MCPcopy
hub / github.com/prisma/prisma / resolveApiClient

Function resolveApiClient

packages/cli/src/postgres/link/Link.ts:46–60  ·  view source on GitHub ↗
(apiKey: string | undefined)

Source from the content-addressed store, hash-verified

44}
45
46async function resolveApiClient(apiKey: string | undefined): Promise<ManagementApiClient> {
47 if (apiKey) {
48 return createManagementApiClient({ baseUrl: getManagementApiUrl(), token: apiKey })
49 }
50
51 const tokenStorage = new FileTokenStorage()
52 const tokens = await tokenStorage.getTokens()
53
54 if (!tokens) {
55 console.log(`Opening browser to authenticate on ${dim('console.prisma.io')}...`)
56 await login({ utmMedium: 'command-postgres-link' })
57 }
58
59 return createAuthenticatedManagementAPI().client
60}
61
62function isExpiredSessionError(err: unknown): boolean {
63 return err instanceof AuthError && err.refreshTokenInvalid

Callers 1

executeLinkFlowMethod · 0.85

Calls 5

getTokensMethod · 0.95
loginFunction · 0.90
getManagementApiUrlFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected