@daytonaio/sdk 0.18.0-alpha.1 → 0.18.0-alpha.2

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/Image.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- declare const SUPPORTED_PYTHON_SERIES: readonly ["3.9", "3.10", "3.11", "3.12", "3.13"];
2
- type SupportedPythonSeries = (typeof SUPPORTED_PYTHON_SERIES)[number];
1
+ declare const SUPPORTED_PYTHON_SERIES: readonly ['3.9', '3.10', '3.11', '3.12', '3.13']
2
+ type SupportedPythonSeries = (typeof SUPPORTED_PYTHON_SERIES)[number]
3
3
  /**
4
4
  * Represents a context file to be added to the image.
5
5
  *
@@ -8,8 +8,8 @@ type SupportedPythonSeries = (typeof SUPPORTED_PYTHON_SERIES)[number];
8
8
  * @property {string} archivePath - The path inside the archive file in object storage.
9
9
  */
10
10
  export interface Context {
11
- sourcePath: string;
12
- archivePath?: string;
11
+ sourcePath: string
12
+ archivePath?: string
13
13
  }
14
14
  /**
15
15
  * Options for the pip install command.
@@ -22,11 +22,11 @@ export interface Context {
22
22
  * @property {string} extraOptions - The extra options to use for the pip install command. Given string is passed directly to the pip install command.
23
23
  */
24
24
  export interface PipInstallOptions {
25
- findLinks?: string[];
26
- indexUrl?: string;
27
- extraIndexUrls?: string[];
28
- pre?: boolean;
29
- extraOptions?: string;
25
+ findLinks?: string[]
26
+ indexUrl?: string
27
+ extraIndexUrls?: string[]
28
+ pre?: boolean
29
+ extraOptions?: string
30
30
  }
31
31
  /**
32
32
  * Options for the pip install command from a pyproject.toml file.
@@ -37,7 +37,7 @@ export interface PipInstallOptions {
37
37
  * @extends {PipInstallOptions}
38
38
  */
39
39
  export interface PyprojectOptions extends PipInstallOptions {
40
- optionalDependencies?: string[];
40
+ optionalDependencies?: string[]
41
41
  }
42
42
  /**
43
43
  * Represents an image definition for a Daytona sandbox.
@@ -49,213 +49,213 @@ export interface PyprojectOptions extends PipInstallOptions {
49
49
  * @property {Context[]} contextList - The list of context files to be added to the image.
50
50
  */
51
51
  export declare class Image {
52
- private _dockerfile;
53
- private _contextList;
54
- private constructor();
55
- get dockerfile(): string;
56
- get contextList(): Context[];
57
- /**
58
- * Adds commands to install packages using pip.
59
- *
60
- * @param {string | string[]} packages - The packages to install.
61
- * @param {Object} options - The options for the pip install command.
62
- * @param {string[]} options.findLinks - The find-links to use for the pip install command.
63
- * @returns {Image} The Image instance.
64
- *
65
- * @example
66
- * const image = Image.debianSlim('3.12').pipInstall('numpy', { findLinks: ['https://pypi.org/simple'] })
67
- */
68
- pipInstall(packages: string | string[], options?: PipInstallOptions): Image;
69
- /**
70
- * Installs dependencies from a requirements.txt file.
71
- *
72
- * @param {string} requirementsTxt - The path to the requirements.txt file.
73
- * @param {PipInstallOptions} options - The options for the pip install command.
74
- * @returns {Image} The Image instance.
75
- *
76
- * @example
77
- * const image = Image.debianSlim('3.12')
78
- * image.pipInstallFromRequirements('requirements.txt', { findLinks: ['https://pypi.org/simple'] })
79
- */
80
- pipInstallFromRequirements(requirementsTxt: string, options?: PipInstallOptions): Image;
81
- /**
82
- * Installs dependencies from a pyproject.toml file.
83
- *
84
- * @param {string} pyprojectToml - The path to the pyproject.toml file.
85
- * @param {PyprojectOptions} options - The options for the pip install command.
86
- * @returns {Image} The Image instance.
87
- *
88
- * @example
89
- * const image = Image.debianSlim('3.12')
90
- * image.pipInstallFromPyproject('pyproject.toml', { optionalDependencies: ['dev'] })
91
- */
92
- pipInstallFromPyproject(pyprojectToml: string, options?: PyprojectOptions): Image;
93
- /**
94
- * Adds a local file to the image.
95
- *
96
- * @param {string} localPath - The path to the local file.
97
- * @param {string} remotePath - The path of the file in the image.
98
- * @returns {Image} The Image instance.
99
- *
100
- * @example
101
- * const image = Image
102
- * .debianSlim('3.12')
103
- * .addLocalFile('requirements.txt', '/home/daytona/requirements.txt')
104
- */
105
- addLocalFile(localPath: string, remotePath: string): Image;
106
- /**
107
- * Adds a local directory to the image.
108
- *
109
- * @param {string} localPath - The path to the local directory.
110
- * @param {string} remotePath - The path of the directory in the image.
111
- * @returns {Image} The Image instance.
112
- *
113
- * @example
114
- * const image = Image
115
- * .debianSlim('3.12')
116
- * .addLocalDir('src', '/home/daytona/src')
117
- */
118
- addLocalDir(localPath: string, remotePath: string): Image;
119
- /**
120
- * Runs commands in the image.
121
- *
122
- * @param {string | string[]} commands - The commands to run.
123
- * @returns {Image} The Image instance.
124
- *
125
- * @example
126
- * const image = Image
127
- * .debianSlim('3.12')
128
- * .runCommands('echo "Hello, world!"')
129
- */
130
- runCommands(...commands: (string | string[])[]): Image;
131
- /**
132
- * Sets environment variables in the image.
133
- *
134
- * @param {Record<string, string>} envVars - The environment variables to set.
135
- * @returns {Image} The Image instance.
136
- *
137
- * @example
138
- * const image = Image
139
- * .debianSlim('3.12')
140
- * .env({ FOO: 'bar' })
141
- */
142
- env(envVars: Record<string, string>): Image;
143
- /**
144
- * Sets the working directory in the image.
145
- *
146
- * @param {string} dirPath - The path to the working directory.
147
- * @returns {Image} The Image instance.
148
- *
149
- * @example
150
- * const image = Image
151
- * .debianSlim('3.12')
152
- * .workdir('/home/daytona')
153
- */
154
- workdir(dirPath: string): Image;
155
- /**
156
- * Sets the entrypoint for the image.
157
- *
158
- * @param {string[]} entrypointCommands - The commands to set as the entrypoint.
159
- * @returns {Image} The Image instance.
160
- *
161
- * @example
162
- * const image = Image
163
- * .debianSlim('3.12')
164
- * .entrypoint(['/bin/bash'])
165
- */
166
- entrypoint(entrypointCommands: string[]): Image;
167
- /**
168
- * Sets the default command for the image.
169
- *
170
- * @param {string[]} cmd - The command to set as the default command.
171
- * @returns {Image} The Image instance.
172
- *
173
- * @example
174
- * const image = Image
175
- * .debianSlim('3.12')
176
- * .cmd(['/bin/bash'])
177
- */
178
- cmd(cmd: string[]): Image;
179
- /**
180
- * Extends an image with arbitrary Dockerfile-like commands.
181
- *
182
- * @param {string | string[]} dockerfileCommands - The commands to add to the Dockerfile.
183
- * @param {string} contextDir - The path to the context directory.
184
- * @returns {Image} The Image instance.
185
- *
186
- * @example
187
- * const image = Image
188
- * .debianSlim('3.12')
189
- * .dockerfileCommands(['RUN echo "Hello, world!"'])
190
- */
191
- dockerfileCommands(dockerfileCommands: (string | string[])[], contextDir?: string): Image;
192
- /**
193
- * Creates an Image from an existing Dockerfile.
194
- *
195
- * @param {string} path - The path to the Dockerfile.
196
- * @returns {Image} The Image instance.
197
- *
198
- * @example
199
- * const image = Image.fromDockerfile('Dockerfile')
200
- */
201
- static fromDockerfile(path: string): Image;
202
- /**
203
- * Creates an Image from an existing base image.
204
- *
205
- * @param {string} image - The base image to use.
206
- * @returns {Image} The Image instance.
207
- *
208
- * @example
209
- * const image = Image.base('python:3.12-slim-bookworm')
210
- */
211
- static base(image: string): Image;
212
- /**
213
- * Creates a Debian slim image based on the official Python Docker image.
214
- *
215
- * @param {string} pythonVersion - The Python version to use.
216
- * @returns {Image} The Image instance.
217
- *
218
- * @example
219
- * const image = Image.debianSlim('3.12')
220
- */
221
- static debianSlim(pythonVersion?: SupportedPythonSeries): Image;
222
- /**
223
- * Formats pip install arguments in a single string.
224
- *
225
- * @param {PipInstallOptions} options - The options for the pip install command.
226
- * @returns {string} The formatted pip install arguments.
227
- */
228
- private formatPipInstallArgs;
229
- /**
230
- * Flattens a string argument.
231
- *
232
- * @param {string} functionName - The name of the function.
233
- * @param {string} argName - The name of the argument.
234
- * @param {any} args - The argument to flatten.
235
- * @returns {string[]} The flattened argument.
236
- */
237
- private flattenStringArgs;
238
- /**
239
- * Processes the Python version.
240
- *
241
- * @param {string} pythonVersion - The Python version to use.
242
- * @returns {string} The processed Python version.
243
- */
244
- private static processPythonVersion;
245
- /**
246
- * Extracts source files from COPY commands in a Dockerfile.
247
- *
248
- * @param {string} dockerfileContent - The content of the Dockerfile.
249
- * @param {string} pathPrefix - The path prefix to use for the sources.
250
- * @returns {Array<[string, string]>} The list of the actual file path and its corresponding COPY-command source path.
251
- */
252
- private static extractCopySources;
253
- /**
254
- * Parses a COPY command to extract sources and destination.
255
- *
256
- * @param {string} line - The line to parse.
257
- * @returns {Object} The parsed sources and destination.
258
- */
259
- private static parseCopyCommand;
52
+ private _dockerfile
53
+ private _contextList
54
+ private constructor()
55
+ get dockerfile(): string
56
+ get contextList(): Context[]
57
+ /**
58
+ * Adds commands to install packages using pip.
59
+ *
60
+ * @param {string | string[]} packages - The packages to install.
61
+ * @param {Object} options - The options for the pip install command.
62
+ * @param {string[]} options.findLinks - The find-links to use for the pip install command.
63
+ * @returns {Image} The Image instance.
64
+ *
65
+ * @example
66
+ * const image = Image.debianSlim('3.12').pipInstall('numpy', { findLinks: ['https://pypi.org/simple'] })
67
+ */
68
+ pipInstall(packages: string | string[], options?: PipInstallOptions): Image
69
+ /**
70
+ * Installs dependencies from a requirements.txt file.
71
+ *
72
+ * @param {string} requirementsTxt - The path to the requirements.txt file.
73
+ * @param {PipInstallOptions} options - The options for the pip install command.
74
+ * @returns {Image} The Image instance.
75
+ *
76
+ * @example
77
+ * const image = Image.debianSlim('3.12')
78
+ * image.pipInstallFromRequirements('requirements.txt', { findLinks: ['https://pypi.org/simple'] })
79
+ */
80
+ pipInstallFromRequirements(requirementsTxt: string, options?: PipInstallOptions): Image
81
+ /**
82
+ * Installs dependencies from a pyproject.toml file.
83
+ *
84
+ * @param {string} pyprojectToml - The path to the pyproject.toml file.
85
+ * @param {PyprojectOptions} options - The options for the pip install command.
86
+ * @returns {Image} The Image instance.
87
+ *
88
+ * @example
89
+ * const image = Image.debianSlim('3.12')
90
+ * image.pipInstallFromPyproject('pyproject.toml', { optionalDependencies: ['dev'] })
91
+ */
92
+ pipInstallFromPyproject(pyprojectToml: string, options?: PyprojectOptions): Image
93
+ /**
94
+ * Adds a local file to the image.
95
+ *
96
+ * @param {string} localPath - The path to the local file.
97
+ * @param {string} remotePath - The path of the file in the image.
98
+ * @returns {Image} The Image instance.
99
+ *
100
+ * @example
101
+ * const image = Image
102
+ * .debianSlim('3.12')
103
+ * .addLocalFile('requirements.txt', '/home/daytona/requirements.txt')
104
+ */
105
+ addLocalFile(localPath: string, remotePath: string): Image
106
+ /**
107
+ * Adds a local directory to the image.
108
+ *
109
+ * @param {string} localPath - The path to the local directory.
110
+ * @param {string} remotePath - The path of the directory in the image.
111
+ * @returns {Image} The Image instance.
112
+ *
113
+ * @example
114
+ * const image = Image
115
+ * .debianSlim('3.12')
116
+ * .addLocalDir('src', '/home/daytona/src')
117
+ */
118
+ addLocalDir(localPath: string, remotePath: string): Image
119
+ /**
120
+ * Runs commands in the image.
121
+ *
122
+ * @param {string | string[]} commands - The commands to run.
123
+ * @returns {Image} The Image instance.
124
+ *
125
+ * @example
126
+ * const image = Image
127
+ * .debianSlim('3.12')
128
+ * .runCommands('echo "Hello, world!"')
129
+ */
130
+ runCommands(...commands: (string | string[])[]): Image
131
+ /**
132
+ * Sets environment variables in the image.
133
+ *
134
+ * @param {Record<string, string>} envVars - The environment variables to set.
135
+ * @returns {Image} The Image instance.
136
+ *
137
+ * @example
138
+ * const image = Image
139
+ * .debianSlim('3.12')
140
+ * .env({ FOO: 'bar' })
141
+ */
142
+ env(envVars: Record<string, string>): Image
143
+ /**
144
+ * Sets the working directory in the image.
145
+ *
146
+ * @param {string} dirPath - The path to the working directory.
147
+ * @returns {Image} The Image instance.
148
+ *
149
+ * @example
150
+ * const image = Image
151
+ * .debianSlim('3.12')
152
+ * .workdir('/home/daytona')
153
+ */
154
+ workdir(dirPath: string): Image
155
+ /**
156
+ * Sets the entrypoint for the image.
157
+ *
158
+ * @param {string[]} entrypointCommands - The commands to set as the entrypoint.
159
+ * @returns {Image} The Image instance.
160
+ *
161
+ * @example
162
+ * const image = Image
163
+ * .debianSlim('3.12')
164
+ * .entrypoint(['/bin/bash'])
165
+ */
166
+ entrypoint(entrypointCommands: string[]): Image
167
+ /**
168
+ * Sets the default command for the image.
169
+ *
170
+ * @param {string[]} cmd - The command to set as the default command.
171
+ * @returns {Image} The Image instance.
172
+ *
173
+ * @example
174
+ * const image = Image
175
+ * .debianSlim('3.12')
176
+ * .cmd(['/bin/bash'])
177
+ */
178
+ cmd(cmd: string[]): Image
179
+ /**
180
+ * Extends an image with arbitrary Dockerfile-like commands.
181
+ *
182
+ * @param {string | string[]} dockerfileCommands - The commands to add to the Dockerfile.
183
+ * @param {string} contextDir - The path to the context directory.
184
+ * @returns {Image} The Image instance.
185
+ *
186
+ * @example
187
+ * const image = Image
188
+ * .debianSlim('3.12')
189
+ * .dockerfileCommands(['RUN echo "Hello, world!"'])
190
+ */
191
+ dockerfileCommands(dockerfileCommands: (string | string[])[], contextDir?: string): Image
192
+ /**
193
+ * Creates an Image from an existing Dockerfile.
194
+ *
195
+ * @param {string} path - The path to the Dockerfile.
196
+ * @returns {Image} The Image instance.
197
+ *
198
+ * @example
199
+ * const image = Image.fromDockerfile('Dockerfile')
200
+ */
201
+ static fromDockerfile(path: string): Image
202
+ /**
203
+ * Creates an Image from an existing base image.
204
+ *
205
+ * @param {string} image - The base image to use.
206
+ * @returns {Image} The Image instance.
207
+ *
208
+ * @example
209
+ * const image = Image.base('python:3.12-slim-bookworm')
210
+ */
211
+ static base(image: string): Image
212
+ /**
213
+ * Creates a Debian slim image based on the official Python Docker image.
214
+ *
215
+ * @param {string} pythonVersion - The Python version to use.
216
+ * @returns {Image} The Image instance.
217
+ *
218
+ * @example
219
+ * const image = Image.debianSlim('3.12')
220
+ */
221
+ static debianSlim(pythonVersion?: SupportedPythonSeries): Image
222
+ /**
223
+ * Formats pip install arguments in a single string.
224
+ *
225
+ * @param {PipInstallOptions} options - The options for the pip install command.
226
+ * @returns {string} The formatted pip install arguments.
227
+ */
228
+ private formatPipInstallArgs
229
+ /**
230
+ * Flattens a string argument.
231
+ *
232
+ * @param {string} functionName - The name of the function.
233
+ * @param {string} argName - The name of the argument.
234
+ * @param {any} args - The argument to flatten.
235
+ * @returns {string[]} The flattened argument.
236
+ */
237
+ private flattenStringArgs
238
+ /**
239
+ * Processes the Python version.
240
+ *
241
+ * @param {string} pythonVersion - The Python version to use.
242
+ * @returns {string} The processed Python version.
243
+ */
244
+ private static processPythonVersion
245
+ /**
246
+ * Extracts source files from COPY commands in a Dockerfile.
247
+ *
248
+ * @param {string} dockerfileContent - The content of the Dockerfile.
249
+ * @param {string} pathPrefix - The path prefix to use for the sources.
250
+ * @returns {Array<[string, string]>} The list of the actual file path and its corresponding COPY-command source path.
251
+ */
252
+ private static extractCopySources
253
+ /**
254
+ * Parses a COPY command to extract sources and destination.
255
+ *
256
+ * @param {string} line - The line to parse.
257
+ * @returns {Object} The parsed sources and destination.
258
+ */
259
+ private static parseCopyCommand
260
260
  }
261
- export {};
261
+ export {}
@@ -9,11 +9,11 @@
9
9
  * @property {string} [bucketName] - The name of the bucket to use.
10
10
  */
11
11
  export interface ObjectStorageConfig {
12
- endpointUrl: string;
13
- accessKeyId: string;
14
- secretAccessKey: string;
15
- sessionToken?: string;
16
- bucketName?: string;
12
+ endpointUrl: string
13
+ accessKeyId: string
14
+ secretAccessKey: string
15
+ sessionToken?: string
16
+ bucketName?: string
17
17
  }
18
18
  /**
19
19
  * ObjectStorage class for interacting with object storage services.
@@ -22,64 +22,64 @@ export interface ObjectStorageConfig {
22
22
  * @param {ObjectStorageConfig} config - The configuration for the object storage service.
23
23
  */
24
24
  export declare class ObjectStorage {
25
- private bucketName;
26
- private s3Client;
27
- constructor(config: ObjectStorageConfig);
28
- /**
29
- * Upload a file or directory to object storage.
30
- *
31
- * @param {string} path - The path to the file or directory to upload.
32
- * @param {string} organizationId - The organization ID to use for the upload.
33
- * @param {string} [archiveBasePath] - The base path to use for the archive.
34
- * @returns {Promise<string>} The hash of the uploaded file or directory.
35
- */
36
- upload(path: string, organizationId: string, archiveBasePath?: string): Promise<string>;
37
- /**
38
- * Compute a hash for a file or directory.
39
- *
40
- * @param {string} pathStr - The path to the file or directory to hash.
41
- * @param {string} [archiveBasePath] - The base path to use for the archive.
42
- * @returns {Promise<string>} The hash of the file or directory.
43
- */
44
- private computeHashForPathMd5;
45
- /**
46
- * Recursively hash a directory and its contents.
47
- *
48
- * @param {string} dirPath - The path to the directory to hash.
49
- * @param {string} basePath - The base path to use for the hash.
50
- * @param {crypto.Hash} hasher - The hasher to use for the hash.
51
- * @returns {Promise<void>} A promise that resolves when the directory has been hashed.
52
- */
53
- private hashDirectory;
54
- /**
55
- * Hash a file.
56
- *
57
- * @param {string} filePath - The path to the file to hash.
58
- * @param {crypto.Hash} hasher - The hasher to use for the hash.
59
- * @returns {Promise<void>} A promise that resolves when the file has been hashed.
60
- */
61
- private hashFile;
62
- /**
63
- * Check if a prefix (folder) exists in S3.
64
- *
65
- * @param {string} prefix - The prefix to check.
66
- * @returns {Promise<boolean>} True if the prefix exists, false otherwise.
67
- */
68
- private folderExistsInS3;
69
- /**
70
- * Create a tar archive of the specified path and upload it to S3.
71
- *
72
- * @param {string} s3Key - The key to use for the uploaded file.
73
- * @param {string} sourcePath - The path to the file or directory to upload.
74
- * @param {string} [archiveBasePath] - The base path to use for the archive.
75
- */
76
- private uploadAsTar;
77
- private extractAwsRegion;
78
- /**
79
- * Compute the base path for an archive. Returns normalized path without the root (drive letter or leading slash).
80
- *
81
- * @param {string} pathStr - The path to compute the base path for.
82
- * @returns {string} The base path for the archive.
83
- */
84
- static computeArchiveBasePath(pathStr: string): string;
25
+ private bucketName
26
+ private s3Client
27
+ constructor(config: ObjectStorageConfig)
28
+ /**
29
+ * Upload a file or directory to object storage.
30
+ *
31
+ * @param {string} path - The path to the file or directory to upload.
32
+ * @param {string} organizationId - The organization ID to use for the upload.
33
+ * @param {string} [archiveBasePath] - The base path to use for the archive.
34
+ * @returns {Promise<string>} The hash of the uploaded file or directory.
35
+ */
36
+ upload(path: string, organizationId: string, archiveBasePath?: string): Promise<string>
37
+ /**
38
+ * Compute a hash for a file or directory.
39
+ *
40
+ * @param {string} pathStr - The path to the file or directory to hash.
41
+ * @param {string} [archiveBasePath] - The base path to use for the archive.
42
+ * @returns {Promise<string>} The hash of the file or directory.
43
+ */
44
+ private computeHashForPathMd5
45
+ /**
46
+ * Recursively hash a directory and its contents.
47
+ *
48
+ * @param {string} dirPath - The path to the directory to hash.
49
+ * @param {string} basePath - The base path to use for the hash.
50
+ * @param {crypto.Hash} hasher - The hasher to use for the hash.
51
+ * @returns {Promise<void>} A promise that resolves when the directory has been hashed.
52
+ */
53
+ private hashDirectory
54
+ /**
55
+ * Hash a file.
56
+ *
57
+ * @param {string} filePath - The path to the file to hash.
58
+ * @param {crypto.Hash} hasher - The hasher to use for the hash.
59
+ * @returns {Promise<void>} A promise that resolves when the file has been hashed.
60
+ */
61
+ private hashFile
62
+ /**
63
+ * Check if a prefix (folder) exists in S3.
64
+ *
65
+ * @param {string} prefix - The prefix to check.
66
+ * @returns {Promise<boolean>} True if the prefix exists, false otherwise.
67
+ */
68
+ private folderExistsInS3
69
+ /**
70
+ * Create a tar archive of the specified path and upload it to S3.
71
+ *
72
+ * @param {string} s3Key - The key to use for the uploaded file.
73
+ * @param {string} sourcePath - The path to the file or directory to upload.
74
+ * @param {string} [archiveBasePath] - The base path to use for the archive.
75
+ */
76
+ private uploadAsTar
77
+ private extractAwsRegion
78
+ /**
79
+ * Compute the base path for an archive. Returns normalized path without the root (drive letter or leading slash).
80
+ *
81
+ * @param {string} pathStr - The path to compute the base path for.
82
+ * @returns {string} The base path for the archive.
83
+ */
84
+ static computeArchiveBasePath(pathStr: string): string
85
85
  }
package/dist/Process.d.ts CHANGED
@@ -243,4 +243,5 @@ export declare class Process {
243
243
  * await process.deleteSession('my-session');
244
244
  */
245
245
  deleteSession(sessionId: string): Promise<void>;
246
+ private streamWithStatusPoll;
246
247
  }