@vercel/sandbox 2.0.0-beta.13 → 2.0.0-beta.18

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 (79) hide show
  1. package/dist/api-client/api-client.cjs +3 -15
  2. package/dist/api-client/api-client.cjs.map +1 -1
  3. package/dist/api-client/api-client.d.cts +5510 -76
  4. package/dist/api-client/api-client.d.ts +5510 -76
  5. package/dist/api-client/api-client.js +4 -16
  6. package/dist/api-client/api-client.js.map +1 -1
  7. package/dist/api-client/base-client.cjs +2 -1
  8. package/dist/api-client/base-client.cjs.map +1 -1
  9. package/dist/api-client/base-client.js +2 -1
  10. package/dist/api-client/base-client.js.map +1 -1
  11. package/dist/api-client/index.d.ts +1 -1
  12. package/dist/api-client/index.js +1 -1
  13. package/dist/api-client/validators.cjs +60 -16
  14. package/dist/api-client/validators.cjs.map +1 -1
  15. package/dist/api-client/validators.d.cts +25546 -130
  16. package/dist/api-client/validators.d.ts +25546 -130
  17. package/dist/api-client/validators.js +55 -16
  18. package/dist/api-client/validators.js.map +1 -1
  19. package/dist/auth/api.cjs +1 -1
  20. package/dist/auth/api.cjs.map +1 -1
  21. package/dist/auth/api.js +1 -1
  22. package/dist/auth/api.js.map +1 -1
  23. package/dist/auth/file.d.cts +3 -3
  24. package/dist/auth/file.d.ts +3 -3
  25. package/dist/auth/index.cjs +0 -1
  26. package/dist/auth/index.d.cts +2 -2
  27. package/dist/auth/index.d.ts +2 -2
  28. package/dist/auth/index.js +2 -2
  29. package/dist/auth/project.cjs +124 -26
  30. package/dist/auth/project.cjs.map +1 -1
  31. package/dist/auth/project.d.cts +9 -13
  32. package/dist/auth/project.d.ts +9 -13
  33. package/dist/auth/project.js +125 -26
  34. package/dist/auth/project.js.map +1 -1
  35. package/dist/filesystem.cjs +499 -0
  36. package/dist/filesystem.cjs.map +1 -0
  37. package/dist/filesystem.d.cts +258 -0
  38. package/dist/filesystem.d.ts +258 -0
  39. package/dist/filesystem.js +497 -0
  40. package/dist/filesystem.js.map +1 -0
  41. package/dist/index.cjs +2 -0
  42. package/dist/index.d.cts +4 -3
  43. package/dist/index.d.ts +4 -3
  44. package/dist/index.js +2 -1
  45. package/dist/network-policy.d.cts +58 -2
  46. package/dist/network-policy.d.ts +58 -2
  47. package/dist/sandbox.cjs +138 -22
  48. package/dist/sandbox.cjs.map +1 -1
  49. package/dist/sandbox.d.cts +2069 -22
  50. package/dist/sandbox.d.ts +2069 -22
  51. package/dist/sandbox.js +138 -22
  52. package/dist/sandbox.js.map +1 -1
  53. package/dist/session.cjs +10 -7
  54. package/dist/session.cjs.map +1 -1
  55. package/dist/session.d.cts +7 -5
  56. package/dist/session.d.ts +7 -5
  57. package/dist/session.js +10 -7
  58. package/dist/session.js.map +1 -1
  59. package/dist/snapshot.cjs +63 -10
  60. package/dist/snapshot.cjs.map +1 -1
  61. package/dist/snapshot.d.cts +41 -9
  62. package/dist/snapshot.d.ts +41 -9
  63. package/dist/snapshot.js +62 -10
  64. package/dist/snapshot.js.map +1 -1
  65. package/dist/utils/network-policy.cjs +23 -39
  66. package/dist/utils/network-policy.cjs.map +1 -1
  67. package/dist/utils/network-policy.js +23 -39
  68. package/dist/utils/network-policy.js.map +1 -1
  69. package/dist/utils/paginator.cjs +41 -0
  70. package/dist/utils/paginator.cjs.map +1 -0
  71. package/dist/utils/paginator.d.cts +16 -0
  72. package/dist/utils/paginator.d.ts +16 -0
  73. package/dist/utils/paginator.js +40 -0
  74. package/dist/utils/paginator.js.map +1 -0
  75. package/dist/version.cjs +1 -1
  76. package/dist/version.cjs.map +1 -1
  77. package/dist/version.js +1 -1
  78. package/dist/version.js.map +1 -1
  79. package/package.json +1 -1
@@ -0,0 +1,258 @@
1
+ import { Dirent, Stats } from "fs";
2
+
3
+ //#region src/filesystem.d.ts
4
+ type WriteFileData = string | Buffer | Uint8Array;
5
+ interface MkdirOptions {
6
+ recursive?: boolean;
7
+ signal?: AbortSignal;
8
+ }
9
+ interface RmOptions {
10
+ recursive?: boolean;
11
+ force?: boolean;
12
+ signal?: AbortSignal;
13
+ }
14
+ interface SandboxHandle {
15
+ readFileToBuffer(file: {
16
+ path: string;
17
+ }, opts?: {
18
+ signal?: AbortSignal;
19
+ }): Promise<Buffer | null>;
20
+ writeFiles(files: {
21
+ path: string;
22
+ content: Buffer;
23
+ }[], opts?: {
24
+ signal?: AbortSignal;
25
+ }): Promise<void>;
26
+ mkDir(path: string, opts?: {
27
+ signal?: AbortSignal;
28
+ }): Promise<void>;
29
+ runCommand(cmd: string, args?: string[], opts?: {
30
+ signal?: AbortSignal;
31
+ }): Promise<{
32
+ exitCode: number;
33
+ stdout(opts?: {
34
+ signal?: AbortSignal;
35
+ }): Promise<string>;
36
+ stderr(opts?: {
37
+ signal?: AbortSignal;
38
+ }): Promise<string>;
39
+ }>;
40
+ }
41
+ declare class FileSystem {
42
+ /** @internal */
43
+ private sandbox;
44
+ /** @internal */
45
+ constructor(sandbox: SandboxHandle);
46
+ /**
47
+ * Read the entire contents of a file.
48
+ *
49
+ * @param path - Path to the file
50
+ * @param options - Encoding or options object. If encoding is specified, returns a string; otherwise returns a Buffer.
51
+ */
52
+ readFile(path: string, options?: {
53
+ encoding?: null;
54
+ signal?: AbortSignal;
55
+ } | null): Promise<Buffer>;
56
+ readFile(path: string, options: {
57
+ encoding: BufferEncoding;
58
+ signal?: AbortSignal;
59
+ } | BufferEncoding): Promise<string>;
60
+ /**
61
+ * Write data to a file, replacing the file if it already exists.
62
+ *
63
+ * @param path - Path to the file
64
+ * @param data - The data to write
65
+ * @param options - Write options
66
+ */
67
+ writeFile(path: string, data: WriteFileData, options?: {
68
+ encoding?: BufferEncoding;
69
+ signal?: AbortSignal;
70
+ } | BufferEncoding): Promise<void>;
71
+ /**
72
+ * Append data to a file, creating the file if it does not yet exist.
73
+ *
74
+ * @param path - Path to the file
75
+ * @param data - The data to append
76
+ * @param options - Write options
77
+ */
78
+ appendFile(path: string, data: WriteFileData, options?: {
79
+ encoding?: BufferEncoding;
80
+ signal?: AbortSignal;
81
+ } | BufferEncoding): Promise<void>;
82
+ /**
83
+ * Create a directory.
84
+ *
85
+ * @param path - Path of the directory to create
86
+ * @param options - Options for directory creation
87
+ */
88
+ mkdir(path: string, options?: MkdirOptions | number): Promise<string | undefined>;
89
+ /**
90
+ * Read the contents of a directory.
91
+ *
92
+ * @param path - Path to the directory
93
+ * @param options - Options. When `withFileTypes` is true, returns `Dirent` objects.
94
+ */
95
+ readdir(path: string, options?: {
96
+ signal?: AbortSignal;
97
+ withFileTypes?: false;
98
+ }): Promise<string[]>;
99
+ readdir(path: string, options: {
100
+ signal?: AbortSignal;
101
+ withFileTypes: true;
102
+ }): Promise<Dirent[]>;
103
+ /**
104
+ * Get file status. Follows symbolic links.
105
+ *
106
+ * @param path - Path to the file
107
+ * @param options - Options
108
+ */
109
+ stat(path: string, options?: {
110
+ signal?: AbortSignal;
111
+ }): Promise<Stats>;
112
+ /**
113
+ * Get file status. Does not follow symbolic links.
114
+ *
115
+ * @param path - Path to the file
116
+ * @param options - Options
117
+ */
118
+ lstat(path: string, options?: {
119
+ signal?: AbortSignal;
120
+ }): Promise<Stats>;
121
+ /**
122
+ * Remove a file or symbolic link.
123
+ *
124
+ * @param path - Path to the file
125
+ * @param options - Options
126
+ */
127
+ unlink(path: string, options?: {
128
+ signal?: AbortSignal;
129
+ }): Promise<void>;
130
+ /**
131
+ * Remove files and directories.
132
+ *
133
+ * @param path - Path to remove
134
+ * @param options - Options
135
+ */
136
+ rm(path: string, options?: RmOptions): Promise<void>;
137
+ /**
138
+ * Remove a directory.
139
+ *
140
+ * @param path - Path to the directory
141
+ * @param options - Options
142
+ */
143
+ rmdir(path: string, options?: {
144
+ signal?: AbortSignal;
145
+ }): Promise<void>;
146
+ /**
147
+ * Rename a file or directory.
148
+ *
149
+ * @param oldPath - Current path
150
+ * @param newPath - New path
151
+ * @param options - Options
152
+ */
153
+ rename(oldPath: string, newPath: string, options?: {
154
+ signal?: AbortSignal;
155
+ }): Promise<void>;
156
+ /**
157
+ * Copy a file.
158
+ *
159
+ * @param src - Source path
160
+ * @param dest - Destination path
161
+ * @param options - Options
162
+ */
163
+ copyFile(src: string, dest: string, options?: {
164
+ signal?: AbortSignal;
165
+ }): Promise<void>;
166
+ /**
167
+ * Test whether a file exists and the user has the specified permissions.
168
+ *
169
+ * @param path - Path to the file
170
+ * @param options - Options
171
+ */
172
+ access(path: string, options?: {
173
+ signal?: AbortSignal;
174
+ }): Promise<void>;
175
+ /**
176
+ * Check if a path exists.
177
+ *
178
+ * This is a convenience method not in `node:fs/promises` but commonly needed.
179
+ *
180
+ * @param path - Path to check
181
+ * @param options - Options
182
+ */
183
+ exists(path: string, options?: {
184
+ signal?: AbortSignal;
185
+ }): Promise<boolean>;
186
+ /**
187
+ * Change file mode (permissions).
188
+ *
189
+ * @param path - Path to the file
190
+ * @param mode - File mode (e.g., 0o755 or "755")
191
+ * @param options - Options
192
+ */
193
+ chmod(path: string, mode: number | string, options?: {
194
+ signal?: AbortSignal;
195
+ }): Promise<void>;
196
+ /**
197
+ * Change file owner and group.
198
+ *
199
+ * @param path - Path to the file
200
+ * @param uid - User ID
201
+ * @param gid - Group ID
202
+ * @param options - Options
203
+ */
204
+ chown(path: string, uid: number, gid: number, options?: {
205
+ signal?: AbortSignal;
206
+ }): Promise<void>;
207
+ /**
208
+ * Create a symbolic link.
209
+ *
210
+ * @param target - The target of the symbolic link
211
+ * @param path - The path of the symbolic link to create
212
+ * @param options - Options
213
+ */
214
+ symlink(target: string, path: string, options?: {
215
+ signal?: AbortSignal;
216
+ }): Promise<void>;
217
+ /**
218
+ * Read the value of a symbolic link.
219
+ *
220
+ * @param path - Path to the symbolic link
221
+ * @param options - Options
222
+ */
223
+ readlink(path: string, options?: {
224
+ signal?: AbortSignal;
225
+ }): Promise<string>;
226
+ /**
227
+ * Resolve the real path of a file (resolving symlinks).
228
+ *
229
+ * @param path - Path to resolve
230
+ * @param options - Options
231
+ */
232
+ realpath(path: string, options?: {
233
+ signal?: AbortSignal;
234
+ }): Promise<string>;
235
+ /**
236
+ * Truncate a file to a specified length.
237
+ *
238
+ * @param path - Path to the file
239
+ * @param len - Length to truncate to (default: 0)
240
+ * @param options - Options
241
+ */
242
+ truncate(path: string, len?: number, options?: {
243
+ signal?: AbortSignal;
244
+ }): Promise<void>;
245
+ /**
246
+ * Create a unique temporary directory.
247
+ *
248
+ * @param prefix - The prefix for the temporary directory name
249
+ * @param options - Options
250
+ * @returns The path of the created temporary directory
251
+ */
252
+ mkdtemp(prefix: string, options?: {
253
+ signal?: AbortSignal;
254
+ }): Promise<string>;
255
+ }
256
+ //#endregion
257
+ export { FileSystem };
258
+ //# sourceMappingURL=filesystem.d.cts.map
@@ -0,0 +1,258 @@
1
+ import { Dirent, Stats } from "fs";
2
+
3
+ //#region src/filesystem.d.ts
4
+ type WriteFileData = string | Buffer | Uint8Array;
5
+ interface MkdirOptions {
6
+ recursive?: boolean;
7
+ signal?: AbortSignal;
8
+ }
9
+ interface RmOptions {
10
+ recursive?: boolean;
11
+ force?: boolean;
12
+ signal?: AbortSignal;
13
+ }
14
+ interface SandboxHandle {
15
+ readFileToBuffer(file: {
16
+ path: string;
17
+ }, opts?: {
18
+ signal?: AbortSignal;
19
+ }): Promise<Buffer | null>;
20
+ writeFiles(files: {
21
+ path: string;
22
+ content: Buffer;
23
+ }[], opts?: {
24
+ signal?: AbortSignal;
25
+ }): Promise<void>;
26
+ mkDir(path: string, opts?: {
27
+ signal?: AbortSignal;
28
+ }): Promise<void>;
29
+ runCommand(cmd: string, args?: string[], opts?: {
30
+ signal?: AbortSignal;
31
+ }): Promise<{
32
+ exitCode: number;
33
+ stdout(opts?: {
34
+ signal?: AbortSignal;
35
+ }): Promise<string>;
36
+ stderr(opts?: {
37
+ signal?: AbortSignal;
38
+ }): Promise<string>;
39
+ }>;
40
+ }
41
+ declare class FileSystem {
42
+ /** @internal */
43
+ private sandbox;
44
+ /** @internal */
45
+ constructor(sandbox: SandboxHandle);
46
+ /**
47
+ * Read the entire contents of a file.
48
+ *
49
+ * @param path - Path to the file
50
+ * @param options - Encoding or options object. If encoding is specified, returns a string; otherwise returns a Buffer.
51
+ */
52
+ readFile(path: string, options?: {
53
+ encoding?: null;
54
+ signal?: AbortSignal;
55
+ } | null): Promise<Buffer>;
56
+ readFile(path: string, options: {
57
+ encoding: BufferEncoding;
58
+ signal?: AbortSignal;
59
+ } | BufferEncoding): Promise<string>;
60
+ /**
61
+ * Write data to a file, replacing the file if it already exists.
62
+ *
63
+ * @param path - Path to the file
64
+ * @param data - The data to write
65
+ * @param options - Write options
66
+ */
67
+ writeFile(path: string, data: WriteFileData, options?: {
68
+ encoding?: BufferEncoding;
69
+ signal?: AbortSignal;
70
+ } | BufferEncoding): Promise<void>;
71
+ /**
72
+ * Append data to a file, creating the file if it does not yet exist.
73
+ *
74
+ * @param path - Path to the file
75
+ * @param data - The data to append
76
+ * @param options - Write options
77
+ */
78
+ appendFile(path: string, data: WriteFileData, options?: {
79
+ encoding?: BufferEncoding;
80
+ signal?: AbortSignal;
81
+ } | BufferEncoding): Promise<void>;
82
+ /**
83
+ * Create a directory.
84
+ *
85
+ * @param path - Path of the directory to create
86
+ * @param options - Options for directory creation
87
+ */
88
+ mkdir(path: string, options?: MkdirOptions | number): Promise<string | undefined>;
89
+ /**
90
+ * Read the contents of a directory.
91
+ *
92
+ * @param path - Path to the directory
93
+ * @param options - Options. When `withFileTypes` is true, returns `Dirent` objects.
94
+ */
95
+ readdir(path: string, options?: {
96
+ signal?: AbortSignal;
97
+ withFileTypes?: false;
98
+ }): Promise<string[]>;
99
+ readdir(path: string, options: {
100
+ signal?: AbortSignal;
101
+ withFileTypes: true;
102
+ }): Promise<Dirent[]>;
103
+ /**
104
+ * Get file status. Follows symbolic links.
105
+ *
106
+ * @param path - Path to the file
107
+ * @param options - Options
108
+ */
109
+ stat(path: string, options?: {
110
+ signal?: AbortSignal;
111
+ }): Promise<Stats>;
112
+ /**
113
+ * Get file status. Does not follow symbolic links.
114
+ *
115
+ * @param path - Path to the file
116
+ * @param options - Options
117
+ */
118
+ lstat(path: string, options?: {
119
+ signal?: AbortSignal;
120
+ }): Promise<Stats>;
121
+ /**
122
+ * Remove a file or symbolic link.
123
+ *
124
+ * @param path - Path to the file
125
+ * @param options - Options
126
+ */
127
+ unlink(path: string, options?: {
128
+ signal?: AbortSignal;
129
+ }): Promise<void>;
130
+ /**
131
+ * Remove files and directories.
132
+ *
133
+ * @param path - Path to remove
134
+ * @param options - Options
135
+ */
136
+ rm(path: string, options?: RmOptions): Promise<void>;
137
+ /**
138
+ * Remove a directory.
139
+ *
140
+ * @param path - Path to the directory
141
+ * @param options - Options
142
+ */
143
+ rmdir(path: string, options?: {
144
+ signal?: AbortSignal;
145
+ }): Promise<void>;
146
+ /**
147
+ * Rename a file or directory.
148
+ *
149
+ * @param oldPath - Current path
150
+ * @param newPath - New path
151
+ * @param options - Options
152
+ */
153
+ rename(oldPath: string, newPath: string, options?: {
154
+ signal?: AbortSignal;
155
+ }): Promise<void>;
156
+ /**
157
+ * Copy a file.
158
+ *
159
+ * @param src - Source path
160
+ * @param dest - Destination path
161
+ * @param options - Options
162
+ */
163
+ copyFile(src: string, dest: string, options?: {
164
+ signal?: AbortSignal;
165
+ }): Promise<void>;
166
+ /**
167
+ * Test whether a file exists and the user has the specified permissions.
168
+ *
169
+ * @param path - Path to the file
170
+ * @param options - Options
171
+ */
172
+ access(path: string, options?: {
173
+ signal?: AbortSignal;
174
+ }): Promise<void>;
175
+ /**
176
+ * Check if a path exists.
177
+ *
178
+ * This is a convenience method not in `node:fs/promises` but commonly needed.
179
+ *
180
+ * @param path - Path to check
181
+ * @param options - Options
182
+ */
183
+ exists(path: string, options?: {
184
+ signal?: AbortSignal;
185
+ }): Promise<boolean>;
186
+ /**
187
+ * Change file mode (permissions).
188
+ *
189
+ * @param path - Path to the file
190
+ * @param mode - File mode (e.g., 0o755 or "755")
191
+ * @param options - Options
192
+ */
193
+ chmod(path: string, mode: number | string, options?: {
194
+ signal?: AbortSignal;
195
+ }): Promise<void>;
196
+ /**
197
+ * Change file owner and group.
198
+ *
199
+ * @param path - Path to the file
200
+ * @param uid - User ID
201
+ * @param gid - Group ID
202
+ * @param options - Options
203
+ */
204
+ chown(path: string, uid: number, gid: number, options?: {
205
+ signal?: AbortSignal;
206
+ }): Promise<void>;
207
+ /**
208
+ * Create a symbolic link.
209
+ *
210
+ * @param target - The target of the symbolic link
211
+ * @param path - The path of the symbolic link to create
212
+ * @param options - Options
213
+ */
214
+ symlink(target: string, path: string, options?: {
215
+ signal?: AbortSignal;
216
+ }): Promise<void>;
217
+ /**
218
+ * Read the value of a symbolic link.
219
+ *
220
+ * @param path - Path to the symbolic link
221
+ * @param options - Options
222
+ */
223
+ readlink(path: string, options?: {
224
+ signal?: AbortSignal;
225
+ }): Promise<string>;
226
+ /**
227
+ * Resolve the real path of a file (resolving symlinks).
228
+ *
229
+ * @param path - Path to resolve
230
+ * @param options - Options
231
+ */
232
+ realpath(path: string, options?: {
233
+ signal?: AbortSignal;
234
+ }): Promise<string>;
235
+ /**
236
+ * Truncate a file to a specified length.
237
+ *
238
+ * @param path - Path to the file
239
+ * @param len - Length to truncate to (default: 0)
240
+ * @param options - Options
241
+ */
242
+ truncate(path: string, len?: number, options?: {
243
+ signal?: AbortSignal;
244
+ }): Promise<void>;
245
+ /**
246
+ * Create a unique temporary directory.
247
+ *
248
+ * @param prefix - The prefix for the temporary directory name
249
+ * @param options - Options
250
+ * @returns The path of the created temporary directory
251
+ */
252
+ mkdtemp(prefix: string, options?: {
253
+ signal?: AbortSignal;
254
+ }): Promise<string>;
255
+ }
256
+ //#endregion
257
+ export { FileSystem };
258
+ //# sourceMappingURL=filesystem.d.ts.map