Skip to main content

TrpcOptions

@rotorsoft/act-root


@rotorsoft/act-root / act-http/src/trpc / TrpcOptions

Type Alias: TrpcOptions<Ctx>

TrpcOptions<Ctx> = object

Defined in: libs/act-http/src/trpc/index.ts:107

Per-call options for trpc. The host supplies the three seams the package can't make decisions on:

  • actor โ€” auth resolver. Receives the tRPC context, returns the Actor that flows onto ctx.actor for every generated procedure (via an internal authenticated).
  • stream โ€” stream-id resolver. Receives the action name, the validated action input, and the original tRPC context; returns the target stream. Singleton aggregates return a constant; per-tenant aggregates pull from input or context.
  • expectedVersion (optional) โ€” optimistic-concurrency resolver. When set, the procedure threads the resolved value through target.expectedVersion so app.do refuses to commit if the stream has moved. Hosts typically read it from an If-Match header on the underlying HTTP request, or pull it from the client's last-known snapshot. Returning undefined skips the check for that call โ€” handy when only some actions are concurrency-sensitive.
  • idempotency (optional) โ€” when set, the procedure honors Idempotency-Key via the shared withIdempotency helper. The host supplies the IdempotencyStore and a keyFrom extractor that reads the key out of the tRPC context (typically a header). On a duplicate claim, the procedure throws a CONFLICT TRPCError โ€” the receiver-side convention of "ack the duplicate" doesn't carry over because the contract intentionally does not cache the original handler's result.

Type Parametersโ€‹

Ctxโ€‹

Ctx

The host's tRPC context shape. Flows end-to-end โ€” procedures see this exact context type (plus actor) at runtime.

Propertiesโ€‹

actorโ€‹

readonly actor: ActorExtractor

Defined in: libs/act-http/src/trpc/index.ts:108


expectedVersion?โ€‹

readonly optional expectedVersion?: (action_name, input, ctx) => number | undefined | Promise<number | undefined>

Defined in: libs/act-http/src/trpc/index.ts:114

Parametersโ€‹

action_nameโ€‹

string

inputโ€‹

unknown

ctxโ€‹

Ctx

Returnsโ€‹

number | undefined | Promise<number | undefined>


idempotency?โ€‹

readonly optional idempotency?: object

Defined in: libs/act-http/src/trpc/index.ts:119

keyFromโ€‹

readonly keyFrom: (ctx) => string | undefined

Parametersโ€‹
ctxโ€‹

Ctx

Returnsโ€‹

string | undefined

storeโ€‹

readonly store: IdempotencyStore


sse?โ€‹

readonly optional sse?: SseOptions

Defined in: libs/act-http/src/trpc/index.ts:138

Optional SSE wiring. When set, the generator emits one subscription per unique state name in the registry, grouped on the returned router as router.subscribe.<stateName>.useSubscription({ stream }). Each subscription yields { kind: "state", data } once with the cached state (when present) and then { kind: "patch", data } for every patch the shared SseOptions.channel publishes. The per-process connection cap surfaces as a TOO_MANY_REQUESTS TRPCError.

Off by default โ€” most APIs don't expose live state to every client, and opening one is widening both the auth and cost surface.


streamโ€‹

readonly stream: (action_name, input, ctx) => string | Promise<string>

Defined in: libs/act-http/src/trpc/index.ts:109

Parametersโ€‹

action_nameโ€‹

string

inputโ€‹

unknown

ctxโ€‹

Ctx

Returnsโ€‹

string | Promise<string>