export type RuntimeSheetSessionScope = { baseUrl: string; executorToken: string; orgId: string; preloadedDbSessions?: TPreloadedSession[] | null; playName: string; runId: string; userEmail?: string | null; }; function requireRuntimeSheetSessionField( fieldName: string, value: string, ): string { const trimmed = value.trim(); if (!trimmed) { throw new Error(`Runtime Sheet Session requires ${fieldName}.`); } return trimmed; } export function runtimeSheetSessionScope(input: { baseUrl: string; executorToken: string; orgId: string; preloadedDbSessions?: TPreloadedSession[] | null; playName: string; runId: string; userEmail?: string | null; }): RuntimeSheetSessionScope { return { baseUrl: requireRuntimeSheetSessionField('baseUrl', input.baseUrl), executorToken: requireRuntimeSheetSessionField( 'executorToken', input.executorToken, ), orgId: requireRuntimeSheetSessionField('orgId', input.orgId), preloadedDbSessions: input.preloadedDbSessions ?? null, playName: requireRuntimeSheetSessionField('playName', input.playName), runId: requireRuntimeSheetSessionField('runId', input.runId), userEmail: input.userEmail ?? null, }; }