Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"pnpm": {
"overrides": {
"form-data": ">=4.0.4",
"hono": ">=4.11.10",
"hono": ">=4.12.2",
"jws": ">=4.0.1",
"tar-fs": ">=2.1.4",
"lodash": ">=4.17.23"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"@prisma/generator": "workspace:*",
"@prisma/get-platform": "workspace:*",
"@prisma/internals": "workspace:*",
"@prisma/management-api-sdk": "0.2.0",
"@prisma/management-api-sdk": "1.12.0",
"@prisma/migrate": "workspace:*",
"@swc/core": "1.11.5",
"@swc/jest": "0.2.37",
Expand All @@ -143,7 +143,7 @@
"fs-extra": "11.3.0",
"get-port-please": "3.2.0",
"get-tsconfig": "4.10.0",
"hono": "4.11.7",
"hono": "4.12.3",
"jest": "29.7.0",
"jest-junit": "16.0.0",
"kleur": "4.1.5",
Expand Down
15 changes: 9 additions & 6 deletions packages/cli/src/Init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,15 +544,18 @@ export class Init implements Command {
throw new Error('Missing database info in response')
}

if (!project.database.directConnection) {
// This should never happen: OpenAPI types are not entirely correct,
// `directConnection` is not independently nullable and must always
// be present if `database` is in the response body.
const connection = project.database.connections?.find(
(c) => Boolean(c.endpoints?.direct?.connectionString) || Boolean(c.endpoints?.pooled?.connectionString),
)

const connectionString =
connection?.endpoints?.direct?.connectionString ?? connection?.endpoints?.pooled?.connectionString

if (!connectionString) {
throw new Error('Missing connection string in response')
}

const { host, user, pass } = project.database.directConnection
prismaPostgresDatabaseUrl = `postgres://${user}:${pass}@${host}/postgres?sslmode=require`
prismaPostgresDatabaseUrl = connectionString

workspaceId = project.workspace.id.replace(/^wksp_/, '')
projectId = project.id.replace(/^proj_/, '')
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/management-api/auth-client.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { ManagementAPI } from '@prisma/management-api-sdk'
import { createManagementAPI } from '@prisma/management-api-sdk'
import type { ManagementApiSdk } from '@prisma/management-api-sdk'
import { createManagementApiSdk } from '@prisma/management-api-sdk'

import { FileTokenStorage } from './token-storage'

const CLIENT_ID = 'cmi4ttoor03pv2wco4526rnin'

export function createAuthenticatedManagementAPI(): ManagementAPI {
export function createAuthenticatedManagementAPI(): ManagementApiSdk {
const tokenStorage = new FileTokenStorage()

return createManagementAPI({
return createManagementApiSdk({
clientId: CLIENT_ID,
redirectUri: 'http://localhost:0/auth/callback', // Not used when tokens already exist
redirectUri: 'http://localhost:0/auth/callback',
tokenStorage,
})
}
8 changes: 4 additions & 4 deletions packages/cli/src/management-api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import events from 'node:events'
import http from 'node:http'
import { AddressInfo } from 'node:net'

import type { ManagementAPI } from '@prisma/management-api-sdk'
import { AuthError as SDKAuthError, createManagementAPI } from '@prisma/management-api-sdk'
import type { ManagementApiSdk } from '@prisma/management-api-sdk'
import { AuthError as SDKAuthError, createManagementApiSdk } from '@prisma/management-api-sdk'
import open from 'open'

import { FileTokenStorage } from './token-storage'
Expand Down Expand Up @@ -71,7 +71,7 @@ export async function login(options: LoginOptions): Promise<void> {
export class LoginState {
private latestVerifier?: string
private latestState?: string
private managementAPI: ManagementAPI
private managementAPI: ManagementApiSdk
private tokenStorage: FileTokenStorage

constructor(
Expand All @@ -80,7 +80,7 @@ export class LoginState {
private utmMedium: string,
) {
this.tokenStorage = new FileTokenStorage()
this.managementAPI = createManagementAPI({
this.managementAPI = createManagementApiSdk({
clientId: CLIENT_ID,
redirectUri: `http://${hostname}:${port}/auth/callback`,
tokenStorage: this.tokenStorage,
Expand Down
56 changes: 28 additions & 28 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading