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 extends TRPCContextRuntime, TRPCContextTransaction {} export interface TRPCContextRuntime { readonly runtime: Runtime.Runtime readonly run: ( effect: Effect.Effect, options?: { readonly signal?: AbortSignal }, ) => Promise readonly fork: ( effect: Effect.Effect, options?: Runtime.RunForkOptions, ) => RuntimeFiber } export interface TRPCContextTransaction { readonly transaction: TRPCTransaction } export type TRPCTransaction = Data.TaggedEnum<{ readonly Express: { readonly req: express.Request readonly res: express.Response } readonly WebSocket: { readonly req: IncomingMessage readonly res: WebSocket } }> export const TRPCTransactionEnum = Data.taggedEnum()