@@ -6,19 +6,18 @@ import { interactForCommandSelection } from "./lib/interact-for-command-selectio
66import parseArgs , { ParsedArgs } from "minimist"
77import { interactForLogin } from "./lib/interact-for-login"
88import { interactForWorkspaceId } from "./lib/interact-for-workspace-id"
9- import { getSeam } from "./lib/get-seam"
109import chalk from "chalk"
1110import { interactForServerSelection } from "./lib/interact-for-server-selection"
1211import { getServer } from "./lib/get-server"
1312import prompts from "prompts"
14- import logResponse from "./lib/util/log-response"
1513import { getApiDefinitions } from "./lib/get-api-definitions"
1614import commandLineUsage from "command-line-usage"
1715import { ContextHelpers } from "./lib/types"
1816import { version } from "./package.json"
1917import { interactForUseRemoteApiDefs } from "./lib/interact-for-use-remote-api-defs"
2018import { randomBytes } from "node:crypto"
2119import { interactForActionAttemptPoll } from "./lib/interact-for-action-attempt-poll"
20+ import { RequestSeamApi } from "./lib/util/request-seam-api"
2221
2322const sections = [
2423 {
@@ -177,6 +176,13 @@ async function cli(args: ParsedArgs) {
177176 return
178177 }
179178 await interactForServerSelection ( )
179+ return
180+ } else if ( isEqual ( selectedCommand , [ "health" , "get-health" ] ) ) {
181+ await RequestSeamApi ( {
182+ path : "/health/get_health" ,
183+ params : { } ,
184+ } )
185+
180186 return
181187 }
182188 // TODO - do this using the OpenAPI spec for the command rather than
@@ -209,55 +215,42 @@ async function cli(args: ParsedArgs) {
209215 } )
210216 }
211217
212- const seam = await getSeam ( )
213-
214218 const apiPath = `/${ selectedCommand . join ( "/" ) . replace ( / - / g, "_" ) } `
215219
216220 if ( apiPath . includes ( "/events/list" ) && params . between ) {
217221 delete params . since
218222 }
219223
220- console . log ( `\n\n${ chalk . green ( apiPath ) } ` )
221- console . log ( `Request Params:` )
222- console . log ( params )
223-
224- const response = await seam . client . post ( apiPath , params , {
225- validateStatus : ( ) => true ,
224+ const response = await RequestSeamApi ( {
225+ path : apiPath ,
226+ params,
226227 } )
227228
228- logResponse ( response )
229+ if ( response . data ?. connect_webview ) {
230+ await handleConnectWebviewResponse ( response . data . connect_webview )
231+ }
232+
233+ if ( response . data ?. action_attempt ) {
234+ interactForActionAttemptPoll ( response . data . action_attempt )
235+ }
236+ }
229237
230- if ( response . data . connect_webview ) {
231- if (
232- response . data &&
233- response . data . connect_webview &&
234- response . data . connect_webview . url
235- ) {
236- const url = response . data . connect_webview . url
238+ const handleConnectWebviewResponse = async ( connect_webview : any ) => {
239+ const url = connect_webview . url
237240
238- if ( process . env . INSIDE_WEB_BROWSER !== "1" ) {
239- const { action } = await prompts ( {
240- type : "confirm" ,
241- name : "action" ,
242- message : "Would you like to open the webview in your browser?" ,
243- } )
241+ if ( process . env . INSIDE_WEB_BROWSER !== "1" ) {
242+ const { action } = await prompts ( {
243+ type : "confirm" ,
244+ name : "action" ,
245+ message : "Would you like to open the webview in your browser?" ,
246+ } )
244247
245- if ( action ) {
246- const { default : open } = await import ( "open" )
247- await open ( url )
248- }
249- } else {
250- //TODO: Figure out how to open the webview in the browser
251- }
248+ if ( action ) {
249+ const { default : open } = await import ( "open" )
250+ await open ( url )
252251 }
253- }
254-
255- if (
256- response . data &&
257- typeof response . data === "object" &&
258- "action_attempt" in response . data
259- ) {
260- interactForActionAttemptPoll ( response . data . action_attempt )
252+ } else {
253+ //TODO: Figure out how to open the webview in the browser
261254 }
262255}
263256
0 commit comments