@daytonaio/sdk 0.162.0 → 0.163.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 +3 -3
- package/src/CodeInterpreter.js +4 -4
- package/src/CodeInterpreter.js.map +1 -1
- package/src/Daytona.d.ts +1 -1
- package/src/Daytona.js +12 -33
- package/src/Daytona.js.map +1 -1
- package/src/FileSystem.d.ts +19 -1
- package/src/FileSystem.js +11 -3
- package/src/FileSystem.js.map +1 -1
- package/src/Image.js +51 -11
- package/src/Image.js.map +1 -1
- package/src/LspServer.js +2 -1
- package/src/LspServer.js.map +1 -1
- package/src/ObjectStorage.js +1 -1
- package/src/ObjectStorage.js.map +1 -1
- package/src/PtyHandle.js +4 -4
- package/src/PtyHandle.js.map +1 -1
- package/src/Sandbox.js +12 -12
- package/src/Sandbox.js.map +1 -1
- package/src/errors/DaytonaError.d.ts +146 -7
- package/src/errors/DaytonaError.js +222 -15
- package/src/errors/DaytonaError.js.map +1 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +6 -1
- package/src/index.js.map +1 -1
- package/src/utils/FileTransfer.d.ts +1 -1
- package/src/utils/FileTransfer.js +54 -12
- package/src/utils/FileTransfer.js.map +1 -1
- package/src/utils/Multipart.d.ts +3 -1
- package/src/utils/Multipart.js +4 -2
- package/src/utils/Multipart.js.map +1 -1
|
@@ -4,48 +4,255 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DaytonaTimeoutError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = void 0;
|
|
7
|
+
exports.DaytonaConnectionError = exports.DaytonaTimeoutError = exports.DaytonaValidationError = exports.DaytonaConflictError = exports.DaytonaAuthorizationError = exports.DaytonaAuthenticationError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = void 0;
|
|
8
|
+
exports.errorClassFromStatusCode = errorClassFromStatusCode;
|
|
9
|
+
exports.createDaytonaError = createDaytonaError;
|
|
10
|
+
exports.createAxiosDaytonaError = createAxiosDaytonaError;
|
|
8
11
|
/**
|
|
9
12
|
* Base error for Daytona SDK.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* try {
|
|
17
|
+
* await daytona.get('missing-sandbox')
|
|
18
|
+
* } catch (error) {
|
|
19
|
+
* if (error instanceof DaytonaError) {
|
|
20
|
+
* console.log(error.statusCode)
|
|
21
|
+
* console.log(error.errorCode)
|
|
22
|
+
* console.log(error.message)
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
10
26
|
*/
|
|
11
27
|
class DaytonaError extends Error {
|
|
12
28
|
/** HTTP status code if available */
|
|
13
29
|
statusCode;
|
|
30
|
+
/** Machine-readable error code if available */
|
|
31
|
+
errorCode;
|
|
14
32
|
/** Response headers if available */
|
|
15
33
|
headers;
|
|
16
|
-
constructor(message, statusCode, headers) {
|
|
34
|
+
constructor(message, statusCode, headers, errorCode) {
|
|
17
35
|
super(message);
|
|
18
|
-
this.name =
|
|
36
|
+
this.name = new.target.name;
|
|
19
37
|
this.statusCode = statusCode;
|
|
20
38
|
this.headers = headers;
|
|
39
|
+
this.errorCode = errorCode;
|
|
21
40
|
}
|
|
22
41
|
}
|
|
23
42
|
exports.DaytonaError = DaytonaError;
|
|
43
|
+
/**
|
|
44
|
+
* Error thrown when a resource is not found (HTTP 404).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* try {
|
|
49
|
+
* await sandbox.fs.downloadFile('/workspace/missing.txt')
|
|
50
|
+
* } catch (error) {
|
|
51
|
+
* if (error instanceof DaytonaNotFoundError) {
|
|
52
|
+
* console.log(error.statusCode)
|
|
53
|
+
* }
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
24
57
|
class DaytonaNotFoundError extends DaytonaError {
|
|
25
|
-
constructor(message, statusCode, headers) {
|
|
26
|
-
super(message, statusCode, headers);
|
|
27
|
-
this.name = 'DaytonaNotFoundError';
|
|
28
|
-
}
|
|
29
58
|
}
|
|
30
59
|
exports.DaytonaNotFoundError = DaytonaNotFoundError;
|
|
31
60
|
/**
|
|
32
61
|
* Error thrown when rate limit is exceeded.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* try {
|
|
66
|
+
* await daytona.list()
|
|
67
|
+
* } catch (error) {
|
|
68
|
+
* if (error instanceof DaytonaRateLimitError) {
|
|
69
|
+
* console.log(error.errorCode)
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
33
73
|
*/
|
|
34
74
|
class DaytonaRateLimitError extends DaytonaError {
|
|
35
|
-
constructor(message, statusCode, headers) {
|
|
36
|
-
super(message, statusCode, headers);
|
|
37
|
-
this.name = 'DaytonaRateLimitError';
|
|
38
|
-
}
|
|
39
75
|
}
|
|
40
76
|
exports.DaytonaRateLimitError = DaytonaRateLimitError;
|
|
77
|
+
/**
|
|
78
|
+
* Error thrown when authentication fails (HTTP 401).
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```ts
|
|
82
|
+
* try {
|
|
83
|
+
* await daytona.list()
|
|
84
|
+
* } catch (error) {
|
|
85
|
+
* if (error instanceof DaytonaAuthenticationError) {
|
|
86
|
+
* console.log(error.statusCode)
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
class DaytonaAuthenticationError extends DaytonaError {
|
|
92
|
+
}
|
|
93
|
+
exports.DaytonaAuthenticationError = DaytonaAuthenticationError;
|
|
94
|
+
/**
|
|
95
|
+
* Error thrown when the request is forbidden (HTTP 403).
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* try {
|
|
100
|
+
* await daytona.get('sandbox-without-access')
|
|
101
|
+
* } catch (error) {
|
|
102
|
+
* if (error instanceof DaytonaAuthorizationError) {
|
|
103
|
+
* console.log(error.message)
|
|
104
|
+
* }
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
class DaytonaAuthorizationError extends DaytonaError {
|
|
109
|
+
}
|
|
110
|
+
exports.DaytonaAuthorizationError = DaytonaAuthorizationError;
|
|
111
|
+
/**
|
|
112
|
+
* Error thrown when a resource conflict occurs (HTTP 409).
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* try {
|
|
117
|
+
* await daytona.create({ name: 'existing-sandbox' })
|
|
118
|
+
* } catch (error) {
|
|
119
|
+
* if (error instanceof DaytonaConflictError) {
|
|
120
|
+
* console.log(error.errorCode)
|
|
121
|
+
* }
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
class DaytonaConflictError extends DaytonaError {
|
|
126
|
+
}
|
|
127
|
+
exports.DaytonaConflictError = DaytonaConflictError;
|
|
128
|
+
/**
|
|
129
|
+
* Error thrown when input validation fails (HTTP 400 or client-side validation).
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* try {
|
|
134
|
+
* Image.debianSlim('3.8' as never)
|
|
135
|
+
* } catch (error) {
|
|
136
|
+
* if (error instanceof DaytonaValidationError) {
|
|
137
|
+
* console.log(error.message)
|
|
138
|
+
* }
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
class DaytonaValidationError extends DaytonaError {
|
|
143
|
+
}
|
|
144
|
+
exports.DaytonaValidationError = DaytonaValidationError;
|
|
41
145
|
/**
|
|
42
146
|
* Error thrown when a timeout occurs.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* try {
|
|
151
|
+
* await sandbox.waitUntilStarted(1)
|
|
152
|
+
* } catch (error) {
|
|
153
|
+
* if (error instanceof DaytonaTimeoutError) {
|
|
154
|
+
* console.log(error.message)
|
|
155
|
+
* }
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
43
158
|
*/
|
|
44
159
|
class DaytonaTimeoutError extends DaytonaError {
|
|
45
|
-
constructor(message, statusCode, headers) {
|
|
46
|
-
super(message, statusCode, headers);
|
|
47
|
-
this.name = 'DaytonaTimeoutError';
|
|
48
|
-
}
|
|
49
160
|
}
|
|
50
161
|
exports.DaytonaTimeoutError = DaytonaTimeoutError;
|
|
162
|
+
/**
|
|
163
|
+
* Error thrown when a network connection fails.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* try {
|
|
168
|
+
* await ptyHandle.waitForConnection()
|
|
169
|
+
* } catch (error) {
|
|
170
|
+
* if (error instanceof DaytonaConnectionError) {
|
|
171
|
+
* console.log(error.message)
|
|
172
|
+
* }
|
|
173
|
+
* }
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
class DaytonaConnectionError extends DaytonaError {
|
|
177
|
+
}
|
|
178
|
+
exports.DaytonaConnectionError = DaytonaConnectionError;
|
|
179
|
+
const STATUS_CODE_TO_ERROR = {
|
|
180
|
+
400: DaytonaValidationError,
|
|
181
|
+
401: DaytonaAuthenticationError,
|
|
182
|
+
403: DaytonaAuthorizationError,
|
|
183
|
+
404: DaytonaNotFoundError,
|
|
184
|
+
409: DaytonaConflictError,
|
|
185
|
+
429: DaytonaRateLimitError,
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Maps an HTTP status code to the corresponding Daytona error class.
|
|
189
|
+
*/
|
|
190
|
+
function errorClassFromStatusCode(statusCode) {
|
|
191
|
+
if (statusCode === undefined) {
|
|
192
|
+
return DaytonaError;
|
|
193
|
+
}
|
|
194
|
+
return STATUS_CODE_TO_ERROR[statusCode] || DaytonaError;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Creates the appropriate Daytona error subclass from structured error metadata.
|
|
198
|
+
*/
|
|
199
|
+
function createDaytonaError(message, statusCode, headers, errorCode) {
|
|
200
|
+
const ErrorClass = errorClassFromStatusCode(statusCode);
|
|
201
|
+
return new ErrorClass(message, statusCode, headers, errorCode);
|
|
202
|
+
}
|
|
203
|
+
function isAxiosTimeoutError(error) {
|
|
204
|
+
return error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT' || error.message.includes('timeout of');
|
|
205
|
+
}
|
|
206
|
+
function getAxiosResponseDataObject(error) {
|
|
207
|
+
if (!error.response?.data || typeof error.response.data !== 'object') {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
return error.response.data;
|
|
211
|
+
}
|
|
212
|
+
function extractAxiosErrorCode(responseData) {
|
|
213
|
+
if (typeof responseData?.code === 'string') {
|
|
214
|
+
return responseData.code;
|
|
215
|
+
}
|
|
216
|
+
if (typeof responseData?.error_code === 'string') {
|
|
217
|
+
return responseData.error_code;
|
|
218
|
+
}
|
|
219
|
+
if (typeof responseData?.error === 'string') {
|
|
220
|
+
return responseData.error;
|
|
221
|
+
}
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
function extractAxiosErrorMessage(error) {
|
|
225
|
+
if (isAxiosTimeoutError(error)) {
|
|
226
|
+
return 'Operation timed out';
|
|
227
|
+
}
|
|
228
|
+
const responseData = getAxiosResponseDataObject(error);
|
|
229
|
+
const responseMessage = responseData?.message || error.response?.data;
|
|
230
|
+
const message = responseMessage || error.message || String(error);
|
|
231
|
+
if (typeof message === 'object') {
|
|
232
|
+
try {
|
|
233
|
+
return JSON.stringify(message);
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return String(message);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
return String(message);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Creates the appropriate Daytona error subclass from an Axios error.
|
|
243
|
+
*/
|
|
244
|
+
function createAxiosDaytonaError(error) {
|
|
245
|
+
const message = extractAxiosErrorMessage(error);
|
|
246
|
+
const statusCode = error.response?.status;
|
|
247
|
+
const headers = error.response?.headers;
|
|
248
|
+
const responseData = getAxiosResponseDataObject(error);
|
|
249
|
+
const errorCode = extractAxiosErrorCode(responseData);
|
|
250
|
+
if (isAxiosTimeoutError(error)) {
|
|
251
|
+
return new DaytonaTimeoutError(message, statusCode, headers, errorCode);
|
|
252
|
+
}
|
|
253
|
+
if (!error.response && (error.request || error.code)) {
|
|
254
|
+
return new DaytonaConnectionError(message, statusCode, headers, errorCode);
|
|
255
|
+
}
|
|
256
|
+
return createDaytonaError(message, statusCode, headers, errorCode);
|
|
257
|
+
}
|
|
51
258
|
//# sourceMappingURL=DaytonaError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DaytonaError.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/errors/DaytonaError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"DaytonaError.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/errors/DaytonaError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA+LH,4DAMC;AAKD,gDAQC;AAqDD,0DAgBC;AA7QD;;;;;;;;;;;;;;;GAeG;AACH,MAAa,YAAa,SAAQ,KAAK;IACrC,oCAAoC;IAC7B,UAAU,CAAS;IAC1B,+CAA+C;IACxC,SAAS,CAAS;IACzB,oCAAoC;IAC7B,OAAO,CAAkB;IAEhC,YAAY,OAAe,EAAE,UAAmB,EAAE,OAAyB,EAAE,SAAkB;QAC7F,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CA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O,KAAK,QAAQ,EAAE,CAAC;QAChC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,MAAM,CAAC,OAAO,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,CAAA;AACxB,CAAC;AAED;;GAEG;AACH,SAAgB,uBAAuB,CAAC,KAAiB;IACvD,MAAM,OAAO,GAAG,wBAAwB,CAAC,KAAK,CAAC,CAAA;IAC/C,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,EAAE,OAAsC,CAAA;IACtE,MAAM,YAAY,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAA;IACtD,MAAM,SAAS,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAA;IAErD,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,mBAAmB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IACzE,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,OAAO,IAAI,sBAAsB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;IAC5E,CAAC;IAED,OAAO,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AACpE,CAAC"}
|
package/src/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { CodeLanguage, Daytona } from './Daytona';
|
|
2
2
|
export type { CreateSandboxBaseParams, CreateSandboxFromImageParams, CreateSandboxFromSnapshotParams, DaytonaConfig, Resources, VolumeMount, } from './Daytona';
|
|
3
3
|
export { FileSystem } from './FileSystem';
|
|
4
|
+
export type { DownloadMetadata, FileDownloadErrorDetails, FileDownloadRequest, FileDownloadResponse, FilePermissionsParams, FileUpload, } from './FileSystem';
|
|
4
5
|
export { Git } from './Git';
|
|
5
6
|
export { LspLanguageId } from './LspServer';
|
|
6
7
|
export { Process } from './Process';
|
|
7
|
-
export { DaytonaError, DaytonaNotFoundError, DaytonaRateLimitError, DaytonaTimeoutError } from './errors/DaytonaError';
|
|
8
|
+
export { DaytonaAuthenticationError, DaytonaAuthorizationError, DaytonaConflictError, DaytonaConnectionError, DaytonaError, DaytonaNotFoundError, DaytonaRateLimitError, DaytonaTimeoutError, DaytonaValidationError, } from './errors/DaytonaError';
|
|
8
9
|
export { Image } from './Image';
|
|
9
10
|
export { Sandbox } from './Sandbox';
|
|
10
11
|
export type { SandboxCodeToolbox } from './Sandbox';
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.SandboxState = exports.ChartType = exports.Display = exports.Screenshot = exports.Keyboard = exports.Mouse = exports.ComputerUse = exports.Sandbox = exports.Image = exports.DaytonaTimeoutError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = exports.Process = exports.LspLanguageId = exports.Git = exports.FileSystem = exports.Daytona = exports.CodeLanguage = void 0;
|
|
7
|
+
exports.SandboxState = exports.ChartType = exports.Display = exports.Screenshot = exports.Keyboard = exports.Mouse = exports.ComputerUse = exports.Sandbox = exports.Image = exports.DaytonaValidationError = exports.DaytonaTimeoutError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = exports.DaytonaConnectionError = exports.DaytonaConflictError = exports.DaytonaAuthorizationError = exports.DaytonaAuthenticationError = exports.Process = exports.LspLanguageId = exports.Git = exports.FileSystem = exports.Daytona = exports.CodeLanguage = void 0;
|
|
8
8
|
const tslib_1 = require("tslib");
|
|
9
9
|
var Daytona_1 = require("./Daytona");
|
|
10
10
|
Object.defineProperty(exports, "CodeLanguage", { enumerable: true, get: function () { return Daytona_1.CodeLanguage; } });
|
|
@@ -20,10 +20,15 @@ Object.defineProperty(exports, "Process", { enumerable: true, get: function () {
|
|
|
20
20
|
// export { LspServer } from './LspServer'
|
|
21
21
|
// export type { LspLanguageId, Position } from './LspServer'
|
|
22
22
|
var DaytonaError_1 = require("./errors/DaytonaError");
|
|
23
|
+
Object.defineProperty(exports, "DaytonaAuthenticationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaAuthenticationError; } });
|
|
24
|
+
Object.defineProperty(exports, "DaytonaAuthorizationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaAuthorizationError; } });
|
|
25
|
+
Object.defineProperty(exports, "DaytonaConflictError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaConflictError; } });
|
|
26
|
+
Object.defineProperty(exports, "DaytonaConnectionError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaConnectionError; } });
|
|
23
27
|
Object.defineProperty(exports, "DaytonaError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaError; } });
|
|
24
28
|
Object.defineProperty(exports, "DaytonaNotFoundError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaNotFoundError; } });
|
|
25
29
|
Object.defineProperty(exports, "DaytonaRateLimitError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaRateLimitError; } });
|
|
26
30
|
Object.defineProperty(exports, "DaytonaTimeoutError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaTimeoutError; } });
|
|
31
|
+
Object.defineProperty(exports, "DaytonaValidationError", { enumerable: true, get: function () { return DaytonaError_1.DaytonaValidationError; } });
|
|
27
32
|
var Image_1 = require("./Image");
|
|
28
33
|
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return Image_1.Image; } });
|
|
29
34
|
var Sandbox_1 = require("./Sandbox");
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/sdk-typescript/src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,qCAAiD;AAAxC,uGAAA,YAAY,OAAA;AAAE,kGAAA,OAAO,OAAA;AAS9B,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/sdk-typescript/src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;AAEH,qCAAiD;AAAxC,uGAAA,YAAY,OAAA;AAAE,kGAAA,OAAO,OAAA;AAS9B,2CAAyC;AAAhC,wGAAA,UAAU,OAAA;AASnB,6BAA2B;AAAlB,0FAAA,GAAG,OAAA;AACZ,yCAA2C;AAAlC,0GAAA,aAAa,OAAA;AACtB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,0CAA0C;AAC1C,6DAA6D;AAC7D,sDAU8B;AAT5B,0HAAA,0BAA0B,OAAA;AAC1B,yHAAA,yBAAyB,OAAA;AACzB,oHAAA,oBAAoB,OAAA;AACpB,sHAAA,sBAAsB,OAAA;AACtB,4GAAA,YAAY,OAAA;AACZ,oHAAA,oBAAoB,OAAA;AACpB,qHAAA,qBAAqB,OAAA;AACrB,mHAAA,mBAAmB,OAAA;AACnB,sHAAA,sBAAsB,OAAA;AAExB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA;AACd,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAGhB,6CAAiF;AAAxE,0GAAA,WAAW,OAAA;AAAE,oGAAA,KAAK,OAAA;AAAE,uGAAA,QAAQ,OAAA;AAAE,yGAAA,UAAU,OAAA;AAAE,sGAAA,OAAO,OAAA;AAG1D,2BAA2B;AAC3B,yCAA0C;AAAjC,mGAAA,SAAS,OAAA;AAWlB,kDAAkD;AAAzC,0GAAA,YAAY,OAAA;AAYrB,oDAAyB;AACzB,sDAA2B;AAC3B,sDAA2B"}
|
|
@@ -16,6 +16,47 @@ const Import_1 = require("./Import");
|
|
|
16
16
|
const Binary_1 = require("./Binary");
|
|
17
17
|
const Multipart_1 = require("./Multipart");
|
|
18
18
|
const Multipart_2 = require("./Multipart");
|
|
19
|
+
/**
|
|
20
|
+
* Parses a bulk-download error part into the legacy message and structured metadata.
|
|
21
|
+
*/
|
|
22
|
+
function parseDownloadErrorPart(data, contentType) {
|
|
23
|
+
let message = new TextDecoder('utf-8').decode(data).trim();
|
|
24
|
+
if (!contentType || !/application\/json/i.test(contentType)) {
|
|
25
|
+
return { message };
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const payload = JSON.parse(message);
|
|
29
|
+
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
|
|
30
|
+
return { message };
|
|
31
|
+
}
|
|
32
|
+
const payloadObject = payload;
|
|
33
|
+
const structuredMessage = payloadObject.message;
|
|
34
|
+
const statusCode = payloadObject.statusCode ?? payloadObject.status_code;
|
|
35
|
+
const errorCode = payloadObject.code ?? payloadObject.error_code;
|
|
36
|
+
if (typeof structuredMessage === 'string') {
|
|
37
|
+
message = structuredMessage;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
message,
|
|
41
|
+
errorDetails: {
|
|
42
|
+
message,
|
|
43
|
+
statusCode: typeof statusCode === 'number' ? statusCode : undefined,
|
|
44
|
+
errorCode: typeof errorCode === 'string' ? errorCode : undefined,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return { message };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Records a per-file error part on the corresponding download metadata entry.
|
|
54
|
+
*/
|
|
55
|
+
function assignDownloadErrorPart(metadata, data, contentType) {
|
|
56
|
+
const { message, errorDetails } = parseDownloadErrorPart(data, contentType);
|
|
57
|
+
metadata.error = message;
|
|
58
|
+
metadata.errorDetails = errorDetails;
|
|
59
|
+
}
|
|
19
60
|
/**
|
|
20
61
|
* Safely aborts a stream
|
|
21
62
|
*/
|
|
@@ -68,11 +109,11 @@ async function processDownloadFilesResponseWithBusboy(stream, headers, metadataM
|
|
|
68
109
|
return;
|
|
69
110
|
}
|
|
70
111
|
if (fieldName === 'error') {
|
|
71
|
-
// Collect error
|
|
112
|
+
// Collect per-file error metadata.
|
|
72
113
|
const chunks = [];
|
|
73
114
|
fileStream.on('data', (chunk) => chunks.push(chunk));
|
|
74
115
|
fileStream.on('end', () => {
|
|
75
|
-
metadata
|
|
116
|
+
assignDownloadErrorPart(metadata, buffer_1.Buffer.concat(chunks), fileInfo?.mimeType);
|
|
76
117
|
});
|
|
77
118
|
fileStream.on('error', (err) => {
|
|
78
119
|
metadata.error = `Stream error: ${err.message}`;
|
|
@@ -174,18 +215,19 @@ async function processDownloadFilesResponseWithBuffered(stream, headers, metadat
|
|
|
174
215
|
// Try native FormData parsing for multipart/form-data
|
|
175
216
|
if (/^multipart\/form-data/i.test(contentType) && typeof Response !== 'undefined') {
|
|
176
217
|
try {
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
const metadata = metadataMap.get(
|
|
180
|
-
if (!metadata)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
218
|
+
const formDataParts = await (0, Multipart_1.parseMultipartWithFormData)(bodyBytes, contentType);
|
|
219
|
+
for (const part of formDataParts) {
|
|
220
|
+
const metadata = metadataMap.get(part.filename);
|
|
221
|
+
if (!metadata) {
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
if (part.fieldName === 'error') {
|
|
225
|
+
assignDownloadErrorPart(metadata, part.data, part.contentType);
|
|
184
226
|
}
|
|
185
227
|
else {
|
|
186
|
-
metadata.result = (0, Binary_1.toBuffer)(
|
|
228
|
+
metadata.result = (0, Binary_1.toBuffer)(part.data);
|
|
187
229
|
}
|
|
188
|
-
}
|
|
230
|
+
}
|
|
189
231
|
return;
|
|
190
232
|
}
|
|
191
233
|
catch {
|
|
@@ -205,7 +247,7 @@ async function processDownloadFilesResponseWithBuffered(stream, headers, metadat
|
|
|
205
247
|
if (!metadata)
|
|
206
248
|
continue;
|
|
207
249
|
if (part.name === 'error') {
|
|
208
|
-
metadata.
|
|
250
|
+
assignDownloadErrorPart(metadata, part.data, part.headers['content-type']);
|
|
209
251
|
}
|
|
210
252
|
else if (part.name === 'file') {
|
|
211
253
|
metadata.result = (0, Binary_1.toBuffer)(part.data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileTransfer.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/FileTransfer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;
|
|
1
|
+
{"version":3,"file":"FileTransfer.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/FileTransfer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAiEH,kCAMC;AAKD,0DAgBC;AAKD,wFA2FC;AA8CD,4FAoDC;;AA5RD,mCAA+B;AAC/B,4DAA2B;AAC3B,yDAAqD;AACrD,qCAAwC;AACxC,qCAAqE;AACrE,2CAAoF;AACpF,2CAA4C;AAQ5C;;GAEG;AACH,SAAS,sBAAsB,CAAC,IAAgB,EAAE,WAAoB;IACpE,IAAI,OAAO,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAA;IAC1D,IAAI,CAAC,WAAW,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5D,OAAO,EAAE,OAAO,EAAE,CAAA;IACpB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAY,CAAA;QAC9C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACtE,OAAO,EAAE,OAAO,EAAE,CAAA;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GAAG,IAAA,iBAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;IAED,OAAM;AACR,CAAC"}
|
package/src/utils/Multipart.d.ts
CHANGED
|
@@ -16,8 +16,10 @@ export declare function parseMultipart(body: Uint8Array, boundary: string): Mult
|
|
|
16
16
|
* Parses multipart response using browser's native FormData API
|
|
17
17
|
* This is more reliable than manual parsing when available
|
|
18
18
|
*/
|
|
19
|
-
export declare function parseMultipartWithFormData(bodyBytes: Uint8Array, contentType: string): Promise<
|
|
19
|
+
export declare function parseMultipartWithFormData(bodyBytes: Uint8Array, contentType: string): Promise<Array<{
|
|
20
|
+
fieldName: string;
|
|
20
21
|
filename: string;
|
|
22
|
+
contentType: string;
|
|
21
23
|
data: Uint8Array;
|
|
22
24
|
}>>;
|
|
23
25
|
/**
|
package/src/utils/Multipart.js
CHANGED
|
@@ -77,7 +77,7 @@ function parseMultipart(body, boundary) {
|
|
|
77
77
|
* This is more reliable than manual parsing when available
|
|
78
78
|
*/
|
|
79
79
|
async function parseMultipartWithFormData(bodyBytes, contentType) {
|
|
80
|
-
const result =
|
|
80
|
+
const result = [];
|
|
81
81
|
// Create a Blob and parse with FormData API
|
|
82
82
|
const blob = new Blob([bodyBytes.slice()], { type: contentType });
|
|
83
83
|
const formData = await new Response(blob).formData();
|
|
@@ -88,8 +88,10 @@ async function parseMultipartWithFormData(bodyBytes, contentType) {
|
|
|
88
88
|
filePromises.push((async () => {
|
|
89
89
|
const file = value;
|
|
90
90
|
const arrayBuffer = await file.arrayBuffer();
|
|
91
|
-
result.
|
|
91
|
+
result.push({
|
|
92
|
+
fieldName,
|
|
92
93
|
filename: file.name,
|
|
94
|
+
contentType: file.type,
|
|
93
95
|
data: new Uint8Array(arrayBuffer),
|
|
94
96
|
});
|
|
95
97
|
})());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Multipart.js","sourceRoot":"","sources":["../../../../../libs/sdk-typescript/src/utils/Multipart.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