@daytonaio/sdk 0.128.0-alpha.1 → 0.128.1
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/package.json +8 -20
- package/{cjs → src}/CodeInterpreter.d.ts +0 -1
- package/src/CodeInterpreter.js.map +1 -0
- package/{esm → src}/ComputerUse.d.ts +0 -1
- package/src/ComputerUse.js.map +1 -0
- package/{cjs → src}/Daytona.d.ts +1 -2
- package/{cjs → src}/Daytona.js +8 -6
- package/{cjs → src}/Daytona.js.map +1 -1
- package/{esm → src}/FileSystem.d.ts +0 -1
- package/src/FileSystem.js.map +1 -0
- package/{esm → src}/Git.d.ts +0 -1
- package/src/Git.js.map +1 -0
- package/{cjs → src}/Image.d.ts +0 -21
- package/{cjs → src}/Image.js +91 -123
- package/src/Image.js.map +1 -0
- package/{cjs → src}/LspServer.d.ts +0 -1
- package/src/LspServer.js.map +1 -0
- package/{esm → src}/ObjectStorage.d.ts +0 -1
- package/src/ObjectStorage.js.map +1 -0
- package/{cjs → src}/Process.d.ts +0 -1
- package/src/Process.js.map +1 -0
- package/{cjs → src}/PtyHandle.d.ts +0 -1
- package/src/PtyHandle.js.map +1 -0
- package/{cjs → src}/Sandbox.d.ts +17 -2
- package/{cjs → src}/Sandbox.js +27 -1
- package/src/Sandbox.js.map +1 -0
- package/{cjs → src}/Snapshot.d.ts +0 -2
- package/{cjs → src}/Snapshot.js +1 -9
- package/src/Snapshot.js.map +1 -0
- package/{esm → src}/Volume.d.ts +0 -1
- package/src/Volume.js.map +1 -0
- package/{cjs → src}/code-toolbox/SandboxJsCodeToolbox.d.ts +0 -1
- package/src/code-toolbox/SandboxJsCodeToolbox.js.map +1 -0
- package/{cjs → src}/code-toolbox/SandboxPythonCodeToolbox.d.ts +0 -1
- package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
- package/{cjs → src}/code-toolbox/SandboxTsCodeToolbox.d.ts +0 -1
- package/src/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
- package/{esm → src}/errors/DaytonaError.d.ts +0 -1
- package/src/errors/DaytonaError.js.map +1 -0
- package/{cjs → src}/index.d.ts +0 -1
- package/src/index.js.map +1 -0
- package/{esm → src}/types/Charts.d.ts +0 -1
- package/src/types/Charts.js.map +1 -0
- package/{esm → src}/types/CodeInterpreter.d.ts +0 -1
- package/src/types/CodeInterpreter.js.map +1 -0
- package/{cjs → src}/types/ExecuteResponse.d.ts +0 -1
- package/src/types/ExecuteResponse.js.map +1 -0
- package/{cjs → src}/types/Pty.d.ts +0 -1
- package/src/types/Pty.js.map +1 -0
- package/{cjs → src}/utils/ArtifactParser.d.ts +0 -1
- package/src/utils/ArtifactParser.js.map +1 -0
- package/{esm → src}/utils/Binary.d.ts +0 -1
- package/src/utils/Binary.js.map +1 -0
- package/{cjs → src}/utils/FileTransfer.d.ts +0 -1
- package/src/utils/FileTransfer.js.map +1 -0
- package/{cjs → src}/utils/Import.d.ts +15 -2
- package/src/utils/Import.js +77 -0
- package/src/utils/Import.js.map +1 -0
- package/{esm → src}/utils/Multipart.d.ts +0 -1
- package/src/utils/Multipart.js.map +1 -0
- package/{cjs → src}/utils/Runtime.d.ts +0 -1
- package/src/utils/Runtime.js.map +1 -0
- package/{cjs → src}/utils/Stream.d.ts +0 -1
- package/src/utils/Stream.js.map +1 -0
- package/{esm → src}/utils/WebSocket.d.ts +0 -1
- package/src/utils/WebSocket.js.map +1 -0
- package/LICENSE +0 -190
- package/cjs/CodeInterpreter.d.ts.map +0 -1
- package/cjs/CodeInterpreter.js.map +0 -1
- package/cjs/ComputerUse.d.ts +0 -443
- package/cjs/ComputerUse.d.ts.map +0 -1
- package/cjs/ComputerUse.js.map +0 -1
- package/cjs/Daytona.d.ts.map +0 -1
- package/cjs/FileSystem.d.ts +0 -328
- package/cjs/FileSystem.d.ts.map +0 -1
- package/cjs/FileSystem.js.map +0 -1
- package/cjs/Git.d.ts +0 -203
- package/cjs/Git.d.ts.map +0 -1
- package/cjs/Git.js.map +0 -1
- package/cjs/Image.d.ts.map +0 -1
- package/cjs/Image.js.map +0 -1
- package/cjs/LspServer.d.ts.map +0 -1
- package/cjs/LspServer.js.map +0 -1
- package/cjs/ObjectStorage.d.ts +0 -79
- package/cjs/ObjectStorage.d.ts.map +0 -1
- package/cjs/ObjectStorage.js.map +0 -1
- package/cjs/Process.d.ts.map +0 -1
- package/cjs/Process.js.map +0 -1
- package/cjs/PtyHandle.d.ts.map +0 -1
- package/cjs/PtyHandle.js.map +0 -1
- package/cjs/README.md +0 -147
- package/cjs/Sandbox.d.ts.map +0 -1
- package/cjs/Sandbox.js.map +0 -1
- package/cjs/Snapshot.d.ts.map +0 -1
- package/cjs/Snapshot.js.map +0 -1
- package/cjs/Volume.d.ts +0 -84
- package/cjs/Volume.d.ts.map +0 -1
- package/cjs/Volume.js.map +0 -1
- package/cjs/code-toolbox/SandboxJsCodeToolbox.d.ts.map +0 -1
- package/cjs/code-toolbox/SandboxJsCodeToolbox.js.map +0 -1
- package/cjs/code-toolbox/SandboxPythonCodeToolbox.d.ts.map +0 -1
- package/cjs/code-toolbox/SandboxPythonCodeToolbox.js.map +0 -1
- package/cjs/code-toolbox/SandboxTsCodeToolbox.d.ts.map +0 -1
- package/cjs/code-toolbox/SandboxTsCodeToolbox.js.map +0 -1
- package/cjs/errors/DaytonaError.d.ts +0 -32
- package/cjs/errors/DaytonaError.d.ts.map +0 -1
- package/cjs/errors/DaytonaError.js.map +0 -1
- package/cjs/index.d.ts.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/package.json +0 -3
- package/cjs/types/Charts.d.ts +0 -152
- package/cjs/types/Charts.d.ts.map +0 -1
- package/cjs/types/Charts.js.map +0 -1
- package/cjs/types/CodeInterpreter.d.ts +0 -77
- package/cjs/types/CodeInterpreter.d.ts.map +0 -1
- package/cjs/types/CodeInterpreter.js.map +0 -1
- package/cjs/types/ExecuteResponse.d.ts.map +0 -1
- package/cjs/types/ExecuteResponse.js.map +0 -1
- package/cjs/types/Pty.d.ts.map +0 -1
- package/cjs/types/Pty.js.map +0 -1
- package/cjs/utils/ArtifactParser.d.ts.map +0 -1
- package/cjs/utils/ArtifactParser.js.map +0 -1
- package/cjs/utils/Binary.d.ts +0 -39
- package/cjs/utils/Binary.d.ts.map +0 -1
- package/cjs/utils/Binary.js.map +0 -1
- package/cjs/utils/FileTransfer.d.ts.map +0 -1
- package/cjs/utils/FileTransfer.js.map +0 -1
- package/cjs/utils/Import.d.ts.map +0 -1
- package/cjs/utils/Import.js +0 -81
- package/cjs/utils/Import.js.map +0 -1
- package/cjs/utils/Multipart.d.ts +0 -27
- package/cjs/utils/Multipart.d.ts.map +0 -1
- package/cjs/utils/Multipart.js.map +0 -1
- package/cjs/utils/Runtime.d.ts.map +0 -1
- package/cjs/utils/Runtime.js.map +0 -1
- package/cjs/utils/Stream.d.ts.map +0 -1
- package/cjs/utils/Stream.js.map +0 -1
- package/cjs/utils/WebSocket.d.ts +0 -10
- package/cjs/utils/WebSocket.d.ts.map +0 -1
- package/cjs/utils/WebSocket.js.map +0 -1
- package/esm/CodeInterpreter.d.ts +0 -96
- package/esm/CodeInterpreter.d.ts.map +0 -1
- package/esm/CodeInterpreter.js +0 -295
- package/esm/CodeInterpreter.js.map +0 -1
- package/esm/ComputerUse.d.ts.map +0 -1
- package/esm/ComputerUse.js +0 -509
- package/esm/ComputerUse.js.map +0 -1
- package/esm/Daytona.d.ts +0 -354
- package/esm/Daytona.d.ts.map +0 -1
- package/esm/Daytona.js +0 -410
- package/esm/Daytona.js.map +0 -1
- package/esm/FileSystem.d.ts.map +0 -1
- package/esm/FileSystem.js +0 -331
- package/esm/FileSystem.js.map +0 -1
- package/esm/Git.d.ts.map +0 -1
- package/esm/Git.js +0 -260
- package/esm/Git.js.map +0 -1
- package/esm/Image.d.ts +0 -285
- package/esm/Image.d.ts.map +0 -1
- package/esm/Image.js +0 -569
- package/esm/Image.js.map +0 -1
- package/esm/LspServer.d.ts +0 -172
- package/esm/LspServer.d.ts.map +0 -1
- package/esm/LspServer.js +0 -204
- package/esm/LspServer.js.map +0 -1
- package/esm/ObjectStorage.d.ts.map +0 -1
- package/esm/ObjectStorage.js +0 -187
- package/esm/ObjectStorage.js.map +0 -1
- package/esm/Process.d.ts +0 -442
- package/esm/Process.d.ts.map +0 -1
- package/esm/Process.js +0 -644
- package/esm/Process.js.map +0 -1
- package/esm/PtyHandle.d.ts +0 -155
- package/esm/PtyHandle.d.ts.map +0 -1
- package/esm/PtyHandle.js +0 -374
- package/esm/PtyHandle.js.map +0 -1
- package/esm/README.md +0 -147
- package/esm/Sandbox.d.ts +0 -359
- package/esm/Sandbox.d.ts.map +0 -1
- package/esm/Sandbox.js +0 -532
- package/esm/Sandbox.js.map +0 -1
- package/esm/Snapshot.d.ts +0 -138
- package/esm/Snapshot.d.ts.map +0 -1
- package/esm/Snapshot.js +0 -207
- package/esm/Snapshot.js.map +0 -1
- package/esm/Volume.d.ts.map +0 -1
- package/esm/Volume.js +0 -95
- package/esm/Volume.js.map +0 -1
- package/esm/code-toolbox/SandboxJsCodeToolbox.d.ts +0 -6
- package/esm/code-toolbox/SandboxJsCodeToolbox.d.ts.map +0 -1
- package/esm/code-toolbox/SandboxJsCodeToolbox.js +0 -13
- package/esm/code-toolbox/SandboxJsCodeToolbox.js.map +0 -1
- package/esm/code-toolbox/SandboxPythonCodeToolbox.d.ts +0 -12
- package/esm/code-toolbox/SandboxPythonCodeToolbox.d.ts.map +0 -1
- package/esm/code-toolbox/SandboxPythonCodeToolbox.js +0 -355
- package/esm/code-toolbox/SandboxPythonCodeToolbox.js.map +0 -1
- package/esm/code-toolbox/SandboxTsCodeToolbox.d.ts +0 -6
- package/esm/code-toolbox/SandboxTsCodeToolbox.d.ts.map +0 -1
- package/esm/code-toolbox/SandboxTsCodeToolbox.js +0 -14
- package/esm/code-toolbox/SandboxTsCodeToolbox.js.map +0 -1
- package/esm/errors/DaytonaError.d.ts.map +0 -1
- package/esm/errors/DaytonaError.js +0 -44
- package/esm/errors/DaytonaError.js.map +0 -1
- package/esm/index.d.ts +0 -22
- package/esm/index.d.ts.map +0 -1
- package/esm/index.js +0 -22
- package/esm/index.js.map +0 -1
- package/esm/package.json +0 -3
- package/esm/types/Charts.d.ts.map +0 -1
- package/esm/types/Charts.js +0 -42
- package/esm/types/Charts.js.map +0 -1
- package/esm/types/CodeInterpreter.d.ts.map +0 -1
- package/esm/types/CodeInterpreter.js +0 -6
- package/esm/types/CodeInterpreter.js.map +0 -1
- package/esm/types/ExecuteResponse.d.ts +0 -26
- package/esm/types/ExecuteResponse.d.ts.map +0 -1
- package/esm/types/ExecuteResponse.js +0 -6
- package/esm/types/ExecuteResponse.js.map +0 -1
- package/esm/types/Pty.d.ts +0 -48
- package/esm/types/Pty.d.ts.map +0 -1
- package/esm/types/Pty.js +0 -6
- package/esm/types/Pty.js.map +0 -1
- package/esm/utils/ArtifactParser.d.ts +0 -14
- package/esm/utils/ArtifactParser.d.ts.map +0 -1
- package/esm/utils/ArtifactParser.js +0 -51
- package/esm/utils/ArtifactParser.js.map +0 -1
- package/esm/utils/Binary.d.ts.map +0 -1
- package/esm/utils/Binary.js +0 -157
- package/esm/utils/Binary.js.map +0 -1
- package/esm/utils/FileTransfer.d.ts +0 -15
- package/esm/utils/FileTransfer.d.ts.map +0 -1
- package/esm/utils/FileTransfer.js +0 -209
- package/esm/utils/FileTransfer.js.map +0 -1
- package/esm/utils/Import.d.ts +0 -211
- package/esm/utils/Import.d.ts.map +0 -1
- package/esm/utils/Import.js +0 -45
- package/esm/utils/Import.js.map +0 -1
- package/esm/utils/Multipart.d.ts.map +0 -1
- package/esm/utils/Multipart.js +0 -107
- package/esm/utils/Multipart.js.map +0 -1
- package/esm/utils/Runtime.d.ts +0 -37
- package/esm/utils/Runtime.d.ts.map +0 -1
- package/esm/utils/Runtime.js +0 -57
- package/esm/utils/Runtime.js.map +0 -1
- package/esm/utils/Stream.d.ts +0 -20
- package/esm/utils/Stream.d.ts.map +0 -1
- package/esm/utils/Stream.js +0 -360
- package/esm/utils/Stream.js.map +0 -1
- package/esm/utils/WebSocket.d.ts.map +0 -1
- package/esm/utils/WebSocket.js +0 -22
- package/esm/utils/WebSocket.js.map +0 -1
- /package/{cjs → src}/CodeInterpreter.js +0 -0
- /package/{cjs → src}/ComputerUse.js +0 -0
- /package/{cjs → src}/FileSystem.js +0 -0
- /package/{cjs → src}/Git.js +0 -0
- /package/{cjs → src}/LspServer.js +0 -0
- /package/{cjs → src}/ObjectStorage.js +0 -0
- /package/{cjs → src}/Process.js +0 -0
- /package/{cjs → src}/PtyHandle.js +0 -0
- /package/{cjs → src}/Volume.js +0 -0
- /package/{cjs → src}/code-toolbox/SandboxJsCodeToolbox.js +0 -0
- /package/{cjs → src}/code-toolbox/SandboxPythonCodeToolbox.js +0 -0
- /package/{cjs → src}/code-toolbox/SandboxTsCodeToolbox.js +0 -0
- /package/{cjs → src}/errors/DaytonaError.js +0 -0
- /package/{cjs → src}/index.js +0 -0
- /package/{cjs → src}/types/Charts.js +0 -0
- /package/{cjs → src}/types/CodeInterpreter.js +0 -0
- /package/{cjs → src}/types/ExecuteResponse.js +0 -0
- /package/{cjs → src}/types/Pty.js +0 -0
- /package/{cjs → src}/utils/ArtifactParser.js +0 -0
- /package/{cjs → src}/utils/Binary.js +0 -0
- /package/{cjs → src}/utils/FileTransfer.js +0 -0
- /package/{cjs → src}/utils/Multipart.js +0 -0
- /package/{cjs → src}/utils/Runtime.js +0 -0
- /package/{cjs → src}/utils/Stream.js +0 -0
- /package/{cjs → src}/utils/WebSocket.js +0 -0
package/esm/FileSystem.js
DELETED
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import * as pathe from 'pathe';
|
|
6
|
-
import { dynamicImport } from './utils/Import.js';
|
|
7
|
-
import { RUNTIME, Runtime } from './utils/Runtime.js';
|
|
8
|
-
import { DaytonaError } from './errors/DaytonaError.js';
|
|
9
|
-
import { normalizeResponseStream, processDownloadFilesResponseWithBusboy, processDownloadFilesResponseWithBuffered, } from './utils/FileTransfer.js';
|
|
10
|
-
/**
|
|
11
|
-
* Provides file system operations within a Sandbox.
|
|
12
|
-
*
|
|
13
|
-
* @class
|
|
14
|
-
*/
|
|
15
|
-
export class FileSystem {
|
|
16
|
-
clientConfig;
|
|
17
|
-
apiClient;
|
|
18
|
-
ensureToolboxUrl;
|
|
19
|
-
constructor(clientConfig, apiClient, ensureToolboxUrl) {
|
|
20
|
-
this.clientConfig = clientConfig;
|
|
21
|
-
this.apiClient = apiClient;
|
|
22
|
-
this.ensureToolboxUrl = ensureToolboxUrl;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Create a new directory in the Sandbox with specified permissions.
|
|
26
|
-
*
|
|
27
|
-
* @param {string} path - Path where the directory should be created. Relative paths are resolved based on the sandbox working directory.
|
|
28
|
-
* @param {string} mode - Directory permissions in octal format (e.g. "755")
|
|
29
|
-
* @returns {Promise<void>}
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* // Create a directory with standard permissions
|
|
33
|
-
* await fs.createFolder('app/data', '755');
|
|
34
|
-
*/
|
|
35
|
-
async createFolder(path, mode) {
|
|
36
|
-
const response = await this.apiClient.createFolder(path, mode);
|
|
37
|
-
return response.data;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Deletes a file or directory from the Sandbox.
|
|
41
|
-
*
|
|
42
|
-
* @param {string} path - Path to the file or directory to delete. Relative paths are resolved based on the sandbox working directory.
|
|
43
|
-
* @param {boolean} [recursive] - If the file is a directory, this must be true to delete it.
|
|
44
|
-
* @returns {Promise<void>}
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* // Delete a file
|
|
48
|
-
* await fs.deleteFile('app/temp.log');
|
|
49
|
-
*/
|
|
50
|
-
async deleteFile(path, recursive) {
|
|
51
|
-
const response = await this.apiClient.deleteFile(path, recursive);
|
|
52
|
-
return response.data;
|
|
53
|
-
}
|
|
54
|
-
async downloadFile(src, dst, timeout = 30 * 60) {
|
|
55
|
-
const remotePath = src;
|
|
56
|
-
if (typeof dst !== 'string') {
|
|
57
|
-
if (dst) {
|
|
58
|
-
timeout = dst;
|
|
59
|
-
}
|
|
60
|
-
const response = await this.downloadFiles([{ source: remotePath }], timeout);
|
|
61
|
-
if (response[0].error) {
|
|
62
|
-
throw new DaytonaError(response[0].error);
|
|
63
|
-
}
|
|
64
|
-
return response[0].result;
|
|
65
|
-
}
|
|
66
|
-
const response = await this.downloadFiles([{ source: remotePath, destination: dst }], timeout);
|
|
67
|
-
if (response[0].error) {
|
|
68
|
-
throw new DaytonaError(response[0].error);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Downloads multiple files from the Sandbox. If the files already exist locally, they will be overwritten.
|
|
73
|
-
*
|
|
74
|
-
* @param {FileDownloadRequest[]} files - Array of file download requests.
|
|
75
|
-
* @param {number} [timeoutSec] - Timeout for the download operation in seconds. 0 means no timeout.
|
|
76
|
-
* Default is 30 minutes.
|
|
77
|
-
* @returns {Promise<FileDownloadResponse[]>} Array of download results.
|
|
78
|
-
*
|
|
79
|
-
* @throws {DaytonaError} If the request itself fails (network issues, invalid request/response, etc.). Individual
|
|
80
|
-
* file download errors are returned in the `FileDownloadResponse.error` field.
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* // Download multiple files
|
|
84
|
-
* const results = await fs.downloadFiles([
|
|
85
|
-
* { source: 'tmp/data.json' },
|
|
86
|
-
* { source: 'tmp/config.json', destination: 'local_config.json' }
|
|
87
|
-
* ]);
|
|
88
|
-
* results.forEach(result => {
|
|
89
|
-
* if (result.error) {
|
|
90
|
-
* console.error(`Error downloading ${result.source}: ${result.error}`);
|
|
91
|
-
* } else if (result.result) {
|
|
92
|
-
* console.log(`Downloaded ${result.source} to ${result.result}`);
|
|
93
|
-
* }
|
|
94
|
-
* });
|
|
95
|
-
*/
|
|
96
|
-
async downloadFiles(files, timeoutSec = 30 * 60) {
|
|
97
|
-
if (files.length === 0)
|
|
98
|
-
return [];
|
|
99
|
-
const isNonStreamingRuntime = RUNTIME === Runtime.BROWSER || RUNTIME === Runtime.SERVERLESS;
|
|
100
|
-
// Prepare destinations and metadata
|
|
101
|
-
const metadataMap = new Map();
|
|
102
|
-
for (const f of files) {
|
|
103
|
-
metadataMap.set(f.source, { destination: f.destination });
|
|
104
|
-
if (f.destination) {
|
|
105
|
-
const fs = await dynamicImport('fs', 'Downloading files to local files is not supported: ');
|
|
106
|
-
await fs.promises.mkdir(pathe.dirname(f.destination), { recursive: true });
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
const response = await this.apiClient.downloadFiles({ paths: files.map((f) => f.source) }, {
|
|
110
|
-
responseType: isNonStreamingRuntime ? 'arraybuffer' : 'stream',
|
|
111
|
-
timeout: timeoutSec * 1000,
|
|
112
|
-
});
|
|
113
|
-
const stream = normalizeResponseStream(response.data);
|
|
114
|
-
// Node.js path: use busboy for efficient streaming
|
|
115
|
-
if (isNonStreamingRuntime) {
|
|
116
|
-
await processDownloadFilesResponseWithBuffered(stream, response.headers, metadataMap);
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
await processDownloadFilesResponseWithBusboy(stream, response.headers, metadataMap);
|
|
120
|
-
}
|
|
121
|
-
return files.map((f) => {
|
|
122
|
-
const metadata = metadataMap.get(f.source);
|
|
123
|
-
const error = metadata?.error || (!metadata?.result ? 'No data received for this file' : undefined);
|
|
124
|
-
return {
|
|
125
|
-
source: f.source,
|
|
126
|
-
result: error ? undefined : metadata.result,
|
|
127
|
-
error,
|
|
128
|
-
};
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Searches for text patterns within files in the Sandbox.
|
|
133
|
-
*
|
|
134
|
-
* @param {string} path - Directory to search in. Relative paths are resolved based on the sandbox working directory.
|
|
135
|
-
* @param {string} pattern - Search pattern
|
|
136
|
-
* @returns {Promise<Array<Match>>} Array of matches with file and line information
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* // Find all TODO comments in TypeScript files
|
|
140
|
-
* const matches = await fs.findFiles('app/src', 'TODO:');
|
|
141
|
-
* matches.forEach(match => {
|
|
142
|
-
* console.log(`${match.file}:${match.line}: ${match.content}`);
|
|
143
|
-
* });
|
|
144
|
-
*/
|
|
145
|
-
async findFiles(path, pattern) {
|
|
146
|
-
const response = await this.apiClient.findInFiles(path, pattern);
|
|
147
|
-
return response.data;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Retrieves detailed information about a file or directory.
|
|
151
|
-
*
|
|
152
|
-
* @param {string} path - Path to the file or directory. Relative paths are resolved based on the sandbox working directory.
|
|
153
|
-
* @returns {Promise<FileInfo>} Detailed file information including size, permissions, modification time
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* // Get file details
|
|
157
|
-
* const info = await fs.getFileDetails('app/config.json');
|
|
158
|
-
* console.log(`Size: ${info.size}, Modified: ${info.modTime}`);
|
|
159
|
-
*/
|
|
160
|
-
async getFileDetails(path) {
|
|
161
|
-
const response = await this.apiClient.getFileInfo(path);
|
|
162
|
-
return response.data;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Lists contents of a directory in the Sandbox.
|
|
166
|
-
*
|
|
167
|
-
* @param {string} path - Directory path to list. Relative paths are resolved based on the sandbox working directory.
|
|
168
|
-
* @returns {Promise<FileInfo[]>} Array of file and directory information
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
* // List directory contents
|
|
172
|
-
* const files = await fs.listFiles('app/src');
|
|
173
|
-
* files.forEach(file => {
|
|
174
|
-
* console.log(`${file.name} (${file.size} bytes)`);
|
|
175
|
-
* });
|
|
176
|
-
*/
|
|
177
|
-
async listFiles(path) {
|
|
178
|
-
const response = await this.apiClient.listFiles(path);
|
|
179
|
-
return response.data;
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* Moves or renames a file or directory.
|
|
183
|
-
*
|
|
184
|
-
* @param {string} source - Source path. Relative paths are resolved based on the sandbox working directory.
|
|
185
|
-
* @param {string} destination - Destination path. Relative paths are resolved based on the sandbox working directory.
|
|
186
|
-
* @returns {Promise<void>}
|
|
187
|
-
*
|
|
188
|
-
* @example
|
|
189
|
-
* // Move a file to a new location
|
|
190
|
-
* await fs.moveFiles('app/temp/data.json', 'app/data/data.json');
|
|
191
|
-
*/
|
|
192
|
-
async moveFiles(source, destination) {
|
|
193
|
-
const response = await this.apiClient.moveFile(source, destination);
|
|
194
|
-
return response.data;
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Replaces text content in multiple files.
|
|
198
|
-
*
|
|
199
|
-
* @param {string[]} files - Array of file paths to process. Relative paths are resolved based on the sandbox working directory.
|
|
200
|
-
* @param {string} pattern - Pattern to replace
|
|
201
|
-
* @param {string} newValue - Replacement text
|
|
202
|
-
* @returns {Promise<Array<ReplaceResult>>} Results of the replace operation for each file
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* // Update version number across multiple files
|
|
206
|
-
* const results = await fs.replaceInFiles(
|
|
207
|
-
* ['app/package.json', 'app/version.ts'],
|
|
208
|
-
* '"version": "1.0.0"',
|
|
209
|
-
* '"version": "1.1.0"'
|
|
210
|
-
* );
|
|
211
|
-
*/
|
|
212
|
-
async replaceInFiles(files, pattern, newValue) {
|
|
213
|
-
const replaceRequest = {
|
|
214
|
-
files,
|
|
215
|
-
newValue,
|
|
216
|
-
pattern,
|
|
217
|
-
};
|
|
218
|
-
const response = await this.apiClient.replaceInFiles(replaceRequest);
|
|
219
|
-
return response.data;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Searches for files and directories by name pattern in the Sandbox.
|
|
223
|
-
*
|
|
224
|
-
* @param {string} path - Directory to search in. Relative paths are resolved based on the sandbox working directory.
|
|
225
|
-
* @param {string} pattern - File name pattern (supports globs)
|
|
226
|
-
* @returns {Promise<SearchFilesResponse>} Search results with matching files
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* // Find all TypeScript files
|
|
230
|
-
* const result = await fs.searchFiles('app', '*.ts');
|
|
231
|
-
* result.files.forEach(file => console.log(file));
|
|
232
|
-
*/
|
|
233
|
-
async searchFiles(path, pattern) {
|
|
234
|
-
const response = await this.apiClient.searchFiles(path, pattern);
|
|
235
|
-
return response.data;
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Sets permissions and ownership for a file or directory.
|
|
239
|
-
*
|
|
240
|
-
* @param {string} path - Path to the file or directory. Relative paths are resolved based on the sandbox working directory.
|
|
241
|
-
* @param {FilePermissionsParams} permissions - Permission settings
|
|
242
|
-
* @returns {Promise<void>}
|
|
243
|
-
*
|
|
244
|
-
* @example
|
|
245
|
-
* // Set file permissions and ownership
|
|
246
|
-
* await fs.setFilePermissions('app/script.sh', {
|
|
247
|
-
* owner: 'daytona',
|
|
248
|
-
* group: 'users',
|
|
249
|
-
* mode: '755' // Execute permission for shell script
|
|
250
|
-
* });
|
|
251
|
-
*/
|
|
252
|
-
async setFilePermissions(path, permissions) {
|
|
253
|
-
const response = await this.apiClient.setFilePermissions(path, permissions.owner, permissions.group, permissions.mode);
|
|
254
|
-
return response.data;
|
|
255
|
-
}
|
|
256
|
-
async uploadFile(src, dst, timeout = 30 * 60) {
|
|
257
|
-
await this.uploadFiles([{ source: src, destination: dst }], timeout);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Uploads multiple files to the Sandbox. If files already exist at the destination paths,
|
|
261
|
-
* they will be overwritten.
|
|
262
|
-
*
|
|
263
|
-
* @param {FileUpload[]} files - Array of files to upload.
|
|
264
|
-
* @param {number} [timeout] - Timeout for the upload operation in seconds. 0 means no timeout.
|
|
265
|
-
* Default is 30 minutes.
|
|
266
|
-
* @returns {Promise<void>}
|
|
267
|
-
*
|
|
268
|
-
* @example
|
|
269
|
-
* // Upload multiple text files
|
|
270
|
-
* const files = [
|
|
271
|
-
* {
|
|
272
|
-
* source: Buffer.from('Content of file 1'),
|
|
273
|
-
* destination: '/tmp/file1.txt'
|
|
274
|
-
* },
|
|
275
|
-
* {
|
|
276
|
-
* source: 'app/data/file2.txt',
|
|
277
|
-
* destination: '/tmp/file2.txt'
|
|
278
|
-
* },
|
|
279
|
-
* {
|
|
280
|
-
* source: Buffer.from('{"key": "value"}'),
|
|
281
|
-
* destination: '/tmp/config.json'
|
|
282
|
-
* }
|
|
283
|
-
* ];
|
|
284
|
-
* await fs.uploadFiles(files);
|
|
285
|
-
*/
|
|
286
|
-
async uploadFiles(files, timeout = 30 * 60) {
|
|
287
|
-
const isNonStreamingRuntime = RUNTIME === Runtime.DENO || RUNTIME === Runtime.BROWSER || RUNTIME === Runtime.SERVERLESS;
|
|
288
|
-
const FormDataClass = isNonStreamingRuntime
|
|
289
|
-
? FormData
|
|
290
|
-
: (await dynamicImport('form-data', 'Uploading files is not supported: '));
|
|
291
|
-
const form = new FormDataClass();
|
|
292
|
-
for (const [i, { source, destination }] of files.entries()) {
|
|
293
|
-
form.append(`files[${i}].path`, destination);
|
|
294
|
-
const payload = await this.makeFilePayload(source);
|
|
295
|
-
form.append(`files[${i}].file`, payload, destination);
|
|
296
|
-
}
|
|
297
|
-
if (isNonStreamingRuntime) {
|
|
298
|
-
await this.ensureToolboxUrl();
|
|
299
|
-
const url = `${this.clientConfig.basePath}/files/bulk-upload`;
|
|
300
|
-
await fetch(url, {
|
|
301
|
-
method: 'POST',
|
|
302
|
-
headers: this.clientConfig.baseOptions.headers,
|
|
303
|
-
body: form,
|
|
304
|
-
signal: timeout ? AbortSignal.timeout(timeout * 1000) : undefined,
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
await this.apiClient.uploadFiles({
|
|
309
|
-
data: form,
|
|
310
|
-
maxRedirects: 0,
|
|
311
|
-
timeout: timeout * 1000,
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
async makeFilePayload(source) {
|
|
316
|
-
// String = file path
|
|
317
|
-
if (typeof source === 'string') {
|
|
318
|
-
const fs = await dynamicImport('fs', 'Uploading file from local file system is not supported: ');
|
|
319
|
-
return fs.createReadStream(source);
|
|
320
|
-
}
|
|
321
|
-
// Blob
|
|
322
|
-
if (RUNTIME === Runtime.BROWSER || RUNTIME === Runtime.SERVERLESS || RUNTIME === Runtime.DENO) {
|
|
323
|
-
// Use .slice() to ensure we have a concrete ArrayBuffer, not ArrayBufferLike
|
|
324
|
-
return new Blob([source.slice()], { type: 'application/octet-stream' });
|
|
325
|
-
}
|
|
326
|
-
// Readable stream
|
|
327
|
-
const stream = await dynamicImport('stream', 'Uploading file is not supported: ');
|
|
328
|
-
return stream.Readable.from(source);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
//# sourceMappingURL=FileSystem.js.map
|
package/esm/FileSystem.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FileSystem.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/FileSystem.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAU9B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EACL,uBAAuB,EACvB,sCAAsC,EACtC,wCAAwC,GACzC,MAAM,sBAAsB,CAAA;AAmF7B;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAEF;IACA;IACA;IAHnB,YACmB,YAA2B,EAC3B,SAAwB,EACxB,gBAAqC;QAFrC,iBAAY,GAAZ,YAAY,CAAe;QAC3B,cAAS,GAAT,SAAS,CAAe;QACxB,qBAAgB,GAAhB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C;IAa7B;;;;;;;;;;;;;;;;;;;OAmBG;IACU,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpF;;;;;;;;;;;;;;;;;;;OAmBG;IACU,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpF;;;;;;;;;;;;;;;;OAgBG;IACU,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;CAItD"}
|
package/esm/Git.js
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Provides Git operations within a Sandbox.
|
|
7
|
-
*
|
|
8
|
-
* @class
|
|
9
|
-
*/
|
|
10
|
-
export class Git {
|
|
11
|
-
apiClient;
|
|
12
|
-
constructor(apiClient) {
|
|
13
|
-
this.apiClient = apiClient;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Stages the specified files for the next commit, similar to
|
|
17
|
-
* running 'git add' on the command line.
|
|
18
|
-
*
|
|
19
|
-
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the sandbox working directory.
|
|
20
|
-
* @param {string[]} files - List of file paths or directories to stage, relative to the repository root
|
|
21
|
-
* @returns {Promise<void>}
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* // Stage a single file
|
|
25
|
-
* await git.add('workspace/repo', ['file.txt']);
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* // Stage whole repository
|
|
29
|
-
* await git.add('workspace/repo', ['.']);
|
|
30
|
-
*/
|
|
31
|
-
async add(path, files) {
|
|
32
|
-
await this.apiClient.addFiles({
|
|
33
|
-
path,
|
|
34
|
-
files,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* List branches in the repository.
|
|
39
|
-
*
|
|
40
|
-
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the sandbox working directory.
|
|
41
|
-
* @returns {Promise<ListBranchResponse>} List of branches in the repository
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* const response = await git.branches('workspace/repo');
|
|
45
|
-
* console.log(`Branches: ${response.branches}`);
|
|
46
|
-
*/
|
|
47
|
-
async branches(path) {
|
|
48
|
-
const response = await this.apiClient.listBranches(path);
|
|
49
|
-
return response.data;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Create branch in the repository.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the sandbox working directory.
|
|
55
|
-
* @param {string} name - Name of the new branch to create
|
|
56
|
-
* @returns {Promise<void>}
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* await git.createBranch('workspace/repo', 'new-feature');
|
|
60
|
-
*/
|
|
61
|
-
async createBranch(path, name) {
|
|
62
|
-
await this.apiClient.createBranch({
|
|
63
|
-
path,
|
|
64
|
-
name,
|
|
65
|
-
});
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Delete branche in the repository.
|
|
70
|
-
*
|
|
71
|
-
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the sandbox working directory.
|
|
72
|
-
* @param {string} name - Name of the branch to delete
|
|
73
|
-
* @returns {Promise<void>}
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* await git.deleteBranch('workspace/repo', 'new-feature');
|
|
77
|
-
*/
|
|
78
|
-
async deleteBranch(path, name) {
|
|
79
|
-
await this.apiClient.deleteBranch({
|
|
80
|
-
path,
|
|
81
|
-
name,
|
|
82
|
-
});
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Checkout branche in the repository.
|
|
87
|
-
*
|
|
88
|
-
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the sandbox working directory.
|
|
89
|
-
* @param {string} branch - Name of the branch to checkout
|
|
90
|
-
* @returns {Promise<void>}
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* await git.checkoutBranch('workspace/repo', 'new-feature');
|
|
94
|
-
*/
|
|
95
|
-
async checkoutBranch(path, branch) {
|
|
96
|
-
await this.apiClient.checkoutBranch({
|
|
97
|
-
path,
|
|
98
|
-
branch,
|
|
99
|
-
});
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Clones a Git repository into the specified path. It supports
|
|
104
|
-
* cloning specific branches or commits, and can authenticate with the remote
|
|
105
|
-
* repository if credentials are provided.
|
|
106
|
-
*
|
|
107
|
-
* @param {string} url - Repository URL to clone from
|
|
108
|
-
* @param {string} path - Path where the repository should be cloned. Relative paths are resolved based on the sandbox working directory.
|
|
109
|
-
* @param {string} [branch] - Specific branch to clone. If not specified, clones the default branch
|
|
110
|
-
* @param {string} [commitId] - Specific commit to clone. If specified, the repository will be left in a detached HEAD state at this commit
|
|
111
|
-
* @param {string} [username] - Git username for authentication
|
|
112
|
-
* @param {string} [password] - Git password or token for authentication
|
|
113
|
-
* @returns {Promise<void>}
|
|
114
|
-
*
|
|
115
|
-
* @example
|
|
116
|
-
* // Clone the default branch
|
|
117
|
-
* await git.clone(
|
|
118
|
-
* 'https://github.com/user/repo.git',
|
|
119
|
-
* 'workspace/repo'
|
|
120
|
-
* );
|
|
121
|
-
*
|
|
122
|
-
* @example
|
|
123
|
-
* // Clone a specific branch with authentication
|
|
124
|
-
* await git.clone(
|
|
125
|
-
* 'https://github.com/user/private-repo.git',
|
|
126
|
-
* 'workspace/private',
|
|
127
|
-
* branch='develop',
|
|
128
|
-
* username='user',
|
|
129
|
-
* password='token'
|
|
130
|
-
* );
|
|
131
|
-
*
|
|
132
|
-
* @example
|
|
133
|
-
* // Clone a specific commit
|
|
134
|
-
* await git.clone(
|
|
135
|
-
* 'https://github.com/user/repo.git',
|
|
136
|
-
* 'workspace/repo-old',
|
|
137
|
-
* commitId='abc123'
|
|
138
|
-
* );
|
|
139
|
-
*/
|
|
140
|
-
async clone(url, path, branch, commitId, username, password) {
|
|
141
|
-
await this.apiClient.cloneRepository({
|
|
142
|
-
url: url,
|
|
143
|
-
branch: branch,
|
|
144
|
-
path,
|
|
145
|
-
username,
|
|
146
|
-
password,
|
|
147
|
-
commit_id: commitId,
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Commits staged changes.
|
|
152
|
-
*
|
|
153
|
-
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the sandbox working directory.
|
|
154
|
-
* @param {string} message - Commit message describing the changes
|
|
155
|
-
* @param {string} author - Name of the commit author
|
|
156
|
-
* @param {string} email - Email address of the commit author
|
|
157
|
-
* @param {boolean} [allowEmpty] - Allow creating an empty commit when no changes are staged
|
|
158
|
-
* @returns {Promise<void>}
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* // Stage and commit changes
|
|
162
|
-
* await git.add('workspace/repo', ['README.md']);
|
|
163
|
-
* await git.commit(
|
|
164
|
-
* 'workspace/repo',
|
|
165
|
-
* 'Update documentation',
|
|
166
|
-
* 'John Doe',
|
|
167
|
-
* 'john@example.com',
|
|
168
|
-
* true
|
|
169
|
-
* );
|
|
170
|
-
*
|
|
171
|
-
*/
|
|
172
|
-
async commit(path, message, author, email, allowEmpty) {
|
|
173
|
-
const response = await this.apiClient.commitChanges({
|
|
174
|
-
path,
|
|
175
|
-
message,
|
|
176
|
-
author,
|
|
177
|
-
email,
|
|
178
|
-
allow_empty: allowEmpty,
|
|
179
|
-
});
|
|
180
|
-
return {
|
|
181
|
-
sha: response.data.hash,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Push local changes to the remote repository.
|
|
186
|
-
*
|
|
187
|
-
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the sandbox working directory.
|
|
188
|
-
* @param {string} [username] - Git username for authentication
|
|
189
|
-
* @param {string} [password] - Git password or token for authentication
|
|
190
|
-
* @returns {Promise<void>}
|
|
191
|
-
*
|
|
192
|
-
* @example
|
|
193
|
-
* // Push to a public repository
|
|
194
|
-
* await git.push('workspace/repo');
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* // Push to a private repository
|
|
198
|
-
* await git.push(
|
|
199
|
-
* 'workspace/repo',
|
|
200
|
-
* 'user',
|
|
201
|
-
* 'token'
|
|
202
|
-
* );
|
|
203
|
-
*/
|
|
204
|
-
async push(path, username, password) {
|
|
205
|
-
await this.apiClient.pushChanges({
|
|
206
|
-
path,
|
|
207
|
-
username,
|
|
208
|
-
password,
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Pulls changes from the remote repository.
|
|
213
|
-
*
|
|
214
|
-
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the sandbox working directory.
|
|
215
|
-
* @param {string} [username] - Git username for authentication
|
|
216
|
-
* @param {string} [password] - Git password or token for authentication
|
|
217
|
-
* @returns {Promise<void>}
|
|
218
|
-
*
|
|
219
|
-
* @example
|
|
220
|
-
* // Pull from a public repository
|
|
221
|
-
* await git.pull('workspace/repo');
|
|
222
|
-
*
|
|
223
|
-
* @example
|
|
224
|
-
* // Pull from a private repository
|
|
225
|
-
* await git.pull(
|
|
226
|
-
* 'workspace/repo',
|
|
227
|
-
* 'user',
|
|
228
|
-
* 'token'
|
|
229
|
-
* );
|
|
230
|
-
*/
|
|
231
|
-
async pull(path, username, password) {
|
|
232
|
-
await this.apiClient.pullChanges({
|
|
233
|
-
path,
|
|
234
|
-
username,
|
|
235
|
-
password,
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Gets the current status of the Git repository.
|
|
240
|
-
*
|
|
241
|
-
* @param {string} path - Path to the Git repository root. Relative paths are resolved based on the sandbox working directory.
|
|
242
|
-
* @returns {Promise<GitStatus>} Current repository status including:
|
|
243
|
-
* - currentBranch: Name of the current branch
|
|
244
|
-
* - ahead: Number of commits ahead of the remote branch
|
|
245
|
-
* - behind: Number of commits behind the remote branch
|
|
246
|
-
* - branchPublished: Whether the branch has been published to the remote repository
|
|
247
|
-
* - fileStatus: List of file statuses
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* const status = await sandbox.git.status('workspace/repo');
|
|
251
|
-
* console.log(`Current branch: ${status.currentBranch}`);
|
|
252
|
-
* console.log(`Commits ahead: ${status.ahead}`);
|
|
253
|
-
* console.log(`Commits behind: ${status.behind}`);
|
|
254
|
-
*/
|
|
255
|
-
async status(path) {
|
|
256
|
-
const response = await this.apiClient.getStatus(path);
|
|
257
|
-
return response.data;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
//# sourceMappingURL=Git.js.map
|
package/esm/Git.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Git.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/Git.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH;;;;GAIG;AACH,MAAM,OAAO,GAAG;IACe;IAA7B,YAA6B,SAAiB;QAAjB,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;IAElD;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,KAAe;QAC5C,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;YAC5B,IAAI;YACJ,KAAK;SACN,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;;;OASG;IACI,KAAK,CAAC,QAAQ,CAAC,IAAY;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QACxD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