@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/dist/api-client.d.ts +38 -38
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +44 -43
- package/dist/api-client.js.map +1 -1
- package/dist/callbacks.d.ts +33 -33
- package/dist/callbacks.d.ts.map +1 -1
- package/dist/compute-client.d.ts +66 -66
- package/dist/compute-client.d.ts.map +1 -1
- package/dist/compute-client.js +274 -272
- package/dist/compute-client.js.map +1 -1
- package/dist/errors.d.ts +28 -28
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +12 -12
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/log-stream.d.ts +1 -1
- package/dist/log-stream.d.ts.map +1 -1
- package/dist/log-stream.js +1 -1
- package/dist/log-stream.js.map +1 -1
- package/dist/polling.d.ts +4 -4
- package/dist/polling.d.ts.map +1 -1
- package/dist/polling.js +15 -15
- package/dist/polling.js.map +1 -1
- package/dist/types.d.ts +8 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/api-client.ts +57 -63
- package/src/callbacks.ts +34 -34
- package/src/compute-client.ts +433 -413
- package/src/errors.ts +42 -38
- package/src/index.ts +26 -26
- package/src/log-stream.ts +2 -2
- package/src/polling.ts +19 -18
- package/src/types.ts +8 -8
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
|
-
|
|
40
|
+
deploymentId: string;
|
|
41
41
|
elapsedMs: number;
|
|
42
42
|
lastStatus: string;
|
|
43
43
|
message: string;
|
|
44
44
|
}>() {
|
|
45
45
|
constructor(args: {
|
|
46
|
-
|
|
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
|
|
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
|
|
58
|
-
|
|
57
|
+
export class DeploymentFailedError extends TaggedError(
|
|
58
|
+
"DeploymentFailedError",
|
|
59
|
+
)<{
|
|
60
|
+
deploymentId: string;
|
|
59
61
|
message: string;
|
|
60
62
|
}>() {
|
|
61
|
-
constructor(args: {
|
|
63
|
+
constructor(args: { deploymentId: string }) {
|
|
62
64
|
super({
|
|
63
|
-
|
|
64
|
-
message: `
|
|
65
|
+
deploymentId: args.deploymentId,
|
|
66
|
+
message: `Deployment ${args.deploymentId} transitioned to failed status`,
|
|
65
67
|
});
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
export class
|
|
70
|
-
"
|
|
71
|
+
export class NoExistingDeploymentError extends TaggedError(
|
|
72
|
+
"NoExistingDeploymentError",
|
|
71
73
|
)<{
|
|
72
|
-
|
|
74
|
+
appId: string;
|
|
73
75
|
message: string;
|
|
74
76
|
}>() {
|
|
75
|
-
constructor(args: {
|
|
77
|
+
constructor(args: { appId: string }) {
|
|
76
78
|
super({
|
|
77
|
-
|
|
78
|
-
message: `
|
|
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
|
|
84
|
-
|
|
85
|
+
export class NoDeploymentsFoundError extends TaggedError(
|
|
86
|
+
"NoDeploymentsFoundError",
|
|
87
|
+
)<{
|
|
88
|
+
appId: string;
|
|
85
89
|
message: string;
|
|
86
90
|
}>() {
|
|
87
|
-
constructor(args: {
|
|
91
|
+
constructor(args: { appId: string }) {
|
|
88
92
|
super({
|
|
89
|
-
|
|
90
|
-
message: `
|
|
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
|
-
|
|
108
|
-
failures: Array<{
|
|
109
|
-
|
|
111
|
+
succeededDeploymentIds: string[];
|
|
112
|
+
failures: Array<{ deploymentId: string; error: DeploymentOperationError }>;
|
|
113
|
+
appDeleted: boolean;
|
|
110
114
|
}>() {
|
|
111
115
|
constructor(args: {
|
|
112
|
-
|
|
113
|
-
failures: Array<{
|
|
114
|
-
|
|
116
|
+
succeededDeploymentIds: string[];
|
|
117
|
+
failures: Array<{ deploymentId: string; error: DeploymentOperationError }>;
|
|
118
|
+
appDeleted: boolean;
|
|
115
119
|
}) {
|
|
116
|
-
const failedIds = args.failures.map((f) => f.
|
|
120
|
+
const failedIds = args.failures.map((f) => f.deploymentId).join(", ");
|
|
117
121
|
super({
|
|
118
122
|
...args,
|
|
119
|
-
message: `Failed to destroy ${args.failures.length}
|
|
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
|
-
|
|
|
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
|
-
|
|
|
153
|
+
| NoExistingDeploymentError
|
|
150
154
|
| TimeoutError
|
|
151
|
-
|
|
|
155
|
+
| DeploymentFailedError
|
|
152
156
|
| CancelledError;
|
|
153
157
|
|
|
154
|
-
export type
|
|
158
|
+
export type DestroyDeploymentError =
|
|
155
159
|
| CancelledError
|
|
156
160
|
| MissingArgumentError
|
|
157
|
-
|
|
|
161
|
+
| NoDeploymentsFoundError
|
|
158
162
|
| AuthenticationError
|
|
159
163
|
| ApiError
|
|
160
164
|
| TimeoutError
|
|
161
|
-
|
|
|
165
|
+
| DeploymentFailedError;
|
|
162
166
|
|
|
163
|
-
export type
|
|
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
|
-
|
|
|
177
|
+
| NoDeploymentsFoundError
|
|
174
178
|
| TimeoutError
|
|
175
|
-
|
|
|
179
|
+
| DeploymentFailedError
|
|
176
180
|
| CancelledError;
|
|
177
181
|
|
|
178
182
|
export type ApiRequestError = CancelledError | AuthenticationError | ApiError;
|
|
179
183
|
|
|
180
|
-
export type
|
|
184
|
+
export type DeploymentOperationError =
|
|
181
185
|
| CancelledError
|
|
182
186
|
| AuthenticationError
|
|
183
187
|
| ApiError
|
|
184
188
|
| TimeoutError
|
|
185
|
-
|
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
DeleteVersionOptions,
|
|
52
|
+
DeleteAppOptions,
|
|
53
|
+
DeleteDeploymentOptions,
|
|
54
54
|
DeployOptions,
|
|
55
55
|
DeployResult,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
87
|
-
|
|
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
|
-
|
|
103
|
-
|
|
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
|
-
|
|
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/
|
|
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
|
-
|
|
|
26
|
+
| DeploymentFailedError
|
|
27
27
|
| ApiClientError;
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
* Polls a
|
|
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
|
|
34
|
+
export async function pollDeploymentStatus(
|
|
35
35
|
api: InternalApiClient,
|
|
36
|
-
|
|
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
|
|
49
|
-
api.
|
|
48
|
+
const deployment = yield* Result.await(
|
|
49
|
+
api.getDeployment(deploymentId, options.signal),
|
|
50
50
|
);
|
|
51
51
|
|
|
52
|
-
if (
|
|
53
|
-
lastStatus =
|
|
54
|
-
options.onStatusChange?.(
|
|
52
|
+
if (deployment.status !== lastStatus) {
|
|
53
|
+
lastStatus = deployment.status;
|
|
54
|
+
options.onStatusChange?.(deployment.status);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
if (
|
|
58
|
-
if (options.targetStatus === "running" && !
|
|
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:
|
|
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:
|
|
70
|
-
lastStatus:
|
|
70
|
+
previewDomain: deployment.previewDomain ?? "",
|
|
71
|
+
lastStatus: deployment.status,
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
if (
|
|
75
|
-
return Result.err(new
|
|
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
|
-
|
|
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
|
|
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
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
export interface AppDetail extends AppInfo {
|
|
35
|
+
latestDeploymentId?: string | null;
|
|
36
|
+
appEndpointDomain?: string;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export interface
|
|
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
|
|
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
|
-
|
|
59
|
-
|
|
58
|
+
appId: string;
|
|
59
|
+
appName: string;
|
|
60
60
|
region: string;
|
|
61
61
|
portMapping?: PortMapping;
|
|
62
62
|
}
|