@prisma/compute-sdk 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/errors.ts CHANGED
@@ -37,57 +37,61 @@ export class ArtifactError extends TaggedError("ArtifactError")<{
37
37
  }>() {}
38
38
 
39
39
  export class TimeoutError extends TaggedError("TimeoutError")<{
40
- versionId: string;
40
+ deploymentId: string;
41
41
  elapsedMs: number;
42
42
  lastStatus: string;
43
43
  message: string;
44
44
  }>() {
45
45
  constructor(args: {
46
- versionId: string;
46
+ deploymentId: string;
47
47
  elapsedMs: number;
48
48
  lastStatus: string;
49
49
  }) {
50
50
  super({
51
51
  ...args,
52
- message: `Timed out waiting for version ${args.versionId} to reach target state (last status: ${args.lastStatus}, elapsed: ${Math.round(args.elapsedMs / 1000)}s)`,
52
+ message: `Timed out waiting for deployment ${args.deploymentId} to reach target state (last status: ${args.lastStatus}, elapsed: ${Math.round(args.elapsedMs / 1000)}s)`,
53
53
  });
54
54
  }
55
55
  }
56
56
 
57
- export class VersionFailedError extends TaggedError("VersionFailedError")<{
58
- versionId: string;
57
+ export class DeploymentFailedError extends TaggedError(
58
+ "DeploymentFailedError",
59
+ )<{
60
+ deploymentId: string;
59
61
  message: string;
60
62
  }>() {
61
- constructor(args: { versionId: string }) {
63
+ constructor(args: { deploymentId: string }) {
62
64
  super({
63
- versionId: args.versionId,
64
- message: `Version ${args.versionId} transitioned to failed status`,
65
+ deploymentId: args.deploymentId,
66
+ message: `Deployment ${args.deploymentId} transitioned to failed status`,
65
67
  });
66
68
  }
67
69
  }
68
70
 
69
- export class NoExistingVersionError extends TaggedError(
70
- "NoExistingVersionError",
71
+ export class NoExistingDeploymentError extends TaggedError(
72
+ "NoExistingDeploymentError",
71
73
  )<{
72
- serviceId: string;
74
+ appId: string;
73
75
  message: string;
74
76
  }>() {
75
- constructor(args: { serviceId: string }) {
77
+ constructor(args: { appId: string }) {
76
78
  super({
77
- serviceId: args.serviceId,
78
- message: `Service ${args.serviceId} has no existing versions. Environment-only updates require at least one prior deployment.`,
79
+ appId: args.appId,
80
+ message: `App ${args.appId} has no existing deployments. Environment-only updates require at least one prior deployment.`,
79
81
  });
80
82
  }
81
83
  }
82
84
 
83
- export class NoVersionsFoundError extends TaggedError("NoVersionsFoundError")<{
84
- serviceId: string;
85
+ export class NoDeploymentsFoundError extends TaggedError(
86
+ "NoDeploymentsFoundError",
87
+ )<{
88
+ appId: string;
85
89
  message: string;
86
90
  }>() {
87
- constructor(args: { serviceId: string }) {
91
+ constructor(args: { appId: string }) {
88
92
  super({
89
- serviceId: args.serviceId,
90
- message: `Service ${args.serviceId} has no versions`,
93
+ appId: args.appId,
94
+ message: `App ${args.appId} has no deployments`,
91
95
  });
92
96
  }
93
97
  }
@@ -104,19 +108,19 @@ export class DestroyAggregateError extends TaggedError(
104
108
  "DestroyAggregateError",
105
109
  )<{
106
110
  message: string;
107
- succeededVersionIds: string[];
108
- failures: Array<{ versionId: string; error: VersionOperationError }>;
109
- serviceDeleted: boolean;
111
+ succeededDeploymentIds: string[];
112
+ failures: Array<{ deploymentId: string; error: DeploymentOperationError }>;
113
+ appDeleted: boolean;
110
114
  }>() {
111
115
  constructor(args: {
112
- succeededVersionIds: string[];
113
- failures: Array<{ versionId: string; error: VersionOperationError }>;
114
- serviceDeleted: boolean;
116
+ succeededDeploymentIds: string[];
117
+ failures: Array<{ deploymentId: string; error: DeploymentOperationError }>;
118
+ appDeleted: boolean;
115
119
  }) {
116
- const failedIds = args.failures.map((f) => f.versionId).join(", ");
120
+ const failedIds = args.failures.map((f) => f.deploymentId).join(", ");
117
121
  super({
118
122
  ...args,
119
- message: `Failed to destroy ${args.failures.length} version(s): ${failedIds}`,
123
+ message: `Failed to destroy ${args.failures.length} deployment(s): ${failedIds}`,
120
124
  });
121
125
  }
122
126
  }
@@ -138,7 +142,7 @@ export type DeployError =
138
142
  | BuildError
139
143
  | ArtifactError
140
144
  | TimeoutError
141
- | VersionFailedError
145
+ | DeploymentFailedError
142
146
  | CancelledError;
143
147
 
144
148
  export type UpdateEnvError =
@@ -146,21 +150,21 @@ export type UpdateEnvError =
146
150
  | ApiError
147
151
  | MissingArgumentError
148
152
  | InvalidOptionsError
149
- | NoExistingVersionError
153
+ | NoExistingDeploymentError
150
154
  | TimeoutError
151
- | VersionFailedError
155
+ | DeploymentFailedError
152
156
  | CancelledError;
153
157
 
154
- export type DestroyVersionError =
158
+ export type DestroyDeploymentError =
155
159
  | CancelledError
156
160
  | MissingArgumentError
157
- | NoVersionsFoundError
161
+ | NoDeploymentsFoundError
158
162
  | AuthenticationError
159
163
  | ApiError
160
164
  | TimeoutError
161
- | VersionFailedError;
165
+ | DeploymentFailedError;
162
166
 
163
- export type DestroyServiceError =
167
+ export type DestroyAppError =
164
168
  | CancelledError
165
169
  | AuthenticationError
166
170
  | ApiError
@@ -170,16 +174,16 @@ export type PromoteError =
170
174
  | AuthenticationError
171
175
  | ApiError
172
176
  | MissingArgumentError
173
- | NoVersionsFoundError
177
+ | NoDeploymentsFoundError
174
178
  | TimeoutError
175
- | VersionFailedError
179
+ | DeploymentFailedError
176
180
  | CancelledError;
177
181
 
178
182
  export type ApiRequestError = CancelledError | AuthenticationError | ApiError;
179
183
 
180
- export type VersionOperationError =
184
+ export type DeploymentOperationError =
181
185
  | CancelledError
182
186
  | AuthenticationError
183
187
  | ApiError
184
188
  | TimeoutError
185
- | VersionFailedError;
189
+ | DeploymentFailedError;
package/src/index.ts CHANGED
@@ -40,32 +40,32 @@ export { BunBuild } from "./bun-build.ts";
40
40
  export type {
41
41
  DeployInteraction,
42
42
  DeployProgress,
43
- DestroyServiceProgress,
44
- DestroyVersionInteraction,
45
- DestroyVersionProgress,
43
+ DestroyAppProgress,
44
+ DestroyDeploymentInteraction,
45
+ DestroyDeploymentProgress,
46
46
  PromoteProgress,
47
47
  UpdateEnvProgress,
48
48
  } from "./callbacks.ts";
49
49
  export type {
50
+ CreateAppOptions,
50
51
  CreateProjectOptions,
51
- CreateServiceOptions,
52
- DeleteServiceOptions,
53
- DeleteVersionOptions,
52
+ DeleteAppOptions,
53
+ DeleteDeploymentOptions,
54
54
  DeployOptions,
55
55
  DeployResult,
56
- DestroyServiceOptions,
57
- DestroyServiceResult,
58
- DestroyVersionOptions,
59
- DestroyVersionResult,
56
+ DestroyAppOptions,
57
+ DestroyAppResult,
58
+ DestroyDeploymentOptions,
59
+ DestroyDeploymentResult,
60
+ ListAppsOptions,
61
+ ListDeploymentsOptions,
60
62
  ListProjectsOptions,
61
- ListServicesOptions,
62
- ListVersionsOptions,
63
63
  PromoteOptions,
64
64
  PromoteResult,
65
- ShowServiceOptions,
66
- ShowVersionOptions,
67
- StartVersionOptions,
68
- StopVersionOptions,
65
+ ShowAppOptions,
66
+ ShowDeploymentOptions,
67
+ StartDeploymentOptions,
68
+ StopDeploymentOptions,
69
69
  UpdateEnvOptions,
70
70
  UpdateEnvResult,
71
71
  } from "./compute-client.ts";
@@ -83,11 +83,11 @@ export { detectAppSchema } from "./detect-schema.ts";
83
83
  export type {
84
84
  ApiRequestError,
85
85
  DeployError,
86
- DestroyServiceError,
87
- DestroyVersionError,
86
+ DeploymentOperationError,
87
+ DestroyAppError,
88
+ DestroyDeploymentError,
88
89
  PromoteError,
89
90
  UpdateEnvError,
90
- VersionOperationError,
91
91
  } from "./errors.ts";
92
92
  export {
93
93
  ApiError,
@@ -95,14 +95,14 @@ export {
95
95
  AuthenticationError,
96
96
  BuildError,
97
97
  CancelledError,
98
+ DeploymentFailedError,
98
99
  DestroyAggregateError,
99
100
  InvalidOptionsError,
100
101
  LogStreamError,
101
102
  MissingArgumentError,
102
- NoExistingVersionError,
103
- NoVersionsFoundError,
103
+ NoDeploymentsFoundError,
104
+ NoExistingDeploymentError,
104
105
  TimeoutError,
105
- VersionFailedError,
106
106
  } from "./errors.ts";
107
107
  export type {
108
108
  LogRecord,
@@ -118,16 +118,16 @@ export { NextjsBuild } from "./nextjs-build.ts";
118
118
  export { NuxtBuild } from "./nuxt-build.ts";
119
119
  export { TanstackStartBuild } from "./tanstack-start-build.ts";
120
120
  export type {
121
+ AppDetail,
122
+ AppInfo,
121
123
  CreateProjectResult,
122
124
  DatabaseInfo,
125
+ DeploymentDetail,
126
+ DeploymentInfo,
123
127
  PortMapping,
124
128
  ProjectInfo,
125
129
  RegionInfo,
126
130
  ResolvedConfig,
127
- ServiceDetail,
128
- ServiceInfo,
129
- VersionDetail,
130
- VersionInfo,
131
131
  } from "./types.ts";
132
132
  export { KNOWN_REGION_IDS, REGIONS } from "./types.ts";
133
133
  export { uploadArtifact } from "./upload-artifact.ts";
package/src/log-stream.ts CHANGED
@@ -27,7 +27,7 @@ export type StreamRecord = LogRecord | TerminalRecord;
27
27
  export type LogStreamOptions = {
28
28
  baseUrl: string;
29
29
  token: string;
30
- versionId: string;
30
+ deploymentId: string;
31
31
  tail?: number;
32
32
  fromStart?: boolean;
33
33
  cursor?: string;
@@ -71,7 +71,7 @@ function toError(value: unknown): Error {
71
71
 
72
72
  function buildWebSocketUrl(options: LogStreamOptions): string {
73
73
  const httpUrl = new URL(
74
- `/v1/compute-services/versions/${encodeURIComponent(options.versionId)}/logs`,
74
+ `/v1/deployments/${encodeURIComponent(options.deploymentId)}/logs`,
75
75
  options.baseUrl,
76
76
  );
77
77
  httpUrl.protocol = httpUrl.protocol === "https:" ? "wss:" : "ws:";
package/src/polling.ts CHANGED
@@ -3,8 +3,8 @@ import type { ApiClientError, InternalApiClient } from "./api-client.ts";
3
3
  import {
4
4
  ApiError,
5
5
  CancelledError,
6
+ DeploymentFailedError,
6
7
  TimeoutError,
7
- VersionFailedError,
8
8
  } from "./errors.ts";
9
9
 
10
10
  export type PollOptions = {
@@ -23,17 +23,17 @@ export type PollResult = {
23
23
  export type PollError =
24
24
  | CancelledError
25
25
  | TimeoutError
26
- | VersionFailedError
26
+ | DeploymentFailedError
27
27
  | ApiClientError;
28
28
 
29
29
  /**
30
- * Polls a compute version until it reaches the target status, fails, or times out.
30
+ * Polls a deployment until it reaches the target status, fails, or times out.
31
31
  *
32
32
  * Returns a Result with the preview domain on success or a typed error.
33
33
  */
34
- export async function pollVersionStatus(
34
+ export async function pollDeploymentStatus(
35
35
  api: InternalApiClient,
36
- versionId: string,
36
+ deploymentId: string,
37
37
  options: PollOptions,
38
38
  ): Promise<Result<PollResult, PollError>> {
39
39
  return Result.gen(async function* () {
@@ -45,34 +45,35 @@ export async function pollVersionStatus(
45
45
  return Result.err(new CancelledError());
46
46
  }
47
47
 
48
- const version = yield* Result.await(
49
- api.getVersion(versionId, options.signal),
48
+ const deployment = yield* Result.await(
49
+ api.getDeployment(deploymentId, options.signal),
50
50
  );
51
51
 
52
- if (version.status !== lastStatus) {
53
- lastStatus = version.status;
54
- options.onStatusChange?.(version.status);
52
+ if (deployment.status !== lastStatus) {
53
+ lastStatus = deployment.status;
54
+ options.onStatusChange?.(deployment.status);
55
55
  }
56
56
 
57
- if (version.status === options.targetStatus) {
58
- if (options.targetStatus === "running" && !version.previewDomain) {
57
+ if (deployment.status === options.targetStatus) {
58
+ if (options.targetStatus === "running" && !deployment.previewDomain) {
59
59
  return Result.err(
60
60
  new ApiError({
61
61
  statusCode: 0,
62
62
  statusText: "",
63
- message: "Version reached running state without a previewDomain",
63
+ message:
64
+ "Deployment reached running state without a previewDomain",
64
65
  traceHeaders: {},
65
66
  }),
66
67
  );
67
68
  }
68
69
  return Result.ok({
69
- previewDomain: version.previewDomain ?? "",
70
- lastStatus: version.status,
70
+ previewDomain: deployment.previewDomain ?? "",
71
+ lastStatus: deployment.status,
71
72
  });
72
73
  }
73
74
 
74
- if (version.status === "failed") {
75
- return Result.err(new VersionFailedError({ versionId }));
75
+ if (deployment.status === "failed") {
76
+ return Result.err(new DeploymentFailedError({ deploymentId }));
76
77
  }
77
78
 
78
79
  await sleep(options.pollIntervalMs, options.signal);
@@ -80,7 +81,7 @@ export async function pollVersionStatus(
80
81
 
81
82
  return Result.err(
82
83
  new TimeoutError({
83
- versionId,
84
+ deploymentId,
84
85
  elapsedMs: Date.now() - (deadline - options.timeoutSeconds * 1_000),
85
86
  lastStatus,
86
87
  }),
package/src/types.ts CHANGED
@@ -23,7 +23,7 @@ export interface CreateProjectResult extends ProjectInfo {
23
23
  database?: DatabaseInfo;
24
24
  }
25
25
 
26
- export interface ServiceInfo {
26
+ export interface AppInfo {
27
27
  id: string;
28
28
  name: string;
29
29
  region: string;
@@ -31,19 +31,19 @@ export interface ServiceInfo {
31
31
  createdAt?: string;
32
32
  }
33
33
 
34
- export interface ServiceDetail extends ServiceInfo {
35
- latestVersionId?: string | null;
36
- serviceEndpointDomain?: string;
34
+ export interface AppDetail extends AppInfo {
35
+ latestDeploymentId?: string | null;
36
+ appEndpointDomain?: string;
37
37
  }
38
38
 
39
- export interface VersionInfo {
39
+ export interface DeploymentInfo {
40
40
  id: string;
41
41
  status: string;
42
42
  createdAt: string;
43
43
  previewDomain?: string | null;
44
44
  }
45
45
 
46
- export interface VersionDetail extends VersionInfo {
46
+ export interface DeploymentDetail extends DeploymentInfo {
47
47
  envVars?: Record<string, string | null>;
48
48
  foundryVersionId?: string;
49
49
  }
@@ -55,8 +55,8 @@ export interface RegionInfo {
55
55
 
56
56
  export interface ResolvedConfig {
57
57
  projectId: string;
58
- serviceId: string;
59
- serviceName: string;
58
+ appId: string;
59
+ appName: string;
60
60
  region: string;
61
61
  portMapping?: PortMapping;
62
62
  }