@daytonaio/sdk 0.128.0-alpha.1 → 0.128.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/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 +0 -1
- package/{cjs → src}/Daytona.js +0 -1
- package/src/Daytona.js.map +1 -0
- 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/Daytona.js.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/LspServer.d.ts
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { CompletionList, LspSymbol, LspApi } from '@daytonaio/toolbox-api-client';
|
|
2
|
-
/**
|
|
3
|
-
* Supported language server types.
|
|
4
|
-
*/
|
|
5
|
-
export declare enum LspLanguageId {
|
|
6
|
-
PYTHON = "python",
|
|
7
|
-
TYPESCRIPT = "typescript",
|
|
8
|
-
JAVASCRIPT = "javascript"
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Represents a zero-based position within a text document,
|
|
12
|
-
* specified by line number and character offset.
|
|
13
|
-
*
|
|
14
|
-
* @interface
|
|
15
|
-
* @property {number} line - Zero-based line number in the document
|
|
16
|
-
* @property {number} character - Zero-based character offset on the line
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const position: Position = {
|
|
20
|
-
* line: 10, // Line 11 (zero-based)
|
|
21
|
-
* character: 15 // Character 16 on the line (zero-based)
|
|
22
|
-
* };
|
|
23
|
-
*/
|
|
24
|
-
export type Position = {
|
|
25
|
-
/** Zero-based line number */
|
|
26
|
-
line: number;
|
|
27
|
-
/** Zero-based character offset */
|
|
28
|
-
character: number;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Provides Language Server Protocol functionality for code intelligence to provide
|
|
32
|
-
* IDE-like features such as code completion, symbol search, and more.
|
|
33
|
-
*
|
|
34
|
-
* @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
|
|
35
|
-
* @property {string} pathToProject - Path to the project root directory. Relative paths are resolved based on the sandbox working directory.
|
|
36
|
-
* @property {LspApi} apiClient - API client for Sandbox lsp operations
|
|
37
|
-
* @property {SandboxInstance} instance - The Sandbox instance this server belongs to
|
|
38
|
-
*
|
|
39
|
-
* @class
|
|
40
|
-
*/
|
|
41
|
-
export declare class LspServer {
|
|
42
|
-
private readonly languageId;
|
|
43
|
-
private readonly pathToProject;
|
|
44
|
-
private readonly apiClient;
|
|
45
|
-
constructor(languageId: LspLanguageId, pathToProject: string, apiClient: LspApi);
|
|
46
|
-
/**
|
|
47
|
-
* Starts the language server, must be called before using any other LSP functionality.
|
|
48
|
-
* It initializes the language server for the specified language and project.
|
|
49
|
-
*
|
|
50
|
-
* @returns {Promise<void>}
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* const lsp = await sandbox.createLspServer('typescript', 'workspace/project');
|
|
54
|
-
* await lsp.start(); // Initialize the server
|
|
55
|
-
* // Now ready for LSP operations
|
|
56
|
-
*/
|
|
57
|
-
start(): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Stops the language server, should be called when the LSP server is no longer needed to
|
|
60
|
-
* free up system resources.
|
|
61
|
-
*
|
|
62
|
-
* @returns {Promise<void>}
|
|
63
|
-
*
|
|
64
|
-
* @example
|
|
65
|
-
* // When done with LSP features
|
|
66
|
-
* await lsp.stop(); // Clean up resources
|
|
67
|
-
*/
|
|
68
|
-
stop(): Promise<void>;
|
|
69
|
-
/**
|
|
70
|
-
* Notifies the language server that a file has been opened, enabling
|
|
71
|
-
* language features like diagnostics and completions for that file. The server
|
|
72
|
-
* will begin tracking the file's contents and providing language features.
|
|
73
|
-
*
|
|
74
|
-
* @param {string} path - Path to the opened file. Relative paths are resolved based on the sandbox working directory.
|
|
75
|
-
* @returns {Promise<void>}
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* // When opening a file for editing
|
|
79
|
-
* await lsp.didOpen('workspace/project/src/index.ts');
|
|
80
|
-
* // Now can get completions, symbols, etc. for this file
|
|
81
|
-
*/
|
|
82
|
-
didOpen(path: string): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Notifies the language server that a file has been closed, should be called when a file is closed
|
|
85
|
-
* in the editor to allow the language server to clean up any resources associated with that file.
|
|
86
|
-
*
|
|
87
|
-
* @param {string} path - Path to the closed file. Relative paths are resolved based on the project path
|
|
88
|
-
* set in the LSP server constructor.
|
|
89
|
-
* @returns {Promise<void>}
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* // When done editing a file
|
|
93
|
-
* await lsp.didClose('workspace/project/src/index.ts');
|
|
94
|
-
*/
|
|
95
|
-
didClose(path: string): Promise<void>;
|
|
96
|
-
/**
|
|
97
|
-
* Get symbol information (functions, classes, variables, etc.) from a document.
|
|
98
|
-
*
|
|
99
|
-
* @param {string} path - Path to the file to get symbols from. Relative paths are resolved based on the project path
|
|
100
|
-
* set in the LSP server constructor.
|
|
101
|
-
* @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
|
|
102
|
-
* - name: The symbol's name
|
|
103
|
-
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
104
|
-
* - location: The location of the symbol in the file
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* // Get all symbols in a file
|
|
108
|
-
* const symbols = await lsp.documentSymbols('workspace/project/src/index.ts');
|
|
109
|
-
* symbols.forEach(symbol => {
|
|
110
|
-
* console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
|
|
111
|
-
* });
|
|
112
|
-
*/
|
|
113
|
-
documentSymbols(path: string): Promise<LspSymbol[]>;
|
|
114
|
-
/**
|
|
115
|
-
* Searches for symbols matching the query string across the entire Sandbox.
|
|
116
|
-
*
|
|
117
|
-
* @param {string} query - Search query to match against symbol names
|
|
118
|
-
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
|
119
|
-
* - name: The symbol's name
|
|
120
|
-
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
121
|
-
* - location: The location of the symbol in the file
|
|
122
|
-
*
|
|
123
|
-
* @deprecated Use `sandboxSymbols` instead. This method will be removed in a future version.
|
|
124
|
-
*/
|
|
125
|
-
workspaceSymbols(query: string): Promise<LspSymbol[]>;
|
|
126
|
-
/**
|
|
127
|
-
* Searches for symbols matching the query string across the entire Sandbox.
|
|
128
|
-
*
|
|
129
|
-
* @param {string} query - Search query to match against symbol names
|
|
130
|
-
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
|
131
|
-
* - name: The symbol's name
|
|
132
|
-
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
133
|
-
* - location: The location of the symbol in the file
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* // Search for all symbols containing "User"
|
|
137
|
-
* const symbols = await lsp.sandboxSymbols('User');
|
|
138
|
-
* symbols.forEach(symbol => {
|
|
139
|
-
* console.log(`${symbol.name} (${symbol.kind}) in ${symbol.location}`);
|
|
140
|
-
* });
|
|
141
|
-
*/
|
|
142
|
-
sandboxSymbols(query: string): Promise<LspSymbol[]>;
|
|
143
|
-
/**
|
|
144
|
-
* Gets completion suggestions at a position in a file.
|
|
145
|
-
*
|
|
146
|
-
* @param {string} path - Path to the file. Relative paths are resolved based on the project path
|
|
147
|
-
* set in the LSP server constructor.
|
|
148
|
-
* @param {Position} position - The position in the file where completion was requested
|
|
149
|
-
* @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
|
|
150
|
-
* - isIncomplete: Whether more items might be available
|
|
151
|
-
* - items: List of completion items, each containing:
|
|
152
|
-
* - label: The text to insert
|
|
153
|
-
* - kind: The kind of completion
|
|
154
|
-
* - detail: Additional details about the item
|
|
155
|
-
* - documentation: Documentation for the item
|
|
156
|
-
* - sortText: Text used to sort the item in the list
|
|
157
|
-
* - filterText: Text used to filter the item
|
|
158
|
-
* - insertText: The actual text to insert (if different from label)
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* // Get completions at a specific position
|
|
162
|
-
* const completions = await lsp.completions('workspace/project/src/index.ts', {
|
|
163
|
-
* line: 10,
|
|
164
|
-
* character: 15
|
|
165
|
-
* });
|
|
166
|
-
* completions.items.forEach(item => {
|
|
167
|
-
* console.log(`${item.label} (${item.kind}): ${item.detail}`);
|
|
168
|
-
* });
|
|
169
|
-
*/
|
|
170
|
-
completions(path: string, position: Position): Promise<CompletionList>;
|
|
171
|
-
}
|
|
172
|
-
//# sourceMappingURL=LspServer.d.ts.map
|
package/esm/LspServer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LspServer.d.ts","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/LspServer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAA;AAEjF;;GAEG;AACH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js
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Supported language server types.
|
|
7
|
-
*/
|
|
8
|
-
export var LspLanguageId;
|
|
9
|
-
(function (LspLanguageId) {
|
|
10
|
-
LspLanguageId["PYTHON"] = "python";
|
|
11
|
-
LspLanguageId["TYPESCRIPT"] = "typescript";
|
|
12
|
-
LspLanguageId["JAVASCRIPT"] = "javascript";
|
|
13
|
-
})(LspLanguageId || (LspLanguageId = {}));
|
|
14
|
-
/**
|
|
15
|
-
* Provides Language Server Protocol functionality for code intelligence to provide
|
|
16
|
-
* IDE-like features such as code completion, symbol search, and more.
|
|
17
|
-
*
|
|
18
|
-
* @property {LspLanguageId} languageId - The language server type (e.g., "typescript")
|
|
19
|
-
* @property {string} pathToProject - Path to the project root directory. Relative paths are resolved based on the sandbox working directory.
|
|
20
|
-
* @property {LspApi} apiClient - API client for Sandbox lsp operations
|
|
21
|
-
* @property {SandboxInstance} instance - The Sandbox instance this server belongs to
|
|
22
|
-
*
|
|
23
|
-
* @class
|
|
24
|
-
*/
|
|
25
|
-
export class LspServer {
|
|
26
|
-
languageId;
|
|
27
|
-
pathToProject;
|
|
28
|
-
apiClient;
|
|
29
|
-
constructor(languageId, pathToProject, apiClient) {
|
|
30
|
-
this.languageId = languageId;
|
|
31
|
-
this.pathToProject = pathToProject;
|
|
32
|
-
this.apiClient = apiClient;
|
|
33
|
-
if (!Object.values(LspLanguageId).includes(this.languageId)) {
|
|
34
|
-
throw new Error(`Invalid languageId: ${this.languageId}. Supported values are: ${Object.values(LspLanguageId).join(', ')}`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Starts the language server, must be called before using any other LSP functionality.
|
|
39
|
-
* It initializes the language server for the specified language and project.
|
|
40
|
-
*
|
|
41
|
-
* @returns {Promise<void>}
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* const lsp = await sandbox.createLspServer('typescript', 'workspace/project');
|
|
45
|
-
* await lsp.start(); // Initialize the server
|
|
46
|
-
* // Now ready for LSP operations
|
|
47
|
-
*/
|
|
48
|
-
async start() {
|
|
49
|
-
await this.apiClient.start({
|
|
50
|
-
languageId: this.languageId,
|
|
51
|
-
pathToProject: this.pathToProject,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Stops the language server, should be called when the LSP server is no longer needed to
|
|
56
|
-
* free up system resources.
|
|
57
|
-
*
|
|
58
|
-
* @returns {Promise<void>}
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* // When done with LSP features
|
|
62
|
-
* await lsp.stop(); // Clean up resources
|
|
63
|
-
*/
|
|
64
|
-
async stop() {
|
|
65
|
-
await this.apiClient.stop({
|
|
66
|
-
languageId: this.languageId,
|
|
67
|
-
pathToProject: this.pathToProject,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Notifies the language server that a file has been opened, enabling
|
|
72
|
-
* language features like diagnostics and completions for that file. The server
|
|
73
|
-
* will begin tracking the file's contents and providing language features.
|
|
74
|
-
*
|
|
75
|
-
* @param {string} path - Path to the opened file. Relative paths are resolved based on the sandbox working directory.
|
|
76
|
-
* @returns {Promise<void>}
|
|
77
|
-
*
|
|
78
|
-
* @example
|
|
79
|
-
* // When opening a file for editing
|
|
80
|
-
* await lsp.didOpen('workspace/project/src/index.ts');
|
|
81
|
-
* // Now can get completions, symbols, etc. for this file
|
|
82
|
-
*/
|
|
83
|
-
async didOpen(path) {
|
|
84
|
-
await this.apiClient.didOpen({
|
|
85
|
-
languageId: this.languageId,
|
|
86
|
-
pathToProject: this.pathToProject,
|
|
87
|
-
uri: 'file://' + path,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Notifies the language server that a file has been closed, should be called when a file is closed
|
|
92
|
-
* in the editor to allow the language server to clean up any resources associated with that file.
|
|
93
|
-
*
|
|
94
|
-
* @param {string} path - Path to the closed file. Relative paths are resolved based on the project path
|
|
95
|
-
* set in the LSP server constructor.
|
|
96
|
-
* @returns {Promise<void>}
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* // When done editing a file
|
|
100
|
-
* await lsp.didClose('workspace/project/src/index.ts');
|
|
101
|
-
*/
|
|
102
|
-
async didClose(path) {
|
|
103
|
-
await this.apiClient.didClose({
|
|
104
|
-
languageId: this.languageId,
|
|
105
|
-
pathToProject: this.pathToProject,
|
|
106
|
-
uri: 'file://' + path,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Get symbol information (functions, classes, variables, etc.) from a document.
|
|
111
|
-
*
|
|
112
|
-
* @param {string} path - Path to the file to get symbols from. Relative paths are resolved based on the project path
|
|
113
|
-
* set in the LSP server constructor.
|
|
114
|
-
* @returns {Promise<LspSymbol[]>} List of symbols in the document. Each symbol includes:
|
|
115
|
-
* - name: The symbol's name
|
|
116
|
-
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
117
|
-
* - location: The location of the symbol in the file
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
* // Get all symbols in a file
|
|
121
|
-
* const symbols = await lsp.documentSymbols('workspace/project/src/index.ts');
|
|
122
|
-
* symbols.forEach(symbol => {
|
|
123
|
-
* console.log(`${symbol.kind} ${symbol.name}: ${symbol.location}`);
|
|
124
|
-
* });
|
|
125
|
-
*/
|
|
126
|
-
async documentSymbols(path) {
|
|
127
|
-
const response = await this.apiClient.documentSymbols(this.languageId, this.pathToProject, 'file://' + path);
|
|
128
|
-
return response.data;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Searches for symbols matching the query string across the entire Sandbox.
|
|
132
|
-
*
|
|
133
|
-
* @param {string} query - Search query to match against symbol names
|
|
134
|
-
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
|
135
|
-
* - name: The symbol's name
|
|
136
|
-
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
137
|
-
* - location: The location of the symbol in the file
|
|
138
|
-
*
|
|
139
|
-
* @deprecated Use `sandboxSymbols` instead. This method will be removed in a future version.
|
|
140
|
-
*/
|
|
141
|
-
async workspaceSymbols(query) {
|
|
142
|
-
return await this.sandboxSymbols(query);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Searches for symbols matching the query string across the entire Sandbox.
|
|
146
|
-
*
|
|
147
|
-
* @param {string} query - Search query to match against symbol names
|
|
148
|
-
* @returns {Promise<LspSymbol[]>} List of matching symbols from all files. Each symbol includes:
|
|
149
|
-
* - name: The symbol's name
|
|
150
|
-
* - kind: The symbol's kind (function, class, variable, etc.)
|
|
151
|
-
* - location: The location of the symbol in the file
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* // Search for all symbols containing "User"
|
|
155
|
-
* const symbols = await lsp.sandboxSymbols('User');
|
|
156
|
-
* symbols.forEach(symbol => {
|
|
157
|
-
* console.log(`${symbol.name} (${symbol.kind}) in ${symbol.location}`);
|
|
158
|
-
* });
|
|
159
|
-
*/
|
|
160
|
-
async sandboxSymbols(query) {
|
|
161
|
-
const response = await this.apiClient.workspaceSymbols(query, this.languageId, this.pathToProject);
|
|
162
|
-
return response.data;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Gets completion suggestions at a position in a file.
|
|
166
|
-
*
|
|
167
|
-
* @param {string} path - Path to the file. Relative paths are resolved based on the project path
|
|
168
|
-
* set in the LSP server constructor.
|
|
169
|
-
* @param {Position} position - The position in the file where completion was requested
|
|
170
|
-
* @returns {Promise<CompletionList>} List of completion suggestions. The list includes:
|
|
171
|
-
* - isIncomplete: Whether more items might be available
|
|
172
|
-
* - items: List of completion items, each containing:
|
|
173
|
-
* - label: The text to insert
|
|
174
|
-
* - kind: The kind of completion
|
|
175
|
-
* - detail: Additional details about the item
|
|
176
|
-
* - documentation: Documentation for the item
|
|
177
|
-
* - sortText: Text used to sort the item in the list
|
|
178
|
-
* - filterText: Text used to filter the item
|
|
179
|
-
* - insertText: The actual text to insert (if different from label)
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* // Get completions at a specific position
|
|
183
|
-
* const completions = await lsp.completions('workspace/project/src/index.ts', {
|
|
184
|
-
* line: 10,
|
|
185
|
-
* character: 15
|
|
186
|
-
* });
|
|
187
|
-
* completions.items.forEach(item => {
|
|
188
|
-
* console.log(`${item.label} (${item.kind}): ${item.detail}`);
|
|
189
|
-
* });
|
|
190
|
-
*/
|
|
191
|
-
async completions(path, position) {
|
|
192
|
-
const response = await this.apiClient.completions({
|
|
193
|
-
languageId: this.languageId,
|
|
194
|
-
pathToProject: this.pathToProject,
|
|
195
|
-
uri: 'file://' + path,
|
|
196
|
-
position: {
|
|
197
|
-
line: position.line,
|
|
198
|
-
character: position.character,
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
return response.data;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
//# sourceMappingURL=LspServer.js.map
|
package/esm/LspServer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LspServer.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/LspServer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,0CAAyB,CAAA;IACzB,0CAAyB,CAAA;AAC3B,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAuBD;;;;;;;;;;GAUG;AACH,MAAM,OAAO,SAAS;IAED;IACA;IACA;IAHnB,YACmB,UAAyB,EACzB,aAAqB,EACrB,SAAiB;QAFjB,eAAU,GAAV,UAAU,CAAe;QACzB,kBAAa,GAAb,aAAa,CAAQ;QACrB,cA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,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,QAAQ,CAAU;gBAEd,MAAM,EAAE,mBAAmB;IAcvC;;;;;;;OAOG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0B5F;;;;;;OAMG;YACW,qBAAqB;IAmBnC;;;;;;;OAOG;YACW,aAAa;IA2B3B;;;;;;OAMG;YACW,QAAQ;IAWtB;;;;;OAKG;YACW,gBAAgB;IAY9B;;;;;;OAMG;YACW,WAAW;IA2CzB,OAAO,CAAC,gBAAgB;CAIzB"}
|
package/esm/ObjectStorage.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2025 Daytona Platforms Inc.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
import { ListObjectsV2Command, S3Client } from '@aws-sdk/client-s3';
|
|
6
|
-
import { Upload } from '@aws-sdk/lib-storage';
|
|
7
|
-
import * as crypto from 'crypto';
|
|
8
|
-
import * as pathe from 'pathe';
|
|
9
|
-
import { DaytonaError } from './errors/DaytonaError.js';
|
|
10
|
-
import { dynamicImport } from './utils/Import.js';
|
|
11
|
-
/**
|
|
12
|
-
* ObjectStorage class for interacting with object storage services.
|
|
13
|
-
*
|
|
14
|
-
* @class
|
|
15
|
-
* @param {ObjectStorageConfig} config - The configuration for the object storage service.
|
|
16
|
-
*/
|
|
17
|
-
export class ObjectStorage {
|
|
18
|
-
bucketName;
|
|
19
|
-
s3Client;
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.bucketName = config.bucketName || 'daytona-volume-builds';
|
|
22
|
-
this.s3Client = new S3Client({
|
|
23
|
-
region: this.extractAwsRegion(config.endpointUrl) || 'us-east-1',
|
|
24
|
-
endpoint: config.endpointUrl,
|
|
25
|
-
credentials: {
|
|
26
|
-
accessKeyId: config.accessKeyId,
|
|
27
|
-
secretAccessKey: config.secretAccessKey,
|
|
28
|
-
sessionToken: config.sessionToken,
|
|
29
|
-
},
|
|
30
|
-
forcePathStyle: true,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Upload a file or directory to object storage.
|
|
35
|
-
*
|
|
36
|
-
* @param {string} path - The path to the file or directory to upload.
|
|
37
|
-
* @param {string} organizationId - The organization ID to use for the upload.
|
|
38
|
-
* @param {string} archiveBasePath - The base path to use for the archive.
|
|
39
|
-
* @returns {Promise<string>} The hash of the uploaded file or directory.
|
|
40
|
-
*/
|
|
41
|
-
async upload(path, organizationId, archiveBasePath) {
|
|
42
|
-
const fs = await dynamicImport('fs', '"upload" is not supported: ');
|
|
43
|
-
if (!fs.existsSync(path)) {
|
|
44
|
-
const errMsg = `Path does not exist: ${path}`;
|
|
45
|
-
throw new DaytonaError(errMsg);
|
|
46
|
-
}
|
|
47
|
-
// Compute hash for the path
|
|
48
|
-
const pathHash = await this.computeHashForPathMd5(path, archiveBasePath);
|
|
49
|
-
// Define the S3 prefix
|
|
50
|
-
const prefix = `${organizationId}/${pathHash}/`;
|
|
51
|
-
const s3Key = `${prefix}context.tar`;
|
|
52
|
-
// Check if it already exists in S3
|
|
53
|
-
if (await this.folderExistsInS3(prefix)) {
|
|
54
|
-
return pathHash;
|
|
55
|
-
}
|
|
56
|
-
// Upload to S3
|
|
57
|
-
await this.uploadAsTar(s3Key, path, archiveBasePath);
|
|
58
|
-
return pathHash;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Compute a hash for a file or directory.
|
|
62
|
-
*
|
|
63
|
-
* @param {string} pathStr - The path to the file or directory to hash.
|
|
64
|
-
* @param {string} archiveBasePath - The base path to use for the archive.
|
|
65
|
-
* @returns {Promise<string>} The hash of the file or directory.
|
|
66
|
-
*/
|
|
67
|
-
async computeHashForPathMd5(pathStr, archiveBasePath) {
|
|
68
|
-
const fs = await dynamicImport('fs', '"computeHashForPathMd5" is not supported: ');
|
|
69
|
-
const md5Hasher = crypto.createHash('md5');
|
|
70
|
-
const absPathStr = pathe.resolve(pathStr);
|
|
71
|
-
md5Hasher.update(archiveBasePath);
|
|
72
|
-
if (fs.statSync(absPathStr).isFile()) {
|
|
73
|
-
// For files, hash the content
|
|
74
|
-
await this.hashFile(absPathStr, md5Hasher);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
// For directories, recursively hash all files and their paths
|
|
78
|
-
await this.hashDirectory(absPathStr, pathStr, md5Hasher);
|
|
79
|
-
}
|
|
80
|
-
return md5Hasher.digest('hex');
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Recursively hash a directory and its contents.
|
|
84
|
-
*
|
|
85
|
-
* @param {string} dirPath - The path to the directory to hash.
|
|
86
|
-
* @param {string} basePath - The base path to use for the hash.
|
|
87
|
-
* @param {crypto.Hash} hasher - The hasher to use for the hash.
|
|
88
|
-
* @returns {Promise<void>} A promise that resolves when the directory has been hashed.
|
|
89
|
-
*/
|
|
90
|
-
async hashDirectory(dirPath, basePath, hasher) {
|
|
91
|
-
const fs = await dynamicImport('fs', '"hashDirectory" is not supported: ');
|
|
92
|
-
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
93
|
-
const hasSubdirs = entries.some((e) => e.isDirectory());
|
|
94
|
-
const hasFiles = entries.some((e) => e.isFile());
|
|
95
|
-
if (!hasSubdirs && !hasFiles) {
|
|
96
|
-
// Empty directory
|
|
97
|
-
const relDir = pathe.relative(basePath, dirPath);
|
|
98
|
-
hasher.update(relDir);
|
|
99
|
-
}
|
|
100
|
-
for (const entry of entries) {
|
|
101
|
-
const fullPath = pathe.join(dirPath, entry.name);
|
|
102
|
-
if (entry.isDirectory()) {
|
|
103
|
-
await this.hashDirectory(fullPath, basePath, hasher);
|
|
104
|
-
}
|
|
105
|
-
else if (entry.isFile()) {
|
|
106
|
-
const relPath = pathe.relative(basePath, fullPath);
|
|
107
|
-
hasher.update(relPath);
|
|
108
|
-
await this.hashFile(fullPath, hasher);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Hash a file.
|
|
114
|
-
*
|
|
115
|
-
* @param {string} filePath - The path to the file to hash.
|
|
116
|
-
* @param {crypto.Hash} hasher - The hasher to use for the hash.
|
|
117
|
-
* @returns {Promise<void>} A promise that resolves when the file has been hashed.
|
|
118
|
-
*/
|
|
119
|
-
async hashFile(filePath, hasher) {
|
|
120
|
-
const fs = await dynamicImport('fs', '"hashFile" is not supported: ');
|
|
121
|
-
await new Promise((resolve, reject) => {
|
|
122
|
-
const stream = fs.createReadStream(filePath, { highWaterMark: 8192 });
|
|
123
|
-
stream.on('data', (chunk) => hasher.update(chunk));
|
|
124
|
-
stream.on('end', resolve);
|
|
125
|
-
stream.on('error', reject);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Check if a prefix (folder) exists in S3.
|
|
130
|
-
*
|
|
131
|
-
* @param {string} prefix - The prefix to check.
|
|
132
|
-
* @returns {Promise<boolean>} True if the prefix exists, false otherwise.
|
|
133
|
-
*/
|
|
134
|
-
async folderExistsInS3(prefix) {
|
|
135
|
-
const response = await this.s3Client.send(new ListObjectsV2Command({
|
|
136
|
-
Bucket: this.bucketName,
|
|
137
|
-
Prefix: prefix,
|
|
138
|
-
MaxKeys: 1,
|
|
139
|
-
}));
|
|
140
|
-
return !!response.Contents && response.Contents.length > 0;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Create a tar archive of the specified path and upload it to S3.
|
|
144
|
-
*
|
|
145
|
-
* @param {string} s3Key - The key to use for the uploaded file.
|
|
146
|
-
* @param {string} sourcePath - The path to the file or directory to upload.
|
|
147
|
-
* @param {string} archiveBasePath - The base path to use for the archive.
|
|
148
|
-
*/
|
|
149
|
-
async uploadAsTar(s3Key, sourcePath, archiveBasePath) {
|
|
150
|
-
const importErrorPrefix = '"uploadAsTar" is not supported: ';
|
|
151
|
-
const tar = await dynamicImport('tar', importErrorPrefix);
|
|
152
|
-
const stream = await dynamicImport('stream', importErrorPrefix);
|
|
153
|
-
sourcePath = pathe.resolve(sourcePath);
|
|
154
|
-
const normalizedSourcePath = pathe.normalize(sourcePath);
|
|
155
|
-
const normalizedArchiveBasePath = pathe.normalize(archiveBasePath);
|
|
156
|
-
let basePrefix;
|
|
157
|
-
if (normalizedArchiveBasePath === '.') {
|
|
158
|
-
// When archiveBasePath is empty (normalized to '.'), use the normalizedSourcePath as cwd and the '.' as target
|
|
159
|
-
basePrefix = normalizedSourcePath;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
// Normal case: extract the base prefix by removing archiveBasePath from the end
|
|
163
|
-
basePrefix = normalizedSourcePath.slice(0, normalizedSourcePath.length - normalizedArchiveBasePath.length);
|
|
164
|
-
}
|
|
165
|
-
const tarStream = tar.create({
|
|
166
|
-
cwd: basePrefix,
|
|
167
|
-
portable: true,
|
|
168
|
-
gzip: false,
|
|
169
|
-
}, [normalizedArchiveBasePath]);
|
|
170
|
-
const pass = new stream.PassThrough();
|
|
171
|
-
tarStream.pipe(pass);
|
|
172
|
-
const uploader = new Upload({
|
|
173
|
-
client: this.s3Client,
|
|
174
|
-
params: {
|
|
175
|
-
Bucket: this.bucketName,
|
|
176
|
-
Key: s3Key,
|
|
177
|
-
Body: pass,
|
|
178
|
-
},
|
|
179
|
-
});
|
|
180
|
-
await uploader.done();
|
|
181
|
-
}
|
|
182
|
-
extractAwsRegion(endpoint) {
|
|
183
|
-
const match = endpoint.match(/s3[.-]([a-z0-9-]+)\.amazonaws\.com/);
|
|
184
|
-
return match?.[1];
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
//# sourceMappingURL=ObjectStorage.js.map
|
package/esm/ObjectStorage.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectStorage.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/ObjectStorage.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAoB9C;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAChB,UAAU,CAAQ;IAClB,QAAQ,CAAU;IAE1B,YAAY,MAA2B;QACrC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,IAAI,uBAAuB,CAAA;QAC9D,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC;YAC3B,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,WAAW;YAChE,QAAQ,EAAE,MAAM,CAAC,WAAW;YAC5B,WAAW,EAAE;gBACX,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,eAAe,EAAE,MAAM,CAAC,eAAe;gBACvC,YAAY,EAAE,MAAM,CAAC,YAAY;aAClC;YACD,cAAc,EAAE,IAAI;SACrB,CAAC,CAAA;IACJ,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,cAAsB,EAAE,eAAuB;QACxE,MAAM,EAAE,GAAG,MAAM,aAAa,CAAC,IAAI,EAAE,6BAA6B,CAAC,CAAA;QAEnE,IA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