@daytonaio/sdk 0.184.0-alpha.1 → 0.184.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/cjs/Daytona.d.ts +5 -1
- package/cjs/Daytona.js +10 -7
- package/cjs/Daytona.js.map +1 -1
- package/cjs/FileSystem.d.ts +2 -4
- package/cjs/FileSystem.js +1 -1
- package/cjs/FileSystem.js.map +1 -1
- package/cjs/Sandbox.d.ts +15 -16
- package/cjs/Sandbox.js +18 -15
- package/cjs/Sandbox.js.map +1 -1
- package/cjs/Snapshot.js +5 -0
- package/cjs/Snapshot.js.map +1 -1
- package/cjs/errors/DaytonaError.d.ts +143 -87
- package/cjs/errors/DaytonaError.js +166 -174
- package/cjs/errors/DaytonaError.js.map +1 -1
- package/cjs/index.d.ts +2 -2
- package/cjs/index.js +7 -36
- package/cjs/index.js.map +1 -1
- package/cjs/utils/FileTransfer.js +2 -4
- package/cjs/utils/FileTransfer.js.map +1 -1
- package/cjs/utils/Runtime.js +1 -1
- package/cjs/utils/Runtime.js.map +1 -1
- package/esm/Daytona.d.ts +5 -1
- package/esm/Daytona.js +10 -7
- package/esm/Daytona.js.map +1 -1
- package/esm/FileSystem.d.ts +2 -4
- package/esm/FileSystem.js +1 -1
- package/esm/FileSystem.js.map +1 -1
- package/esm/Sandbox.d.ts +15 -16
- package/esm/Sandbox.js +18 -15
- package/esm/Sandbox.js.map +1 -1
- package/esm/Snapshot.js +5 -0
- package/esm/Snapshot.js.map +1 -1
- package/esm/errors/DaytonaError.d.ts +143 -87
- package/esm/errors/DaytonaError.js +159 -144
- package/esm/errors/DaytonaError.js.map +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +2 -10
- package/esm/index.js.map +1 -1
- package/esm/utils/FileTransfer.js +2 -4
- package/esm/utils/FileTransfer.js.map +1 -1
- package/esm/utils/Runtime.js +1 -1
- package/esm/utils/Runtime.js.map +1 -1
- package/package.json +3 -3
|
@@ -5,116 +5,172 @@ import { AxiosHeaders } from 'axios';
|
|
|
5
5
|
import type { AxiosError } from 'axios';
|
|
6
6
|
export type ResponseHeaders = InstanceType<typeof AxiosHeaders>;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
8
|
+
* Base error for Daytona SDK.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* try {
|
|
13
|
+
* await daytona.get('missing-sandbox')
|
|
14
|
+
* } catch (error) {
|
|
15
|
+
* if (error instanceof DaytonaError) {
|
|
16
|
+
* console.log(error.statusCode)
|
|
17
|
+
* console.log(error.errorCode)
|
|
18
|
+
* console.log(error.message)
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
19
22
|
*/
|
|
20
23
|
export declare class DaytonaError extends Error {
|
|
24
|
+
/** HTTP status code if available */
|
|
21
25
|
statusCode?: number;
|
|
22
|
-
code
|
|
23
|
-
|
|
26
|
+
/** Machine-readable error code if available */
|
|
27
|
+
errorCode?: string;
|
|
28
|
+
/** Response headers if available */
|
|
24
29
|
headers?: ResponseHeaders;
|
|
25
|
-
constructor(message: string, statusCode?: number, headers?: ResponseHeaders,
|
|
26
|
-
}
|
|
27
|
-
export declare class DaytonaBadRequestError extends DaytonaError {
|
|
28
|
-
}
|
|
29
|
-
export declare class DaytonaAuthenticationError extends DaytonaError {
|
|
30
|
-
}
|
|
31
|
-
export declare class DaytonaForbiddenError extends DaytonaError {
|
|
30
|
+
constructor(message: string, statusCode?: number, headers?: ResponseHeaders, errorCode?: string);
|
|
32
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Error thrown when a resource is not found (HTTP 404).
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* try {
|
|
38
|
+
* await sandbox.fs.downloadFile('/workspace/missing.txt')
|
|
39
|
+
* } catch (error) {
|
|
40
|
+
* if (error instanceof DaytonaNotFoundError) {
|
|
41
|
+
* console.log(error.statusCode)
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
33
46
|
export declare class DaytonaNotFoundError extends DaytonaError {
|
|
34
47
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Error thrown when rate limit is exceeded.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* try {
|
|
54
|
+
* for await (const sandbox of daytona.list()) {
|
|
55
|
+
* console.log(sandbox.id)
|
|
56
|
+
* }
|
|
57
|
+
* } catch (error) {
|
|
58
|
+
* if (error instanceof DaytonaRateLimitError) {
|
|
59
|
+
* console.log(error.errorCode)
|
|
60
|
+
* }
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
43
64
|
export declare class DaytonaRateLimitError extends DaytonaError {
|
|
44
65
|
}
|
|
45
|
-
export declare class DaytonaInternalServerError extends DaytonaError {
|
|
46
|
-
}
|
|
47
|
-
export declare class DaytonaBadGatewayError extends DaytonaError {
|
|
48
|
-
}
|
|
49
|
-
export declare class DaytonaServiceUnavailableError extends DaytonaError {
|
|
50
|
-
}
|
|
51
66
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
67
|
+
* Error thrown when authentication fails (HTTP 401).
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* try {
|
|
72
|
+
* for await (const sandbox of daytona.list()) {
|
|
73
|
+
* console.log(sandbox.id)
|
|
74
|
+
* }
|
|
75
|
+
* } catch (error) {
|
|
76
|
+
* if (error instanceof DaytonaAuthenticationError) {
|
|
77
|
+
* console.log(error.statusCode)
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
55
81
|
*/
|
|
56
|
-
export declare
|
|
57
|
-
|
|
58
|
-
export type DaytonaValidationError = DaytonaBadRequestError;
|
|
82
|
+
export declare class DaytonaAuthenticationError extends DaytonaError {
|
|
83
|
+
}
|
|
59
84
|
/**
|
|
60
|
-
*
|
|
85
|
+
* Error thrown when the request is forbidden (HTTP 403).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* try {
|
|
90
|
+
* await daytona.get('sandbox-without-access')
|
|
91
|
+
* } catch (error) {
|
|
92
|
+
* if (error instanceof DaytonaAuthorizationError) {
|
|
93
|
+
* console.log(error.message)
|
|
94
|
+
* }
|
|
95
|
+
* }
|
|
96
|
+
* ```
|
|
61
97
|
*/
|
|
62
|
-
export declare
|
|
63
|
-
/** @deprecated Use {@link DaytonaForbiddenError} instead. */
|
|
64
|
-
export type DaytonaAuthorizationError = DaytonaForbiddenError;
|
|
65
|
-
/** Network connection failure (can't connect or mid-request drop). */
|
|
66
|
-
export declare class DaytonaConnectionError extends DaytonaError {
|
|
67
|
-
}
|
|
68
|
-
/** Transport-layer timeout (connect / read). Subclass of DaytonaConnectionError. */
|
|
69
|
-
export declare class DaytonaConnectionTimeoutError extends DaytonaConnectionError {
|
|
70
|
-
}
|
|
71
|
-
export declare class DaytonaGitAuthFailedError extends DaytonaAuthenticationError {
|
|
72
|
-
}
|
|
73
|
-
export declare class DaytonaGitRepoNotFoundError extends DaytonaNotFoundError {
|
|
98
|
+
export declare class DaytonaAuthorizationError extends DaytonaError {
|
|
74
99
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
export declare class
|
|
90
|
-
}
|
|
91
|
-
export declare class DaytonaProcessExecutionTimeoutError extends DaytonaTimeoutError {
|
|
92
|
-
}
|
|
93
|
-
export declare class DaytonaProcessNotFoundError extends DaytonaNotFoundError {
|
|
94
|
-
}
|
|
95
|
-
export declare class DaytonaSessionEndedError extends DaytonaGoneError {
|
|
96
|
-
}
|
|
97
|
-
export declare class DaytonaCommandAlreadyCompletedError extends DaytonaGoneError {
|
|
100
|
+
/**
|
|
101
|
+
* Error thrown when a resource conflict occurs (HTTP 409).
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* try {
|
|
106
|
+
* await daytona.create({ name: 'existing-sandbox' })
|
|
107
|
+
* } catch (error) {
|
|
108
|
+
* if (error instanceof DaytonaConflictError) {
|
|
109
|
+
* console.log(error.errorCode)
|
|
110
|
+
* }
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare class DaytonaConflictError extends DaytonaError {
|
|
98
115
|
}
|
|
99
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Error thrown when input validation fails (HTTP 400 or client-side validation).
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* try {
|
|
122
|
+
* Image.debianSlim('3.8' as never)
|
|
123
|
+
* } catch (error) {
|
|
124
|
+
* if (error instanceof DaytonaValidationError) {
|
|
125
|
+
* console.log(error.message)
|
|
126
|
+
* }
|
|
127
|
+
* }
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare class DaytonaValidationError extends DaytonaError {
|
|
100
131
|
}
|
|
101
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Error thrown when a timeout occurs.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* try {
|
|
138
|
+
* await sandbox.waitUntilStarted(1)
|
|
139
|
+
* } catch (error) {
|
|
140
|
+
* if (error instanceof DaytonaTimeoutError) {
|
|
141
|
+
* console.log(error.message)
|
|
142
|
+
* }
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
export declare class DaytonaTimeoutError extends DaytonaError {
|
|
102
147
|
}
|
|
103
|
-
|
|
148
|
+
/**
|
|
149
|
+
* Error thrown when a network connection fails.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```ts
|
|
153
|
+
* try {
|
|
154
|
+
* await ptyHandle.waitForConnection()
|
|
155
|
+
* } catch (error) {
|
|
156
|
+
* if (error instanceof DaytonaConnectionError) {
|
|
157
|
+
* console.log(error.message)
|
|
158
|
+
* }
|
|
159
|
+
* }
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export declare class DaytonaConnectionError extends DaytonaError {
|
|
104
163
|
}
|
|
105
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* Maps an HTTP status code to the corresponding Daytona error class.
|
|
166
|
+
*/
|
|
106
167
|
export declare function errorClassFromStatusCode(statusCode?: number): typeof DaytonaError;
|
|
107
168
|
/**
|
|
108
169
|
* Creates the appropriate Daytona error subclass from structured error metadata.
|
|
109
|
-
*
|
|
110
|
-
* Resolution order: (source, code) override -> HTTP status code -> DaytonaError.
|
|
111
170
|
*/
|
|
112
|
-
export declare function createDaytonaError(message: string, statusCode?: number, headers?: ResponseHeaders,
|
|
171
|
+
export declare function createDaytonaError(message: string, statusCode?: number, headers?: ResponseHeaders, errorCode?: string): DaytonaError;
|
|
113
172
|
/**
|
|
114
|
-
* Creates the appropriate Daytona error subclass from an Axios error.
|
|
115
|
-
* client-side timeouts to DaytonaConnectionTimeoutError, networking failures
|
|
116
|
-
* (no response received) to DaytonaConnectionError, and HTTP responses to
|
|
117
|
-
* the most specific subclass via `createDaytonaError`.
|
|
173
|
+
* Creates the appropriate Daytona error subclass from an Axios error.
|
|
118
174
|
*/
|
|
119
175
|
export declare function createAxiosDaytonaError(error: AxiosError): DaytonaError;
|
|
120
176
|
//# sourceMappingURL=DaytonaError.d.ts.map
|
|
@@ -4,201 +4,193 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.DaytonaConnectionError = exports.DaytonaTimeoutError = exports.DaytonaValidationError = exports.DaytonaConflictError = exports.DaytonaAuthorizationError = exports.DaytonaAuthenticationError = exports.DaytonaRateLimitError = exports.DaytonaNotFoundError = exports.DaytonaError = void 0;
|
|
8
8
|
exports.errorClassFromStatusCode = errorClassFromStatusCode;
|
|
9
9
|
exports.createDaytonaError = createDaytonaError;
|
|
10
10
|
exports.createAxiosDaytonaError = createAxiosDaytonaError;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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
|
+
* ```
|
|
23
26
|
*/
|
|
24
27
|
class DaytonaError extends Error {
|
|
28
|
+
/** HTTP status code if available */
|
|
25
29
|
statusCode;
|
|
26
|
-
code
|
|
27
|
-
|
|
30
|
+
/** Machine-readable error code if available */
|
|
31
|
+
errorCode;
|
|
32
|
+
/** Response headers if available */
|
|
28
33
|
headers;
|
|
29
|
-
constructor(message, statusCode, headers,
|
|
34
|
+
constructor(message, statusCode, headers, errorCode) {
|
|
30
35
|
super(message);
|
|
31
36
|
this.name = new.target.name;
|
|
32
37
|
this.statusCode = statusCode;
|
|
33
38
|
this.headers = headers;
|
|
34
|
-
this.
|
|
35
|
-
this.source = source;
|
|
39
|
+
this.errorCode = errorCode;
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
exports.DaytonaError = DaytonaError;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
*/
|
|
50
57
|
class DaytonaNotFoundError extends DaytonaError {
|
|
51
58
|
}
|
|
52
59
|
exports.DaytonaNotFoundError = DaytonaNotFoundError;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Error thrown when rate limit is exceeded.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* try {
|
|
66
|
+
* for await (const sandbox of daytona.list()) {
|
|
67
|
+
* console.log(sandbox.id)
|
|
68
|
+
* }
|
|
69
|
+
* } catch (error) {
|
|
70
|
+
* if (error instanceof DaytonaRateLimitError) {
|
|
71
|
+
* console.log(error.errorCode)
|
|
72
|
+
* }
|
|
73
|
+
* }
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
65
76
|
class DaytonaRateLimitError extends DaytonaError {
|
|
66
77
|
}
|
|
67
78
|
exports.DaytonaRateLimitError = DaytonaRateLimitError;
|
|
68
|
-
class DaytonaInternalServerError extends DaytonaError {
|
|
69
|
-
}
|
|
70
|
-
exports.DaytonaInternalServerError = DaytonaInternalServerError;
|
|
71
|
-
class DaytonaBadGatewayError extends DaytonaError {
|
|
72
|
-
}
|
|
73
|
-
exports.DaytonaBadGatewayError = DaytonaBadGatewayError;
|
|
74
|
-
class DaytonaServiceUnavailableError extends DaytonaError {
|
|
75
|
-
}
|
|
76
|
-
exports.DaytonaServiceUnavailableError = DaytonaServiceUnavailableError;
|
|
77
79
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
80
|
+
* Error thrown when authentication fails (HTTP 401).
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* try {
|
|
85
|
+
* for await (const sandbox of daytona.list()) {
|
|
86
|
+
* console.log(sandbox.id)
|
|
87
|
+
* }
|
|
88
|
+
* } catch (error) {
|
|
89
|
+
* if (error instanceof DaytonaAuthenticationError) {
|
|
90
|
+
* console.log(error.statusCode)
|
|
91
|
+
* }
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
81
94
|
*/
|
|
82
|
-
|
|
95
|
+
class DaytonaAuthenticationError extends DaytonaError {
|
|
96
|
+
}
|
|
97
|
+
exports.DaytonaAuthenticationError = DaytonaAuthenticationError;
|
|
83
98
|
/**
|
|
84
|
-
*
|
|
99
|
+
* Error thrown when the request is forbidden (HTTP 403).
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* try {
|
|
104
|
+
* await daytona.get('sandbox-without-access')
|
|
105
|
+
* } catch (error) {
|
|
106
|
+
* if (error instanceof DaytonaAuthorizationError) {
|
|
107
|
+
* console.log(error.message)
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
85
111
|
*/
|
|
86
|
-
|
|
87
|
-
/** Network connection failure (can't connect or mid-request drop). */
|
|
88
|
-
class DaytonaConnectionError extends DaytonaError {
|
|
89
|
-
}
|
|
90
|
-
exports.DaytonaConnectionError = DaytonaConnectionError;
|
|
91
|
-
/** Transport-layer timeout (connect / read). Subclass of DaytonaConnectionError. */
|
|
92
|
-
class DaytonaConnectionTimeoutError extends DaytonaConnectionError {
|
|
93
|
-
}
|
|
94
|
-
exports.DaytonaConnectionTimeoutError = DaytonaConnectionTimeoutError;
|
|
95
|
-
// Domain-specific subclasses. Each inherits from the HTTP-status class that
|
|
96
|
-
// matches its server-side status, so callers can catch either level.
|
|
97
|
-
// --- Git (daemon) ---
|
|
98
|
-
class DaytonaGitAuthFailedError extends DaytonaAuthenticationError {
|
|
99
|
-
}
|
|
100
|
-
exports.DaytonaGitAuthFailedError = DaytonaGitAuthFailedError;
|
|
101
|
-
class DaytonaGitRepoNotFoundError extends DaytonaNotFoundError {
|
|
102
|
-
}
|
|
103
|
-
exports.DaytonaGitRepoNotFoundError = DaytonaGitRepoNotFoundError;
|
|
104
|
-
class DaytonaGitBranchNotFoundError extends DaytonaNotFoundError {
|
|
112
|
+
class DaytonaAuthorizationError extends DaytonaError {
|
|
105
113
|
}
|
|
106
|
-
exports.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
exports.DaytonaFileNotFoundError = DaytonaFileNotFoundError;
|
|
123
|
-
class DaytonaFileAccessDeniedError extends DaytonaForbiddenError {
|
|
124
|
-
}
|
|
125
|
-
exports.DaytonaFileAccessDeniedError = DaytonaFileAccessDeniedError;
|
|
126
|
-
// --- LSP (daemon) ---
|
|
127
|
-
class DaytonaLspServerNotInitializedError extends DaytonaBadRequestError {
|
|
128
|
-
}
|
|
129
|
-
exports.DaytonaLspServerNotInitializedError = DaytonaLspServerNotInitializedError;
|
|
130
|
-
// --- Process / session (daemon) ---
|
|
131
|
-
class DaytonaProcessExecutionTimeoutError extends DaytonaTimeoutError {
|
|
132
|
-
}
|
|
133
|
-
exports.DaytonaProcessExecutionTimeoutError = DaytonaProcessExecutionTimeoutError;
|
|
134
|
-
class DaytonaProcessNotFoundError extends DaytonaNotFoundError {
|
|
135
|
-
}
|
|
136
|
-
exports.DaytonaProcessNotFoundError = DaytonaProcessNotFoundError;
|
|
137
|
-
class DaytonaSessionEndedError extends DaytonaGoneError {
|
|
138
|
-
}
|
|
139
|
-
exports.DaytonaSessionEndedError = DaytonaSessionEndedError;
|
|
140
|
-
class DaytonaCommandAlreadyCompletedError extends DaytonaGoneError {
|
|
141
|
-
}
|
|
142
|
-
exports.DaytonaCommandAlreadyCompletedError = DaytonaCommandAlreadyCompletedError;
|
|
143
|
-
// --- Computer-use (daemon) ---
|
|
144
|
-
class DaytonaA11yUnavailableError extends DaytonaServiceUnavailableError {
|
|
114
|
+
exports.DaytonaAuthorizationError = DaytonaAuthorizationError;
|
|
115
|
+
/**
|
|
116
|
+
* Error thrown when a resource conflict occurs (HTTP 409).
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* try {
|
|
121
|
+
* await daytona.create({ name: 'existing-sandbox' })
|
|
122
|
+
* } catch (error) {
|
|
123
|
+
* if (error instanceof DaytonaConflictError) {
|
|
124
|
+
* console.log(error.errorCode)
|
|
125
|
+
* }
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
class DaytonaConflictError extends DaytonaError {
|
|
145
130
|
}
|
|
146
|
-
exports.
|
|
147
|
-
|
|
131
|
+
exports.DaytonaConflictError = DaytonaConflictError;
|
|
132
|
+
/**
|
|
133
|
+
* Error thrown when input validation fails (HTTP 400 or client-side validation).
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* try {
|
|
138
|
+
* Image.debianSlim('3.8' as never)
|
|
139
|
+
* } catch (error) {
|
|
140
|
+
* if (error instanceof DaytonaValidationError) {
|
|
141
|
+
* console.log(error.message)
|
|
142
|
+
* }
|
|
143
|
+
* }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
class DaytonaValidationError extends DaytonaError {
|
|
148
147
|
}
|
|
149
|
-
exports.
|
|
150
|
-
|
|
148
|
+
exports.DaytonaValidationError = DaytonaValidationError;
|
|
149
|
+
/**
|
|
150
|
+
* Error thrown when a timeout occurs.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* try {
|
|
155
|
+
* await sandbox.waitUntilStarted(1)
|
|
156
|
+
* } catch (error) {
|
|
157
|
+
* if (error instanceof DaytonaTimeoutError) {
|
|
158
|
+
* console.log(error.message)
|
|
159
|
+
* }
|
|
160
|
+
* }
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
class DaytonaTimeoutError extends DaytonaError {
|
|
151
164
|
}
|
|
152
|
-
exports.
|
|
165
|
+
exports.DaytonaTimeoutError = DaytonaTimeoutError;
|
|
153
166
|
/**
|
|
154
|
-
*
|
|
155
|
-
* HTTP status code fallback, so a domain code wins over the status default.
|
|
167
|
+
* Error thrown when a network connection fails.
|
|
156
168
|
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```ts
|
|
171
|
+
* try {
|
|
172
|
+
* await ptyHandle.waitForConnection()
|
|
173
|
+
* } catch (error) {
|
|
174
|
+
* if (error instanceof DaytonaConnectionError) {
|
|
175
|
+
* console.log(error.message)
|
|
176
|
+
* }
|
|
177
|
+
* }
|
|
178
|
+
* ```
|
|
160
179
|
*/
|
|
161
|
-
|
|
162
|
-
// Daemon
|
|
163
|
-
'DAYTONA_DAEMON|GIT_AUTH_FAILED': DaytonaGitAuthFailedError,
|
|
164
|
-
'DAYTONA_DAEMON|GIT_REPO_NOT_FOUND': DaytonaGitRepoNotFoundError,
|
|
165
|
-
'DAYTONA_DAEMON|GIT_BRANCH_NOT_FOUND': DaytonaGitBranchNotFoundError,
|
|
166
|
-
'DAYTONA_DAEMON|GIT_BRANCH_EXISTS': DaytonaGitBranchExistsError,
|
|
167
|
-
'DAYTONA_DAEMON|GIT_PUSH_REJECTED': DaytonaGitPushRejectedError,
|
|
168
|
-
'DAYTONA_DAEMON|GIT_DIRTY_WORKTREE': DaytonaGitDirtyWorktreeError,
|
|
169
|
-
'DAYTONA_DAEMON|GIT_MERGE_CONFLICT': DaytonaGitMergeConflictError,
|
|
170
|
-
'DAYTONA_DAEMON|FILE_NOT_FOUND': DaytonaFileNotFoundError,
|
|
171
|
-
'DAYTONA_DAEMON|FILE_ACCESS_DENIED': DaytonaFileAccessDeniedError,
|
|
172
|
-
'DAYTONA_DAEMON|LSP_SERVER_NOT_INITIALIZED': DaytonaLspServerNotInitializedError,
|
|
173
|
-
'DAYTONA_DAEMON|PROCESS_EXECUTION_TIMEOUT': DaytonaProcessExecutionTimeoutError,
|
|
174
|
-
'DAYTONA_DAEMON|PROCESS_NOT_FOUND': DaytonaProcessNotFoundError,
|
|
175
|
-
'DAYTONA_DAEMON|SESSION_ENDED': DaytonaSessionEndedError,
|
|
176
|
-
'DAYTONA_DAEMON|COMMAND_ALREADY_COMPLETED': DaytonaCommandAlreadyCompletedError,
|
|
177
|
-
'DAYTONA_DAEMON|A11Y_UNAVAILABLE': DaytonaA11yUnavailableError,
|
|
178
|
-
'DAYTONA_DAEMON|RECORDING_STILL_ACTIVE': DaytonaRecordingStillActiveError,
|
|
179
|
-
'DAYTONA_DAEMON|RECORDING_FFMPEG_NOT_FOUND': DaytonaRecordingFfmpegNotFoundError,
|
|
180
|
-
};
|
|
181
|
-
function lookupErrorClass(source, code) {
|
|
182
|
-
if (!code || !source)
|
|
183
|
-
return undefined;
|
|
184
|
-
return CODE_TO_ERROR_CLASS[`${source}|${code}`];
|
|
180
|
+
class DaytonaConnectionError extends DaytonaError {
|
|
185
181
|
}
|
|
182
|
+
exports.DaytonaConnectionError = DaytonaConnectionError;
|
|
186
183
|
const STATUS_CODE_TO_ERROR = {
|
|
187
|
-
400:
|
|
184
|
+
400: DaytonaValidationError,
|
|
188
185
|
401: DaytonaAuthenticationError,
|
|
189
|
-
403:
|
|
186
|
+
403: DaytonaAuthorizationError,
|
|
190
187
|
404: DaytonaNotFoundError,
|
|
191
|
-
408: DaytonaTimeoutError,
|
|
192
188
|
409: DaytonaConflictError,
|
|
193
|
-
410: DaytonaGoneError,
|
|
194
|
-
422: DaytonaUnprocessableEntityError,
|
|
195
189
|
429: DaytonaRateLimitError,
|
|
196
|
-
500: DaytonaInternalServerError,
|
|
197
|
-
502: DaytonaBadGatewayError,
|
|
198
|
-
503: DaytonaServiceUnavailableError,
|
|
199
|
-
504: DaytonaTimeoutError,
|
|
200
190
|
};
|
|
201
|
-
/**
|
|
191
|
+
/**
|
|
192
|
+
* Maps an HTTP status code to the corresponding Daytona error class.
|
|
193
|
+
*/
|
|
202
194
|
function errorClassFromStatusCode(statusCode) {
|
|
203
195
|
if (statusCode === undefined) {
|
|
204
196
|
return DaytonaError;
|
|
@@ -207,12 +199,10 @@ function errorClassFromStatusCode(statusCode) {
|
|
|
207
199
|
}
|
|
208
200
|
/**
|
|
209
201
|
* Creates the appropriate Daytona error subclass from structured error metadata.
|
|
210
|
-
*
|
|
211
|
-
* Resolution order: (source, code) override -> HTTP status code -> DaytonaError.
|
|
212
202
|
*/
|
|
213
|
-
function createDaytonaError(message, statusCode, headers,
|
|
214
|
-
const ErrorClass =
|
|
215
|
-
return new ErrorClass(message, statusCode, headers,
|
|
203
|
+
function createDaytonaError(message, statusCode, headers, errorCode) {
|
|
204
|
+
const ErrorClass = errorClassFromStatusCode(statusCode);
|
|
205
|
+
return new ErrorClass(message, statusCode, headers, errorCode);
|
|
216
206
|
}
|
|
217
207
|
function isAxiosTimeoutError(error) {
|
|
218
208
|
return error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT' || error.message.includes('timeout of');
|
|
@@ -224,10 +214,16 @@ function getAxiosResponseDataObject(error) {
|
|
|
224
214
|
return error.response.data;
|
|
225
215
|
}
|
|
226
216
|
function extractAxiosErrorCode(responseData) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
217
|
+
if (typeof responseData?.code === 'string') {
|
|
218
|
+
return responseData.code;
|
|
219
|
+
}
|
|
220
|
+
if (typeof responseData?.error_code === 'string') {
|
|
221
|
+
return responseData.error_code;
|
|
222
|
+
}
|
|
223
|
+
if (typeof responseData?.error === 'string') {
|
|
224
|
+
return responseData.error;
|
|
225
|
+
}
|
|
226
|
+
return undefined;
|
|
231
227
|
}
|
|
232
228
|
function extractAxiosErrorMessage(error) {
|
|
233
229
|
if (isAxiosTimeoutError(error)) {
|
|
@@ -247,24 +243,20 @@ function extractAxiosErrorMessage(error) {
|
|
|
247
243
|
return String(message);
|
|
248
244
|
}
|
|
249
245
|
/**
|
|
250
|
-
* Creates the appropriate Daytona error subclass from an Axios error.
|
|
251
|
-
* client-side timeouts to DaytonaConnectionTimeoutError, networking failures
|
|
252
|
-
* (no response received) to DaytonaConnectionError, and HTTP responses to
|
|
253
|
-
* the most specific subclass via `createDaytonaError`.
|
|
246
|
+
* Creates the appropriate Daytona error subclass from an Axios error.
|
|
254
247
|
*/
|
|
255
248
|
function createAxiosDaytonaError(error) {
|
|
256
249
|
const message = extractAxiosErrorMessage(error);
|
|
257
250
|
const statusCode = error.response?.status;
|
|
258
251
|
const headers = error.response?.headers;
|
|
259
252
|
const responseData = getAxiosResponseDataObject(error);
|
|
260
|
-
const
|
|
261
|
-
const source = extractAxiosErrorSource(responseData);
|
|
253
|
+
const errorCode = extractAxiosErrorCode(responseData);
|
|
262
254
|
if (isAxiosTimeoutError(error)) {
|
|
263
|
-
return new
|
|
255
|
+
return new DaytonaTimeoutError(message, statusCode, headers, errorCode);
|
|
264
256
|
}
|
|
265
257
|
if (!error.response && (error.request || error.code)) {
|
|
266
|
-
return new DaytonaConnectionError(message, statusCode, headers,
|
|
258
|
+
return new DaytonaConnectionError(message, statusCode, headers, errorCode);
|
|
267
259
|
}
|
|
268
|
-
return createDaytonaError(message, statusCode, headers,
|
|
260
|
+
return createDaytonaError(message, statusCode, headers, errorCode);
|
|
269
261
|
}
|
|
270
262
|
//# sourceMappingURL=DaytonaError.js.map
|