Skip to main content
Version: Current

TrpcOptions

@rotorsoft/act-root


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

Type Alias: TrpcOptions<Ctx, TApp>

TrpcOptions<Ctx, TApp> = object

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

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 leaves the call to the version the action loads; a number pins it, and a pinned conflict is never retried.
  • 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). A duplicate of a key that already succeeded 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. A duplicate that arrives while the original is still running throws a retryable SERVICE_UNAVAILABLE (503) instead: the original may yet fail and release the key, and a client told "already used" would never retry.

Type Parameters​

Ctx​

Ctx

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

TApp​

TApp = ActSurface

Properties​

actor​

readonly actor: ActorExtractor<Ctx>

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


expectedVersion?​

readonly optional expectedVersion?: (...args) => number | undefined | Promise<number | undefined>

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

Parameters​

args​

...ResolverArgs<TApp, NoInfer<Ctx>>

Returns​

number | undefined | Promise<number | undefined>


idempotency?​

readonly optional idempotency?: object

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

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:148

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: (...args) => string | Promise<string>

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

Parameters​

args​

...ResolverArgs<TApp, NoInfer<Ctx>>

Returns​

string | Promise<string>