@vercel/sandbox 2.0.0-beta.11 → 2.0.0-beta.13
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/README.md +8 -0
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/api-client/api-client.cjs +456 -0
- package/dist/api-client/api-client.cjs.map +1 -0
- package/dist/api-client/api-client.d.cts +790 -0
- package/dist/api-client/api-client.d.ts +784 -777
- package/dist/api-client/api-client.js +445 -471
- package/dist/api-client/api-client.js.map +1 -1
- package/dist/api-client/api-error.cjs +32 -0
- package/dist/api-client/api-error.cjs.map +1 -0
- package/dist/api-client/api-error.d.cts +29 -0
- package/dist/api-client/api-error.d.ts +21 -18
- package/dist/api-client/api-error.js +28 -33
- package/dist/api-client/api-error.js.map +1 -1
- package/dist/api-client/base-client.cjs +125 -0
- package/dist/api-client/base-client.cjs.map +1 -0
- package/dist/api-client/base-client.d.cts +38 -0
- package/dist/api-client/base-client.d.ts +31 -36
- package/dist/api-client/base-client.js +110 -130
- package/dist/api-client/base-client.js.map +1 -1
- package/dist/api-client/file-writer.cjs +62 -0
- package/dist/api-client/file-writer.cjs.map +1 -0
- package/dist/api-client/file-writer.d.cts +66 -0
- package/dist/api-client/file-writer.d.ts +56 -52
- package/dist/api-client/file-writer.js +57 -61
- package/dist/api-client/file-writer.js.map +1 -1
- package/dist/api-client/index.cjs +2 -0
- package/dist/api-client/index.d.ts +2 -2
- package/dist/api-client/index.js +4 -21
- package/dist/api-client/validators.cjs +182 -0
- package/dist/api-client/validators.cjs.map +1 -0
- package/dist/api-client/validators.d.cts +1469 -0
- package/dist/api-client/validators.d.ts +1282 -3699
- package/dist/api-client/validators.js +155 -170
- package/dist/api-client/validators.js.map +1 -1
- package/dist/api-client/with-retry.cjs +89 -0
- package/dist/api-client/with-retry.cjs.map +1 -0
- package/dist/api-client/with-retry.d.cts +10 -0
- package/dist/api-client/with-retry.d.ts +9 -13
- package/dist/api-client/with-retry.js +81 -102
- package/dist/api-client/with-retry.js.map +1 -1
- package/dist/auth/api.cjs +29 -0
- package/dist/auth/api.cjs.map +1 -0
- package/dist/auth/api.js +26 -25
- package/dist/auth/api.js.map +1 -1
- package/dist/auth/error.cjs +13 -0
- package/dist/auth/error.cjs.map +1 -0
- package/dist/auth/error.js +11 -11
- package/dist/auth/error.js.map +1 -1
- package/dist/auth/file.cjs +64 -0
- package/dist/auth/file.cjs.map +1 -0
- package/dist/auth/file.d.cts +26 -0
- package/dist/auth/file.d.ts +19 -15
- package/dist/auth/file.js +49 -64
- package/dist/auth/file.js.map +1 -1
- package/dist/auth/index.cjs +12 -0
- package/dist/auth/index.d.cts +5 -0
- package/dist/auth/index.d.ts +5 -6
- package/dist/auth/index.js +6 -27
- package/dist/auth/linked-project.cjs +38 -0
- package/dist/auth/linked-project.cjs.map +1 -0
- package/dist/auth/linked-project.js +30 -64
- package/dist/auth/linked-project.js.map +1 -1
- package/dist/auth/oauth.cjs +205 -0
- package/dist/auth/oauth.cjs.map +1 -0
- package/dist/auth/oauth.d.cts +135 -0
- package/dist/auth/oauth.d.ts +113 -109
- package/dist/auth/oauth.js +185 -252
- package/dist/auth/oauth.js.map +1 -1
- package/dist/auth/poll-for-token.cjs +82 -0
- package/dist/auth/poll-for-token.cjs.map +1 -0
- package/dist/auth/poll-for-token.d.cts +28 -0
- package/dist/auth/poll-for-token.d.ts +23 -15
- package/dist/auth/poll-for-token.js +79 -64
- package/dist/auth/poll-for-token.js.map +1 -1
- package/dist/auth/project.cjs +80 -0
- package/dist/auth/project.cjs.map +1 -0
- package/dist/auth/project.d.cts +44 -0
- package/dist/auth/project.d.ts +12 -8
- package/dist/auth/project.js +70 -72
- package/dist/auth/project.js.map +1 -1
- package/dist/auth/zod.cjs +22 -0
- package/dist/auth/zod.cjs.map +1 -0
- package/dist/auth/zod.js +18 -17
- package/dist/auth/zod.js.map +1 -1
- package/dist/command.cjs +328 -0
- package/dist/command.cjs.map +1 -0
- package/dist/command.d.cts +289 -0
- package/dist/command.d.ts +265 -171
- package/dist/command.js +323 -226
- package/dist/command.js.map +1 -1
- package/dist/constants.d.cts +5 -0
- package/dist/constants.d.ts +5 -1
- package/dist/index.cjs +13 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.js +7 -17
- package/dist/network-policy.d.cts +100 -0
- package/dist/network-policy.d.ts +32 -28
- package/dist/sandbox.cjs +694 -0
- package/dist/sandbox.cjs.map +1 -0
- package/dist/sandbox.d.cts +796 -0
- package/dist/sandbox.d.ts +783 -711
- package/dist/sandbox.js +684 -615
- package/dist/sandbox.js.map +1 -1
- package/dist/session.cjs +520 -0
- package/dist/session.cjs.map +1 -0
- package/dist/session.d.cts +406 -0
- package/dist/session.d.ts +398 -367
- package/dist/session.js +517 -505
- package/dist/session.js.map +1 -1
- package/dist/snapshot.cjs +116 -0
- package/dist/snapshot.cjs.map +1 -0
- package/dist/snapshot.d.cts +107 -0
- package/dist/snapshot.d.ts +98 -91
- package/dist/snapshot.js +114 -115
- package/dist/snapshot.js.map +1 -1
- package/dist/utils/array.cjs +17 -0
- package/dist/utils/array.cjs.map +1 -0
- package/dist/utils/array.js +12 -15
- package/dist/utils/array.js.map +1 -1
- package/dist/utils/consume-readable.cjs +18 -0
- package/dist/utils/consume-readable.cjs.map +1 -0
- package/dist/utils/consume-readable.js +13 -12
- package/dist/utils/consume-readable.js.map +1 -1
- package/dist/utils/decode-base64-url.cjs +15 -0
- package/dist/utils/decode-base64-url.cjs.map +1 -0
- package/dist/utils/decode-base64-url.js +10 -9
- package/dist/utils/decode-base64-url.js.map +1 -1
- package/dist/utils/dev-credentials.cjs +142 -0
- package/dist/utils/dev-credentials.cjs.map +1 -0
- package/dist/utils/dev-credentials.js +126 -184
- package/dist/utils/dev-credentials.js.map +1 -1
- package/dist/utils/get-credentials.cjs +123 -0
- package/dist/utils/get-credentials.cjs.map +1 -0
- package/dist/utils/get-credentials.d.cts +21 -0
- package/dist/utils/get-credentials.d.ts +19 -61
- package/dist/utils/get-credentials.js +106 -140
- package/dist/utils/get-credentials.js.map +1 -1
- package/dist/utils/log.cjs +25 -0
- package/dist/utils/log.cjs.map +1 -0
- package/dist/utils/log.js +15 -17
- package/dist/utils/log.js.map +1 -1
- package/dist/utils/network-policy.cjs +65 -0
- package/dist/utils/network-policy.cjs.map +1 -0
- package/dist/utils/network-policy.js +58 -77
- package/dist/utils/network-policy.js.map +1 -1
- package/dist/utils/normalizePath.cjs +27 -0
- package/dist/utils/normalizePath.cjs.map +1 -0
- package/dist/utils/normalizePath.js +21 -28
- package/dist/utils/normalizePath.js.map +1 -1
- package/dist/utils/resolveSignal.cjs +20 -0
- package/dist/utils/resolveSignal.cjs.map +1 -0
- package/dist/utils/resolveSignal.d.cts +15 -0
- package/dist/utils/resolveSignal.d.ts +12 -10
- package/dist/utils/resolveSignal.js +14 -17
- package/dist/utils/resolveSignal.js.map +1 -1
- package/dist/utils/sandbox-snapshot.cjs +14 -0
- package/dist/utils/sandbox-snapshot.cjs.map +1 -0
- package/dist/utils/sandbox-snapshot.d.cts +10 -0
- package/dist/utils/sandbox-snapshot.d.ts +11 -0
- package/dist/utils/sandbox-snapshot.js +14 -0
- package/dist/utils/sandbox-snapshot.js.map +1 -0
- package/dist/utils/types.cjs +13 -0
- package/dist/utils/types.cjs.map +1 -0
- package/dist/utils/types.d.cts +11 -0
- package/dist/utils/types.d.ts +5 -7
- package/dist/utils/types.js +8 -8
- package/dist/utils/types.js.map +1 -1
- package/dist/version.cjs +7 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.js +5 -5
- package/dist/version.js.map +1 -1
- package/package.json +23 -3
- package/dist/api-client/index.js.map +0 -1
- package/dist/auth/api.d.ts +0 -6
- package/dist/auth/error.d.ts +0 -11
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/linked-project.d.ts +0 -10
- package/dist/auth/zod.d.ts +0 -5
- package/dist/constants.js +0 -3
- package/dist/constants.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/network-policy.js +0 -3
- package/dist/network-policy.js.map +0 -1
- package/dist/utils/array.d.ts +0 -9
- package/dist/utils/consume-readable.d.ts +0 -5
- package/dist/utils/convert-sandbox.d.ts +0 -6
- package/dist/utils/convert-sandbox.js +0 -14
- package/dist/utils/convert-sandbox.js.map +0 -1
- package/dist/utils/decode-base64-url.d.ts +0 -7
- package/dist/utils/dev-credentials.d.ts +0 -37
- package/dist/utils/log.d.ts +0 -2
- package/dist/utils/network-policy.d.ts +0 -7
- package/dist/utils/normalizePath.d.ts +0 -17
- package/dist/version.d.ts +0 -1
|
@@ -1,173 +1,158 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
allowedCIDRs: zod_1.z.array(zod_1.z.string()).optional(),
|
|
20
|
-
deniedCIDRs: zod_1.z.array(zod_1.z.string()).optional(),
|
|
21
|
-
injectionRules: zod_1.z.array(exports.InjectionRuleValidator).optional(),
|
|
22
|
-
})
|
|
23
|
-
.passthrough(),
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
//#region src/api-client/validators.ts
|
|
4
|
+
const InjectionRuleValidator = z.object({
|
|
5
|
+
domain: z.string(),
|
|
6
|
+
headers: z.record(z.string()).optional(),
|
|
7
|
+
headerNames: z.array(z.string()).optional()
|
|
8
|
+
});
|
|
9
|
+
const NetworkPolicyValidator = z.union([
|
|
10
|
+
z.object({ mode: z.literal("allow-all") }).passthrough(),
|
|
11
|
+
z.object({ mode: z.literal("deny-all") }).passthrough(),
|
|
12
|
+
z.object({
|
|
13
|
+
mode: z.literal("custom"),
|
|
14
|
+
allowedDomains: z.array(z.string()).optional(),
|
|
15
|
+
allowedCIDRs: z.array(z.string()).optional(),
|
|
16
|
+
deniedCIDRs: z.array(z.string()).optional(),
|
|
17
|
+
injectionRules: z.array(InjectionRuleValidator).optional()
|
|
18
|
+
}).passthrough()
|
|
24
19
|
]);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
stream: zod_1.z.literal("error"),
|
|
117
|
-
data: zod_1.z.object({
|
|
118
|
-
code: zod_1.z.string(),
|
|
119
|
-
message: zod_1.z.string(),
|
|
120
|
-
}),
|
|
121
|
-
});
|
|
122
|
-
exports.LogLine = zod_1.z.discriminatedUnion("stream", [
|
|
123
|
-
exports.LogLineStdout,
|
|
124
|
-
exports.LogLineStderr,
|
|
125
|
-
exports.LogError,
|
|
20
|
+
const Session = z.object({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
memory: z.number(),
|
|
23
|
+
vcpus: z.number(),
|
|
24
|
+
region: z.string(),
|
|
25
|
+
runtime: z.string(),
|
|
26
|
+
timeout: z.number(),
|
|
27
|
+
status: z.enum([
|
|
28
|
+
"pending",
|
|
29
|
+
"running",
|
|
30
|
+
"stopping",
|
|
31
|
+
"stopped",
|
|
32
|
+
"failed",
|
|
33
|
+
"aborted",
|
|
34
|
+
"snapshotting"
|
|
35
|
+
]),
|
|
36
|
+
requestedAt: z.number(),
|
|
37
|
+
startedAt: z.number().optional(),
|
|
38
|
+
requestedStopAt: z.number().optional(),
|
|
39
|
+
stoppedAt: z.number().optional(),
|
|
40
|
+
abortedAt: z.number().optional(),
|
|
41
|
+
duration: z.number().optional(),
|
|
42
|
+
sourceSnapshotId: z.string().optional(),
|
|
43
|
+
snapshottedAt: z.number().optional(),
|
|
44
|
+
createdAt: z.number(),
|
|
45
|
+
cwd: z.string(),
|
|
46
|
+
updatedAt: z.number(),
|
|
47
|
+
interactivePort: z.number().optional(),
|
|
48
|
+
networkPolicy: NetworkPolicyValidator.optional(),
|
|
49
|
+
activeCpuDurationMs: z.number().optional(),
|
|
50
|
+
networkTransfer: z.object({
|
|
51
|
+
ingress: z.number(),
|
|
52
|
+
egress: z.number()
|
|
53
|
+
}).optional()
|
|
54
|
+
});
|
|
55
|
+
const SandboxRoute = z.object({
|
|
56
|
+
url: z.string(),
|
|
57
|
+
subdomain: z.string(),
|
|
58
|
+
port: z.number()
|
|
59
|
+
});
|
|
60
|
+
const Snapshot = z.object({
|
|
61
|
+
id: z.string(),
|
|
62
|
+
sourceSessionId: z.string(),
|
|
63
|
+
region: z.string(),
|
|
64
|
+
status: z.enum([
|
|
65
|
+
"created",
|
|
66
|
+
"deleted",
|
|
67
|
+
"failed"
|
|
68
|
+
]),
|
|
69
|
+
sizeBytes: z.number(),
|
|
70
|
+
expiresAt: z.number().optional(),
|
|
71
|
+
createdAt: z.number(),
|
|
72
|
+
updatedAt: z.number()
|
|
73
|
+
});
|
|
74
|
+
const CursorPagination = z.object({
|
|
75
|
+
count: z.number(),
|
|
76
|
+
next: z.string().nullable()
|
|
77
|
+
});
|
|
78
|
+
const Command = z.object({
|
|
79
|
+
id: z.string(),
|
|
80
|
+
name: z.string(),
|
|
81
|
+
args: z.array(z.string()),
|
|
82
|
+
cwd: z.string(),
|
|
83
|
+
sessionId: z.string(),
|
|
84
|
+
exitCode: z.number().nullable(),
|
|
85
|
+
startedAt: z.number()
|
|
86
|
+
});
|
|
87
|
+
const CommandFinished = Command.extend({ exitCode: z.number() });
|
|
88
|
+
const SessionResponse = z.object({ session: Session.passthrough() });
|
|
89
|
+
const SessionAndRoutesResponse = SessionResponse.extend({ routes: z.array(SandboxRoute) });
|
|
90
|
+
const SessionsResponse = z.object({
|
|
91
|
+
sessions: z.array(Session.passthrough()),
|
|
92
|
+
pagination: CursorPagination
|
|
93
|
+
});
|
|
94
|
+
const CommandResponse = z.object({ command: Command });
|
|
95
|
+
const CommandFinishedResponse = z.object({ command: CommandFinished });
|
|
96
|
+
const EmptyResponse = z.object({});
|
|
97
|
+
const LogLineBase = z.object({ data: z.string() });
|
|
98
|
+
const LogLineStdout = LogLineBase.extend({ stream: z.literal("stdout") });
|
|
99
|
+
const LogLineStderr = LogLineBase.extend({ stream: z.literal("stderr") });
|
|
100
|
+
const LogError = z.object({
|
|
101
|
+
stream: z.literal("error"),
|
|
102
|
+
data: z.object({
|
|
103
|
+
code: z.string(),
|
|
104
|
+
message: z.string()
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
const LogLine = z.discriminatedUnion("stream", [
|
|
108
|
+
LogLineStdout,
|
|
109
|
+
LogLineStderr,
|
|
110
|
+
LogError
|
|
126
111
|
]);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
112
|
+
const SnapshotsResponse = z.object({
|
|
113
|
+
snapshots: z.array(Snapshot),
|
|
114
|
+
pagination: CursorPagination
|
|
115
|
+
});
|
|
116
|
+
const CreateSnapshotResponse = z.object({
|
|
117
|
+
snapshot: Snapshot,
|
|
118
|
+
session: Session.passthrough()
|
|
119
|
+
});
|
|
120
|
+
const SnapshotResponse = z.object({ snapshot: Snapshot });
|
|
121
|
+
const Sandbox = z.object({
|
|
122
|
+
name: z.string(),
|
|
123
|
+
persistent: z.boolean(),
|
|
124
|
+
region: z.string().optional(),
|
|
125
|
+
vcpus: z.number().optional(),
|
|
126
|
+
memory: z.number().optional(),
|
|
127
|
+
runtime: z.string().optional(),
|
|
128
|
+
timeout: z.number().optional(),
|
|
129
|
+
networkPolicy: NetworkPolicyValidator.optional(),
|
|
130
|
+
totalEgressBytes: z.number().optional(),
|
|
131
|
+
totalIngressBytes: z.number().optional(),
|
|
132
|
+
totalActiveCpuDurationMs: z.number().optional(),
|
|
133
|
+
totalDurationMs: z.number().optional(),
|
|
134
|
+
createdAt: z.number(),
|
|
135
|
+
updatedAt: z.number(),
|
|
136
|
+
currentSessionId: z.string(),
|
|
137
|
+
currentSnapshotId: z.string().optional(),
|
|
138
|
+
status: Session.shape.status,
|
|
139
|
+
statusUpdatedAt: z.number().optional(),
|
|
140
|
+
cwd: z.string().optional(),
|
|
141
|
+
tags: z.record(z.string()).optional(),
|
|
142
|
+
snapshotExpiration: z.number().optional()
|
|
143
|
+
});
|
|
144
|
+
const SandboxAndSessionResponse = z.object({
|
|
145
|
+
sandbox: Sandbox,
|
|
146
|
+
session: Session.passthrough(),
|
|
147
|
+
routes: z.array(SandboxRoute),
|
|
148
|
+
resumed: z.boolean().optional()
|
|
149
|
+
});
|
|
150
|
+
const SandboxesPaginationResponse = z.object({
|
|
151
|
+
sandboxes: z.array(Sandbox),
|
|
152
|
+
pagination: CursorPagination
|
|
153
|
+
});
|
|
154
|
+
const UpdateSandboxResponse = z.object({ sandbox: Sandbox });
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
export { Command, CommandFinishedResponse, CommandResponse, CreateSnapshotResponse, CursorPagination, EmptyResponse, InjectionRuleValidator, LogError, LogLine, LogLineStderr, LogLineStdout, NetworkPolicyValidator, Sandbox, SandboxAndSessionResponse, SandboxRoute, SandboxesPaginationResponse, Session, SessionAndRoutesResponse, SessionResponse, SessionsResponse, Snapshot, SnapshotResponse, SnapshotsResponse, UpdateSandboxResponse };
|
|
173
158
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","
|
|
1
|
+
{"version":3,"file":"validators.js","names":[],"sources":["../../src/api-client/validators.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport type SessionMetaData = z.infer<typeof Session>;\n\nexport const InjectionRuleValidator = z.object({\n domain: z.string(),\n // headers are only sent in requests\n headers: z.record(z.string()).optional(),\n // headerNames are returned in responses\n headerNames: z.array(z.string()).optional(),\n});\n\nexport const NetworkPolicyValidator = z.union([\n z.object({ mode: z.literal(\"allow-all\") }).passthrough(),\n z.object({ mode: z.literal(\"deny-all\") }).passthrough(),\n z\n .object({\n mode: z.literal(\"custom\"),\n allowedDomains: z.array(z.string()).optional(),\n allowedCIDRs: z.array(z.string()).optional(),\n deniedCIDRs: z.array(z.string()).optional(),\n injectionRules: z.array(InjectionRuleValidator).optional(),\n })\n .passthrough(),\n]);\n\nexport const Session = z.object({\n id: z.string(),\n memory: z.number(),\n vcpus: z.number(),\n region: z.string(),\n runtime: z.string(),\n timeout: z.number(),\n status: z.enum([\n \"pending\",\n \"running\",\n \"stopping\",\n \"stopped\",\n \"failed\",\n \"aborted\",\n \"snapshotting\",\n ]),\n requestedAt: z.number(),\n startedAt: z.number().optional(),\n requestedStopAt: z.number().optional(),\n stoppedAt: z.number().optional(),\n abortedAt: z.number().optional(),\n duration: z.number().optional(),\n sourceSnapshotId: z.string().optional(),\n snapshottedAt: z.number().optional(),\n createdAt: z.number(),\n cwd: z.string(),\n updatedAt: z.number(),\n interactivePort: z.number().optional(),\n networkPolicy: NetworkPolicyValidator.optional(),\n activeCpuDurationMs: z.number().optional(),\n networkTransfer: z.object({\n ingress: z.number(),\n egress: z.number(),\n }).optional(),\n});\n\nexport type SandboxRouteData = z.infer<typeof SandboxRoute>;\n\nexport const SandboxRoute = z.object({\n url: z.string(),\n subdomain: z.string(),\n port: z.number(),\n});\n\nexport type SnapshotMetadata = z.infer<typeof Snapshot>;\n\nexport const Snapshot = z.object({\n id: z.string(),\n sourceSessionId: z.string(),\n region: z.string(),\n status: z.enum([\"created\", \"deleted\", \"failed\"]),\n sizeBytes: z.number(),\n expiresAt: z.number().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n});\n\nexport const CursorPagination = z.object({\n count: z.number(),\n next: z.string().nullable(),\n});\n\nexport type CommandData = z.infer<typeof Command>;\n\nexport const Command = z.object({\n id: z.string(),\n name: z.string(),\n args: z.array(z.string()),\n cwd: z.string(),\n sessionId: z.string(),\n exitCode: z.number().nullable(),\n startedAt: z.number(),\n});\n\nconst CommandFinished = Command.extend({\n exitCode: z.number(),\n});\n\nexport const SessionResponse = z.object({\n session: Session.passthrough(),\n});\n\nexport const SessionAndRoutesResponse = SessionResponse.extend({\n routes: z.array(SandboxRoute),\n});\n\nexport const SessionsResponse = z.object({\n sessions: z.array(Session.passthrough()),\n pagination: CursorPagination,\n});\n\nexport const CommandResponse = z.object({\n command: Command,\n});\n\nexport type CommandFinishedData = z.infer<typeof CommandFinishedResponse>[\"command\"];\n\nexport const CommandFinishedResponse = z.object({\n command: CommandFinished,\n});\n\nexport const EmptyResponse = z.object({});\n\nconst LogLineBase = z.object({ data: z.string() });\nexport const LogLineStdout = LogLineBase.extend({\n stream: z.literal(\"stdout\"),\n});\nexport const LogLineStderr = LogLineBase.extend({\n stream: z.literal(\"stderr\"),\n});\n\nexport const LogError = z.object({\n stream: z.literal(\"error\"),\n data: z.object({\n code: z.string(),\n message: z.string(),\n }),\n});\n\nexport const LogLine = z.discriminatedUnion(\"stream\", [\n LogLineStdout,\n LogLineStderr,\n LogError,\n]);\n\nexport const SnapshotsResponse = z.object({\n snapshots: z.array(Snapshot),\n pagination: CursorPagination,\n});\n\nexport const CreateSnapshotResponse = z.object({\n snapshot: Snapshot,\n session: Session.passthrough(),\n});\n\nexport const SnapshotResponse = z.object({\n snapshot: Snapshot,\n});\n\nexport const Sandbox = z.object({\n name: z.string(),\n persistent: z.boolean(),\n region: z.string().optional(),\n vcpus: z.number().optional(),\n memory: z.number().optional(),\n runtime: z.string().optional(),\n timeout: z.number().optional(),\n networkPolicy: NetworkPolicyValidator.optional(),\n totalEgressBytes: z.number().optional(),\n totalIngressBytes: z.number().optional(),\n totalActiveCpuDurationMs: z.number().optional(),\n totalDurationMs: z.number().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n currentSessionId: z.string(),\n currentSnapshotId: z.string().optional(),\n status: Session.shape.status,\n statusUpdatedAt: z.number().optional(),\n cwd: z.string().optional(),\n tags: z.record(z.string()).optional(),\n snapshotExpiration: z.number().optional(),\n});\n\nexport type SandboxMetaData = z.infer<typeof Sandbox>;\n\nexport const SandboxAndSessionResponse = z.object({\n sandbox: Sandbox,\n session: Session.passthrough(),\n routes: z.array(SandboxRoute),\n resumed: z.boolean().optional(),\n});\n\nexport const SandboxesPaginationResponse = z.object({\n sandboxes: z.array(Sandbox),\n pagination: CursorPagination,\n});\n\nexport const UpdateSandboxResponse = z.object({\n sandbox: Sandbox,\n});\n"],"mappings":";;;AAIA,MAAa,yBAAyB,EAAE,OAAO;CAC7C,QAAQ,EAAE,QAAQ;CAElB,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,UAAU;CAExC,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;CAC5C,CAAC;AAEF,MAAa,yBAAyB,EAAE,MAAM;CAC5C,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,YAAY,EAAE,CAAC,CAAC,aAAa;CACxD,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,WAAW,EAAE,CAAC,CAAC,aAAa;CACvD,EACG,OAAO;EACN,MAAM,EAAE,QAAQ,SAAS;EACzB,gBAAgB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAC9C,cAAc,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAC5C,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,UAAU;EAC3C,gBAAgB,EAAE,MAAM,uBAAuB,CAAC,UAAU;EAC3D,CAAC,CACD,aAAa;CACjB,CAAC;AAEF,MAAa,UAAU,EAAE,OAAO;CAC9B,IAAI,EAAE,QAAQ;CACd,QAAQ,EAAE,QAAQ;CAClB,OAAO,EAAE,QAAQ;CACjB,Q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AwB,EAAE,OAAO,EAC5C,SAAS,SACV,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_api_error = require('./api-error.cjs');
|
|
3
|
+
let node_timers_promises = require("node:timers/promises");
|
|
4
|
+
let async_retry = require("async-retry");
|
|
5
|
+
async_retry = require_rolldown_runtime.__toESM(async_retry);
|
|
6
|
+
|
|
7
|
+
//#region src/api-client/with-retry.ts
|
|
8
|
+
/**
|
|
9
|
+
* Wraps a fetch function with retry logic. The retry logic will retry
|
|
10
|
+
* on network errors, 429 responses and 5xx responses. The retry logic
|
|
11
|
+
* will not retry on 4xx responses.
|
|
12
|
+
*
|
|
13
|
+
* @param rawFetch The fetch function to wrap.
|
|
14
|
+
* @returns The wrapped fetch function.
|
|
15
|
+
*/
|
|
16
|
+
function withRetry(rawFetch) {
|
|
17
|
+
return async (url, opts = {}) => {
|
|
18
|
+
/**
|
|
19
|
+
* Timeouts by default will be [10, 60, 360, 2160, 12960]
|
|
20
|
+
* before randomization is added.
|
|
21
|
+
*/
|
|
22
|
+
const retryOpts = Object.assign({
|
|
23
|
+
minTimeout: 10,
|
|
24
|
+
retries: 5,
|
|
25
|
+
factor: 6,
|
|
26
|
+
maxRetryAfter: 20
|
|
27
|
+
}, opts.retry);
|
|
28
|
+
if (opts.onRetry) retryOpts.onRetry = (error, attempts) => {
|
|
29
|
+
opts.onRetry(error, opts);
|
|
30
|
+
if (opts.retry && opts.retry.onRetry) opts.retry.onRetry(error, attempts);
|
|
31
|
+
};
|
|
32
|
+
try {
|
|
33
|
+
return await (0, async_retry.default)(async (bail) => {
|
|
34
|
+
try {
|
|
35
|
+
if (opts.signal?.aborted) return bail(opts.signal.reason || /* @__PURE__ */ new Error("Request aborted"));
|
|
36
|
+
const response = await rawFetch(url, opts);
|
|
37
|
+
/**
|
|
38
|
+
* When the response is 429 we will try to parse the Retry-After
|
|
39
|
+
* header. If the header exists we will try to parse it and, if
|
|
40
|
+
* the wait time is higher than the maximum defined, we respond.
|
|
41
|
+
* Otherwise we wait for the time given in the header and throw
|
|
42
|
+
* to retry.
|
|
43
|
+
*/
|
|
44
|
+
if (response.status === 429) {
|
|
45
|
+
const retryAfter = parseInt(response.headers.get("retry-after") || "", 10);
|
|
46
|
+
if (retryAfter && !isNaN(retryAfter)) {
|
|
47
|
+
if (retryAfter > retryOpts.maxRetryAfter) return response;
|
|
48
|
+
await (0, node_timers_promises.setTimeout)(retryAfter * 1e3);
|
|
49
|
+
}
|
|
50
|
+
throw new require_api_error.APIError(response);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* If the response is a a retryable error, we throw in
|
|
54
|
+
* order to retry.
|
|
55
|
+
*/
|
|
56
|
+
if (response.status >= 500 && response.status < 600) throw new require_api_error.APIError(response);
|
|
57
|
+
return response;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
/**
|
|
60
|
+
* If the request was aborted using the AbortController
|
|
61
|
+
* we bail from retrying throwing the original error.
|
|
62
|
+
*/
|
|
63
|
+
if (isAbortError(error)) return bail(error);
|
|
64
|
+
/**
|
|
65
|
+
* If the signal was aborted meanwhile we were
|
|
66
|
+
* waiting, we bail from retrying.
|
|
67
|
+
*/
|
|
68
|
+
if (opts.signal?.aborted) return bail(opts.signal.reason || /* @__PURE__ */ new Error("Request aborted"));
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}, retryOpts);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
/**
|
|
74
|
+
* The ResponseError is only intended for retries so in case we
|
|
75
|
+
* ran out of attempts we will respond with the last response
|
|
76
|
+
* we obtained.
|
|
77
|
+
*/
|
|
78
|
+
if (error instanceof require_api_error.APIError) return error.response;
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function isAbortError(error) {
|
|
84
|
+
return error !== void 0 && error !== null && error.name === "AbortError";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
exports.withRetry = withRetry;
|
|
89
|
+
//# sourceMappingURL=with-retry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with-retry.cjs","names":["APIError"],"sources":["../../src/api-client/with-retry.ts"],"sourcesContent":["import type { Options as RetryOptions } from \"async-retry\";\nimport { APIError } from \"./api-error.js\";\nimport { setTimeout } from \"node:timers/promises\";\nimport retry from \"async-retry\";\n\nexport interface RequestOptions {\n onRetry?(error: any, options: RequestOptions): void;\n retry?: Partial<RetryOptions>;\n}\n\n/**\n * Wraps a fetch function with retry logic. The retry logic will retry\n * on network errors, 429 responses and 5xx responses. The retry logic\n * will not retry on 4xx responses.\n *\n * @param rawFetch The fetch function to wrap.\n * @returns The wrapped fetch function.\n */\nexport function withRetry<T extends RequestInit>(\n rawFetch: (url: URL | string, init?: T) => Promise<Response>,\n) {\n return async (\n url: URL | string,\n opts: T & RequestOptions = <T & RequestOptions>{},\n ) => {\n /**\n * Timeouts by default will be [10, 60, 360, 2160, 12960]\n * before randomization is added.\n */\n const retryOpts = Object.assign(\n {\n minTimeout: 10,\n retries: 5,\n factor: 6,\n maxRetryAfter: 20,\n },\n opts.retry,\n );\n\n if (opts.onRetry) {\n retryOpts.onRetry = (error, attempts) => {\n opts.onRetry!(error, opts);\n if (opts.retry && opts.retry.onRetry) {\n opts.retry.onRetry(error, attempts);\n }\n };\n }\n\n try {\n return (await retry(async (bail) => {\n try {\n if (opts.signal?.aborted) {\n return bail(opts.signal.reason || new Error(\"Request aborted\"));\n }\n const response = await rawFetch(url, opts);\n\n /**\n * When the response is 429 we will try to parse the Retry-After\n * header. If the header exists we will try to parse it and, if\n * the wait time is higher than the maximum defined, we respond.\n * Otherwise we wait for the time given in the header and throw\n * to retry.\n */\n if (response.status === 429) {\n const retryAfter = parseInt(\n response.headers.get(\"retry-after\") || \"\",\n 10,\n );\n\n if (retryAfter && !isNaN(retryAfter)) {\n if (retryAfter > retryOpts.maxRetryAfter) {\n return response;\n }\n\n await setTimeout(retryAfter * 1e3);\n }\n\n throw new APIError(response);\n }\n\n /**\n * If the response is a a retryable error, we throw in\n * order to retry.\n */\n if (response.status >= 500 && response.status < 600) {\n throw new APIError(response);\n }\n\n return response;\n } catch (error) {\n /**\n * If the request was aborted using the AbortController\n * we bail from retrying throwing the original error.\n */\n if (isAbortError(error)) {\n return bail(error);\n }\n\n /**\n * If the signal was aborted meanwhile we were\n * waiting, we bail from retrying.\n */\n if (opts.signal?.aborted) {\n return bail(opts.signal.reason || new Error(\"Request aborted\"));\n }\n\n throw error;\n }\n }, retryOpts)) as Response;\n } catch (error) {\n /**\n * The ResponseError is only intended for retries so in case we\n * ran out of attempts we will respond with the last response\n * we obtained.\n */\n if (error instanceof APIError) {\n return error.response;\n }\n\n throw error;\n }\n };\n}\n\nfunction isAbortError(error: unknown): error is Error {\n return (\n error !== undefined &&\n error !== null &&\n (error as Error).name === \"AbortError\"\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,SAAgB,UACd,UACA;AACA,QAAO,OACL,KACA,OAA+C,EAAE,KAC9C;;;;;EAKH,MAAM,YAAY,OAAO,OACvB;GACE,YAAY;GACZ,SAAS;GACT,QAAQ;GACR,eAAe;GAChB,EACD,KAAK,MACN;AAED,MAAI,KAAK,QACP,WAAU,WAAW,OAAO,aAAa;AACvC,QAAK,QAAS,OAAO,KAAK;AAC1B,OAAI,KAAK,SAAS,KAAK,MAAM,QAC3B,MAAK,MAAM,QAAQ,OAAO,SAAS;;AAKzC,MAAI;AACF,UAAQ,+BAAY,OAAO,SAAS;AAClC,QAAI;AACF,SAAI,KAAK,QAAQ,QACf,QAAO,KAAK,KAAK,OAAO,0BAAU,IAAI,MAAM,kBAAkB,CAAC;KAEjE,MAAM,WAAW,MAAM,SAAS,KAAK,KAAK;;;;;;;;AAS1C,SAAI,SAAS,WAAW,KAAK;MAC3B,MAAM,aAAa,SACjB,SAAS,QAAQ,IAAI,cAAc,IAAI,IACvC,GACD;AAED,UAAI,cAAc,CAAC,MAAM,WAAW,EAAE;AACpC,WAAI,aAAa,UAAU,cACzB,QAAO;AAGT,kDAAiB,aAAa,IAAI;;AAGpC,YAAM,IAAIA,2BAAS,SAAS;;;;;;AAO9B,SAAI,SAAS,UAAU,OAAO,SAAS,SAAS,IAC9C,OAAM,IAAIA,2BAAS,SAAS;AAG9B,YAAO;aACA,OAAO;;;;;AAKd,SAAI,aAAa,MAAM,CACrB,QAAO,KAAK,MAAM;;;;;AAOpB,SAAI,KAAK,QAAQ,QACf,QAAO,KAAK,KAAK,OAAO,0BAAU,IAAI,MAAM,kBAAkB,CAAC;AAGjE,WAAM;;MAEP,UAAU;WACN,OAAO;;;;;;AAMd,OAAI,iBAAiBA,2BACnB,QAAO,MAAM;AAGf,SAAM;;;;AAKZ,SAAS,aAAa,OAAgC;AACpD,QACE,UAAU,UACV,UAAU,QACT,MAAgB,SAAS"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Options } from "async-retry";
|
|
2
|
+
|
|
3
|
+
//#region src/api-client/with-retry.d.ts
|
|
4
|
+
interface RequestOptions {
|
|
5
|
+
onRetry?(error: any, options: RequestOptions): void;
|
|
6
|
+
retry?: Partial<Options>;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { RequestOptions };
|
|
10
|
+
//# sourceMappingURL=with-retry.d.cts.map
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Options } from "async-retry";
|
|
2
|
+
|
|
3
|
+
//#region src/api-client/with-retry.d.ts
|
|
4
|
+
interface RequestOptions {
|
|
5
|
+
onRetry?(error: any, options: RequestOptions): void;
|
|
6
|
+
retry?: Partial<Options>;
|
|
5
7
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* will not retry on 4xx responses.
|
|
10
|
-
*
|
|
11
|
-
* @param rawFetch The fetch function to wrap.
|
|
12
|
-
* @returns The wrapped fetch function.
|
|
13
|
-
*/
|
|
14
|
-
export declare function withRetry<T extends RequestInit>(rawFetch: (url: URL | string, init?: T) => Promise<Response>): (url: URL | string, opts?: T & RequestOptions) => Promise<Response>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { RequestOptions };
|
|
10
|
+
//# sourceMappingURL=with-retry.d.ts.map
|