|
1 | 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
2 | 2 |
|
3 | 3 | import type { RequestInit, RequestInfo, BodyInit } from './internal/builtin-types'; |
4 | | -import type { HTTPMethod, PromiseOrValue, MergedRequestInit } from './internal/types'; |
| 4 | +import type { HTTPMethod, PromiseOrValue, MergedRequestInit, FinalizedRequestInit } from './internal/types'; |
5 | 5 | import { uuid4 } from './internal/utils/uuid'; |
6 | | -import { validatePositiveInteger, isAbsoluteURL, hasOwn } from './internal/utils/values'; |
| 6 | +import { validatePositiveInteger, isAbsoluteURL, safeJSON } from './internal/utils/values'; |
7 | 7 | import { sleep } from './internal/utils/sleep'; |
| 8 | +import { type Logger, type LogLevel, parseLogLevel } from './internal/utils/log'; |
| 9 | +export type { Logger, LogLevel } from './internal/utils/log'; |
8 | 10 | import { castToError, isAbortError } from './internal/errors'; |
9 | 11 | import type { APIResponseProps } from './internal/parse'; |
10 | 12 | import { getPlatformHeaders } from './internal/detect-platform'; |
@@ -235,48 +237,6 @@ import { |
235 | 237 | Users, |
236 | 238 | } from './resources/users/users'; |
237 | 239 |
|
238 | | -const safeJSON = (text: string) => { |
239 | | - try { |
240 | | - return JSON.parse(text); |
241 | | - } catch (err) { |
242 | | - return undefined; |
243 | | - } |
244 | | -}; |
245 | | - |
246 | | -type LogFn = (message: string, ...rest: unknown[]) => void; |
247 | | -export type Logger = { |
248 | | - error: LogFn; |
249 | | - warn: LogFn; |
250 | | - info: LogFn; |
251 | | - debug: LogFn; |
252 | | -}; |
253 | | -export type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug'; |
254 | | -const parseLogLevel = ( |
255 | | - maybeLevel: string | undefined, |
256 | | - sourceName: string, |
257 | | - client: Gitpod, |
258 | | -): LogLevel | undefined => { |
259 | | - if (!maybeLevel) { |
260 | | - return undefined; |
261 | | - } |
262 | | - const levels: Record<LogLevel, true> = { |
263 | | - off: true, |
264 | | - error: true, |
265 | | - warn: true, |
266 | | - info: true, |
267 | | - debug: true, |
268 | | - }; |
269 | | - if (hasOwn(levels, maybeLevel)) { |
270 | | - return maybeLevel; |
271 | | - } |
272 | | - loggerFor(client).warn( |
273 | | - `${sourceName} was set to ${JSON.stringify(maybeLevel)}, expected one of ${JSON.stringify( |
274 | | - Object.keys(levels), |
275 | | - )}`, |
276 | | - ); |
277 | | - return undefined; |
278 | | -}; |
279 | | - |
280 | 240 | export interface ClientOptions { |
281 | 241 | /** |
282 | 242 | * Defaults to process.env['GITPOD_API_KEY']. |
@@ -350,8 +310,6 @@ export interface ClientOptions { |
350 | 310 | logger?: Logger | undefined; |
351 | 311 | } |
352 | 312 |
|
353 | | -type FinalizedRequestInit = RequestInit & { headers: Headers }; |
354 | | - |
355 | 313 | /** |
356 | 314 | * API Client for interfacing with the Gitpod API. |
357 | 315 | */ |
|
0 commit comments