@daytonaio/sdk 0.9.2 → 0.10.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.
Files changed (221) hide show
  1. package/dist/Daytona.d.ts +239 -47
  2. package/dist/Daytona.js +274 -63
  3. package/dist/FileSystem.d.ts +183 -32
  4. package/dist/FileSystem.js +168 -28
  5. package/dist/Git.d.ts +178 -30
  6. package/dist/Git.js +178 -30
  7. package/dist/LspServer.d.ts +170 -22
  8. package/dist/LspServer.js +162 -18
  9. package/dist/Process.d.ts +187 -37
  10. package/dist/Process.js +185 -44
  11. package/dist/Workspace.d.ts +252 -36
  12. package/dist/Workspace.js +239 -49
  13. package/dist/code-toolbox/WorkspacePythonCodeToolbox.d.ts +2 -1
  14. package/dist/code-toolbox/WorkspacePythonCodeToolbox.js +4 -2
  15. package/dist/code-toolbox/WorkspaceTsCodeToolbox.d.ts +2 -1
  16. package/dist/code-toolbox/WorkspaceTsCodeToolbox.js +4 -2
  17. package/dist/errors/DaytonaError.d.ts +8 -0
  18. package/dist/errors/DaytonaError.js +12 -0
  19. package/dist/index.d.ts +4 -0
  20. package/dist/index.js +12 -1
  21. package/dist/utils/Axios.d.ts +6 -0
  22. package/dist/utils/Axios.js +28 -0
  23. package/dist/utils/errors.d.ts +10 -0
  24. package/dist/utils/errors.js +36 -0
  25. package/dist/utils/timeout.d.ts +35 -0
  26. package/dist/utils/timeout.js +73 -0
  27. package/package.json +9 -8
  28. package/dist/client/apis/ApiKeyApi.d.ts +0 -54
  29. package/dist/client/apis/ApiKeyApi.js +0 -135
  30. package/dist/client/apis/BuildApi.d.ts +0 -95
  31. package/dist/client/apis/BuildApi.js +0 -228
  32. package/dist/client/apis/ContainerRegistryApi.d.ts +0 -68
  33. package/dist/client/apis/ContainerRegistryApi.js +0 -163
  34. package/dist/client/apis/DefaultApi.d.ts +0 -31
  35. package/dist/client/apis/DefaultApi.js +0 -72
  36. package/dist/client/apis/GitProviderApi.d.ts +0 -197
  37. package/dist/client/apis/GitProviderApi.js +0 -477
  38. package/dist/client/apis/PrebuildApi.d.ts +0 -97
  39. package/dist/client/apis/PrebuildApi.js +0 -241
  40. package/dist/client/apis/ProfileApi.d.ts +0 -51
  41. package/dist/client/apis/ProfileApi.js +0 -128
  42. package/dist/client/apis/ProjectConfigApi.d.ts +0 -94
  43. package/dist/client/apis/ProjectConfigApi.js +0 -220
  44. package/dist/client/apis/ProviderApi.d.ts +0 -71
  45. package/dist/client/apis/ProviderApi.js +0 -160
  46. package/dist/client/apis/SampleApi.d.ts +0 -28
  47. package/dist/client/apis/SampleApi.js +0 -73
  48. package/dist/client/apis/ServerApi.d.ts +0 -61
  49. package/dist/client/apis/ServerApi.js +0 -156
  50. package/dist/client/apis/TargetApi.d.ts +0 -67
  51. package/dist/client/apis/TargetApi.js +0 -159
  52. package/dist/client/apis/WorkspaceApi.d.ts +0 -141
  53. package/dist/client/apis/WorkspaceApi.js +0 -330
  54. package/dist/client/apis/WorkspaceToolboxApi.d.ts +0 -464
  55. package/dist/client/apis/WorkspaceToolboxApi.js +0 -1248
  56. package/dist/client/apis/index.d.ts +0 -14
  57. package/dist/client/apis/index.js +0 -32
  58. package/dist/client/index.d.ts +0 -3
  59. package/dist/client/index.js +0 -21
  60. package/dist/client/models/ApiKey.d.ts +0 -45
  61. package/dist/client/models/ApiKey.js +0 -60
  62. package/dist/client/models/ApikeyApiKeyType.d.ts +0 -26
  63. package/dist/client/models/ApikeyApiKeyType.js +0 -52
  64. package/dist/client/models/Build.d.ts +0 -98
  65. package/dist/client/models/Build.js +0 -91
  66. package/dist/client/models/BuildBuildState.d.ts +0 -31
  67. package/dist/client/models/BuildBuildState.js +0 -57
  68. package/dist/client/models/BuildConfig.d.ts +0 -40
  69. package/dist/client/models/BuildConfig.js +0 -57
  70. package/dist/client/models/CachedBuild.d.ts +0 -38
  71. package/dist/client/models/CachedBuild.js +0 -55
  72. package/dist/client/models/CloneTarget.d.ts +0 -25
  73. package/dist/client/models/CloneTarget.js +0 -51
  74. package/dist/client/models/CompletionContext.d.ts +0 -38
  75. package/dist/client/models/CompletionContext.js +0 -53
  76. package/dist/client/models/CompletionItem.d.ts +0 -68
  77. package/dist/client/models/CompletionItem.js +0 -63
  78. package/dist/client/models/CompletionList.d.ts +0 -39
  79. package/dist/client/models/CompletionList.js +0 -56
  80. package/dist/client/models/ContainerConfig.d.ts +0 -38
  81. package/dist/client/models/ContainerConfig.js +0 -55
  82. package/dist/client/models/ContainerRegistry.d.ts +0 -44
  83. package/dist/client/models/ContainerRegistry.js +0 -59
  84. package/dist/client/models/CreateBuildDTO.d.ts +0 -52
  85. package/dist/client/models/CreateBuildDTO.js +0 -62
  86. package/dist/client/models/CreatePrebuildDTO.d.ts +0 -56
  87. package/dist/client/models/CreatePrebuildDTO.js +0 -59
  88. package/dist/client/models/CreateProjectConfigDTO.d.ts +0 -71
  89. package/dist/client/models/CreateProjectConfigDTO.js +0 -72
  90. package/dist/client/models/CreateProjectDTO.d.ts +0 -72
  91. package/dist/client/models/CreateProjectDTO.js +0 -73
  92. package/dist/client/models/CreateProjectSourceDTO.d.ts +0 -33
  93. package/dist/client/models/CreateProjectSourceDTO.js +0 -52
  94. package/dist/client/models/CreateProviderTargetDTO.d.ts +0 -45
  95. package/dist/client/models/CreateProviderTargetDTO.js +0 -60
  96. package/dist/client/models/CreateWorkspaceDTO.d.ts +0 -51
  97. package/dist/client/models/CreateWorkspaceDTO.js +0 -64
  98. package/dist/client/models/DevcontainerConfig.d.ts +0 -32
  99. package/dist/client/models/DevcontainerConfig.js +0 -51
  100. package/dist/client/models/ExecuteRequest.d.ts +0 -38
  101. package/dist/client/models/ExecuteRequest.js +0 -53
  102. package/dist/client/models/ExecuteResponse.d.ts +0 -38
  103. package/dist/client/models/ExecuteResponse.js +0 -55
  104. package/dist/client/models/FRPSConfig.d.ts +0 -44
  105. package/dist/client/models/FRPSConfig.js +0 -59
  106. package/dist/client/models/FileInfo.d.ts +0 -74
  107. package/dist/client/models/FileInfo.js +0 -79
  108. package/dist/client/models/FileStatus.d.ts +0 -51
  109. package/dist/client/models/FileStatus.js +0 -64
  110. package/dist/client/models/GetRepositoryContext.d.ts +0 -80
  111. package/dist/client/models/GetRepositoryContext.js +0 -67
  112. package/dist/client/models/GitAddRequest.d.ts +0 -38
  113. package/dist/client/models/GitAddRequest.js +0 -55
  114. package/dist/client/models/GitBranch.d.ts +0 -38
  115. package/dist/client/models/GitBranch.js +0 -55
  116. package/dist/client/models/GitBranchRequest.d.ts +0 -38
  117. package/dist/client/models/GitBranchRequest.js +0 -55
  118. package/dist/client/models/GitCloneRequest.d.ts +0 -62
  119. package/dist/client/models/GitCloneRequest.js +0 -63
  120. package/dist/client/models/GitCommitInfo.d.ts +0 -56
  121. package/dist/client/models/GitCommitInfo.js +0 -67
  122. package/dist/client/models/GitCommitRequest.d.ts +0 -50
  123. package/dist/client/models/GitCommitRequest.js +0 -63
  124. package/dist/client/models/GitCommitResponse.d.ts +0 -32
  125. package/dist/client/models/GitCommitResponse.js +0 -51
  126. package/dist/client/models/GitNamespace.d.ts +0 -38
  127. package/dist/client/models/GitNamespace.js +0 -55
  128. package/dist/client/models/GitProvider.d.ts +0 -75
  129. package/dist/client/models/GitProvider.js +0 -76
  130. package/dist/client/models/GitPullRequest.d.ts +0 -68
  131. package/dist/client/models/GitPullRequest.js +0 -75
  132. package/dist/client/models/GitRepoRequest.d.ts +0 -44
  133. package/dist/client/models/GitRepoRequest.js +0 -55
  134. package/dist/client/models/GitRepository.d.ts +0 -87
  135. package/dist/client/models/GitRepository.js +0 -84
  136. package/dist/client/models/GitStatus.d.ts +0 -57
  137. package/dist/client/models/GitStatus.js +0 -62
  138. package/dist/client/models/GitUser.d.ts +0 -50
  139. package/dist/client/models/GitUser.js +0 -63
  140. package/dist/client/models/InstallProviderRequest.d.ts +0 -40
  141. package/dist/client/models/InstallProviderRequest.js +0 -55
  142. package/dist/client/models/ListBranchResponse.d.ts +0 -32
  143. package/dist/client/models/ListBranchResponse.js +0 -51
  144. package/dist/client/models/LogFileConfig.d.ts +0 -62
  145. package/dist/client/models/LogFileConfig.js +0 -67
  146. package/dist/client/models/LspCompletionParams.d.ts +0 -58
  147. package/dist/client/models/LspCompletionParams.js +0 -69
  148. package/dist/client/models/LspDocumentRequest.d.ts +0 -44
  149. package/dist/client/models/LspDocumentRequest.js +0 -59
  150. package/dist/client/models/LspLocation.d.ts +0 -39
  151. package/dist/client/models/LspLocation.js +0 -56
  152. package/dist/client/models/LspPosition.d.ts +0 -38
  153. package/dist/client/models/LspPosition.js +0 -55
  154. package/dist/client/models/LspRange.d.ts +0 -39
  155. package/dist/client/models/LspRange.js +0 -56
  156. package/dist/client/models/LspServerRequest.d.ts +0 -38
  157. package/dist/client/models/LspServerRequest.js +0 -55
  158. package/dist/client/models/LspSymbol.d.ts +0 -45
  159. package/dist/client/models/LspSymbol.js +0 -60
  160. package/dist/client/models/Match.d.ts +0 -44
  161. package/dist/client/models/Match.js +0 -59
  162. package/dist/client/models/NetworkKey.d.ts +0 -32
  163. package/dist/client/models/NetworkKey.js +0 -51
  164. package/dist/client/models/Position.d.ts +0 -38
  165. package/dist/client/models/Position.js +0 -55
  166. package/dist/client/models/PrebuildConfig.d.ts +0 -56
  167. package/dist/client/models/PrebuildConfig.js +0 -67
  168. package/dist/client/models/PrebuildDTO.d.ts +0 -62
  169. package/dist/client/models/PrebuildDTO.js +0 -68
  170. package/dist/client/models/ProfileData.d.ts +0 -34
  171. package/dist/client/models/ProfileData.js +0 -51
  172. package/dist/client/models/Project.d.ts +0 -91
  173. package/dist/client/models/Project.js +0 -88
  174. package/dist/client/models/ProjectConfig.d.ts +0 -84
  175. package/dist/client/models/ProjectConfig.js +0 -87
  176. package/dist/client/models/ProjectDirResponse.d.ts +0 -32
  177. package/dist/client/models/ProjectDirResponse.js +0 -49
  178. package/dist/client/models/ProjectInfo.d.ts +0 -56
  179. package/dist/client/models/ProjectInfo.js +0 -65
  180. package/dist/client/models/ProjectState.d.ts +0 -45
  181. package/dist/client/models/ProjectState.js +0 -60
  182. package/dist/client/models/Provider.d.ts +0 -44
  183. package/dist/client/models/Provider.js +0 -57
  184. package/dist/client/models/ProviderProviderInfo.d.ts +0 -44
  185. package/dist/client/models/ProviderProviderInfo.js +0 -57
  186. package/dist/client/models/ProviderProviderTargetProperty.d.ts +0 -72
  187. package/dist/client/models/ProviderProviderTargetProperty.js +0 -64
  188. package/dist/client/models/ProviderProviderTargetPropertyType.d.ts +0 -29
  189. package/dist/client/models/ProviderProviderTargetPropertyType.js +0 -55
  190. package/dist/client/models/ProviderTarget.d.ts +0 -51
  191. package/dist/client/models/ProviderTarget.js +0 -64
  192. package/dist/client/models/ReplaceRequest.d.ts +0 -44
  193. package/dist/client/models/ReplaceRequest.js +0 -59
  194. package/dist/client/models/ReplaceResult.d.ts +0 -44
  195. package/dist/client/models/ReplaceResult.js +0 -53
  196. package/dist/client/models/RepositoryUrl.d.ts +0 -32
  197. package/dist/client/models/RepositoryUrl.js +0 -51
  198. package/dist/client/models/Sample.d.ts +0 -44
  199. package/dist/client/models/Sample.js +0 -59
  200. package/dist/client/models/SearchFilesResponse.d.ts +0 -32
  201. package/dist/client/models/SearchFilesResponse.js +0 -51
  202. package/dist/client/models/ServerConfig.d.ts +0 -130
  203. package/dist/client/models/ServerConfig.js +0 -119
  204. package/dist/client/models/SetGitProviderConfig.d.ts +0 -75
  205. package/dist/client/models/SetGitProviderConfig.js +0 -70
  206. package/dist/client/models/SetProjectState.d.ts +0 -39
  207. package/dist/client/models/SetProjectState.js +0 -56
  208. package/dist/client/models/SigningMethod.d.ts +0 -25
  209. package/dist/client/models/SigningMethod.js +0 -51
  210. package/dist/client/models/Status.d.ts +0 -31
  211. package/dist/client/models/Status.js +0 -57
  212. package/dist/client/models/Workspace.d.ts +0 -51
  213. package/dist/client/models/Workspace.js +0 -64
  214. package/dist/client/models/WorkspaceDTO.d.ts +0 -58
  215. package/dist/client/models/WorkspaceDTO.js +0 -67
  216. package/dist/client/models/WorkspaceInfo.d.ts +0 -45
  217. package/dist/client/models/WorkspaceInfo.js +0 -58
  218. package/dist/client/models/index.d.ts +0 -79
  219. package/dist/client/models/index.js +0 -97
  220. package/dist/client/runtime.d.ts +0 -182
  221. package/dist/client/runtime.js +0 -340
package/dist/Git.d.ts CHANGED
@@ -1,67 +1,215 @@
1
- import { Workspace as WorkspaceInstance, ToolboxApi, ListBranchResponse, GitStatus } from '@daytonaio/api-client';
2
- import { Workspace } from './Workspace';
3
1
  /**
4
- * Provides Git operations within a workspace
5
- * @class Git
2
+ * The Daytona SDK provides built-in Git support. This guide covers all available Git
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 workspace
12
+ * const workspace = await daytona.create();
13
+ *
14
+ * // Clone a repository
15
+ * await workspace.git.clone(
16
+ * 'https://github.com/user/repo.git',
17
+ * '/workspace/repo'
18
+ * );
19
+ *
20
+ * // Make some changes
21
+ * await workspace.fs.uploadFile(
22
+ * '/workspace/repo/test.txt',
23
+ * new File([Buffer.from('Hello, World!')], 'test.txt')
24
+ * );
25
+ *
26
+ * // Stage and commit changes
27
+ * await workspace.git.add('/workspace/repo', ['test.txt']);
28
+ * await workspace.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 workspace.git.push(
37
+ * '/workspace/repo',
38
+ * 'user',
39
+ * 'token'
40
+ * );
41
+ *
6
42
  */
43
+ import { ToolboxApi, ListBranchResponse, GitStatus } from '@daytonaio/api-client';
44
+ import { Workspace, WorkspaceInstance } from './Workspace';
7
45
  export declare class Git {
8
46
  private readonly workspace;
9
47
  private readonly toolboxApi;
10
48
  private readonly instance;
11
49
  constructor(workspace: Workspace, toolboxApi: ToolboxApi, instance: WorkspaceInstance);
12
50
  /**
13
- * Stages files for commit
14
- * @param {string} path - Repository path
15
- * @param {string[]} files - Array of file paths to stage
51
+ * Stages files for commit.
52
+ *
53
+ * This method stages the specified files for the next commit, similar to
54
+ * running 'git add' on the command line.
55
+ *
56
+ * @param {string} path - Absolute path to the Git repository root
57
+ * @param {string[]} files - List of file paths or directories to stage, relative to the repository root
16
58
  * @returns {Promise<void>}
59
+ *
60
+ * @example
61
+ * // Stage a single file
62
+ * await git.add('/workspace/repo', ['file.txt']);
63
+ *
64
+ * @example
65
+ * // Stage whole repository
66
+ * await git.add('/workspace/repo', ['.']);
17
67
  */
18
68
  add(path: string, files: string[]): Promise<void>;
19
69
  /**
20
- * Lists branches in the repository
21
- * @param {string} path - Repository path
22
- * @returns {Promise<ListBranchResponse>} List of branches
70
+ * List branches in the repository.
71
+ *
72
+ * This method returns information about all branches in the repository.
73
+ *
74
+ * @param {string} path - Absolute path to the Git repository root
75
+ * @returns {Promise<ListBranchResponse>} List of branches in the repository
76
+ *
77
+ * @example
78
+ * const response = await git.branches('/workspace/repo');
79
+ * console.log(`Branches: ${response.branches}`);
23
80
  */
24
81
  branches(path: string): Promise<ListBranchResponse>;
25
82
  /**
26
- * Clones a Git repository
27
- * @param {string} url - Repository URL
28
- * @param {string} path - Destination path
29
- * @param {string} [branch] - Branch to clone
30
- * @param {string} [commitId] - Specific commit to clone
83
+ * Clones a Git repository.
84
+ *
85
+ * This method clones a Git repository into the specified path. It supports
86
+ * cloning specific branches or commits, and can authenticate with the remote
87
+ * repository if credentials are provided.
88
+ *
89
+ * @param {string} url - Repository URL to clone from
90
+ * @param {string} path - Absolute path where the repository should be cloned
91
+ * @param {string} [branch] - Specific branch to clone. If not specified, clones the default branch
92
+ * @param {string} [commitId] - Specific commit to clone. If specified, the repository will be left in a detached HEAD state at this commit
31
93
  * @param {string} [username] - Git username for authentication
32
- * @param {string} [password] - Git password/token for authentication
94
+ * @param {string} [password] - Git password or token for authentication
33
95
  * @returns {Promise<void>}
96
+ *
97
+ * @example
98
+ * // Clone the default branch
99
+ * await git.clone(
100
+ * 'https://github.com/user/repo.git',
101
+ * '/workspace/repo'
102
+ * );
103
+ *
104
+ * @example
105
+ * // Clone a specific branch with authentication
106
+ * await git.clone(
107
+ * 'https://github.com/user/private-repo.git',
108
+ * '/workspace/private',
109
+ * branch='develop',
110
+ * username='user',
111
+ * password='token'
112
+ * );
113
+ *
114
+ * @example
115
+ * // Clone a specific commit
116
+ * await git.clone(
117
+ * 'https://github.com/user/repo.git',
118
+ * '/workspace/repo-old',
119
+ * commitId='abc123'
120
+ * );
34
121
  */
35
122
  clone(url: string, path: string, branch?: string, commitId?: string, username?: string, password?: string): Promise<void>;
36
123
  /**
37
- * Creates a new commit with staged changes
38
- * @param {string} path - Repository path
39
- * @param {string} message - Commit message
40
- * @param {string} author - Author name
41
- * @param {string} email - Author email
124
+ * Commits staged changes.
125
+ *
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
+ * @param {string} path - Absolute path to the Git repository root
130
+ * @param {string} message - Commit message describing the changes
131
+ * @param {string} author - Name of the commit author
132
+ * @param {string} email - Email address of the commit author
42
133
  * @returns {Promise<void>}
134
+ *
135
+ * @example
136
+ * // Stage and commit changes
137
+ * await git.add('/workspace/repo', ['README.md']);
138
+ * await git.commit(
139
+ * '/workspace/repo',
140
+ * 'Update documentation',
141
+ * 'John Doe',
142
+ * 'john@example.com'
143
+ * );
43
144
  */
44
145
  commit(path: string, message: string, author: string, email: string): Promise<void>;
45
146
  /**
46
- * Pushes local commits to remote repository
47
- * @param {string} path - Repository path
147
+ * Push local changes to the remote repository.
148
+ *
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
+ * @param {string} path - Absolute path to the Git repository root
48
153
  * @param {string} [username] - Git username for authentication
49
- * @param {string} [password] - Git password/token for authentication
154
+ * @param {string} [password] - Git password or token for authentication
50
155
  * @returns {Promise<void>}
156
+ *
157
+ * @example
158
+ * // Push to a public repository
159
+ * await git.push('/workspace/repo');
160
+ *
161
+ * @example
162
+ * // Push to a private repository
163
+ * await git.push(
164
+ * '/workspace/repo',
165
+ * 'user',
166
+ * 'token'
167
+ * );
51
168
  */
52
169
  push(path: string, username?: string, password?: string): Promise<void>;
53
170
  /**
54
- * Pulls changes from remote repository
55
- * @param {string} path - Repository path
171
+ * Pulls changes from the remote repository.
172
+ *
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
+ * @param {string} path - Absolute path to the Git repository root
56
177
  * @param {string} [username] - Git username for authentication
57
- * @param {string} [password] - Git password/token for authentication
178
+ * @param {string} [password] - Git password or token for authentication
58
179
  * @returns {Promise<void>}
180
+ *
181
+ * @example
182
+ * // Pull from a public repository
183
+ * await git.pull('/workspace/repo');
184
+ *
185
+ * @example
186
+ * // Pull from a private repository
187
+ * await git.pull(
188
+ * '/workspace/repo',
189
+ * 'user',
190
+ * 'token'
191
+ * );
59
192
  */
60
193
  pull(path: string, username?: string, password?: string): Promise<void>;
61
194
  /**
62
- * Gets the current Git repository status
63
- * @param {string} path - Repository path
64
- * @returns {Promise<GitStatus>} Repository status information
195
+ * Gets the current status of the Git repository.
196
+ *
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
+ * @param {string} path - Absolute path to the Git repository root
201
+ * @returns {Promise<GitStatus>} Current repository status including:
202
+ * - currentBranch: Name of the current branch
203
+ * - ahead: Number of commits ahead of the remote branch
204
+ * - behind: Number of commits behind the remote branch
205
+ * - branchPublished: Whether the branch has been published to the remote repository
206
+ * - fileStatus: List of file statuses
207
+ *
208
+ * @example
209
+ * const status = await workspace.git.status('/workspace/repo');
210
+ * console.log(`Current branch: ${status.currentBranch}`);
211
+ * console.log(`Commits ahead: ${status.ahead}`);
212
+ * console.log(`Commits behind: ${status.behind}`);
65
213
  */
66
214
  status(path: string): Promise<GitStatus>;
67
215
  }
package/dist/Git.js CHANGED
@@ -1,10 +1,48 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Git = void 0;
4
2
  /**
5
- * Provides Git operations within a workspace
6
- * @class Git
3
+ * The Daytona SDK provides built-in Git support. This guide covers all available Git
4
+ * operations and best practices. Daytona SDK provides an option to clone, check status,
5
+ * and manage Git repositories in Sandboxes. You can interact with Git repositories using
6
+ * the `git` module.
7
+ *
8
+ * @module Git
9
+ *
10
+ * @example
11
+ * // Basic Git workflow
12
+ * // Create and initialize workspace
13
+ * const workspace = await daytona.create();
14
+ *
15
+ * // Clone a repository
16
+ * await workspace.git.clone(
17
+ * 'https://github.com/user/repo.git',
18
+ * '/workspace/repo'
19
+ * );
20
+ *
21
+ * // Make some changes
22
+ * await workspace.fs.uploadFile(
23
+ * '/workspace/repo/test.txt',
24
+ * new File([Buffer.from('Hello, World!')], 'test.txt')
25
+ * );
26
+ *
27
+ * // Stage and commit changes
28
+ * await workspace.git.add('/workspace/repo', ['test.txt']);
29
+ * await workspace.git.commit(
30
+ * '/workspace/repo',
31
+ * 'Add test file',
32
+ * 'John Doe',
33
+ * 'john@example.com'
34
+ * );
35
+ *
36
+ * // Push changes (with authentication)
37
+ * await workspace.git.push(
38
+ * '/workspace/repo',
39
+ * 'user',
40
+ * 'token'
41
+ * );
42
+ *
7
43
  */
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.Git = void 0;
8
46
  class Git {
9
47
  constructor(workspace, toolboxApi, instance) {
10
48
  this.workspace = workspace;
@@ -12,10 +50,22 @@ class Git {
12
50
  this.instance = instance;
13
51
  }
14
52
  /**
15
- * Stages files for commit
16
- * @param {string} path - Repository path
17
- * @param {string[]} files - Array of file paths to stage
53
+ * Stages files for commit.
54
+ *
55
+ * This method stages the specified files for the next commit, similar to
56
+ * running 'git add' on the command line.
57
+ *
58
+ * @param {string} path - Absolute path to the Git repository root
59
+ * @param {string[]} files - List of file paths or directories to stage, relative to the repository root
18
60
  * @returns {Promise<void>}
61
+ *
62
+ * @example
63
+ * // Stage a single file
64
+ * await git.add('/workspace/repo', ['file.txt']);
65
+ *
66
+ * @example
67
+ * // Stage whole repository
68
+ * await git.add('/workspace/repo', ['.']);
19
69
  */
20
70
  async add(path, files) {
21
71
  await this.toolboxApi.gitAddFiles(this.instance.id, {
@@ -24,23 +74,60 @@ class Git {
24
74
  });
25
75
  }
26
76
  /**
27
- * Lists branches in the repository
28
- * @param {string} path - Repository path
29
- * @returns {Promise<ListBranchResponse>} List of branches
77
+ * List branches in the repository.
78
+ *
79
+ * This method returns information about all branches in the repository.
80
+ *
81
+ * @param {string} path - Absolute path to the Git repository root
82
+ * @returns {Promise<ListBranchResponse>} List of branches in the repository
83
+ *
84
+ * @example
85
+ * const response = await git.branches('/workspace/repo');
86
+ * console.log(`Branches: ${response.branches}`);
30
87
  */
31
88
  async branches(path) {
32
89
  const response = await this.toolboxApi.gitListBranches(this.instance.id, path);
33
90
  return response.data;
34
91
  }
35
92
  /**
36
- * Clones a Git repository
37
- * @param {string} url - Repository URL
38
- * @param {string} path - Destination path
39
- * @param {string} [branch] - Branch to clone
40
- * @param {string} [commitId] - Specific commit to clone
93
+ * Clones a Git repository.
94
+ *
95
+ * This method clones a Git repository into the specified path. It supports
96
+ * cloning specific branches or commits, and can authenticate with the remote
97
+ * repository if credentials are provided.
98
+ *
99
+ * @param {string} url - Repository URL to clone from
100
+ * @param {string} path - Absolute path where the repository should be cloned
101
+ * @param {string} [branch] - Specific branch to clone. If not specified, clones the default branch
102
+ * @param {string} [commitId] - Specific commit to clone. If specified, the repository will be left in a detached HEAD state at this commit
41
103
  * @param {string} [username] - Git username for authentication
42
- * @param {string} [password] - Git password/token for authentication
104
+ * @param {string} [password] - Git password or token for authentication
43
105
  * @returns {Promise<void>}
106
+ *
107
+ * @example
108
+ * // Clone the default branch
109
+ * await git.clone(
110
+ * 'https://github.com/user/repo.git',
111
+ * '/workspace/repo'
112
+ * );
113
+ *
114
+ * @example
115
+ * // Clone a specific branch with authentication
116
+ * await git.clone(
117
+ * 'https://github.com/user/private-repo.git',
118
+ * '/workspace/private',
119
+ * branch='develop',
120
+ * username='user',
121
+ * password='token'
122
+ * );
123
+ *
124
+ * @example
125
+ * // Clone a specific commit
126
+ * await git.clone(
127
+ * 'https://github.com/user/repo.git',
128
+ * '/workspace/repo-old',
129
+ * commitId='abc123'
130
+ * );
44
131
  */
45
132
  async clone(url, path, branch, commitId, username, password) {
46
133
  await this.toolboxApi.gitCloneRepository(this.instance.id, {
@@ -53,12 +140,26 @@ class Git {
53
140
  });
54
141
  }
55
142
  /**
56
- * Creates a new commit with staged changes
57
- * @param {string} path - Repository path
58
- * @param {string} message - Commit message
59
- * @param {string} author - Author name
60
- * @param {string} email - Author email
143
+ * Commits staged changes.
144
+ *
145
+ * This method creates a new commit with the staged changes. Make sure to stage
146
+ * changes using the add() method before committing.
147
+ *
148
+ * @param {string} path - Absolute path to the Git repository root
149
+ * @param {string} message - Commit message describing the changes
150
+ * @param {string} author - Name of the commit author
151
+ * @param {string} email - Email address of the commit author
61
152
  * @returns {Promise<void>}
153
+ *
154
+ * @example
155
+ * // Stage and commit changes
156
+ * await git.add('/workspace/repo', ['README.md']);
157
+ * await git.commit(
158
+ * '/workspace/repo',
159
+ * 'Update documentation',
160
+ * 'John Doe',
161
+ * 'john@example.com'
162
+ * );
62
163
  */
63
164
  async commit(path, message, author, email) {
64
165
  await this.toolboxApi.gitCommitChanges(this.instance.id, {
@@ -69,11 +170,27 @@ class Git {
69
170
  });
70
171
  }
71
172
  /**
72
- * Pushes local commits to remote repository
73
- * @param {string} path - Repository path
173
+ * Push local changes to the remote repository.
174
+ *
175
+ * This method pushes committed changes to the remote repository. If the remote
176
+ * requires authentication, username and password/token must be provided.
177
+ *
178
+ * @param {string} path - Absolute path to the Git repository root
74
179
  * @param {string} [username] - Git username for authentication
75
- * @param {string} [password] - Git password/token for authentication
180
+ * @param {string} [password] - Git password or token for authentication
76
181
  * @returns {Promise<void>}
182
+ *
183
+ * @example
184
+ * // Push to a public repository
185
+ * await git.push('/workspace/repo');
186
+ *
187
+ * @example
188
+ * // Push to a private repository
189
+ * await git.push(
190
+ * '/workspace/repo',
191
+ * 'user',
192
+ * 'token'
193
+ * );
77
194
  */
78
195
  async push(path, username, password) {
79
196
  await this.toolboxApi.gitPushChanges(this.instance.id, {
@@ -83,11 +200,27 @@ class Git {
83
200
  });
84
201
  }
85
202
  /**
86
- * Pulls changes from remote repository
87
- * @param {string} path - Repository path
203
+ * Pulls changes from the remote repository.
204
+ *
205
+ * This method fetches and merges changes from the remote repository. If the remote
206
+ * requires authentication, username and password/token must be provided.
207
+ *
208
+ * @param {string} path - Absolute path to the Git repository root
88
209
  * @param {string} [username] - Git username for authentication
89
- * @param {string} [password] - Git password/token for authentication
210
+ * @param {string} [password] - Git password or token for authentication
90
211
  * @returns {Promise<void>}
212
+ *
213
+ * @example
214
+ * // Pull from a public repository
215
+ * await git.pull('/workspace/repo');
216
+ *
217
+ * @example
218
+ * // Pull from a private repository
219
+ * await git.pull(
220
+ * '/workspace/repo',
221
+ * 'user',
222
+ * 'token'
223
+ * );
91
224
  */
92
225
  async pull(path, username, password) {
93
226
  await this.toolboxApi.gitPullChanges(this.instance.id, {
@@ -97,9 +230,24 @@ class Git {
97
230
  });
98
231
  }
99
232
  /**
100
- * Gets the current Git repository status
101
- * @param {string} path - Repository path
102
- * @returns {Promise<GitStatus>} Repository status information
233
+ * Gets the current status of the Git repository.
234
+ *
235
+ * This method returns information about the current state of the repository,
236
+ * including staged and unstaged changes, current branch, and untracked files.
237
+ *
238
+ * @param {string} path - Absolute path to the Git repository root
239
+ * @returns {Promise<GitStatus>} Current repository status including:
240
+ * - currentBranch: Name of the current branch
241
+ * - ahead: Number of commits ahead of the remote branch
242
+ * - behind: Number of commits behind the remote branch
243
+ * - branchPublished: Whether the branch has been published to the remote repository
244
+ * - fileStatus: List of file statuses
245
+ *
246
+ * @example
247
+ * const status = await workspace.git.status('/workspace/repo');
248
+ * console.log(`Current branch: ${status.currentBranch}`);
249
+ * console.log(`Commits ahead: ${status.ahead}`);
250
+ * console.log(`Commits behind: ${status.behind}`);
103
251
  */
104
252
  async status(path) {
105
253
  const response = await this.toolboxApi.gitGetStatus(this.instance.id, path);