@prisma/compute-sdk 0.30.0 → 0.32.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 (48) hide show
  1. package/dist/artifact-stage.d.ts +19 -0
  2. package/dist/artifact-stage.d.ts.map +1 -1
  3. package/dist/artifact-stage.js +24 -10
  4. package/dist/artifact-stage.js.map +1 -1
  5. package/dist/astro-build.d.ts.map +1 -1
  6. package/dist/astro-build.js +1 -0
  7. package/dist/astro-build.js.map +1 -1
  8. package/dist/config/index.d.ts +1 -1
  9. package/dist/config/index.d.ts.map +1 -1
  10. package/dist/config/index.js +1 -1
  11. package/dist/config/index.js.map +1 -1
  12. package/dist/config/normalize.d.ts +3 -1
  13. package/dist/config/normalize.d.ts.map +1 -1
  14. package/dist/config/normalize.js +24 -6
  15. package/dist/config/normalize.js.map +1 -1
  16. package/dist/config/serialize.d.ts.map +1 -1
  17. package/dist/config/serialize.js +26 -3
  18. package/dist/config/serialize.js.map +1 -1
  19. package/dist/config/types.d.ts +15 -3
  20. package/dist/config/types.d.ts.map +1 -1
  21. package/dist/config/types.js +9 -0
  22. package/dist/config/types.js.map +1 -1
  23. package/dist/configured-artifact-trace.d.ts +15 -0
  24. package/dist/configured-artifact-trace.d.ts.map +1 -0
  25. package/dist/configured-artifact-trace.js +58 -0
  26. package/dist/configured-artifact-trace.js.map +1 -0
  27. package/dist/configured-artifact.d.ts +1 -0
  28. package/dist/configured-artifact.d.ts.map +1 -1
  29. package/dist/configured-artifact.js +10 -0
  30. package/dist/configured-artifact.js.map +1 -1
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js.map +1 -1
  34. package/dist/types.d.ts +1 -0
  35. package/dist/types.d.ts.map +1 -1
  36. package/dist/types.js +2 -8
  37. package/dist/types.js.map +1 -1
  38. package/package.json +1 -1
  39. package/src/artifact-stage.ts +38 -18
  40. package/src/astro-build.ts +1 -0
  41. package/src/config/index.ts +3 -0
  42. package/src/config/normalize.ts +58 -5
  43. package/src/config/serialize.ts +39 -4
  44. package/src/config/types.ts +27 -2
  45. package/src/configured-artifact-trace.ts +98 -0
  46. package/src/configured-artifact.ts +11 -0
  47. package/src/index.ts +1 -0
  48. package/src/types.ts +5 -9
@@ -0,0 +1,98 @@
1
+ import { realpath } from "node:fs/promises";
2
+ import path from "node:path";
3
+
4
+ import { nodeFileTrace } from "@vercel/nft";
5
+
6
+ import {
7
+ copyPathMaterializingSymlinks,
8
+ hoistIsolatedStoreDependencies,
9
+ isPathWithin,
10
+ } from "./artifact-stage.ts";
11
+ import { resolveSourceRoot } from "./config/source-root.ts";
12
+
13
+ /**
14
+ * Configured artifacts copy an output directory's contents to the artifact
15
+ * root. Runtime dependencies traced from that output need the same relocation:
16
+ * app-local node_modules become artifact-root node_modules, while hoisted
17
+ * workspace deps and workspace packages keep enough source-root layout for
18
+ * bare imports and package symlinks to resolve after unpacking.
19
+ */
20
+ export async function stageConfiguredArtifactDependencies(options: {
21
+ appPath: string;
22
+ artifactDir: string;
23
+ outputDirectory: string;
24
+ entrypoint: string;
25
+ signal?: AbortSignal;
26
+ }): Promise<void> {
27
+ const [appRoot, outputRoot] = await Promise.all([
28
+ realpath(path.resolve(options.appPath)),
29
+ realpath(path.resolve(options.outputDirectory)),
30
+ ]);
31
+ const sourceRoot = await resolveSourceRoot(appRoot, options.signal);
32
+ const entrypointPath = path.join(outputRoot, options.entrypoint);
33
+
34
+ options.signal?.throwIfAborted();
35
+ const { fileList } = await nodeFileTrace([entrypointPath], {
36
+ base: sourceRoot,
37
+ });
38
+
39
+ for (const relativePath of fileList) {
40
+ options.signal?.throwIfAborted();
41
+ const sourcePath = path.join(sourceRoot, relativePath);
42
+ if (isPathWithin(outputRoot, sourcePath)) {
43
+ continue;
44
+ }
45
+
46
+ await copyPathMaterializingSymlinks(
47
+ sourcePath,
48
+ path.join(
49
+ options.artifactDir,
50
+ artifactRelativePathForTrace(sourcePath, {
51
+ appRoot,
52
+ sourceRoot,
53
+ }),
54
+ ),
55
+ {
56
+ appRoot,
57
+ sourceRoot,
58
+ allowedSymlinkTargetRoots: [appRoot, sourceRoot],
59
+ ignoreMissingSource: true,
60
+ signal: options.signal,
61
+ },
62
+ );
63
+ }
64
+
65
+ await hoistIsolatedStoreDependencies(
66
+ path.join(options.artifactDir, "node_modules"),
67
+ options.signal,
68
+ );
69
+ }
70
+
71
+ function artifactRelativePathForTrace(
72
+ sourcePath: string,
73
+ options: { appRoot: string; sourceRoot: string },
74
+ ): string {
75
+ const resolvedSource = path.resolve(sourcePath);
76
+ const appNodeModules = path.join(options.appRoot, "node_modules");
77
+ const sourceNodeModules = path.join(options.sourceRoot, "node_modules");
78
+
79
+ if (isPathWithin(appNodeModules, resolvedSource)) {
80
+ return path.join(
81
+ "node_modules",
82
+ path.relative(appNodeModules, resolvedSource),
83
+ );
84
+ }
85
+
86
+ if (isPathWithin(options.appRoot, resolvedSource)) {
87
+ return path.relative(options.appRoot, resolvedSource);
88
+ }
89
+
90
+ if (isPathWithin(sourceNodeModules, resolvedSource)) {
91
+ return path.join(
92
+ "node_modules",
93
+ path.relative(sourceNodeModules, resolvedSource),
94
+ );
95
+ }
96
+
97
+ return path.relative(options.sourceRoot, resolvedSource);
98
+ }
@@ -8,6 +8,7 @@ import {
8
8
  defaultHttpPortForBuildType,
9
9
  type FrameworkBuildType,
10
10
  } from "./config/frameworks.ts";
11
+ import { stageConfiguredArtifactDependencies } from "./configured-artifact-trace.ts";
11
12
 
12
13
  export async function stageConfiguredArtifact(options: {
13
14
  appPath: string;
@@ -16,6 +17,7 @@ export async function stageConfiguredArtifact(options: {
16
17
  buildType: FrameworkBuildType;
17
18
  label: string;
18
19
  missingEntrypointMessage?: string;
20
+ traceDependencies?: boolean;
19
21
  signal?: AbortSignal;
20
22
  }): Promise<BuildArtifact> {
21
23
  options.signal?.throwIfAborted();
@@ -61,6 +63,15 @@ export async function stageConfiguredArtifact(options: {
61
63
  options.appPath,
62
64
  options.signal,
63
65
  );
66
+ if (options.traceDependencies) {
67
+ await stageConfiguredArtifactDependencies({
68
+ appPath: realAppPath,
69
+ artifactDir,
70
+ outputDirectory: realOutputDir,
71
+ entrypoint,
72
+ signal: options.signal,
73
+ });
74
+ }
64
75
 
65
76
  return {
66
77
  directory: artifactDir,
package/src/index.ts CHANGED
@@ -120,6 +120,7 @@ export { TanstackStartBuild } from "./tanstack-start-build.ts";
120
120
  export type {
121
121
  AppDetail,
122
122
  AppInfo,
123
+ ComputeRegion,
123
124
  CreateProjectResult,
124
125
  DatabaseInfo,
125
126
  DeploymentDetail,
package/src/types.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  * Domain types for the Compute SDK.
3
3
  */
4
4
 
5
+ import { COMPUTE_REGIONS } from "./config/types.ts";
6
+
5
7
  export interface PortMapping {
6
8
  http?: number | null;
7
9
  }
@@ -61,16 +63,10 @@ export interface ResolvedConfig {
61
63
  portMapping?: PortMapping;
62
64
  }
63
65
 
64
- /** Known compute region identifiers, used by the CLI for interactive prompts. */
65
- export const KNOWN_REGION_IDS = [
66
- "us-east-1",
67
- "us-west-1",
68
- "eu-west-3",
69
- "eu-central-1",
70
- "ap-northeast-1",
71
- "ap-southeast-1",
72
- ] as const;
66
+ export type { ComputeRegion } from "./config/types.ts";
73
67
 
68
+ /** Known compute region identifiers, used by the CLI for interactive prompts. */
69
+ export const KNOWN_REGION_IDS = COMPUTE_REGIONS;
74
70
  export const REGIONS: RegionInfo[] = KNOWN_REGION_IDS.map((id) => ({
75
71
  id,
76
72
  displayName: id,