Thanks to visit codestin.com
Credit goes to effect-ts.github.io

Skip to main content Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App Codestin Search App

RpcGroup.ts overview

Since v1.0.0


Exports Grouped by Category


groups

Any (interface)

Signature

export interface Any {
  readonly [TypeId]: TypeId
}

Source

Since v1.0.0

HandlerContext (type alias)

Signature

type HandlerContext<Rpcs, K, Handler> = [Rpc.IsStream<Rpcs, K>] extends [true]
  ? Handler extends (
      ...args: any
    ) =>
      | Stream.Stream<infer _A, infer _E, infer _R>
      | Rpc.Wrapper<Stream.Stream<infer _A, infer _E, infer _R>>
      | Effect.Effect<ReadonlyMailbox<infer _A, infer _E>, infer _EX, infer _R>
      | Rpc.Wrapper<Effect.Effect<ReadonlyMailbox<infer _A, infer _E>, infer _EX, infer _R>>
    ? Exclude<Rpc.ExcludeProvides<_R, Rpcs, K>, Scope>
    : never
  : Handler extends (
        ...args: any
      ) => Effect.Effect<infer _A, infer _E, infer _R> | Rpc.Wrapper<Effect.Effect<infer _A, infer _E, infer _R>>
    ? Rpc.ExcludeProvides<_R, Rpcs, K>
    : never

Source

Since v1.0.0

HandlerFrom (type alias)

Signature

type HandlerFrom<Rpc, Tag> =
  Extract<Rpc, { readonly _tag: Tag }> extends infer Current
    ? Current extends Rpc.Any
      ? Rpc.ToHandlerFn<Current>
      : never
    : never

Source

Since v1.0.0

HandlersContext (type alias)

Signature

type HandlersContext<Rpcs, Handlers> = keyof Handlers extends infer K
  ? K extends keyof Handlers & string
    ? HandlerContext<Rpcs, K, Handlers[K]>
    : never
  : never

Source

Since v1.0.0

HandlersFrom (type alias)

Signature

type HandlersFrom<Rpc> = {
  readonly [Current in Rpc as Current["_tag"]]: Rpc.ToHandlerFn<Current>
}

Source

Since v1.0.0

RpcGroup (interface)

Signature

export interface RpcGroup<in out R extends Rpc.Any> extends Pipeable {
  new (_: never): {}

  readonly [TypeId]: TypeId
  readonly requests: ReadonlyMap<string, R>
  readonly annotations: Context.Context<never>

  /**
   * Add one or more procedures to the group.
   */
  add<const Rpcs2 extends ReadonlyArray<Rpc.Any>>(...rpcs: Rpcs2): RpcGroup<R | Rpcs2[number]>

  /**
   * Merge this group with one or more other groups.
   */
  merge<const Groups extends ReadonlyArray<Any>>(...groups: Groups): RpcGroup<R | Rpcs<Groups[number]>>

  /**
   * Add middleware to all the procedures added to the group until this point.
   */
  middleware<M extends RpcMiddleware.TagClassAny>(middleware: M): RpcGroup<Rpc.AddMiddleware<R, M>>

  /**
   * Add a prefix to the procedures in this group, returning a new group
   */
  prefix<const Prefix extends string>(prefix: Prefix): RpcGroup<Rpc.Prefixed<R, Prefix>>

  /**
   * Implement the handlers for the procedures in this group, returning a
   * context object.
   */
  toHandlersContext<Handlers extends HandlersFrom<R>, EX = never, RX = never>(
    build: Handlers | Effect.Effect<Handlers, EX, RX>
  ): Effect.Effect<Context.Context<Rpc.ToHandler<R>>, EX, RX | HandlersContext<R, Handlers>>

  /**
   * Implement the handlers for the procedures in this group.
   */
  toLayer<Handlers extends HandlersFrom<R>, EX = never, RX = never>(
    build: Handlers | Effect.Effect<Handlers, EX, RX>
  ): Layer.Layer<Rpc.ToHandler<R>, EX, Exclude<RX, Scope> | HandlersContext<R, Handlers>>

  of<const Handlers extends HandlersFrom<R>>(handlers: Handlers): Handlers

  /**
   * Implement a single handler from the group.
   */
  toLayerHandler<const Tag extends R["_tag"], Handler extends HandlerFrom<R, Tag>, EX = never, RX = never>(
    tag: Tag,
    build: Handler | Effect.Effect<Handler, EX, RX>
  ): Layer.Layer<Rpc.Handler<Tag>, EX, Exclude<RX, Scope> | HandlerContext<R, Tag, Handler>>

  /**
   * Retrieve a handler for a specific procedure in the group.
   */
  accessHandler<const Tag extends R["_tag"]>(
    tag: Tag
  ): Effect.Effect<
    (
      payload: Rpc.Payload<Extract<R, { readonly _tag: Tag }>>,
      headers: Headers
    ) => Rpc.ResultFrom<Extract<R, { readonly _tag: Tag }>, never>,
    never,
    Rpc.Handler<Tag>
  >

  /**
   * Annotate the group with a value.
   */
  annotate<I, S>(tag: Context.Tag<I, S>, value: S): RpcGroup<R>

  /**
   * Annotate the Rpc's above this point with a value.
   */
  annotateRpcs<I, S>(tag: Context.Tag<I, S>, value: S): RpcGroup<R>

  /**
   * Annotate the group with a context object.
   */
  annotateContext<S>(context: Context.Context<S>): RpcGroup<R>

  /**
   * Annotate the Rpc's above this point with a context object.
   */
  annotateRpcsContext<S>(context: Context.Context<S>): RpcGroup<R>
}

Source

Since v1.0.0

Rpcs (type alias)

Signature

type Rpcs<Group> = Group extends RpcGroup<infer R> ? (string extends R["_tag"] ? never : R) : never

Source

Since v1.0.0

make

Signature

declare const make: <const Rpcs extends ReadonlyArray<Rpc.Any>>(...rpcs: Rpcs) => RpcGroup<Rpcs[number]>

Source

Since v1.0.0

type ids

TypeId

Signature

declare const TypeId: unique symbol

Source

Since v1.0.0

TypeId (type alias)

Signature

type TypeId = typeof TypeId

Source

Since v1.0.0