@prisma/compute-sdk 0.28.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.
Files changed (106) hide show
  1. package/dist/api-client.d.ts +38 -38
  2. package/dist/api-client.d.ts.map +1 -1
  3. package/dist/api-client.js +44 -43
  4. package/dist/api-client.js.map +1 -1
  5. package/dist/astro-build.d.ts +2 -0
  6. package/dist/astro-build.d.ts.map +1 -1
  7. package/dist/astro-build.js +31 -39
  8. package/dist/astro-build.js.map +1 -1
  9. package/dist/build-settings.d.ts +3 -0
  10. package/dist/build-settings.d.ts.map +1 -1
  11. package/dist/build-settings.js +13 -0
  12. package/dist/build-settings.js.map +1 -1
  13. package/dist/build-strategy.d.ts +20 -0
  14. package/dist/build-strategy.d.ts.map +1 -1
  15. package/dist/build-strategy.js +33 -1
  16. package/dist/build-strategy.js.map +1 -1
  17. package/dist/build.d.ts +2 -1
  18. package/dist/build.d.ts.map +1 -1
  19. package/dist/build.js +16 -4
  20. package/dist/build.js.map +1 -1
  21. package/dist/bun-build.d.ts +1 -1
  22. package/dist/bun-build.d.ts.map +1 -1
  23. package/dist/bun-build.js +25 -9
  24. package/dist/bun-build.js.map +1 -1
  25. package/dist/callbacks.d.ts +33 -33
  26. package/dist/callbacks.d.ts.map +1 -1
  27. package/dist/compute-client.d.ts +66 -66
  28. package/dist/compute-client.d.ts.map +1 -1
  29. package/dist/compute-client.js +274 -272
  30. package/dist/compute-client.js.map +1 -1
  31. package/dist/config/frameworks.d.ts +4 -8
  32. package/dist/config/frameworks.d.ts.map +1 -1
  33. package/dist/config/frameworks.js +17 -5
  34. package/dist/config/frameworks.js.map +1 -1
  35. package/dist/config/normalize.d.ts +6 -0
  36. package/dist/config/normalize.d.ts.map +1 -1
  37. package/dist/config/normalize.js +53 -12
  38. package/dist/config/normalize.js.map +1 -1
  39. package/dist/config/types.d.ts +3 -1
  40. package/dist/config/types.d.ts.map +1 -1
  41. package/dist/config/types.js +1 -0
  42. package/dist/config/types.js.map +1 -1
  43. package/dist/configured-artifact.d.ts +20 -0
  44. package/dist/configured-artifact.d.ts.map +1 -0
  45. package/dist/configured-artifact.js +104 -0
  46. package/dist/configured-artifact.js.map +1 -0
  47. package/dist/custom-build.d.ts +20 -0
  48. package/dist/custom-build.d.ts.map +1 -0
  49. package/dist/custom-build.js +53 -0
  50. package/dist/custom-build.js.map +1 -0
  51. package/dist/errors.d.ts +28 -28
  52. package/dist/errors.d.ts.map +1 -1
  53. package/dist/errors.js +12 -12
  54. package/dist/errors.js.map +1 -1
  55. package/dist/index.d.ts +6 -5
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +2 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/log-stream.d.ts +1 -1
  60. package/dist/log-stream.d.ts.map +1 -1
  61. package/dist/log-stream.js +1 -1
  62. package/dist/log-stream.js.map +1 -1
  63. package/dist/nestjs-build.d.ts.map +1 -1
  64. package/dist/nestjs-build.js +28 -29
  65. package/dist/nestjs-build.js.map +1 -1
  66. package/dist/nextjs-build.d.ts +1 -1
  67. package/dist/nextjs-build.d.ts.map +1 -1
  68. package/dist/nextjs-build.js +25 -14
  69. package/dist/nextjs-build.js.map +1 -1
  70. package/dist/nuxt-build.d.ts +2 -0
  71. package/dist/nuxt-build.d.ts.map +1 -1
  72. package/dist/nuxt-build.js +31 -39
  73. package/dist/nuxt-build.js.map +1 -1
  74. package/dist/polling.d.ts +4 -4
  75. package/dist/polling.d.ts.map +1 -1
  76. package/dist/polling.js +15 -15
  77. package/dist/polling.js.map +1 -1
  78. package/dist/tanstack-start-build.d.ts +1 -1
  79. package/dist/tanstack-start-build.d.ts.map +1 -1
  80. package/dist/tanstack-start-build.js +26 -47
  81. package/dist/tanstack-start-build.js.map +1 -1
  82. package/dist/types.d.ts +8 -8
  83. package/dist/types.d.ts.map +1 -1
  84. package/package.json +2 -2
  85. package/src/api-client.ts +57 -63
  86. package/src/astro-build.ts +39 -46
  87. package/src/build-settings.ts +16 -0
  88. package/src/build-strategy.ts +56 -1
  89. package/src/build.ts +16 -4
  90. package/src/bun-build.ts +39 -10
  91. package/src/callbacks.ts +34 -34
  92. package/src/compute-client.ts +433 -413
  93. package/src/config/frameworks.ts +18 -5
  94. package/src/config/normalize.ts +74 -13
  95. package/src/config/types.ts +3 -0
  96. package/src/configured-artifact.ts +169 -0
  97. package/src/custom-build.ts +73 -0
  98. package/src/errors.ts +42 -38
  99. package/src/index.ts +27 -26
  100. package/src/log-stream.ts +2 -2
  101. package/src/nestjs-build.ts +36 -33
  102. package/src/nextjs-build.ts +31 -14
  103. package/src/nuxt-build.ts +39 -46
  104. package/src/polling.ts +19 -18
  105. package/src/tanstack-start-build.ts +31 -53
  106. package/src/types.ts +8 -8
package/src/index.ts CHANGED
@@ -40,36 +40,37 @@ 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";
72
72
  export { ComputeClient } from "./compute-client.ts";
73
+ export { CustomBuild } from "./custom-build.ts";
73
74
  export type {
74
75
  DetectedSchema,
75
76
  MigrationCommand,
@@ -82,11 +83,11 @@ export { detectAppSchema } from "./detect-schema.ts";
82
83
  export type {
83
84
  ApiRequestError,
84
85
  DeployError,
85
- DestroyServiceError,
86
- DestroyVersionError,
86
+ DeploymentOperationError,
87
+ DestroyAppError,
88
+ DestroyDeploymentError,
87
89
  PromoteError,
88
90
  UpdateEnvError,
89
- VersionOperationError,
90
91
  } from "./errors.ts";
91
92
  export {
92
93
  ApiError,
@@ -94,14 +95,14 @@ export {
94
95
  AuthenticationError,
95
96
  BuildError,
96
97
  CancelledError,
98
+ DeploymentFailedError,
97
99
  DestroyAggregateError,
98
100
  InvalidOptionsError,
99
101
  LogStreamError,
100
102
  MissingArgumentError,
101
- NoExistingVersionError,
102
- NoVersionsFoundError,
103
+ NoDeploymentsFoundError,
104
+ NoExistingDeploymentError,
103
105
  TimeoutError,
104
- VersionFailedError,
105
106
  } from "./errors.ts";
106
107
  export type {
107
108
  LogRecord,
@@ -117,16 +118,16 @@ export { NextjsBuild } from "./nextjs-build.ts";
117
118
  export { NuxtBuild } from "./nuxt-build.ts";
118
119
  export { TanstackStartBuild } from "./tanstack-start-build.ts";
119
120
  export type {
121
+ AppDetail,
122
+ AppInfo,
120
123
  CreateProjectResult,
121
124
  DatabaseInfo,
125
+ DeploymentDetail,
126
+ DeploymentInfo,
122
127
  PortMapping,
123
128
  ProjectInfo,
124
129
  RegionInfo,
125
130
  ResolvedConfig,
126
- ServiceDetail,
127
- ServiceInfo,
128
- VersionDetail,
129
- VersionInfo,
130
131
  } from "./types.ts";
131
132
  export { KNOWN_REGION_IDS, REGIONS } from "./types.ts";
132
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:";
@@ -24,15 +24,11 @@ import type { BuildArtifact, BuildStrategy } from "./build-strategy.ts";
24
24
  import {
25
25
  hasPackageDependency,
26
26
  hasRootFile,
27
- runPackageCli,
27
+ runBuildSettingsCommand,
28
28
  } from "./build-strategy.ts";
29
29
  import { defaultHttpPortForBuildType } from "./config/frameworks.ts";
30
30
  import { resolveSourceRoot } from "./config/source-root.ts";
31
- import {
32
- type BuildCommandIo,
33
- readPackageManifest,
34
- runBuildCommand,
35
- } from "./workspace.ts";
31
+ import { type BuildCommandIo, readPackageManifest } from "./workspace.ts";
36
32
 
37
33
  const NEST_CLI_FILENAME = "nest-cli.json";
38
34
 
@@ -81,37 +77,26 @@ export class NestjsBuild implements BuildStrategy {
81
77
  signal,
82
78
  }));
83
79
 
84
- // `resolveBuildSettings` always returns a non-null `nest build` fallback, so
85
- // route by source: a user `build` script runs as-is, the framework default
86
- // goes through the launcher ladder (local bin -> npx -> bunx).
87
- const usingFrameworkDefault =
88
- settings.buildCommand === null ||
89
- settings.buildCommandSource === "NestJS default";
90
- if (!usingFrameworkDefault && settings.buildCommand) {
91
- await runBuildCommand({
92
- appPath: this.#appPath,
93
- command: settings.buildCommand,
94
- failurePrefix: "NestJS",
95
- env: this.#io?.env,
96
- onOutput: this.#io?.onOutput,
97
- signal,
98
- });
99
- } else {
100
- await runPackageCli({
101
- appPath: this.#appPath,
80
+ await runBuildSettingsCommand({
81
+ appPath: this.#appPath,
82
+ settings,
83
+ failurePrefix: "NestJS",
84
+ defaultCli: {
85
+ source: "NestJS default",
102
86
  cliName: "nest",
103
87
  args: ["build"],
104
- failurePrefix: "NestJS",
105
88
  missingMessage:
106
89
  "Could not find the Nest CLI. Add a `build` script to package.json, install @nestjs/cli, or ensure npx/bunx is available.",
107
- env: this.#io?.env,
108
- onOutput: this.#io?.onOutput,
109
- signal,
110
- });
111
- }
90
+ },
91
+ io: this.#io,
92
+ signal,
93
+ });
112
94
 
113
95
  signal?.throwIfAborted();
114
- const compiledEntry = await this.#resolveCompiledEntrypoint(signal);
96
+ const compiledEntry = await this.#resolveCompiledEntrypoint(
97
+ settings,
98
+ signal,
99
+ );
115
100
 
116
101
  const outDir = await mkdtemp(path.join(os.tmpdir(), "compute-build-"));
117
102
  try {
@@ -140,9 +125,16 @@ export class NestjsBuild implements BuildStrategy {
140
125
  * separators. Prefers `package.json` `main`, then the path computed from
141
126
  * `nest-cli.json` and the tsconfig `outDir`, then the common defaults.
142
127
  */
143
- async #resolveCompiledEntrypoint(signal?: AbortSignal): Promise<string> {
128
+ async #resolveCompiledEntrypoint(
129
+ settings: BuildSettings,
130
+ signal?: AbortSignal,
131
+ ): Promise<string> {
144
132
  const candidates: string[] = [];
145
133
 
134
+ if (settings.entrypoint) {
135
+ candidates.push(joinPosix(settings.outputDirectory, settings.entrypoint));
136
+ }
137
+
146
138
  const fromMain = await this.#mainFieldEntrypoint(signal);
147
139
  if (fromMain) {
148
140
  candidates.push(fromMain);
@@ -153,7 +145,7 @@ export class NestjsBuild implements BuildStrategy {
153
145
  candidates.push(fromConfig);
154
146
  }
155
147
 
156
- candidates.push(...DEFAULT_COMPILED_ENTRYPOINTS);
148
+ candidates.push(...compiledEntrypointDefaults(settings.outputDirectory));
157
149
 
158
150
  for (const candidate of candidates) {
159
151
  signal?.throwIfAborted();
@@ -195,6 +187,17 @@ export class NestjsBuild implements BuildStrategy {
195
187
  }
196
188
  }
197
189
 
190
+ function compiledEntrypointDefaults(outputDirectory: string): string[] {
191
+ if (outputDirectory === "dist") {
192
+ return DEFAULT_COMPILED_ENTRYPOINTS;
193
+ }
194
+ return [
195
+ joinPosix(outputDirectory, "src/main.js"),
196
+ joinPosix(outputDirectory, "main.js"),
197
+ ...DEFAULT_COMPILED_ENTRYPOINTS,
198
+ ];
199
+ }
200
+
198
201
  interface NestCliConfig {
199
202
  sourceRoot?: string;
200
203
  entryFile?: string;
@@ -9,9 +9,14 @@ import {
9
9
  resolveBuildSettings,
10
10
  } from "./build-settings.ts";
11
11
  import type { BuildArtifact, BuildStrategy } from "./build-strategy.ts";
12
- import { hasPackageDependency, hasRootFile } from "./build-strategy.ts";
12
+ import {
13
+ hasPackageDependency,
14
+ hasRootFile,
15
+ runBuildSettingsCommand,
16
+ } from "./build-strategy.ts";
13
17
  import { defaultHttpPortForBuildType } from "./config/frameworks.ts";
14
- import { type BuildCommandIo, runBuildCommand } from "./workspace.ts";
18
+ import { resolveConfiguredArtifactEntrypoint } from "./configured-artifact.ts";
19
+ import type { BuildCommandIo } from "./workspace.ts";
15
20
 
16
21
  const NEXT_CONFIG_FILENAMES = [
17
22
  "next.config.js",
@@ -63,20 +68,24 @@ export class NextjsBuild implements BuildStrategy {
63
68
  buildType: "nextjs",
64
69
  signal,
65
70
  }));
66
- if (settings.buildCommand) {
67
- await runBuildCommand({
68
- appPath: this.#appPath,
69
- command: settings.buildCommand,
70
- failurePrefix: "Next.js",
71
- env: this.#io?.env,
72
- onOutput: this.#io?.onOutput,
73
- signal,
74
- });
75
- }
71
+ await runBuildSettingsCommand({
72
+ appPath: this.#appPath,
73
+ settings,
74
+ failurePrefix: "Next.js",
75
+ defaultCli: {
76
+ source: "Next.js default",
77
+ cliName: "next",
78
+ args: ["build"],
79
+ missingMessage:
80
+ "Could not find the Next.js CLI. Install it with `npm install next` or ensure npx/bunx is available.",
81
+ },
82
+ io: this.#io,
83
+ signal,
84
+ });
76
85
 
77
86
  const standaloneDir = path.join(this.#appPath, settings.outputDirectory);
78
87
  if (!(await directoryExists(standaloneDir))) {
79
- if (this.#requireStandalone) {
88
+ if (this.#requireStandalone || settings.entrypoint) {
80
89
  throw new Error(
81
90
  `Next.js build did not produce standalone output at ${settings.outputDirectory}. ` +
82
91
  'Set output: "standalone" in your next.config; this deploy target requires it.',
@@ -97,7 +106,15 @@ export class NextjsBuild implements BuildStrategy {
97
106
  appPath: this.#appPath,
98
107
  signal,
99
108
  });
100
- const entrypoint = await findStandaloneEntrypoint(artifactDir);
109
+ const entrypoint = settings.entrypoint
110
+ ? await resolveConfiguredArtifactEntrypoint({
111
+ directory: artifactDir,
112
+ entrypoint: settings.entrypoint,
113
+ label: "Next.js",
114
+ displayDirectory: settings.outputDirectory,
115
+ missingEntrypointMessage: `Next.js standalone output did not contain configured entrypoint ${settings.outputDirectory}/${settings.entrypoint}.`,
116
+ })
117
+ : await findStandaloneEntrypoint(artifactDir);
101
118
  await copyStaticAssets({
102
119
  appPath: this.#appPath,
103
120
  artifactDir,
package/src/nuxt-build.ts CHANGED
@@ -1,15 +1,11 @@
1
- import { cp, mkdtemp, rm, stat } from "node:fs/promises";
2
- import os from "node:os";
3
- import path from "node:path";
4
-
5
- import { normalizeArtifactSymlinks } from "./artifact-postprocess.ts";
1
+ import { type BuildSettings, resolveBuildSettings } from "./build-settings.ts";
6
2
  import type { BuildArtifact, BuildStrategy } from "./build-strategy.ts";
7
3
  import {
8
4
  hasPackageDependency,
9
5
  hasRootFile,
10
- runPackageCli,
6
+ runBuildSettingsCommand,
11
7
  } from "./build-strategy.ts";
12
- import { defaultHttpPortForBuildType } from "./config/frameworks.ts";
8
+ import { stageConfiguredArtifact } from "./configured-artifact.ts";
13
9
  import type { BuildCommandIo } from "./workspace.ts";
14
10
 
15
11
  const NUXT_CONFIG_FILENAMES = [
@@ -26,10 +22,16 @@ const NUXT_CONFIG_FILENAMES = [
26
22
  */
27
23
  export class NuxtBuild implements BuildStrategy {
28
24
  readonly #appPath: string;
25
+ readonly #buildSettings?: BuildSettings;
29
26
  readonly #io?: BuildCommandIo;
30
27
 
31
- constructor(options: { appPath: string; io?: BuildCommandIo }) {
28
+ constructor(options: {
29
+ appPath: string;
30
+ buildSettings?: BuildSettings;
31
+ io?: BuildCommandIo;
32
+ }) {
32
33
  this.#appPath = options.appPath;
34
+ this.#buildSettings = options.buildSettings;
33
35
  this.#io = options.io;
34
36
  }
35
37
 
@@ -42,48 +44,39 @@ export class NuxtBuild implements BuildStrategy {
42
44
 
43
45
  async execute(signal?: AbortSignal): Promise<BuildArtifact> {
44
46
  signal?.throwIfAborted();
45
- await runPackageCli({
47
+ const settings =
48
+ this.#buildSettings ??
49
+ (await resolveBuildSettings({
50
+ appPath: this.#appPath,
51
+ buildType: "nuxt",
52
+ signal,
53
+ }));
54
+
55
+ await runBuildSettingsCommand({
46
56
  appPath: this.#appPath,
47
- cliName: "nuxt",
48
- args: ["build"],
57
+ settings,
49
58
  failurePrefix: "Nuxt",
50
- missingMessage:
51
- "Could not find the Nuxt CLI. Install it with `npm install nuxt` or ensure npx/bunx is available.",
52
- env: this.#io?.env,
53
- onOutput: this.#io?.onOutput,
59
+ defaultCli: {
60
+ source: "Nuxt default",
61
+ cliName: "nuxt",
62
+ args: ["build"],
63
+ missingMessage:
64
+ "Could not find the Nuxt CLI. Install it with `npm install nuxt` or ensure npx/bunx is available.",
65
+ },
66
+ io: this.#io,
54
67
  signal,
55
68
  });
56
69
 
57
- const outputDir = path.join(this.#appPath, ".output");
58
- const entryPath = path.join(outputDir, "server", "index.mjs");
59
- const entryStat = await stat(entryPath).catch(() => null);
60
- if (!entryStat?.isFile()) {
61
- throw new Error(
62
- "Nuxt build did not produce a Nitro node server entrypoint at .output/server/index.mjs. Ensure nitro.preset is 'node-server' (the default) — set NITRO_PRESET=node-server or remove any custom preset from nuxt.config.",
63
- );
64
- }
65
-
66
- const outDir = await mkdtemp(path.join(os.tmpdir(), "compute-build-"));
67
-
68
- try {
69
- const artifactDir = path.join(outDir, "app");
70
- await cp(outputDir, artifactDir, {
71
- recursive: true,
72
- verbatimSymlinks: true,
73
- });
74
- // Materialize any symlinks into the app/workspace node_modules so the
75
- // artifact is self-contained once unpacked elsewhere.
76
- await normalizeArtifactSymlinks(artifactDir, this.#appPath, signal);
77
-
78
- return {
79
- directory: artifactDir,
80
- entrypoint: "server/index.mjs",
81
- defaultPortMapping: { http: defaultHttpPortForBuildType("nuxt") },
82
- cleanup: () => rm(outDir, { recursive: true, force: true }),
83
- };
84
- } catch (error) {
85
- await rm(outDir, { recursive: true, force: true });
86
- throw error;
87
- }
70
+ return stageConfiguredArtifact({
71
+ appPath: this.#appPath,
72
+ outputDirectory: settings.outputDirectory,
73
+ entrypoint: settings.entrypoint ?? "server/index.mjs",
74
+ buildType: "nuxt",
75
+ label: "Nuxt",
76
+ missingEntrypointMessage: settings.entrypoint
77
+ ? undefined
78
+ : `Nuxt build did not produce a Nitro node server entrypoint at ${settings.outputDirectory}/server/index.mjs. Ensure nitro.preset is 'node-server' (the default) - set NITRO_PRESET=node-server or remove any custom preset from nuxt.config.`,
79
+ signal,
80
+ });
88
81
  }
89
82
  }
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
  }),
@@ -1,13 +1,11 @@
1
- import { cp, mkdtemp, rm, stat } from "node:fs/promises";
2
- import os from "node:os";
3
- import path from "node:path";
4
-
5
- import { normalizeArtifactSymlinks } from "./artifact-postprocess.ts";
6
1
  import { type BuildSettings, resolveBuildSettings } from "./build-settings.ts";
7
2
  import type { BuildArtifact, BuildStrategy } from "./build-strategy.ts";
8
- import { hasPackageDependency } from "./build-strategy.ts";
9
- import { defaultHttpPortForBuildType } from "./config/frameworks.ts";
10
- import { type BuildCommandIo, runBuildCommand } from "./workspace.ts";
3
+ import {
4
+ hasPackageDependency,
5
+ runBuildSettingsCommand,
6
+ } from "./build-strategy.ts";
7
+ import { stageConfiguredArtifact } from "./configured-artifact.ts";
8
+ import type { BuildCommandIo } from "./workspace.ts";
11
9
 
12
10
  const TANSTACK_START_PACKAGES = [
13
11
  "@tanstack/react-start",
@@ -47,51 +45,31 @@ export class TanstackStartBuild implements BuildStrategy {
47
45
  buildType: "tanstack-start",
48
46
  signal,
49
47
  }));
50
- if (settings.buildCommand) {
51
- await runBuildCommand({
52
- appPath: this.#appPath,
53
- command: settings.buildCommand,
54
- failurePrefix: "TanStack Start",
55
- env: this.#io?.env,
56
- onOutput: this.#io?.onOutput,
57
- signal,
58
- });
59
- }
60
-
61
- const outputDir = path.join(this.#appPath, settings.outputDirectory);
62
- const entrypoint = "server/index.mjs";
63
- const entryStat = await stat(path.join(outputDir, entrypoint)).catch(
64
- () => null,
65
- );
66
- if (!entryStat?.isFile()) {
67
- throw new Error(
68
- `TanStack Start build did not produce a Nitro node server entrypoint at ${settings.outputDirectory}/${entrypoint}. ` +
69
- "Ensure your vite.config includes the tanstackStart() and nitro() plugins with the default node preset.",
70
- );
71
- }
72
-
73
- const outDir = await mkdtemp(path.join(os.tmpdir(), "compute-build-"));
74
- try {
75
- const artifactDir = path.join(outDir, "app");
76
- await cp(outputDir, artifactDir, {
77
- recursive: true,
78
- verbatimSymlinks: true,
79
- });
80
- // Materialize any symlinks into the app/workspace node_modules so the
81
- // artifact is self-contained once unpacked elsewhere.
82
- await normalizeArtifactSymlinks(artifactDir, this.#appPath, signal);
48
+ await runBuildSettingsCommand({
49
+ appPath: this.#appPath,
50
+ settings,
51
+ failurePrefix: "TanStack Start",
52
+ defaultCli: {
53
+ source: "TanStack Start default",
54
+ cliName: "vite",
55
+ args: ["build"],
56
+ missingMessage:
57
+ "Could not find the Vite CLI. Install it with `npm install vite` or ensure npx/bunx is available.",
58
+ },
59
+ io: this.#io,
60
+ signal,
61
+ });
83
62
 
84
- return {
85
- directory: artifactDir,
86
- entrypoint,
87
- defaultPortMapping: {
88
- http: defaultHttpPortForBuildType("tanstack-start"),
89
- },
90
- cleanup: () => rm(outDir, { recursive: true, force: true }),
91
- };
92
- } catch (error) {
93
- await rm(outDir, { recursive: true, force: true });
94
- throw error;
95
- }
63
+ return stageConfiguredArtifact({
64
+ appPath: this.#appPath,
65
+ outputDirectory: settings.outputDirectory,
66
+ entrypoint: settings.entrypoint ?? "server/index.mjs",
67
+ buildType: "tanstack-start",
68
+ label: "TanStack Start",
69
+ missingEntrypointMessage: settings.entrypoint
70
+ ? undefined
71
+ : `TanStack Start build did not produce a Nitro node server entrypoint at ${settings.outputDirectory}/server/index.mjs. Ensure your vite.config includes the tanstackStart() and nitro() plugins with the default node preset.`,
72
+ signal,
73
+ });
96
74
  }
97
75
  }
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
  }