import type { TRPCError } from "@trpc/server" import { Data, type Effect, type Runtime } from "effect" import type { RuntimeFiber } from "effect/Fiber" import type express from "express" import type { IncomingMessage } from "node:http" import type { WebSocket } from "ws" export interface TRPCContext { readonly runtime: Runtime.Runtime readonly run: ( effect: Effect.Effect, options?: { readonly signal?: AbortSignal }, ) => Promise readonly fork: ( effect: Effect.Effect, options?: Runtime.RunForkOptions, ) => RuntimeFiber readonly transaction: TRPCContextTransaction } export type TRPCContextTransaction = Data.TaggedEnum<{ readonly Express: { readonly req: express.Request readonly res: express.Response } readonly WebSocket: { readonly req: IncomingMessage readonly res: WebSocket } }> export const TRPCContextTransactionEnum = Data.taggedEnum()