@daytonaio/sdk 0.127.0 → 0.128.0-alpha.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.
Files changed (277) hide show
  1. package/LICENSE +190 -0
  2. package/{src → cjs}/CodeInterpreter.d.ts +1 -0
  3. package/cjs/CodeInterpreter.d.ts.map +1 -0
  4. package/cjs/CodeInterpreter.js.map +1 -0
  5. package/{src → cjs}/ComputerUse.d.ts +1 -0
  6. package/cjs/ComputerUse.d.ts.map +1 -0
  7. package/cjs/ComputerUse.js.map +1 -0
  8. package/{src → cjs}/Daytona.d.ts +1 -0
  9. package/cjs/Daytona.d.ts.map +1 -0
  10. package/{src → cjs}/Daytona.js +1 -0
  11. package/cjs/Daytona.js.map +1 -0
  12. package/{src → cjs}/FileSystem.d.ts +1 -0
  13. package/cjs/FileSystem.d.ts.map +1 -0
  14. package/cjs/FileSystem.js.map +1 -0
  15. package/{src → cjs}/Git.d.ts +1 -0
  16. package/cjs/Git.d.ts.map +1 -0
  17. package/cjs/Git.js.map +1 -0
  18. package/{src → cjs}/Image.d.ts +21 -0
  19. package/cjs/Image.d.ts.map +1 -0
  20. package/{src → cjs}/Image.js +123 -91
  21. package/cjs/Image.js.map +1 -0
  22. package/{src → cjs}/LspServer.d.ts +1 -0
  23. package/cjs/LspServer.d.ts.map +1 -0
  24. package/cjs/LspServer.js.map +1 -0
  25. package/{src → cjs}/ObjectStorage.d.ts +1 -0
  26. package/cjs/ObjectStorage.d.ts.map +1 -0
  27. package/cjs/ObjectStorage.js.map +1 -0
  28. package/{src → cjs}/Process.d.ts +1 -0
  29. package/cjs/Process.d.ts.map +1 -0
  30. package/cjs/Process.js.map +1 -0
  31. package/{src → cjs}/PtyHandle.d.ts +1 -0
  32. package/cjs/PtyHandle.d.ts.map +1 -0
  33. package/cjs/PtyHandle.js.map +1 -0
  34. package/cjs/README.md +147 -0
  35. package/{src → cjs}/Sandbox.d.ts +2 -17
  36. package/cjs/Sandbox.d.ts.map +1 -0
  37. package/{src → cjs}/Sandbox.js +1 -27
  38. package/cjs/Sandbox.js.map +1 -0
  39. package/{src → cjs}/Snapshot.d.ts +2 -0
  40. package/cjs/Snapshot.d.ts.map +1 -0
  41. package/{src → cjs}/Snapshot.js +9 -1
  42. package/cjs/Snapshot.js.map +1 -0
  43. package/{src → cjs}/Volume.d.ts +1 -0
  44. package/cjs/Volume.d.ts.map +1 -0
  45. package/cjs/Volume.js.map +1 -0
  46. package/{src → cjs}/code-toolbox/SandboxJsCodeToolbox.d.ts +1 -0
  47. package/cjs/code-toolbox/SandboxJsCodeToolbox.d.ts.map +1 -0
  48. package/cjs/code-toolbox/SandboxJsCodeToolbox.js.map +1 -0
  49. package/{src → cjs}/code-toolbox/SandboxPythonCodeToolbox.d.ts +1 -0
  50. package/cjs/code-toolbox/SandboxPythonCodeToolbox.d.ts.map +1 -0
  51. package/cjs/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
  52. package/{src → cjs}/code-toolbox/SandboxTsCodeToolbox.d.ts +1 -0
  53. package/cjs/code-toolbox/SandboxTsCodeToolbox.d.ts.map +1 -0
  54. package/cjs/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
  55. package/{src → cjs}/errors/DaytonaError.d.ts +1 -0
  56. package/cjs/errors/DaytonaError.d.ts.map +1 -0
  57. package/cjs/errors/DaytonaError.js.map +1 -0
  58. package/{src → cjs}/index.d.ts +1 -0
  59. package/cjs/index.d.ts.map +1 -0
  60. package/cjs/index.js.map +1 -0
  61. package/cjs/package.json +3 -0
  62. package/{src → cjs}/types/Charts.d.ts +1 -0
  63. package/cjs/types/Charts.d.ts.map +1 -0
  64. package/cjs/types/Charts.js.map +1 -0
  65. package/{src → cjs}/types/CodeInterpreter.d.ts +1 -0
  66. package/cjs/types/CodeInterpreter.d.ts.map +1 -0
  67. package/cjs/types/CodeInterpreter.js.map +1 -0
  68. package/{src → cjs}/types/ExecuteResponse.d.ts +1 -0
  69. package/cjs/types/ExecuteResponse.d.ts.map +1 -0
  70. package/cjs/types/ExecuteResponse.js.map +1 -0
  71. package/{src → cjs}/types/Pty.d.ts +1 -0
  72. package/cjs/types/Pty.d.ts.map +1 -0
  73. package/cjs/types/Pty.js.map +1 -0
  74. package/{src → cjs}/utils/ArtifactParser.d.ts +1 -0
  75. package/cjs/utils/ArtifactParser.d.ts.map +1 -0
  76. package/cjs/utils/ArtifactParser.js.map +1 -0
  77. package/{src → cjs}/utils/Binary.d.ts +1 -0
  78. package/cjs/utils/Binary.d.ts.map +1 -0
  79. package/cjs/utils/Binary.js.map +1 -0
  80. package/{src → cjs}/utils/FileTransfer.d.ts +1 -0
  81. package/cjs/utils/FileTransfer.d.ts.map +1 -0
  82. package/cjs/utils/FileTransfer.js.map +1 -0
  83. package/{src → cjs}/utils/Import.d.ts +2 -15
  84. package/cjs/utils/Import.d.ts.map +1 -0
  85. package/cjs/utils/Import.js +81 -0
  86. package/cjs/utils/Import.js.map +1 -0
  87. package/{src → cjs}/utils/Multipart.d.ts +1 -0
  88. package/cjs/utils/Multipart.d.ts.map +1 -0
  89. package/cjs/utils/Multipart.js.map +1 -0
  90. package/{src → cjs}/utils/Runtime.d.ts +1 -0
  91. package/cjs/utils/Runtime.d.ts.map +1 -0
  92. package/cjs/utils/Runtime.js.map +1 -0
  93. package/{src → cjs}/utils/Stream.d.ts +1 -0
  94. package/cjs/utils/Stream.d.ts.map +1 -0
  95. package/cjs/utils/Stream.js.map +1 -0
  96. package/{src → cjs}/utils/WebSocket.d.ts +1 -0
  97. package/cjs/utils/WebSocket.d.ts.map +1 -0
  98. package/cjs/utils/WebSocket.js.map +1 -0
  99. package/esm/CodeInterpreter.d.ts +96 -0
  100. package/esm/CodeInterpreter.d.ts.map +1 -0
  101. package/esm/CodeInterpreter.js +295 -0
  102. package/esm/CodeInterpreter.js.map +1 -0
  103. package/esm/ComputerUse.d.ts +443 -0
  104. package/esm/ComputerUse.d.ts.map +1 -0
  105. package/esm/ComputerUse.js +509 -0
  106. package/esm/ComputerUse.js.map +1 -0
  107. package/esm/Daytona.d.ts +354 -0
  108. package/esm/Daytona.d.ts.map +1 -0
  109. package/esm/Daytona.js +410 -0
  110. package/esm/Daytona.js.map +1 -0
  111. package/esm/FileSystem.d.ts +328 -0
  112. package/esm/FileSystem.d.ts.map +1 -0
  113. package/esm/FileSystem.js +331 -0
  114. package/esm/FileSystem.js.map +1 -0
  115. package/esm/Git.d.ts +203 -0
  116. package/esm/Git.d.ts.map +1 -0
  117. package/esm/Git.js +260 -0
  118. package/esm/Git.js.map +1 -0
  119. package/esm/Image.d.ts +285 -0
  120. package/esm/Image.d.ts.map +1 -0
  121. package/esm/Image.js +569 -0
  122. package/esm/Image.js.map +1 -0
  123. package/esm/LspServer.d.ts +172 -0
  124. package/esm/LspServer.d.ts.map +1 -0
  125. package/esm/LspServer.js +204 -0
  126. package/esm/LspServer.js.map +1 -0
  127. package/esm/ObjectStorage.d.ts +79 -0
  128. package/esm/ObjectStorage.d.ts.map +1 -0
  129. package/esm/ObjectStorage.js +187 -0
  130. package/esm/ObjectStorage.js.map +1 -0
  131. package/esm/Process.d.ts +442 -0
  132. package/esm/Process.d.ts.map +1 -0
  133. package/esm/Process.js +644 -0
  134. package/esm/Process.js.map +1 -0
  135. package/esm/PtyHandle.d.ts +155 -0
  136. package/esm/PtyHandle.d.ts.map +1 -0
  137. package/esm/PtyHandle.js +374 -0
  138. package/esm/PtyHandle.js.map +1 -0
  139. package/esm/README.md +147 -0
  140. package/esm/Sandbox.d.ts +359 -0
  141. package/esm/Sandbox.d.ts.map +1 -0
  142. package/esm/Sandbox.js +532 -0
  143. package/esm/Sandbox.js.map +1 -0
  144. package/esm/Snapshot.d.ts +138 -0
  145. package/esm/Snapshot.d.ts.map +1 -0
  146. package/esm/Snapshot.js +207 -0
  147. package/esm/Snapshot.js.map +1 -0
  148. package/esm/Volume.d.ts +84 -0
  149. package/esm/Volume.d.ts.map +1 -0
  150. package/esm/Volume.js +95 -0
  151. package/esm/Volume.js.map +1 -0
  152. package/esm/code-toolbox/SandboxJsCodeToolbox.d.ts +6 -0
  153. package/esm/code-toolbox/SandboxJsCodeToolbox.d.ts.map +1 -0
  154. package/esm/code-toolbox/SandboxJsCodeToolbox.js +13 -0
  155. package/esm/code-toolbox/SandboxJsCodeToolbox.js.map +1 -0
  156. package/esm/code-toolbox/SandboxPythonCodeToolbox.d.ts +12 -0
  157. package/esm/code-toolbox/SandboxPythonCodeToolbox.d.ts.map +1 -0
  158. package/esm/code-toolbox/SandboxPythonCodeToolbox.js +355 -0
  159. package/esm/code-toolbox/SandboxPythonCodeToolbox.js.map +1 -0
  160. package/esm/code-toolbox/SandboxTsCodeToolbox.d.ts +6 -0
  161. package/esm/code-toolbox/SandboxTsCodeToolbox.d.ts.map +1 -0
  162. package/esm/code-toolbox/SandboxTsCodeToolbox.js +14 -0
  163. package/esm/code-toolbox/SandboxTsCodeToolbox.js.map +1 -0
  164. package/esm/errors/DaytonaError.d.ts +32 -0
  165. package/esm/errors/DaytonaError.d.ts.map +1 -0
  166. package/esm/errors/DaytonaError.js +44 -0
  167. package/esm/errors/DaytonaError.js.map +1 -0
  168. package/esm/index.d.ts +22 -0
  169. package/esm/index.d.ts.map +1 -0
  170. package/esm/index.js +22 -0
  171. package/esm/index.js.map +1 -0
  172. package/esm/package.json +3 -0
  173. package/esm/types/Charts.d.ts +152 -0
  174. package/esm/types/Charts.d.ts.map +1 -0
  175. package/esm/types/Charts.js +42 -0
  176. package/esm/types/Charts.js.map +1 -0
  177. package/esm/types/CodeInterpreter.d.ts +77 -0
  178. package/esm/types/CodeInterpreter.d.ts.map +1 -0
  179. package/esm/types/CodeInterpreter.js +6 -0
  180. package/esm/types/CodeInterpreter.js.map +1 -0
  181. package/esm/types/ExecuteResponse.d.ts +26 -0
  182. package/esm/types/ExecuteResponse.d.ts.map +1 -0
  183. package/esm/types/ExecuteResponse.js +6 -0
  184. package/esm/types/ExecuteResponse.js.map +1 -0
  185. package/esm/types/Pty.d.ts +48 -0
  186. package/esm/types/Pty.d.ts.map +1 -0
  187. package/esm/types/Pty.js +6 -0
  188. package/esm/types/Pty.js.map +1 -0
  189. package/esm/utils/ArtifactParser.d.ts +14 -0
  190. package/esm/utils/ArtifactParser.d.ts.map +1 -0
  191. package/esm/utils/ArtifactParser.js +51 -0
  192. package/esm/utils/ArtifactParser.js.map +1 -0
  193. package/esm/utils/Binary.d.ts +39 -0
  194. package/esm/utils/Binary.d.ts.map +1 -0
  195. package/esm/utils/Binary.js +157 -0
  196. package/esm/utils/Binary.js.map +1 -0
  197. package/esm/utils/FileTransfer.d.ts +15 -0
  198. package/esm/utils/FileTransfer.d.ts.map +1 -0
  199. package/esm/utils/FileTransfer.js +209 -0
  200. package/esm/utils/FileTransfer.js.map +1 -0
  201. package/esm/utils/Import.d.ts +211 -0
  202. package/esm/utils/Import.d.ts.map +1 -0
  203. package/esm/utils/Import.js +45 -0
  204. package/esm/utils/Import.js.map +1 -0
  205. package/esm/utils/Multipart.d.ts +27 -0
  206. package/esm/utils/Multipart.d.ts.map +1 -0
  207. package/esm/utils/Multipart.js +107 -0
  208. package/esm/utils/Multipart.js.map +1 -0
  209. package/esm/utils/Runtime.d.ts +37 -0
  210. package/esm/utils/Runtime.d.ts.map +1 -0
  211. package/esm/utils/Runtime.js +57 -0
  212. package/esm/utils/Runtime.js.map +1 -0
  213. package/esm/utils/Stream.d.ts +20 -0
  214. package/esm/utils/Stream.d.ts.map +1 -0
  215. package/esm/utils/Stream.js +360 -0
  216. package/esm/utils/Stream.js.map +1 -0
  217. package/esm/utils/WebSocket.d.ts +10 -0
  218. package/esm/utils/WebSocket.d.ts.map +1 -0
  219. package/esm/utils/WebSocket.js +22 -0
  220. package/esm/utils/WebSocket.js.map +1 -0
  221. package/package.json +20 -8
  222. package/src/CodeInterpreter.js.map +0 -1
  223. package/src/ComputerUse.js.map +0 -1
  224. package/src/Daytona.js.map +0 -1
  225. package/src/FileSystem.js.map +0 -1
  226. package/src/Git.js.map +0 -1
  227. package/src/Image.js.map +0 -1
  228. package/src/LspServer.js.map +0 -1
  229. package/src/ObjectStorage.js.map +0 -1
  230. package/src/Process.js.map +0 -1
  231. package/src/PtyHandle.js.map +0 -1
  232. package/src/Sandbox.js.map +0 -1
  233. package/src/Snapshot.js.map +0 -1
  234. package/src/Volume.js.map +0 -1
  235. package/src/code-toolbox/SandboxJsCodeToolbox.js.map +0 -1
  236. package/src/code-toolbox/SandboxPythonCodeToolbox.js.map +0 -1
  237. package/src/code-toolbox/SandboxTsCodeToolbox.js.map +0 -1
  238. package/src/errors/DaytonaError.js.map +0 -1
  239. package/src/index.js.map +0 -1
  240. package/src/types/Charts.js.map +0 -1
  241. package/src/types/CodeInterpreter.js.map +0 -1
  242. package/src/types/ExecuteResponse.js.map +0 -1
  243. package/src/types/Pty.js.map +0 -1
  244. package/src/utils/ArtifactParser.js.map +0 -1
  245. package/src/utils/Binary.js.map +0 -1
  246. package/src/utils/FileTransfer.js.map +0 -1
  247. package/src/utils/Import.js +0 -77
  248. package/src/utils/Import.js.map +0 -1
  249. package/src/utils/Multipart.js.map +0 -1
  250. package/src/utils/Runtime.js.map +0 -1
  251. package/src/utils/Stream.js.map +0 -1
  252. package/src/utils/WebSocket.js.map +0 -1
  253. /package/{src → cjs}/CodeInterpreter.js +0 -0
  254. /package/{src → cjs}/ComputerUse.js +0 -0
  255. /package/{src → cjs}/FileSystem.js +0 -0
  256. /package/{src → cjs}/Git.js +0 -0
  257. /package/{src → cjs}/LspServer.js +0 -0
  258. /package/{src → cjs}/ObjectStorage.js +0 -0
  259. /package/{src → cjs}/Process.js +0 -0
  260. /package/{src → cjs}/PtyHandle.js +0 -0
  261. /package/{src → cjs}/Volume.js +0 -0
  262. /package/{src → cjs}/code-toolbox/SandboxJsCodeToolbox.js +0 -0
  263. /package/{src → cjs}/code-toolbox/SandboxPythonCodeToolbox.js +0 -0
  264. /package/{src → cjs}/code-toolbox/SandboxTsCodeToolbox.js +0 -0
  265. /package/{src → cjs}/errors/DaytonaError.js +0 -0
  266. /package/{src → cjs}/index.js +0 -0
  267. /package/{src → cjs}/types/Charts.js +0 -0
  268. /package/{src → cjs}/types/CodeInterpreter.js +0 -0
  269. /package/{src → cjs}/types/ExecuteResponse.js +0 -0
  270. /package/{src → cjs}/types/Pty.js +0 -0
  271. /package/{src → cjs}/utils/ArtifactParser.js +0 -0
  272. /package/{src → cjs}/utils/Binary.js +0 -0
  273. /package/{src → cjs}/utils/FileTransfer.js +0 -0
  274. /package/{src → cjs}/utils/Multipart.js +0 -0
  275. /package/{src → cjs}/utils/Runtime.js +0 -0
  276. /package/{src → cjs}/utils/Stream.js +0 -0
  277. /package/{src → cjs}/utils/WebSocket.js +0 -0
@@ -0,0 +1,157 @@
1
+ /*
2
+ * Copyright 2025 Daytona Platforms Inc.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { Buffer } from 'buffer';
6
+ import { DaytonaError } from '../errors/DaytonaError.js';
7
+ /**
8
+ * Converts various data types to Uint8Array
9
+ */
10
+ export function toUint8Array(data) {
11
+ if (typeof data === 'string') {
12
+ return new TextEncoder().encode(data);
13
+ }
14
+ if (data instanceof ArrayBuffer) {
15
+ return new Uint8Array(data);
16
+ }
17
+ if (ArrayBuffer.isView(data)) {
18
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
19
+ }
20
+ throw new DaytonaError('Unsupported data type for byte conversion.');
21
+ }
22
+ /**
23
+ * Concatenates multiple Uint8Array chunks into a single Uint8Array
24
+ */
25
+ export function concatUint8Arrays(parts) {
26
+ const size = parts.reduce((sum, part) => sum + part.byteLength, 0);
27
+ const result = new Uint8Array(size);
28
+ let offset = 0;
29
+ for (const part of parts) {
30
+ result.set(part, offset);
31
+ offset += part.byteLength;
32
+ }
33
+ return result;
34
+ }
35
+ /**
36
+ * Converts Uint8Array to Buffer (uses polyfill in non-Node environments)
37
+ */
38
+ export function toBuffer(data) {
39
+ return Buffer.from(data);
40
+ }
41
+ /**
42
+ * Decodes Uint8Array to UTF-8 string
43
+ */
44
+ export function utf8Decode(data) {
45
+ return new TextDecoder('utf-8').decode(data);
46
+ }
47
+ /**
48
+ * Finds all occurrences of a pattern in a byte buffer
49
+ */
50
+ export function findAllBytes(buffer, pattern) {
51
+ const results = [];
52
+ let i = 0;
53
+ while (i <= buffer.length - pattern.length) {
54
+ let match = true;
55
+ for (let j = 0; j < pattern.length; j++) {
56
+ if (buffer[i + j] !== pattern[j]) {
57
+ match = false;
58
+ break;
59
+ }
60
+ }
61
+ if (match) {
62
+ results.push(i);
63
+ i += pattern.length;
64
+ }
65
+ else {
66
+ i++;
67
+ }
68
+ }
69
+ return results;
70
+ }
71
+ /**
72
+ * Finds the first occurrence of a pattern in a byte buffer within a range
73
+ */
74
+ export function findBytesInRange(buffer, start, end, pattern) {
75
+ let i = start;
76
+ while (i <= end - pattern.length) {
77
+ let match = true;
78
+ for (let j = 0; j < pattern.length; j++) {
79
+ if (buffer[i + j] !== pattern[j]) {
80
+ match = false;
81
+ break;
82
+ }
83
+ }
84
+ if (match)
85
+ return i;
86
+ i++;
87
+ }
88
+ return -1;
89
+ }
90
+ /**
91
+ * Checks if a sequence starts at a given position in a byte buffer
92
+ * Returns the position after the sequence if found, -1 otherwise
93
+ */
94
+ export function indexAfterSequence(buffer, start, sequence) {
95
+ for (let j = 0; j < sequence.length; j++) {
96
+ if (buffer[start + j] !== sequence[j])
97
+ return -1;
98
+ }
99
+ return start + sequence.length;
100
+ }
101
+ /**
102
+ * Collects all bytes from various stream types into a single Uint8Array
103
+ */
104
+ export async function collectStreamBytes(stream) {
105
+ if (!stream)
106
+ return new Uint8Array(0);
107
+ // ReadableStream (WHATWG)
108
+ if (typeof stream.getReader === 'function') {
109
+ const reader = stream.getReader();
110
+ const chunks = [];
111
+ try {
112
+ while (true) {
113
+ const { done, value } = await reader.read();
114
+ if (done)
115
+ break;
116
+ if (value?.byteLength) {
117
+ chunks.push(value);
118
+ }
119
+ }
120
+ }
121
+ finally {
122
+ await reader.cancel();
123
+ }
124
+ return concatUint8Arrays(chunks);
125
+ }
126
+ // AsyncIterable
127
+ if (stream?.[Symbol.asyncIterator]) {
128
+ const chunks = [];
129
+ for await (const chunk of stream) {
130
+ chunks.push(toUint8Array(chunk));
131
+ }
132
+ return concatUint8Arrays(chunks);
133
+ }
134
+ // Direct data types
135
+ if (typeof stream === 'string' || stream instanceof ArrayBuffer || ArrayBuffer.isView(stream)) {
136
+ return toUint8Array(stream);
137
+ }
138
+ // Blob
139
+ if (typeof Blob !== 'undefined' && stream instanceof Blob) {
140
+ const arrayBuffer = await stream.arrayBuffer();
141
+ return new Uint8Array(arrayBuffer);
142
+ }
143
+ // Response
144
+ if (typeof Response !== 'undefined' && stream instanceof Response) {
145
+ const arrayBuffer = await stream.arrayBuffer();
146
+ return new Uint8Array(arrayBuffer);
147
+ }
148
+ throw new DaytonaError('Unsupported stream type for byte collection.');
149
+ }
150
+ /**
151
+ * Checks if value is a File object (browser environment)
152
+ */
153
+ export function isFile(value) {
154
+ const FileConstructor = globalThis.File;
155
+ return typeof FileConstructor !== 'undefined' && value instanceof FileConstructor;
156
+ }
157
+ //# sourceMappingURL=Binary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Binary.js","sourceRoot":"","sources":["../../../../../../libs/sdk-typescript/src/utils/Binary.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAErD;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAA4C;IACvE,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC;IACD,IAAI,IAAI,YAAY,WAAW,EAAE,CAAC;QAChC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;IACD,IAAI,WAAW,CAAC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B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9F,OAAO,YAAY,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IAED,OAAO;IACP,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,MAAM,YAAY,IAAI,EAAE,CAAC;QAC1D,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAA;QAC9C,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAAA;IACpC,CAAC;IAED,WAAW;IACX,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,MAAM,YAAY,QAAQ,EAAE,CAAC;QAClE,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAA;QAC9C,OAAO,IAAI,UAAU,CAAC,WAAW,CAAC,CAAA;IACpC,CAAC;IAED,MAAM,IAAI,YAAY,CAAC,8CAA8C,CAAC,CAAA;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAAU;IAC/B,MAAM,eAAe,GAAI,UAAkB,CAAC,IAAI,CAAA;IAChD,OAAO,OAAO,eAAe,KAAK,WAAW,IAAI,KAAK,YAAY,eAAe,CAAA;AACnF,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { DownloadMetadata } from '../FileSystem.js';
2
+ /**
3
+ * Safely aborts a stream
4
+ */
5
+ export declare function abortStream(stream: any): void;
6
+ /**
7
+ * Normalizes response data to extract the actual stream
8
+ */
9
+ export declare function normalizeResponseStream(responseData: any): any;
10
+ /**
11
+ * Processes multipart response using busboy (Node.js path)
12
+ */
13
+ export declare function processDownloadFilesResponseWithBusboy(stream: any, headers: Record<string, string>, metadataMap: Map<string, DownloadMetadata>): Promise<void>;
14
+ export declare function processDownloadFilesResponseWithBuffered(stream: any, headers: Record<string, string>, metadataMap: Map<string, DownloadMetadata>): Promise<void>;
15
+ //# sourceMappingURL=FileTransfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileTransfer.d.ts","sourceRoot":"","sources":["../../../../../../libs/sdk-typescript/src/utils/FileTransfer.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAEhD;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAM7C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,YAAY,EAAE,GAAG,GAAG,GAAG,CAgB9D;AAED;;GAEG;AACH,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CAuFf;AA8CD,wBAAsB,wCAAwC,CAC5D,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC,CA8Cf"}
@@ -0,0 +1,209 @@
1
+ /*
2
+ * Copyright 2025 Daytona Platforms Inc.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { Buffer } from 'buffer';
6
+ import busboy from 'busboy';
7
+ import { DaytonaError } from '../errors/DaytonaError.js';
8
+ import { dynamicImport } from './Import.js';
9
+ import { collectStreamBytes, toBuffer, toUint8Array } from './Binary.js';
10
+ import { extractBoundary, getHeader, parseMultipartWithFormData } from './Multipart.js';
11
+ import { parseMultipart } from './Multipart.js';
12
+ /**
13
+ * Safely aborts a stream
14
+ */
15
+ export function abortStream(stream) {
16
+ if (stream && typeof stream.destroy === 'function') {
17
+ stream.destroy();
18
+ }
19
+ else if (stream && typeof stream.cancel === 'function') {
20
+ stream.cancel();
21
+ }
22
+ }
23
+ /**
24
+ * Normalizes response data to extract the actual stream
25
+ */
26
+ export function normalizeResponseStream(responseData) {
27
+ if (!responseData || typeof responseData !== 'object') {
28
+ return responseData;
29
+ }
30
+ // WHATWG ReadableStream
31
+ if (responseData.body && typeof responseData.body.getReader === 'function') {
32
+ return responseData.body;
33
+ }
34
+ // Some adapters use .stream
35
+ if (responseData.stream) {
36
+ return responseData.stream;
37
+ }
38
+ return responseData;
39
+ }
40
+ /**
41
+ * Processes multipart response using busboy (Node.js path)
42
+ */
43
+ export async function processDownloadFilesResponseWithBusboy(stream, headers, metadataMap) {
44
+ const fileTasks = [];
45
+ await new Promise((resolve, reject) => {
46
+ const bb = busboy({
47
+ headers,
48
+ preservePath: true,
49
+ });
50
+ bb.on('file', (fieldName, fileStream, fileInfo) => {
51
+ const source = fileInfo?.filename;
52
+ if (!source) {
53
+ abortStream(stream);
54
+ reject(new DaytonaError(`Received unexpected file "${fileInfo?.filename}".`));
55
+ return;
56
+ }
57
+ const metadata = metadataMap.get(source);
58
+ if (!metadata) {
59
+ abortStream(stream);
60
+ reject(new DaytonaError(`Target metadata missing for valid source: ${source}`));
61
+ return;
62
+ }
63
+ if (fieldName === 'error') {
64
+ // Collect error message
65
+ const chunks = [];
66
+ fileStream.on('data', (chunk) => chunks.push(chunk));
67
+ fileStream.on('end', () => {
68
+ metadata.error = Buffer.concat(chunks).toString('utf-8').trim();
69
+ });
70
+ fileStream.on('error', (err) => {
71
+ metadata.error = `Stream error: ${err.message}`;
72
+ });
73
+ }
74
+ else if (fieldName === 'file') {
75
+ if (metadata.destination) {
76
+ // Stream to file
77
+ fileTasks.push(new Promise((resolveTask) => {
78
+ dynamicImport('fs', 'Downloading files to local files is not supported: ').then((fs) => {
79
+ const writeStream = fs.createWriteStream(metadata.destination, { autoClose: true });
80
+ fileStream.pipe(writeStream);
81
+ writeStream.on('finish', () => {
82
+ metadata.result = metadata.destination;
83
+ resolveTask();
84
+ });
85
+ writeStream.on('error', (err) => {
86
+ metadata.error = `Write stream failed: ${err.message}`;
87
+ resolveTask();
88
+ });
89
+ fileStream.on('error', (err) => {
90
+ metadata.error = `Read stream failed: ${err.message}`;
91
+ });
92
+ });
93
+ }));
94
+ }
95
+ else {
96
+ // Collect to buffer
97
+ const chunks = [];
98
+ fileStream.on('data', (chunk) => {
99
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
100
+ });
101
+ fileStream.on('end', () => {
102
+ metadata.result = Buffer.concat(chunks);
103
+ });
104
+ fileStream.on('error', (err) => {
105
+ metadata.error = `Read failed: ${err.message}`;
106
+ });
107
+ }
108
+ }
109
+ else {
110
+ // Unknown field, drain it
111
+ fileStream.resume();
112
+ }
113
+ });
114
+ bb.on('error', (err) => {
115
+ abortStream(stream);
116
+ reject(err);
117
+ });
118
+ bb.on('finish', resolve);
119
+ // Feed stream into busboy
120
+ feedStreamToBusboy(stream, bb).catch((err) => bb.destroy(err));
121
+ });
122
+ await Promise.all(fileTasks);
123
+ }
124
+ /**
125
+ * Feeds various stream types into busboy
126
+ */
127
+ async function feedStreamToBusboy(stream, bb) {
128
+ // Node.js stream (piping)
129
+ if (typeof stream?.pipe === 'function') {
130
+ stream.pipe(bb);
131
+ return;
132
+ }
133
+ // Direct buffer-like data
134
+ if (typeof stream === 'string' || stream instanceof ArrayBuffer || ArrayBuffer.isView(stream)) {
135
+ const data = toUint8Array(stream);
136
+ bb.write(Buffer.from(data));
137
+ bb.end();
138
+ return;
139
+ }
140
+ // WHATWG ReadableStream
141
+ if (typeof stream?.getReader === 'function') {
142
+ const reader = stream.getReader();
143
+ while (true) {
144
+ const { done, value } = await reader.read();
145
+ if (done)
146
+ break;
147
+ bb.write(Buffer.from(value));
148
+ }
149
+ bb.end();
150
+ return;
151
+ }
152
+ // AsyncIterable
153
+ if (stream?.[Symbol.asyncIterator]) {
154
+ for await (const chunk of stream) {
155
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(toUint8Array(chunk));
156
+ bb.write(buffer);
157
+ }
158
+ bb.end();
159
+ return;
160
+ }
161
+ // Unsupported stream type
162
+ throw new DaytonaError(`Unsupported stream type: ${stream?.constructor?.name || typeof stream}`);
163
+ }
164
+ export async function processDownloadFilesResponseWithBuffered(stream, headers, metadataMap) {
165
+ const contentType = getHeader(headers, 'content-type') || '';
166
+ const bodyBytes = await collectStreamBytes(stream);
167
+ // Try native FormData parsing for multipart/form-data
168
+ if (/^multipart\/form-data/i.test(contentType) && typeof Response !== 'undefined') {
169
+ try {
170
+ const formDataMap = await parseMultipartWithFormData(bodyBytes, contentType);
171
+ formDataMap.forEach((value, fieldName) => {
172
+ const metadata = metadataMap.get(value.filename);
173
+ if (!metadata)
174
+ return;
175
+ if (fieldName.includes('error')) {
176
+ metadata.error = new TextDecoder('utf-8').decode(value.data).trim();
177
+ }
178
+ else {
179
+ metadata.result = toBuffer(value.data);
180
+ }
181
+ });
182
+ return;
183
+ }
184
+ catch {
185
+ // Fall through to manual parsing
186
+ }
187
+ }
188
+ // Manual multipart parsing (handles multipart/mixed, etc.)
189
+ const boundary = extractBoundary(contentType);
190
+ if (!boundary) {
191
+ throw new DaytonaError(`Missing multipart boundary in Content-Type: "${contentType}"`);
192
+ }
193
+ const parts = parseMultipart(bodyBytes, boundary);
194
+ for (const part of parts) {
195
+ if (!part.filename)
196
+ continue;
197
+ const metadata = metadataMap.get(part.filename);
198
+ if (!metadata)
199
+ continue;
200
+ if (part.name === 'error') {
201
+ metadata.error = new TextDecoder('utf-8').decode(part.data).trim();
202
+ }
203
+ else if (part.name === 'file') {
204
+ metadata.result = toBuffer(part.data);
205
+ }
206
+ }
207
+ return;
208
+ }
209
+ //# sourceMappingURL=FileTransfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileTransfer.js","sourceRoot":"","sources":["../../../../../../libs/sdk-typescript/src/utils/FileTransfer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC/B,O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CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,YAAY,CAAC,gDAAgD,WAAW,GAAG,CAAC,CAAA;IACxF,CAAC;IAED,MAAM,KAAK,GAAG,cAAc,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IACjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,SAAQ;QAC5B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC/C,IAAI,CAAC,QAAQ;YAAE,SAAQ;QAEvB,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,QAAQ,CAAC,KAAK,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;QACpE,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAChC,QAAQ,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;IAED,OAAM;AACR,CAAC"}
@@ -0,0 +1,211 @@
1
+ declare const loaderMap: {
2
+ 'fast-glob': () => Promise<{
3
+ default: typeof import("fast-glob");
4
+ sync(source: import("fast-glob/out/types").Pattern | import("fast-glob/out/types").Pattern[], options: import("fast-glob/out/settings").Options & ({
5
+ objectMode: true;
6
+ } | {
7
+ stats: true;
8
+ })): import("fast-glob/out/types").Entry[];
9
+ sync(source: import("fast-glob/out/types").Pattern | import("fast-glob/out/types").Pattern[], options?: import("fast-glob/out/settings").Options): string[];
10
+ stream(source: import("fast-glob/out/types").Pattern | import("fast-glob/out/types").Pattern[], options?: import("fast-glob/out/settings").Options): NodeJS.ReadableStream;
11
+ generateTasks(source: import("fast-glob/out/types").Pattern | import("fast-glob/out/types").Pattern[], options?: import("fast-glob/out/settings").Options): import("fast-glob").Task[];
12
+ isDynamicPattern(source: import("fast-glob/out/types").Pattern, options?: import("fast-glob/out/settings").Options): boolean;
13
+ escapePath(source: string): import("fast-glob/out/types").Pattern;
14
+ convertPathToPattern(source: string): import("fast-glob/out/types").Pattern;
15
+ glob: typeof import("fast-glob");
16
+ globSync: typeof import("fast-glob").sync;
17
+ globStream: typeof import("fast-glob").stream;
18
+ async: typeof import("fast-glob");
19
+ posix: typeof import("fast-glob").posix;
20
+ win32: typeof import("fast-glob").win32;
21
+ }>;
22
+ '@iarna/toml': () => Promise<{
23
+ default: typeof import("@iarna/toml");
24
+ parse: import("@iarna/toml").FuncParse;
25
+ stringify: import("@iarna/toml").FuncStringify;
26
+ }>;
27
+ stream: () => Promise<{
28
+ default: typeof import("stream");
29
+ Stream: typeof import("stream");
30
+ promises: typeof import("node:stream/promises");
31
+ duplexPair(options?: import("stream").DuplexOptions): [import("stream").Duplex, import("stream").Duplex];
32
+ addAbortSignal<T extends import("stream")>(signal: AbortSignal, stream: T): T;
33
+ getDefaultHighWaterMark(objectMode: boolean): number;
34
+ setDefaultHighWaterMark(objectMode: boolean, value: number): void;
35
+ finished: typeof import("stream").finished;
36
+ pipeline: typeof import("stream").pipeline;
37
+ isErrored(stream: import("stream").Readable | import("stream").Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean;
38
+ isReadable(stream: import("stream").Readable | NodeJS.ReadableStream): boolean;
39
+ Readable: typeof import("stream").Readable;
40
+ Writable: typeof import("stream").Writable;
41
+ Duplex: typeof import("stream").Duplex;
42
+ Transform: typeof import("stream").Transform;
43
+ PassThrough: typeof import("stream").PassThrough;
44
+ errorMonitor: typeof import("events").errorMonitor;
45
+ captureRejectionSymbol: typeof import("events").captureRejectionSymbol;
46
+ captureRejections: boolean;
47
+ defaultMaxListeners: number;
48
+ EventEmitter: typeof import("events");
49
+ EventEmitterAsyncResource: typeof import("events").EventEmitterAsyncResource;
50
+ }>;
51
+ tar: () => Promise<{
52
+ default: typeof import("tar");
53
+ Extract(opts: import("tar").ExtractOptions | string): import("tar").ParseStream;
54
+ create(options: import("tar").CreateOptions, fileList: readonly string[], callback?: (err?: Error) => void): import("stream").Readable;
55
+ create(options: import("tar").CreateOptions & import("tar").FileOptions, fileList: readonly string[]): Promise<void>;
56
+ create(options: import("tar").CreateOptions & import("tar").FileOptions & {
57
+ sync: true;
58
+ }, fileList: readonly string[]): void;
59
+ create(options: import("tar").CreateOptions & import("tar").FileOptions, fileList: readonly string[], callback: (err?: Error) => void): void;
60
+ extract(options: import("tar").ExtractOptions, fileList?: readonly string[], callback?: (err?: Error) => void): import("stream").Writable;
61
+ extract(options: import("tar").ExtractOptions & import("tar").FileOptions, fileList?: readonly string[]): Promise<void>;
62
+ extract(options: import("tar").ExtractOptions & import("tar").FileOptions & {
63
+ sync: true;
64
+ }, fileList?: readonly string[]): void;
65
+ extract(options: import("tar").ExtractOptions & import("tar").FileOptions, fileList: readonly string[] | undefined, callback: (err?: Error) => void): void;
66
+ list(options: import("tar").ListOptions & import("tar").RequiredFileOptions, fileList?: readonly string[]): Promise<void>;
67
+ list(options: import("tar").ListOptions & import("tar").RequiredFileOptions & {
68
+ sync: true;
69
+ }, fileList?: readonly string[]): void;
70
+ list(callback?: (err?: Error) => void): import("tar").Parse;
71
+ list(optionsOrFileList: import("tar").ListOptions | readonly string[], callback?: (err?: Error) => void): import("tar").Parse;
72
+ list(options: import("tar").ListOptions, fileList: readonly string[], callback?: (err?: Error) => void): import("tar").Parse;
73
+ replace(options: import("tar").ReplaceOptions, fileList?: readonly string[]): Promise<void>;
74
+ replace(options: import("tar").ReplaceOptions, fileList: readonly string[] | undefined, callback: (err?: Error) => void): Promise<void>;
75
+ update(options: import("tar").ReplaceOptions, fileList?: readonly string[]): Promise<void>;
76
+ update(options: import("tar").ReplaceOptions, fileList: readonly string[] | undefined, callback: (err?: Error) => void): Promise<void>;
77
+ fieldSize: number[];
78
+ fieldOffs: number[];
79
+ fieldEnds: number[];
80
+ types: {
81
+ 0: string;
82
+ "\0": string;
83
+ "": string;
84
+ 1: string;
85
+ 2: string;
86
+ 3: string;
87
+ 4: string;
88
+ 5: string;
89
+ 6: string;
90
+ 7: string;
91
+ g: string;
92
+ x: string;
93
+ A: string;
94
+ D: string;
95
+ I: string;
96
+ K: string;
97
+ L: string;
98
+ M: string;
99
+ N: string;
100
+ S: string;
101
+ V: string;
102
+ X: string;
103
+ File: string;
104
+ OldFile: string;
105
+ Link: string;
106
+ SymbolicLick: string;
107
+ CharacterDevice: string;
108
+ BlockDevice: string;
109
+ Directory: string;
110
+ FIFO: string;
111
+ ContiguousFile: string;
112
+ GlobalExtendedHeader: string;
113
+ ExtendedHeader: string;
114
+ SolarisACL: string;
115
+ GNUDumpDir: string;
116
+ INode: string;
117
+ NextFileHasLonLinkPath: string;
118
+ NextFileHasLongPath: string;
119
+ ContinuationFile: string;
120
+ TapeVolumeHeader: string;
121
+ OldExtendedHeader: string;
122
+ };
123
+ modes: {
124
+ suid: number;
125
+ sgid: number;
126
+ svtx: number;
127
+ uread: number;
128
+ uwrite: number;
129
+ uexec: number;
130
+ gread: number;
131
+ gwrite: number;
132
+ gexec: number;
133
+ oread: number;
134
+ owrite: number;
135
+ oexec: number;
136
+ };
137
+ numeric: {
138
+ mode: boolean;
139
+ uid: boolean;
140
+ gid: boolean;
141
+ size: boolean;
142
+ mtime: boolean;
143
+ devmaj: boolean;
144
+ devmin: boolean;
145
+ cksum: boolean;
146
+ atime: boolean;
147
+ ctime: boolean;
148
+ dev: boolean;
149
+ ino: boolean;
150
+ nlink: boolean;
151
+ };
152
+ knownExtended: {
153
+ atime: boolean;
154
+ charset: boolean;
155
+ comment: boolean;
156
+ ctime: boolean;
157
+ gid: boolean;
158
+ gname: boolean;
159
+ linkpat: boolean;
160
+ mtime: boolean;
161
+ path: boolean;
162
+ realtime: boolean;
163
+ security: boolean;
164
+ size: boolean;
165
+ uid: boolean;
166
+ uname: boolean;
167
+ };
168
+ headerSize: number;
169
+ blockSize: number;
170
+ Parse: {
171
+ new (opt?: import("tar").ParseOptions): import("tar").Parse;
172
+ };
173
+ Pack: typeof import("tar").Pack;
174
+ c: typeof import("tar").create;
175
+ x: typeof import("tar").extract;
176
+ t: typeof import("tar").list;
177
+ r: typeof import("tar").replace;
178
+ u: typeof import("tar").update;
179
+ }>;
180
+ 'expand-tilde': () => Promise<any>;
181
+ ObjectStorage: () => Promise<typeof import("../ObjectStorage.js")>;
182
+ fs: () => Promise<typeof import("fs")>;
183
+ 'form-data': () => Promise<{
184
+ default: typeof import("form-data");
185
+ Stream: typeof import("stream");
186
+ promises: typeof import("node:stream/promises");
187
+ duplexPair(options?: import("stream").DuplexOptions): [import("stream").Duplex, import("stream").Duplex];
188
+ addAbortSignal<T extends import("stream")>(signal: AbortSignal, stream: T): T;
189
+ getDefaultHighWaterMark(objectMode: boolean): number;
190
+ setDefaultHighWaterMark(objectMode: boolean, value: number): void;
191
+ finished: typeof import("stream").finished;
192
+ pipeline: typeof import("stream").pipeline;
193
+ isErrored(stream: import("stream").Readable | import("stream").Writable | NodeJS.ReadableStream | NodeJS.WritableStream): boolean;
194
+ isReadable(stream: import("stream").Readable | NodeJS.ReadableStream): boolean;
195
+ Readable: typeof import("stream").Readable;
196
+ Writable: typeof import("stream").Writable;
197
+ Duplex: typeof import("stream").Duplex;
198
+ Transform: typeof import("stream").Transform;
199
+ PassThrough: typeof import("stream").PassThrough;
200
+ errorMonitor: typeof import("events").errorMonitor;
201
+ captureRejectionSymbol: typeof import("events").captureRejectionSymbol;
202
+ captureRejections: boolean;
203
+ defaultMaxListeners: number;
204
+ EventEmitter: typeof import("events");
205
+ EventEmitterAsyncResource: typeof import("events").EventEmitterAsyncResource;
206
+ }>;
207
+ };
208
+ type ModuleMap = typeof loaderMap;
209
+ export declare function dynamicImport<K extends keyof ModuleMap>(name: K, errorPrefix?: string): Promise<Awaited<ReturnType<ModuleMap[K]>>>;
210
+ export {};
211
+ //# sourceMappingURL=Import.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Import.d.ts","sourceRoot":"","sources":["../../../../../../libs/sdk-typescript/src/utils/Import.ts"],"names":[],"mappings":"AAQA,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iGAiDinpB,CAAC;;;;;4HAA8qB,CAAC;oGAA41B,CAAC;;;;;0IAAw+B,CAAC;;;;;4BAA0lB,CAAC;8FAAkH,CAAC;6FAAiH,CAAC;;8GAAysB,CAAC;;6GAA2qB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAAhiuB,CAAC;;;;;;;;;;;cA1CnwE,OAAO,CAAC,cAAc,IAAI,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAErC,CAAA;AAYD,KAAK,SAAS,GAAG,OAAO,SAAS,CAAA;AAEjC,wBAAsB,aAAa,CAAC,CAAC,SAAS,MAAM,SAAS,EAC3D,IAAI,EAAE,CAAC,EACP,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAsB5C"}
@@ -0,0 +1,45 @@
1
+ /*
2
+ * Copyright 2025 Daytona Platforms Inc.
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+ import { DaytonaError } from '../errors/DaytonaError.js';
6
+ import { RUNTIME } from './Runtime.js';
7
+ const loaderMap = {
8
+ 'fast-glob': () => import('fast-glob'),
9
+ '@iarna/toml': () => import('@iarna/toml'),
10
+ stream: () => import('stream'),
11
+ tar: () => import('tar'),
12
+ 'expand-tilde': () => import('expand-tilde'),
13
+ ObjectStorage: () => import('../ObjectStorage.js'),
14
+ fs: () => import('fs'),
15
+ 'form-data': () => import('form-data'),
16
+ };
17
+ const validateMap = {
18
+ 'fast-glob': (mod) => typeof mod === 'function' && typeof mod?.sync === 'function',
19
+ '@iarna/toml': (mod) => typeof mod.parse === 'function' && typeof mod.stringify === 'function',
20
+ stream: (mod) => typeof mod.Readable === 'function' && typeof mod.Writable === 'function',
21
+ tar: (mod) => typeof mod.extract === 'function' && typeof mod.create === 'function',
22
+ 'expand-tilde': (mod) => typeof mod === 'function',
23
+ fs: (mod) => typeof mod.createReadStream === 'function' && typeof mod.readFile === 'function',
24
+ 'form-data': (mod) => typeof mod === 'function',
25
+ };
26
+ export async function dynamicImport(name, errorPrefix) {
27
+ const loader = loaderMap[name];
28
+ if (!loader) {
29
+ throw new DaytonaError(`${errorPrefix || ''} Unknown module "${name}"`);
30
+ }
31
+ let mod;
32
+ try {
33
+ mod = (await loader());
34
+ mod = mod?.default ?? mod;
35
+ }
36
+ catch (err) {
37
+ const msg = err instanceof Error ? err.message : String(err);
38
+ throw new DaytonaError(`${errorPrefix || ''} Module "${name}" is not available in the "${RUNTIME}" runtime: ${msg}`);
39
+ }
40
+ if (validateMap[name] && !validateMap[name](mod)) {
41
+ throw new DaytonaError(`${errorPrefix || ''} Module "${name}" didn't pass import validation in the "${RUNTIME}" runtime`);
42
+ }
43
+ return mod;
44
+ }
45
+ //# sourceMappingURL=Import.js.map