diff --git a/grafast/grafast/src/engine/executeBucket.ts b/grafast/grafast/src/engine/executeBucket.ts index 0cb89737fd..3da978fcb9 100644 --- a/grafast/grafast/src/engine/executeBucket.ts +++ b/grafast/grafast/src/engine/executeBucket.ts @@ -20,6 +20,7 @@ import type { ExecuteStepEvent, ExecutionDetails, ExecutionDetailsStream, + ExecutionDetailsValues, ExecutionEntryFlags, ExecutionExtra, ExecutionResults, @@ -830,7 +831,9 @@ export function executeBucket( indexMap: makeIndexMap(count), indexForEach: makeIndexForEach(count), count, - values, + values: Object.assign(values, { + get: values.at as ExecutionDetailsValues["get"], + }), extra, stream: evaluateStream(bucket, step, distributorOptions), }; diff --git a/grafast/grafast/src/interfaces.ts b/grafast/grafast/src/interfaces.ts index 16e2d6b632..efc6400b7f 100644 --- a/grafast/grafast/src/interfaces.ts +++ b/grafast/grafast/src/interfaces.ts @@ -720,6 +720,16 @@ export interface ExecutionDetailsStream { initialCount: number; } +type TupleIndicies = { + [K in keyof T]: K extends `${infer N extends number}` ? N : never; +}[keyof T]; +export type ExecutionDetailsValues< + TDeps extends readonly [...any[]] = readonly [...any[]], +> = { [TKey in keyof TDeps]: ExecutionValue } & { + get>( + idx: TKey, + ): ExecutionValue; +}; export interface ExecutionDetails< TDeps extends readonly [...any[]] = readonly [...any[]], > { @@ -727,12 +737,7 @@ export interface ExecutionDetails< count: number; /** An "execution value" for each dependency of the step */ - values: { - [DepIdx in keyof TDeps]: ExecutionValue; - } & { - length: TDeps["length"]; - map: ReadonlyArray>["map"]; - }; + values: ExecutionDetailsValues; /** Helper; makes array from `callback(batchIndex)` for each `0 <= batchIndex < count` */ indexMap: IndexMap; diff --git a/grafast/grafast/src/steps/listTransform.ts b/grafast/grafast/src/steps/listTransform.ts index 01066e23a2..5c0e164ed4 100644 --- a/grafast/grafast/src/steps/listTransform.ts +++ b/grafast/grafast/src/steps/listTransform.ts @@ -253,7 +253,7 @@ export class __ListTransformStep< ); } - const listStepValue = values[this.listStepDepId]; + const listStepValue = values[this.listStepDepId as 0]; if (itemStep._isUnary) { const list = listStepValue.unaryValue(); diff --git a/grafast/grafast/src/steps/listen.ts b/grafast/grafast/src/steps/listen.ts index 4ffa0a0a3d..7766d4b073 100644 --- a/grafast/grafast/src/steps/listen.ts +++ b/grafast/grafast/src/steps/listen.ts @@ -68,7 +68,7 @@ export class ListenStep< values, stream, }: ExecutionDetails< - readonly [GrafastSubscriber, TTopic] + readonly [GrafastSubscriber, TTopic, TTopics[TTopic] | undefined] >): GrafastResultStreamList { if (!stream) { throw new Error("ListenStep must be streamed, never merely executed"); @@ -76,7 +76,7 @@ export class ListenStep< const pubsubValue = values[this.pubsubDep as 0]; const topicValue = values[this.topicDep as 1]; const initialEventValue = - this.initialEventDep !== null ? values[this.initialEventDep] : null; + this.initialEventDep !== null ? values[this.initialEventDep as 2] : null; return indexMap((i) => { const pubsub = pubsubValue.at(i); if (!pubsub) {