@daytonaio/sdk 0.11.2 → 0.12.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.
- package/README.md +3 -3
- package/dist/Daytona.d.ts +18 -59
- package/dist/Daytona.js +14 -54
- package/dist/FileSystem.d.ts +2 -68
- package/dist/FileSystem.js +1 -67
- package/dist/Git.d.ts +15 -61
- package/dist/Git.js +10 -62
- package/dist/LspServer.d.ts +13 -75
- package/dist/LspServer.js +11 -71
- package/dist/Process.d.ts +51 -39
- package/dist/Process.js +60 -41
- package/dist/Sandbox.d.ts +5 -47
- package/dist/Sandbox.js +2 -44
- package/dist/code-toolbox/SandboxPythonCodeToolbox.d.ts +6 -0
- package/dist/code-toolbox/SandboxPythonCodeToolbox.js +344 -2
- package/dist/index.d.ts +9 -8
- package/dist/index.js +7 -5
- package/dist/types/Charts.d.ts +151 -0
- package/dist/types/Charts.js +40 -0
- package/dist/types/ExecuteResponse.d.ts +26 -0
- package/dist/types/ExecuteResponse.js +2 -0
- package/dist/utils/ArtifactParser.d.ts +13 -0
- package/dist/utils/ArtifactParser.js +50 -0
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Daytona SDK for TypeScript
|
|
2
2
|
|
|
3
|
-
A TypeScript SDK for interacting with Daytona
|
|
3
|
+
A TypeScript SDK for interacting with the Daytona API, providing a simple interface for Daytona Sandbox management, Git operations, file system operations, and language server protocol support.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -47,7 +47,7 @@ import { Daytona } from '@daytonaio/sdk'
|
|
|
47
47
|
// Initialize with configuration
|
|
48
48
|
const daytona = new Daytona({
|
|
49
49
|
apiKey: 'your-api-key',
|
|
50
|
-
|
|
50
|
+
apiUrl: 'your-api-url',
|
|
51
51
|
target: 'us',
|
|
52
52
|
})
|
|
53
53
|
```
|
|
@@ -55,7 +55,7 @@ const daytona = new Daytona({
|
|
|
55
55
|
Or using environment variables:
|
|
56
56
|
|
|
57
57
|
- `DAYTONA_API_KEY`: Your Daytona API key
|
|
58
|
-
- `
|
|
58
|
+
- `DAYTONA_API_URL`: The Daytona API URL
|
|
59
59
|
- `DAYTONA_TARGET`: Your target environment
|
|
60
60
|
|
|
61
61
|
You can also customize sandbox creation:
|
package/dist/Daytona.d.ts
CHANGED
|
@@ -1,72 +1,31 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sandboxes are isolated development environments managed by Daytona.
|
|
3
|
-
* This guide covers how to create, manage, and remove Sandboxes using the SDK.
|
|
4
|
-
*
|
|
5
|
-
* @module Daytona
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* // Initialize using environment variables (DAYTONA_API_KEY, DAYTONA_SERVER_URL, DAYTONA_TARGET)
|
|
9
|
-
* const daytona = new Daytona();
|
|
10
|
-
*
|
|
11
|
-
* // Create and use a sandbox
|
|
12
|
-
* const sandbox = await daytona.create({
|
|
13
|
-
* language: 'typescript',
|
|
14
|
-
* envVars: { NODE_ENV: 'development' }
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* // Execute commands in the sandbox
|
|
18
|
-
* const response = await sandbox.process.executeCommand('echo "Hello, World!"');
|
|
19
|
-
* console.log(response.result);
|
|
20
|
-
*
|
|
21
|
-
* // Execute code in the sandbox
|
|
22
|
-
* const response = await sandbox.process.codeRun('console.log("Hello, World!")');
|
|
23
|
-
* console.log(response.result);
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* // Initialize with explicit configuration
|
|
27
|
-
* const daytona = new Daytona({
|
|
28
|
-
* apiKey: process.env.CUSTOM_API_KEY,
|
|
29
|
-
* serverUrl: 'https://daytona.example.com',
|
|
30
|
-
* target: 'us'
|
|
31
|
-
* });
|
|
32
|
-
*
|
|
33
|
-
* // Create a custom sandbox
|
|
34
|
-
* const sandbox = await daytona.create({
|
|
35
|
-
* language: 'typescript',
|
|
36
|
-
* image: 'node:18',
|
|
37
|
-
* resources: {
|
|
38
|
-
* cpu: 2,
|
|
39
|
-
* memory: 4 // 4GB RAM
|
|
40
|
-
* },
|
|
41
|
-
* autoStopInterval: 60 // Auto-stop after 1 hour of inactivity
|
|
42
|
-
* });
|
|
43
|
-
*
|
|
44
|
-
* // Use sandbox features
|
|
45
|
-
* await sandbox.git.clone('https://github.com/user/repo.git');
|
|
46
|
-
* await sandbox.process.executeCommand('npm test');
|
|
47
|
-
*/
|
|
48
1
|
import { Sandbox, Sandbox as Workspace } from './Sandbox';
|
|
49
2
|
import { CreateWorkspaceTargetEnum as SandboxTargetRegion } from '@daytonaio/api-client';
|
|
50
3
|
/**
|
|
51
4
|
* Configuration options for initializing the Daytona client.
|
|
52
5
|
*
|
|
53
6
|
* @interface
|
|
54
|
-
* @property {string} apiKey - API key for authentication with Daytona
|
|
55
|
-
* @property {string}
|
|
7
|
+
* @property {string} apiKey - API key for authentication with the Daytona API
|
|
8
|
+
* @property {string} apiUrl - URL of the Daytona API. Defaults to 'https://app.daytona.io/api'
|
|
9
|
+
* if not set here and not set in environment variable DAYTONA_API_URL.
|
|
56
10
|
* @property {CreateSandboxTargetEnum} target - Target location for Sandboxes
|
|
57
11
|
*
|
|
58
12
|
* @example
|
|
59
13
|
* const config: DaytonaConfig = {
|
|
60
14
|
* apiKey: "your-api-key",
|
|
61
|
-
*
|
|
15
|
+
* apiUrl: "https://your-api.com",
|
|
62
16
|
* target: "us"
|
|
63
17
|
* };
|
|
64
18
|
* const daytona = new Daytona(config);
|
|
65
19
|
*/
|
|
66
20
|
export interface DaytonaConfig {
|
|
67
|
-
/** API key for authentication with Daytona
|
|
21
|
+
/** API key for authentication with the Daytona API */
|
|
68
22
|
apiKey?: string;
|
|
69
|
-
/** URL of the Daytona
|
|
23
|
+
/** URL of the Daytona API.
|
|
24
|
+
*/
|
|
25
|
+
apiUrl?: string;
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use `apiUrl` instead. This property will be removed in future versions.
|
|
28
|
+
*/
|
|
70
29
|
serverUrl?: string;
|
|
71
30
|
/** Target environment for sandboxes */
|
|
72
31
|
target?: SandboxTargetRegion;
|
|
@@ -112,11 +71,11 @@ export interface SandboxResources {
|
|
|
112
71
|
* @property {string} [id] - Optional Sandbox ID. If not provided, a random ID will be generated
|
|
113
72
|
* @property {string} [image] - Optional Docker image to use for the Sandbox
|
|
114
73
|
* @property {string} [user] - Optional os user to use for the Sandbox
|
|
115
|
-
* @property {CodeLanguage} [language] - Programming language for direct code execution
|
|
74
|
+
* @property {CodeLanguage | string} [language] - Programming language for direct code execution
|
|
116
75
|
* @property {Record<string, string>} [envVars] - Optional environment variables to set in the Sandbox
|
|
117
76
|
* @property {Record<string, string>} [labels] - Sandbox labels
|
|
118
77
|
* @property {boolean} [public] - Is the Sandbox port preview public
|
|
119
|
-
* @property {string} [target] - Target location for the Sandbox
|
|
78
|
+
* @property {SandboxTargetRegion | string} [target] - Target location for the Sandbox
|
|
120
79
|
* @property {SandboxResources} [resources] - Resource allocation for the Sandbox
|
|
121
80
|
* @property {boolean} [async] - If true, will not wait for the Sandbox to be ready before returning
|
|
122
81
|
* @property {number} [timeout] - Timeout in seconds for the Sandbox to be ready (0 means no timeout)
|
|
@@ -164,7 +123,7 @@ export type CreateSandboxParams = {
|
|
|
164
123
|
autoStopInterval?: number;
|
|
165
124
|
};
|
|
166
125
|
/**
|
|
167
|
-
* Main class for interacting with Daytona
|
|
126
|
+
* Main class for interacting with the Daytona API.
|
|
168
127
|
*
|
|
169
128
|
* Provides methods for creating, managing, and interacting with Daytona Sandboxes.
|
|
170
129
|
* Can be initialized either with explicit configuration or using environment variables.
|
|
@@ -172,7 +131,7 @@ export type CreateSandboxParams = {
|
|
|
172
131
|
*
|
|
173
132
|
* @example
|
|
174
133
|
* // Using environment variables
|
|
175
|
-
* // Uses DAYTONA_API_KEY,
|
|
134
|
+
* // Uses DAYTONA_API_KEY, DAYTONA_API_URL, DAYTONA_TARGET
|
|
176
135
|
* const daytona = new Daytona();
|
|
177
136
|
* const sandbox = await daytona.create();
|
|
178
137
|
*
|
|
@@ -180,7 +139,7 @@ export type CreateSandboxParams = {
|
|
|
180
139
|
* // Using explicit configuration
|
|
181
140
|
* const config: DaytonaConfig = {
|
|
182
141
|
* apiKey: "your-api-key",
|
|
183
|
-
*
|
|
142
|
+
* apiUrl: "https://your-api.com",
|
|
184
143
|
* target: "us"
|
|
185
144
|
* };
|
|
186
145
|
* const daytona = new Daytona(config);
|
|
@@ -192,12 +151,12 @@ export declare class Daytona {
|
|
|
192
151
|
private readonly toolboxApi;
|
|
193
152
|
private readonly target;
|
|
194
153
|
private readonly apiKey;
|
|
195
|
-
private readonly
|
|
154
|
+
private readonly apiUrl;
|
|
196
155
|
/**
|
|
197
156
|
* Creates a new Daytona client instance.
|
|
198
157
|
*
|
|
199
158
|
* @param {DaytonaConfig} [config] - Configuration options
|
|
200
|
-
* @throws {DaytonaError} - `DaytonaError` - When API key
|
|
159
|
+
* @throws {DaytonaError} - `DaytonaError` - When API key is missing
|
|
201
160
|
*/
|
|
202
161
|
constructor(config?: DaytonaConfig);
|
|
203
162
|
/**
|
package/dist/Daytona.js
CHANGED
|
@@ -1,51 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Sandboxes are isolated development environments managed by Daytona.
|
|
4
|
-
* This guide covers how to create, manage, and remove Sandboxes using the SDK.
|
|
5
|
-
*
|
|
6
|
-
* @module Daytona
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // Initialize using environment variables (DAYTONA_API_KEY, DAYTONA_SERVER_URL, DAYTONA_TARGET)
|
|
10
|
-
* const daytona = new Daytona();
|
|
11
|
-
*
|
|
12
|
-
* // Create and use a sandbox
|
|
13
|
-
* const sandbox = await daytona.create({
|
|
14
|
-
* language: 'typescript',
|
|
15
|
-
* envVars: { NODE_ENV: 'development' }
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // Execute commands in the sandbox
|
|
19
|
-
* const response = await sandbox.process.executeCommand('echo "Hello, World!"');
|
|
20
|
-
* console.log(response.result);
|
|
21
|
-
*
|
|
22
|
-
* // Execute code in the sandbox
|
|
23
|
-
* const response = await sandbox.process.codeRun('console.log("Hello, World!")');
|
|
24
|
-
* console.log(response.result);
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* // Initialize with explicit configuration
|
|
28
|
-
* const daytona = new Daytona({
|
|
29
|
-
* apiKey: process.env.CUSTOM_API_KEY,
|
|
30
|
-
* serverUrl: 'https://daytona.example.com',
|
|
31
|
-
* target: 'us'
|
|
32
|
-
* });
|
|
33
|
-
*
|
|
34
|
-
* // Create a custom sandbox
|
|
35
|
-
* const sandbox = await daytona.create({
|
|
36
|
-
* language: 'typescript',
|
|
37
|
-
* image: 'node:18',
|
|
38
|
-
* resources: {
|
|
39
|
-
* cpu: 2,
|
|
40
|
-
* memory: 4 // 4GB RAM
|
|
41
|
-
* },
|
|
42
|
-
* autoStopInterval: 60 // Auto-stop after 1 hour of inactivity
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* // Use sandbox features
|
|
46
|
-
* await sandbox.git.clone('https://github.com/user/repo.git');
|
|
47
|
-
* await sandbox.process.executeCommand('npm test');
|
|
48
|
-
*/
|
|
49
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
50
3
|
if (k2 === undefined) k2 = k;
|
|
51
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -101,7 +54,7 @@ var CodeLanguage;
|
|
|
101
54
|
CodeLanguage["JAVASCRIPT"] = "javascript";
|
|
102
55
|
})(CodeLanguage || (exports.CodeLanguage = CodeLanguage = {}));
|
|
103
56
|
/**
|
|
104
|
-
* Main class for interacting with Daytona
|
|
57
|
+
* Main class for interacting with the Daytona API.
|
|
105
58
|
*
|
|
106
59
|
* Provides methods for creating, managing, and interacting with Daytona Sandboxes.
|
|
107
60
|
* Can be initialized either with explicit configuration or using environment variables.
|
|
@@ -109,7 +62,7 @@ var CodeLanguage;
|
|
|
109
62
|
*
|
|
110
63
|
* @example
|
|
111
64
|
* // Using environment variables
|
|
112
|
-
* // Uses DAYTONA_API_KEY,
|
|
65
|
+
* // Uses DAYTONA_API_KEY, DAYTONA_API_URL, DAYTONA_TARGET
|
|
113
66
|
* const daytona = new Daytona();
|
|
114
67
|
* const sandbox = await daytona.create();
|
|
115
68
|
*
|
|
@@ -117,7 +70,7 @@ var CodeLanguage;
|
|
|
117
70
|
* // Using explicit configuration
|
|
118
71
|
* const config: DaytonaConfig = {
|
|
119
72
|
* apiKey: "your-api-key",
|
|
120
|
-
*
|
|
73
|
+
* apiUrl: "https://your-api.com",
|
|
121
74
|
* target: "us"
|
|
122
75
|
* };
|
|
123
76
|
* const daytona = new Daytona(config);
|
|
@@ -129,7 +82,7 @@ class Daytona {
|
|
|
129
82
|
* Creates a new Daytona client instance.
|
|
130
83
|
*
|
|
131
84
|
* @param {DaytonaConfig} [config] - Configuration options
|
|
132
|
-
* @throws {DaytonaError} - `DaytonaError` - When API key
|
|
85
|
+
* @throws {DaytonaError} - `DaytonaError` - When API key is missing
|
|
133
86
|
*/
|
|
134
87
|
constructor(config) {
|
|
135
88
|
dotenv_1.default.config();
|
|
@@ -138,14 +91,21 @@ class Daytona {
|
|
|
138
91
|
if (!apiKey) {
|
|
139
92
|
throw new DaytonaError_1.DaytonaError('API key is required');
|
|
140
93
|
}
|
|
141
|
-
const
|
|
94
|
+
const apiUrl = (config === null || config === void 0 ? void 0 : config.apiUrl) ||
|
|
95
|
+
(config === null || config === void 0 ? void 0 : config.serverUrl) ||
|
|
96
|
+
process.env.DAYTONA_API_URL ||
|
|
97
|
+
process.env.DAYTONA_SERVER_URL ||
|
|
98
|
+
'https://app.daytona.io/api';
|
|
142
99
|
const envTarget = process.env.DAYTONA_TARGET;
|
|
143
100
|
const target = (config === null || config === void 0 ? void 0 : config.target) || envTarget || api_client_1.CreateWorkspaceTargetEnum.US;
|
|
101
|
+
if (process.env.DAYTONA_SERVER_URL && !process.env.DAYTONA_API_URL) {
|
|
102
|
+
console.warn('[Deprecation Warning] Environment variable `DAYTONA_SERVER_URL` is deprecated and will be removed in future versions. Use `DAYTONA_API_URL` instead.');
|
|
103
|
+
}
|
|
144
104
|
this.apiKey = apiKey;
|
|
145
|
-
this.
|
|
105
|
+
this.apiUrl = apiUrl;
|
|
146
106
|
this.target = target;
|
|
147
107
|
const configuration = new api_client_1.Configuration({
|
|
148
|
-
basePath: this.
|
|
108
|
+
basePath: this.apiUrl,
|
|
149
109
|
baseOptions: {
|
|
150
110
|
headers: {
|
|
151
111
|
Authorization: `Bearer ${this.apiKey}`,
|
package/dist/FileSystem.d.ts
CHANGED
|
@@ -1,72 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Daytona SDK provides comprehensive file system operations through the `fs` module in Sandboxes.
|
|
3
|
-
* You can perform various operations like listing files, creating directories, reading and writing files, and more.
|
|
4
|
-
* This guide covers all available file system operations and best practices.
|
|
5
|
-
*
|
|
6
|
-
* @module FileSystem
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* // Basic file operations
|
|
10
|
-
* // Create a sandbox
|
|
11
|
-
* const sandbox = await daytona.create();
|
|
12
|
-
*
|
|
13
|
-
* // Create a directory
|
|
14
|
-
* await sandbox.fs.createFolder('/workspace/data', '755');
|
|
15
|
-
*
|
|
16
|
-
* // Upload a file
|
|
17
|
-
* const fileContent = new File(['content'], 'local_file.txt');
|
|
18
|
-
* await sandbox.fs.uploadFile('/workspace/data/file.txt', fileContent);
|
|
19
|
-
*
|
|
20
|
-
* // List directory contents
|
|
21
|
-
* const files = await sandbox.fs.listFiles('/workspace');
|
|
22
|
-
* files.forEach(file => {
|
|
23
|
-
* console.log(`Name: ${file.name}`);
|
|
24
|
-
* console.log(`Is directory: ${file.isDir}`);
|
|
25
|
-
* console.log(`Size: ${file.size}`);
|
|
26
|
-
* console.log(`Modified: ${file.modTime}`);
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* // Search file contents
|
|
30
|
-
* const matches = await sandbox.fs.findFiles(
|
|
31
|
-
* '/workspace/src',
|
|
32
|
-
* 'text-of-interest'
|
|
33
|
-
* );
|
|
34
|
-
* matches.forEach(match => {
|
|
35
|
-
* console.log(`Absolute file path: ${match.file}`);
|
|
36
|
-
* console.log(`Line number: ${match.line}`);
|
|
37
|
-
* console.log(`Line content: ${match.content}\n`);
|
|
38
|
-
* });
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* // File manipulation
|
|
42
|
-
* // Move files
|
|
43
|
-
* await sandbox.fs.moveFiles(
|
|
44
|
-
* '/workspace/data/old.txt',
|
|
45
|
-
* '/workspace/data/new.txt'
|
|
46
|
-
* );
|
|
47
|
-
*
|
|
48
|
-
* // Replace text in files
|
|
49
|
-
* const results = await sandbox.fs.replaceInFiles(
|
|
50
|
-
* ['/workspace/data/new.txt'],
|
|
51
|
-
* 'old_version',
|
|
52
|
-
* 'new_version'
|
|
53
|
-
* );
|
|
54
|
-
*
|
|
55
|
-
* // Set permissions
|
|
56
|
-
* await sandbox.fs.setFilePermissions(
|
|
57
|
-
* '/workspace/data/script.sh',
|
|
58
|
-
* {
|
|
59
|
-
* mode: '755',
|
|
60
|
-
* owner: 'daytona'
|
|
61
|
-
* }
|
|
62
|
-
* );
|
|
63
|
-
*/
|
|
64
1
|
import { FileInfo, Match, ReplaceResult, SearchFilesResponse, ToolboxApi } from '@daytonaio/api-client';
|
|
65
2
|
import { SandboxInstance } from './Sandbox';
|
|
66
3
|
/**
|
|
67
4
|
* Parameters for setting file permissions in the Sandbox.
|
|
68
5
|
*
|
|
69
|
-
* @interface
|
|
6
|
+
* @interface
|
|
70
7
|
* @property {string} [mode] - File mode/permissions in octal format (e.g. "644")
|
|
71
8
|
* @property {string} [owner] - User owner of the file
|
|
72
9
|
* @property {string} [group] - Group owner of the file
|
|
@@ -89,10 +26,7 @@ export type FilePermissionsParams = {
|
|
|
89
26
|
/**
|
|
90
27
|
* Provides file system operations within a Sandbox.
|
|
91
28
|
*
|
|
92
|
-
*
|
|
93
|
-
* be performed within a Daytona Sandbox. It supports common operations like
|
|
94
|
-
* creating, deleting, and moving files, as well as searching file contents and
|
|
95
|
-
* managing permissions.
|
|
29
|
+
* @class
|
|
96
30
|
*/
|
|
97
31
|
export declare class FileSystem {
|
|
98
32
|
private readonly instance;
|
package/dist/FileSystem.js
CHANGED
|
@@ -1,76 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The Daytona SDK provides comprehensive file system operations through the `fs` module in Sandboxes.
|
|
4
|
-
* You can perform various operations like listing files, creating directories, reading and writing files, and more.
|
|
5
|
-
* This guide covers all available file system operations and best practices.
|
|
6
|
-
*
|
|
7
|
-
* @module FileSystem
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Basic file operations
|
|
11
|
-
* // Create a sandbox
|
|
12
|
-
* const sandbox = await daytona.create();
|
|
13
|
-
*
|
|
14
|
-
* // Create a directory
|
|
15
|
-
* await sandbox.fs.createFolder('/workspace/data', '755');
|
|
16
|
-
*
|
|
17
|
-
* // Upload a file
|
|
18
|
-
* const fileContent = new File(['content'], 'local_file.txt');
|
|
19
|
-
* await sandbox.fs.uploadFile('/workspace/data/file.txt', fileContent);
|
|
20
|
-
*
|
|
21
|
-
* // List directory contents
|
|
22
|
-
* const files = await sandbox.fs.listFiles('/workspace');
|
|
23
|
-
* files.forEach(file => {
|
|
24
|
-
* console.log(`Name: ${file.name}`);
|
|
25
|
-
* console.log(`Is directory: ${file.isDir}`);
|
|
26
|
-
* console.log(`Size: ${file.size}`);
|
|
27
|
-
* console.log(`Modified: ${file.modTime}`);
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* // Search file contents
|
|
31
|
-
* const matches = await sandbox.fs.findFiles(
|
|
32
|
-
* '/workspace/src',
|
|
33
|
-
* 'text-of-interest'
|
|
34
|
-
* );
|
|
35
|
-
* matches.forEach(match => {
|
|
36
|
-
* console.log(`Absolute file path: ${match.file}`);
|
|
37
|
-
* console.log(`Line number: ${match.line}`);
|
|
38
|
-
* console.log(`Line content: ${match.content}\n`);
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* // File manipulation
|
|
43
|
-
* // Move files
|
|
44
|
-
* await sandbox.fs.moveFiles(
|
|
45
|
-
* '/workspace/data/old.txt',
|
|
46
|
-
* '/workspace/data/new.txt'
|
|
47
|
-
* );
|
|
48
|
-
*
|
|
49
|
-
* // Replace text in files
|
|
50
|
-
* const results = await sandbox.fs.replaceInFiles(
|
|
51
|
-
* ['/workspace/data/new.txt'],
|
|
52
|
-
* 'old_version',
|
|
53
|
-
* 'new_version'
|
|
54
|
-
* );
|
|
55
|
-
*
|
|
56
|
-
* // Set permissions
|
|
57
|
-
* await sandbox.fs.setFilePermissions(
|
|
58
|
-
* '/workspace/data/script.sh',
|
|
59
|
-
* {
|
|
60
|
-
* mode: '755',
|
|
61
|
-
* owner: 'daytona'
|
|
62
|
-
* }
|
|
63
|
-
* );
|
|
64
|
-
*/
|
|
65
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
3
|
exports.FileSystem = void 0;
|
|
67
4
|
/**
|
|
68
5
|
* Provides file system operations within a Sandbox.
|
|
69
6
|
*
|
|
70
|
-
*
|
|
71
|
-
* be performed within a Daytona Sandbox. It supports common operations like
|
|
72
|
-
* creating, deleting, and moving files, as well as searching file contents and
|
|
73
|
-
* managing permissions.
|
|
7
|
+
* @class
|
|
74
8
|
*/
|
|
75
9
|
class FileSystem {
|
|
76
10
|
constructor(instance, toolboxApi) {
|
package/dist/Git.d.ts
CHANGED
|
@@ -1,56 +1,26 @@
|
|
|
1
|
+
import { ToolboxApi, ListBranchResponse, GitStatus } from '@daytonaio/api-client';
|
|
2
|
+
import { Sandbox, SandboxInstance } from './Sandbox';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
* operations and best practices. Daytona SDK provides an option to clone, check status,
|
|
4
|
-
* and manage Git repositories in Sandboxes. You can interact with Git repositories using
|
|
5
|
-
* the `git` module.
|
|
6
|
-
*
|
|
7
|
-
* @module Git
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* // Basic Git workflow
|
|
11
|
-
* // Create and initialize sandbox
|
|
12
|
-
* const sandbox = await daytona.create();
|
|
13
|
-
*
|
|
14
|
-
* // Clone a repository
|
|
15
|
-
* await sandbox.git.clone(
|
|
16
|
-
* 'https://github.com/user/repo.git',
|
|
17
|
-
* '/workspace/repo'
|
|
18
|
-
* );
|
|
4
|
+
* Response from the git commit.
|
|
19
5
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
* await sandbox.git.commit(
|
|
29
|
-
* '/workspace/repo',
|
|
30
|
-
* 'Add test file',
|
|
31
|
-
* 'John Doe',
|
|
32
|
-
* 'john@example.com'
|
|
33
|
-
* );
|
|
34
|
-
*
|
|
35
|
-
* // Push changes (with authentication)
|
|
36
|
-
* await sandbox.git.push(
|
|
37
|
-
* '/workspace/repo',
|
|
38
|
-
* 'user',
|
|
39
|
-
* 'token'
|
|
40
|
-
* );
|
|
6
|
+
* @interface
|
|
7
|
+
* @property {string} sha - The SHA of the commit
|
|
8
|
+
*/
|
|
9
|
+
export interface GitCommitResponse {
|
|
10
|
+
sha: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Provides Git operations within a Sandbox.
|
|
41
14
|
*
|
|
15
|
+
* @class
|
|
42
16
|
*/
|
|
43
|
-
import { ToolboxApi, ListBranchResponse, GitStatus } from '@daytonaio/api-client';
|
|
44
|
-
import { Sandbox, SandboxInstance } from './Sandbox';
|
|
45
17
|
export declare class Git {
|
|
46
18
|
private readonly sandbox;
|
|
47
19
|
private readonly toolboxApi;
|
|
48
20
|
private readonly instance;
|
|
49
21
|
constructor(sandbox: Sandbox, toolboxApi: ToolboxApi, instance: SandboxInstance);
|
|
50
22
|
/**
|
|
51
|
-
* Stages files for commit
|
|
52
|
-
*
|
|
53
|
-
* This method stages the specified files for the next commit, similar to
|
|
23
|
+
* Stages the specified files for the next commit, similar to
|
|
54
24
|
* running 'git add' on the command line.
|
|
55
25
|
*
|
|
56
26
|
* @param {string} path - Absolute path to the Git repository root
|
|
@@ -69,8 +39,6 @@ export declare class Git {
|
|
|
69
39
|
/**
|
|
70
40
|
* List branches in the repository.
|
|
71
41
|
*
|
|
72
|
-
* This method returns information about all branches in the repository.
|
|
73
|
-
*
|
|
74
42
|
* @param {string} path - Absolute path to the Git repository root
|
|
75
43
|
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
76
44
|
*
|
|
@@ -80,9 +48,7 @@ export declare class Git {
|
|
|
80
48
|
*/
|
|
81
49
|
branches(path: string): Promise<ListBranchResponse>;
|
|
82
50
|
/**
|
|
83
|
-
* Clones a Git repository.
|
|
84
|
-
*
|
|
85
|
-
* This method clones a Git repository into the specified path. It supports
|
|
51
|
+
* Clones a Git repository into the specified path. It supports
|
|
86
52
|
* cloning specific branches or commits, and can authenticate with the remote
|
|
87
53
|
* repository if credentials are provided.
|
|
88
54
|
*
|
|
@@ -123,9 +89,6 @@ export declare class Git {
|
|
|
123
89
|
/**
|
|
124
90
|
* Commits staged changes.
|
|
125
91
|
*
|
|
126
|
-
* This method creates a new commit with the staged changes. Make sure to stage
|
|
127
|
-
* changes using the add() method before committing.
|
|
128
|
-
*
|
|
129
92
|
* @param {string} path - Absolute path to the Git repository root
|
|
130
93
|
* @param {string} message - Commit message describing the changes
|
|
131
94
|
* @param {string} author - Name of the commit author
|
|
@@ -142,13 +105,10 @@ export declare class Git {
|
|
|
142
105
|
* 'john@example.com'
|
|
143
106
|
* );
|
|
144
107
|
*/
|
|
145
|
-
commit(path: string, message: string, author: string, email: string): Promise<
|
|
108
|
+
commit(path: string, message: string, author: string, email: string): Promise<GitCommitResponse>;
|
|
146
109
|
/**
|
|
147
110
|
* Push local changes to the remote repository.
|
|
148
111
|
*
|
|
149
|
-
* This method pushes committed changes to the remote repository. If the remote
|
|
150
|
-
* requires authentication, username and password/token must be provided.
|
|
151
|
-
*
|
|
152
112
|
* @param {string} path - Absolute path to the Git repository root
|
|
153
113
|
* @param {string} [username] - Git username for authentication
|
|
154
114
|
* @param {string} [password] - Git password or token for authentication
|
|
@@ -170,9 +130,6 @@ export declare class Git {
|
|
|
170
130
|
/**
|
|
171
131
|
* Pulls changes from the remote repository.
|
|
172
132
|
*
|
|
173
|
-
* This method fetches and merges changes from the remote repository. If the remote
|
|
174
|
-
* requires authentication, username and password/token must be provided.
|
|
175
|
-
*
|
|
176
133
|
* @param {string} path - Absolute path to the Git repository root
|
|
177
134
|
* @param {string} [username] - Git username for authentication
|
|
178
135
|
* @param {string} [password] - Git password or token for authentication
|
|
@@ -194,9 +151,6 @@ export declare class Git {
|
|
|
194
151
|
/**
|
|
195
152
|
* Gets the current status of the Git repository.
|
|
196
153
|
*
|
|
197
|
-
* This method returns information about the current state of the repository,
|
|
198
|
-
* including staged and unstaged changes, current branch, and untracked files.
|
|
199
|
-
*
|
|
200
154
|
* @param {string} path - Absolute path to the Git repository root
|
|
201
155
|
* @returns {Promise<GitStatus>} Current repository status including:
|
|
202
156
|
* - currentBranch: Name of the current branch
|