From 5cffe02849853521a2058a631e5d6aa1dd730e4a Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Wed, 8 Jul 2026 11:17:11 +0100 Subject: [PATCH 1/3] Fix values type --- grafast/grafast/src/interfaces.ts | 6 +++++- grafast/grafast/src/steps/listTransform.ts | 2 +- grafast/grafast/src/steps/listen.ts | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/grafast/grafast/src/interfaces.ts b/grafast/grafast/src/interfaces.ts index 16e2d6b632..c21d8c8562 100644 --- a/grafast/grafast/src/interfaces.ts +++ b/grafast/grafast/src/interfaces.ts @@ -720,6 +720,9 @@ export interface ExecutionDetailsStream { initialCount: number; } +type TupleIndicies = { + [K in keyof T]: K extends `${infer N extends number}` ? N : never; +}[keyof T]; export interface ExecutionDetails< TDeps extends readonly [...any[]] = readonly [...any[]], > { @@ -728,10 +731,11 @@ export interface ExecutionDetails< /** An "execution value" for each dependency of the step */ values: { - [DepIdx in keyof TDeps]: ExecutionValue; + [DepIdx in TupleIndicies]: ExecutionValue; } & { length: TDeps["length"]; map: ReadonlyArray>["map"]; + [Symbol.iterator](): IterableIterator>; }; /** Helper; makes array from `callback(batchIndex)` for each `0 <= batchIndex < count` */ 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) { From e76c3fc28e3e33b333f0dcb0c0b139646d671325 Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Wed, 8 Jul 2026 12:22:12 +0100 Subject: [PATCH 2/3] Fix values so destructuring works --- grafast/grafast/src/engine/executeBucket.ts | 3 ++- grafast/grafast/src/interfaces.ts | 13 ++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/grafast/grafast/src/engine/executeBucket.ts b/grafast/grafast/src/engine/executeBucket.ts index 0cb89737fd..1dd850f60c 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,7 @@ export function executeBucket( indexMap: makeIndexMap(count), indexForEach: makeIndexForEach(count), count, - values, + values: values as ExecutionDetailsValues, extra, stream: evaluateStream(bucket, step, distributorOptions), }; diff --git a/grafast/grafast/src/interfaces.ts b/grafast/grafast/src/interfaces.ts index c21d8c8562..e0bb9fcf12 100644 --- a/grafast/grafast/src/interfaces.ts +++ b/grafast/grafast/src/interfaces.ts @@ -723,6 +723,11 @@ export interface ExecutionDetailsStream { 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 } & { + at>(idx: TKey): ExecutionValue; +}; export interface ExecutionDetails< TDeps extends readonly [...any[]] = readonly [...any[]], > { @@ -730,13 +735,7 @@ export interface ExecutionDetails< count: number; /** An "execution value" for each dependency of the step */ - values: { - [DepIdx in TupleIndicies]: ExecutionValue; - } & { - length: TDeps["length"]; - map: ReadonlyArray>["map"]; - [Symbol.iterator](): IterableIterator>; - }; + values: ExecutionDetailsValues; /** Helper; makes array from `callback(batchIndex)` for each `0 <= batchIndex < count` */ indexMap: IndexMap; From d9f9f1349904f2d61a536762c5320b8e2c9e3c6f Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Wed, 8 Jul 2026 14:24:57 +0100 Subject: [PATCH 3/3] Can't override 'at', use 'get' --- grafast/grafast/src/engine/executeBucket.ts | 4 +++- grafast/grafast/src/interfaces.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/grafast/grafast/src/engine/executeBucket.ts b/grafast/grafast/src/engine/executeBucket.ts index 1dd850f60c..3da978fcb9 100644 --- a/grafast/grafast/src/engine/executeBucket.ts +++ b/grafast/grafast/src/engine/executeBucket.ts @@ -831,7 +831,9 @@ export function executeBucket( indexMap: makeIndexMap(count), indexForEach: makeIndexForEach(count), count, - values: values as ExecutionDetailsValues, + 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 e0bb9fcf12..efc6400b7f 100644 --- a/grafast/grafast/src/interfaces.ts +++ b/grafast/grafast/src/interfaces.ts @@ -726,7 +726,9 @@ type TupleIndicies = { export type ExecutionDetailsValues< TDeps extends readonly [...any[]] = readonly [...any[]], > = { [TKey in keyof TDeps]: ExecutionValue } & { - at>(idx: TKey): ExecutionValue; + get>( + idx: TKey, + ): ExecutionValue; }; export interface ExecutionDetails< TDeps extends readonly [...any[]] = readonly [...any[]],