freestyle-sandboxes 0.0.96 → 0.1.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.
Files changed (69) hide show
  1. package/README.md +39 -48
  2. package/index.cjs +4362 -0
  3. package/index.d.cts +9401 -0
  4. package/index.d.mts +9401 -0
  5. package/index.mjs +4348 -0
  6. package/package.json +16 -109
  7. package/dist/ai/inde.d.cts +0 -75
  8. package/dist/ai/inde.d.mts +0 -75
  9. package/dist/ai/index.cjs +0 -13
  10. package/dist/ai/index.d.cts +0 -75
  11. package/dist/ai/index.d.mts +0 -75
  12. package/dist/ai/index.mjs +0 -4
  13. package/dist/expo/inde.d.cts +0 -6
  14. package/dist/expo/inde.d.mts +0 -6
  15. package/dist/expo/index.cjs +0 -319
  16. package/dist/expo/index.d.cts +0 -6
  17. package/dist/expo/index.d.mts +0 -6
  18. package/dist/expo/index.mjs +0 -297
  19. package/dist/inde.d.cts +0 -373
  20. package/dist/inde.d.mts +0 -373
  21. package/dist/index-BKAG8L-o.mjs +0 -3061
  22. package/dist/index-DuOpIaWc.cjs +0 -3068
  23. package/dist/index.cjs +0 -1329
  24. package/dist/index.d-9H_wnIbz.d.ts +0 -4223
  25. package/dist/index.d.cts +0 -373
  26. package/dist/index.d.mts +0 -373
  27. package/dist/index.mjs +0 -1327
  28. package/dist/langgraph/inde.d.cts +0 -4180
  29. package/dist/langgraph/inde.d.mts +0 -4180
  30. package/dist/langgraph/index.cjs +0 -17155
  31. package/dist/langgraph/index.d.cts +0 -4180
  32. package/dist/langgraph/index.d.mts +0 -4180
  33. package/dist/langgraph/index.mjs +0 -17153
  34. package/dist/mastra/inde.d.cts +0 -2623
  35. package/dist/mastra/inde.d.mts +0 -2623
  36. package/dist/mastra/index.cjs +0 -55
  37. package/dist/mastra/index.d.cts +0 -2623
  38. package/dist/mastra/index.d.mts +0 -2623
  39. package/dist/mastra/index.mjs +0 -53
  40. package/dist/react/dev-server/index..d.cts +0 -33
  41. package/dist/react/dev-server/index..d.mts +0 -33
  42. package/dist/react/dev-server/index.cjs +0 -148
  43. package/dist/react/dev-server/index.d.cts +0 -33
  44. package/dist/react/dev-server/index.d.mts +0 -33
  45. package/dist/react/dev-server/index.mjs +0 -145
  46. package/dist/types.gen-CJa21P0C.d.ts +0 -1902
  47. package/dist/types.gen-DKjMRuu5.d.ts +0 -1898
  48. package/dist/utils/inde.d.cts +0 -10
  49. package/dist/utils/inde.d.mts +0 -10
  50. package/dist/utils/index.cjs +0 -100
  51. package/dist/utils/index.d.cts +0 -10
  52. package/dist/utils/index.d.mts +0 -10
  53. package/dist/utils/index.mjs +0 -75
  54. package/openapi/index.ts +0 -3
  55. package/openapi/sdk.gen.ts +0 -929
  56. package/openapi/types.gen.ts +0 -2234
  57. package/openapi-ts.config.ts +0 -7
  58. package/openapi.json +0 -1
  59. package/src/ai/index.ts +0 -164
  60. package/src/dev-server.ts +0 -95
  61. package/src/expo/_expo_internals.ts +0 -389
  62. package/src/expo/index.ts +0 -26
  63. package/src/index.ts +0 -1459
  64. package/src/langgraph/index.ts +0 -33
  65. package/src/mastra/index.ts +0 -38
  66. package/src/react/dev-server/index.tsx +0 -195
  67. package/src/react/dev-server/types.ts +0 -5
  68. package/src/utils/index.ts +0 -97
  69. package/tsconfig.json +0 -8
package/index.cjs ADDED
@@ -0,0 +1,4362 @@
1
+ 'use strict';
2
+
3
+ function errorFromJSON(body) {
4
+ const ErrorClass = FREESTYLE_ERROR_CODE_MAP[body.code];
5
+ if (ErrorClass) {
6
+ return new ErrorClass(body);
7
+ } else {
8
+ return new Error(`Unknown error code: ${body.code} - ${body.description}`);
9
+ }
10
+ }
11
+ class VmNotFoundInFsError extends Error {
12
+ constructor(body) {
13
+ super(
14
+ `VM_NOT_FOUND_IN_FS: ${body.message}`
15
+ );
16
+ this.body = body;
17
+ this.name = "VmNotFoundInFsError";
18
+ }
19
+ static code = "VM_NOT_FOUND_IN_FS";
20
+ static statusCode = 406;
21
+ static description = `Vm Not found in filesystem`;
22
+ }
23
+ class VmNotRunningError extends Error {
24
+ constructor(body) {
25
+ super(
26
+ `VM_NOT_RUNNING: ${body.message}`
27
+ );
28
+ this.body = body;
29
+ this.name = "VmNotRunningError";
30
+ }
31
+ static code = "VM_NOT_RUNNING";
32
+ static statusCode = 400;
33
+ static description = `VmNotRunning`;
34
+ }
35
+ class VmNotFoundError extends Error {
36
+ constructor(body) {
37
+ super(
38
+ `VM_NOT_FOUND: ${body.message}`
39
+ );
40
+ this.body = body;
41
+ this.name = "VmNotFoundError";
42
+ }
43
+ static code = "VM_NOT_FOUND";
44
+ static statusCode = 404;
45
+ static description = `VmNotFound`;
46
+ }
47
+ class InternalForkVmNotFoundError extends Error {
48
+ constructor(body) {
49
+ super(
50
+ `INTERNAL_FORK_VM_NOT_FOUND: ${body.message}`
51
+ );
52
+ this.body = body;
53
+ this.name = "InternalForkVmNotFoundError";
54
+ }
55
+ static code = "INTERNAL_FORK_VM_NOT_FOUND";
56
+ static statusCode = 404;
57
+ static description = `The VM you're trying to fork from was not found: {fork_vm_id}`;
58
+ }
59
+ class BadRequestError extends Error {
60
+ constructor(body) {
61
+ super(
62
+ `BAD_REQUEST: ${body.message}`
63
+ );
64
+ this.body = body;
65
+ this.name = "BadRequestError";
66
+ }
67
+ static code = "BAD_REQUEST";
68
+ static statusCode = 400;
69
+ static description = `Bad request: {message}`;
70
+ }
71
+ class InternalVmNotFoundError extends Error {
72
+ constructor(body) {
73
+ super(
74
+ `INTERNAL_VM_NOT_FOUND: ${body.message}`
75
+ );
76
+ this.body = body;
77
+ this.name = "InternalVmNotFoundError";
78
+ }
79
+ static code = "INTERNAL_VM_NOT_FOUND";
80
+ static statusCode = 404;
81
+ static description = `VM not found: {vm_id}`;
82
+ }
83
+ class VmMustBeStoppedError extends Error {
84
+ constructor(body) {
85
+ super(
86
+ `VM_MUST_BE_STOPPED: ${body.message}`
87
+ );
88
+ this.body = body;
89
+ this.name = "VmMustBeStoppedError";
90
+ }
91
+ static code = "VM_MUST_BE_STOPPED";
92
+ static statusCode = 400;
93
+ static description = `VM must be stopped before converting to base`;
94
+ }
95
+ class AlreadyHasBaseError extends Error {
96
+ constructor(body) {
97
+ super(
98
+ `ALREADY_HAS_BASE: ${body.message}`
99
+ );
100
+ this.body = body;
101
+ this.name = "AlreadyHasBaseError";
102
+ }
103
+ static code = "ALREADY_HAS_BASE";
104
+ static statusCode = 400;
105
+ static description = `VM already has a base rootfs`;
106
+ }
107
+ class NotFoundError extends Error {
108
+ constructor(body) {
109
+ super(
110
+ `NOT_FOUND: ${body.message}`
111
+ );
112
+ this.body = body;
113
+ this.name = "NotFoundError";
114
+ }
115
+ static code = "NOT_FOUND";
116
+ static statusCode = 404;
117
+ static description = `VM not found`;
118
+ }
119
+ class InternalErrorError extends Error {
120
+ constructor(body) {
121
+ super(
122
+ `INTERNAL_ERROR: ${body.message}`
123
+ );
124
+ this.body = body;
125
+ this.name = "InternalErrorError";
126
+ }
127
+ static code = "INTERNAL_ERROR";
128
+ static statusCode = 500;
129
+ static description = `Internal error: {message}`;
130
+ }
131
+ class DockerImportBadRequestError extends Error {
132
+ constructor(body) {
133
+ super(
134
+ `DOCKER_IMPORT_BAD_REQUEST: ${body.message}`
135
+ );
136
+ this.body = body;
137
+ this.name = "DockerImportBadRequestError";
138
+ }
139
+ static code = "DOCKER_IMPORT_BAD_REQUEST";
140
+ static statusCode = 400;
141
+ static description = `Bad request: {message}`;
142
+ }
143
+ class ForkVmNotFoundError extends Error {
144
+ constructor(body) {
145
+ super(
146
+ `FORK_VM_NOT_FOUND: ${body.message}`
147
+ );
148
+ this.body = body;
149
+ this.name = "ForkVmNotFoundError";
150
+ }
151
+ static code = "FORK_VM_NOT_FOUND";
152
+ static statusCode = 404;
153
+ static description = `Fork VM not found: {fork_vm_id}`;
154
+ }
155
+ class CreateSnapshotBadRequestError extends Error {
156
+ constructor(body) {
157
+ super(
158
+ `CREATE_SNAPSHOT_BAD_REQUEST: ${body.message}`
159
+ );
160
+ this.body = body;
161
+ this.name = "CreateSnapshotBadRequestError";
162
+ }
163
+ static code = "CREATE_SNAPSHOT_BAD_REQUEST";
164
+ static statusCode = 400;
165
+ static description = `Bad request: {message}`;
166
+ }
167
+ class SnapshotVmBadRequestError extends Error {
168
+ constructor(body) {
169
+ super(
170
+ `SNAPSHOT_VM_BAD_REQUEST: ${body.message}`
171
+ );
172
+ this.body = body;
173
+ this.name = "SnapshotVmBadRequestError";
174
+ }
175
+ static code = "SNAPSHOT_VM_BAD_REQUEST";
176
+ static statusCode = 400;
177
+ static description = `Bad request: {message}`;
178
+ }
179
+ class FileNotFoundError extends Error {
180
+ constructor(body) {
181
+ super(
182
+ `FILE_NOT_FOUND: ${body.message}`
183
+ );
184
+ this.body = body;
185
+ this.name = "FileNotFoundError";
186
+ }
187
+ static code = "FILE_NOT_FOUND";
188
+ static statusCode = 404;
189
+ static description = `File not found: {path}`;
190
+ }
191
+ class FilesBadRequestError extends Error {
192
+ constructor(body) {
193
+ super(
194
+ `FILES_BAD_REQUEST: ${body.message}`
195
+ );
196
+ this.body = body;
197
+ this.name = "FilesBadRequestError";
198
+ }
199
+ static code = "FILES_BAD_REQUEST";
200
+ static statusCode = 400;
201
+ static description = `Bad request: {message}`;
202
+ }
203
+ class VmDeletedError extends Error {
204
+ constructor(body) {
205
+ super(
206
+ `VM_DELETED: ${body.message}`
207
+ );
208
+ this.body = body;
209
+ this.name = "VmDeletedError";
210
+ }
211
+ static code = "VM_DELETED";
212
+ static statusCode = 410;
213
+ static description = `Cannot start VM: VM files have been deleted. This VM was ephemeral and its files were removed.`;
214
+ }
215
+ class ReqwestError extends Error {
216
+ constructor(body) {
217
+ super(
218
+ `REQWEST: ${body.message}`
219
+ );
220
+ this.body = body;
221
+ this.name = "ReqwestError";
222
+ }
223
+ static code = "REQWEST";
224
+ static statusCode = 500;
225
+ static description = `Reqwest error`;
226
+ }
227
+ class FirecrackerPidNotFoundError extends Error {
228
+ constructor(body) {
229
+ super(
230
+ `FIRECRACKER_PID_NOT_FOUND: ${body.message}`
231
+ );
232
+ this.body = body;
233
+ this.name = "FirecrackerPidNotFoundError";
234
+ }
235
+ static code = "FIRECRACKER_PID_NOT_FOUND";
236
+ static statusCode = 500;
237
+ static description = `Firecracker PID not found`;
238
+ }
239
+ class FirecrackerApiSocketNotFoundError extends Error {
240
+ constructor(body) {
241
+ super(
242
+ `FIRECRACKER_API_SOCKET_NOT_FOUND: ${body.message}`
243
+ );
244
+ this.body = body;
245
+ this.name = "FirecrackerApiSocketNotFoundError";
246
+ }
247
+ static code = "FIRECRACKER_API_SOCKET_NOT_FOUND";
248
+ static statusCode = 500;
249
+ static description = `Firecracker API socket not found`;
250
+ }
251
+ class VmStartTimeoutError extends Error {
252
+ constructor(body) {
253
+ super(
254
+ `VM_START_TIMEOUT: ${body.message}`
255
+ );
256
+ this.body = body;
257
+ this.name = "VmStartTimeoutError";
258
+ }
259
+ static code = "VM_START_TIMEOUT";
260
+ static statusCode = 504;
261
+ static description = `VM did not become ready within the specified timeout`;
262
+ }
263
+ class VmExitDuringStartError extends Error {
264
+ constructor(body) {
265
+ super(
266
+ `VM_EXIT_DURING_START: ${body.message}`
267
+ );
268
+ this.body = body;
269
+ this.name = "VmExitDuringStartError";
270
+ }
271
+ static code = "VM_EXIT_DURING_START";
272
+ static statusCode = 500;
273
+ static description = `VM process exited unexpectedly during start`;
274
+ }
275
+ class StdIoError extends Error {
276
+ constructor(body) {
277
+ super(
278
+ `STD_IO: ${body.message}`
279
+ );
280
+ this.body = body;
281
+ this.name = "StdIoError";
282
+ }
283
+ static code = "STD_IO";
284
+ static statusCode = 500;
285
+ static description = `Standard IO error`;
286
+ }
287
+ class VmCreateTmuxSessionError extends Error {
288
+ constructor(body) {
289
+ super(
290
+ `VM_CREATE_TMUX_SESSION: ${body.message}`
291
+ );
292
+ this.body = body;
293
+ this.name = "VmCreateTmuxSessionError";
294
+ }
295
+ static code = "VM_CREATE_TMUX_SESSION";
296
+ static statusCode = 500;
297
+ static description = `Failed to create tmux session for VM`;
298
+ }
299
+ class VmSubnetNotFoundError extends Error {
300
+ constructor(body) {
301
+ super(
302
+ `VM_SUBNET_NOT_FOUND: ${body.message}`
303
+ );
304
+ this.body = body;
305
+ this.name = "VmSubnetNotFoundError";
306
+ }
307
+ static code = "VM_SUBNET_NOT_FOUND";
308
+ static statusCode = 500;
309
+ static description = `Subnet for VM not found`;
310
+ }
311
+ class VmOperationDeniedDuringTransactionError extends Error {
312
+ constructor(body) {
313
+ super(
314
+ `VM_OPERATION_DENIED_DURING_TRANSACTION: ${body.message}`
315
+ );
316
+ this.body = body;
317
+ this.name = "VmOperationDeniedDuringTransactionError";
318
+ }
319
+ static code = "VM_OPERATION_DENIED_DURING_TRANSACTION";
320
+ static statusCode = 409;
321
+ static description = `VM operation denied during active transaction for VM {vm_id} in transaction {transaction_id}`;
322
+ }
323
+ class VmTransactionIdMismatchError extends Error {
324
+ constructor(body) {
325
+ super(
326
+ `VM_TRANSACTION_ID_MISMATCH: ${body.message}`
327
+ );
328
+ this.body = body;
329
+ this.name = "VmTransactionIdMismatchError";
330
+ }
331
+ static code = "VM_TRANSACTION_ID_MISMATCH";
332
+ static statusCode = 400;
333
+ static description = `Transaction ID {provided_transaction_id} does not match the current VM transaction {expected_transaction_id} for VM {vm_id}`;
334
+ }
335
+ class VmNotInTransactionError extends Error {
336
+ constructor(body) {
337
+ super(
338
+ `VM_NOT_IN_TRANSACTION: ${body.message}`
339
+ );
340
+ this.body = body;
341
+ this.name = "VmNotInTransactionError";
342
+ }
343
+ static code = "VM_NOT_IN_TRANSACTION";
344
+ static statusCode = 404;
345
+ static description = `VM not in a transaction: {vm_id}`;
346
+ }
347
+ class CreateVmBadRequestError extends Error {
348
+ constructor(body) {
349
+ super(
350
+ `CREATE_VM_BAD_REQUEST: ${body.message}`
351
+ );
352
+ this.body = body;
353
+ this.name = "CreateVmBadRequestError";
354
+ }
355
+ static code = "CREATE_VM_BAD_REQUEST";
356
+ static statusCode = 400;
357
+ static description = `Bad request: {message}`;
358
+ }
359
+ class UserNotFoundError extends Error {
360
+ constructor(body) {
361
+ super(
362
+ `USER_NOT_FOUND: ${body.message}`
363
+ );
364
+ this.body = body;
365
+ this.name = "UserNotFoundError";
366
+ }
367
+ static code = "USER_NOT_FOUND";
368
+ static statusCode = 404;
369
+ static description = `User not found: {user_name}`;
370
+ }
371
+ class UserAlreadyExistsError extends Error {
372
+ constructor(body) {
373
+ super(
374
+ `USER_ALREADY_EXISTS: ${body.message}`
375
+ );
376
+ this.body = body;
377
+ this.name = "UserAlreadyExistsError";
378
+ }
379
+ static code = "USER_ALREADY_EXISTS";
380
+ static statusCode = 409;
381
+ static description = `Conflict: User '{user_name}' already exists`;
382
+ }
383
+ class ValidationErrorError extends Error {
384
+ constructor(body) {
385
+ super(
386
+ `VALIDATION_ERROR: ${body.message}`
387
+ );
388
+ this.body = body;
389
+ this.name = "ValidationErrorError";
390
+ }
391
+ static code = "VALIDATION_ERROR";
392
+ static statusCode = 400;
393
+ static description = `Validation error: {message}`;
394
+ }
395
+ class GroupNotFoundError extends Error {
396
+ constructor(body) {
397
+ super(
398
+ `GROUP_NOT_FOUND: ${body.message}`
399
+ );
400
+ this.body = body;
401
+ this.name = "GroupNotFoundError";
402
+ }
403
+ static code = "GROUP_NOT_FOUND";
404
+ static statusCode = 404;
405
+ static description = `Group not found: {group_name}`;
406
+ }
407
+ class GroupAlreadyExistsError extends Error {
408
+ constructor(body) {
409
+ super(
410
+ `GROUP_ALREADY_EXISTS: ${body.message}`
411
+ );
412
+ this.body = body;
413
+ this.name = "GroupAlreadyExistsError";
414
+ }
415
+ static code = "GROUP_ALREADY_EXISTS";
416
+ static statusCode = 409;
417
+ static description = `Conflict: Group '{group_name}' already exists`;
418
+ }
419
+ class DuplicateUserNameError extends Error {
420
+ constructor(body) {
421
+ super(
422
+ `DUPLICATE_USER_NAME: ${body.message}`
423
+ );
424
+ this.body = body;
425
+ this.name = "DuplicateUserNameError";
426
+ }
427
+ static code = "DUPLICATE_USER_NAME";
428
+ static statusCode = 400;
429
+ static description = `Duplicate user name '{name}' found`;
430
+ }
431
+ class UserGroupEmptyError extends Error {
432
+ constructor(body) {
433
+ super(
434
+ `USER_GROUP_EMPTY: ${body.message}`
435
+ );
436
+ this.body = body;
437
+ this.name = "UserGroupEmptyError";
438
+ }
439
+ static code = "USER_GROUP_EMPTY";
440
+ static statusCode = 400;
441
+ static description = `User '{user}' has empty string in groups`;
442
+ }
443
+ class UserSystemFlagMismatchError extends Error {
444
+ constructor(body) {
445
+ super(
446
+ `USER_SYSTEM_FLAG_MISMATCH: ${body.message}`
447
+ );
448
+ this.body = body;
449
+ this.name = "UserSystemFlagMismatchError";
450
+ }
451
+ static code = "USER_SYSTEM_FLAG_MISMATCH";
452
+ static statusCode = 400;
453
+ static description = `User '{user}' has system=true but UID {uid} is > 999 (system range)`;
454
+ }
455
+ class UserUidOutOfRangeError extends Error {
456
+ constructor(body) {
457
+ super(
458
+ `USER_UID_OUT_OF_RANGE: ${body.message}`
459
+ );
460
+ this.body = body;
461
+ this.name = "UserUidOutOfRangeError";
462
+ }
463
+ static code = "USER_UID_OUT_OF_RANGE";
464
+ static statusCode = 400;
465
+ static description = `User '{user}' has invalid UID {uid} (must be 0-65535)`;
466
+ }
467
+ class UserHomeInvalidError extends Error {
468
+ constructor(body) {
469
+ super(
470
+ `USER_HOME_INVALID: ${body.message}`
471
+ );
472
+ this.body = body;
473
+ this.name = "UserHomeInvalidError";
474
+ }
475
+ static code = "USER_HOME_INVALID";
476
+ static statusCode = 400;
477
+ static description = `User '{user}' has invalid home path '{home}' (must be absolute path starting with /)`;
478
+ }
479
+ class UserShellInvalidError extends Error {
480
+ constructor(body) {
481
+ super(
482
+ `USER_SHELL_INVALID: ${body.message}`
483
+ );
484
+ this.body = body;
485
+ this.name = "UserShellInvalidError";
486
+ }
487
+ static code = "USER_SHELL_INVALID";
488
+ static statusCode = 400;
489
+ static description = `User '{user}' has invalid shell path '{shell}' (must be absolute path starting with /)`;
490
+ }
491
+ class DuplicateGroupNameError extends Error {
492
+ constructor(body) {
493
+ super(
494
+ `DUPLICATE_GROUP_NAME: ${body.message}`
495
+ );
496
+ this.body = body;
497
+ this.name = "DuplicateGroupNameError";
498
+ }
499
+ static code = "DUPLICATE_GROUP_NAME";
500
+ static statusCode = 400;
501
+ static description = `Duplicate group name '{name}' found`;
502
+ }
503
+ class GroupNameReservedError extends Error {
504
+ constructor(body) {
505
+ super(
506
+ `GROUP_NAME_RESERVED: ${body.message}`
507
+ );
508
+ this.body = body;
509
+ this.name = "GroupNameReservedError";
510
+ }
511
+ static code = "GROUP_NAME_RESERVED";
512
+ static statusCode = 400;
513
+ static description = `Group name '{name}' is reserved and cannot be used`;
514
+ }
515
+ class GroupNameInvalidCharsError extends Error {
516
+ constructor(body) {
517
+ super(
518
+ `GROUP_NAME_INVALID_CHARS: ${body.message}`
519
+ );
520
+ this.body = body;
521
+ this.name = "GroupNameInvalidCharsError";
522
+ }
523
+ static code = "GROUP_NAME_INVALID_CHARS";
524
+ static statusCode = 400;
525
+ static description = `Group name '{name}' contains invalid characters (must match [a-z_][a-z0-9_-]*)`;
526
+ }
527
+ class GroupNameTooLongError extends Error {
528
+ constructor(body) {
529
+ super(
530
+ `GROUP_NAME_TOO_LONG: ${body.message}`
531
+ );
532
+ this.body = body;
533
+ this.name = "GroupNameTooLongError";
534
+ }
535
+ static code = "GROUP_NAME_TOO_LONG";
536
+ static statusCode = 400;
537
+ static description = `Group name '{name}' is too long (max {max_length} characters)`;
538
+ }
539
+ class GroupNameEmptyError extends Error {
540
+ constructor(body) {
541
+ super(
542
+ `GROUP_NAME_EMPTY: ${body.message}`
543
+ );
544
+ this.body = body;
545
+ this.name = "GroupNameEmptyError";
546
+ }
547
+ static code = "GROUP_NAME_EMPTY";
548
+ static statusCode = 400;
549
+ static description = `Group name cannot be empty`;
550
+ }
551
+ class WantedByEmptyError extends Error {
552
+ constructor(body) {
553
+ super(
554
+ `WANTED_BY_EMPTY: ${body.message}`
555
+ );
556
+ this.body = body;
557
+ this.name = "WantedByEmptyError";
558
+ }
559
+ static code = "WANTED_BY_EMPTY";
560
+ static statusCode = 400;
561
+ static description = `wanted_by cannot be empty if provided`;
562
+ }
563
+ class WorkdirEmptyError extends Error {
564
+ constructor(body) {
565
+ super(
566
+ `WORKDIR_EMPTY: ${body.message}`
567
+ );
568
+ this.body = body;
569
+ this.name = "WorkdirEmptyError";
570
+ }
571
+ static code = "WORKDIR_EMPTY";
572
+ static statusCode = 400;
573
+ static description = `Working directory cannot be empty if provided`;
574
+ }
575
+ class GroupEmptyError extends Error {
576
+ constructor(body) {
577
+ super(
578
+ `GROUP_EMPTY: ${body.message}`
579
+ );
580
+ this.body = body;
581
+ this.name = "GroupEmptyError";
582
+ }
583
+ static code = "GROUP_EMPTY";
584
+ static statusCode = 400;
585
+ static description = `Group cannot be empty if provided`;
586
+ }
587
+ class UserEmptyError extends Error {
588
+ constructor(body) {
589
+ super(
590
+ `USER_EMPTY: ${body.message}`
591
+ );
592
+ this.body = body;
593
+ this.name = "UserEmptyError";
594
+ }
595
+ static code = "USER_EMPTY";
596
+ static statusCode = 400;
597
+ static description = `User cannot be empty if provided`;
598
+ }
599
+ class OnFailureArrayContainsEmptyError extends Error {
600
+ constructor(body) {
601
+ super(
602
+ `ON_FAILURE_ARRAY_CONTAINS_EMPTY: ${body.message}`
603
+ );
604
+ this.body = body;
605
+ this.name = "OnFailureArrayContainsEmptyError";
606
+ }
607
+ static code = "ON_FAILURE_ARRAY_CONTAINS_EMPTY";
608
+ static statusCode = 400;
609
+ static description = `'onFailure' array cannot contain empty strings`;
610
+ }
611
+ class RequiresArrayContainsEmptyError extends Error {
612
+ constructor(body) {
613
+ super(
614
+ `REQUIRES_ARRAY_CONTAINS_EMPTY: ${body.message}`
615
+ );
616
+ this.body = body;
617
+ this.name = "RequiresArrayContainsEmptyError";
618
+ }
619
+ static code = "REQUIRES_ARRAY_CONTAINS_EMPTY";
620
+ static statusCode = 400;
621
+ static description = `'requires' array cannot contain empty strings`;
622
+ }
623
+ class AfterArrayContainsEmptyError extends Error {
624
+ constructor(body) {
625
+ super(
626
+ `AFTER_ARRAY_CONTAINS_EMPTY: ${body.message}`
627
+ );
628
+ this.body = body;
629
+ this.name = "AfterArrayContainsEmptyError";
630
+ }
631
+ static code = "AFTER_ARRAY_CONTAINS_EMPTY";
632
+ static statusCode = 400;
633
+ static description = `'after' array cannot contain empty strings`;
634
+ }
635
+ class EnvKeyContainsEqualsError extends Error {
636
+ constructor(body) {
637
+ super(
638
+ `ENV_KEY_CONTAINS_EQUALS: ${body.message}`
639
+ );
640
+ this.body = body;
641
+ this.name = "EnvKeyContainsEqualsError";
642
+ }
643
+ static code = "ENV_KEY_CONTAINS_EQUALS";
644
+ static statusCode = 400;
645
+ static description = `Environment variable key '{key}' cannot contain '='`;
646
+ }
647
+ class EnvKeyEmptyError extends Error {
648
+ constructor(body) {
649
+ super(
650
+ `ENV_KEY_EMPTY: ${body.message}`
651
+ );
652
+ this.body = body;
653
+ this.name = "EnvKeyEmptyError";
654
+ }
655
+ static code = "ENV_KEY_EMPTY";
656
+ static statusCode = 400;
657
+ static description = `Environment variable key cannot be empty`;
658
+ }
659
+ class ExecEmptyError extends Error {
660
+ constructor(body) {
661
+ super(
662
+ `EXEC_EMPTY: ${body.message}`
663
+ );
664
+ this.body = body;
665
+ this.name = "ExecEmptyError";
666
+ }
667
+ static code = "EXEC_EMPTY";
668
+ static statusCode = 400;
669
+ static description = `Executable path (exec) cannot be empty`;
670
+ }
671
+ class ServiceNameTooLongError extends Error {
672
+ constructor(body) {
673
+ super(
674
+ `SERVICE_NAME_TOO_LONG: ${body.message}`
675
+ );
676
+ this.body = body;
677
+ this.name = "ServiceNameTooLongError";
678
+ }
679
+ static code = "SERVICE_NAME_TOO_LONG";
680
+ static statusCode = 400;
681
+ static description = `Service name '{name}' is too long (max {max_length} characters)`;
682
+ }
683
+ class ServiceNameInvalidPrefixError extends Error {
684
+ constructor(body) {
685
+ super(
686
+ `SERVICE_NAME_INVALID_PREFIX: ${body.message}`
687
+ );
688
+ this.body = body;
689
+ this.name = "ServiceNameInvalidPrefixError";
690
+ }
691
+ static code = "SERVICE_NAME_INVALID_PREFIX";
692
+ static statusCode = 400;
693
+ static description = `Service name '{name}' cannot start with '.' or '-'`;
694
+ }
695
+ class ServiceNameInvalidCharsError extends Error {
696
+ constructor(body) {
697
+ super(
698
+ `SERVICE_NAME_INVALID_CHARS: ${body.message}`
699
+ );
700
+ this.body = body;
701
+ this.name = "ServiceNameInvalidCharsError";
702
+ }
703
+ static code = "SERVICE_NAME_INVALID_CHARS";
704
+ static statusCode = 400;
705
+ static description = `Service name '{name}' contains invalid characters (/ or null)`;
706
+ }
707
+ class ServiceNameEmptyError extends Error {
708
+ constructor(body) {
709
+ super(
710
+ `SERVICE_NAME_EMPTY: ${body.message}`
711
+ );
712
+ this.body = body;
713
+ this.name = "ServiceNameEmptyError";
714
+ }
715
+ static code = "SERVICE_NAME_EMPTY";
716
+ static statusCode = 400;
717
+ static description = `Service name cannot be empty`;
718
+ }
719
+ class ServiceAlreadyExistsError extends Error {
720
+ constructor(body) {
721
+ super(
722
+ `SERVICE_ALREADY_EXISTS: ${body.message}`
723
+ );
724
+ this.body = body;
725
+ this.name = "ServiceAlreadyExistsError";
726
+ }
727
+ static code = "SERVICE_ALREADY_EXISTS";
728
+ static statusCode = 409;
729
+ static description = `Service '{service_name}' already exists`;
730
+ }
731
+ class ServiceNotFoundError extends Error {
732
+ constructor(body) {
733
+ super(
734
+ `SERVICE_NOT_FOUND: ${body.message}`
735
+ );
736
+ this.body = body;
737
+ this.name = "ServiceNotFoundError";
738
+ }
739
+ static code = "SERVICE_NOT_FOUND";
740
+ static statusCode = 404;
741
+ static description = `null`;
742
+ }
743
+ class InternalError extends Error {
744
+ constructor(body) {
745
+ super(
746
+ `INTERNAL: ${body.message}`
747
+ );
748
+ this.body = body;
749
+ this.name = "InternalError";
750
+ }
751
+ static code = "INTERNAL";
752
+ static statusCode = 500;
753
+ static description = `Internal error: {0}`;
754
+ }
755
+ class SigningError extends Error {
756
+ constructor(body) {
757
+ super(
758
+ `SIGNING: ${body.message}`
759
+ );
760
+ this.body = body;
761
+ this.name = "SigningError";
762
+ }
763
+ static code = "SIGNING";
764
+ static statusCode = 500;
765
+ static description = `Signing error`;
766
+ }
767
+ class InvalidSignatureError extends Error {
768
+ constructor(body) {
769
+ super(
770
+ `INVALID_SIGNATURE: ${body.message}`
771
+ );
772
+ this.body = body;
773
+ this.name = "InvalidSignatureError";
774
+ }
775
+ static code = "INVALID_SIGNATURE";
776
+ static statusCode = 403;
777
+ static description = `Invalid signature`;
778
+ }
779
+ class InvalidParametersError extends Error {
780
+ constructor(body) {
781
+ super(
782
+ `INVALID_PARAMETERS: ${body.message}`
783
+ );
784
+ this.body = body;
785
+ this.name = "InvalidParametersError";
786
+ }
787
+ static code = "INVALID_PARAMETERS";
788
+ static statusCode = 400;
789
+ static description = `Invalid parameters`;
790
+ }
791
+ class MaxUsesExceededError extends Error {
792
+ constructor(body) {
793
+ super(
794
+ `MAX_USES_EXCEEDED: ${body.message}`
795
+ );
796
+ this.body = body;
797
+ this.name = "MaxUsesExceededError";
798
+ }
799
+ static code = "MAX_USES_EXCEEDED";
800
+ static statusCode = 403;
801
+ static description = `Session maximum uses exceeded`;
802
+ }
803
+ class ExpiredError extends Error {
804
+ constructor(body) {
805
+ super(
806
+ `EXPIRED: ${body.message}`
807
+ );
808
+ this.body = body;
809
+ this.name = "ExpiredError";
810
+ }
811
+ static code = "EXPIRED";
812
+ static statusCode = 403;
813
+ static description = `Session has expired`;
814
+ }
815
+ class ConflictError extends Error {
816
+ constructor(body) {
817
+ super(
818
+ `CONFLICT: ${body.message}`
819
+ );
820
+ this.body = body;
821
+ this.name = "ConflictError";
822
+ }
823
+ static code = "CONFLICT";
824
+ static statusCode = 409;
825
+ static description = `Sync conflict: {message}`;
826
+ }
827
+ class RepoNotFoundError extends Error {
828
+ constructor(body) {
829
+ super(
830
+ `REPO_NOT_FOUND: ${body.message}`
831
+ );
832
+ this.body = body;
833
+ this.name = "RepoNotFoundError";
834
+ }
835
+ static code = "REPO_NOT_FOUND";
836
+ static statusCode = 404;
837
+ static description = `Repository not found`;
838
+ }
839
+ class ForbiddenError extends Error {
840
+ constructor(body) {
841
+ super(
842
+ `FORBIDDEN: ${body.message}`
843
+ );
844
+ this.body = body;
845
+ this.name = "ForbiddenError";
846
+ }
847
+ static code = "FORBIDDEN";
848
+ static statusCode = 403;
849
+ static description = `Forbidden: {message}`;
850
+ }
851
+ class UnsupportedTransferError extends Error {
852
+ constructor(body) {
853
+ super(
854
+ `UNSUPPORTED_TRANSFER: ${body.message}`
855
+ );
856
+ this.body = body;
857
+ this.name = "UnsupportedTransferError";
858
+ }
859
+ static code = "UNSUPPORTED_TRANSFER";
860
+ static statusCode = 400;
861
+ static description = `Unsupported LFS transfer protocol(s)`;
862
+ }
863
+ class BranchNotFoundError extends Error {
864
+ constructor(body) {
865
+ super(
866
+ `BRANCH_NOT_FOUND: ${body.message}`
867
+ );
868
+ this.body = body;
869
+ this.name = "BranchNotFoundError";
870
+ }
871
+ static code = "BRANCH_NOT_FOUND";
872
+ static statusCode = 404;
873
+ static description = `Branch not found: {branch}`;
874
+ }
875
+ class InvalidObjectIdError extends Error {
876
+ constructor(body) {
877
+ super(
878
+ `INVALID_OBJECT_ID: ${body.message}`
879
+ );
880
+ this.body = body;
881
+ this.name = "InvalidObjectIdError";
882
+ }
883
+ static code = "INVALID_OBJECT_ID";
884
+ static statusCode = 400;
885
+ static description = `Invalid object ID`;
886
+ }
887
+ class BlobNotFoundError extends Error {
888
+ constructor(body) {
889
+ super(
890
+ `BLOB_NOT_FOUND: ${body.message}`
891
+ );
892
+ this.body = body;
893
+ this.name = "BlobNotFoundError";
894
+ }
895
+ static code = "BLOB_NOT_FOUND";
896
+ static statusCode = 404;
897
+ static description = `Blob not found: {hash}`;
898
+ }
899
+ class ReferenceNotFoundError extends Error {
900
+ constructor(body) {
901
+ super(
902
+ `REFERENCE_NOT_FOUND: ${body.message}`
903
+ );
904
+ this.body = body;
905
+ this.name = "ReferenceNotFoundError";
906
+ }
907
+ static code = "REFERENCE_NOT_FOUND";
908
+ static statusCode = 404;
909
+ static description = `Reference not found: {reference}`;
910
+ }
911
+ class TagNotFoundError extends Error {
912
+ constructor(body) {
913
+ super(
914
+ `TAG_NOT_FOUND: ${body.message}`
915
+ );
916
+ this.body = body;
917
+ this.name = "TagNotFoundError";
918
+ }
919
+ static code = "TAG_NOT_FOUND";
920
+ static statusCode = 404;
921
+ static description = `Tag not found: {tag}`;
922
+ }
923
+ class CommitNotFoundError extends Error {
924
+ constructor(body) {
925
+ super(
926
+ `COMMIT_NOT_FOUND: ${body.message}`
927
+ );
928
+ this.body = body;
929
+ this.name = "CommitNotFoundError";
930
+ }
931
+ static code = "COMMIT_NOT_FOUND";
932
+ static statusCode = 404;
933
+ static description = `Commit not found: {hash}`;
934
+ }
935
+ class InvalidRequestError extends Error {
936
+ constructor(body) {
937
+ super(
938
+ `INVALID_REQUEST: ${body.message}`
939
+ );
940
+ this.body = body;
941
+ this.name = "InvalidRequestError";
942
+ }
943
+ static code = "INVALID_REQUEST";
944
+ static statusCode = 400;
945
+ static description = `Invalid request: {message}`;
946
+ }
947
+ class PathNotFoundError extends Error {
948
+ constructor(body) {
949
+ super(
950
+ `PATH_NOT_FOUND: ${body.message}`
951
+ );
952
+ this.body = body;
953
+ this.name = "PathNotFoundError";
954
+ }
955
+ static code = "PATH_NOT_FOUND";
956
+ static statusCode = 404;
957
+ static description = `Path not found: {path}`;
958
+ }
959
+ class InvalidRevisionError extends Error {
960
+ constructor(body) {
961
+ super(
962
+ `INVALID_REVISION: ${body.message}`
963
+ );
964
+ this.body = body;
965
+ this.name = "InvalidRevisionError";
966
+ }
967
+ static code = "INVALID_REVISION";
968
+ static statusCode = 400;
969
+ static description = `null`;
970
+ }
971
+ class UnauthorizedError extends Error {
972
+ constructor(body) {
973
+ super(
974
+ `UNAUTHORIZED: ${body.message}`
975
+ );
976
+ this.body = body;
977
+ this.name = "UnauthorizedError";
978
+ }
979
+ static code = "UNAUTHORIZED";
980
+ static statusCode = 401;
981
+ static description = `Unauthorized`;
982
+ }
983
+ class TreeNotFoundError extends Error {
984
+ constructor(body) {
985
+ super(
986
+ `TREE_NOT_FOUND: ${body.message}`
987
+ );
988
+ this.body = body;
989
+ this.name = "TreeNotFoundError";
990
+ }
991
+ static code = "TREE_NOT_FOUND";
992
+ static statusCode = 404;
993
+ static description = `Tree not found: {hash}`;
994
+ }
995
+ class BuildFailedError extends Error {
996
+ constructor(body) {
997
+ super(
998
+ `BUILD_FAILED: ${body.message}`
999
+ );
1000
+ this.body = body;
1001
+ this.name = "BuildFailedError";
1002
+ }
1003
+ static code = "BUILD_FAILED";
1004
+ static statusCode = 500;
1005
+ static description = `Build failed on VM {vm_id}`;
1006
+ }
1007
+ class NoEntrypointFoundError extends Error {
1008
+ constructor(body) {
1009
+ super(
1010
+ `NO_ENTRYPOINT_FOUND: ${body.message}`
1011
+ );
1012
+ this.body = body;
1013
+ this.name = "NoEntrypointFoundError";
1014
+ }
1015
+ static code = "NO_ENTRYPOINT_FOUND";
1016
+ static statusCode = 400;
1017
+ static description = `No entrypoint found in deployment`;
1018
+ }
1019
+ class EntrypointNotFoundError extends Error {
1020
+ constructor(body) {
1021
+ super(
1022
+ `ENTRYPOINT_NOT_FOUND: ${body.message}`
1023
+ );
1024
+ this.body = body;
1025
+ this.name = "EntrypointNotFoundError";
1026
+ }
1027
+ static code = "ENTRYPOINT_NOT_FOUND";
1028
+ static statusCode = 400;
1029
+ static description = `Entrypoint not found: {entrypoint}`;
1030
+ }
1031
+ class NoDomainOwnershipError extends Error {
1032
+ constructor(body) {
1033
+ super(
1034
+ `NO_DOMAIN_OWNERSHIP: ${body.message}`
1035
+ );
1036
+ this.body = body;
1037
+ this.name = "NoDomainOwnershipError";
1038
+ }
1039
+ static code = "NO_DOMAIN_OWNERSHIP";
1040
+ static statusCode = 403;
1041
+ static description = `No domain ownership for: {domain}`;
1042
+ }
1043
+ class InvalidDomainsError extends Error {
1044
+ constructor(body) {
1045
+ super(
1046
+ `INVALID_DOMAINS: ${body.message}`
1047
+ );
1048
+ this.body = body;
1049
+ this.name = "InvalidDomainsError";
1050
+ }
1051
+ static code = "INVALID_DOMAINS";
1052
+ static statusCode = 400;
1053
+ static description = `Invalid domains provided`;
1054
+ }
1055
+ class WebDeploymentBadRequestError extends Error {
1056
+ constructor(body) {
1057
+ super(
1058
+ `WEB_DEPLOYMENT_BAD_REQUEST: ${body.message}`
1059
+ );
1060
+ this.body = body;
1061
+ this.name = "WebDeploymentBadRequestError";
1062
+ }
1063
+ static code = "WEB_DEPLOYMENT_BAD_REQUEST";
1064
+ static statusCode = 400;
1065
+ static description = `Bad request: {message}`;
1066
+ }
1067
+ class DeploymentNotFoundError extends Error {
1068
+ constructor(body) {
1069
+ super(
1070
+ `DEPLOYMENT_NOT_FOUND: ${body.message}`
1071
+ );
1072
+ this.body = body;
1073
+ this.name = "DeploymentNotFoundError";
1074
+ }
1075
+ static code = "DEPLOYMENT_NOT_FOUND";
1076
+ static statusCode = 404;
1077
+ static description = `Deployment not found`;
1078
+ }
1079
+ class DatabaseErrorError extends Error {
1080
+ constructor(body) {
1081
+ super(
1082
+ `DATABASE_ERROR: ${body.message}`
1083
+ );
1084
+ this.body = body;
1085
+ this.name = "DatabaseErrorError";
1086
+ }
1087
+ static code = "DATABASE_ERROR";
1088
+ static statusCode = 500;
1089
+ static description = `Database operation failed: {message}`;
1090
+ }
1091
+ class TriggerErrorError extends Error {
1092
+ constructor(body) {
1093
+ super(
1094
+ `TRIGGER_ERROR: ${body.message}`
1095
+ );
1096
+ this.body = body;
1097
+ this.name = "TriggerErrorError";
1098
+ }
1099
+ static code = "TRIGGER_ERROR";
1100
+ static statusCode = 500;
1101
+ static description = `Failed to manage triggers: {message}`;
1102
+ }
1103
+ class TokenErrorError extends Error {
1104
+ constructor(body) {
1105
+ super(
1106
+ `TOKEN_ERROR: ${body.message}`
1107
+ );
1108
+ this.body = body;
1109
+ this.name = "TokenErrorError";
1110
+ }
1111
+ static code = "TOKEN_ERROR";
1112
+ static statusCode = 500;
1113
+ static description = `Failed to manage tokens: {message}`;
1114
+ }
1115
+ class PermissionErrorError extends Error {
1116
+ constructor(body) {
1117
+ super(
1118
+ `PERMISSION_ERROR: ${body.message}`
1119
+ );
1120
+ this.body = body;
1121
+ this.name = "PermissionErrorError";
1122
+ }
1123
+ static code = "PERMISSION_ERROR";
1124
+ static statusCode = 500;
1125
+ static description = `Failed to manage permissions: {message}`;
1126
+ }
1127
+ class IdentityErrorError extends Error {
1128
+ constructor(body) {
1129
+ super(
1130
+ `IDENTITY_ERROR: ${body.message}`
1131
+ );
1132
+ this.body = body;
1133
+ this.name = "IdentityErrorError";
1134
+ }
1135
+ static code = "IDENTITY_ERROR";
1136
+ static statusCode = 500;
1137
+ static description = `Failed to manage identity: {message}`;
1138
+ }
1139
+ class GetContentFailedError extends Error {
1140
+ constructor(body) {
1141
+ super(
1142
+ `GET_CONTENT_FAILED: ${body.message}`
1143
+ );
1144
+ this.body = body;
1145
+ this.name = "GetContentFailedError";
1146
+ }
1147
+ static code = "GET_CONTENT_FAILED";
1148
+ static statusCode = 500;
1149
+ static description = `Failed to get content: {message}`;
1150
+ }
1151
+ class ContentNotFoundError extends Error {
1152
+ constructor(body) {
1153
+ super(
1154
+ `CONTENT_NOT_FOUND: ${body.message}`
1155
+ );
1156
+ this.body = body;
1157
+ this.name = "ContentNotFoundError";
1158
+ }
1159
+ static code = "CONTENT_NOT_FOUND";
1160
+ static statusCode = 404;
1161
+ static description = `Content not found: {path}`;
1162
+ }
1163
+ class DownloadFailedError extends Error {
1164
+ constructor(body) {
1165
+ super(
1166
+ `DOWNLOAD_FAILED: ${body.message}`
1167
+ );
1168
+ this.body = body;
1169
+ this.name = "DownloadFailedError";
1170
+ }
1171
+ static code = "DOWNLOAD_FAILED";
1172
+ static statusCode = 500;
1173
+ static description = `Failed to download repository: {message}`;
1174
+ }
1175
+ class GitServerErrorError extends Error {
1176
+ constructor(body) {
1177
+ super(
1178
+ `GIT_SERVER_ERROR: ${body.message}`
1179
+ );
1180
+ this.body = body;
1181
+ this.name = "GitServerErrorError";
1182
+ }
1183
+ static code = "GIT_SERVER_ERROR";
1184
+ static statusCode = 500;
1185
+ static description = `Git server error: {message}`;
1186
+ }
1187
+ class ParseResponseErrorError extends Error {
1188
+ constructor(body) {
1189
+ super(
1190
+ `PARSE_RESPONSE_ERROR: ${body.message}`
1191
+ );
1192
+ this.body = body;
1193
+ this.name = "ParseResponseErrorError";
1194
+ }
1195
+ static code = "PARSE_RESPONSE_ERROR";
1196
+ static statusCode = 500;
1197
+ static description = `Failed to parse response from Git server: {message}`;
1198
+ }
1199
+ class RepositoryAccessDeniedError extends Error {
1200
+ constructor(body) {
1201
+ super(
1202
+ `REPOSITORY_ACCESS_DENIED: ${body.message}`
1203
+ );
1204
+ this.body = body;
1205
+ this.name = "RepositoryAccessDeniedError";
1206
+ }
1207
+ static code = "REPOSITORY_ACCESS_DENIED";
1208
+ static statusCode = 403;
1209
+ static description = `Repository does not belong to account`;
1210
+ }
1211
+ class GitHubSyncFailedError extends Error {
1212
+ constructor(body) {
1213
+ super(
1214
+ `GIT_HUB_SYNC_FAILED: ${body.message}`
1215
+ );
1216
+ this.body = body;
1217
+ this.name = "GitHubSyncFailedError";
1218
+ }
1219
+ static code = "GIT_HUB_SYNC_FAILED";
1220
+ static statusCode = 500;
1221
+ static description = `Failed to configure GitHub sync: {message}`;
1222
+ }
1223
+ class UpdateDefaultBranchFailedError extends Error {
1224
+ constructor(body) {
1225
+ super(
1226
+ `UPDATE_DEFAULT_BRANCH_FAILED: ${body.message}`
1227
+ );
1228
+ this.body = body;
1229
+ this.name = "UpdateDefaultBranchFailedError";
1230
+ }
1231
+ static code = "UPDATE_DEFAULT_BRANCH_FAILED";
1232
+ static statusCode = 500;
1233
+ static description = `Failed to update default branch: {message}`;
1234
+ }
1235
+ class GetRepositoryInfoFailedError extends Error {
1236
+ constructor(body) {
1237
+ super(
1238
+ `GET_REPOSITORY_INFO_FAILED: ${body.message}`
1239
+ );
1240
+ this.body = body;
1241
+ this.name = "GetRepositoryInfoFailedError";
1242
+ }
1243
+ static code = "GET_REPOSITORY_INFO_FAILED";
1244
+ static statusCode = 500;
1245
+ static description = `Failed to get repository info: {message}`;
1246
+ }
1247
+ class ListRepositoriesFailedError extends Error {
1248
+ constructor(body) {
1249
+ super(
1250
+ `LIST_REPOSITORIES_FAILED: ${body.message}`
1251
+ );
1252
+ this.body = body;
1253
+ this.name = "ListRepositoriesFailedError";
1254
+ }
1255
+ static code = "LIST_REPOSITORIES_FAILED";
1256
+ static statusCode = 500;
1257
+ static description = `Failed to list repositories: {message}`;
1258
+ }
1259
+ class DeleteRepositoryFailedError extends Error {
1260
+ constructor(body) {
1261
+ super(
1262
+ `DELETE_REPOSITORY_FAILED: ${body.message}`
1263
+ );
1264
+ this.body = body;
1265
+ this.name = "DeleteRepositoryFailedError";
1266
+ }
1267
+ static code = "DELETE_REPOSITORY_FAILED";
1268
+ static statusCode = 500;
1269
+ static description = `Failed to delete repository: {message}`;
1270
+ }
1271
+ class CreateRepositoryFailedError extends Error {
1272
+ constructor(body) {
1273
+ super(
1274
+ `CREATE_REPOSITORY_FAILED: ${body.message}`
1275
+ );
1276
+ this.body = body;
1277
+ this.name = "CreateRepositoryFailedError";
1278
+ }
1279
+ static code = "CREATE_REPOSITORY_FAILED";
1280
+ static statusCode = 500;
1281
+ static description = `Failed to create repository: {message}`;
1282
+ }
1283
+ class SerializationErrorError extends Error {
1284
+ constructor(body) {
1285
+ super(
1286
+ `SERIALIZATION_ERROR: ${body.message}`
1287
+ );
1288
+ this.body = body;
1289
+ this.name = "SerializationErrorError";
1290
+ }
1291
+ static code = "SERIALIZATION_ERROR";
1292
+ static statusCode = 400;
1293
+ static description = `Failed to serialize request: {message}`;
1294
+ }
1295
+ class GitInvalidRequestError extends Error {
1296
+ constructor(body) {
1297
+ super(
1298
+ `GIT_INVALID_REQUEST: ${body.message}`
1299
+ );
1300
+ this.body = body;
1301
+ this.name = "GitInvalidRequestError";
1302
+ }
1303
+ static code = "GIT_INVALID_REQUEST";
1304
+ static statusCode = 400;
1305
+ static description = `Invalid request: {message}`;
1306
+ }
1307
+ class RepositoryNotFoundError extends Error {
1308
+ constructor(body) {
1309
+ super(
1310
+ `REPOSITORY_NOT_FOUND: ${body.message}`
1311
+ );
1312
+ this.body = body;
1313
+ this.name = "RepositoryNotFoundError";
1314
+ }
1315
+ static code = "REPOSITORY_NOT_FOUND";
1316
+ static statusCode = 404;
1317
+ static description = `Repository not found: {repo_id}`;
1318
+ }
1319
+ class FailedToProvisionCertificateError extends Error {
1320
+ constructor(body) {
1321
+ super(
1322
+ `FAILED_TO_PROVISION_CERTIFICATE: ${body.message}`
1323
+ );
1324
+ this.body = body;
1325
+ this.name = "FailedToProvisionCertificateError";
1326
+ }
1327
+ static code = "FAILED_TO_PROVISION_CERTIFICATE";
1328
+ static statusCode = 422;
1329
+ static description = `Failed to provision certificate: {message}`;
1330
+ }
1331
+ class FailedToInsertDomainMappingError extends Error {
1332
+ constructor(body) {
1333
+ super(
1334
+ `FAILED_TO_INSERT_DOMAIN_MAPPING: ${body.message}`
1335
+ );
1336
+ this.body = body;
1337
+ this.name = "FailedToInsertDomainMappingError";
1338
+ }
1339
+ static code = "FAILED_TO_INSERT_DOMAIN_MAPPING";
1340
+ static statusCode = 500;
1341
+ static description = `Failed to insert domain mapping: {message}`;
1342
+ }
1343
+ class PermissionDeniedError extends Error {
1344
+ constructor(body) {
1345
+ super(
1346
+ `PERMISSION_DENIED: ${body.message}`
1347
+ );
1348
+ this.body = body;
1349
+ this.name = "PermissionDeniedError";
1350
+ }
1351
+ static code = "PERMISSION_DENIED";
1352
+ static statusCode = 401;
1353
+ static description = `Permission denied: {message}`;
1354
+ }
1355
+ class FailedToCheckPermissionsError extends Error {
1356
+ constructor(body) {
1357
+ super(
1358
+ `FAILED_TO_CHECK_PERMISSIONS: ${body.message}`
1359
+ );
1360
+ this.body = body;
1361
+ this.name = "FailedToCheckPermissionsError";
1362
+ }
1363
+ static code = "FAILED_TO_CHECK_PERMISSIONS";
1364
+ static statusCode = 502;
1365
+ static description = `Failed to check permissions: {message}`;
1366
+ }
1367
+ class FailedToListDomainsError extends Error {
1368
+ constructor(body) {
1369
+ super(
1370
+ `FAILED_TO_LIST_DOMAINS: ${body.message}`
1371
+ );
1372
+ this.body = body;
1373
+ this.name = "FailedToListDomainsError";
1374
+ }
1375
+ static code = "FAILED_TO_LIST_DOMAINS";
1376
+ static statusCode = 500;
1377
+ static description = `Failed to list domains: {message}`;
1378
+ }
1379
+ class FailedToListVerificationsError extends Error {
1380
+ constructor(body) {
1381
+ super(
1382
+ `FAILED_TO_LIST_VERIFICATIONS: ${body.message}`
1383
+ );
1384
+ this.body = body;
1385
+ this.name = "FailedToListVerificationsError";
1386
+ }
1387
+ static code = "FAILED_TO_LIST_VERIFICATIONS";
1388
+ static statusCode = 500;
1389
+ static description = `Failed to list verifications: {message}`;
1390
+ }
1391
+ class FailedToVerifyDomainError extends Error {
1392
+ constructor(body) {
1393
+ super(
1394
+ `FAILED_TO_VERIFY_DOMAIN: ${body.message}`
1395
+ );
1396
+ this.body = body;
1397
+ this.name = "FailedToVerifyDomainError";
1398
+ }
1399
+ static code = "FAILED_TO_VERIFY_DOMAIN";
1400
+ static statusCode = 500;
1401
+ static description = `Failed to verify domain: {message}`;
1402
+ }
1403
+ class VerificationFailedError extends Error {
1404
+ constructor(body) {
1405
+ super(
1406
+ `VERIFICATION_FAILED: ${body.message}`
1407
+ );
1408
+ this.body = body;
1409
+ this.name = "VerificationFailedError";
1410
+ }
1411
+ static code = "VERIFICATION_FAILED";
1412
+ static statusCode = 400;
1413
+ static description = `Domain verification failed: {message}`;
1414
+ }
1415
+ class FailedToDeleteVerificationError extends Error {
1416
+ constructor(body) {
1417
+ super(
1418
+ `FAILED_TO_DELETE_VERIFICATION: ${body.message}`
1419
+ );
1420
+ this.body = body;
1421
+ this.name = "FailedToDeleteVerificationError";
1422
+ }
1423
+ static code = "FAILED_TO_DELETE_VERIFICATION";
1424
+ static statusCode = 400;
1425
+ static description = `Failed to delete verification: {message}`;
1426
+ }
1427
+ class VerificationNotFoundError extends Error {
1428
+ constructor(body) {
1429
+ super(
1430
+ `VERIFICATION_NOT_FOUND: ${body.message}`
1431
+ );
1432
+ this.body = body;
1433
+ this.name = "VerificationNotFoundError";
1434
+ }
1435
+ static code = "VERIFICATION_NOT_FOUND";
1436
+ static statusCode = 404;
1437
+ static description = `Verification request not found for domain: {domain}`;
1438
+ }
1439
+ class FailedToCreateVerificationCodeError extends Error {
1440
+ constructor(body) {
1441
+ super(
1442
+ `FAILED_TO_CREATE_VERIFICATION_CODE: ${body.message}`
1443
+ );
1444
+ this.body = body;
1445
+ this.name = "FailedToCreateVerificationCodeError";
1446
+ }
1447
+ static code = "FAILED_TO_CREATE_VERIFICATION_CODE";
1448
+ static statusCode = 400;
1449
+ static description = `Failed to create verification code: {message}`;
1450
+ }
1451
+ class InvalidDomainError extends Error {
1452
+ constructor(body) {
1453
+ super(
1454
+ `INVALID_DOMAIN: ${body.message}`
1455
+ );
1456
+ this.body = body;
1457
+ this.name = "InvalidDomainError";
1458
+ }
1459
+ static code = "INVALID_DOMAIN";
1460
+ static statusCode = 400;
1461
+ static description = `Invalid domain: {domain}`;
1462
+ }
1463
+ class DomainAlreadyExistsError extends Error {
1464
+ constructor(body) {
1465
+ super(
1466
+ `DOMAIN_ALREADY_EXISTS: ${body.message}`
1467
+ );
1468
+ this.body = body;
1469
+ this.name = "DomainAlreadyExistsError";
1470
+ }
1471
+ static code = "DOMAIN_ALREADY_EXISTS";
1472
+ static statusCode = 400;
1473
+ static description = `Domain already exists: {domain}`;
1474
+ }
1475
+ class FailedToInsertOwnershipError extends Error {
1476
+ constructor(body) {
1477
+ super(
1478
+ `FAILED_TO_INSERT_OWNERSHIP: ${body.message}`
1479
+ );
1480
+ this.body = body;
1481
+ this.name = "FailedToInsertOwnershipError";
1482
+ }
1483
+ static code = "FAILED_TO_INSERT_OWNERSHIP";
1484
+ static statusCode = 500;
1485
+ static description = `Failed to insert domain ownership: {message}`;
1486
+ }
1487
+ class FailedRemoveDomainMappingError extends Error {
1488
+ constructor(body) {
1489
+ super(
1490
+ `FAILED_REMOVE_DOMAIN_MAPPING: ${body.message}`
1491
+ );
1492
+ this.body = body;
1493
+ this.name = "FailedRemoveDomainMappingError";
1494
+ }
1495
+ static code = "FAILED_REMOVE_DOMAIN_MAPPING";
1496
+ static statusCode = 500;
1497
+ static description = `Failed to remove domain mapping: {message}`;
1498
+ }
1499
+ class FailedPermissionsCheckError extends Error {
1500
+ constructor(body) {
1501
+ super(
1502
+ `FAILED_PERMISSIONS_CHECK: ${body.message}`
1503
+ );
1504
+ this.body = body;
1505
+ this.name = "FailedPermissionsCheckError";
1506
+ }
1507
+ static code = "FAILED_PERMISSIONS_CHECK";
1508
+ static statusCode = 401;
1509
+ static description = `You do not have permission to delete the domain mapping for: {domain}`;
1510
+ }
1511
+ class FailedToCheckDomainMappingPermissionsError extends Error {
1512
+ constructor(body) {
1513
+ super(
1514
+ `FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS: ${body.message}`
1515
+ );
1516
+ this.body = body;
1517
+ this.name = "FailedToCheckDomainMappingPermissionsError";
1518
+ }
1519
+ static code = "FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS";
1520
+ static statusCode = 502;
1521
+ static description = `Failed to check permissions: {message}`;
1522
+ }
1523
+ class AnyhowError extends Error {
1524
+ constructor(body) {
1525
+ super(
1526
+ `ANYHOW: ${body.message}`
1527
+ );
1528
+ this.body = body;
1529
+ this.name = "AnyhowError";
1530
+ }
1531
+ static code = "ANYHOW";
1532
+ static statusCode = 500;
1533
+ static description = `null`;
1534
+ }
1535
+ class ObservabilityDatabaseErrorError extends Error {
1536
+ constructor(body) {
1537
+ super(
1538
+ `OBSERVABILITY_DATABASE_ERROR: ${body.message}`
1539
+ );
1540
+ this.body = body;
1541
+ this.name = "ObservabilityDatabaseErrorError";
1542
+ }
1543
+ static code = "OBSERVABILITY_DATABASE_ERROR";
1544
+ static statusCode = 500;
1545
+ static description = `Database operation failed: {message}`;
1546
+ }
1547
+ class ObservabilityAccessDeniedError extends Error {
1548
+ constructor(body) {
1549
+ super(
1550
+ `OBSERVABILITY_ACCESS_DENIED: ${body.message}`
1551
+ );
1552
+ this.body = body;
1553
+ this.name = "ObservabilityAccessDeniedError";
1554
+ }
1555
+ static code = "OBSERVABILITY_ACCESS_DENIED";
1556
+ static statusCode = 403;
1557
+ static description = `Access denied to logs for deployment: {deployment_id}`;
1558
+ }
1559
+ class ParseLogsFailedError extends Error {
1560
+ constructor(body) {
1561
+ super(
1562
+ `PARSE_LOGS_FAILED: ${body.message}`
1563
+ );
1564
+ this.body = body;
1565
+ this.name = "ParseLogsFailedError";
1566
+ }
1567
+ static code = "PARSE_LOGS_FAILED";
1568
+ static statusCode = 500;
1569
+ static description = `Failed to parse logs: {message}`;
1570
+ }
1571
+ class RetrieveLogsFailedError extends Error {
1572
+ constructor(body) {
1573
+ super(
1574
+ `RETRIEVE_LOGS_FAILED: ${body.message}`
1575
+ );
1576
+ this.body = body;
1577
+ this.name = "RetrieveLogsFailedError";
1578
+ }
1579
+ static code = "RETRIEVE_LOGS_FAILED";
1580
+ static statusCode = 500;
1581
+ static description = `Failed to retrieve logs: {message}`;
1582
+ }
1583
+ class InvalidQueryError extends Error {
1584
+ constructor(body) {
1585
+ super(
1586
+ `INVALID_QUERY: ${body.message}`
1587
+ );
1588
+ this.body = body;
1589
+ this.name = "InvalidQueryError";
1590
+ }
1591
+ static code = "INVALID_QUERY";
1592
+ static statusCode = 400;
1593
+ static description = `Invalid log query: {message}`;
1594
+ }
1595
+ class LogsNotFoundError extends Error {
1596
+ constructor(body) {
1597
+ super(
1598
+ `LOGS_NOT_FOUND: ${body.message}`
1599
+ );
1600
+ this.body = body;
1601
+ this.name = "LogsNotFoundError";
1602
+ }
1603
+ static code = "LOGS_NOT_FOUND";
1604
+ static statusCode = 404;
1605
+ static description = `Logs not found for deployment: {deployment_id}`;
1606
+ }
1607
+ class PermissionAlreadyExistsError extends Error {
1608
+ constructor(body) {
1609
+ super(
1610
+ `PERMISSION_ALREADY_EXISTS: ${body.message}`
1611
+ );
1612
+ this.body = body;
1613
+ this.name = "PermissionAlreadyExistsError";
1614
+ }
1615
+ static code = "PERMISSION_ALREADY_EXISTS";
1616
+ static statusCode = 409;
1617
+ static description = `Permission already exists`;
1618
+ }
1619
+ class ListTokensFailedError extends Error {
1620
+ constructor(body) {
1621
+ super(
1622
+ `LIST_TOKENS_FAILED: ${body.message}`
1623
+ );
1624
+ this.body = body;
1625
+ this.name = "ListTokensFailedError";
1626
+ }
1627
+ static code = "LIST_TOKENS_FAILED";
1628
+ static statusCode = 500;
1629
+ static description = `Failed to list tokens: {message}`;
1630
+ }
1631
+ class RevokeTokenFailedError extends Error {
1632
+ constructor(body) {
1633
+ super(
1634
+ `REVOKE_TOKEN_FAILED: ${body.message}`
1635
+ );
1636
+ this.body = body;
1637
+ this.name = "RevokeTokenFailedError";
1638
+ }
1639
+ static code = "REVOKE_TOKEN_FAILED";
1640
+ static statusCode = 500;
1641
+ static description = `Failed to revoke token: {message}`;
1642
+ }
1643
+ class CreateTokenFailedError extends Error {
1644
+ constructor(body) {
1645
+ super(
1646
+ `CREATE_TOKEN_FAILED: ${body.message}`
1647
+ );
1648
+ this.body = body;
1649
+ this.name = "CreateTokenFailedError";
1650
+ }
1651
+ static code = "CREATE_TOKEN_FAILED";
1652
+ static statusCode = 500;
1653
+ static description = `Failed to create token: {message}`;
1654
+ }
1655
+ class ListPermissionsFailedError extends Error {
1656
+ constructor(body) {
1657
+ super(
1658
+ `LIST_PERMISSIONS_FAILED: ${body.message}`
1659
+ );
1660
+ this.body = body;
1661
+ this.name = "ListPermissionsFailedError";
1662
+ }
1663
+ static code = "LIST_PERMISSIONS_FAILED";
1664
+ static statusCode = 500;
1665
+ static description = `Failed to list permissions: {message}`;
1666
+ }
1667
+ class GetPermissionFailedError extends Error {
1668
+ constructor(body) {
1669
+ super(
1670
+ `GET_PERMISSION_FAILED: ${body.message}`
1671
+ );
1672
+ this.body = body;
1673
+ this.name = "GetPermissionFailedError";
1674
+ }
1675
+ static code = "GET_PERMISSION_FAILED";
1676
+ static statusCode = 500;
1677
+ static description = `Failed to get permission: {message}`;
1678
+ }
1679
+ class UpdatePermissionFailedError extends Error {
1680
+ constructor(body) {
1681
+ super(
1682
+ `UPDATE_PERMISSION_FAILED: ${body.message}`
1683
+ );
1684
+ this.body = body;
1685
+ this.name = "UpdatePermissionFailedError";
1686
+ }
1687
+ static code = "UPDATE_PERMISSION_FAILED";
1688
+ static statusCode = 500;
1689
+ static description = `Failed to update permission: {message}`;
1690
+ }
1691
+ class RevokePermissionFailedError extends Error {
1692
+ constructor(body) {
1693
+ super(
1694
+ `REVOKE_PERMISSION_FAILED: ${body.message}`
1695
+ );
1696
+ this.body = body;
1697
+ this.name = "RevokePermissionFailedError";
1698
+ }
1699
+ static code = "REVOKE_PERMISSION_FAILED";
1700
+ static statusCode = 500;
1701
+ static description = `Failed to revoke permission: {message}`;
1702
+ }
1703
+ class GrantPermissionFailedError extends Error {
1704
+ constructor(body) {
1705
+ super(
1706
+ `GRANT_PERMISSION_FAILED: ${body.message}`
1707
+ );
1708
+ this.body = body;
1709
+ this.name = "GrantPermissionFailedError";
1710
+ }
1711
+ static code = "GRANT_PERMISSION_FAILED";
1712
+ static statusCode = 500;
1713
+ static description = `Failed to grant permission: {message}`;
1714
+ }
1715
+ class ListIdentitiesFailedError extends Error {
1716
+ constructor(body) {
1717
+ super(
1718
+ `LIST_IDENTITIES_FAILED: ${body.message}`
1719
+ );
1720
+ this.body = body;
1721
+ this.name = "ListIdentitiesFailedError";
1722
+ }
1723
+ static code = "LIST_IDENTITIES_FAILED";
1724
+ static statusCode = 500;
1725
+ static description = `Failed to list identities: {message}`;
1726
+ }
1727
+ class DeleteIdentityFailedError extends Error {
1728
+ constructor(body) {
1729
+ super(
1730
+ `DELETE_IDENTITY_FAILED: ${body.message}`
1731
+ );
1732
+ this.body = body;
1733
+ this.name = "DeleteIdentityFailedError";
1734
+ }
1735
+ static code = "DELETE_IDENTITY_FAILED";
1736
+ static statusCode = 500;
1737
+ static description = `Failed to delete identity: {message}`;
1738
+ }
1739
+ class CreateIdentityFailedError extends Error {
1740
+ constructor(body) {
1741
+ super(
1742
+ `CREATE_IDENTITY_FAILED: ${body.message}`
1743
+ );
1744
+ this.body = body;
1745
+ this.name = "CreateIdentityFailedError";
1746
+ }
1747
+ static code = "CREATE_IDENTITY_FAILED";
1748
+ static statusCode = 500;
1749
+ static description = `Failed to create identity: {message}`;
1750
+ }
1751
+ class VmPermissionNotFoundError extends Error {
1752
+ constructor(body) {
1753
+ super(
1754
+ `VM_PERMISSION_NOT_FOUND: ${body.message}`
1755
+ );
1756
+ this.body = body;
1757
+ this.name = "VmPermissionNotFoundError";
1758
+ }
1759
+ static code = "VM_PERMISSION_NOT_FOUND";
1760
+ static statusCode = 404;
1761
+ static description = `VM permission not found`;
1762
+ }
1763
+ class PermissionNotFoundError extends Error {
1764
+ constructor(body) {
1765
+ super(
1766
+ `PERMISSION_NOT_FOUND: ${body.message}`
1767
+ );
1768
+ this.body = body;
1769
+ this.name = "PermissionNotFoundError";
1770
+ }
1771
+ static code = "PERMISSION_NOT_FOUND";
1772
+ static statusCode = 404;
1773
+ static description = `Permission not found`;
1774
+ }
1775
+ class VmAccessDeniedError extends Error {
1776
+ constructor(body) {
1777
+ super(
1778
+ `VM_ACCESS_DENIED: ${body.message}`
1779
+ );
1780
+ this.body = body;
1781
+ this.name = "VmAccessDeniedError";
1782
+ }
1783
+ static code = "VM_ACCESS_DENIED";
1784
+ static statusCode = 403;
1785
+ static description = `You are not allowed to access this VM`;
1786
+ }
1787
+ class GitRepositoryAccessDeniedError extends Error {
1788
+ constructor(body) {
1789
+ super(
1790
+ `GIT_REPOSITORY_ACCESS_DENIED: ${body.message}`
1791
+ );
1792
+ this.body = body;
1793
+ this.name = "GitRepositoryAccessDeniedError";
1794
+ }
1795
+ static code = "GIT_REPOSITORY_ACCESS_DENIED";
1796
+ static statusCode = 403;
1797
+ static description = `You are not allowed to access this repository`;
1798
+ }
1799
+ class GitRepositoryNotFoundError extends Error {
1800
+ constructor(body) {
1801
+ super(
1802
+ `GIT_REPOSITORY_NOT_FOUND: ${body.message}`
1803
+ );
1804
+ this.body = body;
1805
+ this.name = "GitRepositoryNotFoundError";
1806
+ }
1807
+ static code = "GIT_REPOSITORY_NOT_FOUND";
1808
+ static statusCode = 404;
1809
+ static description = `Repository not found`;
1810
+ }
1811
+ class CannotDeleteManagedIdentityError extends Error {
1812
+ constructor(body) {
1813
+ super(
1814
+ `CANNOT_DELETE_MANAGED_IDENTITY: ${body.message}`
1815
+ );
1816
+ this.body = body;
1817
+ this.name = "CannotDeleteManagedIdentityError";
1818
+ }
1819
+ static code = "CANNOT_DELETE_MANAGED_IDENTITY";
1820
+ static statusCode = 403;
1821
+ static description = `Cannot delete managed identities`;
1822
+ }
1823
+ class CannotModifyManagedIdentityError extends Error {
1824
+ constructor(body) {
1825
+ super(
1826
+ `CANNOT_MODIFY_MANAGED_IDENTITY: ${body.message}`
1827
+ );
1828
+ this.body = body;
1829
+ this.name = "CannotModifyManagedIdentityError";
1830
+ }
1831
+ static code = "CANNOT_MODIFY_MANAGED_IDENTITY";
1832
+ static statusCode = 403;
1833
+ static description = `Cannot modify managed identities`;
1834
+ }
1835
+ class IdentityAccessDeniedError extends Error {
1836
+ constructor(body) {
1837
+ super(
1838
+ `IDENTITY_ACCESS_DENIED: ${body.message}`
1839
+ );
1840
+ this.body = body;
1841
+ this.name = "IdentityAccessDeniedError";
1842
+ }
1843
+ static code = "IDENTITY_ACCESS_DENIED";
1844
+ static statusCode = 403;
1845
+ static description = `You are not allowed to access this identity`;
1846
+ }
1847
+ class IdentityNotFoundError extends Error {
1848
+ constructor(body) {
1849
+ super(
1850
+ `IDENTITY_NOT_FOUND: ${body.message}`
1851
+ );
1852
+ this.body = body;
1853
+ this.name = "IdentityNotFoundError";
1854
+ }
1855
+ static code = "IDENTITY_NOT_FOUND";
1856
+ static statusCode = 404;
1857
+ static description = `Identity not found`;
1858
+ }
1859
+ class ExecuteInternalErrorError extends Error {
1860
+ constructor(body) {
1861
+ super(
1862
+ `EXECUTE_INTERNAL_ERROR: ${body.message}`
1863
+ );
1864
+ this.body = body;
1865
+ this.name = "ExecuteInternalErrorError";
1866
+ }
1867
+ static code = "EXECUTE_INTERNAL_ERROR";
1868
+ static statusCode = 500;
1869
+ static description = `Internal error: {message}`;
1870
+ }
1871
+ class ExecuteAccessDeniedError extends Error {
1872
+ constructor(body) {
1873
+ super(
1874
+ `EXECUTE_ACCESS_DENIED: ${body.message}`
1875
+ );
1876
+ this.body = body;
1877
+ this.name = "ExecuteAccessDeniedError";
1878
+ }
1879
+ static code = "EXECUTE_ACCESS_DENIED";
1880
+ static statusCode = 403;
1881
+ static description = `Access denied to execute run`;
1882
+ }
1883
+ class ListRunsFailedError extends Error {
1884
+ constructor(body) {
1885
+ super(
1886
+ `LIST_RUNS_FAILED: ${body.message}`
1887
+ );
1888
+ this.body = body;
1889
+ this.name = "ListRunsFailedError";
1890
+ }
1891
+ static code = "LIST_RUNS_FAILED";
1892
+ static statusCode = 500;
1893
+ static description = `Failed to list execute runs: {message}`;
1894
+ }
1895
+ class ExecutionErrorError extends Error {
1896
+ constructor(body) {
1897
+ super(
1898
+ `EXECUTION_ERROR: ${body.message}`
1899
+ );
1900
+ this.body = body;
1901
+ this.name = "ExecutionErrorError";
1902
+ }
1903
+ static code = "EXECUTION_ERROR";
1904
+ static statusCode = 500;
1905
+ static description = `Script execution error: {message}`;
1906
+ }
1907
+ class ConnectionFailedError extends Error {
1908
+ constructor(body) {
1909
+ super(
1910
+ `CONNECTION_FAILED: ${body.message}`
1911
+ );
1912
+ this.body = body;
1913
+ this.name = "ConnectionFailedError";
1914
+ }
1915
+ static code = "CONNECTION_FAILED";
1916
+ static statusCode = 500;
1917
+ static description = `Failed to connect to execute server: {message}`;
1918
+ }
1919
+ class MetadataWriteFailedError extends Error {
1920
+ constructor(body) {
1921
+ super(
1922
+ `METADATA_WRITE_FAILED: ${body.message}`
1923
+ );
1924
+ this.body = body;
1925
+ this.name = "MetadataWriteFailedError";
1926
+ }
1927
+ static code = "METADATA_WRITE_FAILED";
1928
+ static statusCode = 500;
1929
+ static description = `Failed to write metadata file: {message}`;
1930
+ }
1931
+ class NodeModulesInstallFailedError extends Error {
1932
+ constructor(body) {
1933
+ super(
1934
+ `NODE_MODULES_INSTALL_FAILED: ${body.message}`
1935
+ );
1936
+ this.body = body;
1937
+ this.name = "NodeModulesInstallFailedError";
1938
+ }
1939
+ static code = "NODE_MODULES_INSTALL_FAILED";
1940
+ static statusCode = 500;
1941
+ static description = `Failed to install node modules: {message}`;
1942
+ }
1943
+ class NodeModulesDownloadFailedError extends Error {
1944
+ constructor(body) {
1945
+ super(
1946
+ `NODE_MODULES_DOWNLOAD_FAILED: ${body.message}`
1947
+ );
1948
+ this.body = body;
1949
+ this.name = "NodeModulesDownloadFailedError";
1950
+ }
1951
+ static code = "NODE_MODULES_DOWNLOAD_FAILED";
1952
+ static statusCode = 500;
1953
+ static description = `Failed to download node modules: {message}`;
1954
+ }
1955
+ class LockGenerationFailedError extends Error {
1956
+ constructor(body) {
1957
+ super(
1958
+ `LOCK_GENERATION_FAILED: ${body.message}`
1959
+ );
1960
+ this.body = body;
1961
+ this.name = "LockGenerationFailedError";
1962
+ }
1963
+ static code = "LOCK_GENERATION_FAILED";
1964
+ static statusCode = 500;
1965
+ static description = `Failed to generate lock file: {message}`;
1966
+ }
1967
+ class WriteScriptFailedError extends Error {
1968
+ constructor(body) {
1969
+ super(
1970
+ `WRITE_SCRIPT_FAILED: ${body.message}`
1971
+ );
1972
+ this.body = body;
1973
+ this.name = "WriteScriptFailedError";
1974
+ }
1975
+ static code = "WRITE_SCRIPT_FAILED";
1976
+ static statusCode = 500;
1977
+ static description = `Failed to write script file: {message}`;
1978
+ }
1979
+ class DirectoryCreationFailedError extends Error {
1980
+ constructor(body) {
1981
+ super(
1982
+ `DIRECTORY_CREATION_FAILED: ${body.message}`
1983
+ );
1984
+ this.body = body;
1985
+ this.name = "DirectoryCreationFailedError";
1986
+ }
1987
+ static code = "DIRECTORY_CREATION_FAILED";
1988
+ static statusCode = 500;
1989
+ static description = `Failed to create script directory: {message}`;
1990
+ }
1991
+ class NetworkPermissionsFailedError extends Error {
1992
+ constructor(body) {
1993
+ super(
1994
+ `NETWORK_PERMISSIONS_FAILED: ${body.message}`
1995
+ );
1996
+ this.body = body;
1997
+ this.name = "NetworkPermissionsFailedError";
1998
+ }
1999
+ static code = "NETWORK_PERMISSIONS_FAILED";
2000
+ static statusCode = 500;
2001
+ static description = `Failed to insert network permissions: {message}`;
2002
+ }
2003
+ class LoggingFailedError extends Error {
2004
+ constructor(body) {
2005
+ super(
2006
+ `LOGGING_FAILED: ${body.message}`
2007
+ );
2008
+ this.body = body;
2009
+ this.name = "LoggingFailedError";
2010
+ }
2011
+ static code = "LOGGING_FAILED";
2012
+ static statusCode = 500;
2013
+ static description = `Failed to log execute run: {message}`;
2014
+ }
2015
+ class RunNotFoundError extends Error {
2016
+ constructor(body) {
2017
+ super(
2018
+ `RUN_NOT_FOUND: ${body.message}`
2019
+ );
2020
+ this.body = body;
2021
+ this.name = "RunNotFoundError";
2022
+ }
2023
+ static code = "RUN_NOT_FOUND";
2024
+ static statusCode = 404;
2025
+ static description = `Execute run not found: {run_id}`;
2026
+ }
2027
+ class CloudstateInternalErrorError extends Error {
2028
+ constructor(body) {
2029
+ super(
2030
+ `CLOUDSTATE_INTERNAL_ERROR: ${body.message}`
2031
+ );
2032
+ this.body = body;
2033
+ this.name = "CloudstateInternalErrorError";
2034
+ }
2035
+ static code = "CLOUDSTATE_INTERNAL_ERROR";
2036
+ static statusCode = 500;
2037
+ static description = `Internal error: {message}`;
2038
+ }
2039
+ class CloudstateDatabaseErrorError extends Error {
2040
+ constructor(body) {
2041
+ super(
2042
+ `CLOUDSTATE_DATABASE_ERROR: ${body.message}`
2043
+ );
2044
+ this.body = body;
2045
+ this.name = "CloudstateDatabaseErrorError";
2046
+ }
2047
+ static code = "CLOUDSTATE_DATABASE_ERROR";
2048
+ static statusCode = 500;
2049
+ static description = `Database operation failed: {message}`;
2050
+ }
2051
+ class CloudstateAccessDeniedError extends Error {
2052
+ constructor(body) {
2053
+ super(
2054
+ `CLOUDSTATE_ACCESS_DENIED: ${body.message}`
2055
+ );
2056
+ this.body = body;
2057
+ this.name = "CloudstateAccessDeniedError";
2058
+ }
2059
+ static code = "CLOUDSTATE_ACCESS_DENIED";
2060
+ static statusCode = 403;
2061
+ static description = `Access denied to project: {project_id}`;
2062
+ }
2063
+ class RestoreFailedError extends Error {
2064
+ constructor(body) {
2065
+ super(
2066
+ `RESTORE_FAILED: ${body.message}`
2067
+ );
2068
+ this.body = body;
2069
+ this.name = "RestoreFailedError";
2070
+ }
2071
+ static code = "RESTORE_FAILED";
2072
+ static statusCode = 500;
2073
+ static description = `Failed to restore from backup: {message}`;
2074
+ }
2075
+ class CreateBackupFailedError extends Error {
2076
+ constructor(body) {
2077
+ super(
2078
+ `CREATE_BACKUP_FAILED: ${body.message}`
2079
+ );
2080
+ this.body = body;
2081
+ this.name = "CreateBackupFailedError";
2082
+ }
2083
+ static code = "CREATE_BACKUP_FAILED";
2084
+ static statusCode = 500;
2085
+ static description = `Failed to create backup: {message}`;
2086
+ }
2087
+ class BackupFailedError extends Error {
2088
+ constructor(body) {
2089
+ super(
2090
+ `BACKUP_FAILED: ${body.message}`
2091
+ );
2092
+ this.body = body;
2093
+ this.name = "BackupFailedError";
2094
+ }
2095
+ static code = "BACKUP_FAILED";
2096
+ static statusCode = 500;
2097
+ static description = `Backup failed: {message}`;
2098
+ }
2099
+ class DeploymentFailedError extends Error {
2100
+ constructor(body) {
2101
+ super(
2102
+ `DEPLOYMENT_FAILED: ${body.message}`
2103
+ );
2104
+ this.body = body;
2105
+ this.name = "DeploymentFailedError";
2106
+ }
2107
+ static code = "DEPLOYMENT_FAILED";
2108
+ static statusCode = 500;
2109
+ static description = `Deployment failed: {message}`;
2110
+ }
2111
+ class InvalidDeploymentRequestError extends Error {
2112
+ constructor(body) {
2113
+ super(
2114
+ `INVALID_DEPLOYMENT_REQUEST: ${body.message}`
2115
+ );
2116
+ this.body = body;
2117
+ this.name = "InvalidDeploymentRequestError";
2118
+ }
2119
+ static code = "INVALID_DEPLOYMENT_REQUEST";
2120
+ static statusCode = 400;
2121
+ static description = `Invalid deployment request: {message}`;
2122
+ }
2123
+ class ProjectNotFoundError extends Error {
2124
+ constructor(body) {
2125
+ super(
2126
+ `PROJECT_NOT_FOUND: ${body.message}`
2127
+ );
2128
+ this.body = body;
2129
+ this.name = "ProjectNotFoundError";
2130
+ }
2131
+ static code = "PROJECT_NOT_FOUND";
2132
+ static statusCode = 404;
2133
+ static description = `Project not found: {project_id}`;
2134
+ }
2135
+ class ResizeFailedError extends Error {
2136
+ constructor(body) {
2137
+ super(
2138
+ `RESIZE_FAILED: ${body.message}`
2139
+ );
2140
+ this.body = body;
2141
+ this.name = "ResizeFailedError";
2142
+ }
2143
+ static code = "RESIZE_FAILED";
2144
+ static statusCode = 500;
2145
+ static description = `Failed to resize VM: {message}`;
2146
+ }
2147
+ class InternalResizeVmNotFoundError extends Error {
2148
+ constructor(body) {
2149
+ super(
2150
+ `INTERNAL_RESIZE_VM_NOT_FOUND: ${body.message}`
2151
+ );
2152
+ this.body = body;
2153
+ this.name = "InternalResizeVmNotFoundError";
2154
+ }
2155
+ static code = "INTERNAL_RESIZE_VM_NOT_FOUND";
2156
+ static statusCode = 404;
2157
+ static description = `VM not found`;
2158
+ }
2159
+ class DomainOwnershipVerificationFailedError extends Error {
2160
+ constructor(body) {
2161
+ super(
2162
+ `DOMAIN_OWNERSHIP_VERIFICATION_FAILED: ${body.message}`
2163
+ );
2164
+ this.body = body;
2165
+ this.name = "DomainOwnershipVerificationFailedError";
2166
+ }
2167
+ static code = "DOMAIN_OWNERSHIP_VERIFICATION_FAILED";
2168
+ static statusCode = 403;
2169
+ static description = `Domain ownership verification failed`;
2170
+ }
2171
+ class ErrorDeletingRecordError extends Error {
2172
+ constructor(body) {
2173
+ super(
2174
+ `ERROR_DELETING_RECORD: ${body.message}`
2175
+ );
2176
+ this.body = body;
2177
+ this.name = "ErrorDeletingRecordError";
2178
+ }
2179
+ static code = "ERROR_DELETING_RECORD";
2180
+ static statusCode = 500;
2181
+ static description = `Error deleting DNS record for {domain}/{name}: {message}`;
2182
+ }
2183
+ class RecordOwnershipErrorError extends Error {
2184
+ constructor(body) {
2185
+ super(
2186
+ `RECORD_OWNERSHIP_ERROR: ${body.message}`
2187
+ );
2188
+ this.body = body;
2189
+ this.name = "RecordOwnershipErrorError";
2190
+ }
2191
+ static code = "RECORD_OWNERSHIP_ERROR";
2192
+ static statusCode = 403;
2193
+ static description = `Account {account_id} does not own record {record_id}`;
2194
+ }
2195
+ class ErrorCreatingRecordError extends Error {
2196
+ constructor(body) {
2197
+ super(
2198
+ `ERROR_CREATING_RECORD: ${body.message}`
2199
+ );
2200
+ this.body = body;
2201
+ this.name = "ErrorCreatingRecordError";
2202
+ }
2203
+ static code = "ERROR_CREATING_RECORD";
2204
+ static statusCode = 500;
2205
+ static description = `Error creating DNS record: {message}`;
2206
+ }
2207
+ class DomainOwnershipErrorError extends Error {
2208
+ constructor(body) {
2209
+ super(
2210
+ `DOMAIN_OWNERSHIP_ERROR: ${body.message}`
2211
+ );
2212
+ this.body = body;
2213
+ this.name = "DomainOwnershipErrorError";
2214
+ }
2215
+ static code = "DOMAIN_OWNERSHIP_ERROR";
2216
+ static statusCode = 403;
2217
+ static description = `Account {account_id} does not own domain {domain}`;
2218
+ }
2219
+ class BrowserOperationFailedError extends Error {
2220
+ constructor(body) {
2221
+ super(
2222
+ `BROWSER_OPERATION_FAILED: ${body.message}`
2223
+ );
2224
+ this.body = body;
2225
+ this.name = "BrowserOperationFailedError";
2226
+ }
2227
+ static code = "BROWSER_OPERATION_FAILED";
2228
+ static statusCode = 500;
2229
+ static description = `Browser operation failed: {message}`;
2230
+ }
2231
+ class WatchFilesFailedError extends Error {
2232
+ constructor(body) {
2233
+ super(
2234
+ `WATCH_FILES_FAILED: ${body.message}`
2235
+ );
2236
+ this.body = body;
2237
+ this.name = "WatchFilesFailedError";
2238
+ }
2239
+ static code = "WATCH_FILES_FAILED";
2240
+ static statusCode = 500;
2241
+ static description = `Failed to watch files: {message}`;
2242
+ }
2243
+ class LogsFailedError extends Error {
2244
+ constructor(body) {
2245
+ super(
2246
+ `LOGS_FAILED: ${body.message}`
2247
+ );
2248
+ this.body = body;
2249
+ this.name = "LogsFailedError";
2250
+ }
2251
+ static code = "LOGS_FAILED";
2252
+ static statusCode = 500;
2253
+ static description = `Failed to get logs: {message}`;
2254
+ }
2255
+ class StatusFailedError extends Error {
2256
+ constructor(body) {
2257
+ super(
2258
+ `STATUS_FAILED: ${body.message}`
2259
+ );
2260
+ this.body = body;
2261
+ this.name = "StatusFailedError";
2262
+ }
2263
+ static code = "STATUS_FAILED";
2264
+ static statusCode = 500;
2265
+ static description = `Failed to get dev server status: {message}`;
2266
+ }
2267
+ class RestartFailedError extends Error {
2268
+ constructor(body) {
2269
+ super(
2270
+ `RESTART_FAILED: ${body.message}`
2271
+ );
2272
+ this.body = body;
2273
+ this.name = "RestartFailedError";
2274
+ }
2275
+ static code = "RESTART_FAILED";
2276
+ static statusCode = 500;
2277
+ static description = `Failed to restart dev server: {message}`;
2278
+ }
2279
+ class ShutdownFailedError extends Error {
2280
+ constructor(body) {
2281
+ super(
2282
+ `SHUTDOWN_FAILED: ${body.message}`
2283
+ );
2284
+ this.body = body;
2285
+ this.name = "ShutdownFailedError";
2286
+ }
2287
+ static code = "SHUTDOWN_FAILED";
2288
+ static statusCode = 500;
2289
+ static description = `Failed to shutdown dev server: {message}`;
2290
+ }
2291
+ class CommitFailedError extends Error {
2292
+ constructor(body) {
2293
+ super(
2294
+ `COMMIT_FAILED: ${body.message}`
2295
+ );
2296
+ this.body = body;
2297
+ this.name = "CommitFailedError";
2298
+ }
2299
+ static code = "COMMIT_FAILED";
2300
+ static statusCode = 500;
2301
+ static description = `Failed to commit changes: {message}`;
2302
+ }
2303
+ class WriteFileFailedError extends Error {
2304
+ constructor(body) {
2305
+ super(
2306
+ `WRITE_FILE_FAILED: ${body.message}`
2307
+ );
2308
+ this.body = body;
2309
+ this.name = "WriteFileFailedError";
2310
+ }
2311
+ static code = "WRITE_FILE_FAILED";
2312
+ static statusCode = 500;
2313
+ static description = `Failed to write file: {message}`;
2314
+ }
2315
+ class ReadFileFailedError extends Error {
2316
+ constructor(body) {
2317
+ super(
2318
+ `READ_FILE_FAILED: ${body.message}`
2319
+ );
2320
+ this.body = body;
2321
+ this.name = "ReadFileFailedError";
2322
+ }
2323
+ static code = "READ_FILE_FAILED";
2324
+ static statusCode = 500;
2325
+ static description = `Failed to read file: {message}`;
2326
+ }
2327
+ class ExecutionFailedError extends Error {
2328
+ constructor(body) {
2329
+ super(
2330
+ `EXECUTION_FAILED: ${body.message}`
2331
+ );
2332
+ this.body = body;
2333
+ this.name = "ExecutionFailedError";
2334
+ }
2335
+ static code = "EXECUTION_FAILED";
2336
+ static statusCode = 500;
2337
+ static description = `Failed to execute command: {message}`;
2338
+ }
2339
+ class RequestFailedError extends Error {
2340
+ constructor(body) {
2341
+ super(
2342
+ `REQUEST_FAILED: ${body.message}`
2343
+ );
2344
+ this.body = body;
2345
+ this.name = "RequestFailedError";
2346
+ }
2347
+ static code = "REQUEST_FAILED";
2348
+ static statusCode = 500;
2349
+ static description = `Failed to request dev server: {message}`;
2350
+ }
2351
+ class DevServerFileNotFoundError extends Error {
2352
+ constructor(body) {
2353
+ super(
2354
+ `DEV_SERVER_FILE_NOT_FOUND: ${body.message}`
2355
+ );
2356
+ this.body = body;
2357
+ this.name = "DevServerFileNotFoundError";
2358
+ }
2359
+ static code = "DEV_SERVER_FILE_NOT_FOUND";
2360
+ static statusCode = 404;
2361
+ static description = `Dev server file not found: {path}`;
2362
+ }
2363
+ class DevServerInvalidRequestError extends Error {
2364
+ constructor(body) {
2365
+ super(
2366
+ `DEV_SERVER_INVALID_REQUEST: ${body.message}`
2367
+ );
2368
+ this.body = body;
2369
+ this.name = "DevServerInvalidRequestError";
2370
+ }
2371
+ static code = "DEV_SERVER_INVALID_REQUEST";
2372
+ static statusCode = 400;
2373
+ static description = `Invalid dev server request: {message}`;
2374
+ }
2375
+ class DevServerNotFoundError extends Error {
2376
+ constructor(body) {
2377
+ super(
2378
+ `DEV_SERVER_NOT_FOUND: ${body.message}`
2379
+ );
2380
+ this.body = body;
2381
+ this.name = "DevServerNotFoundError";
2382
+ }
2383
+ static code = "DEV_SERVER_NOT_FOUND";
2384
+ static statusCode = 404;
2385
+ static description = `Dev server not found: {server_id}`;
2386
+ }
2387
+ const FREESTYLE_ERROR_CODE_MAP = {
2388
+ "VM_NOT_FOUND_IN_FS": VmNotFoundInFsError,
2389
+ "VM_NOT_RUNNING": VmNotRunningError,
2390
+ "VM_NOT_FOUND": VmNotFoundError,
2391
+ "INTERNAL_FORK_VM_NOT_FOUND": InternalForkVmNotFoundError,
2392
+ "BAD_REQUEST": BadRequestError,
2393
+ "INTERNAL_VM_NOT_FOUND": InternalVmNotFoundError,
2394
+ "VM_MUST_BE_STOPPED": VmMustBeStoppedError,
2395
+ "ALREADY_HAS_BASE": AlreadyHasBaseError,
2396
+ "NOT_FOUND": NotFoundError,
2397
+ "INTERNAL_ERROR": InternalErrorError,
2398
+ "DOCKER_IMPORT_BAD_REQUEST": DockerImportBadRequestError,
2399
+ "FORK_VM_NOT_FOUND": ForkVmNotFoundError,
2400
+ "CREATE_SNAPSHOT_BAD_REQUEST": CreateSnapshotBadRequestError,
2401
+ "SNAPSHOT_VM_BAD_REQUEST": SnapshotVmBadRequestError,
2402
+ "FILE_NOT_FOUND": FileNotFoundError,
2403
+ "FILES_BAD_REQUEST": FilesBadRequestError,
2404
+ "VM_DELETED": VmDeletedError,
2405
+ "REQWEST": ReqwestError,
2406
+ "FIRECRACKER_PID_NOT_FOUND": FirecrackerPidNotFoundError,
2407
+ "FIRECRACKER_API_SOCKET_NOT_FOUND": FirecrackerApiSocketNotFoundError,
2408
+ "VM_START_TIMEOUT": VmStartTimeoutError,
2409
+ "VM_EXIT_DURING_START": VmExitDuringStartError,
2410
+ "STD_IO": StdIoError,
2411
+ "VM_CREATE_TMUX_SESSION": VmCreateTmuxSessionError,
2412
+ "VM_SUBNET_NOT_FOUND": VmSubnetNotFoundError,
2413
+ "VM_OPERATION_DENIED_DURING_TRANSACTION": VmOperationDeniedDuringTransactionError,
2414
+ "VM_TRANSACTION_ID_MISMATCH": VmTransactionIdMismatchError,
2415
+ "VM_NOT_IN_TRANSACTION": VmNotInTransactionError,
2416
+ "CREATE_VM_BAD_REQUEST": CreateVmBadRequestError,
2417
+ "USER_NOT_FOUND": UserNotFoundError,
2418
+ "USER_ALREADY_EXISTS": UserAlreadyExistsError,
2419
+ "VALIDATION_ERROR": ValidationErrorError,
2420
+ "GROUP_NOT_FOUND": GroupNotFoundError,
2421
+ "GROUP_ALREADY_EXISTS": GroupAlreadyExistsError,
2422
+ "DUPLICATE_USER_NAME": DuplicateUserNameError,
2423
+ "USER_GROUP_EMPTY": UserGroupEmptyError,
2424
+ "USER_SYSTEM_FLAG_MISMATCH": UserSystemFlagMismatchError,
2425
+ "USER_UID_OUT_OF_RANGE": UserUidOutOfRangeError,
2426
+ "USER_HOME_INVALID": UserHomeInvalidError,
2427
+ "USER_SHELL_INVALID": UserShellInvalidError,
2428
+ "DUPLICATE_GROUP_NAME": DuplicateGroupNameError,
2429
+ "GROUP_NAME_RESERVED": GroupNameReservedError,
2430
+ "GROUP_NAME_INVALID_CHARS": GroupNameInvalidCharsError,
2431
+ "GROUP_NAME_TOO_LONG": GroupNameTooLongError,
2432
+ "GROUP_NAME_EMPTY": GroupNameEmptyError,
2433
+ "WANTED_BY_EMPTY": WantedByEmptyError,
2434
+ "WORKDIR_EMPTY": WorkdirEmptyError,
2435
+ "GROUP_EMPTY": GroupEmptyError,
2436
+ "USER_EMPTY": UserEmptyError,
2437
+ "ON_FAILURE_ARRAY_CONTAINS_EMPTY": OnFailureArrayContainsEmptyError,
2438
+ "REQUIRES_ARRAY_CONTAINS_EMPTY": RequiresArrayContainsEmptyError,
2439
+ "AFTER_ARRAY_CONTAINS_EMPTY": AfterArrayContainsEmptyError,
2440
+ "ENV_KEY_CONTAINS_EQUALS": EnvKeyContainsEqualsError,
2441
+ "ENV_KEY_EMPTY": EnvKeyEmptyError,
2442
+ "EXEC_EMPTY": ExecEmptyError,
2443
+ "SERVICE_NAME_TOO_LONG": ServiceNameTooLongError,
2444
+ "SERVICE_NAME_INVALID_PREFIX": ServiceNameInvalidPrefixError,
2445
+ "SERVICE_NAME_INVALID_CHARS": ServiceNameInvalidCharsError,
2446
+ "SERVICE_NAME_EMPTY": ServiceNameEmptyError,
2447
+ "SERVICE_ALREADY_EXISTS": ServiceAlreadyExistsError,
2448
+ "SERVICE_NOT_FOUND": ServiceNotFoundError,
2449
+ "INTERNAL": InternalError,
2450
+ "SIGNING": SigningError,
2451
+ "INVALID_SIGNATURE": InvalidSignatureError,
2452
+ "INVALID_PARAMETERS": InvalidParametersError,
2453
+ "MAX_USES_EXCEEDED": MaxUsesExceededError,
2454
+ "EXPIRED": ExpiredError,
2455
+ "CONFLICT": ConflictError,
2456
+ "REPO_NOT_FOUND": RepoNotFoundError,
2457
+ "FORBIDDEN": ForbiddenError,
2458
+ "UNSUPPORTED_TRANSFER": UnsupportedTransferError,
2459
+ "BRANCH_NOT_FOUND": BranchNotFoundError,
2460
+ "INVALID_OBJECT_ID": InvalidObjectIdError,
2461
+ "BLOB_NOT_FOUND": BlobNotFoundError,
2462
+ "REFERENCE_NOT_FOUND": ReferenceNotFoundError,
2463
+ "TAG_NOT_FOUND": TagNotFoundError,
2464
+ "COMMIT_NOT_FOUND": CommitNotFoundError,
2465
+ "INVALID_REQUEST": InvalidRequestError,
2466
+ "PATH_NOT_FOUND": PathNotFoundError,
2467
+ "INVALID_REVISION": InvalidRevisionError,
2468
+ "UNAUTHORIZED": UnauthorizedError,
2469
+ "TREE_NOT_FOUND": TreeNotFoundError,
2470
+ "BUILD_FAILED": BuildFailedError,
2471
+ "NO_ENTRYPOINT_FOUND": NoEntrypointFoundError,
2472
+ "ENTRYPOINT_NOT_FOUND": EntrypointNotFoundError,
2473
+ "NO_DOMAIN_OWNERSHIP": NoDomainOwnershipError,
2474
+ "INVALID_DOMAINS": InvalidDomainsError,
2475
+ "WEB_DEPLOYMENT_BAD_REQUEST": WebDeploymentBadRequestError,
2476
+ "DEPLOYMENT_NOT_FOUND": DeploymentNotFoundError,
2477
+ "DATABASE_ERROR": DatabaseErrorError,
2478
+ "TRIGGER_ERROR": TriggerErrorError,
2479
+ "TOKEN_ERROR": TokenErrorError,
2480
+ "PERMISSION_ERROR": PermissionErrorError,
2481
+ "IDENTITY_ERROR": IdentityErrorError,
2482
+ "GET_CONTENT_FAILED": GetContentFailedError,
2483
+ "CONTENT_NOT_FOUND": ContentNotFoundError,
2484
+ "DOWNLOAD_FAILED": DownloadFailedError,
2485
+ "GIT_SERVER_ERROR": GitServerErrorError,
2486
+ "PARSE_RESPONSE_ERROR": ParseResponseErrorError,
2487
+ "REPOSITORY_ACCESS_DENIED": RepositoryAccessDeniedError,
2488
+ "GIT_HUB_SYNC_FAILED": GitHubSyncFailedError,
2489
+ "UPDATE_DEFAULT_BRANCH_FAILED": UpdateDefaultBranchFailedError,
2490
+ "GET_REPOSITORY_INFO_FAILED": GetRepositoryInfoFailedError,
2491
+ "LIST_REPOSITORIES_FAILED": ListRepositoriesFailedError,
2492
+ "DELETE_REPOSITORY_FAILED": DeleteRepositoryFailedError,
2493
+ "CREATE_REPOSITORY_FAILED": CreateRepositoryFailedError,
2494
+ "SERIALIZATION_ERROR": SerializationErrorError,
2495
+ "GIT_INVALID_REQUEST": GitInvalidRequestError,
2496
+ "REPOSITORY_NOT_FOUND": RepositoryNotFoundError,
2497
+ "FAILED_TO_PROVISION_CERTIFICATE": FailedToProvisionCertificateError,
2498
+ "FAILED_TO_INSERT_DOMAIN_MAPPING": FailedToInsertDomainMappingError,
2499
+ "PERMISSION_DENIED": PermissionDeniedError,
2500
+ "FAILED_TO_CHECK_PERMISSIONS": FailedToCheckPermissionsError,
2501
+ "FAILED_TO_LIST_DOMAINS": FailedToListDomainsError,
2502
+ "FAILED_TO_LIST_VERIFICATIONS": FailedToListVerificationsError,
2503
+ "FAILED_TO_VERIFY_DOMAIN": FailedToVerifyDomainError,
2504
+ "VERIFICATION_FAILED": VerificationFailedError,
2505
+ "FAILED_TO_DELETE_VERIFICATION": FailedToDeleteVerificationError,
2506
+ "VERIFICATION_NOT_FOUND": VerificationNotFoundError,
2507
+ "FAILED_TO_CREATE_VERIFICATION_CODE": FailedToCreateVerificationCodeError,
2508
+ "INVALID_DOMAIN": InvalidDomainError,
2509
+ "DOMAIN_ALREADY_EXISTS": DomainAlreadyExistsError,
2510
+ "FAILED_TO_INSERT_OWNERSHIP": FailedToInsertOwnershipError,
2511
+ "FAILED_REMOVE_DOMAIN_MAPPING": FailedRemoveDomainMappingError,
2512
+ "FAILED_PERMISSIONS_CHECK": FailedPermissionsCheckError,
2513
+ "FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS": FailedToCheckDomainMappingPermissionsError,
2514
+ "ANYHOW": AnyhowError,
2515
+ "OBSERVABILITY_DATABASE_ERROR": ObservabilityDatabaseErrorError,
2516
+ "OBSERVABILITY_ACCESS_DENIED": ObservabilityAccessDeniedError,
2517
+ "PARSE_LOGS_FAILED": ParseLogsFailedError,
2518
+ "RETRIEVE_LOGS_FAILED": RetrieveLogsFailedError,
2519
+ "INVALID_QUERY": InvalidQueryError,
2520
+ "LOGS_NOT_FOUND": LogsNotFoundError,
2521
+ "PERMISSION_ALREADY_EXISTS": PermissionAlreadyExistsError,
2522
+ "LIST_TOKENS_FAILED": ListTokensFailedError,
2523
+ "REVOKE_TOKEN_FAILED": RevokeTokenFailedError,
2524
+ "CREATE_TOKEN_FAILED": CreateTokenFailedError,
2525
+ "LIST_PERMISSIONS_FAILED": ListPermissionsFailedError,
2526
+ "GET_PERMISSION_FAILED": GetPermissionFailedError,
2527
+ "UPDATE_PERMISSION_FAILED": UpdatePermissionFailedError,
2528
+ "REVOKE_PERMISSION_FAILED": RevokePermissionFailedError,
2529
+ "GRANT_PERMISSION_FAILED": GrantPermissionFailedError,
2530
+ "LIST_IDENTITIES_FAILED": ListIdentitiesFailedError,
2531
+ "DELETE_IDENTITY_FAILED": DeleteIdentityFailedError,
2532
+ "CREATE_IDENTITY_FAILED": CreateIdentityFailedError,
2533
+ "VM_PERMISSION_NOT_FOUND": VmPermissionNotFoundError,
2534
+ "PERMISSION_NOT_FOUND": PermissionNotFoundError,
2535
+ "VM_ACCESS_DENIED": VmAccessDeniedError,
2536
+ "GIT_REPOSITORY_ACCESS_DENIED": GitRepositoryAccessDeniedError,
2537
+ "GIT_REPOSITORY_NOT_FOUND": GitRepositoryNotFoundError,
2538
+ "CANNOT_DELETE_MANAGED_IDENTITY": CannotDeleteManagedIdentityError,
2539
+ "CANNOT_MODIFY_MANAGED_IDENTITY": CannotModifyManagedIdentityError,
2540
+ "IDENTITY_ACCESS_DENIED": IdentityAccessDeniedError,
2541
+ "IDENTITY_NOT_FOUND": IdentityNotFoundError,
2542
+ "EXECUTE_INTERNAL_ERROR": ExecuteInternalErrorError,
2543
+ "EXECUTE_ACCESS_DENIED": ExecuteAccessDeniedError,
2544
+ "LIST_RUNS_FAILED": ListRunsFailedError,
2545
+ "EXECUTION_ERROR": ExecutionErrorError,
2546
+ "CONNECTION_FAILED": ConnectionFailedError,
2547
+ "METADATA_WRITE_FAILED": MetadataWriteFailedError,
2548
+ "NODE_MODULES_INSTALL_FAILED": NodeModulesInstallFailedError,
2549
+ "NODE_MODULES_DOWNLOAD_FAILED": NodeModulesDownloadFailedError,
2550
+ "LOCK_GENERATION_FAILED": LockGenerationFailedError,
2551
+ "WRITE_SCRIPT_FAILED": WriteScriptFailedError,
2552
+ "DIRECTORY_CREATION_FAILED": DirectoryCreationFailedError,
2553
+ "NETWORK_PERMISSIONS_FAILED": NetworkPermissionsFailedError,
2554
+ "LOGGING_FAILED": LoggingFailedError,
2555
+ "RUN_NOT_FOUND": RunNotFoundError,
2556
+ "CLOUDSTATE_INTERNAL_ERROR": CloudstateInternalErrorError,
2557
+ "CLOUDSTATE_DATABASE_ERROR": CloudstateDatabaseErrorError,
2558
+ "CLOUDSTATE_ACCESS_DENIED": CloudstateAccessDeniedError,
2559
+ "RESTORE_FAILED": RestoreFailedError,
2560
+ "CREATE_BACKUP_FAILED": CreateBackupFailedError,
2561
+ "BACKUP_FAILED": BackupFailedError,
2562
+ "DEPLOYMENT_FAILED": DeploymentFailedError,
2563
+ "INVALID_DEPLOYMENT_REQUEST": InvalidDeploymentRequestError,
2564
+ "PROJECT_NOT_FOUND": ProjectNotFoundError,
2565
+ "RESIZE_FAILED": ResizeFailedError,
2566
+ "INTERNAL_RESIZE_VM_NOT_FOUND": InternalResizeVmNotFoundError,
2567
+ "DOMAIN_OWNERSHIP_VERIFICATION_FAILED": DomainOwnershipVerificationFailedError,
2568
+ "ERROR_DELETING_RECORD": ErrorDeletingRecordError,
2569
+ "RECORD_OWNERSHIP_ERROR": RecordOwnershipErrorError,
2570
+ "ERROR_CREATING_RECORD": ErrorCreatingRecordError,
2571
+ "DOMAIN_OWNERSHIP_ERROR": DomainOwnershipErrorError,
2572
+ "BROWSER_OPERATION_FAILED": BrowserOperationFailedError,
2573
+ "WATCH_FILES_FAILED": WatchFilesFailedError,
2574
+ "LOGS_FAILED": LogsFailedError,
2575
+ "STATUS_FAILED": StatusFailedError,
2576
+ "RESTART_FAILED": RestartFailedError,
2577
+ "SHUTDOWN_FAILED": ShutdownFailedError,
2578
+ "COMMIT_FAILED": CommitFailedError,
2579
+ "WRITE_FILE_FAILED": WriteFileFailedError,
2580
+ "READ_FILE_FAILED": ReadFileFailedError,
2581
+ "EXECUTION_FAILED": ExecutionFailedError,
2582
+ "REQUEST_FAILED": RequestFailedError,
2583
+ "DEV_SERVER_FILE_NOT_FOUND": DevServerFileNotFoundError,
2584
+ "DEV_SERVER_INVALID_REQUEST": DevServerInvalidRequestError,
2585
+ "DEV_SERVER_NOT_FOUND": DevServerNotFoundError
2586
+ };
2587
+
2588
+ var errors = /*#__PURE__*/Object.freeze({
2589
+ __proto__: null,
2590
+ AfterArrayContainsEmptyError: AfterArrayContainsEmptyError,
2591
+ AlreadyHasBaseError: AlreadyHasBaseError,
2592
+ AnyhowError: AnyhowError,
2593
+ BackupFailedError: BackupFailedError,
2594
+ BadRequestError: BadRequestError,
2595
+ BlobNotFoundError: BlobNotFoundError,
2596
+ BranchNotFoundError: BranchNotFoundError,
2597
+ BrowserOperationFailedError: BrowserOperationFailedError,
2598
+ BuildFailedError: BuildFailedError,
2599
+ CannotDeleteManagedIdentityError: CannotDeleteManagedIdentityError,
2600
+ CannotModifyManagedIdentityError: CannotModifyManagedIdentityError,
2601
+ CloudstateAccessDeniedError: CloudstateAccessDeniedError,
2602
+ CloudstateDatabaseErrorError: CloudstateDatabaseErrorError,
2603
+ CloudstateInternalErrorError: CloudstateInternalErrorError,
2604
+ CommitFailedError: CommitFailedError,
2605
+ CommitNotFoundError: CommitNotFoundError,
2606
+ ConflictError: ConflictError,
2607
+ ConnectionFailedError: ConnectionFailedError,
2608
+ ContentNotFoundError: ContentNotFoundError,
2609
+ CreateBackupFailedError: CreateBackupFailedError,
2610
+ CreateIdentityFailedError: CreateIdentityFailedError,
2611
+ CreateRepositoryFailedError: CreateRepositoryFailedError,
2612
+ CreateSnapshotBadRequestError: CreateSnapshotBadRequestError,
2613
+ CreateTokenFailedError: CreateTokenFailedError,
2614
+ CreateVmBadRequestError: CreateVmBadRequestError,
2615
+ DatabaseErrorError: DatabaseErrorError,
2616
+ DeleteIdentityFailedError: DeleteIdentityFailedError,
2617
+ DeleteRepositoryFailedError: DeleteRepositoryFailedError,
2618
+ DeploymentFailedError: DeploymentFailedError,
2619
+ DeploymentNotFoundError: DeploymentNotFoundError,
2620
+ DevServerFileNotFoundError: DevServerFileNotFoundError,
2621
+ DevServerInvalidRequestError: DevServerInvalidRequestError,
2622
+ DevServerNotFoundError: DevServerNotFoundError,
2623
+ DirectoryCreationFailedError: DirectoryCreationFailedError,
2624
+ DockerImportBadRequestError: DockerImportBadRequestError,
2625
+ DomainAlreadyExistsError: DomainAlreadyExistsError,
2626
+ DomainOwnershipErrorError: DomainOwnershipErrorError,
2627
+ DomainOwnershipVerificationFailedError: DomainOwnershipVerificationFailedError,
2628
+ DownloadFailedError: DownloadFailedError,
2629
+ DuplicateGroupNameError: DuplicateGroupNameError,
2630
+ DuplicateUserNameError: DuplicateUserNameError,
2631
+ EntrypointNotFoundError: EntrypointNotFoundError,
2632
+ EnvKeyContainsEqualsError: EnvKeyContainsEqualsError,
2633
+ EnvKeyEmptyError: EnvKeyEmptyError,
2634
+ ErrorCreatingRecordError: ErrorCreatingRecordError,
2635
+ ErrorDeletingRecordError: ErrorDeletingRecordError,
2636
+ ExecEmptyError: ExecEmptyError,
2637
+ ExecuteAccessDeniedError: ExecuteAccessDeniedError,
2638
+ ExecuteInternalErrorError: ExecuteInternalErrorError,
2639
+ ExecutionErrorError: ExecutionErrorError,
2640
+ ExecutionFailedError: ExecutionFailedError,
2641
+ ExpiredError: ExpiredError,
2642
+ FREESTYLE_ERROR_CODE_MAP: FREESTYLE_ERROR_CODE_MAP,
2643
+ FailedPermissionsCheckError: FailedPermissionsCheckError,
2644
+ FailedRemoveDomainMappingError: FailedRemoveDomainMappingError,
2645
+ FailedToCheckDomainMappingPermissionsError: FailedToCheckDomainMappingPermissionsError,
2646
+ FailedToCheckPermissionsError: FailedToCheckPermissionsError,
2647
+ FailedToCreateVerificationCodeError: FailedToCreateVerificationCodeError,
2648
+ FailedToDeleteVerificationError: FailedToDeleteVerificationError,
2649
+ FailedToInsertDomainMappingError: FailedToInsertDomainMappingError,
2650
+ FailedToInsertOwnershipError: FailedToInsertOwnershipError,
2651
+ FailedToListDomainsError: FailedToListDomainsError,
2652
+ FailedToListVerificationsError: FailedToListVerificationsError,
2653
+ FailedToProvisionCertificateError: FailedToProvisionCertificateError,
2654
+ FailedToVerifyDomainError: FailedToVerifyDomainError,
2655
+ FileNotFoundError: FileNotFoundError,
2656
+ FilesBadRequestError: FilesBadRequestError,
2657
+ FirecrackerApiSocketNotFoundError: FirecrackerApiSocketNotFoundError,
2658
+ FirecrackerPidNotFoundError: FirecrackerPidNotFoundError,
2659
+ ForbiddenError: ForbiddenError,
2660
+ ForkVmNotFoundError: ForkVmNotFoundError,
2661
+ GetContentFailedError: GetContentFailedError,
2662
+ GetPermissionFailedError: GetPermissionFailedError,
2663
+ GetRepositoryInfoFailedError: GetRepositoryInfoFailedError,
2664
+ GitHubSyncFailedError: GitHubSyncFailedError,
2665
+ GitInvalidRequestError: GitInvalidRequestError,
2666
+ GitRepositoryAccessDeniedError: GitRepositoryAccessDeniedError,
2667
+ GitRepositoryNotFoundError: GitRepositoryNotFoundError,
2668
+ GitServerErrorError: GitServerErrorError,
2669
+ GrantPermissionFailedError: GrantPermissionFailedError,
2670
+ GroupAlreadyExistsError: GroupAlreadyExistsError,
2671
+ GroupEmptyError: GroupEmptyError,
2672
+ GroupNameEmptyError: GroupNameEmptyError,
2673
+ GroupNameInvalidCharsError: GroupNameInvalidCharsError,
2674
+ GroupNameReservedError: GroupNameReservedError,
2675
+ GroupNameTooLongError: GroupNameTooLongError,
2676
+ GroupNotFoundError: GroupNotFoundError,
2677
+ IdentityAccessDeniedError: IdentityAccessDeniedError,
2678
+ IdentityErrorError: IdentityErrorError,
2679
+ IdentityNotFoundError: IdentityNotFoundError,
2680
+ InternalError: InternalError,
2681
+ InternalErrorError: InternalErrorError,
2682
+ InternalForkVmNotFoundError: InternalForkVmNotFoundError,
2683
+ InternalResizeVmNotFoundError: InternalResizeVmNotFoundError,
2684
+ InternalVmNotFoundError: InternalVmNotFoundError,
2685
+ InvalidDeploymentRequestError: InvalidDeploymentRequestError,
2686
+ InvalidDomainError: InvalidDomainError,
2687
+ InvalidDomainsError: InvalidDomainsError,
2688
+ InvalidObjectIdError: InvalidObjectIdError,
2689
+ InvalidParametersError: InvalidParametersError,
2690
+ InvalidQueryError: InvalidQueryError,
2691
+ InvalidRequestError: InvalidRequestError,
2692
+ InvalidRevisionError: InvalidRevisionError,
2693
+ InvalidSignatureError: InvalidSignatureError,
2694
+ ListIdentitiesFailedError: ListIdentitiesFailedError,
2695
+ ListPermissionsFailedError: ListPermissionsFailedError,
2696
+ ListRepositoriesFailedError: ListRepositoriesFailedError,
2697
+ ListRunsFailedError: ListRunsFailedError,
2698
+ ListTokensFailedError: ListTokensFailedError,
2699
+ LockGenerationFailedError: LockGenerationFailedError,
2700
+ LoggingFailedError: LoggingFailedError,
2701
+ LogsFailedError: LogsFailedError,
2702
+ LogsNotFoundError: LogsNotFoundError,
2703
+ MaxUsesExceededError: MaxUsesExceededError,
2704
+ MetadataWriteFailedError: MetadataWriteFailedError,
2705
+ NetworkPermissionsFailedError: NetworkPermissionsFailedError,
2706
+ NoDomainOwnershipError: NoDomainOwnershipError,
2707
+ NoEntrypointFoundError: NoEntrypointFoundError,
2708
+ NodeModulesDownloadFailedError: NodeModulesDownloadFailedError,
2709
+ NodeModulesInstallFailedError: NodeModulesInstallFailedError,
2710
+ NotFoundError: NotFoundError,
2711
+ ObservabilityAccessDeniedError: ObservabilityAccessDeniedError,
2712
+ ObservabilityDatabaseErrorError: ObservabilityDatabaseErrorError,
2713
+ OnFailureArrayContainsEmptyError: OnFailureArrayContainsEmptyError,
2714
+ ParseLogsFailedError: ParseLogsFailedError,
2715
+ ParseResponseErrorError: ParseResponseErrorError,
2716
+ PathNotFoundError: PathNotFoundError,
2717
+ PermissionAlreadyExistsError: PermissionAlreadyExistsError,
2718
+ PermissionDeniedError: PermissionDeniedError,
2719
+ PermissionErrorError: PermissionErrorError,
2720
+ PermissionNotFoundError: PermissionNotFoundError,
2721
+ ProjectNotFoundError: ProjectNotFoundError,
2722
+ ReadFileFailedError: ReadFileFailedError,
2723
+ RecordOwnershipErrorError: RecordOwnershipErrorError,
2724
+ ReferenceNotFoundError: ReferenceNotFoundError,
2725
+ RepoNotFoundError: RepoNotFoundError,
2726
+ RepositoryAccessDeniedError: RepositoryAccessDeniedError,
2727
+ RepositoryNotFoundError: RepositoryNotFoundError,
2728
+ RequestFailedError: RequestFailedError,
2729
+ RequiresArrayContainsEmptyError: RequiresArrayContainsEmptyError,
2730
+ ReqwestError: ReqwestError,
2731
+ ResizeFailedError: ResizeFailedError,
2732
+ RestartFailedError: RestartFailedError,
2733
+ RestoreFailedError: RestoreFailedError,
2734
+ RetrieveLogsFailedError: RetrieveLogsFailedError,
2735
+ RevokePermissionFailedError: RevokePermissionFailedError,
2736
+ RevokeTokenFailedError: RevokeTokenFailedError,
2737
+ RunNotFoundError: RunNotFoundError,
2738
+ SerializationErrorError: SerializationErrorError,
2739
+ ServiceAlreadyExistsError: ServiceAlreadyExistsError,
2740
+ ServiceNameEmptyError: ServiceNameEmptyError,
2741
+ ServiceNameInvalidCharsError: ServiceNameInvalidCharsError,
2742
+ ServiceNameInvalidPrefixError: ServiceNameInvalidPrefixError,
2743
+ ServiceNameTooLongError: ServiceNameTooLongError,
2744
+ ServiceNotFoundError: ServiceNotFoundError,
2745
+ ShutdownFailedError: ShutdownFailedError,
2746
+ SigningError: SigningError,
2747
+ SnapshotVmBadRequestError: SnapshotVmBadRequestError,
2748
+ StatusFailedError: StatusFailedError,
2749
+ StdIoError: StdIoError,
2750
+ TagNotFoundError: TagNotFoundError,
2751
+ TokenErrorError: TokenErrorError,
2752
+ TreeNotFoundError: TreeNotFoundError,
2753
+ TriggerErrorError: TriggerErrorError,
2754
+ UnauthorizedError: UnauthorizedError,
2755
+ UnsupportedTransferError: UnsupportedTransferError,
2756
+ UpdateDefaultBranchFailedError: UpdateDefaultBranchFailedError,
2757
+ UpdatePermissionFailedError: UpdatePermissionFailedError,
2758
+ UserAlreadyExistsError: UserAlreadyExistsError,
2759
+ UserEmptyError: UserEmptyError,
2760
+ UserGroupEmptyError: UserGroupEmptyError,
2761
+ UserHomeInvalidError: UserHomeInvalidError,
2762
+ UserNotFoundError: UserNotFoundError,
2763
+ UserShellInvalidError: UserShellInvalidError,
2764
+ UserSystemFlagMismatchError: UserSystemFlagMismatchError,
2765
+ UserUidOutOfRangeError: UserUidOutOfRangeError,
2766
+ ValidationErrorError: ValidationErrorError,
2767
+ VerificationFailedError: VerificationFailedError,
2768
+ VerificationNotFoundError: VerificationNotFoundError,
2769
+ VmAccessDeniedError: VmAccessDeniedError,
2770
+ VmCreateTmuxSessionError: VmCreateTmuxSessionError,
2771
+ VmDeletedError: VmDeletedError,
2772
+ VmExitDuringStartError: VmExitDuringStartError,
2773
+ VmMustBeStoppedError: VmMustBeStoppedError,
2774
+ VmNotFoundError: VmNotFoundError,
2775
+ VmNotFoundInFsError: VmNotFoundInFsError,
2776
+ VmNotInTransactionError: VmNotInTransactionError,
2777
+ VmNotRunningError: VmNotRunningError,
2778
+ VmOperationDeniedDuringTransactionError: VmOperationDeniedDuringTransactionError,
2779
+ VmPermissionNotFoundError: VmPermissionNotFoundError,
2780
+ VmStartTimeoutError: VmStartTimeoutError,
2781
+ VmSubnetNotFoundError: VmSubnetNotFoundError,
2782
+ VmTransactionIdMismatchError: VmTransactionIdMismatchError,
2783
+ WantedByEmptyError: WantedByEmptyError,
2784
+ WatchFilesFailedError: WatchFilesFailedError,
2785
+ WebDeploymentBadRequestError: WebDeploymentBadRequestError,
2786
+ WorkdirEmptyError: WorkdirEmptyError,
2787
+ WriteFileFailedError: WriteFileFailedError,
2788
+ WriteScriptFailedError: WriteScriptFailedError,
2789
+ errorFromJSON: errorFromJSON
2790
+ });
2791
+
2792
+ const SDK_VERSION = "0.1.0";
2793
+ const SDK_NAME = "freestyle-sdk-ts";
2794
+ class ApiClient {
2795
+ baseUrl;
2796
+ apiKey;
2797
+ accessToken;
2798
+ fetchFn;
2799
+ constructor(config = {}) {
2800
+ this.baseUrl = config.baseUrl || "https://api.freestyle.sh";
2801
+ this.apiKey = "apiKey" in config ? config.apiKey : void 0;
2802
+ this.accessToken = "accessToken" in config ? config.accessToken : void 0;
2803
+ this.fetchFn = config.fetch || fetch;
2804
+ }
2805
+ buildUrl(path, params, query) {
2806
+ let url = path;
2807
+ if (params) {
2808
+ for (const [key, value] of Object.entries(params)) {
2809
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
2810
+ }
2811
+ }
2812
+ if (query) {
2813
+ const searchParams = new URLSearchParams();
2814
+ for (const [key, value] of Object.entries(query)) {
2815
+ if (value !== void 0 && value !== null) {
2816
+ searchParams.append(key, String(value));
2817
+ }
2818
+ }
2819
+ const queryString = searchParams.toString();
2820
+ if (queryString) {
2821
+ url += `?${queryString}`;
2822
+ }
2823
+ }
2824
+ return this.baseUrl + url;
2825
+ }
2826
+ getDefaultHeaders() {
2827
+ const headers = {
2828
+ "X-Freestyle-SDK": SDK_NAME,
2829
+ "X-Freestyle-SDK-Version": SDK_VERSION,
2830
+ "User-Agent": `${SDK_NAME}/${SDK_VERSION}`
2831
+ };
2832
+ if (this.apiKey) {
2833
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
2834
+ } else if (this.accessToken) {
2835
+ headers["X-Freestyle-Identity-Access-Token"] = this.accessToken;
2836
+ }
2837
+ return headers;
2838
+ }
2839
+ async request(method, url, body) {
2840
+ const headers = this.getDefaultHeaders();
2841
+ if (body) {
2842
+ headers["Content-Type"] = "application/json";
2843
+ }
2844
+ const response = await this.fetchFn(url, {
2845
+ method,
2846
+ headers,
2847
+ body: body ? JSON.stringify(body) : void 0
2848
+ });
2849
+ if (!response.ok) {
2850
+ const errorData = await response.json();
2851
+ throw errorFromJSON(errorData);
2852
+ }
2853
+ return response.json();
2854
+ }
2855
+ async fetch(url, options) {
2856
+ const headers = this.getDefaultHeaders();
2857
+ const finalOptions = {
2858
+ ...options,
2859
+ headers: {
2860
+ ...headers,
2861
+ ...options?.headers || {}
2862
+ }
2863
+ };
2864
+ return this.fetchFn(url, finalOptions);
2865
+ }
2866
+ get(path, ...args) {
2867
+ const options = args[0];
2868
+ const url = this.buildUrl(path, options?.params, options?.query);
2869
+ return this.request("GET", url, options?.body);
2870
+ }
2871
+ post(path, ...args) {
2872
+ const options = args[0];
2873
+ const url = this.buildUrl(path, options?.params, options?.query);
2874
+ return this.request("POST", url, options?.body);
2875
+ }
2876
+ put(path, ...args) {
2877
+ const options = args[0];
2878
+ const url = this.buildUrl(path, options?.params, options?.query);
2879
+ return this.request("PUT", url, options?.body);
2880
+ }
2881
+ delete(path, ...args) {
2882
+ const options = args[0];
2883
+ const url = this.buildUrl(path, options?.params, options?.query);
2884
+ return this.request("DELETE", url, options?.body);
2885
+ }
2886
+ patch(path, ...args) {
2887
+ const options = args[0];
2888
+ const url = this.buildUrl(path, options?.params, options?.query);
2889
+ return this.request("PATCH", url, options?.body);
2890
+ }
2891
+ }
2892
+
2893
+ class DomainVerificationsNamespace {
2894
+ constructor(apiClient) {
2895
+ this.apiClient = apiClient;
2896
+ }
2897
+ /**
2898
+ * Create a domain verification request.
2899
+ */
2900
+ async create({ domain }) {
2901
+ const response = await this.apiClient.post("/domains/v1/verifications", {
2902
+ body: { domain }
2903
+ });
2904
+ return {
2905
+ verificationId: response.id,
2906
+ instructions: `Navigate to your domain's DNS settings and create a TXT record with the following details:
2907
+
2908
+ Name: _freestyle-verification.${domain}
2909
+
2910
+ Value: ${response.verificationCode}
2911
+
2912
+ After adding the record, return here to complete the verification process. Note that DNS changes may take some time to propagate. If verification fails after waiting a few minutes, try setting the Name to just "_freestyle-verification". Some DNS providers automatically append the domain name to the record name.`,
2913
+ record: {
2914
+ type: "TXT",
2915
+ name: `_freestyle-verification.${domain}`,
2916
+ value: response.verificationCode
2917
+ }
2918
+ };
2919
+ }
2920
+ /**
2921
+ * Complete a domain verification by domain or verification ID.
2922
+ */
2923
+ async complete(options) {
2924
+ return this.apiClient.put("/domains/v1/verifications", {
2925
+ body: "verificationId" in options ? { id: options.verificationId } : { domain: options.domain }
2926
+ });
2927
+ }
2928
+ /**
2929
+ * List domain verification requests.
2930
+ */
2931
+ async list() {
2932
+ return this.apiClient.get("/domains/v1/verifications", void 0);
2933
+ }
2934
+ /**
2935
+ * Cancel a domain verification request.
2936
+ */
2937
+ async cancel({
2938
+ domain,
2939
+ verificationCode
2940
+ }) {
2941
+ return this.apiClient.delete("/domains/v1/verifications", {
2942
+ body: { domain, verificationCode }
2943
+ });
2944
+ }
2945
+ }
2946
+ class DomainCertificatesNamespace {
2947
+ constructor(apiClient) {
2948
+ this.apiClient = apiClient;
2949
+ }
2950
+ /**
2951
+ * Provision a wildcard certificate for a domain.
2952
+ */
2953
+ async createWildcard({
2954
+ domain
2955
+ }) {
2956
+ return this.apiClient.post("/domains/v1/certs/{domain}/wildcard", {
2957
+ params: { domain }
2958
+ });
2959
+ }
2960
+ }
2961
+ class DomainMappingsNamespace {
2962
+ constructor(apiClient) {
2963
+ this.apiClient = apiClient;
2964
+ }
2965
+ /**
2966
+ * Create a domain mapping to a deployment.
2967
+ */
2968
+ async create({
2969
+ domain,
2970
+ deploymentId
2971
+ }) {
2972
+ return this.apiClient.post("/domains/v1/mappings/{domain}", {
2973
+ params: { domain },
2974
+ body: { deploymentId }
2975
+ });
2976
+ }
2977
+ /**
2978
+ * Delete a domain mapping.
2979
+ */
2980
+ async delete({
2981
+ domain
2982
+ }) {
2983
+ return this.apiClient.delete("/domains/v1/mappings/{domain}", {
2984
+ params: { domain }
2985
+ });
2986
+ }
2987
+ /**
2988
+ * List domain mappings.
2989
+ */
2990
+ async list({
2991
+ domain,
2992
+ domainOwnership,
2993
+ limit = 10,
2994
+ cursor
2995
+ } = {}) {
2996
+ const offset = cursor ? parseInt(cursor, 10) : 0;
2997
+ const mappings = await this.apiClient.get("/domains/v1/mappings", {
2998
+ query: { domain, domainOwnership, limit, offset }
2999
+ });
3000
+ return { mappings };
3001
+ }
3002
+ }
3003
+ class DomainsNamespace {
3004
+ constructor(apiClient) {
3005
+ this.apiClient = apiClient;
3006
+ this.verifications = new DomainVerificationsNamespace(apiClient);
3007
+ this.certificates = new DomainCertificatesNamespace(apiClient);
3008
+ this.mappings = new DomainMappingsNamespace(apiClient);
3009
+ }
3010
+ verifications;
3011
+ certificates;
3012
+ mappings;
3013
+ /**
3014
+ * List verified domains.
3015
+ */
3016
+ async list({
3017
+ limit,
3018
+ cursor
3019
+ } = {}) {
3020
+ const offset = cursor ? parseInt(cursor, 10) : 0;
3021
+ return this.apiClient.get("/domains/v1/domains", {
3022
+ query: { limit, offset }
3023
+ });
3024
+ }
3025
+ }
3026
+
3027
+ class GitRepo {
3028
+ constructor(repoId, apiClient) {
3029
+ this.apiClient = apiClient;
3030
+ this.repoId = repoId;
3031
+ }
3032
+ repoId;
3033
+ /**
3034
+ * Set the default branch for this repository.
3035
+ */
3036
+ async setDefaultBranch({
3037
+ defaultBranch
3038
+ }) {
3039
+ return this.apiClient.put("/git/v1/repo/{repo_id}/default-branch", {
3040
+ params: { repo_id: this.repoId },
3041
+ body: { defaultBranch }
3042
+ });
3043
+ }
3044
+ /**
3045
+ * Get the default branch for this repository.
3046
+ */
3047
+ async getDefaultBranch() {
3048
+ return this.apiClient.get("/git/v1/repo/{repo_id}/default-branch", {
3049
+ params: { repo_id: this.repoId }
3050
+ });
3051
+ }
3052
+ /**
3053
+ * Get the contents of this repository at the given path.
3054
+ */
3055
+ async getContents({
3056
+ path = "",
3057
+ ref
3058
+ } = {}) {
3059
+ return this.apiClient.get("/git/v1/repo/{repo}/contents/{path}", {
3060
+ params: { repo: this.repoId, path },
3061
+ query: { ref }
3062
+ });
3063
+ }
3064
+ /**
3065
+ * Get the GitHub sync configuration for this repository.
3066
+ */
3067
+ async getGitHubSyncConfig() {
3068
+ try {
3069
+ return await this.apiClient.get("/git/v1/repo/{repo_id}/github-sync", {
3070
+ params: { repo_id: this.repoId }
3071
+ });
3072
+ } catch (error) {
3073
+ if (error.message?.includes("404")) {
3074
+ return null;
3075
+ }
3076
+ throw error;
3077
+ }
3078
+ }
3079
+ /**
3080
+ * List git triggers for this repository.
3081
+ */
3082
+ async listTriggers() {
3083
+ return this.apiClient.get("/git/v1/repo/{repo}/trigger", {
3084
+ params: { repo: this.repoId }
3085
+ });
3086
+ }
3087
+ /**
3088
+ * Create a git trigger for this repository.
3089
+ */
3090
+ async createTrigger({
3091
+ trigger,
3092
+ action
3093
+ }) {
3094
+ const response = await this.apiClient.post("/git/v1/repo/{repo}/trigger", {
3095
+ params: { repo: this.repoId },
3096
+ body: { trigger, action }
3097
+ });
3098
+ return {
3099
+ triggerId: response.triggerId
3100
+ };
3101
+ }
3102
+ /**
3103
+ * Delete a git trigger.
3104
+ */
3105
+ async deleteTrigger({
3106
+ triggerId
3107
+ }) {
3108
+ return this.apiClient.delete("/git/v1/repo/{repo}/trigger/{trigger}", {
3109
+ params: { repo: this.repoId, trigger: triggerId }
3110
+ });
3111
+ }
3112
+ }
3113
+ class GitReposNamespace {
3114
+ constructor(apiClient) {
3115
+ this.apiClient = apiClient;
3116
+ }
3117
+ /**
3118
+ * Create a new git repository.
3119
+ */
3120
+ async create({ ...body }) {
3121
+ const response = await this.apiClient.post("/git/v1/repo", { body });
3122
+ const repoId = response.repoId;
3123
+ return {
3124
+ repoId,
3125
+ repo: new GitRepo(repoId, this.apiClient)
3126
+ };
3127
+ }
3128
+ /**
3129
+ * List git repositories.
3130
+ */
3131
+ async list({
3132
+ limit = 10,
3133
+ cursor
3134
+ } = {}) {
3135
+ const offset = cursor ? parseInt(cursor, 10) : 0;
3136
+ return this.apiClient.get("/git/v1/repo", {
3137
+ query: { limit, offset }
3138
+ });
3139
+ }
3140
+ /**
3141
+ * Get a repository instance by ID.
3142
+ */
3143
+ instance({ repoId }) {
3144
+ return new GitRepo(repoId, this.apiClient);
3145
+ }
3146
+ /**
3147
+ * Delete a git repository.
3148
+ */
3149
+ async delete({
3150
+ repoId
3151
+ }) {
3152
+ return this.apiClient.delete("/git/v1/repo/{repo}", {
3153
+ params: { repo: repoId }
3154
+ });
3155
+ }
3156
+ }
3157
+ class GitNamespace {
3158
+ constructor(apiClient, freestyle) {
3159
+ this.apiClient = apiClient;
3160
+ this.freestyle = freestyle;
3161
+ this.repos = new GitReposNamespace(apiClient);
3162
+ }
3163
+ repos;
3164
+ }
3165
+
3166
+ class Identity {
3167
+ constructor(identityId, apiClient) {
3168
+ this.apiClient = apiClient;
3169
+ this.identityId = identityId;
3170
+ this.permissions = new IdentityPermissions(identityId, apiClient);
3171
+ }
3172
+ identityId;
3173
+ permissions;
3174
+ /**
3175
+ * Create a new access token for this identity.
3176
+ */
3177
+ async createToken() {
3178
+ const response = await this.apiClient.post(
3179
+ "/identity/v1/identities/{identity}/tokens",
3180
+ {
3181
+ params: { identity: this.identityId }
3182
+ }
3183
+ );
3184
+ return {
3185
+ tokenId: response.id,
3186
+ token: response.token
3187
+ };
3188
+ }
3189
+ /**
3190
+ * Revoke an access token.
3191
+ */
3192
+ async revokeToken({
3193
+ tokenId
3194
+ }) {
3195
+ return this.apiClient.delete(
3196
+ "/identity/v1/identities/{identity}/tokens/{token}",
3197
+ {
3198
+ params: { identity: this.identityId, token: tokenId }
3199
+ }
3200
+ );
3201
+ }
3202
+ /**
3203
+ * List access tokens for this identity.
3204
+ */
3205
+ async listTokens() {
3206
+ return this.apiClient.get("/identity/v1/identities/{identity}/tokens", {
3207
+ params: { identity: this.identityId }
3208
+ });
3209
+ }
3210
+ }
3211
+ class IdentityPermissions {
3212
+ constructor(identityId, apiClient) {
3213
+ this.identityId = identityId;
3214
+ this.apiClient = apiClient;
3215
+ this.git = new GitPermissions(identityId, apiClient);
3216
+ this.vms = new VmPermissions(identityId, apiClient);
3217
+ }
3218
+ git;
3219
+ vms;
3220
+ }
3221
+ class GitPermissions {
3222
+ constructor(identityId, apiClient) {
3223
+ this.identityId = identityId;
3224
+ this.apiClient = apiClient;
3225
+ }
3226
+ /**
3227
+ * List all git repository access permissions for this identity.
3228
+ */
3229
+ async list({
3230
+ limit,
3231
+ cursor
3232
+ } = {}) {
3233
+ const offset = cursor ? parseInt(cursor, 10) : 0;
3234
+ return this.apiClient.get(
3235
+ "/identity/v1/identities/{identity}/permissions/git",
3236
+ {
3237
+ params: { identity: this.identityId },
3238
+ query: { limit, offset }
3239
+ }
3240
+ );
3241
+ }
3242
+ /**
3243
+ * Get this identity's permission level for a specific repository.
3244
+ */
3245
+ async get({
3246
+ repoId
3247
+ }) {
3248
+ return this.apiClient.get(
3249
+ "/identity/v1/identities/{identity}/permissions/git/{repo}",
3250
+ {
3251
+ params: { identity: this.identityId, repo: repoId }
3252
+ }
3253
+ );
3254
+ }
3255
+ /**
3256
+ * Update this identity's access to a repository.
3257
+ */
3258
+ async update({
3259
+ repoId,
3260
+ permission
3261
+ }) {
3262
+ return this.apiClient.put(
3263
+ "/identity/v1/identities/{identity}/permissions/git/{repo}",
3264
+ {
3265
+ params: { identity: this.identityId, repo: repoId },
3266
+ body: { permission }
3267
+ }
3268
+ );
3269
+ }
3270
+ /**
3271
+ * Grant this identity access to a repository.
3272
+ */
3273
+ async create({
3274
+ repoId,
3275
+ permission
3276
+ }) {
3277
+ return this.apiClient.post(
3278
+ "/identity/v1/identities/{identity}/permissions/git/{repo}",
3279
+ {
3280
+ params: { identity: this.identityId, repo: repoId },
3281
+ body: { permission }
3282
+ }
3283
+ );
3284
+ }
3285
+ /**
3286
+ * Revoke this identity's access to a repository.
3287
+ */
3288
+ async delete({
3289
+ repoId
3290
+ }) {
3291
+ return this.apiClient.delete(
3292
+ "/identity/v1/identities/{identity}/permissions/git/{repo}",
3293
+ {
3294
+ params: { identity: this.identityId, repo: repoId }
3295
+ }
3296
+ );
3297
+ }
3298
+ }
3299
+ class VmPermissions {
3300
+ constructor(identityId, apiClient) {
3301
+ this.identityId = identityId;
3302
+ this.apiClient = apiClient;
3303
+ }
3304
+ /**
3305
+ * List all VM access permissions for this identity.
3306
+ */
3307
+ async list({
3308
+ limit,
3309
+ cursor
3310
+ } = {}) {
3311
+ const offset = cursor ? parseInt(cursor, 10) : 0;
3312
+ return this.apiClient.get(
3313
+ "/identity/v1/identities/{identity}/permissions/vm",
3314
+ {
3315
+ params: { identity: this.identityId },
3316
+ query: { limit, offset }
3317
+ }
3318
+ );
3319
+ }
3320
+ /**
3321
+ * Get this identity's permission level for a specific VM.
3322
+ */
3323
+ async get({
3324
+ vmId
3325
+ }) {
3326
+ return this.apiClient.get(
3327
+ "/identity/v1/identities/{identity}/permissions/vm/{vm_id}",
3328
+ {
3329
+ params: { identity: this.identityId, vm_id: vmId }
3330
+ }
3331
+ );
3332
+ }
3333
+ /**
3334
+ * Update this identity's access to a VM.
3335
+ */
3336
+ async update({
3337
+ vmId,
3338
+ allowedUsers
3339
+ }) {
3340
+ return this.apiClient.put(
3341
+ "/identity/v1/identities/{identity}/permissions/vm/{vm_id}",
3342
+ {
3343
+ params: { identity: this.identityId, vm_id: vmId },
3344
+ body: { allowedUsers }
3345
+ }
3346
+ );
3347
+ }
3348
+ /**
3349
+ * Grant this identity access to a VM.
3350
+ */
3351
+ async create({
3352
+ vmId,
3353
+ allowedUsers
3354
+ }) {
3355
+ return this.apiClient.post(
3356
+ "/identity/v1/identities/{identity}/permissions/vm/{vm_id}",
3357
+ {
3358
+ params: { identity: this.identityId, vm_id: vmId },
3359
+ body: { allowedUsers }
3360
+ }
3361
+ );
3362
+ }
3363
+ /**
3364
+ * Revoke this identity's access to a VM.
3365
+ */
3366
+ async delete({
3367
+ vmId
3368
+ }) {
3369
+ return this.apiClient.delete(
3370
+ "/identity/v1/identities/{identity}/permissions/vm/{vm_id}",
3371
+ {
3372
+ params: { identity: this.identityId, vm_id: vmId }
3373
+ }
3374
+ );
3375
+ }
3376
+ }
3377
+ class IdentitiesNamespace {
3378
+ constructor(apiClient) {
3379
+ this.apiClient = apiClient;
3380
+ }
3381
+ /**
3382
+ * List all identities.
3383
+ */
3384
+ async list({
3385
+ limit,
3386
+ cursor
3387
+ } = {}) {
3388
+ const offset = cursor ? parseInt(cursor, 10) : 0;
3389
+ return this.apiClient.get("/identity/v1/identities", {
3390
+ query: { limit, offset }
3391
+ });
3392
+ }
3393
+ /**
3394
+ * Create a new identity.
3395
+ * Identities are global entities that can be granted permissions to access git repositories and VMs.
3396
+ */
3397
+ async create({} = {}) {
3398
+ const response = await this.apiClient.post(
3399
+ "/identity/v1/identities",
3400
+ void 0
3401
+ );
3402
+ const identityId = response.id;
3403
+ return {
3404
+ identityId,
3405
+ identity: new Identity(identityId, this.apiClient)
3406
+ };
3407
+ }
3408
+ /**
3409
+ * Create an identity instance by ID without making an api call.
3410
+ */
3411
+ ref({ identityId }) {
3412
+ return new Identity(identityId, this.apiClient);
3413
+ }
3414
+ /**
3415
+ * Delete an identity.
3416
+ */
3417
+ async delete({
3418
+ identityId
3419
+ }) {
3420
+ return this.apiClient.delete("/identity/v1/identities/{identity}", {
3421
+ params: { identity: identityId }
3422
+ });
3423
+ }
3424
+ }
3425
+
3426
+ class DnsRecordsNamespace {
3427
+ constructor(apiClient) {
3428
+ this.apiClient = apiClient;
3429
+ }
3430
+ /**
3431
+ * Create DNS records.
3432
+ */
3433
+ async create({
3434
+ ...body
3435
+ }) {
3436
+ return this.apiClient.post("/dns/v1/records", { body });
3437
+ }
3438
+ /**
3439
+ * List DNS records.
3440
+ */
3441
+ async list({
3442
+ ...query
3443
+ } = {}) {
3444
+ return this.apiClient.get("/dns/v1/records", { query });
3445
+ }
3446
+ /**
3447
+ * Delete DNS records.
3448
+ */
3449
+ async delete({
3450
+ ...query
3451
+ } = {}) {
3452
+ return this.apiClient.delete("/dns/v1/records", { query });
3453
+ }
3454
+ }
3455
+ class DnsNamespace {
3456
+ constructor(apiClient) {
3457
+ this.apiClient = apiClient;
3458
+ this.records = new DnsRecordsNamespace(apiClient);
3459
+ }
3460
+ records;
3461
+ }
3462
+
3463
+ class Deployment {
3464
+ constructor(deploymentId, apiClient) {
3465
+ this.apiClient = apiClient;
3466
+ this.deploymentId = deploymentId;
3467
+ }
3468
+ deploymentId;
3469
+ /**
3470
+ * Get details of this deployment (execute type).
3471
+ */
3472
+ async getDetails() {
3473
+ return this.apiClient.get("/execute/v1/deployments/{deployment}", {
3474
+ params: { deployment: this.deploymentId }
3475
+ });
3476
+ }
3477
+ /**
3478
+ * Get logs for this deployment.
3479
+ */
3480
+ async getLogs() {
3481
+ return this.apiClient.get("/observability/v1/logs", {
3482
+ query: { deploymentId: this.deploymentId }
3483
+ });
3484
+ }
3485
+ }
3486
+ class DeploymentsNamespace {
3487
+ constructor(apiClient) {
3488
+ this.apiClient = apiClient;
3489
+ }
3490
+ /**
3491
+ * Create a web deployment on the edge.
3492
+ */
3493
+ async create({ ...body }) {
3494
+ let source;
3495
+ if ("repo" in body) {
3496
+ source = {
3497
+ kind: "git",
3498
+ url: body.repo,
3499
+ branch: body.branch,
3500
+ dir: body.rootPath
3501
+ };
3502
+ } else if ("code" in body) {
3503
+ source = {
3504
+ kind: "files",
3505
+ files: {
3506
+ "index.js": {
3507
+ content: body.code
3508
+ }
3509
+ }
3510
+ };
3511
+ } else if ("files" in body) {
3512
+ source = {
3513
+ kind: "files",
3514
+ files: Object.fromEntries(
3515
+ body.files.map((file) => [file.path, { content: file.content }])
3516
+ )
3517
+ };
3518
+ } else if ("tarUrl" in body) {
3519
+ source = {
3520
+ kind: "tar",
3521
+ url: body.tarUrl
3522
+ };
3523
+ } else {
3524
+ throw new Error(
3525
+ "Invalid deployment source. You must provide repo, code, files, or tarUrl."
3526
+ );
3527
+ }
3528
+ const response = await this.apiClient.post("/web/v1/deployment", {
3529
+ body: {
3530
+ source,
3531
+ config: {
3532
+ await: body.waitForRollout,
3533
+ build: body.build,
3534
+ domains: body.domains,
3535
+ networkPermissions: body.networkPermissions?.map((np) => ({
3536
+ action: np.action,
3537
+ query: np.domain,
3538
+ behavior: np.behavior
3539
+ })),
3540
+ envVars: body.envVars,
3541
+ nodeModules: body.nodeModules,
3542
+ timeout: body.timeoutMs,
3543
+ entrypoint: body.entrypointPath
3544
+ }
3545
+ }
3546
+ });
3547
+ return {
3548
+ deploymentId: response.deploymentId,
3549
+ deployment: new Deployment(response.deploymentId, this.apiClient),
3550
+ domains: body.domains || []
3551
+ };
3552
+ }
3553
+ /**
3554
+ * List web deployments.
3555
+ */
3556
+ async list({
3557
+ limit = 50,
3558
+ cursor
3559
+ } = {}) {
3560
+ const offset = cursor ? parseInt(cursor, 10) : 0;
3561
+ return this.apiClient.get("/web/v1/deployments", {
3562
+ query: { limit, offset }
3563
+ });
3564
+ }
3565
+ /**
3566
+ * Get a deployment instance by ID.
3567
+ */
3568
+ ref({ deploymentId }) {
3569
+ return new Deployment(deploymentId, this.apiClient);
3570
+ }
3571
+ }
3572
+ class RunsNamespace {
3573
+ constructor(apiClient) {
3574
+ this.apiClient = apiClient;
3575
+ }
3576
+ /**
3577
+ * Create and execute a script run.
3578
+ */
3579
+ async create({
3580
+ code,
3581
+ ...config
3582
+ }) {
3583
+ const response = await this.apiClient.post("/execute/v1/script", {
3584
+ body: {
3585
+ script: code,
3586
+ config: {
3587
+ customHeaders: config.customHeaders,
3588
+ networkPermissions: config.networkPermissions?.map((np) => ({
3589
+ action: np.action,
3590
+ query: np.domain,
3591
+ behavior: np.behavior
3592
+ })),
3593
+ envVars: config.envVars,
3594
+ nodeModules: config.nodeModules,
3595
+ timeout: config.timeoutMs
3596
+ // entrypoint: config.entrypointPath,
3597
+ }
3598
+ }
3599
+ });
3600
+ if (!response.result && !response.logs) {
3601
+ throw new Error("Execution failed");
3602
+ }
3603
+ return {
3604
+ result: response.result,
3605
+ logs: response.logs || []
3606
+ };
3607
+ }
3608
+ /**
3609
+ * List execution runs.
3610
+ */
3611
+ async list({
3612
+ limit = 50,
3613
+ cursor
3614
+ } = {}) {
3615
+ const offset = cursor ? parseInt(cursor, 10) : 0;
3616
+ const res = await this.apiClient.get("/execute/v1/deployments", {
3617
+ query: { limit, offset }
3618
+ });
3619
+ return {
3620
+ runs: res.entries.map((item) => ({
3621
+ createdAt: item.provisionedAt,
3622
+ startedAt: item.startedAt || void 0,
3623
+ runId: item.deployment,
3624
+ status: item.state
3625
+ })),
3626
+ nextCursor: res.offset < res.total ? res.offset.toString() : void 0,
3627
+ totalCount: res.total
3628
+ };
3629
+ }
3630
+ }
3631
+ class EdgeNamespace {
3632
+ constructor(apiClient) {
3633
+ this.apiClient = apiClient;
3634
+ this.deployments = new DeploymentsNamespace(apiClient);
3635
+ this.runs = new RunsNamespace(apiClient);
3636
+ }
3637
+ deployments;
3638
+ runs;
3639
+ }
3640
+
3641
+ class FileSystem {
3642
+ constructor(vmId, client) {
3643
+ this.vmId = vmId;
3644
+ this.client = client;
3645
+ }
3646
+ /**
3647
+ * Read a file from the VM as a buffer.
3648
+ * @param filepath The path to the file in the VM
3649
+ * @returns Buffer containing the file content
3650
+ */
3651
+ async readFile(filepath) {
3652
+ const response = await this.client.get("/v1/vms/{vm_id}/files/{filepath}", {
3653
+ params: { vm_id: this.vmId, filepath }
3654
+ });
3655
+ if (response && typeof response === "object" && "content" in response) {
3656
+ const content = response.content;
3657
+ try {
3658
+ return Buffer.from(content, "base64");
3659
+ } catch {
3660
+ return Buffer.from(content, "utf-8");
3661
+ }
3662
+ }
3663
+ throw new Error("Unexpected response format from VM file read");
3664
+ }
3665
+ /**
3666
+ * Write a file to the VM from a buffer.
3667
+ * @param filepath The path to the file in the VM
3668
+ * @param content Buffer containing the content to write
3669
+ */
3670
+ async writeFile(filepath, content) {
3671
+ const base64Content = content.toString("base64");
3672
+ await this.client.put("/v1/vms/{vm_id}/files/{filepath}", {
3673
+ params: { vm_id: this.vmId, filepath },
3674
+ body: { content: base64Content }
3675
+ });
3676
+ }
3677
+ /**
3678
+ * Read a text file from the VM.
3679
+ * @param filepath The path to the file in the VM
3680
+ * @param encoding The text encoding to use (default: utf-8)
3681
+ * @returns The file content as a string
3682
+ */
3683
+ async readTextFile(filepath, encoding = "utf-8") {
3684
+ const buffer = await this.readFile(filepath);
3685
+ return buffer.toString(encoding);
3686
+ }
3687
+ /**
3688
+ * Write a text file to the VM.
3689
+ * @param filepath The path to the file in the VM
3690
+ * @param content The text content to write
3691
+ * @param encoding The text encoding to use (default: utf-8)
3692
+ */
3693
+ async writeTextFile(filepath, content, encoding = "utf-8") {
3694
+ const buffer = Buffer.from(content, encoding);
3695
+ await this.writeFile(filepath, buffer);
3696
+ }
3697
+ /**
3698
+ * Read a directory from the VM.
3699
+ * @param path The path to the directory in the VM
3700
+ * @returns Array of file/directory names
3701
+ */
3702
+ async readDir(path) {
3703
+ throw new Error("Not implemented");
3704
+ }
3705
+ /**
3706
+ * Create a directory in the VM.
3707
+ * @param path The path to create
3708
+ */
3709
+ async mkdir(path) {
3710
+ throw new Error("Not implemented");
3711
+ }
3712
+ /**
3713
+ * Remove a file or directory from the VM.
3714
+ * @param path The path to remove
3715
+ */
3716
+ async remove(path) {
3717
+ throw new Error("Not implemented");
3718
+ }
3719
+ /**
3720
+ * Check if a file or directory exists in the VM.
3721
+ * @param path The path to check
3722
+ * @returns True if exists, false otherwise
3723
+ */
3724
+ async exists(path) {
3725
+ throw new Error("Not implemented");
3726
+ }
3727
+ /**
3728
+ * Get file/directory stats.
3729
+ * @param path The path to stat
3730
+ * @returns File/directory stats
3731
+ */
3732
+ async stat(path) {
3733
+ throw new Error("Not implemented");
3734
+ }
3735
+ /**
3736
+ * Watch for file changes in the VM.
3737
+ * @returns An async generator that yields file change events
3738
+ */
3739
+ async *watchFiles() {
3740
+ const response = await this.client.fetch(
3741
+ `/v1/vms/${this.vmId}/watch-files`,
3742
+ {
3743
+ method: "POST"
3744
+ }
3745
+ );
3746
+ if (!response.ok) {
3747
+ throw new Error(
3748
+ `Failed to watch files: ${response.status} ${response.statusText}`
3749
+ );
3750
+ }
3751
+ if (!response.body) {
3752
+ throw new Error("Failed to watch files: No response body");
3753
+ }
3754
+ const reader = response.body.getReader();
3755
+ const decoder = new TextDecoder("utf-8");
3756
+ let buffer = "";
3757
+ while (true) {
3758
+ const { done, value } = await reader.read();
3759
+ if (done) break;
3760
+ buffer += decoder.decode(value, { stream: true });
3761
+ let newlineIndex;
3762
+ while ((newlineIndex = buffer.indexOf("\n")) >= 0) {
3763
+ const line = buffer.slice(0, newlineIndex).trim();
3764
+ buffer = buffer.slice(newlineIndex + 1);
3765
+ if (line) {
3766
+ yield JSON.parse(line);
3767
+ }
3768
+ }
3769
+ }
3770
+ if (buffer.trim()) {
3771
+ yield JSON.parse(buffer.trim());
3772
+ }
3773
+ }
3774
+ }
3775
+
3776
+ class VmWithInstance {
3777
+ vm;
3778
+ _init(vm) {
3779
+ this.vm = vm;
3780
+ return this;
3781
+ }
3782
+ }
3783
+ class VmWith {
3784
+ instance;
3785
+ /**
3786
+ * Helper method to compose multiple configurations together.
3787
+ * Uses the same merging strategy as the main compose function.
3788
+ */
3789
+ compose(...configs) {
3790
+ return composeCreateVmOptions(configs);
3791
+ }
3792
+ }
3793
+ const VmService = VmWith;
3794
+ const VmBuilder = VmWith;
3795
+ function composeCreateVmOptions(arr) {
3796
+ const result = {};
3797
+ for (const options of arr) {
3798
+ if (options.idleTimeoutSeconds !== void 0)
3799
+ result.idleTimeoutSeconds = options.idleTimeoutSeconds;
3800
+ if (options.waitForReadySignal !== void 0)
3801
+ result.waitForReadySignal = options.waitForReadySignal;
3802
+ if (options.readySignalTimeoutSeconds !== void 0)
3803
+ result.readySignalTimeoutSeconds = options.readySignalTimeoutSeconds;
3804
+ if (options.workdir !== void 0) result.workdir = options.workdir;
3805
+ if (options.snapshotId !== void 0)
3806
+ result.snapshotId = options.snapshotId;
3807
+ if (options.recreate !== void 0) result.recreate = options.recreate;
3808
+ if (options.persistence !== void 0)
3809
+ result.persistence = options.persistence;
3810
+ if (options.ports !== void 0) {
3811
+ if (!result.ports) {
3812
+ result.ports = options.ports;
3813
+ } else if (options.ports !== null) {
3814
+ const existingPorts = result.ports || [];
3815
+ const newPorts = options.ports;
3816
+ const portMap = /* @__PURE__ */ new Map();
3817
+ for (const port of existingPorts) {
3818
+ portMap.set(port.port, port);
3819
+ }
3820
+ for (const port of newPorts) {
3821
+ portMap.set(port.port, port);
3822
+ }
3823
+ result.ports = Array.from(portMap.values());
3824
+ }
3825
+ }
3826
+ if (options.systemd !== void 0) {
3827
+ if (!result.systemd) {
3828
+ result.systemd = options.systemd;
3829
+ } else if (options.systemd !== null) {
3830
+ if (options.systemd.services !== void 0) {
3831
+ const existingServices = result.systemd.services || [];
3832
+ const newServices = options.systemd.services || [];
3833
+ const serviceMap = /* @__PURE__ */ new Map();
3834
+ for (const service of existingServices) {
3835
+ serviceMap.set(service.name, service);
3836
+ }
3837
+ for (const service of newServices) {
3838
+ serviceMap.set(service.name, service);
3839
+ }
3840
+ result.systemd.services = Array.from(serviceMap.values());
3841
+ }
3842
+ if (options.systemd.patchedServices !== void 0) {
3843
+ const existingPatched = result.systemd.patchedServices || [];
3844
+ const newPatched = options.systemd.patchedServices || [];
3845
+ const patchedMap = /* @__PURE__ */ new Map();
3846
+ for (const service of existingPatched) {
3847
+ patchedMap.set(service.name, service);
3848
+ }
3849
+ for (const service of newPatched) {
3850
+ patchedMap.set(service.name, service);
3851
+ }
3852
+ result.systemd.patchedServices = Array.from(patchedMap.values());
3853
+ }
3854
+ }
3855
+ }
3856
+ if (options.users !== void 0) {
3857
+ if (!result.users) {
3858
+ result.users = options.users;
3859
+ } else if (options.users !== null) {
3860
+ const existingUsers = result.users || [];
3861
+ const newUsers = options.users;
3862
+ const userMap = /* @__PURE__ */ new Map();
3863
+ for (const user of existingUsers) {
3864
+ userMap.set(user.name, user);
3865
+ }
3866
+ for (const user of newUsers) {
3867
+ userMap.set(user.name, user);
3868
+ }
3869
+ result.users = Array.from(userMap.values());
3870
+ }
3871
+ }
3872
+ if (options.groups !== void 0) {
3873
+ if (!result.groups) {
3874
+ result.groups = options.groups;
3875
+ } else if (options.groups !== null) {
3876
+ const existingGroups = result.groups || [];
3877
+ const newGroups = options.groups;
3878
+ const groupMap = /* @__PURE__ */ new Map();
3879
+ for (const group of existingGroups) {
3880
+ groupMap.set(group.name, group);
3881
+ }
3882
+ for (const group of newGroups) {
3883
+ groupMap.set(group.name, group);
3884
+ }
3885
+ result.groups = Array.from(groupMap.values());
3886
+ }
3887
+ }
3888
+ if (options.additionalFiles !== void 0) {
3889
+ if (!result.additionalFiles) {
3890
+ result.additionalFiles = options.additionalFiles;
3891
+ } else if (options.additionalFiles !== null) {
3892
+ result.additionalFiles = {
3893
+ ...result.additionalFiles,
3894
+ ...options.additionalFiles
3895
+ };
3896
+ }
3897
+ }
3898
+ if (options.gitRepos !== void 0) {
3899
+ if (!result.gitRepos) {
3900
+ result.gitRepos = options.gitRepos;
3901
+ } else if (options.gitRepos !== null) {
3902
+ const existingRepos = result.gitRepos || [];
3903
+ const newRepos = options.gitRepos;
3904
+ const repoMap = /* @__PURE__ */ new Map();
3905
+ for (const repo of existingRepos) {
3906
+ repoMap.set(repo.path, repo);
3907
+ }
3908
+ for (const repo of newRepos) {
3909
+ repoMap.set(repo.path, repo);
3910
+ }
3911
+ result.gitRepos = Array.from(repoMap.values());
3912
+ }
3913
+ }
3914
+ if (options.template !== void 0) {
3915
+ if (!result.template) {
3916
+ result.template = options.template;
3917
+ } else if (options.template !== null) {
3918
+ const baseTemplate = result.template instanceof VmTemplate ? result.template["template"] : result.template;
3919
+ const newTemplate = options.template instanceof VmTemplate ? options.template["template"] : options.template;
3920
+ result.template = {
3921
+ // Simple overrides - start with base, override with new
3922
+ snapshotId: newTemplate.snapshotId !== void 0 ? newTemplate.snapshotId : baseTemplate.snapshotId,
3923
+ rootfsSizeMb: newTemplate.rootfsSizeMb !== void 0 ? newTemplate.rootfsSizeMb : baseTemplate.rootfsSizeMb,
3924
+ workdir: newTemplate.workdir !== void 0 ? newTemplate.workdir : baseTemplate.workdir,
3925
+ idleTimeoutSeconds: newTemplate.idleTimeoutSeconds !== void 0 ? newTemplate.idleTimeoutSeconds : baseTemplate.idleTimeoutSeconds,
3926
+ waitForReadySignal: newTemplate.waitForReadySignal !== void 0 ? newTemplate.waitForReadySignal : baseTemplate.waitForReadySignal,
3927
+ readySignalTimeoutSeconds: newTemplate.readySignalTimeoutSeconds !== void 0 ? newTemplate.readySignalTimeoutSeconds : baseTemplate.readySignalTimeoutSeconds,
3928
+ persistence: newTemplate.persistence !== void 0 ? newTemplate.persistence : baseTemplate.persistence,
3929
+ // Merge ports
3930
+ ports: (() => {
3931
+ if (newTemplate.ports === null) return null;
3932
+ if (!baseTemplate.ports) return newTemplate.ports;
3933
+ if (newTemplate.ports === void 0) return baseTemplate.ports;
3934
+ const portMap = /* @__PURE__ */ new Map();
3935
+ for (const port of baseTemplate.ports || []) {
3936
+ portMap.set(port.port, port);
3937
+ }
3938
+ for (const port of newTemplate.ports || []) {
3939
+ portMap.set(port.port, port);
3940
+ }
3941
+ return Array.from(portMap.values());
3942
+ })(),
3943
+ // Merge systemd
3944
+ systemd: (() => {
3945
+ if (newTemplate.systemd === null) return null;
3946
+ if (!baseTemplate.systemd) return newTemplate.systemd;
3947
+ if (newTemplate.systemd === void 0) return baseTemplate.systemd;
3948
+ const mergedSystemd = {
3949
+ ...baseTemplate.systemd,
3950
+ ...newTemplate.systemd
3951
+ };
3952
+ const baseServices = baseTemplate.systemd?.services || [];
3953
+ const newServices = newTemplate.systemd?.services || [];
3954
+ if (baseServices.length > 0 || newServices.length > 0) {
3955
+ const serviceMap = /* @__PURE__ */ new Map();
3956
+ for (const svc of baseServices) {
3957
+ serviceMap.set(svc.name, svc);
3958
+ }
3959
+ for (const svc of newServices) {
3960
+ serviceMap.set(svc.name, svc);
3961
+ }
3962
+ mergedSystemd.services = Array.from(serviceMap.values());
3963
+ }
3964
+ const basePatchedServices = baseTemplate.systemd?.patchedServices || [];
3965
+ const newPatchedServices = newTemplate.systemd?.patchedServices || [];
3966
+ if (basePatchedServices.length > 0 || newPatchedServices.length > 0) {
3967
+ const patchedMap = /* @__PURE__ */ new Map();
3968
+ for (const svc of basePatchedServices) {
3969
+ patchedMap.set(svc.name, svc);
3970
+ }
3971
+ for (const svc of newPatchedServices) {
3972
+ patchedMap.set(svc.name, svc);
3973
+ }
3974
+ mergedSystemd.patchedServices = Array.from(patchedMap.values());
3975
+ }
3976
+ return mergedSystemd;
3977
+ })(),
3978
+ // Merge users
3979
+ users: (() => {
3980
+ if (newTemplate.users === null) return null;
3981
+ if (!baseTemplate.users) return newTemplate.users;
3982
+ if (newTemplate.users === void 0) return baseTemplate.users;
3983
+ const userMap = /* @__PURE__ */ new Map();
3984
+ for (const user of baseTemplate.users || []) {
3985
+ userMap.set(user.name, user);
3986
+ }
3987
+ for (const user of newTemplate.users || []) {
3988
+ userMap.set(user.name, user);
3989
+ }
3990
+ return Array.from(userMap.values());
3991
+ })(),
3992
+ // Merge groups
3993
+ groups: (() => {
3994
+ if (newTemplate.groups === null) return null;
3995
+ if (!baseTemplate.groups) return newTemplate.groups;
3996
+ if (newTemplate.groups === void 0) return baseTemplate.groups;
3997
+ const groupMap = /* @__PURE__ */ new Map();
3998
+ for (const group of baseTemplate.groups || []) {
3999
+ groupMap.set(group.name, group);
4000
+ }
4001
+ for (const group of newTemplate.groups || []) {
4002
+ groupMap.set(group.name, group);
4003
+ }
4004
+ return Array.from(groupMap.values());
4005
+ })(),
4006
+ // Merge additionalFiles
4007
+ additionalFiles: (() => {
4008
+ if (newTemplate.additionalFiles === null) return null;
4009
+ if (!baseTemplate.additionalFiles)
4010
+ return newTemplate.additionalFiles;
4011
+ if (newTemplate.additionalFiles === void 0)
4012
+ return baseTemplate.additionalFiles;
4013
+ return {
4014
+ ...baseTemplate.additionalFiles,
4015
+ ...newTemplate.additionalFiles
4016
+ };
4017
+ })(),
4018
+ // Merge gitRepos
4019
+ gitRepos: (() => {
4020
+ if (newTemplate.gitRepos === null) return null;
4021
+ if (!baseTemplate.gitRepos) return newTemplate.gitRepos;
4022
+ if (newTemplate.gitRepos === void 0)
4023
+ return baseTemplate.gitRepos;
4024
+ const repoMap = /* @__PURE__ */ new Map();
4025
+ for (const repo of baseTemplate.gitRepos || []) {
4026
+ repoMap.set(repo.path, repo);
4027
+ }
4028
+ for (const repo of newTemplate.gitRepos || []) {
4029
+ repoMap.set(repo.path, repo);
4030
+ }
4031
+ return Array.from(repoMap.values());
4032
+ })()
4033
+ };
4034
+ }
4035
+ }
4036
+ }
4037
+ return result;
4038
+ }
4039
+
4040
+ class VmTerminals {
4041
+ constructor(vmId, client) {
4042
+ this.vmId = vmId;
4043
+ this.client = client;
4044
+ }
4045
+ /**
4046
+ * List all terminals in the VM.
4047
+ * @returns Array of terminal information
4048
+ */
4049
+ async list() {
4050
+ return this.client.get("/v1/vms/{vm_id}/terminals", {
4051
+ params: { vm_id: this.vmId }
4052
+ });
4053
+ }
4054
+ /**
4055
+ * Get logs from a specific terminal.
4056
+ * @param terminalId The ID of the terminal
4057
+ * @returns Terminal log entries
4058
+ */
4059
+ async getLogs({ terminalId }) {
4060
+ return this.client.get("/v1/vms/{vm_id}/terminals/{terminal_id}/logs", {
4061
+ params: { vm_id: this.vmId, terminal_id: terminalId }
4062
+ });
4063
+ }
4064
+ /**
4065
+ * Get xterm-256color output from a specific terminal.
4066
+ * @param terminalId The ID of the terminal
4067
+ * @returns Terminal output
4068
+ */
4069
+ async getOutput({ terminalId }) {
4070
+ return this.client.get(
4071
+ "/v1/vms/{vm_id}/terminals/{terminal_id}/xterm-256color",
4072
+ {
4073
+ params: { vm_id: this.vmId, terminal_id: terminalId }
4074
+ }
4075
+ );
4076
+ }
4077
+ }
4078
+ class Vm {
4079
+ constructor(vmId, apiClient) {
4080
+ this.apiClient = apiClient;
4081
+ this.vmId = vmId;
4082
+ this.fs = new FileSystem(vmId, apiClient);
4083
+ this.terminals = new VmTerminals(vmId, apiClient);
4084
+ }
4085
+ vmId;
4086
+ fs;
4087
+ terminals;
4088
+ /**
4089
+ * Get the current state and metadata of the VM.
4090
+ * @returns VM state information
4091
+ */
4092
+ async getInfo() {
4093
+ return this.apiClient.get("/v1/vms/{vm_id}", {
4094
+ params: { vm_id: this.vmId }
4095
+ });
4096
+ }
4097
+ /**
4098
+ * Start the VM.
4099
+ * @param options Optional startup configuration
4100
+ * @returns Start response with VM information
4101
+ */
4102
+ async start({ ...options } = {}) {
4103
+ return this.apiClient.post("/v1/vms/{vm_id}/start", {
4104
+ params: { vm_id: this.vmId },
4105
+ body: options
4106
+ });
4107
+ }
4108
+ /**
4109
+ * Stop the VM gracefully.
4110
+ * @returns Stop response
4111
+ */
4112
+ async stop() {
4113
+ return this.apiClient.post("/v1/vms/{vm_id}/stop", {
4114
+ params: { vm_id: this.vmId }
4115
+ });
4116
+ }
4117
+ /**
4118
+ * Suspend the VM to disk.
4119
+ * @returns Suspend response
4120
+ */
4121
+ async suspend() {
4122
+ return this.apiClient.post("/v1/vms/{vm_id}/suspend", {
4123
+ params: { vm_id: this.vmId }
4124
+ });
4125
+ }
4126
+ /**
4127
+ * Kill the VM immediately.
4128
+ * @returns Kill response
4129
+ */
4130
+ async kill() {
4131
+ return this.apiClient.post("/v1/vms/{vm_id}/kill", {
4132
+ params: { vm_id: this.vmId }
4133
+ });
4134
+ }
4135
+ /**
4136
+ * Wait for the VM to exit.
4137
+ * @returns Await response with exit information
4138
+ */
4139
+ async waitForExit() {
4140
+ return this.apiClient.post("/v1/vms/{vm_id}/await", {
4141
+ params: { vm_id: this.vmId }
4142
+ });
4143
+ }
4144
+ /**
4145
+ * Execute a command in the VM and wait for it to complete.
4146
+ * @param command The command to execute
4147
+ * @param terminal Optional terminal ID
4148
+ * @param timeoutMs Optional timeout in milliseconds
4149
+ * @returns Execution result with stdout/stderr
4150
+ */
4151
+ async exec(options) {
4152
+ if (typeof options === "string") {
4153
+ options = { command: options };
4154
+ }
4155
+ const { command, terminal, timeoutMs } = options;
4156
+ return this.apiClient.post("/v1/vms/{vm_id}/exec-await", {
4157
+ params: { vm_id: this.vmId },
4158
+ body: {
4159
+ command,
4160
+ terminal: terminal ?? null,
4161
+ timeoutMs: timeoutMs ?? null
4162
+ }
4163
+ });
4164
+ }
4165
+ /**
4166
+ * Fork (clone) the VM.
4167
+ * @param options Optional fork configuration
4168
+ * @returns A new VM instance representing the forked VM
4169
+ */
4170
+ async fork({
4171
+ ...options
4172
+ } = {}) {
4173
+ const response = await this.apiClient.post("/v1/vms/{vm_id}/fork", {
4174
+ params: { vm_id: this.vmId },
4175
+ body: options
4176
+ });
4177
+ const vmId = response.id;
4178
+ return {
4179
+ vmId,
4180
+ vm: new Vm(vmId, this.apiClient)
4181
+ };
4182
+ }
4183
+ /**
4184
+ * Optimize the VM (compact memory/disk).
4185
+ * @returns Optimization response
4186
+ */
4187
+ async optimize() {
4188
+ return this.apiClient.post("/v1/vms/{vm_id}/optimize", {
4189
+ params: { vm_id: this.vmId }
4190
+ });
4191
+ }
4192
+ /**
4193
+ * Resize the VM's disk.
4194
+ * @param sizeMb New disk size in megabytes
4195
+ * @returns Resize response
4196
+ */
4197
+ async resize({
4198
+ sizeMb
4199
+ }) {
4200
+ return this.apiClient.post("/v1/vms/{id}/resize", {
4201
+ params: { id: this.vmId },
4202
+ body: { sizeMb }
4203
+ });
4204
+ }
4205
+ }
4206
+ class VmSnapshotsNamespace {
4207
+ constructor(apiClient) {
4208
+ this.apiClient = apiClient;
4209
+ }
4210
+ async ensure(options) {
4211
+ return this.apiClient.post("/v1/vms/snapshots", {
4212
+ body: {
4213
+ ...options,
4214
+ // @ts-ignore
4215
+ template: options.template?.template
4216
+ }
4217
+ });
4218
+ }
4219
+ }
4220
+ class VmsNamespace {
4221
+ constructor(apiClient) {
4222
+ this.apiClient = apiClient;
4223
+ this.snapshots = new VmSnapshotsNamespace(apiClient);
4224
+ }
4225
+ snapshots;
4226
+ /**
4227
+ * Create a new VM.
4228
+ * @param options Optional VM configuration
4229
+ * @returns A VM instance representing the created VM
4230
+ */
4231
+ async create(options = {}) {
4232
+ const builders = options.with || {};
4233
+ const { with: _, ...baseConfig } = options;
4234
+ let config = baseConfig;
4235
+ const keys = Object.keys(builders);
4236
+ for (const key of keys) {
4237
+ const builder = builders[key];
4238
+ if (builder) {
4239
+ config = await builder.configure(config);
4240
+ }
4241
+ }
4242
+ const response = await this.apiClient.post("/v1/vms", {
4243
+ body: {
4244
+ ...config,
4245
+ template: config.template instanceof VmTemplate ? config.template["template"] : config.template
4246
+ }
4247
+ });
4248
+ const vmId = response.id;
4249
+ const vm = new Vm(vmId, this.apiClient);
4250
+ for (const key in builders) {
4251
+ const builder = builders[key];
4252
+ if (builder) {
4253
+ const instance = builder.createInstance();
4254
+ builder.createInstance = () => {
4255
+ throw new Error(
4256
+ `Attempted to create multiple instances from the same VmWith ${key}: ${builder.constructor.name}`
4257
+ );
4258
+ };
4259
+ builder.instance = instance;
4260
+ instance._init(vm);
4261
+ vm[key] = instance;
4262
+ }
4263
+ }
4264
+ return {
4265
+ ...response,
4266
+ vmId,
4267
+ vm,
4268
+ domains: response.domains || []
4269
+ };
4270
+ }
4271
+ /**
4272
+ * List all VMs.
4273
+ * @returns List of VMs with their states and metadata
4274
+ */
4275
+ async list() {
4276
+ return this.apiClient.get("/v1/vms", void 0);
4277
+ }
4278
+ /**
4279
+ * Create a VM instance by ID without making an api call.
4280
+ */
4281
+ ref({ vmId }) {
4282
+ return new Vm(vmId, this.apiClient);
4283
+ }
4284
+ }
4285
+ class VmTemplate {
4286
+ template;
4287
+ constructor(template) {
4288
+ this.template = template;
4289
+ }
4290
+ }
4291
+
4292
+ class Freestyle {
4293
+ apiClient;
4294
+ // Organized namespaces
4295
+ domains;
4296
+ git;
4297
+ identities;
4298
+ dns;
4299
+ edge;
4300
+ vms;
4301
+ constructor(options = {}) {
4302
+ options.baseUrl ?? process.env.FREESTYLE_API_URL;
4303
+ let apiKey;
4304
+ if ("accessToken" in options && options.accessToken) {
4305
+ options.accessToken;
4306
+ } else {
4307
+ apiKey = options.apiKey ?? process.env.FREESTYLE_API_KEY;
4308
+ if (!apiKey) {
4309
+ throw new Error(
4310
+ "API key is required. Please provide it in the constructor or set the FREESTYLE_API_KEY environment variable."
4311
+ );
4312
+ }
4313
+ }
4314
+ this.apiClient = new ApiClient(options);
4315
+ this.domains = new DomainsNamespace(this.apiClient);
4316
+ this.git = new GitNamespace(this.apiClient, this);
4317
+ this.identities = new IdentitiesNamespace(this.apiClient);
4318
+ this.dns = new DnsNamespace(this.apiClient);
4319
+ this.edge = new EdgeNamespace(this.apiClient);
4320
+ this.vms = new VmsNamespace(this.apiClient);
4321
+ }
4322
+ /**
4323
+ * Helper method to make raw fetch requests to the API.
4324
+ */
4325
+ fetch(path, init) {
4326
+ return this.apiClient.fetch(path, init);
4327
+ }
4328
+ }
4329
+ function createLazyFreestyle(options = {}) {
4330
+ let instance = null;
4331
+ const getOrCreateInstance = () => {
4332
+ if (!instance) {
4333
+ instance = new Freestyle(options);
4334
+ }
4335
+ return instance;
4336
+ };
4337
+ return new Proxy({}, {
4338
+ get(_target, prop) {
4339
+ const inst = getOrCreateInstance();
4340
+ const value = inst[prop];
4341
+ if (typeof value === "function") {
4342
+ return value.bind(inst);
4343
+ }
4344
+ return value;
4345
+ }
4346
+ });
4347
+ }
4348
+ const freestyle = createLazyFreestyle();
4349
+
4350
+ exports.Deployment = Deployment;
4351
+ exports.Errors = errors;
4352
+ exports.FileSystem = FileSystem;
4353
+ exports.Freestyle = Freestyle;
4354
+ exports.GitRepo = GitRepo;
4355
+ exports.Identity = Identity;
4356
+ exports.Vm = Vm;
4357
+ exports.VmBuilder = VmBuilder;
4358
+ exports.VmService = VmService;
4359
+ exports.VmTemplate = VmTemplate;
4360
+ exports.VmWith = VmWith;
4361
+ exports.VmWithInstance = VmWithInstance;
4362
+ exports.freestyle = freestyle;