()
| 59 | }; |
| 60 | |
| 61 | async run(): Promise<void> { |
| 62 | const { args, flags } = await this.parse(Fetch); |
| 63 | const format = flags.format as FetchFormat; |
| 64 | const schema = resolveFetchSchema(format, flags.schema); |
| 65 | const client = createBrowserbaseClient(toApiOptions(flags)); |
| 66 | const result = await withBrowserbaseApi( |
| 67 | "fetch", |
| 68 | async () => |
| 69 | await client.fetchAPI.create({ |
| 70 | url: args.url, |
| 71 | allowInsecureSsl: flags["allow-insecure-ssl"], |
| 72 | allowRedirects: flags["allow-redirects"], |
| 73 | format, |
| 74 | proxies: flags.proxies, |
| 75 | schema, |
| 76 | }), |
| 77 | ); |
| 78 | |
| 79 | if (flags.output) { |
| 80 | const contents = stringifyFetchContent(result.content); |
| 81 | await writeOutputFile(flags.output, contents); |
| 82 | outputJson({ |
| 83 | ok: true, |
| 84 | outputPath: flags.output, |
| 85 | contentType: result.contentType, |
| 86 | statusCode: result.statusCode, |
| 87 | sizeBytes: Buffer.byteLength(contents, "utf8"), |
| 88 | }); |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | outputJson(result); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | function resolveFetchSchema( |
nothing calls this directly
no test coverage detected