From 53288562ca323cc702ef3a8d728e6a810ec19845 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 27 Aug 2026 12:19:16 +0800 Subject: [PATCH] refactor(google-meet): share token source resolution (#130423) --- .../google-meet/src/cli-artifact-commands.ts | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/extensions/google-meet/src/cli-artifact-commands.ts b/extensions/google-meet/src/cli-artifact-commands.ts index 9dad9cab9132..bcd1fa83988b 100644 --- a/extensions/google-meet/src/cli-artifact-commands.ts +++ b/extensions/google-meet/src/cli-artifact-commands.ts @@ -38,6 +38,10 @@ async function resolveCliArtifactQuery( }; } +function resolveTokenSource(refreshed: boolean) { + return refreshed ? "refresh-token" : "cached-access-token"; +} + export function registerGoogleMeetArtifactCommands(context: GoogleMeetCliCommandContext): void { const params = context; const { root } = context; @@ -61,7 +65,7 @@ export function registerGoogleMeetArtifactCommands(context: GoogleMeetCliCommand JSON.stringify( { ...result, - tokenSource: resolved.token.refreshed ? "refresh-token" : "cached-access-token", + tokenSource: resolveTokenSource(resolved.token.refreshed), }, null, 2, @@ -77,10 +81,7 @@ export function registerGoogleMeetArtifactCommands(context: GoogleMeetCliCommand throw new Error("Unsupported format. Expected summary or markdown."); } writeArtifactsSummary(result); - writeStdoutLine( - "token source: %s", - resolved.token.refreshed ? "refresh-token" : "cached-access-token", - ); + writeStdoutLine("token source: %s", resolveTokenSource(resolved.token.refreshed)); }); addGoogleMeetArtifactOptions( @@ -101,7 +102,7 @@ export function registerGoogleMeetArtifactCommands(context: GoogleMeetCliCommand JSON.stringify( { ...result, - tokenSource: resolved.token.refreshed ? "refresh-token" : "cached-access-token", + tokenSource: resolveTokenSource(resolved.token.refreshed), }, null, 2, @@ -121,10 +122,7 @@ export function registerGoogleMeetArtifactCommands(context: GoogleMeetCliCommand throw new Error("Unsupported format. Expected summary, markdown, or csv."); } writeAttendanceSummary(result); - writeStdoutLine( - "token source: %s", - resolved.token.refreshed ? "refresh-token" : "cached-access-token", - ); + writeStdoutLine("token source: %s", resolveTokenSource(resolved.token.refreshed)); }); addGoogleMeetArtifactOptions( @@ -175,11 +173,11 @@ export function registerGoogleMeetArtifactCommands(context: GoogleMeetCliCommand attendance, files: googleMeetExportFileNames(), request, - tokenSource: resolved.token.refreshed ? "refresh-token" : "cached-access-token", + tokenSource: resolveTokenSource(resolved.token.refreshed), ...(resolved.calendarEvent ? { calendarEvent: resolved.calendarEvent } : {}), }), ...(resolved.calendarEvent ? { calendarEvent: resolved.calendarEvent } : {}), - tokenSource: resolved.token.refreshed ? "refresh-token" : "cached-access-token", + tokenSource: resolveTokenSource(resolved.token.refreshed), }); return; } @@ -189,13 +187,13 @@ export function registerGoogleMeetArtifactCommands(context: GoogleMeetCliCommand attendance, zip: Boolean(options.zip), request, - tokenSource: resolved.token.refreshed ? "refresh-token" : "cached-access-token", + tokenSource: resolveTokenSource(resolved.token.refreshed), ...(resolved.calendarEvent ? { calendarEvent: resolved.calendarEvent } : {}), }); const payload = { ...bundle, ...(resolved.calendarEvent ? { calendarEvent: resolved.calendarEvent } : {}), - tokenSource: resolved.token.refreshed ? "refresh-token" : "cached-access-token", + tokenSource: resolveTokenSource(resolved.token.refreshed), }; if (options.json) { writeStdoutJson(payload);