Skip to content

OutputCollector

Defined in: src/types.ts:344

Accumulates output batches during a produce/exchange call. Enforces that exactly one data batch is emitted per call (plus any number of log batches).

new OutputCollector(
outputSchema,
producerMode?,
serverId?,
requestId?,
authContext?,
cookies?,
kind?,
budgets?): OutputCollector;

Defined in: src/types.ts:364

ParameterTypeDefault valueDescription
outputSchemaVgiSchemaundefined-
producerModebooleantrue-
serverIdstring""-
requestIdstring | nullnull-
authContext?AuthContextundefined-
cookies?ReadonlyMap<string, string>undefined-
kind?TransportKindundefined-
budgets?{ externalizationEnabled?: boolean; remainingExternalizedResponseBytes?: number; remainingResponseBytes?: number; }undefinedSnapshot budget fields exposed to worker code via CallContext. Optional — non-HTTP transports omit them and existing call sites remain source-compatible.
budgets.externalizationEnabled?booleanundefined-
budgets.remainingExternalizedResponseBytes?numberundefined-
budgets.remainingResponseBytes?numberundefined-

OutputCollector

readonly auth: AuthContext;

Defined in: src/types.ts:357

Authenticated principal for this call; AuthContext.anonymous when the request was not authenticated.

CallContext.auth


readonly cookies: ReadonlyMap<string, string>;

Defined in: src/types.ts:358

Incoming request cookies. Empty for non-HTTP transports.

CallContext.cookies


readonly optional externalizationEnabled?: boolean;

Defined in: src/types.ts:362

True iff the server has an externalisation backend wired up.

CallContext.externalizationEnabled


readonly optional kind?: TransportKind;

Defined in: src/types.ts:359

Coarse identifier of the bound transport, or undefined until the server begins serving (the value is committed by the lifecycle hook on the very first request).

CallContext.kind


readonly optional remainingExternalizedResponseBytes?: number;

Defined in: src/types.ts:361

External-channel bytes left this iteration. Always a hard cap — externalised uploads have no escape valve like producer continuation tokens. Undefined when no cap is configured or externalisation is disabled.

CallContext.remainingExternalizedResponseBytes


readonly optional remainingResponseBytes?: number;

Defined in: src/types.ts:360

Wire body bytes the framework will accept this iteration before triggering a continuation token (producer streams) or strict-fail with an EXCEPTION batch (unary / stream-exchange). Snapshot at collector construction; not live. undefined when no cap is configured or the transport doesn’t expose one (stdio).

CallContext.remainingResponseBytes

get batches(): EmittedBatch[];

Defined in: src/types.ts:488

Batches emitted so far this call — the single data batch plus any log batches, in emission order. Consumed by the dispatch layer.

EmittedBatch[]


get finished(): boolean;

Defined in: src/types.ts:482

True once finish has been called (producer streams only).

boolean


get outputSchema(): VgiSchema;

Defined in: src/types.ts:477

Schema of the data batches this collector emits.

VgiSchema


get session(): unknown;

Defined in: src/types.ts:440

Live sticky-session state object, or null when no session is bound to this request. HTTP-only — other transports always return null.

unknown

Live sticky-session state object, or null when no session is bound to this request. HTTP-only — other transports always return null.

CallContext.session


get sessionId(): string | null;

Defined in: src/types.ts:444

Opaque 24-char-hex session ID, or null when no session is bound. Survives closeSession so post-close access-log records still carry the id.

string | null

Opaque 24-char-hex session ID, or null when no session is bound. Survives closeSession so post-close access-log records still carry the id.

CallContext.sessionId

clientLog(
level,
message,
extra?): void;

Defined in: src/types.ts:537

Emit a zero-row client-directed log batch.

ParameterType
levelstring
messagestring
extra?Record<string, string>

void

CallContext.clientLog


closeSession(): void;

Defined in: src/types.ts:467

Invalidate the sticky session bound to this request. Idempotent.

void

CallContext.closeSession


deleteCookie(name, opts?): void;

Defined in: src/types.ts:423

Queue an unset-cookie directive on the HTTP response. Only valid inside a unary RPC method served over HTTP; throws otherwise.

ParameterType
namestring
opts?{ domain?: string; path?: string; }
opts.domain?string
opts.path?string

void

CallContext.deleteCookie


emit(batch, metadata?): void;

Defined in: src/types.ts:493

Emit a pre-built batch as the data batch for this call.

ParameterType
batchVgiBatch
metadata?Map<string, string>

void

emit(columns): void;

Defined in: src/types.ts:495

Emit a data batch from column arrays keyed by field name. Int64 Number values are coerced to BigInt.

ParameterType
columnsRecord<string, any[]>

void


emitRow(values): void;

Defined in: src/types.ts:518

Single-row convenience. Wraps each value in [value] then calls emit().

ParameterType
valuesRecord<string, any>

void


finish(): void;

Defined in: src/types.ts:527

Signal stream completion for producer streams. Throws if called on exchange streams.

void


openSession(state, ttl?): void;

Defined in: src/types.ts:448

Register a sticky session holding state for subsequent requests on this transport. HTTP-only — throws on other transports, on calls without the VGI-Session-Accept: true opt-in header, or when a session is already bound to this request.

ParameterType
stateunknown
ttl?number

void

CallContext.openSession


setCookie(
name,
value,
attrs?): void;

Defined in: src/types.ts:413

Queue a Set-Cookie header on the HTTP response. Only valid inside a unary RPC method served over HTTP; throws otherwise.

ParameterType
namestring
valuestring
attrs?CookieAttrs

void

CallContext.setCookie