@vercel/sandbox 0.0.2 → 0.0.4

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 (37) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-typecheck.log +1 -1
  3. package/CHANGELOG.md +12 -0
  4. package/README.md +22 -17
  5. package/dist/{src/client → client}/client.d.ts +2 -1
  6. package/dist/{src/client → client}/client.js +1 -0
  7. package/dist/{src/create-sandbox.d.ts → create-sandbox.d.ts} +36 -15
  8. package/dist/{src/create-sandbox.js → create-sandbox.js} +34 -16
  9. package/dist/index.d.ts +2 -0
  10. package/dist/{src/index.js → index.js} +2 -2
  11. package/dist/version.d.ts +1 -0
  12. package/dist/{src/version.js → version.js} +1 -1
  13. package/package.json +2 -1
  14. package/src/client/client.ts +3 -1
  15. package/src/create-sandbox.ts +37 -15
  16. package/src/index.ts +1 -1
  17. package/src/version.ts +1 -1
  18. package/tsconfig.json +1 -1
  19. package/dist/package.json +0 -31
  20. package/dist/scripts/inject-version.d.ts +0 -1
  21. package/dist/scripts/inject-version.js +0 -14
  22. package/dist/src/index.d.ts +0 -2
  23. package/dist/src/version.d.ts +0 -1
  24. /package/dist/{src/client → client}/api-error.d.ts +0 -0
  25. /package/dist/{src/client → client}/api-error.js +0 -0
  26. /package/dist/{src/client → client}/base-client.d.ts +0 -0
  27. /package/dist/{src/client → client}/base-client.js +0 -0
  28. /package/dist/{src/client → client}/validators.d.ts +0 -0
  29. /package/dist/{src/client → client}/validators.js +0 -0
  30. /package/dist/{src/client → client}/with-retry.d.ts +0 -0
  31. /package/dist/{src/client → client}/with-retry.js +0 -0
  32. /package/dist/{src/utils → utils}/array.d.ts +0 -0
  33. /package/dist/{src/utils → utils}/array.js +0 -0
  34. /package/dist/{src/utils → utils}/deferred-generator.d.ts +0 -0
  35. /package/dist/{src/utils → utils}/deferred-generator.js +0 -0
  36. /package/dist/{src/utils → utils}/deferred.d.ts +0 -0
  37. /package/dist/{src/utils → utils}/deferred.js +0 -0
@@ -1,4 +1,4 @@
1
1
 
2
- > @vercel/sandbox@0.0.2 build /home/runner/work/sandbox-sdk/sandbox-sdk/packages/sandbox
2
+ > @vercel/sandbox@0.0.4 build /home/runner/work/sandbox-sdk/sandbox-sdk/packages/sandbox
3
3
  > tsc
4
4
 
@@ -1,4 +1,4 @@
1
1
 
2
- > @vercel/sandbox@0.0.2 typecheck /home/runner/work/sandbox-sdk/sandbox-sdk/packages/sandbox
2
+ > @vercel/sandbox@0.0.4 typecheck /home/runner/work/sandbox-sdk/sandbox-sdk/packages/sandbox
3
3
  > tsc --noEmit
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @vercel/sandbox
2
2
 
3
+ ## 0.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Rename `SandboxSDK` to `SDK` and incorporate `projectId` as a required parameter ([#21](https://github.com/vercel/sandbox-sdk/pull/21))
8
+
9
+ ## 0.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - Do not include dev scripts in package output ([#16](https://github.com/vercel/sandbox-sdk/pull/16))
14
+
3
15
  ## 0.0.2
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -12,31 +12,36 @@ infrastructure][hive] that powers 1M+ builds a day at Vercel.
12
12
  Vercel Sandbox is in private beta. These examples will not work unless these
13
13
  APIs are enabled for your team.
14
14
 
15
- - Go to your team settings, and copy the team ID.
16
- - Go to your Vercel account settings and [create a token][create-token]. Make
17
- sure it is scoped to the team ID from the previous step.
18
- - Create a new project:
19
-
20
- ```
21
- $ mkdir sandbox-test
22
- $ pnpm init
23
- $ pnpm add @vercel/sandbox
24
- $ pnpm add --save-dev tsx
15
+ - Go to your team settings, and copy the team ID.
16
+ - Go to your Vercel account settings and [create a token][create-token]. Make
17
+ sure it is scoped to the team ID from the previous step.
18
+ - Create a new project:
19
+
20
+ ```sh
21
+ mkdir sandbox-test
22
+ cd sandbox-test
23
+ pnpm init
24
+ pnpm add @vercel/sandbox ms
25
25
  ```
26
26
 
27
- Now create `whoami.ts`:
27
+ Now create `next-dev.ts`:
28
28
 
29
- {@includeCode ../cli/src/example-whoami.ts}
29
+ {@includeCode ../cli/src/example-next.ts}
30
30
 
31
31
  Run it like this:
32
32
 
33
+ ```sh
34
+ VERCEL_TEAM_ID=<team_id> VERCEL_TOKEN=<token> node --experimental-strip-types ./next-dev.ts
33
35
  ```
34
- $ VERCEL_TEAM_ID=<team_id> VERCEL_TOKEN=<token> pnpm tsx ./whoami.ts
35
- Running as: vercel-sandbox
36
- Working dir: /vercel/sandbox
37
- ```
38
36
 
39
- Now have a look at the sidebar for which classes exist.
37
+ This will:
38
+
39
+ - Start a sandbox, seeding it with a git repository.
40
+ - Install dependencies.
41
+ - Run a `next dev` server
42
+ - Open it in your browser
43
+
44
+ All while streaming logs to your local terminal.
40
45
 
41
46
  ## Limitations
42
47
 
@@ -9,11 +9,12 @@ export declare class SandboxClient extends APIClient {
9
9
  });
10
10
  protected request(path: string, params?: RequestParams): Promise<import("node-fetch").Response>;
11
11
  createSandbox(params: {
12
+ ports: number[];
13
+ projectId: string;
12
14
  source: {
13
15
  type: "git";
14
16
  url: string;
15
17
  };
16
- ports: number[];
17
18
  timeout?: number;
18
19
  }): Promise<import("./base-client").Parsed<{
19
20
  sandboxId: string;
@@ -36,6 +36,7 @@ class SandboxClient extends base_client_1.APIClient {
36
36
  return (0, base_client_1.parseOrThrow)(validators_1.CreatedSandbox, await this.request("/v1/sandboxes", {
37
37
  method: "POST",
38
38
  body: JSON.stringify({
39
+ projectId: params.projectId,
39
40
  ports: params.ports,
40
41
  source: params.source,
41
42
  timeout: params.timeout,
@@ -1,36 +1,57 @@
1
1
  import { SandboxClient } from "./client/client";
2
2
  import { Readable } from "stream";
3
3
  /**
4
- * Create a new instance of the SandboxSDK.
4
+ * SDK for interacting with the Sandbox API. Provides methods to create and
5
+ * manage sandboxes configured with specific source code and network ports.
5
6
  *
6
- * ````
7
- * const teamId = process.env.VERCEL_TEAM_ID
8
- * const token = process.env.VERCEL_TOKEN
9
- * const sdk = new SandboxSDK({ teamId: teamId!, token: token! });
10
- * ````
7
+ * Example:
8
+ * ```ts
9
+ * const sdk = new SDK({
10
+ * teamId: process.env.VERCEL_TEAM_ID!,
11
+ * token: process.env.VERCEL_TOKEN!,
12
+ * });
13
+ * ```
11
14
  *
12
- * @see {@link createSandbox} to start a sandbox.
15
+ * @see {@link SDK.createSandbox} to start a new sandbox.
13
16
  */
14
- export declare class SandboxSDK {
15
- client: SandboxClient;
17
+ export declare class SDK {
18
+ /**
19
+ * Internal API client for communicating with the sandbox backend.
20
+ */
21
+ private client;
22
+ /**
23
+ * Create a new instance of `SDK`.
24
+ *
25
+ * @param config - Configuration options for the SDK.
26
+ * @param config.teamId - The Vercel team ID used to scope the Sandbox.
27
+ * @param config.token - The API token used for authentication.
28
+ */
16
29
  constructor({ teamId, token }: {
17
30
  teamId: string;
18
31
  token: string;
19
32
  });
20
33
  /**
21
- * Create a new Sandbox with the given resources, source code, and ports.
34
+ * Creates a new sandbox instance using the provided Git repository and exposed ports.
35
+ *
36
+ * The repository must be public. On start, the sandbox will clone the repository
37
+ * and expose the specified ports for access.
22
38
  *
23
- * Upon start, the sandbox will perform a `git clone` of the repository given.
24
- * This repo needs to be public.
39
+ * @param params - Configuration parameters for the sandbox.
40
+ * @param params.source - The source of the sandbox, currently supports Git repositories only.
41
+ * @param params.source.type - Type of source, must be `"git"`.
42
+ * @param params.source.url - The URL of the public Git repository to clone.
43
+ * @param config.projectId - The Vercel project ID used to link the Sandbox to.
44
+ * @param params.ports - Array of port numbers to expose from the sandbox.
45
+ * @param params.timeout - (Optional) Timeout in seconds before the sandbox auto-terminates.
25
46
  *
26
- * @param params
27
- * @returns a
47
+ * @returns A promise that resolves to a `Sandbox` instance.
28
48
  */
29
49
  createSandbox(params: {
30
50
  source: {
31
51
  type: "git";
32
52
  url: string;
33
53
  };
54
+ projectId: string;
34
55
  ports: number[];
35
56
  timeout?: number;
36
57
  }): Promise<Sandbox>;
@@ -46,7 +67,7 @@ export declare class SandboxSDK {
46
67
  /**
47
68
  * A Sandbox is an isolated Linux MicroVM that you can your experiments on.
48
69
  *
49
- * @see {@link SandboxSDK.createSandbox} to construct a Sandbox.
70
+ * @see {@link SDK.createSandbox} to construct a Sandbox.
50
71
  * @hideconstructor
51
72
  */
52
73
  export declare class Sandbox {
@@ -1,35 +1,53 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Command = exports.Sandbox = exports.SandboxSDK = void 0;
3
+ exports.Command = exports.Sandbox = exports.SDK = void 0;
4
4
  const client_1 = require("./client/client");
5
5
  /**
6
- * Create a new instance of the SandboxSDK.
6
+ * SDK for interacting with the Sandbox API. Provides methods to create and
7
+ * manage sandboxes configured with specific source code and network ports.
7
8
  *
8
- * ````
9
- * const teamId = process.env.VERCEL_TEAM_ID
10
- * const token = process.env.VERCEL_TOKEN
11
- * const sdk = new SandboxSDK({ teamId: teamId!, token: token! });
12
- * ````
9
+ * Example:
10
+ * ```ts
11
+ * const sdk = new SDK({
12
+ * teamId: process.env.VERCEL_TEAM_ID!,
13
+ * token: process.env.VERCEL_TOKEN!,
14
+ * });
15
+ * ```
13
16
  *
14
- * @see {@link createSandbox} to start a sandbox.
17
+ * @see {@link SDK.createSandbox} to start a new sandbox.
15
18
  */
16
- class SandboxSDK {
19
+ class SDK {
20
+ /**
21
+ * Create a new instance of `SDK`.
22
+ *
23
+ * @param config - Configuration options for the SDK.
24
+ * @param config.teamId - The Vercel team ID used to scope the Sandbox.
25
+ * @param config.token - The API token used for authentication.
26
+ */
17
27
  constructor({ teamId, token }) {
18
28
  this.client = new client_1.SandboxClient({ teamId, token });
19
29
  }
20
30
  /**
21
- * Create a new Sandbox with the given resources, source code, and ports.
31
+ * Creates a new sandbox instance using the provided Git repository and exposed ports.
32
+ *
33
+ * The repository must be public. On start, the sandbox will clone the repository
34
+ * and expose the specified ports for access.
22
35
  *
23
- * Upon start, the sandbox will perform a `git clone` of the repository given.
24
- * This repo needs to be public.
36
+ * @param params - Configuration parameters for the sandbox.
37
+ * @param params.source - The source of the sandbox, currently supports Git repositories only.
38
+ * @param params.source.type - Type of source, must be `"git"`.
39
+ * @param params.source.url - The URL of the public Git repository to clone.
40
+ * @param config.projectId - The Vercel project ID used to link the Sandbox to.
41
+ * @param params.ports - Array of port numbers to expose from the sandbox.
42
+ * @param params.timeout - (Optional) Timeout in seconds before the sandbox auto-terminates.
25
43
  *
26
- * @param params
27
- * @returns a
44
+ * @returns A promise that resolves to a `Sandbox` instance.
28
45
  */
29
46
  async createSandbox(params) {
30
47
  const { client } = this;
31
48
  const sandbox = await client.createSandbox({
32
49
  source: params.source,
50
+ projectId: params.projectId,
33
51
  ports: params.ports,
34
52
  timeout: params.timeout,
35
53
  });
@@ -48,11 +66,11 @@ class SandboxSDK {
48
66
  });
49
67
  }
50
68
  }
51
- exports.SandboxSDK = SandboxSDK;
69
+ exports.SDK = SDK;
52
70
  /**
53
71
  * A Sandbox is an isolated Linux MicroVM that you can your experiments on.
54
72
  *
55
- * @see {@link SandboxSDK.createSandbox} to construct a Sandbox.
73
+ * @see {@link SDK.createSandbox} to construct a Sandbox.
56
74
  * @hideconstructor
57
75
  */
58
76
  class Sandbox {
@@ -0,0 +1,2 @@
1
+ export { SDK, Sandbox, Command } from "./create-sandbox";
2
+ export { SandboxClient } from "./client/client";
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SandboxClient = exports.Command = exports.Sandbox = exports.SandboxSDK = void 0;
3
+ exports.SandboxClient = exports.Command = exports.Sandbox = exports.SDK = void 0;
4
4
  var create_sandbox_1 = require("./create-sandbox");
5
- Object.defineProperty(exports, "SandboxSDK", { enumerable: true, get: function () { return create_sandbox_1.SandboxSDK; } });
5
+ Object.defineProperty(exports, "SDK", { enumerable: true, get: function () { return create_sandbox_1.SDK; } });
6
6
  Object.defineProperty(exports, "Sandbox", { enumerable: true, get: function () { return create_sandbox_1.Sandbox; } });
7
7
  Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return create_sandbox_1.Command; } });
8
8
  var client_1 = require("./client/client");
@@ -0,0 +1 @@
1
+ export declare const VERSION = "0.0.4";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Autogenerated by inject-version.ts
5
- exports.VERSION = "0.0.2";
5
+ exports.VERSION = "0.0.4";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/sandbox",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,6 +23,7 @@
23
23
  "typescript": "5.8.3"
24
24
  },
25
25
  "scripts": {
26
+ "clean": "rm -rf node_modules dist",
26
27
  "build": "tsc",
27
28
  "typedoc": "typedoc",
28
29
  "typecheck": "tsc --noEmit",
@@ -41,8 +41,9 @@ export class SandboxClient extends APIClient {
41
41
  }
42
42
 
43
43
  async createSandbox(params: {
44
- source: { type: "git"; url: string };
45
44
  ports: number[];
45
+ projectId: string;
46
+ source: { type: "git"; url: string };
46
47
  timeout?: number;
47
48
  }) {
48
49
  return parseOrThrow(
@@ -50,6 +51,7 @@ export class SandboxClient extends APIClient {
50
51
  await this.request("/v1/sandboxes", {
51
52
  method: "POST",
52
53
  body: JSON.stringify({
54
+ projectId: params.projectId,
53
55
  ports: params.ports,
54
56
  source: params.source,
55
57
  timeout: params.timeout,
@@ -2,40 +2,62 @@ import { SandboxClient } from "./client/client";
2
2
  import { Readable } from "stream";
3
3
 
4
4
  /**
5
- * Create a new instance of the SandboxSDK.
5
+ * SDK for interacting with the Sandbox API. Provides methods to create and
6
+ * manage sandboxes configured with specific source code and network ports.
6
7
  *
7
- * ````
8
- * const teamId = process.env.VERCEL_TEAM_ID
9
- * const token = process.env.VERCEL_TOKEN
10
- * const sdk = new SandboxSDK({ teamId: teamId!, token: token! });
11
- * ````
8
+ * Example:
9
+ * ```ts
10
+ * const sdk = new SDK({
11
+ * teamId: process.env.VERCEL_TEAM_ID!,
12
+ * token: process.env.VERCEL_TOKEN!,
13
+ * });
14
+ * ```
12
15
  *
13
- * @see {@link createSandbox} to start a sandbox.
16
+ * @see {@link SDK.createSandbox} to start a new sandbox.
14
17
  */
15
- export class SandboxSDK {
16
- public client: SandboxClient;
18
+ export class SDK {
19
+ /**
20
+ * Internal API client for communicating with the sandbox backend.
21
+ */
22
+ private client: SandboxClient;
17
23
 
24
+ /**
25
+ * Create a new instance of `SDK`.
26
+ *
27
+ * @param config - Configuration options for the SDK.
28
+ * @param config.teamId - The Vercel team ID used to scope the Sandbox.
29
+ * @param config.token - The API token used for authentication.
30
+ */
18
31
  constructor({ teamId, token }: { teamId: string; token: string }) {
19
32
  this.client = new SandboxClient({ teamId, token });
20
33
  }
21
34
 
22
35
  /**
23
- * Create a new Sandbox with the given resources, source code, and ports.
36
+ * Creates a new sandbox instance using the provided Git repository and exposed ports.
37
+ *
38
+ * The repository must be public. On start, the sandbox will clone the repository
39
+ * and expose the specified ports for access.
24
40
  *
25
- * Upon start, the sandbox will perform a `git clone` of the repository given.
26
- * This repo needs to be public.
41
+ * @param params - Configuration parameters for the sandbox.
42
+ * @param params.source - The source of the sandbox, currently supports Git repositories only.
43
+ * @param params.source.type - Type of source, must be `"git"`.
44
+ * @param params.source.url - The URL of the public Git repository to clone.
45
+ * @param config.projectId - The Vercel project ID used to link the Sandbox to.
46
+ * @param params.ports - Array of port numbers to expose from the sandbox.
47
+ * @param params.timeout - (Optional) Timeout in seconds before the sandbox auto-terminates.
27
48
  *
28
- * @param params
29
- * @returns a
49
+ * @returns A promise that resolves to a `Sandbox` instance.
30
50
  */
31
51
  async createSandbox(params: {
32
52
  source: { type: "git"; url: string };
53
+ projectId: string;
33
54
  ports: number[];
34
55
  timeout?: number;
35
56
  }) {
36
57
  const { client } = this;
37
58
  const sandbox = await client.createSandbox({
38
59
  source: params.source,
60
+ projectId: params.projectId,
39
61
  ports: params.ports,
40
62
  timeout: params.timeout,
41
63
  });
@@ -66,7 +88,7 @@ export class SandboxSDK {
66
88
  /**
67
89
  * A Sandbox is an isolated Linux MicroVM that you can your experiments on.
68
90
  *
69
- * @see {@link SandboxSDK.createSandbox} to construct a Sandbox.
91
+ * @see {@link SDK.createSandbox} to construct a Sandbox.
70
92
  * @hideconstructor
71
93
  */
72
94
  export class Sandbox {
package/src/index.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { SandboxSDK, Sandbox, Command } from "./create-sandbox";
1
+ export { SDK, Sandbox, Command } from "./create-sandbox";
2
2
  export { SandboxClient } from "./client/client";
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Autogenerated by inject-version.ts
2
- export const VERSION = "0.0.2";
2
+ export const VERSION = "0.0.4";
package/tsconfig.json CHANGED
@@ -9,5 +9,5 @@
9
9
  "module": "commonjs",
10
10
  "resolveJsonModule": true
11
11
  },
12
- "include": ["scripts/**/*", "src/**/*"]
12
+ "include": ["src/**/*"]
13
13
  }
package/dist/package.json DELETED
@@ -1,31 +0,0 @@
1
- {
2
- "name": "@vercel/sandbox",
3
- "version": "0.0.2",
4
- "description": "",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsc",
9
- "typedoc": "typedoc",
10
- "typecheck": "tsc --noEmit",
11
- "inject-version": "ts-node scripts/inject-version.ts"
12
- },
13
- "keywords": [],
14
- "author": "",
15
- "license": "ISC",
16
- "dependencies": {
17
- "async-retry": "1.3.3",
18
- "form-data": "3.0.0",
19
- "jsonlines": "0.1.1",
20
- "node-fetch": "2.6.11",
21
- "zod": "3.24.4"
22
- },
23
- "devDependencies": {
24
- "@types/async-retry": "1.4.9",
25
- "@types/jsonlines": "0.1.5",
26
- "@types/node": "22.15.12",
27
- "@types/node-fetch": "2.6.12",
28
- "typedoc": "^0.28.4",
29
- "typescript": "5.8.3"
30
- }
31
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const package_json_1 = require("../package.json");
7
- const promises_1 = require("fs/promises");
8
- const path_1 = __importDefault(require("path"));
9
- async function main() {
10
- const outPath = path_1.default.resolve(__dirname, "../src/version.ts");
11
- const content = `// Autogenerated by inject-version.ts\nexport const VERSION = "${package_json_1.version}";\n`;
12
- await (0, promises_1.writeFile)(outPath, content);
13
- }
14
- main().catch(console.error);
@@ -1,2 +0,0 @@
1
- export { SandboxSDK, Sandbox, Command } from "./create-sandbox";
2
- export { SandboxClient } from "./client/client";
@@ -1 +0,0 @@
1
- export declare const VERSION = "0.0.2";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes