@finalai/sandbox-router-final 0.2.1 → 0.2.2
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 +63 -6
- package/dist/modules/claims.d.mts +3 -0
- package/dist/modules/claims.mjs +24 -0
- package/dist/modules/claims.mjs.map +7 -0
- package/dist/modules/computer.d.mts +7 -0
- package/dist/modules/computer.mjs +57 -0
- package/dist/modules/computer.mjs.map +7 -0
- package/dist/modules/images.d.mts +23 -3
- package/dist/modules/images.mjs +48 -23
- package/dist/modules/images.mjs.map +3 -3
- package/dist/modules/lifecycle.d.mts +25 -0
- package/dist/modules/lifecycle.mjs +46 -0
- package/dist/modules/lifecycle.mjs.map +7 -0
- package/dist/modules/limits.d.mts +1 -0
- package/dist/modules/limits.mjs +20 -1
- package/dist/modules/limits.mjs.map +2 -2
- package/dist/modules/options.d.mts +8 -5
- package/dist/modules/options.mjs +8 -6
- package/dist/modules/options.mjs.map +2 -2
- package/dist/modules/provider.mjs +1016 -127
- package/dist/modules/provider.mjs.map +2 -2
- package/dist/modules/service.d.mts +12 -0
- package/dist/modules/service.mjs +49 -0
- package/dist/modules/service.mjs.map +7 -0
- package/dist/modules/usage.d.mts +7 -0
- package/dist/modules/usage.mjs +50 -0
- package/dist/modules/usage.mjs.map +7 -0
- package/dist/modules/vm/api.d.mts +2 -1
- package/dist/modules/vm/api.mjs +11 -3
- package/dist/modules/vm/api.mjs.map +2 -2
- package/dist/modules/vm/client.d.mts +85 -4
- package/dist/modules/vm/client.mjs +142 -6
- package/dist/modules/vm/client.mjs.map +2 -2
- package/dist/modules/vm/errors.d.mts +2 -0
- package/dist/modules/vm/errors.mjs +2 -1
- package/dist/modules/vm/errors.mjs.map +2 -2
- package/dist/modules/vm/exec.d.mts +1 -0
- package/dist/modules/vm/exec.mjs +2 -0
- package/dist/modules/vm/exec.mjs.map +2 -2
- package/dist/modules/vm/files.d.mts +8 -0
- package/dist/modules/vm/files.mjs +47 -0
- package/dist/modules/vm/files.mjs.map +2 -2
- package/dist/modules/vm/ids.d.mts +1 -0
- package/dist/modules/vm/ids.mjs +2 -0
- package/dist/modules/vm/ids.mjs.map +2 -2
- package/dist/modules/vm/ingress.d.mts +5 -0
- package/dist/modules/vm/ingress.mjs +21 -0
- package/dist/modules/vm/ingress.mjs.map +2 -2
- package/dist/modules/vm/network.d.mts +3 -1
- package/dist/modules/vm/network.mjs +3 -2
- package/dist/modules/vm/network.mjs.map +2 -2
- package/dist/modules/vm/resources.d.mts +251 -0
- package/dist/modules/vm/resources.mjs +210 -0
- package/dist/modules/vm/resources.mjs.map +7 -0
- package/dist/modules/vm/routes.d.mts +55 -0
- package/dist/modules/vm/routes.mjs +61 -0
- package/dist/modules/vm/routes.mjs.map +7 -0
- package/dist/modules/vm/sandbox.d.mts +92 -3
- package/dist/modules/vm/sandbox.mjs +234 -4
- package/dist/modules/vm/sandbox.mjs.map +2 -2
- package/dist/modules/vm/schemas.d.mts +219 -0
- package/dist/modules/vm/schemas.mjs +34 -3
- package/dist/modules/vm/schemas.mjs.map +2 -2
- package/dist/modules/vm/size.d.mts +10 -0
- package/dist/modules/vm/size.mjs +7 -0
- package/dist/modules/vm/size.mjs.map +7 -0
- package/dist/modules/vm/wire.d.mts +3 -0
- package/dist/modules/vm/wire.mjs +6 -0
- package/dist/modules/vm/wire.mjs.map +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare enum IdlePolicy {
|
|
3
|
+
Pause = 1,
|
|
4
|
+
Stop = 2,
|
|
5
|
+
Delete = 3
|
|
6
|
+
}
|
|
7
|
+
export declare enum MaxLifetimeFrom {
|
|
8
|
+
Create = "create",
|
|
9
|
+
Start = "start"
|
|
10
|
+
}
|
|
11
|
+
export declare const maxLifetimeSchema: z.ZodObject<{
|
|
12
|
+
after_s: z.ZodNumber;
|
|
13
|
+
action: z.ZodEnum<{
|
|
14
|
+
stop: "stop";
|
|
15
|
+
delete: "delete";
|
|
16
|
+
}>;
|
|
17
|
+
from: z.ZodEnum<{
|
|
18
|
+
start: "start";
|
|
19
|
+
create: "create";
|
|
20
|
+
}>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export interface MaxLifetimeBodyIface {
|
|
23
|
+
after_s: number;
|
|
24
|
+
action: 'stop' | 'delete';
|
|
25
|
+
from: MaxLifetimeFrom;
|
|
26
|
+
}
|
|
27
|
+
export declare const healthCheckSchema: z.ZodObject<{
|
|
28
|
+
port: z.ZodNumber;
|
|
29
|
+
path: z.ZodString;
|
|
30
|
+
interval_s: z.ZodNumber;
|
|
31
|
+
timeout_s: z.ZodNumber;
|
|
32
|
+
grace_s: z.ZodNumber;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export declare const workloadSchema: z.ZodObject<{
|
|
35
|
+
entrypoint: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
cmd: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
workdir: z.ZodOptional<z.ZodString>;
|
|
38
|
+
user: z.ZodOptional<z.ZodString>;
|
|
39
|
+
restart: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
termination_grace_s: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
health_check: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
port: z.ZodNumber;
|
|
43
|
+
path: z.ZodString;
|
|
44
|
+
interval_s: z.ZodNumber;
|
|
45
|
+
timeout_s: z.ZodNumber;
|
|
46
|
+
grace_s: z.ZodNumber;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
export type WorkloadBodyIface = z.output<typeof workloadSchema>;
|
|
50
|
+
export declare const workloadAnswerSchema: z.ZodObject<{
|
|
51
|
+
workload: z.ZodNullable<z.ZodObject<{
|
|
52
|
+
entrypoint: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
53
|
+
cmd: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
54
|
+
workdir: z.ZodOptional<z.ZodString>;
|
|
55
|
+
user: z.ZodOptional<z.ZodString>;
|
|
56
|
+
restart: z.ZodOptional<z.ZodBoolean>;
|
|
57
|
+
termination_grace_s: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
health_check: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
port: z.ZodNumber;
|
|
60
|
+
path: z.ZodString;
|
|
61
|
+
interval_s: z.ZodNumber;
|
|
62
|
+
timeout_s: z.ZodNumber;
|
|
63
|
+
grace_s: z.ZodNumber;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
health: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
67
|
+
healthy: z.ZodNullable<z.ZodBoolean>;
|
|
68
|
+
error: z.ZodNullable<z.ZodString>;
|
|
69
|
+
checked_at: z.ZodNullable<z.ZodNumber>;
|
|
70
|
+
}, z.core.$strip>>>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
export declare const settingsAnswerSchema: z.ZodObject<{
|
|
73
|
+
auto_resume: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
idle_policy: z.ZodOptional<z.ZodNumber>;
|
|
75
|
+
idle_timeout_s: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
76
|
+
idle_timeout_disabled: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
max_lifetime: z.ZodOptional<z.ZodNullable<z.ZodLazy<z.ZodObject<{
|
|
78
|
+
after_s: z.ZodNumber;
|
|
79
|
+
action: z.ZodEnum<{
|
|
80
|
+
stop: "stop";
|
|
81
|
+
delete: "delete";
|
|
82
|
+
}>;
|
|
83
|
+
from: z.ZodEnum<{
|
|
84
|
+
start: "start";
|
|
85
|
+
create: "create";
|
|
86
|
+
}>;
|
|
87
|
+
}, z.core.$strip>>>>;
|
|
88
|
+
paused_retention_s: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
89
|
+
revision: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
}, z.core.$loose>;
|
|
91
|
+
export declare const eventsAnswerSchema: z.ZodObject<{
|
|
92
|
+
events: z.ZodArray<z.ZodObject<{
|
|
93
|
+
id: z.ZodString;
|
|
94
|
+
generation: z.ZodNullable<z.ZodNumber>;
|
|
95
|
+
state: z.ZodNullable<z.ZodString>;
|
|
96
|
+
created_at: z.ZodNumber;
|
|
97
|
+
}, z.core.$strip>>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
export declare const tokenListSchema: z.ZodObject<{
|
|
100
|
+
tokens: z.ZodArray<z.ZodObject<{
|
|
101
|
+
id: z.ZodString;
|
|
102
|
+
purpose: z.ZodString;
|
|
103
|
+
scopes: z.ZodArray<z.ZodString>;
|
|
104
|
+
expires_at: z.ZodNullable<z.ZodNumber>;
|
|
105
|
+
revoked_at: z.ZodNullable<z.ZodNumber>;
|
|
106
|
+
created_at: z.ZodNumber;
|
|
107
|
+
}, z.core.$strip>>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
export declare const domainSchema: z.ZodObject<{
|
|
110
|
+
id: z.ZodString;
|
|
111
|
+
domain: z.ZodString;
|
|
112
|
+
port: z.ZodNumber;
|
|
113
|
+
status: z.ZodString;
|
|
114
|
+
error: z.ZodNullable<z.ZodString>;
|
|
115
|
+
created_at: z.ZodOptional<z.ZodNumber>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
export declare const domainListSchema: z.ZodObject<{
|
|
118
|
+
domains: z.ZodArray<z.ZodObject<{
|
|
119
|
+
id: z.ZodString;
|
|
120
|
+
domain: z.ZodString;
|
|
121
|
+
port: z.ZodNumber;
|
|
122
|
+
status: z.ZodString;
|
|
123
|
+
error: z.ZodNullable<z.ZodString>;
|
|
124
|
+
created_at: z.ZodOptional<z.ZodNumber>;
|
|
125
|
+
}, z.core.$strip>>;
|
|
126
|
+
cname_target: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
127
|
+
}, z.core.$strip>;
|
|
128
|
+
export declare const desktopStatusSchema: z.ZodObject<{
|
|
129
|
+
state: z.ZodString;
|
|
130
|
+
version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
applied_version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
132
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
export declare const screenAnswerSchema: z.ZodObject<{
|
|
135
|
+
connect: z.ZodObject<{
|
|
136
|
+
endpoint: z.ZodString;
|
|
137
|
+
token: z.ZodString;
|
|
138
|
+
expires_at: z.ZodNumber;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
view_only: z.ZodBoolean;
|
|
141
|
+
ice_servers: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
|
|
142
|
+
viewer_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
export declare const volumeSchema: z.ZodObject<{
|
|
145
|
+
id: z.ZodString;
|
|
146
|
+
name: z.ZodString;
|
|
147
|
+
size_gb: z.ZodNumber;
|
|
148
|
+
version: z.ZodOptional<z.ZodNumber>;
|
|
149
|
+
state: z.ZodString;
|
|
150
|
+
labels: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
151
|
+
}, z.core.$strip>;
|
|
152
|
+
export type VolumeIface = z.output<typeof volumeSchema>;
|
|
153
|
+
export declare const commitSchema: z.ZodObject<{
|
|
154
|
+
id: z.ZodString;
|
|
155
|
+
state: z.ZodString;
|
|
156
|
+
version: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
157
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
158
|
+
}, z.core.$strip>;
|
|
159
|
+
export declare const cacheObjectSchema: z.ZodObject<{
|
|
160
|
+
id: z.ZodString;
|
|
161
|
+
namespace: z.ZodString;
|
|
162
|
+
key: z.ZodString;
|
|
163
|
+
state: z.ZodString;
|
|
164
|
+
size_bytes: z.ZodNullable<z.ZodNumber>;
|
|
165
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
export type CacheObjectIface = z.output<typeof cacheObjectSchema>;
|
|
168
|
+
export declare const cachePartsSchema: z.ZodObject<{
|
|
169
|
+
parts: z.ZodArray<z.ZodObject<{
|
|
170
|
+
part_number: z.ZodNumber;
|
|
171
|
+
url: z.ZodString;
|
|
172
|
+
}, z.core.$strip>>;
|
|
173
|
+
parts_expire_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
export declare const cacheStartSchema: z.ZodObject<{
|
|
176
|
+
parts: z.ZodArray<z.ZodObject<{
|
|
177
|
+
part_number: z.ZodNumber;
|
|
178
|
+
url: z.ZodString;
|
|
179
|
+
}, z.core.$strip>>;
|
|
180
|
+
parts_expire_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
181
|
+
object: z.ZodObject<{
|
|
182
|
+
id: z.ZodString;
|
|
183
|
+
namespace: z.ZodString;
|
|
184
|
+
key: z.ZodString;
|
|
185
|
+
state: z.ZodString;
|
|
186
|
+
size_bytes: z.ZodNullable<z.ZodNumber>;
|
|
187
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
188
|
+
}, z.core.$strip>;
|
|
189
|
+
}, z.core.$strip>;
|
|
190
|
+
export declare const cacheReadSchema: z.ZodObject<{
|
|
191
|
+
object: z.ZodNullable<z.ZodObject<{
|
|
192
|
+
id: z.ZodString;
|
|
193
|
+
namespace: z.ZodString;
|
|
194
|
+
key: z.ZodString;
|
|
195
|
+
state: z.ZodString;
|
|
196
|
+
size_bytes: z.ZodNullable<z.ZodNumber>;
|
|
197
|
+
created_at: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
198
|
+
}, z.core.$strip>>;
|
|
199
|
+
url: z.ZodOptional<z.ZodString>;
|
|
200
|
+
url_expires_at: z.ZodOptional<z.ZodString>;
|
|
201
|
+
}, z.core.$strip>;
|
|
202
|
+
export declare const managedProcessPageSchema: z.ZodObject<{
|
|
203
|
+
processes: z.ZodArray<z.ZodObject<{
|
|
204
|
+
process_id: z.ZodString;
|
|
205
|
+
pid: z.ZodNumber;
|
|
206
|
+
cmd: z.ZodString;
|
|
207
|
+
args: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
208
|
+
user: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
209
|
+
cwd: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
210
|
+
state: z.ZodString;
|
|
211
|
+
started_at_ms: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
212
|
+
ended_at_ms: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
213
|
+
exit_code: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
214
|
+
}, z.core.$loose>>;
|
|
215
|
+
next_process_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
216
|
+
}, z.core.$strip>;
|
|
217
|
+
export declare const guestStatusSchema: z.ZodObject<{
|
|
218
|
+
workload: z.ZodObject<{
|
|
219
|
+
state: z.ZodString;
|
|
220
|
+
exit_code: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
221
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
222
|
+
}, z.core.$strip>;
|
|
223
|
+
}, z.core.$strip>;
|
|
224
|
+
export declare const metricsAnswerSchema: z.ZodObject<{
|
|
225
|
+
step_s: z.ZodNumber;
|
|
226
|
+
from: z.ZodNumber;
|
|
227
|
+
to: z.ZodNumber;
|
|
228
|
+
points: z.ZodArray<z.ZodObject<{
|
|
229
|
+
at: z.ZodNumber;
|
|
230
|
+
cpu_percent: z.ZodNullable<z.ZodNumber>;
|
|
231
|
+
memory_bytes: z.ZodNullable<z.ZodNumber>;
|
|
232
|
+
memory_limit_bytes: z.ZodNullable<z.ZodNumber>;
|
|
233
|
+
rx_bytes: z.ZodNullable<z.ZodNumber>;
|
|
234
|
+
tx_bytes: z.ZodNullable<z.ZodNumber>;
|
|
235
|
+
}, z.core.$strip>>;
|
|
236
|
+
}, z.core.$strip>;
|
|
237
|
+
export declare const chargesAnswerSchema: z.ZodObject<{
|
|
238
|
+
currency: z.ZodString;
|
|
239
|
+
from: z.ZodNumber;
|
|
240
|
+
to: z.ZodNumber;
|
|
241
|
+
settled: z.ZodBoolean;
|
|
242
|
+
total_micros: z.ZodNumber;
|
|
243
|
+
lines: z.ZodArray<z.ZodObject<{
|
|
244
|
+
kind: z.ZodString;
|
|
245
|
+
resource: z.ZodString;
|
|
246
|
+
quantity: z.ZodNumber;
|
|
247
|
+
unit: z.ZodString;
|
|
248
|
+
unit_price_micros: z.ZodNumber;
|
|
249
|
+
amount_micros: z.ZodNumber;
|
|
250
|
+
}, z.core.$strip>>;
|
|
251
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
var IdlePolicy = /* @__PURE__ */ ((IdlePolicy2) => {
|
|
3
|
+
IdlePolicy2[IdlePolicy2["Pause"] = 1] = "Pause";
|
|
4
|
+
IdlePolicy2[IdlePolicy2["Stop"] = 2] = "Stop";
|
|
5
|
+
IdlePolicy2[IdlePolicy2["Delete"] = 3] = "Delete";
|
|
6
|
+
return IdlePolicy2;
|
|
7
|
+
})(IdlePolicy || {});
|
|
8
|
+
var MaxLifetimeFrom = /* @__PURE__ */ ((MaxLifetimeFrom2) => {
|
|
9
|
+
MaxLifetimeFrom2["Create"] = "create";
|
|
10
|
+
MaxLifetimeFrom2["Start"] = "start";
|
|
11
|
+
return MaxLifetimeFrom2;
|
|
12
|
+
})(MaxLifetimeFrom || {});
|
|
13
|
+
const maxLifetimeSchema = z.object({
|
|
14
|
+
after_s: z.number(),
|
|
15
|
+
action: z.enum(["stop", "delete"]),
|
|
16
|
+
from: z.enum(["create", "start"])
|
|
17
|
+
});
|
|
18
|
+
const healthCheckSchema = z.object({
|
|
19
|
+
port: z.number(),
|
|
20
|
+
path: z.string(),
|
|
21
|
+
interval_s: z.number(),
|
|
22
|
+
timeout_s: z.number(),
|
|
23
|
+
grace_s: z.number()
|
|
24
|
+
});
|
|
25
|
+
const workloadSchema = z.object({
|
|
26
|
+
entrypoint: z.array(z.string()).optional(),
|
|
27
|
+
cmd: z.array(z.string()).optional(),
|
|
28
|
+
workdir: z.string().optional(),
|
|
29
|
+
user: z.string().optional(),
|
|
30
|
+
restart: z.boolean().optional(),
|
|
31
|
+
termination_grace_s: z.number().optional(),
|
|
32
|
+
health_check: healthCheckSchema.optional()
|
|
33
|
+
});
|
|
34
|
+
const workloadAnswerSchema = z.object({
|
|
35
|
+
workload: workloadSchema.nullable(),
|
|
36
|
+
health: z.object({
|
|
37
|
+
healthy: z.boolean().nullable(),
|
|
38
|
+
error: z.string().nullable(),
|
|
39
|
+
checked_at: z.number().nullable()
|
|
40
|
+
}).nullable().optional()
|
|
41
|
+
});
|
|
42
|
+
const settingsAnswerSchema = z.object({
|
|
43
|
+
auto_resume: z.boolean().optional(),
|
|
44
|
+
idle_policy: z.number().optional(),
|
|
45
|
+
idle_timeout_s: z.number().nullable().optional(),
|
|
46
|
+
idle_timeout_disabled: z.boolean().optional(),
|
|
47
|
+
max_lifetime: z.lazy(() => maxLifetimeSchema).nullable().optional(),
|
|
48
|
+
paused_retention_s: z.number().nullable().optional(),
|
|
49
|
+
revision: z.number().optional()
|
|
50
|
+
}).loose();
|
|
51
|
+
const eventsAnswerSchema = z.object({
|
|
52
|
+
events: z.array(
|
|
53
|
+
z.object({
|
|
54
|
+
id: z.string(),
|
|
55
|
+
generation: z.number().nullable(),
|
|
56
|
+
state: z.string().nullable(),
|
|
57
|
+
created_at: z.number()
|
|
58
|
+
})
|
|
59
|
+
)
|
|
60
|
+
});
|
|
61
|
+
const tokenListSchema = z.object({
|
|
62
|
+
tokens: z.array(
|
|
63
|
+
z.object({
|
|
64
|
+
id: z.string(),
|
|
65
|
+
purpose: z.string(),
|
|
66
|
+
scopes: z.array(z.string()),
|
|
67
|
+
expires_at: z.number().nullable(),
|
|
68
|
+
revoked_at: z.number().nullable(),
|
|
69
|
+
created_at: z.number()
|
|
70
|
+
})
|
|
71
|
+
)
|
|
72
|
+
});
|
|
73
|
+
const domainSchema = z.object({
|
|
74
|
+
id: z.string(),
|
|
75
|
+
domain: z.string(),
|
|
76
|
+
port: z.number(),
|
|
77
|
+
status: z.string(),
|
|
78
|
+
error: z.string().nullable(),
|
|
79
|
+
created_at: z.number().optional()
|
|
80
|
+
});
|
|
81
|
+
const domainListSchema = z.object({
|
|
82
|
+
domains: z.array(domainSchema),
|
|
83
|
+
cname_target: z.string().nullable().optional()
|
|
84
|
+
});
|
|
85
|
+
const desktopStatusSchema = z.object({
|
|
86
|
+
state: z.string(),
|
|
87
|
+
version: z.string().nullable().optional(),
|
|
88
|
+
applied_version: z.string().nullable().optional(),
|
|
89
|
+
error: z.string().nullable().optional()
|
|
90
|
+
});
|
|
91
|
+
const screenAnswerSchema = z.object({
|
|
92
|
+
connect: z.object({ endpoint: z.string(), token: z.string(), expires_at: z.number() }),
|
|
93
|
+
view_only: z.boolean(),
|
|
94
|
+
ice_servers: z.array(z.unknown()).optional(),
|
|
95
|
+
viewer_url: z.string().nullable().optional()
|
|
96
|
+
});
|
|
97
|
+
const volumeSchema = z.object({
|
|
98
|
+
id: z.string(),
|
|
99
|
+
name: z.string(),
|
|
100
|
+
size_gb: z.number(),
|
|
101
|
+
version: z.number().optional(),
|
|
102
|
+
state: z.string(),
|
|
103
|
+
labels: z.record(z.string(), z.string()).default({})
|
|
104
|
+
});
|
|
105
|
+
const commitSchema = z.object({
|
|
106
|
+
id: z.string(),
|
|
107
|
+
state: z.string(),
|
|
108
|
+
version: z.number().nullable().optional(),
|
|
109
|
+
error: z.string().nullable().optional()
|
|
110
|
+
});
|
|
111
|
+
const cacheObjectSchema = z.object({
|
|
112
|
+
id: z.string(),
|
|
113
|
+
namespace: z.string(),
|
|
114
|
+
key: z.string(),
|
|
115
|
+
state: z.string(),
|
|
116
|
+
size_bytes: z.number().nullable(),
|
|
117
|
+
created_at: z.string().nullable().optional()
|
|
118
|
+
});
|
|
119
|
+
const cachePartsSchema = z.object({
|
|
120
|
+
parts: z.array(z.object({ part_number: z.number(), url: z.string() })),
|
|
121
|
+
parts_expire_at: z.string().nullable().optional()
|
|
122
|
+
});
|
|
123
|
+
const cacheStartSchema = cachePartsSchema.extend({ object: cacheObjectSchema });
|
|
124
|
+
const cacheReadSchema = z.object({
|
|
125
|
+
object: cacheObjectSchema.nullable(),
|
|
126
|
+
url: z.string().optional(),
|
|
127
|
+
url_expires_at: z.string().optional()
|
|
128
|
+
});
|
|
129
|
+
const managedProcessPageSchema = z.object({
|
|
130
|
+
processes: z.array(
|
|
131
|
+
z.object({
|
|
132
|
+
process_id: z.string(),
|
|
133
|
+
pid: z.number(),
|
|
134
|
+
cmd: z.string(),
|
|
135
|
+
args: z.array(z.string()).nullable().optional(),
|
|
136
|
+
user: z.string().nullable().optional(),
|
|
137
|
+
cwd: z.string().nullable().optional(),
|
|
138
|
+
state: z.string(),
|
|
139
|
+
started_at_ms: z.number().nullable().optional(),
|
|
140
|
+
ended_at_ms: z.number().nullable().optional(),
|
|
141
|
+
exit_code: z.number().nullable().optional()
|
|
142
|
+
}).loose()
|
|
143
|
+
),
|
|
144
|
+
next_process_id: z.string().nullable().optional()
|
|
145
|
+
});
|
|
146
|
+
const guestStatusSchema = z.object({
|
|
147
|
+
workload: z.object({
|
|
148
|
+
state: z.string(),
|
|
149
|
+
exit_code: z.number().nullable().optional(),
|
|
150
|
+
error: z.string().nullable().optional()
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
const metricsAnswerSchema = z.object({
|
|
154
|
+
step_s: z.number(),
|
|
155
|
+
from: z.number(),
|
|
156
|
+
to: z.number(),
|
|
157
|
+
points: z.array(
|
|
158
|
+
z.object({
|
|
159
|
+
at: z.number(),
|
|
160
|
+
cpu_percent: z.number().nullable(),
|
|
161
|
+
memory_bytes: z.number().nullable(),
|
|
162
|
+
memory_limit_bytes: z.number().nullable(),
|
|
163
|
+
rx_bytes: z.number().nullable(),
|
|
164
|
+
tx_bytes: z.number().nullable()
|
|
165
|
+
})
|
|
166
|
+
)
|
|
167
|
+
});
|
|
168
|
+
const chargesAnswerSchema = z.object({
|
|
169
|
+
currency: z.string(),
|
|
170
|
+
from: z.number(),
|
|
171
|
+
to: z.number(),
|
|
172
|
+
settled: z.boolean(),
|
|
173
|
+
total_micros: z.number(),
|
|
174
|
+
lines: z.array(
|
|
175
|
+
z.object({
|
|
176
|
+
kind: z.string(),
|
|
177
|
+
resource: z.string(),
|
|
178
|
+
quantity: z.number(),
|
|
179
|
+
unit: z.string(),
|
|
180
|
+
unit_price_micros: z.number(),
|
|
181
|
+
amount_micros: z.number()
|
|
182
|
+
})
|
|
183
|
+
)
|
|
184
|
+
});
|
|
185
|
+
export {
|
|
186
|
+
IdlePolicy,
|
|
187
|
+
MaxLifetimeFrom,
|
|
188
|
+
cacheObjectSchema,
|
|
189
|
+
cachePartsSchema,
|
|
190
|
+
cacheReadSchema,
|
|
191
|
+
cacheStartSchema,
|
|
192
|
+
chargesAnswerSchema,
|
|
193
|
+
commitSchema,
|
|
194
|
+
desktopStatusSchema,
|
|
195
|
+
domainListSchema,
|
|
196
|
+
domainSchema,
|
|
197
|
+
eventsAnswerSchema,
|
|
198
|
+
guestStatusSchema,
|
|
199
|
+
healthCheckSchema,
|
|
200
|
+
managedProcessPageSchema,
|
|
201
|
+
maxLifetimeSchema,
|
|
202
|
+
metricsAnswerSchema,
|
|
203
|
+
screenAnswerSchema,
|
|
204
|
+
settingsAnswerSchema,
|
|
205
|
+
tokenListSchema,
|
|
206
|
+
volumeSchema,
|
|
207
|
+
workloadAnswerSchema,
|
|
208
|
+
workloadSchema
|
|
209
|
+
};
|
|
210
|
+
//# sourceMappingURL=resources.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/vm/resources.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\n\n// Answers of the API's sandbox sub-resources (workload, settings, tokens, domains, desktop,\n// events), volumes and cache objects, and the data plane's process and guest status reads.\n\nexport enum IdlePolicy {\n Pause = 1,\n Stop = 2,\n Delete = 3,\n}\n\n// A sandbox's max lifetime: stop or delete it `after_s` from its creation or latest start, in any\n// state. While set it replaces the wall-clock limit.\nexport enum MaxLifetimeFrom {\n Create = 'create',\n Start = 'start',\n}\n\nexport const maxLifetimeSchema = z.object({\n after_s: z.number(),\n action: z.enum(['stop', 'delete']),\n from: z.enum(['create', 'start']),\n});\n\nexport interface MaxLifetimeBodyIface {\n after_s: number;\n action: 'stop' | 'delete';\n from: MaxLifetimeFrom;\n}\n\nexport const healthCheckSchema = z.object({\n port: z.number(),\n path: z.string(),\n interval_s: z.number(),\n timeout_s: z.number(),\n grace_s: z.number(),\n});\n\nexport const workloadSchema = z.object({\n entrypoint: z.array(z.string()).optional(),\n cmd: z.array(z.string()).optional(),\n workdir: z.string().optional(),\n user: z.string().optional(),\n restart: z.boolean().optional(),\n termination_grace_s: z.number().optional(),\n health_check: healthCheckSchema.optional(),\n});\n\nexport type WorkloadBodyIface = z.output<typeof workloadSchema>;\n\nexport const workloadAnswerSchema = z.object({\n workload: workloadSchema.nullable(),\n health: z\n .object({\n healthy: z.boolean().nullable(),\n error: z.string().nullable(),\n checked_at: z.number().nullable(),\n })\n .nullable()\n .optional(),\n});\n\nexport const settingsAnswerSchema = z\n .object({\n auto_resume: z.boolean().optional(),\n idle_policy: z.number().optional(),\n idle_timeout_s: z.number().nullable().optional(),\n idle_timeout_disabled: z.boolean().optional(),\n max_lifetime: z\n .lazy(() => maxLifetimeSchema)\n .nullable()\n .optional(),\n paused_retention_s: z.number().nullable().optional(),\n revision: z.number().optional(),\n })\n .loose();\n\nexport const eventsAnswerSchema = z.object({\n events: z.array(\n z.object({\n id: z.string(),\n generation: z.number().nullable(),\n state: z.string().nullable(),\n created_at: z.number(),\n }),\n ),\n});\n\nexport const tokenListSchema = z.object({\n tokens: z.array(\n z.object({\n id: z.string(),\n purpose: z.string(),\n scopes: z.array(z.string()),\n expires_at: z.number().nullable(),\n revoked_at: z.number().nullable(),\n created_at: z.number(),\n }),\n ),\n});\n\nexport const domainSchema = z.object({\n id: z.string(),\n domain: z.string(),\n port: z.number(),\n status: z.string(),\n error: z.string().nullable(),\n created_at: z.number().optional(),\n});\n\nexport const domainListSchema = z.object({\n domains: z.array(domainSchema),\n cname_target: z.string().nullable().optional(),\n});\n\nexport const desktopStatusSchema = z.object({\n state: z.string(),\n version: z.string().nullable().optional(),\n applied_version: z.string().nullable().optional(),\n error: z.string().nullable().optional(),\n});\n\nexport const screenAnswerSchema = z.object({\n connect: z.object({ endpoint: z.string(), token: z.string(), expires_at: z.number() }),\n view_only: z.boolean(),\n ice_servers: z.array(z.unknown()).optional(),\n viewer_url: z.string().nullable().optional(),\n});\n\nexport const volumeSchema = z.object({\n id: z.string(),\n name: z.string(),\n size_gb: z.number(),\n version: z.number().optional(),\n state: z.string(),\n labels: z.record(z.string(), z.string()).default({}),\n});\n\nexport type VolumeIface = z.output<typeof volumeSchema>;\n\nexport const commitSchema = z.object({\n id: z.string(),\n state: z.string(),\n version: z.number().nullable().optional(),\n error: z.string().nullable().optional(),\n});\n\nexport const cacheObjectSchema = z.object({\n id: z.string(),\n namespace: z.string(),\n key: z.string(),\n state: z.string(),\n size_bytes: z.number().nullable(),\n created_at: z.string().nullable().optional(),\n});\n\nexport type CacheObjectIface = z.output<typeof cacheObjectSchema>;\n\nexport const cachePartsSchema = z.object({\n parts: z.array(z.object({ part_number: z.number(), url: z.string() })),\n parts_expire_at: z.string().nullable().optional(),\n});\n\nexport const cacheStartSchema = cachePartsSchema.extend({ object: cacheObjectSchema });\n\nexport const cacheReadSchema = z.object({\n object: cacheObjectSchema.nullable(),\n url: z.string().optional(),\n url_expires_at: z.string().optional(),\n});\n\n// Commands started through exec in the current boot, running or ended (`GET\n// \u2026/managed-processes`), a page at a time.\nexport const managedProcessPageSchema = z.object({\n processes: z.array(\n z\n .object({\n process_id: z.string(),\n pid: z.number(),\n cmd: z.string(),\n args: z.array(z.string()).nullable().optional(),\n user: z.string().nullable().optional(),\n cwd: z.string().nullable().optional(),\n state: z.string(),\n started_at_ms: z.number().nullable().optional(),\n ended_at_ms: z.number().nullable().optional(),\n exit_code: z.number().nullable().optional(),\n })\n .loose(),\n ),\n next_process_id: z.string().nullable().optional(),\n});\n\nexport const guestStatusSchema = z.object({\n workload: z.object({\n state: z.string(),\n exit_code: z.number().nullable().optional(),\n error: z.string().nullable().optional(),\n }),\n});\n\n// Unix ms in, unix ms out (`GET /sandboxes/{id}/metrics`).\nexport const metricsAnswerSchema = z.object({\n step_s: z.number(),\n from: z.number(),\n to: z.number(),\n points: z.array(\n z.object({\n at: z.number(),\n cpu_percent: z.number().nullable(),\n memory_bytes: z.number().nullable(),\n memory_limit_bytes: z.number().nullable(),\n rx_bytes: z.number().nullable(),\n tx_bytes: z.number().nullable(),\n }),\n ),\n});\n\n// Micros are whole for `amount_micros` and `total_micros`, fractional for a unit price.\nexport const chargesAnswerSchema = z.object({\n currency: z.string(),\n from: z.number(),\n to: z.number(),\n settled: z.boolean(),\n total_micros: z.number(),\n lines: z.array(\n z.object({\n kind: z.string(),\n resource: z.string(),\n quantity: z.number(),\n unit: z.string(),\n unit_price_micros: z.number(),\n amount_micros: z.number(),\n }),\n ),\n});\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AAKZ,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,wBAAA,WAAQ,KAAR;AACA,EAAAA,wBAAA,UAAO,KAAP;AACA,EAAAA,wBAAA,YAAS,KAAT;AAHU,SAAAA;AAAA,GAAA;AAQL,IAAK,kBAAL,k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as z from 'zod';
|
|
2
|
+
import { type ApiTransport } from "./api.mjs";
|
|
3
|
+
export declare const ingressRouteSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
project_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
hostname: z.ZodString;
|
|
7
|
+
port: z.ZodNumber;
|
|
8
|
+
selector: z.ZodNullable<z.ZodObject<{
|
|
9
|
+
labels: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
health_check: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
12
|
+
path: z.ZodString;
|
|
13
|
+
interval_s: z.ZodNumber;
|
|
14
|
+
timeout_s: z.ZodNumber;
|
|
15
|
+
}, z.core.$strip>>>;
|
|
16
|
+
revision: z.ZodNumber;
|
|
17
|
+
tls: z.ZodObject<{
|
|
18
|
+
state: z.ZodString;
|
|
19
|
+
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
records: z.ZodArray<z.ZodObject<{
|
|
22
|
+
type: z.ZodString;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
value: z.ZodString;
|
|
25
|
+
}, z.core.$strip>>;
|
|
26
|
+
targets: z.ZodArray<z.ZodObject<{
|
|
27
|
+
sandbox_id: z.ZodString;
|
|
28
|
+
healthy: z.ZodBoolean;
|
|
29
|
+
checked_at: z.ZodNullable<z.ZodNumber>;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
created_at: z.ZodNumber;
|
|
32
|
+
updated_at: z.ZodNumber;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type IngressRouteIface = z.output<typeof ingressRouteSchema>;
|
|
35
|
+
export interface IngressRoutesIface {
|
|
36
|
+
create: (options: {
|
|
37
|
+
hostname: string;
|
|
38
|
+
port: number;
|
|
39
|
+
selector: Record<string, string> | null;
|
|
40
|
+
projectId?: string;
|
|
41
|
+
}) => Promise<IngressRouteIface>;
|
|
42
|
+
get: (id: string) => Promise<IngressRouteIface>;
|
|
43
|
+
list: (options: {
|
|
44
|
+
hostname?: string;
|
|
45
|
+
labels?: Record<string, string>;
|
|
46
|
+
projectId?: string;
|
|
47
|
+
}) => Promise<IngressRouteIface[]>;
|
|
48
|
+
update: (id: string, patch: {
|
|
49
|
+
selector?: Record<string, string> | null;
|
|
50
|
+
port?: number;
|
|
51
|
+
expectedRevision?: number;
|
|
52
|
+
}) => Promise<IngressRouteIface>;
|
|
53
|
+
delete: (id: string) => Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export declare const createIngressRoutes: (api: ApiTransport) => IngressRoutesIface;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { HttpMethod, labelQuery } from "./api.mjs";
|
|
3
|
+
const ingressRouteSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
project_id: z.string().nullable().optional(),
|
|
6
|
+
hostname: z.string(),
|
|
7
|
+
port: z.number(),
|
|
8
|
+
selector: z.object({ labels: z.record(z.string(), z.string()) }).nullable(),
|
|
9
|
+
health_check: z.object({ path: z.string(), interval_s: z.number(), timeout_s: z.number() }).nullable().optional(),
|
|
10
|
+
revision: z.number(),
|
|
11
|
+
tls: z.object({ state: z.string(), error: z.string().nullable().optional() }),
|
|
12
|
+
records: z.array(z.object({ type: z.string(), name: z.string(), value: z.string() })),
|
|
13
|
+
targets: z.array(
|
|
14
|
+
z.object({ sandbox_id: z.string(), healthy: z.boolean(), checked_at: z.number().nullable() })
|
|
15
|
+
),
|
|
16
|
+
created_at: z.number(),
|
|
17
|
+
updated_at: z.number()
|
|
18
|
+
});
|
|
19
|
+
const item = (id) => `/ingress-routes/${encodeURIComponent(id)}`;
|
|
20
|
+
const createIngressRoutes = (api) => ({
|
|
21
|
+
create: (options) => api({
|
|
22
|
+
method: HttpMethod.Post,
|
|
23
|
+
path: "/ingress-routes",
|
|
24
|
+
body: {
|
|
25
|
+
hostname: options.hostname,
|
|
26
|
+
port: options.port,
|
|
27
|
+
selector: options.selector == null ? null : { labels: options.selector },
|
|
28
|
+
project_id: options.projectId
|
|
29
|
+
},
|
|
30
|
+
schema: ingressRouteSchema
|
|
31
|
+
}),
|
|
32
|
+
get: (id) => api({ method: HttpMethod.Get, path: item(id), schema: ingressRouteSchema }),
|
|
33
|
+
list: async (options) => (await api({
|
|
34
|
+
method: HttpMethod.Get,
|
|
35
|
+
path: "/ingress-routes",
|
|
36
|
+
query: {
|
|
37
|
+
hostname: options.hostname,
|
|
38
|
+
project_id: options.projectId,
|
|
39
|
+
label: labelQuery(options.labels ?? {})
|
|
40
|
+
},
|
|
41
|
+
schema: z.object({ ingress_routes: z.array(ingressRouteSchema) })
|
|
42
|
+
})).ingress_routes,
|
|
43
|
+
update: (id, patch) => api({
|
|
44
|
+
method: HttpMethod.Patch,
|
|
45
|
+
path: item(id),
|
|
46
|
+
body: {
|
|
47
|
+
selector: patch.selector === void 0 ? void 0 : patch.selector === null ? null : { labels: patch.selector },
|
|
48
|
+
port: patch.port,
|
|
49
|
+
expected_revision: patch.expectedRevision
|
|
50
|
+
},
|
|
51
|
+
schema: ingressRouteSchema
|
|
52
|
+
}),
|
|
53
|
+
delete: async (id) => {
|
|
54
|
+
await api({ method: HttpMethod.Delete, path: item(id), schema: z.unknown() });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
export {
|
|
58
|
+
createIngressRoutes,
|
|
59
|
+
ingressRouteSchema
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=routes.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/vm/routes.ts"],
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport { HttpMethod, labelQuery, type ApiTransport } from \"./api.mjs\";\n\n// Ingress routes (`/ingress-routes`): a hostname of a project served from the project's sandboxes\n// that carry every selector label. A route without a selector holds the hostname and its\n// certificate and serves nothing. Times are unix ms.\n\nexport const ingressRouteSchema = z.object({\n id: z.string(),\n project_id: z.string().nullable().optional(),\n hostname: z.string(),\n port: z.number(),\n selector: z.object({ labels: z.record(z.string(), z.string()) }).nullable(),\n health_check: z\n .object({ path: z.string(), interval_s: z.number(), timeout_s: z.number() })\n .nullable()\n .optional(),\n revision: z.number(),\n tls: z.object({ state: z.string(), error: z.string().nullable().optional() }),\n records: z.array(z.object({ type: z.string(), name: z.string(), value: z.string() })),\n targets: z.array(\n z.object({ sandbox_id: z.string(), healthy: z.boolean(), checked_at: z.number().nullable() }),\n ),\n created_at: z.number(),\n updated_at: z.number(),\n});\n\nexport type IngressRouteIface = z.output<typeof ingressRouteSchema>;\n\nexport interface IngressRoutesIface {\n // Fails with `hostname_taken` (another organization or project holds it), `conflict` (a route of\n // this project holds it), `invalid_hostname`, `reserved_domain` or `not_entitled`.\n create: (options: {\n hostname: string;\n port: number;\n // Null claims the hostname without routing.\n selector: Record<string, string> | null;\n projectId?: string;\n }) => Promise<IngressRouteIface>;\n get: (id: string) => Promise<IngressRouteIface>;\n // At most 500, newest first.\n list: (options: {\n hostname?: string;\n labels?: Record<string, string>;\n projectId?: string;\n }) => Promise<IngressRouteIface[]>;\n // One compare-and-set: `conflict` unless the route is still at `expectedRevision`.\n update: (\n id: string,\n patch: { selector?: Record<string, string> | null; port?: number; expectedRevision?: number },\n ) => Promise<IngressRouteIface>;\n delete: (id: string) => Promise<void>;\n}\n\nconst item = (id: string) => `/ingress-routes/${encodeURIComponent(id)}`;\n\nexport const createIngressRoutes = (api: ApiTransport): IngressRoutesIface => ({\n create: (options) =>\n api({\n method: HttpMethod.Post,\n path: '/ingress-routes',\n body: {\n hostname: options.hostname,\n port: options.port,\n selector: options.selector == null ? null : { labels: options.selector },\n project_id: options.projectId,\n },\n schema: ingressRouteSchema,\n }),\n get: (id) => api({ method: HttpMethod.Get, path: item(id), schema: ingressRouteSchema }),\n list: async (options) =>\n (\n await api({\n method: HttpMethod.Get,\n path: '/ingress-routes',\n query: {\n hostname: options.hostname,\n project_id: options.projectId,\n label: labelQuery(options.labels ?? {}),\n },\n schema: z.object({ ingress_routes: z.array(ingressRouteSchema) }),\n })\n ).ingress_routes,\n update: (id, patch) =>\n api({\n method: HttpMethod.Patch,\n path: item(id),\n body: {\n selector:\n patch.selector === undefined\n ? undefined\n : patch.selector === null\n ? null\n : { labels: patch.selector },\n port: patch.port,\n expected_revision: patch.expectedRevision,\n },\n schema: ingressRouteSchema,\n }),\n delete: async (id) => {\n await api({ method: HttpMethod.Delete, path: item(id), schema: z.unknown() });\n },\n});\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,YAAY,kBAAqC;AAMnD,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAO;AAAA,EACb,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EAC3C,UAAU,EAAE,OAAO;AAAA,EACnB,MAAM,EAAE,OAAO;AAAA,EACf,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,SAAS;AAAA,EAC1E,cAAc,EACX,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,YAAY,EAAE,OAAO,GAAG,WAAW,EAAE,OAAO,EAAE,CAAC,EAC1E,SAAS,EACT,SAAS;AAAA,EACZ,UAAU,EAAE,OAAO;AAAA,EACnB,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAAA,EAC5E,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;AAAA,EACpF,SAAS,EAAE;AAAA,IACT,EAAE,OAAO,EAAE,YAAY,E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