| 1 | import * as Effect from "effect/Effect"; |
| 2 | import { PrismaClient, type PrismaManagementClient } from "./Client.ts"; |
| 3 | import * as LogsClient from "./Internal/LogsClient.ts"; |
| 4 | import type { |
| 5 | AppCreateInput, |
| 6 | AppDeploymentTarget, |
| 7 | AppUpdateInput, |
| 8 | BranchCreateInput, |
| 9 | BranchUpdateInput, |
| 10 | BucketCreateInput, |
| 11 | BucketKeyCreateInput, |
| 12 | BuildLogsQuery, |
| 13 | DatabaseConnectionCreateInput, |
| 14 | DeploymentCreateInput, |
| 15 | DeploymentLogsQuery, |
| 16 | ConnectionCreateInput, |
| 17 | CustomDomainCreateInput, |
| 18 | DatabaseCreateInput, |
| 19 | DatabaseUpdateInput, |
| 20 | EnvironmentVariableCreateInput, |
| 21 | EnvironmentVariableUpdateInput, |
| 22 | PrismaBranchIdFilter, |
| 23 | ProjectCreateInput, |
| 24 | ProjectDatabaseCreateInput, |
| 25 | ProjectTransferInput, |
| 26 | ProjectUpdateInput, |
| 27 | RestoreDatabaseInput, |
| 28 | ScmInstallIntentCreateInput, |
| 29 | SourceRepositoryCreateInput, |
| 30 | } from "./Types.ts"; |
| 31 | |
| 32 | const withClient = <A, E, R>( |
| 33 | f: (client: PrismaManagementClient) => Effect.Effect<A, E, R>, |
| 34 | ) => Effect.flatMap(PrismaClient, f); |
| 35 | |
| 36 | export const listWorkspaces = (query?: { |
| 37 | cursor?: string | null; |
| 38 | limit?: number; |
| 39 | }) => withClient((client) => client.listWorkspaces(query)); |
| 40 | export const getWorkspace = (id: string) => |
| 41 | withClient((client) => client.getWorkspace(id)); |
| 42 | export const getCurrentPrincipal = () => |
| 43 | withClient((client) => client.getCurrentPrincipal()); |
| 44 | |
| 45 | export const listRegions = (query?: { product?: "postgres" | "accelerate" }) => |
| 46 | withClient((client) => client.listRegions(query)); |
| 47 | export const listPostgresRegions = () => |
| 48 | withClient((client) => client.listPostgresRegions()); |
| 49 | export const listAccelerateRegions = () => |
| 50 | withClient((client) => client.listAccelerateRegions()); |
| 51 | |
| 52 | export const listProjects = (query?: { |
| 53 | cursor?: string | null; |
| 54 | limit?: number; |
| 55 | }) => withClient((client) => client.listProjects(query)); |
| 56 | export const getProject = (id: string) => |
| 57 | withClient((client) => client.getProject(id)); |
| 58 | export const createProject = (input: ProjectCreateInput) => |
| 59 | withClient((client) => client.createProject(input)); |
| 60 | export const updateProject = (id: string, input: ProjectUpdateInput) => |
| 61 | withClient((client) => client.updateProject(id, input)); |
| 62 | export const deleteProject = (id: string) => |
| 63 | withClient((client) => client.deleteProject(id)); |
| 64 | export const transferProject = (id: string, input: ProjectTransferInput) => |
| 65 | withClient((client) => client.transferProject(id, input)); |
| 66 | |
| 67 | export const listDatabases = (query?: { |
| 68 | cursor?: string | null; |
| 69 | limit?: number; |
| 70 | projectId?: string; |
| 71 | branchId?: PrismaBranchIdFilter; |
| 72 | branchGitName?: string; |
| 73 | }) => withClient((client) => client.listDatabases(query)); |
| 74 | export const listProjectDatabases = ( |
| 75 | projectId: string, |
| 76 | query?: { cursor?: string | null; limit?: number }, |
| 77 | ) => withClient((client) => client.listProjectDatabases(projectId, query)); |
| 78 | export const getDatabase = (id: string) => |
| 79 | withClient((client) => client.getDatabase(id)); |
| 80 | export const createDatabase = (input: DatabaseCreateInput) => |
| 81 | withClient((client) => client.createDatabase(input)); |
| 82 | export const createProjectDatabase = ( |
| 83 | projectId: string, |
| 84 | input: ProjectDatabaseCreateInput, |
| 85 | ) => withClient((client) => client.createProjectDatabase(projectId, input)); |
| 86 | export const updateDatabase = (id: string, input: DatabaseUpdateInput) => |
| 87 | withClient((client) => client.updateDatabase(id, input)); |
| 88 | export const deleteDatabase = (id: string) => |
| 89 | withClient((client) => client.deleteDatabase(id)); |
| 90 | export const listBackups = (databaseId: string, query?: { limit?: number }) => |
| 91 | withClient((client) => client.listBackups(databaseId, query)); |
| 92 | export const restoreDatabase = ( |
| 93 | targetDatabaseId: string, |
| 94 | input: RestoreDatabaseInput, |
| 95 | ) => withClient((client) => client.restoreDatabase(targetDatabaseId, input)); |
| 96 | export const getDatabaseUsage = ( |
| 97 | databaseId: string, |
| 98 | query?: { startDate?: string; endDate?: string }, |
| 99 | ) => withClient((client) => client.getDatabaseUsage(databaseId, query)); |
| 100 | |
| 101 | export const listConnections = (query?: { |
| 102 | cursor?: string | null; |
| 103 | limit?: number; |
| 104 | databaseId?: string; |
| 105 | }) => withClient((client) => client.listConnections(query)); |
| 106 | export const listDatabaseConnections = ( |
| 107 | databaseId: string, |
| 108 | query?: { cursor?: string | null; limit?: number }, |
| 109 | ) => withClient((client) => client.listDatabaseConnections(databaseId, query)); |
| 110 | export const getConnection = (id: string) => |
| 111 | withClient((client) => client.getConnection(id)); |
| 112 | export const createConnection = (input: ConnectionCreateInput) => |
| 113 | withClient((client) => client.createConnection(input)); |
| 114 | export const createDatabaseConnection = ( |
| 115 | databaseId: string, |
| 116 | input: DatabaseConnectionCreateInput, |
| 117 | ) => withClient((client) => client.createDatabaseConnection(databaseId, input)); |
| 118 | export const deleteConnection = (id: string) => |
| 119 | withClient((client) => client.deleteConnection(id)); |
| 120 | export const rotateConnection = (id: string) => |
| 121 | withClient((client) => client.rotateConnection(id)); |
| 122 | |
| 123 | export const listBranches = ( |
| 124 | projectId: string, |
| 125 | query?: { |
| 126 | cursor?: string | null; |
| 127 | limit?: number; |
| 128 | gitName?: string; |
| 129 | gitNameContains?: string; |
| 130 | }, |
| 131 | ) => withClient((client) => client.listBranches(projectId, query)); |
| 132 | export const getBranch = (id: string) => |
| 133 | withClient((client) => client.getBranch(id)); |
| 134 | export const createBranch = (projectId: string, input: BranchCreateInput) => |
| 135 | withClient((client) => client.createBranch(projectId, input)); |
| 136 | export const updateBranch = (id: string, input: BranchUpdateInput) => |
| 137 | withClient((client) => client.updateBranch(id, input)); |
| 138 | export const deleteBranch = (id: string) => |
| 139 | withClient((client) => client.deleteBranch(id)); |
| 140 | |
| 141 | export const listBuckets = (query?: { |
| 142 | cursor?: string | null; |
| 143 | limit?: number; |
| 144 | projectId?: string; |
| 145 | branchId?: PrismaBranchIdFilter; |
| 146 | branchGitName?: string; |
| 147 | }) => withClient((client) => client.listBuckets(query)); |
| 148 | export const getBucket = (id: string) => |
| 149 | withClient((client) => client.getBucket(id)); |
| 150 | export const createBucket = (input: BucketCreateInput) => |
| 151 | withClient((client) => client.createBucket(input)); |
| 152 | export const deleteBucket = (id: string) => |
| 153 | withClient((client) => client.deleteBucket(id)); |
| 154 | export const listBucketKeys = ( |
| 155 | bucketId: string, |
| 156 | query?: { cursor?: string | null; limit?: number }, |
| 157 | ) => withClient((client) => client.listBucketKeys(bucketId, query)); |
| 158 | export const createBucketKey = ( |
| 159 | bucketId: string, |
| 160 | input: BucketKeyCreateInput, |
| 161 | ) => withClient((client) => client.createBucketKey(bucketId, input)); |
| 162 | export const deleteBucketKey = (bucketId: string, keyId: string) => |
| 163 | withClient((client) => client.deleteBucketKey(bucketId, keyId)); |
| 164 | |
| 165 | export const getCustomDomain = (id: string) => |
| 166 | withClient((client) => client.getCustomDomain(id)); |
| 167 | export const deleteCustomDomain = (id: string) => |
| 168 | withClient((client) => client.deleteCustomDomain(id)); |
| 169 | export const retryCustomDomain = (id: string) => |
| 170 | withClient((client) => client.retryCustomDomain(id)); |
| 171 | |
| 172 | export const listApps = (query?: { |
| 173 | cursor?: string | null; |
| 174 | limit?: number; |
| 175 | projectId?: string; |
| 176 | branchId?: PrismaBranchIdFilter; |
| 177 | branchGitName?: string; |
| 178 | }) => withClient((client) => client.listApps(query)); |
| 179 | export const getApp = (id: string) => withClient((client) => client.getApp(id)); |
| 180 | export const createApp = (input: AppCreateInput) => |
| 181 | withClient((client) => client.createApp(input)); |
| 182 | export const updateApp = (id: string, input: AppUpdateInput) => |
| 183 | withClient((client) => client.updateApp(id, input)); |
| 184 | export const deleteApp = (id: string) => |
| 185 | withClient((client) => client.deleteApp(id)); |
| 186 | export const promoteApp = (id: string, target: AppDeploymentTarget) => |
| 187 | withClient((client) => client.promoteApp(id, target)); |
| 188 | export const rollbackApp = (id: string, target: AppDeploymentTarget) => |
| 189 | withClient((client) => client.rollbackApp(id, target)); |
| 190 | export const listAppDomains = (appId: string) => |
| 191 | withClient((client) => client.listAppDomains(appId)); |
| 192 | export const createAppDomain = ( |
| 193 | appId: string, |
| 194 | input: CustomDomainCreateInput, |
| 195 | ) => withClient((client) => client.createAppDomain(appId, input)); |
| 196 | export const listAppDeployments = ( |
| 197 | appId: string, |
| 198 | query?: { cursor?: string | null; limit?: number }, |
| 199 | ) => withClient((client) => client.listAppDeployments(appId, query)); |
| 200 | export const createAppDeployment = ( |
| 201 | appId: string, |
| 202 | input?: DeploymentCreateInput, |
| 203 | ) => withClient((client) => client.createAppDeployment(appId, input)); |
| 204 | export const getDeployment = (id: string) => |
| 205 | withClient((client) => client.getDeployment(id)); |
| 206 | export const deleteDeployment = (id: string) => |
| 207 | withClient((client) => client.deleteDeployment(id)); |
| 208 | export const startDeployment = (id: string) => |
| 209 | withClient((client) => client.startDeployment(id)); |
| 210 | export const stopDeployment = (id: string) => |
| 211 | withClient((client) => client.stopDeployment(id)); |
| 212 | export const getDeploymentLogsRequest = ( |
| 213 | id: string, |
| 214 | query?: DeploymentLogsQuery, |
| 215 | ) => LogsClient.getDeploymentLogsRequest(id, query); |
| 216 | export const getBuildLogsRequest = (buildId: string, query?: BuildLogsQuery) => |
| 217 | LogsClient.getBuildLogsRequest(buildId, query); |
| 218 | |
| 219 | export const listEnvironmentVariables = (query?: { |
| 220 | cursor?: string | null; |
| 221 | limit?: number; |
| 222 | projectId?: string; |
| 223 | class?: "production" | "preview"; |
| 224 | key?: string; |
| 225 | branchId?: string; |
| 226 | }) => withClient((client) => client.listEnvironmentVariables(query)); |
| 227 | export const getEnvironmentVariable = (id: string) => |
| 228 | withClient((client) => client.getEnvironmentVariable(id)); |
| 229 | export const createEnvironmentVariable = ( |
| 230 | input: EnvironmentVariableCreateInput, |
| 231 | ) => withClient((client) => client.createEnvironmentVariable(input)); |
| 232 | export const updateEnvironmentVariable = ( |
| 233 | id: string, |
| 234 | input: EnvironmentVariableUpdateInput, |
| 235 | ) => withClient((client) => client.updateEnvironmentVariable(id, input)); |
| 236 | export const deleteEnvironmentVariable = (id: string) => |
| 237 | withClient((client) => client.deleteEnvironmentVariable(id)); |
| 238 | |
| 239 | export const listIntegrations = (query: { |
| 240 | workspaceId: string; |
| 241 | cursor?: string | null; |
| 242 | limit?: number; |
| 243 | }) => withClient((client) => client.listIntegrations(query)); |
| 244 | export const listWorkspaceIntegrations = ( |
| 245 | workspaceId: string, |
| 246 | query?: { cursor?: string | null; limit?: number }, |
| 247 | ) => |
| 248 | withClient((client) => client.listWorkspaceIntegrations(workspaceId, query)); |
| 249 | export const getIntegration = (id: string) => |
| 250 | withClient((client) => client.getIntegration(id)); |
| 251 | export const deleteIntegration = (id: string) => |
| 252 | withClient((client) => client.deleteIntegration(id)); |
| 253 | export const revokeWorkspaceIntegration = ( |
| 254 | workspaceId: string, |
| 255 | clientId: string, |
| 256 | ) => |
| 257 | withClient((client) => |
| 258 | client.revokeWorkspaceIntegration(workspaceId, clientId), |
| 259 | ); |
| 260 | |
| 261 | export const listScmInstallations = (query: { |
| 262 | workspaceId: string; |
| 263 | cursor?: string | null; |
| 264 | limit?: number; |
| 265 | }) => withClient((client) => client.listScmInstallations(query)); |
| 266 | export const createScmInstallIntent = (input: ScmInstallIntentCreateInput) => |
| 267 | withClient((client) => client.createScmInstallIntent(input)); |
| 268 | export const listScmInstallationRepositories = ( |
| 269 | installationId: string, |
| 270 | query?: { cursor?: string | null; limit?: number }, |
| 271 | ) => |
| 272 | withClient((client) => |
| 273 | client.listScmInstallationRepositories(installationId, query), |
| 274 | ); |
| 275 | |
| 276 | export const listSourceRepositories = (query: { |
| 277 | projectId: string; |
| 278 | cursor?: string | null; |
| 279 | limit?: number; |
| 280 | }) => withClient((client) => client.listSourceRepositories(query)); |
| 281 | export const getSourceRepository = (id: string) => |
| 282 | withClient((client) => client.getSourceRepository(id)); |
| 283 | export const createSourceRepository = (input: SourceRepositoryCreateInput) => |
| 284 | withClient((client) => client.createSourceRepository(input)); |
| 285 | export const deleteSourceRepository = (id: string) => |
| 286 | withClient((client) => client.deleteSourceRepository(id)); |