freestyle-sandboxes 0.1.35 → 0.1.37

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 (6) hide show
  1. package/cli.mjs +35 -12
  2. package/index.cjs +1618 -1278
  3. package/index.d.cts +1008 -863
  4. package/index.d.mts +1008 -863
  5. package/index.mjs +1618 -1279
  6. package/package.json +1 -1
package/index.cjs CHANGED
@@ -82,209 +82,281 @@ class GitErrorError extends Error {
82
82
  static statusCode = 500;
83
83
  static description = `{message}`;
84
84
  }
85
- class PartitionNotFoundError extends Error {
85
+ class SnapshotNotFoundError extends Error {
86
86
  constructor(body) {
87
87
  super(
88
- `PARTITION_NOT_FOUND: ${body.message}`
88
+ `SNAPSHOT_NOT_FOUND: ${body.message}`
89
89
  );
90
90
  this.body = body;
91
- this.name = "PartitionNotFoundError";
91
+ this.name = "SnapshotNotFoundError";
92
92
  }
93
- static code = "PARTITION_NOT_FOUND";
93
+ static code = "SNAPSHOT_NOT_FOUND";
94
94
  static statusCode = 404;
95
- static description = `Partition not found: {partition_id}`;
95
+ static description = `Snapshot not found: {snapshot_id}`;
96
96
  }
97
- class VmOperationDeniedDuringTransactionError extends Error {
97
+ class ResumedVmNonResponsiveError extends Error {
98
98
  constructor(body) {
99
99
  super(
100
- `VM_OPERATION_DENIED_DURING_TRANSACTION: ${body.message}`
100
+ `RESUMED_VM_NON_RESPONSIVE: ${body.message}`
101
101
  );
102
102
  this.body = body;
103
- this.name = "VmOperationDeniedDuringTransactionError";
103
+ this.name = "ResumedVmNonResponsiveError";
104
104
  }
105
- static code = "VM_OPERATION_DENIED_DURING_TRANSACTION";
106
- static statusCode = 409;
107
- static description = `VM operation denied during active transaction for VM {vm_id} in transaction {transaction_id}`;
105
+ static code = "RESUMED_VM_NON_RESPONSIVE";
106
+ static statusCode = 500;
107
+ static description = `Resumed VM {vm_id} is not responsive after {timeout_seconds}s`;
108
108
  }
109
- class VmTransactionIdMismatchError extends Error {
109
+ class SnapshotLoadTimeoutError extends Error {
110
110
  constructor(body) {
111
111
  super(
112
- `VM_TRANSACTION_ID_MISMATCH: ${body.message}`
112
+ `SNAPSHOT_LOAD_TIMEOUT: ${body.message}`
113
113
  );
114
114
  this.body = body;
115
- this.name = "VmTransactionIdMismatchError";
115
+ this.name = "SnapshotLoadTimeoutError";
116
116
  }
117
- static code = "VM_TRANSACTION_ID_MISMATCH";
118
- static statusCode = 400;
119
- static description = `Transaction ID {provided_transaction_id} does not match the current VM transaction {expected_transaction_id} for VM {vm_id}`;
117
+ static code = "SNAPSHOT_LOAD_TIMEOUT";
118
+ static statusCode = 500;
119
+ static description = `Snapshot load timed out after {elapsed_seconds}s for instance {vm_instance_id}, logs: {log_path}`;
120
120
  }
121
- class VmNotInTransactionError extends Error {
121
+ class UffdTimeoutErrorError extends Error {
122
122
  constructor(body) {
123
123
  super(
124
- `VM_NOT_IN_TRANSACTION: ${body.message}`
124
+ `UFFD_TIMEOUT_ERROR: ${body.message}`
125
125
  );
126
126
  this.body = body;
127
- this.name = "VmNotInTransactionError";
127
+ this.name = "UffdTimeoutErrorError";
128
128
  }
129
- static code = "VM_NOT_IN_TRANSACTION";
130
- static statusCode = 404;
131
- static description = `VM not in a transaction: {vm_id}`;
129
+ static code = "UFFD_TIMEOUT_ERROR";
130
+ static statusCode = 500;
131
+ static description = `UFFD socket timeout: {report_socket_path}, logs: {log_path}`;
132
132
  }
133
- class VmNotRunningError extends Error {
133
+ class KernelPanicError extends Error {
134
134
  constructor(body) {
135
135
  super(
136
- `VM_NOT_RUNNING: ${body.message}`
136
+ `KERNEL_PANIC: ${body.message}`
137
137
  );
138
138
  this.body = body;
139
- this.name = "VmNotRunningError";
139
+ this.name = "KernelPanicError";
140
140
  }
141
- static code = "VM_NOT_RUNNING";
142
- static statusCode = 400;
143
- static description = `Stopped VM not running`;
141
+ static code = "KERNEL_PANIC";
142
+ static statusCode = 500;
143
+ static description = `VM kernel panic detected`;
144
144
  }
145
- class FileNotFoundError extends Error {
145
+ class VmDeletedError extends Error {
146
146
  constructor(body) {
147
147
  super(
148
- `FILE_NOT_FOUND: ${body.message}`
148
+ `VM_DELETED: ${body.message}`
149
149
  );
150
150
  this.body = body;
151
- this.name = "FileNotFoundError";
151
+ this.name = "VmDeletedError";
152
152
  }
153
- static code = "FILE_NOT_FOUND";
154
- static statusCode = 404;
155
- static description = `File not found: {path}`;
153
+ static code = "VM_DELETED";
154
+ static statusCode = 410;
155
+ static description = `Cannot start VM: VM files have been deleted. This VM was ephemeral and its files were removed.`;
156
156
  }
157
- class FilesBadRequestError extends Error {
157
+ class ReqwestError extends Error {
158
158
  constructor(body) {
159
159
  super(
160
- `FILES_BAD_REQUEST: ${body.message}`
160
+ `REQWEST: ${body.message}`
161
161
  );
162
162
  this.body = body;
163
- this.name = "FilesBadRequestError";
163
+ this.name = "ReqwestError";
164
164
  }
165
- static code = "FILES_BAD_REQUEST";
166
- static statusCode = 400;
167
- static description = `Bad request: {message}`;
165
+ static code = "REQWEST";
166
+ static statusCode = 500;
167
+ static description = `Reqwest error: {details}`;
168
168
  }
169
- class InvalidGitRepoSpecErrorError extends Error {
169
+ class FirecrackerPidNotFoundError extends Error {
170
170
  constructor(body) {
171
171
  super(
172
- `INVALID_GIT_REPO_SPEC_ERROR: ${body.message}`
172
+ `FIRECRACKER_PID_NOT_FOUND: ${body.message}`
173
173
  );
174
174
  this.body = body;
175
- this.name = "InvalidGitRepoSpecErrorError";
175
+ this.name = "FirecrackerPidNotFoundError";
176
176
  }
177
- static code = "INVALID_GIT_REPO_SPEC_ERROR";
178
- static statusCode = 400;
179
- static description = `Invalid git repository specification: {message}`;
177
+ static code = "FIRECRACKER_PID_NOT_FOUND";
178
+ static statusCode = 500;
179
+ static description = `Firecracker PID not found`;
180
180
  }
181
- class InternalErrorError extends Error {
181
+ class FirecrackerApiSocketNotFoundError extends Error {
182
182
  constructor(body) {
183
183
  super(
184
- `INTERNAL_ERROR: ${body.message}`
184
+ `FIRECRACKER_API_SOCKET_NOT_FOUND: ${body.message}`
185
185
  );
186
186
  this.body = body;
187
- this.name = "InternalErrorError";
187
+ this.name = "FirecrackerApiSocketNotFoundError";
188
188
  }
189
- static code = "INTERNAL_ERROR";
189
+ static code = "FIRECRACKER_API_SOCKET_NOT_FOUND";
190
190
  static statusCode = 500;
191
- static description = `Internal error: {message}`;
191
+ static description = `Firecracker API socket not found`;
192
192
  }
193
- class ForkVmNotFoundError extends Error {
193
+ class InvalidSnapshotIdError extends Error {
194
194
  constructor(body) {
195
195
  super(
196
- `FORK_VM_NOT_FOUND: ${body.message}`
196
+ `INVALID_SNAPSHOT_ID: ${body.message}`
197
197
  );
198
198
  this.body = body;
199
- this.name = "ForkVmNotFoundError";
199
+ this.name = "InvalidSnapshotIdError";
200
200
  }
201
- static code = "FORK_VM_NOT_FOUND";
202
- static statusCode = 404;
203
- static description = `Fork VM not found: {fork_vm_id}`;
201
+ static code = "INVALID_SNAPSHOT_ID";
202
+ static statusCode = 400;
203
+ static description = `Invalid snapshot id: {id}`;
204
204
  }
205
- class CreateSnapshotBadRequestError extends Error {
205
+ class VmStartTimeoutError extends Error {
206
206
  constructor(body) {
207
207
  super(
208
- `CREATE_SNAPSHOT_BAD_REQUEST: ${body.message}`
208
+ `VM_START_TIMEOUT: ${body.message}`
209
209
  );
210
210
  this.body = body;
211
- this.name = "CreateSnapshotBadRequestError";
211
+ this.name = "VmStartTimeoutError";
212
212
  }
213
- static code = "CREATE_SNAPSHOT_BAD_REQUEST";
214
- static statusCode = 400;
215
- static description = `Bad request: {message}`;
213
+ static code = "VM_START_TIMEOUT";
214
+ static statusCode = 504;
215
+ static description = `VM did not become ready within the specified timeout`;
216
216
  }
217
- class ActiveTransactionErrorError extends Error {
217
+ class VmIsSuspendingError extends Error {
218
218
  constructor(body) {
219
219
  super(
220
- `ACTIVE_TRANSACTION_ERROR: ${body.message}`
220
+ `VM_IS_SUSPENDING: ${body.message}`
221
221
  );
222
222
  this.body = body;
223
- this.name = "ActiveTransactionErrorError";
223
+ this.name = "VmIsSuspendingError";
224
224
  }
225
- static code = "ACTIVE_TRANSACTION_ERROR";
225
+ static code = "VM_IS_SUSPENDING";
226
+ static statusCode = 409;
227
+ static description = `VM is currently being suspended`;
228
+ }
229
+ class VmExitDuringStartError extends Error {
230
+ constructor(body) {
231
+ super(
232
+ `VM_EXIT_DURING_START: ${body.message}`
233
+ );
234
+ this.body = body;
235
+ this.name = "VmExitDuringStartError";
236
+ }
237
+ static code = "VM_EXIT_DURING_START";
226
238
  static statusCode = 500;
227
- static description = `Active transaction error: {details}`;
239
+ static description = `VM process exited unexpectedly during start`;
228
240
  }
229
- class SwapVmTapError extends Error {
241
+ class VmAccessDeniedError extends Error {
230
242
  constructor(body) {
231
243
  super(
232
- `SWAP_VM_TAP: ${body.message}`
244
+ `VM_ACCESS_DENIED: ${body.message}`
233
245
  );
234
246
  this.body = body;
235
- this.name = "SwapVmTapError";
247
+ this.name = "VmAccessDeniedError";
236
248
  }
237
- static code = "SWAP_VM_TAP";
249
+ static code = "VM_ACCESS_DENIED";
250
+ static statusCode = 403;
251
+ static description = `You do not have access to this VM`;
252
+ }
253
+ class StdIoError extends Error {
254
+ constructor(body) {
255
+ super(
256
+ `STD_IO: ${body.message}`
257
+ );
258
+ this.body = body;
259
+ this.name = "StdIoError";
260
+ }
261
+ static code = "STD_IO";
238
262
  static statusCode = 500;
239
- static description = `Failed to swap tap device: {details}`;
263
+ static description = `Standard IO error`;
240
264
  }
241
- class RootfsCopyErrorError extends Error {
265
+ class FailedToSpawnUffdError extends Error {
242
266
  constructor(body) {
243
267
  super(
244
- `ROOTFS_COPY_ERROR: ${body.message}`
268
+ `FAILED_TO_SPAWN_UFFD: ${body.message}`
245
269
  );
246
270
  this.body = body;
247
- this.name = "RootfsCopyErrorError";
271
+ this.name = "FailedToSpawnUffdError";
248
272
  }
249
- static code = "ROOTFS_COPY_ERROR";
273
+ static code = "FAILED_TO_SPAWN_UFFD";
250
274
  static statusCode = 500;
251
- static description = `Failed to copy rootfs from {from} to {to}: {details}`;
275
+ static description = `Failed to spawn UFFD handler '{daemon_name}'`;
252
276
  }
253
- class VmNotFoundInFsError extends Error {
277
+ class VmSpawnProcessError extends Error {
254
278
  constructor(body) {
255
279
  super(
256
- `VM_NOT_FOUND_IN_FS: ${body.message}`
280
+ `VM_SPAWN_PROCESS: ${body.message}`
257
281
  );
258
282
  this.body = body;
259
- this.name = "VmNotFoundInFsError";
283
+ this.name = "VmSpawnProcessError";
260
284
  }
261
- static code = "VM_NOT_FOUND_IN_FS";
262
- static statusCode = 406;
263
- static description = `Vm Not found in filesystem`;
285
+ static code = "VM_SPAWN_PROCESS";
286
+ static statusCode = 500;
287
+ static description = `Failed to spawn process for VM`;
264
288
  }
265
- class DatabaseErrorError extends Error {
289
+ class VmSubnetNotFoundError extends Error {
266
290
  constructor(body) {
267
291
  super(
268
- `DATABASE_ERROR: ${body.message}`
292
+ `VM_SUBNET_NOT_FOUND: ${body.message}`
269
293
  );
270
294
  this.body = body;
271
- this.name = "DatabaseErrorError";
295
+ this.name = "VmSubnetNotFoundError";
272
296
  }
273
- static code = "DATABASE_ERROR";
297
+ static code = "VM_SUBNET_NOT_FOUND";
274
298
  static statusCode = 500;
275
- static description = `Database error occurred while constructing VmRecord, details: {details}`;
299
+ static description = `Subnet for VM not found`;
276
300
  }
277
- class InvalidVmIdError extends Error {
301
+ class VmOperationDeniedDuringTransactionError extends Error {
278
302
  constructor(body) {
279
303
  super(
280
- `INVALID_VM_ID: ${body.message}`
304
+ `VM_OPERATION_DENIED_DURING_TRANSACTION: ${body.message}`
281
305
  );
282
306
  this.body = body;
283
- this.name = "InvalidVmIdError";
307
+ this.name = "VmOperationDeniedDuringTransactionError";
284
308
  }
285
- static code = "INVALID_VM_ID";
309
+ static code = "VM_OPERATION_DENIED_DURING_TRANSACTION";
310
+ static statusCode = 409;
311
+ static description = `VM operation denied during active transaction for VM {vm_id} in transaction {transaction_id}`;
312
+ }
313
+ class VmTransactionIdMismatchError extends Error {
314
+ constructor(body) {
315
+ super(
316
+ `VM_TRANSACTION_ID_MISMATCH: ${body.message}`
317
+ );
318
+ this.body = body;
319
+ this.name = "VmTransactionIdMismatchError";
320
+ }
321
+ static code = "VM_TRANSACTION_ID_MISMATCH";
286
322
  static statusCode = 400;
287
- static description = `Invalid VM ID: {vm_id}, details: {details}`;
323
+ static description = `Transaction ID {provided_transaction_id} does not match the current VM transaction {expected_transaction_id} for VM {vm_id}`;
324
+ }
325
+ class VmNotInTransactionError extends Error {
326
+ constructor(body) {
327
+ super(
328
+ `VM_NOT_IN_TRANSACTION: ${body.message}`
329
+ );
330
+ this.body = body;
331
+ this.name = "VmNotInTransactionError";
332
+ }
333
+ static code = "VM_NOT_IN_TRANSACTION";
334
+ static statusCode = 404;
335
+ static description = `VM not in a transaction: {vm_id}`;
336
+ }
337
+ class VmNotFoundInFsError extends Error {
338
+ constructor(body) {
339
+ super(
340
+ `VM_NOT_FOUND_IN_FS: ${body.message}`
341
+ );
342
+ this.body = body;
343
+ this.name = "VmNotFoundInFsError";
344
+ }
345
+ static code = "VM_NOT_FOUND_IN_FS";
346
+ static statusCode = 406;
347
+ static description = `Vm Not found in filesystem`;
348
+ }
349
+ class VmNotRunningError extends Error {
350
+ constructor(body) {
351
+ super(
352
+ `VM_NOT_RUNNING: ${body.message}`
353
+ );
354
+ this.body = body;
355
+ this.name = "VmNotRunningError";
356
+ }
357
+ static code = "VM_NOT_RUNNING";
358
+ static statusCode = 400;
359
+ static description = `VM is not running: {vm_id}`;
288
360
  }
289
361
  class VmNotFoundError extends Error {
290
362
  constructor(body) {
@@ -334,533 +406,473 @@ class InternalVmNotFoundError extends Error {
334
406
  static statusCode = 404;
335
407
  static description = `VM not found: {vm_id}`;
336
408
  }
337
- class SnapshotSetupFailedError extends Error {
409
+ class UserNotFoundError extends Error {
338
410
  constructor(body) {
339
411
  super(
340
- `SNAPSHOT_SETUP_FAILED: ${body.message}`
412
+ `USER_NOT_FOUND: ${body.message}`
341
413
  );
342
414
  this.body = body;
343
- this.name = "SnapshotSetupFailedError";
415
+ this.name = "UserNotFoundError";
344
416
  }
345
- static code = "SNAPSHOT_SETUP_FAILED";
346
- static statusCode = 500;
347
- static description = `Snapshot setup failed: {failed_reason}`;
417
+ static code = "USER_NOT_FOUND";
418
+ static statusCode = 404;
419
+ static description = `User not found: {user_name}`;
348
420
  }
349
- class SnapshotVmBadRequestError extends Error {
421
+ class UserAlreadyExistsError extends Error {
350
422
  constructor(body) {
351
423
  super(
352
- `SNAPSHOT_VM_BAD_REQUEST: ${body.message}`
424
+ `USER_ALREADY_EXISTS: ${body.message}`
353
425
  );
354
426
  this.body = body;
355
- this.name = "SnapshotVmBadRequestError";
427
+ this.name = "UserAlreadyExistsError";
356
428
  }
357
- static code = "SNAPSHOT_VM_BAD_REQUEST";
358
- static statusCode = 400;
359
- static description = `Bad request: {message}`;
429
+ static code = "USER_ALREADY_EXISTS";
430
+ static statusCode = 409;
431
+ static description = `Conflict: User '{user_name}' already exists`;
360
432
  }
361
- class VmDeletedError extends Error {
433
+ class ValidationErrorError extends Error {
362
434
  constructor(body) {
363
435
  super(
364
- `VM_DELETED: ${body.message}`
436
+ `VALIDATION_ERROR: ${body.message}`
365
437
  );
366
438
  this.body = body;
367
- this.name = "VmDeletedError";
439
+ this.name = "ValidationErrorError";
368
440
  }
369
- static code = "VM_DELETED";
370
- static statusCode = 500;
371
- static description = `Vm {vm_id} is marked as deleted but still exists in the database`;
441
+ static code = "VALIDATION_ERROR";
442
+ static statusCode = 400;
443
+ static description = `Validation error: {message}`;
372
444
  }
373
- class NoDefaultSnapshotAvailableError extends Error {
445
+ class GroupNotFoundError extends Error {
374
446
  constructor(body) {
375
447
  super(
376
- `NO_DEFAULT_SNAPSHOT_AVAILABLE: ${body.message}`
448
+ `GROUP_NOT_FOUND: ${body.message}`
377
449
  );
378
450
  this.body = body;
379
- this.name = "NoDefaultSnapshotAvailableError";
451
+ this.name = "GroupNotFoundError";
380
452
  }
381
- static code = "NO_DEFAULT_SNAPSHOT_AVAILABLE";
453
+ static code = "GROUP_NOT_FOUND";
382
454
  static statusCode = 404;
383
- static description = `No default snapshot available for account {account_id}`;
455
+ static description = `Group not found: {group_name}`;
384
456
  }
385
- class DockerSnapshotFailedError extends Error {
457
+ class GroupAlreadyExistsError extends Error {
386
458
  constructor(body) {
387
459
  super(
388
- `DOCKER_SNAPSHOT_FAILED: ${body.message}`
460
+ `GROUP_ALREADY_EXISTS: ${body.message}`
389
461
  );
390
462
  this.body = body;
391
- this.name = "DockerSnapshotFailedError";
463
+ this.name = "GroupAlreadyExistsError";
392
464
  }
393
- static code = "DOCKER_SNAPSHOT_FAILED";
394
- static statusCode = 500;
395
- static description = `Failed to create snapshot from Docker image {docker_image} for account {account_id}: {details}`;
465
+ static code = "GROUP_ALREADY_EXISTS";
466
+ static statusCode = 409;
467
+ static description = `Conflict: Group '{group_name}' already exists`;
396
468
  }
397
- class SetDefaultSnapshotFailedError extends Error {
469
+ class DuplicateUserNameError extends Error {
398
470
  constructor(body) {
399
471
  super(
400
- `SET_DEFAULT_SNAPSHOT_FAILED: ${body.message}`
472
+ `DUPLICATE_USER_NAME: ${body.message}`
401
473
  );
402
474
  this.body = body;
403
- this.name = "SetDefaultSnapshotFailedError";
475
+ this.name = "DuplicateUserNameError";
404
476
  }
405
- static code = "SET_DEFAULT_SNAPSHOT_FAILED";
406
- static statusCode = 500;
407
- static description = `Failed to update default snapshot in database for account {account_id}, snapshot {snapshot_id}: {details}`;
477
+ static code = "DUPLICATE_USER_NAME";
478
+ static statusCode = 400;
479
+ static description = `Duplicate user name '{name}' found`;
408
480
  }
409
- class SnapshotLayerCreationFailedError extends Error {
481
+ class UserGroupEmptyError extends Error {
410
482
  constructor(body) {
411
483
  super(
412
- `SNAPSHOT_LAYER_CREATION_FAILED: ${body.message}`
484
+ `USER_GROUP_EMPTY: ${body.message}`
413
485
  );
414
486
  this.body = body;
415
- this.name = "SnapshotLayerCreationFailedError";
487
+ this.name = "UserGroupEmptyError";
416
488
  }
417
- static code = "SNAPSHOT_LAYER_CREATION_FAILED";
418
- static statusCode = 500;
419
- static description = `Failed to create snapshot layer for account {account_id} from {source_snapshot_dir}: {details}`;
489
+ static code = "USER_GROUP_EMPTY";
490
+ static statusCode = 400;
491
+ static description = `User '{user}' has empty string in groups`;
420
492
  }
421
- class SnapshotDirNotFoundError extends Error {
493
+ class UserSystemFlagMismatchError extends Error {
422
494
  constructor(body) {
423
495
  super(
424
- `SNAPSHOT_DIR_NOT_FOUND: ${body.message}`
496
+ `USER_SYSTEM_FLAG_MISMATCH: ${body.message}`
425
497
  );
426
498
  this.body = body;
427
- this.name = "SnapshotDirNotFoundError";
499
+ this.name = "UserSystemFlagMismatchError";
428
500
  }
429
- static code = "SNAPSHOT_DIR_NOT_FOUND";
430
- static statusCode = 500;
431
- static description = `Snapshot directory not found at {snapshot_dir} for account {account_id}, snapshot {snapshot_id}`;
501
+ static code = "USER_SYSTEM_FLAG_MISMATCH";
502
+ static statusCode = 400;
503
+ static description = `User '{user}' has system=true but UID {uid} is > 999 (system range)`;
432
504
  }
433
- class SubvolumeCreationFailedError extends Error {
505
+ class UserUidOutOfRangeError extends Error {
434
506
  constructor(body) {
435
507
  super(
436
- `SUBVOLUME_CREATION_FAILED: ${body.message}`
508
+ `USER_UID_OUT_OF_RANGE: ${body.message}`
437
509
  );
438
510
  this.body = body;
439
- this.name = "SubvolumeCreationFailedError";
511
+ this.name = "UserUidOutOfRangeError";
440
512
  }
441
- static code = "SUBVOLUME_CREATION_FAILED";
442
- static statusCode = 500;
443
- static description = `Failed to create account subvolume for account {account_id}: {details}`;
513
+ static code = "USER_UID_OUT_OF_RANGE";
514
+ static statusCode = 400;
515
+ static description = `User '{user}' has invalid UID {uid} (must be 0-65535)`;
444
516
  }
445
- class GetDefaultSnapshotFailedError extends Error {
517
+ class UserHomeInvalidError extends Error {
446
518
  constructor(body) {
447
519
  super(
448
- `GET_DEFAULT_SNAPSHOT_FAILED: ${body.message}`
520
+ `USER_HOME_INVALID: ${body.message}`
449
521
  );
450
522
  this.body = body;
451
- this.name = "GetDefaultSnapshotFailedError";
523
+ this.name = "UserHomeInvalidError";
452
524
  }
453
- static code = "GET_DEFAULT_SNAPSHOT_FAILED";
454
- static statusCode = 500;
455
- static description = `Failed to query account default snapshot for account {account_id}: {details}`;
525
+ static code = "USER_HOME_INVALID";
526
+ static statusCode = 400;
527
+ static description = `User '{user}' has invalid home path '{home}' (must be absolute path starting with /)`;
456
528
  }
457
- class SuspendFailedAndStopFailedError extends Error {
529
+ class UserShellInvalidError extends Error {
458
530
  constructor(body) {
459
531
  super(
460
- `SUSPEND_FAILED_AND_STOP_FAILED: ${body.message}`
532
+ `USER_SHELL_INVALID: ${body.message}`
461
533
  );
462
534
  this.body = body;
463
- this.name = "SuspendFailedAndStopFailedError";
535
+ this.name = "UserShellInvalidError";
464
536
  }
465
- static code = "SUSPEND_FAILED_AND_STOP_FAILED";
466
- static statusCode = 500;
467
- static description = `Failed to gracefully suspend or stop VM`;
537
+ static code = "USER_SHELL_INVALID";
538
+ static statusCode = 400;
539
+ static description = `User '{user}' has invalid shell path '{shell}' (must be absolute path starting with /)`;
468
540
  }
469
- class SuspendFailedAndStoppedError extends Error {
541
+ class DuplicateGroupNameError extends Error {
470
542
  constructor(body) {
471
543
  super(
472
- `SUSPEND_FAILED_AND_STOPPED: ${body.message}`
544
+ `DUPLICATE_GROUP_NAME: ${body.message}`
473
545
  );
474
546
  this.body = body;
475
- this.name = "SuspendFailedAndStoppedError";
547
+ this.name = "DuplicateGroupNameError";
476
548
  }
477
- static code = "SUSPEND_FAILED_AND_STOPPED";
478
- static statusCode = 500;
479
- static description = `Failed to gracefully suspend, stopped VM`;
549
+ static code = "DUPLICATE_GROUP_NAME";
550
+ static statusCode = 400;
551
+ static description = `Duplicate group name '{name}' found`;
480
552
  }
481
- class SnapshotNotFoundError extends Error {
553
+ class GroupNameReservedError extends Error {
482
554
  constructor(body) {
483
555
  super(
484
- `SNAPSHOT_NOT_FOUND: ${body.message}`
556
+ `GROUP_NAME_RESERVED: ${body.message}`
485
557
  );
486
558
  this.body = body;
487
- this.name = "SnapshotNotFoundError";
559
+ this.name = "GroupNameReservedError";
488
560
  }
489
- static code = "SNAPSHOT_NOT_FOUND";
490
- static statusCode = 404;
491
- static description = `Snapshot not found: {snapshot_id}`;
561
+ static code = "GROUP_NAME_RESERVED";
562
+ static statusCode = 400;
563
+ static description = `Group name '{name}' is reserved and cannot be used`;
492
564
  }
493
- class ResumedVmNonResponsiveError extends Error {
565
+ class GroupNameInvalidCharsError extends Error {
494
566
  constructor(body) {
495
567
  super(
496
- `RESUMED_VM_NON_RESPONSIVE: ${body.message}`
568
+ `GROUP_NAME_INVALID_CHARS: ${body.message}`
497
569
  );
498
570
  this.body = body;
499
- this.name = "ResumedVmNonResponsiveError";
571
+ this.name = "GroupNameInvalidCharsError";
500
572
  }
501
- static code = "RESUMED_VM_NON_RESPONSIVE";
502
- static statusCode = 500;
503
- static description = `Resumed VM {vm_id} is not responsive after {timeout_seconds}s`;
573
+ static code = "GROUP_NAME_INVALID_CHARS";
574
+ static statusCode = 400;
575
+ static description = `Group name '{name}' contains invalid characters (must match [a-z_][a-z0-9_-]*)`;
504
576
  }
505
- class SnapshotLoadTimeoutError extends Error {
577
+ class GroupNameTooLongError extends Error {
506
578
  constructor(body) {
507
579
  super(
508
- `SNAPSHOT_LOAD_TIMEOUT: ${body.message}`
580
+ `GROUP_NAME_TOO_LONG: ${body.message}`
509
581
  );
510
582
  this.body = body;
511
- this.name = "SnapshotLoadTimeoutError";
583
+ this.name = "GroupNameTooLongError";
512
584
  }
513
- static code = "SNAPSHOT_LOAD_TIMEOUT";
514
- static statusCode = 500;
515
- static description = `Snapshot load timed out after {elapsed_seconds}s for instance {vm_instance_id}, logs: {log_path}`;
585
+ static code = "GROUP_NAME_TOO_LONG";
586
+ static statusCode = 400;
587
+ static description = `Group name '{name}' is too long (max {max_length} characters)`;
516
588
  }
517
- class UffdTimeoutErrorError extends Error {
589
+ class GroupNameEmptyError extends Error {
518
590
  constructor(body) {
519
591
  super(
520
- `UFFD_TIMEOUT_ERROR: ${body.message}`
592
+ `GROUP_NAME_EMPTY: ${body.message}`
521
593
  );
522
594
  this.body = body;
523
- this.name = "UffdTimeoutErrorError";
595
+ this.name = "GroupNameEmptyError";
524
596
  }
525
- static code = "UFFD_TIMEOUT_ERROR";
526
- static statusCode = 500;
527
- static description = `UFFD socket timeout: {report_socket_path}, logs: {log_path}`;
597
+ static code = "GROUP_NAME_EMPTY";
598
+ static statusCode = 400;
599
+ static description = `Group name cannot be empty`;
528
600
  }
529
- class KernelPanicError extends Error {
601
+ class NoDefaultSnapshotAvailableError extends Error {
530
602
  constructor(body) {
531
603
  super(
532
- `KERNEL_PANIC: ${body.message}`
604
+ `NO_DEFAULT_SNAPSHOT_AVAILABLE: ${body.message}`
533
605
  );
534
606
  this.body = body;
535
- this.name = "KernelPanicError";
607
+ this.name = "NoDefaultSnapshotAvailableError";
536
608
  }
537
- static code = "KERNEL_PANIC";
538
- static statusCode = 500;
539
- static description = `VM kernel panic detected`;
609
+ static code = "NO_DEFAULT_SNAPSHOT_AVAILABLE";
610
+ static statusCode = 404;
611
+ static description = `No default snapshot available for account {account_id}`;
540
612
  }
541
- class ReqwestError extends Error {
613
+ class DockerSnapshotFailedError extends Error {
542
614
  constructor(body) {
543
615
  super(
544
- `REQWEST: ${body.message}`
616
+ `DOCKER_SNAPSHOT_FAILED: ${body.message}`
545
617
  );
546
618
  this.body = body;
547
- this.name = "ReqwestError";
619
+ this.name = "DockerSnapshotFailedError";
548
620
  }
549
- static code = "REQWEST";
621
+ static code = "DOCKER_SNAPSHOT_FAILED";
550
622
  static statusCode = 500;
551
- static description = `Reqwest error: {details}`;
623
+ static description = `Failed to create snapshot from Docker image {docker_image} for account {account_id}: {details}`;
552
624
  }
553
- class FirecrackerPidNotFoundError extends Error {
625
+ class SetDefaultSnapshotFailedError extends Error {
554
626
  constructor(body) {
555
627
  super(
556
- `FIRECRACKER_PID_NOT_FOUND: ${body.message}`
628
+ `SET_DEFAULT_SNAPSHOT_FAILED: ${body.message}`
557
629
  );
558
630
  this.body = body;
559
- this.name = "FirecrackerPidNotFoundError";
631
+ this.name = "SetDefaultSnapshotFailedError";
560
632
  }
561
- static code = "FIRECRACKER_PID_NOT_FOUND";
633
+ static code = "SET_DEFAULT_SNAPSHOT_FAILED";
562
634
  static statusCode = 500;
563
- static description = `Firecracker PID not found`;
635
+ static description = `Failed to update default snapshot in database for account {account_id}, snapshot {snapshot_id}: {details}`;
564
636
  }
565
- class FirecrackerApiSocketNotFoundError extends Error {
637
+ class SnapshotLayerCreationFailedError extends Error {
566
638
  constructor(body) {
567
639
  super(
568
- `FIRECRACKER_API_SOCKET_NOT_FOUND: ${body.message}`
640
+ `SNAPSHOT_LAYER_CREATION_FAILED: ${body.message}`
569
641
  );
570
642
  this.body = body;
571
- this.name = "FirecrackerApiSocketNotFoundError";
643
+ this.name = "SnapshotLayerCreationFailedError";
572
644
  }
573
- static code = "FIRECRACKER_API_SOCKET_NOT_FOUND";
645
+ static code = "SNAPSHOT_LAYER_CREATION_FAILED";
574
646
  static statusCode = 500;
575
- static description = `Firecracker API socket not found`;
576
- }
577
- class InvalidSnapshotIdError extends Error {
578
- constructor(body) {
579
- super(
580
- `INVALID_SNAPSHOT_ID: ${body.message}`
581
- );
582
- this.body = body;
583
- this.name = "InvalidSnapshotIdError";
584
- }
585
- static code = "INVALID_SNAPSHOT_ID";
586
- static statusCode = 400;
587
- static description = `Invalid snapshot id: {id}`;
588
- }
589
- class VmStartTimeoutError extends Error {
590
- constructor(body) {
591
- super(
592
- `VM_START_TIMEOUT: ${body.message}`
593
- );
594
- this.body = body;
595
- this.name = "VmStartTimeoutError";
596
- }
597
- static code = "VM_START_TIMEOUT";
598
- static statusCode = 504;
599
- static description = `VM did not become ready within the specified timeout`;
647
+ static description = `Failed to create snapshot layer for account {account_id} from {source_snapshot_dir}: {details}`;
600
648
  }
601
- class VmExitDuringStartError extends Error {
649
+ class SnapshotDirNotFoundError extends Error {
602
650
  constructor(body) {
603
651
  super(
604
- `VM_EXIT_DURING_START: ${body.message}`
652
+ `SNAPSHOT_DIR_NOT_FOUND: ${body.message}`
605
653
  );
606
654
  this.body = body;
607
- this.name = "VmExitDuringStartError";
655
+ this.name = "SnapshotDirNotFoundError";
608
656
  }
609
- static code = "VM_EXIT_DURING_START";
657
+ static code = "SNAPSHOT_DIR_NOT_FOUND";
610
658
  static statusCode = 500;
611
- static description = `VM process exited unexpectedly during start`;
659
+ static description = `Snapshot directory not found at {snapshot_dir} for account {account_id}, snapshot {snapshot_id}`;
612
660
  }
613
- class VmAccessDeniedError extends Error {
661
+ class SubvolumeCreationFailedError extends Error {
614
662
  constructor(body) {
615
663
  super(
616
- `VM_ACCESS_DENIED: ${body.message}`
664
+ `SUBVOLUME_CREATION_FAILED: ${body.message}`
617
665
  );
618
666
  this.body = body;
619
- this.name = "VmAccessDeniedError";
667
+ this.name = "SubvolumeCreationFailedError";
620
668
  }
621
- static code = "VM_ACCESS_DENIED";
622
- static statusCode = 403;
623
- static description = `You do not have access to this VM`;
669
+ static code = "SUBVOLUME_CREATION_FAILED";
670
+ static statusCode = 500;
671
+ static description = `Failed to create account subvolume for account {account_id}: {details}`;
624
672
  }
625
- class StdIoError extends Error {
673
+ class GetDefaultSnapshotFailedError extends Error {
626
674
  constructor(body) {
627
675
  super(
628
- `STD_IO: ${body.message}`
676
+ `GET_DEFAULT_SNAPSHOT_FAILED: ${body.message}`
629
677
  );
630
678
  this.body = body;
631
- this.name = "StdIoError";
679
+ this.name = "GetDefaultSnapshotFailedError";
632
680
  }
633
- static code = "STD_IO";
681
+ static code = "GET_DEFAULT_SNAPSHOT_FAILED";
634
682
  static statusCode = 500;
635
- static description = `Standard IO error`;
683
+ static description = `Failed to query account default snapshot for account {account_id}: {details}`;
636
684
  }
637
- class FailedToSpawnUffdError extends Error {
685
+ class SnapshotSetupFailedError extends Error {
638
686
  constructor(body) {
639
687
  super(
640
- `FAILED_TO_SPAWN_UFFD: ${body.message}`
688
+ `SNAPSHOT_SETUP_FAILED: ${body.message}`
641
689
  );
642
690
  this.body = body;
643
- this.name = "FailedToSpawnUffdError";
691
+ this.name = "SnapshotSetupFailedError";
644
692
  }
645
- static code = "FAILED_TO_SPAWN_UFFD";
693
+ static code = "SNAPSHOT_SETUP_FAILED";
646
694
  static statusCode = 500;
647
- static description = `Failed to spawn UFFD handler '{daemon_name}'`;
695
+ static description = `Snapshot setup failed: {failed_reason}`;
648
696
  }
649
- class VmSpawnProcessError extends Error {
697
+ class SnapshotVmBadRequestError extends Error {
650
698
  constructor(body) {
651
699
  super(
652
- `VM_SPAWN_PROCESS: ${body.message}`
700
+ `SNAPSHOT_VM_BAD_REQUEST: ${body.message}`
653
701
  );
654
702
  this.body = body;
655
- this.name = "VmSpawnProcessError";
703
+ this.name = "SnapshotVmBadRequestError";
656
704
  }
657
- static code = "VM_SPAWN_PROCESS";
658
- static statusCode = 500;
659
- static description = `Failed to spawn process for VM`;
705
+ static code = "SNAPSHOT_VM_BAD_REQUEST";
706
+ static statusCode = 400;
707
+ static description = `Bad request: {message}`;
660
708
  }
661
- class VmSubnetNotFoundError extends Error {
709
+ class DatabaseErrorError extends Error {
662
710
  constructor(body) {
663
711
  super(
664
- `VM_SUBNET_NOT_FOUND: ${body.message}`
712
+ `DATABASE_ERROR: ${body.message}`
665
713
  );
666
714
  this.body = body;
667
- this.name = "VmSubnetNotFoundError";
715
+ this.name = "DatabaseErrorError";
668
716
  }
669
- static code = "VM_SUBNET_NOT_FOUND";
717
+ static code = "DATABASE_ERROR";
670
718
  static statusCode = 500;
671
- static description = `Subnet for VM not found`;
719
+ static description = `Database error occurred while constructing VmRecord, details: {details}`;
672
720
  }
673
- class UserNotFoundError extends Error {
721
+ class PartitionNotFoundError extends Error {
674
722
  constructor(body) {
675
723
  super(
676
- `USER_NOT_FOUND: ${body.message}`
724
+ `PARTITION_NOT_FOUND: ${body.message}`
677
725
  );
678
726
  this.body = body;
679
- this.name = "UserNotFoundError";
727
+ this.name = "PartitionNotFoundError";
680
728
  }
681
- static code = "USER_NOT_FOUND";
729
+ static code = "PARTITION_NOT_FOUND";
682
730
  static statusCode = 404;
683
- static description = `User not found: {user_name}`;
684
- }
685
- class UserAlreadyExistsError extends Error {
686
- constructor(body) {
687
- super(
688
- `USER_ALREADY_EXISTS: ${body.message}`
689
- );
690
- this.body = body;
691
- this.name = "UserAlreadyExistsError";
692
- }
693
- static code = "USER_ALREADY_EXISTS";
694
- static statusCode = 409;
695
- static description = `Conflict: User '{user_name}' already exists`;
731
+ static description = `Partition not found: {partition_id}`;
696
732
  }
697
- class ValidationErrorError extends Error {
733
+ class InvalidVmIdError extends Error {
698
734
  constructor(body) {
699
735
  super(
700
- `VALIDATION_ERROR: ${body.message}`
736
+ `INVALID_VM_ID: ${body.message}`
701
737
  );
702
738
  this.body = body;
703
- this.name = "ValidationErrorError";
739
+ this.name = "InvalidVmIdError";
704
740
  }
705
- static code = "VALIDATION_ERROR";
741
+ static code = "INVALID_VM_ID";
706
742
  static statusCode = 400;
707
- static description = `Validation error: {message}`;
708
- }
709
- class GroupNotFoundError extends Error {
710
- constructor(body) {
711
- super(
712
- `GROUP_NOT_FOUND: ${body.message}`
713
- );
714
- this.body = body;
715
- this.name = "GroupNotFoundError";
716
- }
717
- static code = "GROUP_NOT_FOUND";
718
- static statusCode = 404;
719
- static description = `Group not found: {group_name}`;
720
- }
721
- class GroupAlreadyExistsError extends Error {
722
- constructor(body) {
723
- super(
724
- `GROUP_ALREADY_EXISTS: ${body.message}`
725
- );
726
- this.body = body;
727
- this.name = "GroupAlreadyExistsError";
728
- }
729
- static code = "GROUP_ALREADY_EXISTS";
730
- static statusCode = 409;
731
- static description = `Conflict: Group '{group_name}' already exists`;
743
+ static description = `Invalid VM ID: {vm_id}, details: {details}`;
732
744
  }
733
- class DuplicateUserNameError extends Error {
745
+ class SuspendFailedAndStopFailedError extends Error {
734
746
  constructor(body) {
735
747
  super(
736
- `DUPLICATE_USER_NAME: ${body.message}`
748
+ `SUSPEND_FAILED_AND_STOP_FAILED: ${body.message}`
737
749
  );
738
750
  this.body = body;
739
- this.name = "DuplicateUserNameError";
751
+ this.name = "SuspendFailedAndStopFailedError";
740
752
  }
741
- static code = "DUPLICATE_USER_NAME";
742
- static statusCode = 400;
743
- static description = `Duplicate user name '{name}' found`;
753
+ static code = "SUSPEND_FAILED_AND_STOP_FAILED";
754
+ static statusCode = 500;
755
+ static description = `Failed to gracefully suspend or stop VM`;
744
756
  }
745
- class UserGroupEmptyError extends Error {
757
+ class SuspendFailedAndStoppedError extends Error {
746
758
  constructor(body) {
747
759
  super(
748
- `USER_GROUP_EMPTY: ${body.message}`
760
+ `SUSPEND_FAILED_AND_STOPPED: ${body.message}`
749
761
  );
750
762
  this.body = body;
751
- this.name = "UserGroupEmptyError";
763
+ this.name = "SuspendFailedAndStoppedError";
752
764
  }
753
- static code = "USER_GROUP_EMPTY";
754
- static statusCode = 400;
755
- static description = `User '{user}' has empty string in groups`;
765
+ static code = "SUSPEND_FAILED_AND_STOPPED";
766
+ static statusCode = 500;
767
+ static description = `Failed to gracefully suspend, stopped VM`;
756
768
  }
757
- class UserSystemFlagMismatchError extends Error {
769
+ class FileNotFoundError extends Error {
758
770
  constructor(body) {
759
771
  super(
760
- `USER_SYSTEM_FLAG_MISMATCH: ${body.message}`
772
+ `FILE_NOT_FOUND: ${body.message}`
761
773
  );
762
774
  this.body = body;
763
- this.name = "UserSystemFlagMismatchError";
775
+ this.name = "FileNotFoundError";
764
776
  }
765
- static code = "USER_SYSTEM_FLAG_MISMATCH";
766
- static statusCode = 400;
767
- static description = `User '{user}' has system=true but UID {uid} is > 999 (system range)`;
777
+ static code = "FILE_NOT_FOUND";
778
+ static statusCode = 404;
779
+ static description = `File not found: {path}`;
768
780
  }
769
- class UserUidOutOfRangeError extends Error {
781
+ class FilesBadRequestError extends Error {
770
782
  constructor(body) {
771
783
  super(
772
- `USER_UID_OUT_OF_RANGE: ${body.message}`
784
+ `FILES_BAD_REQUEST: ${body.message}`
773
785
  );
774
786
  this.body = body;
775
- this.name = "UserUidOutOfRangeError";
787
+ this.name = "FilesBadRequestError";
776
788
  }
777
- static code = "USER_UID_OUT_OF_RANGE";
789
+ static code = "FILES_BAD_REQUEST";
778
790
  static statusCode = 400;
779
- static description = `User '{user}' has invalid UID {uid} (must be 0-65535)`;
791
+ static description = `Bad request: {message}`;
780
792
  }
781
- class UserHomeInvalidError extends Error {
793
+ class InvalidGitRepoSpecErrorError extends Error {
782
794
  constructor(body) {
783
795
  super(
784
- `USER_HOME_INVALID: ${body.message}`
796
+ `INVALID_GIT_REPO_SPEC_ERROR: ${body.message}`
785
797
  );
786
798
  this.body = body;
787
- this.name = "UserHomeInvalidError";
799
+ this.name = "InvalidGitRepoSpecErrorError";
788
800
  }
789
- static code = "USER_HOME_INVALID";
801
+ static code = "INVALID_GIT_REPO_SPEC_ERROR";
790
802
  static statusCode = 400;
791
- static description = `User '{user}' has invalid home path '{home}' (must be absolute path starting with /)`;
803
+ static description = `Invalid git repository specification: {message}`;
792
804
  }
793
- class UserShellInvalidError extends Error {
805
+ class InternalErrorError extends Error {
794
806
  constructor(body) {
795
807
  super(
796
- `USER_SHELL_INVALID: ${body.message}`
808
+ `INTERNAL_ERROR: ${body.message}`
797
809
  );
798
810
  this.body = body;
799
- this.name = "UserShellInvalidError";
811
+ this.name = "InternalErrorError";
800
812
  }
801
- static code = "USER_SHELL_INVALID";
802
- static statusCode = 400;
803
- static description = `User '{user}' has invalid shell path '{shell}' (must be absolute path starting with /)`;
813
+ static code = "INTERNAL_ERROR";
814
+ static statusCode = 500;
815
+ static description = `Internal error: {message}`;
804
816
  }
805
- class DuplicateGroupNameError extends Error {
817
+ class ForkVmNotFoundError extends Error {
806
818
  constructor(body) {
807
819
  super(
808
- `DUPLICATE_GROUP_NAME: ${body.message}`
820
+ `FORK_VM_NOT_FOUND: ${body.message}`
809
821
  );
810
822
  this.body = body;
811
- this.name = "DuplicateGroupNameError";
823
+ this.name = "ForkVmNotFoundError";
812
824
  }
813
- static code = "DUPLICATE_GROUP_NAME";
814
- static statusCode = 400;
815
- static description = `Duplicate group name '{name}' found`;
825
+ static code = "FORK_VM_NOT_FOUND";
826
+ static statusCode = 404;
827
+ static description = `Fork VM not found: {fork_vm_id}`;
816
828
  }
817
- class GroupNameReservedError extends Error {
829
+ class CreateSnapshotBadRequestError extends Error {
818
830
  constructor(body) {
819
831
  super(
820
- `GROUP_NAME_RESERVED: ${body.message}`
832
+ `CREATE_SNAPSHOT_BAD_REQUEST: ${body.message}`
821
833
  );
822
834
  this.body = body;
823
- this.name = "GroupNameReservedError";
835
+ this.name = "CreateSnapshotBadRequestError";
824
836
  }
825
- static code = "GROUP_NAME_RESERVED";
837
+ static code = "CREATE_SNAPSHOT_BAD_REQUEST";
826
838
  static statusCode = 400;
827
- static description = `Group name '{name}' is reserved and cannot be used`;
839
+ static description = `Bad request: {message}`;
828
840
  }
829
- class GroupNameInvalidCharsError extends Error {
841
+ class ActiveTransactionErrorError extends Error {
830
842
  constructor(body) {
831
843
  super(
832
- `GROUP_NAME_INVALID_CHARS: ${body.message}`
844
+ `ACTIVE_TRANSACTION_ERROR: ${body.message}`
833
845
  );
834
846
  this.body = body;
835
- this.name = "GroupNameInvalidCharsError";
847
+ this.name = "ActiveTransactionErrorError";
836
848
  }
837
- static code = "GROUP_NAME_INVALID_CHARS";
838
- static statusCode = 400;
839
- static description = `Group name '{name}' contains invalid characters (must match [a-z_][a-z0-9_-]*)`;
849
+ static code = "ACTIVE_TRANSACTION_ERROR";
850
+ static statusCode = 500;
851
+ static description = `Active transaction error: {details}`;
840
852
  }
841
- class GroupNameTooLongError extends Error {
853
+ class SwapVmTapError extends Error {
842
854
  constructor(body) {
843
855
  super(
844
- `GROUP_NAME_TOO_LONG: ${body.message}`
856
+ `SWAP_VM_TAP: ${body.message}`
845
857
  );
846
858
  this.body = body;
847
- this.name = "GroupNameTooLongError";
859
+ this.name = "SwapVmTapError";
848
860
  }
849
- static code = "GROUP_NAME_TOO_LONG";
850
- static statusCode = 400;
851
- static description = `Group name '{name}' is too long (max {max_length} characters)`;
861
+ static code = "SWAP_VM_TAP";
862
+ static statusCode = 500;
863
+ static description = `Failed to swap tap device: {details}`;
852
864
  }
853
- class GroupNameEmptyError extends Error {
865
+ class RootfsCopyErrorError extends Error {
854
866
  constructor(body) {
855
867
  super(
856
- `GROUP_NAME_EMPTY: ${body.message}`
868
+ `ROOTFS_COPY_ERROR: ${body.message}`
857
869
  );
858
870
  this.body = body;
859
- this.name = "GroupNameEmptyError";
871
+ this.name = "RootfsCopyErrorError";
860
872
  }
861
- static code = "GROUP_NAME_EMPTY";
862
- static statusCode = 400;
863
- static description = `Group name cannot be empty`;
873
+ static code = "ROOTFS_COPY_ERROR";
874
+ static statusCode = 500;
875
+ static description = `Failed to copy rootfs from {from} to {to}: {details}`;
864
876
  }
865
877
  class CreateVmBadRequestError extends Error {
866
878
  constructor(body) {
@@ -1208,31 +1220,79 @@ class ForbiddenError extends Error {
1208
1220
  }
1209
1221
  static code = "FORBIDDEN";
1210
1222
  static statusCode = 403;
1211
- static description = `Forbidden: {message}`;
1223
+ static description = `You do not have permission to push to this repository`;
1212
1224
  }
1213
- class UnsupportedTransferError extends Error {
1225
+ class UnauthorizedError extends Error {
1214
1226
  constructor(body) {
1215
1227
  super(
1216
- `UNSUPPORTED_TRANSFER: ${body.message}`
1228
+ `UNAUTHORIZED: ${body.message}`
1217
1229
  );
1218
1230
  this.body = body;
1219
- this.name = "UnsupportedTransferError";
1231
+ this.name = "UnauthorizedError";
1220
1232
  }
1221
- static code = "UNSUPPORTED_TRANSFER";
1222
- static statusCode = 400;
1223
- static description = `Unsupported LFS transfer protocol(s)`;
1233
+ static code = "UNAUTHORIZED";
1234
+ static statusCode = 401;
1235
+ static description = `Unauthorized`;
1224
1236
  }
1225
- class TreeNotFoundError extends Error {
1237
+ class BlobNotFoundError extends Error {
1226
1238
  constructor(body) {
1227
1239
  super(
1228
- `TREE_NOT_FOUND: ${body.message}`
1240
+ `BLOB_NOT_FOUND: ${body.message}`
1229
1241
  );
1230
1242
  this.body = body;
1231
- this.name = "TreeNotFoundError";
1243
+ this.name = "BlobNotFoundError";
1232
1244
  }
1233
- static code = "TREE_NOT_FOUND";
1245
+ static code = "BLOB_NOT_FOUND";
1234
1246
  static statusCode = 404;
1235
- static description = `Tree not found: {hash}`;
1247
+ static description = `Blob not found: {hash}`;
1248
+ }
1249
+ class InvalidRangeError extends Error {
1250
+ constructor(body) {
1251
+ super(
1252
+ `INVALID_RANGE: ${body.message}`
1253
+ );
1254
+ this.body = body;
1255
+ this.name = "InvalidRangeError";
1256
+ }
1257
+ static code = "INVALID_RANGE";
1258
+ static statusCode = 400;
1259
+ static description = `Invalid range: 'until' commit ({until}) must be a descendant of 'since' commit ({since}). In other words, 'until' must be newer than 'since' in the commit graph.`;
1260
+ }
1261
+ class OffsetWithSelectorError extends Error {
1262
+ constructor(body) {
1263
+ super(
1264
+ `OFFSET_WITH_SELECTOR: ${body.message}`
1265
+ );
1266
+ this.body = body;
1267
+ this.name = "OffsetWithSelectorError";
1268
+ }
1269
+ static code = "OFFSET_WITH_SELECTOR";
1270
+ static statusCode = 400;
1271
+ static description = `Cannot use 'offset' parameter together with 'since' or 'until'. Use 'since' for cursor-based pagination.`;
1272
+ }
1273
+ class CommitNotInBranchError extends Error {
1274
+ constructor(body) {
1275
+ super(
1276
+ `COMMIT_NOT_IN_BRANCH: ${body.message}`
1277
+ );
1278
+ this.body = body;
1279
+ this.name = "CommitNotInBranchError";
1280
+ }
1281
+ static code = "COMMIT_NOT_IN_BRANCH";
1282
+ static statusCode = 400;
1283
+ static description = `Commit {sha} is not in the history of branch {branch}`;
1284
+ }
1285
+ class CommitNotFoundError extends Error {
1286
+ constructor(body) {
1287
+ super(
1288
+ `COMMIT_NOT_FOUND: ${body.message}`
1289
+ );
1290
+ this.body = body;
1291
+ this.name = "CommitNotFoundError";
1292
+ }
1293
+ static code = "COMMIT_NOT_FOUND";
1294
+ static statusCode = 400;
1295
+ static description = `Commit not found: {sha}`;
1236
1296
  }
1237
1297
  class BranchNotFoundError extends Error {
1238
1298
  constructor(body) {
@@ -1246,6 +1306,126 @@ class BranchNotFoundError extends Error {
1246
1306
  static statusCode = 404;
1247
1307
  static description = `Branch not found: {branch}`;
1248
1308
  }
1309
+ class NoDefaultBranchError extends Error {
1310
+ constructor(body) {
1311
+ super(
1312
+ `NO_DEFAULT_BRANCH: ${body.message}`
1313
+ );
1314
+ this.body = body;
1315
+ this.name = "NoDefaultBranchError";
1316
+ }
1317
+ static code = "NO_DEFAULT_BRANCH";
1318
+ static statusCode = 404;
1319
+ static description = `Repository has no default branch configured`;
1320
+ }
1321
+ class InvalidBase64ContentError extends Error {
1322
+ constructor(body) {
1323
+ super(
1324
+ `INVALID_BASE64_CONTENT: ${body.message}`
1325
+ );
1326
+ this.body = body;
1327
+ this.name = "InvalidBase64ContentError";
1328
+ }
1329
+ static code = "INVALID_BASE64_CONTENT";
1330
+ static statusCode = 400;
1331
+ static description = `Invalid base64 content for file: {path}`;
1332
+ }
1333
+ class InvalidFileChangeError extends Error {
1334
+ constructor(body) {
1335
+ super(
1336
+ `INVALID_FILE_CHANGE: ${body.message}`
1337
+ );
1338
+ this.body = body;
1339
+ this.name = "InvalidFileChangeError";
1340
+ }
1341
+ static code = "INVALID_FILE_CHANGE";
1342
+ static statusCode = 400;
1343
+ static description = `File change must have either content or deleted flag, not both: {path}`;
1344
+ }
1345
+ class InvalidFilePathError extends Error {
1346
+ constructor(body) {
1347
+ super(
1348
+ `INVALID_FILE_PATH: ${body.message}`
1349
+ );
1350
+ this.body = body;
1351
+ this.name = "InvalidFilePathError";
1352
+ }
1353
+ static code = "INVALID_FILE_PATH";
1354
+ static statusCode = 400;
1355
+ static description = `Invalid file path: {path}`;
1356
+ }
1357
+ class ConflictingParentError extends Error {
1358
+ constructor(body) {
1359
+ super(
1360
+ `CONFLICTING_PARENT: ${body.message}`
1361
+ );
1362
+ this.body = body;
1363
+ this.name = "ConflictingParentError";
1364
+ }
1365
+ static code = "CONFLICTING_PARENT";
1366
+ static statusCode = 409;
1367
+ static description = `Conflict: expected parent SHA {expected} but current is {actual:?}`;
1368
+ }
1369
+ class AmbiguousError extends Error {
1370
+ constructor(body) {
1371
+ super(
1372
+ `AMBIGUOUS: ${body.message}`
1373
+ );
1374
+ this.body = body;
1375
+ this.name = "AmbiguousError";
1376
+ }
1377
+ static code = "AMBIGUOUS";
1378
+ static statusCode = 400;
1379
+ static description = `rev is ambiguous: {rev}`;
1380
+ }
1381
+ class NotFoundError extends Error {
1382
+ constructor(body) {
1383
+ super(
1384
+ `NOT_FOUND: ${body.message}`
1385
+ );
1386
+ this.body = body;
1387
+ this.name = "NotFoundError";
1388
+ }
1389
+ static code = "NOT_FOUND";
1390
+ static statusCode = 404;
1391
+ static description = `rev not found: {rev}`;
1392
+ }
1393
+ class InvalidError extends Error {
1394
+ constructor(body) {
1395
+ super(
1396
+ `INVALID: ${body.message}`
1397
+ );
1398
+ this.body = body;
1399
+ this.name = "InvalidError";
1400
+ }
1401
+ static code = "INVALID";
1402
+ static statusCode = 400;
1403
+ static description = `invalid rev syntax: {rev}`;
1404
+ }
1405
+ class UnsupportedTransferError extends Error {
1406
+ constructor(body) {
1407
+ super(
1408
+ `UNSUPPORTED_TRANSFER: ${body.message}`
1409
+ );
1410
+ this.body = body;
1411
+ this.name = "UnsupportedTransferError";
1412
+ }
1413
+ static code = "UNSUPPORTED_TRANSFER";
1414
+ static statusCode = 400;
1415
+ static description = `Unsupported LFS transfer protocol(s)`;
1416
+ }
1417
+ class TreeNotFoundError extends Error {
1418
+ constructor(body) {
1419
+ super(
1420
+ `TREE_NOT_FOUND: ${body.message}`
1421
+ );
1422
+ this.body = body;
1423
+ this.name = "TreeNotFoundError";
1424
+ }
1425
+ static code = "TREE_NOT_FOUND";
1426
+ static statusCode = 404;
1427
+ static description = `Tree not found: {hash}`;
1428
+ }
1249
1429
  class ParentNotFoundError extends Error {
1250
1430
  constructor(body) {
1251
1431
  super(
@@ -1273,26 +1453,74 @@ class InvalidServiceError extends Error {
1273
1453
  class ExpectedServiceError extends Error {
1274
1454
  constructor(body) {
1275
1455
  super(
1276
- `EXPECTED_SERVICE: ${body.message}`
1456
+ `EXPECTED_SERVICE: ${body.message}`
1457
+ );
1458
+ this.body = body;
1459
+ this.name = "ExpectedServiceError";
1460
+ }
1461
+ static code = "EXPECTED_SERVICE";
1462
+ static statusCode = 403;
1463
+ static description = `Expected 'service' query parameter`;
1464
+ }
1465
+ class PathNotFoundError extends Error {
1466
+ constructor(body) {
1467
+ super(
1468
+ `PATH_NOT_FOUND: ${body.message}`
1469
+ );
1470
+ this.body = body;
1471
+ this.name = "PathNotFoundError";
1472
+ }
1473
+ static code = "PATH_NOT_FOUND";
1474
+ static statusCode = 404;
1475
+ static description = `Path not found: {path}`;
1476
+ }
1477
+ class ReferenceNotFoundError extends Error {
1478
+ constructor(body) {
1479
+ super(
1480
+ `REFERENCE_NOT_FOUND: ${body.message}`
1481
+ );
1482
+ this.body = body;
1483
+ this.name = "ReferenceNotFoundError";
1484
+ }
1485
+ static code = "REFERENCE_NOT_FOUND";
1486
+ static statusCode = 404;
1487
+ static description = `Reference not found: {reference}`;
1488
+ }
1489
+ class TagNotFoundError extends Error {
1490
+ constructor(body) {
1491
+ super(
1492
+ `TAG_NOT_FOUND: ${body.message}`
1493
+ );
1494
+ this.body = body;
1495
+ this.name = "TagNotFoundError";
1496
+ }
1497
+ static code = "TAG_NOT_FOUND";
1498
+ static statusCode = 404;
1499
+ static description = `Tag not found: {hash}`;
1500
+ }
1501
+ class InvalidRevisionError extends Error {
1502
+ constructor(body) {
1503
+ super(
1504
+ `INVALID_REVISION: ${body.message}`
1277
1505
  );
1278
1506
  this.body = body;
1279
- this.name = "ExpectedServiceError";
1507
+ this.name = "InvalidRevisionError";
1280
1508
  }
1281
- static code = "EXPECTED_SERVICE";
1282
- static statusCode = 403;
1283
- static description = `Expected 'service' query parameter`;
1509
+ static code = "INVALID_REVISION";
1510
+ static statusCode = 400;
1511
+ static description = `Invalid revision: {revision}`;
1284
1512
  }
1285
- class NotFoundError extends Error {
1513
+ class PackfileError extends Error {
1286
1514
  constructor(body) {
1287
1515
  super(
1288
- `NOT_FOUND: ${body.message}`
1516
+ `PACKFILE: ${body.message}`
1289
1517
  );
1290
1518
  this.body = body;
1291
- this.name = "NotFoundError";
1519
+ this.name = "PackfileError";
1292
1520
  }
1293
- static code = "NOT_FOUND";
1294
- static statusCode = 404;
1295
- static description = `Repository not found`;
1521
+ static code = "PACKFILE";
1522
+ static statusCode = 500;
1523
+ static description = `Error building packfile`;
1296
1524
  }
1297
1525
  class SendErrorError extends Error {
1298
1526
  constructor(body) {
@@ -1306,18 +1534,6 @@ class SendErrorError extends Error {
1306
1534
  static statusCode = 500;
1307
1535
  static description = `Stream receiver dropped`;
1308
1536
  }
1309
- class UnauthorizedError extends Error {
1310
- constructor(body) {
1311
- super(
1312
- `UNAUTHORIZED: ${body.message}`
1313
- );
1314
- this.body = body;
1315
- this.name = "UnauthorizedError";
1316
- }
1317
- static code = "UNAUTHORIZED";
1318
- static statusCode = 401;
1319
- static description = `Unauthorized: admin key and account id are required`;
1320
- }
1321
1537
  class InvalidAccountIdError extends Error {
1322
1538
  constructor(body) {
1323
1539
  super(
@@ -1390,545 +1606,497 @@ class RepoAlreadyExistsError extends Error {
1390
1606
  static statusCode = 409;
1391
1607
  static description = `Repo '{repo_id}' already exists`;
1392
1608
  }
1393
- class TagNotFoundError extends Error {
1609
+ class ConflictError extends Error {
1394
1610
  constructor(body) {
1395
1611
  super(
1396
- `TAG_NOT_FOUND: ${body.message}`
1612
+ `CONFLICT: ${body.message}`
1397
1613
  );
1398
1614
  this.body = body;
1399
- this.name = "TagNotFoundError";
1615
+ this.name = "ConflictError";
1400
1616
  }
1401
- static code = "TAG_NOT_FOUND";
1402
- static statusCode = 404;
1403
- static description = `Tag not found: {tag}`;
1617
+ static code = "CONFLICT";
1618
+ static statusCode = 409;
1619
+ static description = `Sync conflict: {message}`;
1404
1620
  }
1405
- class InvalidRangeError extends Error {
1621
+ class BranchAlreadyExistsError extends Error {
1406
1622
  constructor(body) {
1407
1623
  super(
1408
- `INVALID_RANGE: ${body.message}`
1624
+ `BRANCH_ALREADY_EXISTS: ${body.message}`
1409
1625
  );
1410
1626
  this.body = body;
1411
- this.name = "InvalidRangeError";
1627
+ this.name = "BranchAlreadyExistsError";
1412
1628
  }
1413
- static code = "INVALID_RANGE";
1414
- static statusCode = 400;
1415
- static description = `Invalid range: 'until' commit ({until}) must be a descendant of 'since' commit ({since}). In other words, 'until' must be newer than 'since' in the commit graph.`;
1629
+ static code = "BRANCH_ALREADY_EXISTS";
1630
+ static statusCode = 409;
1631
+ static description = `Branch already exists: {branch}`;
1416
1632
  }
1417
- class OffsetWithSelectorError extends Error {
1633
+ class GitHubSyncConflictError extends Error {
1418
1634
  constructor(body) {
1419
1635
  super(
1420
- `OFFSET_WITH_SELECTOR: ${body.message}`
1636
+ `GIT_HUB_SYNC_CONFLICT: ${body.message}`
1421
1637
  );
1422
1638
  this.body = body;
1423
- this.name = "OffsetWithSelectorError";
1639
+ this.name = "GitHubSyncConflictError";
1424
1640
  }
1425
- static code = "OFFSET_WITH_SELECTOR";
1426
- static statusCode = 400;
1427
- static description = `Cannot use 'offset' parameter together with 'since' or 'until'. Use 'since' for cursor-based pagination.`;
1641
+ static code = "GIT_HUB_SYNC_CONFLICT";
1642
+ static statusCode = 409;
1643
+ static description = `GitHub Sync Conflict: {message}`;
1428
1644
  }
1429
- class CommitNotInBranchError extends Error {
1645
+ class InvalidObjectIdError extends Error {
1430
1646
  constructor(body) {
1431
1647
  super(
1432
- `COMMIT_NOT_IN_BRANCH: ${body.message}`
1648
+ `INVALID_OBJECT_ID: ${body.message}`
1433
1649
  );
1434
1650
  this.body = body;
1435
- this.name = "CommitNotInBranchError";
1651
+ this.name = "InvalidObjectIdError";
1436
1652
  }
1437
- static code = "COMMIT_NOT_IN_BRANCH";
1653
+ static code = "INVALID_OBJECT_ID";
1438
1654
  static statusCode = 400;
1439
- static description = `Commit {sha} is not in the history of branch {branch}`;
1655
+ static description = `Invalid object ID: {hash}`;
1440
1656
  }
1441
- class CommitNotFoundError extends Error {
1657
+ class UnavailableError extends Error {
1442
1658
  constructor(body) {
1443
1659
  super(
1444
- `COMMIT_NOT_FOUND: ${body.message}`
1660
+ `UNAVAILABLE: ${body.message}`
1445
1661
  );
1446
1662
  this.body = body;
1447
- this.name = "CommitNotFoundError";
1663
+ this.name = "UnavailableError";
1448
1664
  }
1449
- static code = "COMMIT_NOT_FOUND";
1450
- static statusCode = 400;
1451
- static description = `Commit not found: {sha}`;
1665
+ static code = "UNAVAILABLE";
1666
+ static statusCode = 503;
1667
+ static description = `Cron service unavailable`;
1452
1668
  }
1453
- class NoDefaultBranchError extends Error {
1669
+ class ScheduleNotFoundError extends Error {
1454
1670
  constructor(body) {
1455
1671
  super(
1456
- `NO_DEFAULT_BRANCH: ${body.message}`
1672
+ `SCHEDULE_NOT_FOUND: ${body.message}`
1457
1673
  );
1458
1674
  this.body = body;
1459
- this.name = "NoDefaultBranchError";
1675
+ this.name = "ScheduleNotFoundError";
1460
1676
  }
1461
- static code = "NO_DEFAULT_BRANCH";
1677
+ static code = "SCHEDULE_NOT_FOUND";
1462
1678
  static statusCode = 404;
1463
- static description = `Repository has no default branch configured`;
1464
- }
1465
- class InvalidBase64ContentError extends Error {
1466
- constructor(body) {
1467
- super(
1468
- `INVALID_BASE64_CONTENT: ${body.message}`
1469
- );
1470
- this.body = body;
1471
- this.name = "InvalidBase64ContentError";
1472
- }
1473
- static code = "INVALID_BASE64_CONTENT";
1474
- static statusCode = 400;
1475
- static description = `Invalid base64 content for file: {path}`;
1476
- }
1477
- class InvalidFileChangeError extends Error {
1478
- constructor(body) {
1479
- super(
1480
- `INVALID_FILE_CHANGE: ${body.message}`
1481
- );
1482
- this.body = body;
1483
- this.name = "InvalidFileChangeError";
1484
- }
1485
- static code = "INVALID_FILE_CHANGE";
1486
- static statusCode = 400;
1487
- static description = `File change must have either content or deleted flag, not both: {path}`;
1488
- }
1489
- class InvalidFilePathError extends Error {
1490
- constructor(body) {
1491
- super(
1492
- `INVALID_FILE_PATH: ${body.message}`
1493
- );
1494
- this.body = body;
1495
- this.name = "InvalidFilePathError";
1496
- }
1497
- static code = "INVALID_FILE_PATH";
1498
- static statusCode = 400;
1499
- static description = `Invalid file path: {path}`;
1500
- }
1501
- class ConflictingParentError extends Error {
1502
- constructor(body) {
1503
- super(
1504
- `CONFLICTING_PARENT: ${body.message}`
1505
- );
1506
- this.body = body;
1507
- this.name = "ConflictingParentError";
1508
- }
1509
- static code = "CONFLICTING_PARENT";
1510
- static statusCode = 409;
1511
- static description = `Conflict: expected parent SHA {expected} but current is {actual:?}`;
1679
+ static description = `Schedule not found`;
1512
1680
  }
1513
- class AmbiguousError extends Error {
1681
+ class ServiceUnavailableError extends Error {
1514
1682
  constructor(body) {
1515
1683
  super(
1516
- `AMBIGUOUS: ${body.message}`
1684
+ `SERVICE_UNAVAILABLE: ${body.message}`
1517
1685
  );
1518
1686
  this.body = body;
1519
- this.name = "AmbiguousError";
1687
+ this.name = "ServiceUnavailableError";
1520
1688
  }
1521
- static code = "AMBIGUOUS";
1522
- static statusCode = 400;
1523
- static description = `rev is ambiguous: {rev}`;
1689
+ static code = "SERVICE_UNAVAILABLE";
1690
+ static statusCode = 503;
1691
+ static description = `Cron service not configured`;
1524
1692
  }
1525
- class InvalidError extends Error {
1693
+ class ExecuteLimitExceededError extends Error {
1526
1694
  constructor(body) {
1527
1695
  super(
1528
- `INVALID: ${body.message}`
1696
+ `EXECUTE_LIMIT_EXCEEDED: ${body.message}`
1529
1697
  );
1530
1698
  this.body = body;
1531
- this.name = "InvalidError";
1699
+ this.name = "ExecuteLimitExceededError";
1532
1700
  }
1533
- static code = "INVALID";
1534
- static statusCode = 400;
1535
- static description = `invalid rev syntax: {rev}`;
1701
+ static code = "EXECUTE_LIMIT_EXCEEDED";
1702
+ static statusCode = 403;
1703
+ static description = `Execute runs limit exceeded: your plan allows {limit} runs per month, you have used {current}`;
1536
1704
  }
1537
- class PathNotFoundError extends Error {
1705
+ class ObservabilityDatabaseErrorError extends Error {
1538
1706
  constructor(body) {
1539
1707
  super(
1540
- `PATH_NOT_FOUND: ${body.message}`
1708
+ `OBSERVABILITY_DATABASE_ERROR: ${body.message}`
1541
1709
  );
1542
1710
  this.body = body;
1543
- this.name = "PathNotFoundError";
1711
+ this.name = "ObservabilityDatabaseErrorError";
1544
1712
  }
1545
- static code = "PATH_NOT_FOUND";
1546
- static statusCode = 404;
1547
- static description = `Path not found: {path}`;
1713
+ static code = "OBSERVABILITY_DATABASE_ERROR";
1714
+ static statusCode = 500;
1715
+ static description = `Database operation failed: {message}`;
1548
1716
  }
1549
- class ReferenceNotFoundError extends Error {
1717
+ class ObservabilityAccessDeniedError extends Error {
1550
1718
  constructor(body) {
1551
1719
  super(
1552
- `REFERENCE_NOT_FOUND: ${body.message}`
1720
+ `OBSERVABILITY_ACCESS_DENIED: ${body.message}`
1553
1721
  );
1554
1722
  this.body = body;
1555
- this.name = "ReferenceNotFoundError";
1723
+ this.name = "ObservabilityAccessDeniedError";
1556
1724
  }
1557
- static code = "REFERENCE_NOT_FOUND";
1558
- static statusCode = 404;
1559
- static description = `Reference not found: {reference}`;
1725
+ static code = "OBSERVABILITY_ACCESS_DENIED";
1726
+ static statusCode = 403;
1727
+ static description = `Access denied to logs for deployment: {deployment_id}`;
1560
1728
  }
1561
- class BlobNotFoundError extends Error {
1729
+ class ParseLogsFailedError extends Error {
1562
1730
  constructor(body) {
1563
1731
  super(
1564
- `BLOB_NOT_FOUND: ${body.message}`
1732
+ `PARSE_LOGS_FAILED: ${body.message}`
1565
1733
  );
1566
1734
  this.body = body;
1567
- this.name = "BlobNotFoundError";
1735
+ this.name = "ParseLogsFailedError";
1568
1736
  }
1569
- static code = "BLOB_NOT_FOUND";
1570
- static statusCode = 404;
1571
- static description = `Blob not found: {hash}`;
1737
+ static code = "PARSE_LOGS_FAILED";
1738
+ static statusCode = 500;
1739
+ static description = `Failed to parse logs: {message}`;
1572
1740
  }
1573
- class PackfileError extends Error {
1741
+ class RetrieveLogsFailedError extends Error {
1574
1742
  constructor(body) {
1575
1743
  super(
1576
- `PACKFILE: ${body.message}`
1744
+ `RETRIEVE_LOGS_FAILED: ${body.message}`
1577
1745
  );
1578
1746
  this.body = body;
1579
- this.name = "PackfileError";
1747
+ this.name = "RetrieveLogsFailedError";
1580
1748
  }
1581
- static code = "PACKFILE";
1749
+ static code = "RETRIEVE_LOGS_FAILED";
1582
1750
  static statusCode = 500;
1583
- static description = `Error building packfile`;
1751
+ static description = `Failed to retrieve logs: {message}`;
1584
1752
  }
1585
- class InvalidRevisionError extends Error {
1753
+ class InvalidQueryError extends Error {
1586
1754
  constructor(body) {
1587
1755
  super(
1588
- `INVALID_REVISION: ${body.message}`
1756
+ `INVALID_QUERY: ${body.message}`
1589
1757
  );
1590
1758
  this.body = body;
1591
- this.name = "InvalidRevisionError";
1759
+ this.name = "InvalidQueryError";
1592
1760
  }
1593
- static code = "INVALID_REVISION";
1761
+ static code = "INVALID_QUERY";
1594
1762
  static statusCode = 400;
1595
- static description = `Invalid revision: {revision}`;
1763
+ static description = `Invalid log query: {message}`;
1596
1764
  }
1597
- class ConflictError extends Error {
1765
+ class LogsNotFoundError extends Error {
1598
1766
  constructor(body) {
1599
1767
  super(
1600
- `CONFLICT: ${body.message}`
1768
+ `LOGS_NOT_FOUND: ${body.message}`
1601
1769
  );
1602
1770
  this.body = body;
1603
- this.name = "ConflictError";
1771
+ this.name = "LogsNotFoundError";
1604
1772
  }
1605
- static code = "CONFLICT";
1606
- static statusCode = 409;
1607
- static description = `Sync conflict: {message}`;
1773
+ static code = "LOGS_NOT_FOUND";
1774
+ static statusCode = 404;
1775
+ static description = `Logs not found for deployment: {deployment_id}`;
1608
1776
  }
1609
- class BranchAlreadyExistsError extends Error {
1777
+ class ExecuteInternalErrorError extends Error {
1610
1778
  constructor(body) {
1611
1779
  super(
1612
- `BRANCH_ALREADY_EXISTS: ${body.message}`
1780
+ `EXECUTE_INTERNAL_ERROR: ${body.message}`
1613
1781
  );
1614
1782
  this.body = body;
1615
- this.name = "BranchAlreadyExistsError";
1783
+ this.name = "ExecuteInternalErrorError";
1616
1784
  }
1617
- static code = "BRANCH_ALREADY_EXISTS";
1618
- static statusCode = 409;
1619
- static description = `Branch already exists: {branch}`;
1785
+ static code = "EXECUTE_INTERNAL_ERROR";
1786
+ static statusCode = 500;
1787
+ static description = `Internal error: {message}`;
1620
1788
  }
1621
- class GitHubSyncConflictError extends Error {
1789
+ class ExecuteAccessDeniedError extends Error {
1622
1790
  constructor(body) {
1623
1791
  super(
1624
- `GIT_HUB_SYNC_CONFLICT: ${body.message}`
1792
+ `EXECUTE_ACCESS_DENIED: ${body.message}`
1625
1793
  );
1626
1794
  this.body = body;
1627
- this.name = "GitHubSyncConflictError";
1795
+ this.name = "ExecuteAccessDeniedError";
1628
1796
  }
1629
- static code = "GIT_HUB_SYNC_CONFLICT";
1630
- static statusCode = 409;
1631
- static description = `GitHub Sync Conflict: {message}`;
1797
+ static code = "EXECUTE_ACCESS_DENIED";
1798
+ static statusCode = 403;
1799
+ static description = `Access denied to execute run`;
1632
1800
  }
1633
- class InvalidObjectIdError extends Error {
1801
+ class ListRunsFailedError extends Error {
1634
1802
  constructor(body) {
1635
1803
  super(
1636
- `INVALID_OBJECT_ID: ${body.message}`
1804
+ `LIST_RUNS_FAILED: ${body.message}`
1637
1805
  );
1638
1806
  this.body = body;
1639
- this.name = "InvalidObjectIdError";
1807
+ this.name = "ListRunsFailedError";
1640
1808
  }
1641
- static code = "INVALID_OBJECT_ID";
1642
- static statusCode = 400;
1643
- static description = `Invalid object ID: {hash}`;
1809
+ static code = "LIST_RUNS_FAILED";
1810
+ static statusCode = 500;
1811
+ static description = `Failed to list execute runs: {message}`;
1644
1812
  }
1645
- class UnavailableError extends Error {
1813
+ class ExecutionErrorError extends Error {
1646
1814
  constructor(body) {
1647
1815
  super(
1648
- `UNAVAILABLE: ${body.message}`
1816
+ `EXECUTION_ERROR: ${body.message}`
1649
1817
  );
1650
1818
  this.body = body;
1651
- this.name = "UnavailableError";
1819
+ this.name = "ExecutionErrorError";
1652
1820
  }
1653
- static code = "UNAVAILABLE";
1654
- static statusCode = 503;
1655
- static description = `Cron service unavailable`;
1821
+ static code = "EXECUTION_ERROR";
1822
+ static statusCode = 500;
1823
+ static description = `Script execution error: {message}`;
1656
1824
  }
1657
- class ScheduleNotFoundError extends Error {
1825
+ class ConnectionFailedError extends Error {
1658
1826
  constructor(body) {
1659
1827
  super(
1660
- `SCHEDULE_NOT_FOUND: ${body.message}`
1828
+ `CONNECTION_FAILED: ${body.message}`
1661
1829
  );
1662
1830
  this.body = body;
1663
- this.name = "ScheduleNotFoundError";
1831
+ this.name = "ConnectionFailedError";
1664
1832
  }
1665
- static code = "SCHEDULE_NOT_FOUND";
1666
- static statusCode = 404;
1667
- static description = `Schedule not found`;
1833
+ static code = "CONNECTION_FAILED";
1834
+ static statusCode = 500;
1835
+ static description = `Failed to connect to execute server: {message}`;
1668
1836
  }
1669
- class ServiceUnavailableError extends Error {
1837
+ class MetadataWriteFailedError extends Error {
1670
1838
  constructor(body) {
1671
1839
  super(
1672
- `SERVICE_UNAVAILABLE: ${body.message}`
1840
+ `METADATA_WRITE_FAILED: ${body.message}`
1673
1841
  );
1674
1842
  this.body = body;
1675
- this.name = "ServiceUnavailableError";
1843
+ this.name = "MetadataWriteFailedError";
1676
1844
  }
1677
- static code = "SERVICE_UNAVAILABLE";
1678
- static statusCode = 503;
1679
- static description = `Cron service not configured`;
1845
+ static code = "METADATA_WRITE_FAILED";
1846
+ static statusCode = 500;
1847
+ static description = `Failed to write metadata file: {message}`;
1680
1848
  }
1681
- class PermissionAlreadyExistsError extends Error {
1849
+ class NodeModulesInstallFailedError extends Error {
1682
1850
  constructor(body) {
1683
1851
  super(
1684
- `PERMISSION_ALREADY_EXISTS: ${body.message}`
1852
+ `NODE_MODULES_INSTALL_FAILED: ${body.message}`
1685
1853
  );
1686
1854
  this.body = body;
1687
- this.name = "PermissionAlreadyExistsError";
1855
+ this.name = "NodeModulesInstallFailedError";
1688
1856
  }
1689
- static code = "PERMISSION_ALREADY_EXISTS";
1690
- static statusCode = 409;
1691
- static description = `Permission already exists`;
1857
+ static code = "NODE_MODULES_INSTALL_FAILED";
1858
+ static statusCode = 500;
1859
+ static description = `Failed to install node modules: {message}`;
1692
1860
  }
1693
- class ListTokensFailedError extends Error {
1861
+ class NodeModulesDownloadFailedError extends Error {
1694
1862
  constructor(body) {
1695
1863
  super(
1696
- `LIST_TOKENS_FAILED: ${body.message}`
1864
+ `NODE_MODULES_DOWNLOAD_FAILED: ${body.message}`
1697
1865
  );
1698
1866
  this.body = body;
1699
- this.name = "ListTokensFailedError";
1867
+ this.name = "NodeModulesDownloadFailedError";
1700
1868
  }
1701
- static code = "LIST_TOKENS_FAILED";
1869
+ static code = "NODE_MODULES_DOWNLOAD_FAILED";
1702
1870
  static statusCode = 500;
1703
- static description = `Failed to list tokens: {message}`;
1871
+ static description = `Failed to download node modules: {message}`;
1704
1872
  }
1705
- class RevokeTokenFailedError extends Error {
1873
+ class LockGenerationFailedError extends Error {
1706
1874
  constructor(body) {
1707
1875
  super(
1708
- `REVOKE_TOKEN_FAILED: ${body.message}`
1876
+ `LOCK_GENERATION_FAILED: ${body.message}`
1709
1877
  );
1710
1878
  this.body = body;
1711
- this.name = "RevokeTokenFailedError";
1879
+ this.name = "LockGenerationFailedError";
1712
1880
  }
1713
- static code = "REVOKE_TOKEN_FAILED";
1881
+ static code = "LOCK_GENERATION_FAILED";
1714
1882
  static statusCode = 500;
1715
- static description = `Failed to revoke token: {message}`;
1883
+ static description = `Failed to generate lock file: {message}`;
1716
1884
  }
1717
- class CreateTokenFailedError extends Error {
1885
+ class WriteScriptFailedError extends Error {
1718
1886
  constructor(body) {
1719
1887
  super(
1720
- `CREATE_TOKEN_FAILED: ${body.message}`
1888
+ `WRITE_SCRIPT_FAILED: ${body.message}`
1721
1889
  );
1722
1890
  this.body = body;
1723
- this.name = "CreateTokenFailedError";
1891
+ this.name = "WriteScriptFailedError";
1724
1892
  }
1725
- static code = "CREATE_TOKEN_FAILED";
1893
+ static code = "WRITE_SCRIPT_FAILED";
1726
1894
  static statusCode = 500;
1727
- static description = `Failed to create token: {message}`;
1895
+ static description = `Failed to write script file: {message}`;
1728
1896
  }
1729
- class ListPermissionsFailedError extends Error {
1897
+ class DirectoryCreationFailedError extends Error {
1730
1898
  constructor(body) {
1731
1899
  super(
1732
- `LIST_PERMISSIONS_FAILED: ${body.message}`
1900
+ `DIRECTORY_CREATION_FAILED: ${body.message}`
1733
1901
  );
1734
1902
  this.body = body;
1735
- this.name = "ListPermissionsFailedError";
1903
+ this.name = "DirectoryCreationFailedError";
1736
1904
  }
1737
- static code = "LIST_PERMISSIONS_FAILED";
1905
+ static code = "DIRECTORY_CREATION_FAILED";
1738
1906
  static statusCode = 500;
1739
- static description = `Failed to list permissions: {message}`;
1907
+ static description = `Failed to create script directory: {message}`;
1740
1908
  }
1741
- class GetPermissionFailedError extends Error {
1909
+ class NetworkPermissionsFailedError extends Error {
1742
1910
  constructor(body) {
1743
1911
  super(
1744
- `GET_PERMISSION_FAILED: ${body.message}`
1912
+ `NETWORK_PERMISSIONS_FAILED: ${body.message}`
1745
1913
  );
1746
1914
  this.body = body;
1747
- this.name = "GetPermissionFailedError";
1915
+ this.name = "NetworkPermissionsFailedError";
1748
1916
  }
1749
- static code = "GET_PERMISSION_FAILED";
1917
+ static code = "NETWORK_PERMISSIONS_FAILED";
1750
1918
  static statusCode = 500;
1751
- static description = `Failed to get permission: {message}`;
1919
+ static description = `Failed to insert network permissions: {message}`;
1752
1920
  }
1753
- class UpdatePermissionFailedError extends Error {
1921
+ class LoggingFailedError extends Error {
1754
1922
  constructor(body) {
1755
1923
  super(
1756
- `UPDATE_PERMISSION_FAILED: ${body.message}`
1924
+ `LOGGING_FAILED: ${body.message}`
1757
1925
  );
1758
1926
  this.body = body;
1759
- this.name = "UpdatePermissionFailedError";
1927
+ this.name = "LoggingFailedError";
1760
1928
  }
1761
- static code = "UPDATE_PERMISSION_FAILED";
1929
+ static code = "LOGGING_FAILED";
1762
1930
  static statusCode = 500;
1763
- static description = `Failed to update permission: {message}`;
1931
+ static description = `Failed to log execute run: {message}`;
1764
1932
  }
1765
- class RevokePermissionFailedError extends Error {
1933
+ class RunNotFoundError extends Error {
1766
1934
  constructor(body) {
1767
1935
  super(
1768
- `REVOKE_PERMISSION_FAILED: ${body.message}`
1936
+ `RUN_NOT_FOUND: ${body.message}`
1769
1937
  );
1770
1938
  this.body = body;
1771
- this.name = "RevokePermissionFailedError";
1939
+ this.name = "RunNotFoundError";
1772
1940
  }
1773
- static code = "REVOKE_PERMISSION_FAILED";
1774
- static statusCode = 500;
1775
- static description = `Failed to revoke permission: {message}`;
1941
+ static code = "RUN_NOT_FOUND";
1942
+ static statusCode = 404;
1943
+ static description = `Execute run not found: {run_id}`;
1776
1944
  }
1777
- class GrantPermissionFailedError extends Error {
1945
+ class LimitExceededError extends Error {
1778
1946
  constructor(body) {
1779
1947
  super(
1780
- `GRANT_PERMISSION_FAILED: ${body.message}`
1948
+ `LIMIT_EXCEEDED: ${body.message}`
1781
1949
  );
1782
1950
  this.body = body;
1783
- this.name = "GrantPermissionFailedError";
1951
+ this.name = "LimitExceededError";
1784
1952
  }
1785
- static code = "GRANT_PERMISSION_FAILED";
1786
- static statusCode = 500;
1787
- static description = `Failed to grant permission: {message}`;
1953
+ static code = "LIMIT_EXCEEDED";
1954
+ static statusCode = 403;
1955
+ static description = `Managed domains limit exceeded: your plan allows {limit} verified domains, you have {current}`;
1788
1956
  }
1789
- class ListIdentitiesFailedError extends Error {
1957
+ class FailedToProvisionCertificateError extends Error {
1790
1958
  constructor(body) {
1791
1959
  super(
1792
- `LIST_IDENTITIES_FAILED: ${body.message}`
1960
+ `FAILED_TO_PROVISION_CERTIFICATE: ${body.message}`
1793
1961
  );
1794
1962
  this.body = body;
1795
- this.name = "ListIdentitiesFailedError";
1963
+ this.name = "FailedToProvisionCertificateError";
1796
1964
  }
1797
- static code = "LIST_IDENTITIES_FAILED";
1798
- static statusCode = 500;
1799
- static description = `Failed to list identities: {message}`;
1965
+ static code = "FAILED_TO_PROVISION_CERTIFICATE";
1966
+ static statusCode = 422;
1967
+ static description = `Failed to provision certificate: {message}`;
1800
1968
  }
1801
- class DeleteIdentityFailedError extends Error {
1969
+ class FailedToInsertDomainMappingError extends Error {
1802
1970
  constructor(body) {
1803
1971
  super(
1804
- `DELETE_IDENTITY_FAILED: ${body.message}`
1972
+ `FAILED_TO_INSERT_DOMAIN_MAPPING: ${body.message}`
1805
1973
  );
1806
1974
  this.body = body;
1807
- this.name = "DeleteIdentityFailedError";
1975
+ this.name = "FailedToInsertDomainMappingError";
1808
1976
  }
1809
- static code = "DELETE_IDENTITY_FAILED";
1977
+ static code = "FAILED_TO_INSERT_DOMAIN_MAPPING";
1810
1978
  static statusCode = 500;
1811
- static description = `Failed to delete identity: {message}`;
1979
+ static description = `Failed to insert domain mapping: {message}`;
1812
1980
  }
1813
- class CreateIdentityFailedError extends Error {
1981
+ class PermissionDeniedError extends Error {
1814
1982
  constructor(body) {
1815
1983
  super(
1816
- `CREATE_IDENTITY_FAILED: ${body.message}`
1984
+ `PERMISSION_DENIED: ${body.message}`
1817
1985
  );
1818
1986
  this.body = body;
1819
- this.name = "CreateIdentityFailedError";
1987
+ this.name = "PermissionDeniedError";
1820
1988
  }
1821
- static code = "CREATE_IDENTITY_FAILED";
1822
- static statusCode = 500;
1823
- static description = `Failed to create identity: {message}`;
1989
+ static code = "PERMISSION_DENIED";
1990
+ static statusCode = 401;
1991
+ static description = `Permission denied: {message}`;
1824
1992
  }
1825
- class VmPermissionNotFoundError extends Error {
1993
+ class FailedToCheckPermissionsError extends Error {
1826
1994
  constructor(body) {
1827
1995
  super(
1828
- `VM_PERMISSION_NOT_FOUND: ${body.message}`
1996
+ `FAILED_TO_CHECK_PERMISSIONS: ${body.message}`
1829
1997
  );
1830
1998
  this.body = body;
1831
- this.name = "VmPermissionNotFoundError";
1999
+ this.name = "FailedToCheckPermissionsError";
1832
2000
  }
1833
- static code = "VM_PERMISSION_NOT_FOUND";
1834
- static statusCode = 404;
1835
- static description = `VM permission not found`;
2001
+ static code = "FAILED_TO_CHECK_PERMISSIONS";
2002
+ static statusCode = 502;
2003
+ static description = `Failed to check permissions: {message}`;
1836
2004
  }
1837
- class PermissionNotFoundError extends Error {
2005
+ class FailedToListDomainsError extends Error {
1838
2006
  constructor(body) {
1839
2007
  super(
1840
- `PERMISSION_NOT_FOUND: ${body.message}`
2008
+ `FAILED_TO_LIST_DOMAINS: ${body.message}`
1841
2009
  );
1842
2010
  this.body = body;
1843
- this.name = "PermissionNotFoundError";
2011
+ this.name = "FailedToListDomainsError";
1844
2012
  }
1845
- static code = "PERMISSION_NOT_FOUND";
1846
- static statusCode = 404;
1847
- static description = `Permission not found`;
2013
+ static code = "FAILED_TO_LIST_DOMAINS";
2014
+ static statusCode = 500;
2015
+ static description = `Failed to list domains: {message}`;
1848
2016
  }
1849
- class GitRepositoryAccessDeniedError extends Error {
2017
+ class FailedToListVerificationsError extends Error {
1850
2018
  constructor(body) {
1851
2019
  super(
1852
- `GIT_REPOSITORY_ACCESS_DENIED: ${body.message}`
2020
+ `FAILED_TO_LIST_VERIFICATIONS: ${body.message}`
1853
2021
  );
1854
2022
  this.body = body;
1855
- this.name = "GitRepositoryAccessDeniedError";
2023
+ this.name = "FailedToListVerificationsError";
1856
2024
  }
1857
- static code = "GIT_REPOSITORY_ACCESS_DENIED";
1858
- static statusCode = 403;
1859
- static description = `You are not allowed to access this repository`;
2025
+ static code = "FAILED_TO_LIST_VERIFICATIONS";
2026
+ static statusCode = 500;
2027
+ static description = `Failed to list verifications: {message}`;
1860
2028
  }
1861
- class GitRepositoryNotFoundError extends Error {
2029
+ class FailedToVerifyDomainError extends Error {
1862
2030
  constructor(body) {
1863
2031
  super(
1864
- `GIT_REPOSITORY_NOT_FOUND: ${body.message}`
2032
+ `FAILED_TO_VERIFY_DOMAIN: ${body.message}`
1865
2033
  );
1866
2034
  this.body = body;
1867
- this.name = "GitRepositoryNotFoundError";
2035
+ this.name = "FailedToVerifyDomainError";
1868
2036
  }
1869
- static code = "GIT_REPOSITORY_NOT_FOUND";
1870
- static statusCode = 404;
1871
- static description = `Repository not found`;
2037
+ static code = "FAILED_TO_VERIFY_DOMAIN";
2038
+ static statusCode = 500;
2039
+ static description = `Failed to verify domain: {message}`;
1872
2040
  }
1873
- class CannotDeleteManagedIdentityError extends Error {
2041
+ class VerificationFailedError extends Error {
1874
2042
  constructor(body) {
1875
2043
  super(
1876
- `CANNOT_DELETE_MANAGED_IDENTITY: ${body.message}`
2044
+ `VERIFICATION_FAILED: ${body.message}`
1877
2045
  );
1878
2046
  this.body = body;
1879
- this.name = "CannotDeleteManagedIdentityError";
2047
+ this.name = "VerificationFailedError";
1880
2048
  }
1881
- static code = "CANNOT_DELETE_MANAGED_IDENTITY";
1882
- static statusCode = 403;
1883
- static description = `Cannot delete managed identities`;
2049
+ static code = "VERIFICATION_FAILED";
2050
+ static statusCode = 400;
2051
+ static description = `Domain verification failed: {message}`;
1884
2052
  }
1885
- class CannotModifyManagedIdentityError extends Error {
2053
+ class FailedToDeleteVerificationError extends Error {
1886
2054
  constructor(body) {
1887
2055
  super(
1888
- `CANNOT_MODIFY_MANAGED_IDENTITY: ${body.message}`
2056
+ `FAILED_TO_DELETE_VERIFICATION: ${body.message}`
1889
2057
  );
1890
2058
  this.body = body;
1891
- this.name = "CannotModifyManagedIdentityError";
1892
- }
1893
- static code = "CANNOT_MODIFY_MANAGED_IDENTITY";
1894
- static statusCode = 403;
1895
- static description = `Cannot modify managed identities`;
2059
+ this.name = "FailedToDeleteVerificationError";
2060
+ }
2061
+ static code = "FAILED_TO_DELETE_VERIFICATION";
2062
+ static statusCode = 400;
2063
+ static description = `Failed to delete verification: {message}`;
1896
2064
  }
1897
- class IdentityAccessDeniedError extends Error {
2065
+ class VerificationNotFoundError extends Error {
1898
2066
  constructor(body) {
1899
2067
  super(
1900
- `IDENTITY_ACCESS_DENIED: ${body.message}`
2068
+ `VERIFICATION_NOT_FOUND: ${body.message}`
1901
2069
  );
1902
2070
  this.body = body;
1903
- this.name = "IdentityAccessDeniedError";
2071
+ this.name = "VerificationNotFoundError";
1904
2072
  }
1905
- static code = "IDENTITY_ACCESS_DENIED";
1906
- static statusCode = 403;
1907
- static description = `You are not allowed to access this identity`;
2073
+ static code = "VERIFICATION_NOT_FOUND";
2074
+ static statusCode = 404;
2075
+ static description = `Verification request not found for domain: {domain}`;
1908
2076
  }
1909
- class IdentityNotFoundError extends Error {
2077
+ class FailedToCreateVerificationCodeError extends Error {
1910
2078
  constructor(body) {
1911
2079
  super(
1912
- `IDENTITY_NOT_FOUND: ${body.message}`
2080
+ `FAILED_TO_CREATE_VERIFICATION_CODE: ${body.message}`
1913
2081
  );
1914
2082
  this.body = body;
1915
- this.name = "IdentityNotFoundError";
2083
+ this.name = "FailedToCreateVerificationCodeError";
1916
2084
  }
1917
- static code = "IDENTITY_NOT_FOUND";
1918
- static statusCode = 404;
1919
- static description = `Identity not found`;
2085
+ static code = "FAILED_TO_CREATE_VERIFICATION_CODE";
2086
+ static statusCode = 400;
2087
+ static description = `Failed to create verification code: {message}`;
1920
2088
  }
1921
- class UnauthorizedErrorError extends Error {
2089
+ class InvalidDomainError extends Error {
1922
2090
  constructor(body) {
1923
2091
  super(
1924
- `UNAUTHORIZED_ERROR: ${body.message}`
2092
+ `INVALID_DOMAIN: ${body.message}`
1925
2093
  );
1926
2094
  this.body = body;
1927
- this.name = "UnauthorizedErrorError";
2095
+ this.name = "InvalidDomainError";
1928
2096
  }
1929
- static code = "UNAUTHORIZED_ERROR";
1930
- static statusCode = 401;
1931
- static description = `Unauthorized request to {route}`;
2097
+ static code = "INVALID_DOMAIN";
2098
+ static statusCode = 400;
2099
+ static description = `Invalid domain: {domain}`;
1932
2100
  }
1933
2101
  class BuildFailedError extends Error {
1934
2102
  constructor(body) {
@@ -2062,6 +2230,18 @@ class WebDeploymentBadRequestError extends Error {
2062
2230
  static statusCode = 400;
2063
2231
  static description = `Bad request: {message}`;
2064
2232
  }
2233
+ class TimeoutLimitExceededError extends Error {
2234
+ constructor(body) {
2235
+ super(
2236
+ `TIMEOUT_LIMIT_EXCEEDED: ${body.message}`
2237
+ );
2238
+ this.body = body;
2239
+ this.name = "TimeoutLimitExceededError";
2240
+ }
2241
+ static code = "TIMEOUT_LIMIT_EXCEEDED";
2242
+ static statusCode = 403;
2243
+ static description = `Timeout exceeds plan limit: requested {requested_ms}ms but your plan allows a maximum of {max_ms}ms`;
2244
+ }
2065
2245
  class DeploymentLimitExceededError extends Error {
2066
2246
  constructor(body) {
2067
2247
  super(
@@ -2110,41 +2290,41 @@ class InternalResizeVmNotFoundError extends Error {
2110
2290
  static statusCode = 404;
2111
2291
  static description = `VM not found`;
2112
2292
  }
2113
- class BranchNameEmptyError extends Error {
2293
+ class AccessDeniedError extends Error {
2114
2294
  constructor(body) {
2115
2295
  super(
2116
- `BRANCH_NAME_EMPTY: ${body.message}`
2296
+ `ACCESS_DENIED: ${body.message}`
2117
2297
  );
2118
2298
  this.body = body;
2119
- this.name = "BranchNameEmptyError";
2299
+ this.name = "AccessDeniedError";
2120
2300
  }
2121
- static code = "BRANCH_NAME_EMPTY";
2122
- static statusCode = 400;
2123
- static description = `Branch name cannot be empty`;
2301
+ static code = "ACCESS_DENIED";
2302
+ static statusCode = 403;
2303
+ static description = `VM access denied`;
2124
2304
  }
2125
- class ExecuteLimitExceededError extends Error {
2305
+ class BranchNameEmptyError extends Error {
2126
2306
  constructor(body) {
2127
2307
  super(
2128
- `EXECUTE_LIMIT_EXCEEDED: ${body.message}`
2308
+ `BRANCH_NAME_EMPTY: ${body.message}`
2129
2309
  );
2130
2310
  this.body = body;
2131
- this.name = "ExecuteLimitExceededError";
2311
+ this.name = "BranchNameEmptyError";
2132
2312
  }
2133
- static code = "EXECUTE_LIMIT_EXCEEDED";
2134
- static statusCode = 403;
2135
- static description = `Execute runs limit exceeded: your plan allows {limit} runs per month, you have used {current}`;
2313
+ static code = "BRANCH_NAME_EMPTY";
2314
+ static statusCode = 400;
2315
+ static description = `Branch name cannot be empty`;
2136
2316
  }
2137
- class VmLimitExceededError extends Error {
2317
+ class UnauthorizedErrorError extends Error {
2138
2318
  constructor(body) {
2139
2319
  super(
2140
- `VM_LIMIT_EXCEEDED: ${body.message}`
2320
+ `UNAUTHORIZED_ERROR: ${body.message}`
2141
2321
  );
2142
2322
  this.body = body;
2143
- this.name = "VmLimitExceededError";
2323
+ this.name = "UnauthorizedErrorError";
2144
2324
  }
2145
- static code = "VM_LIMIT_EXCEEDED";
2146
- static statusCode = 403;
2147
- static description = `VM limit exceeded: your plan allows {limit} VMs, you currently have {current}`;
2325
+ static code = "UNAUTHORIZED_ERROR";
2326
+ static statusCode = 401;
2327
+ static description = `Unauthorized request to {route}`;
2148
2328
  }
2149
2329
  class TriggerErrorError extends Error {
2150
2330
  constructor(body) {
@@ -2476,191 +2656,23 @@ class FailedPermissionsCheckError extends Error {
2476
2656
  `FAILED_PERMISSIONS_CHECK: ${body.message}`
2477
2657
  );
2478
2658
  this.body = body;
2479
- this.name = "FailedPermissionsCheckError";
2480
- }
2481
- static code = "FAILED_PERMISSIONS_CHECK";
2482
- static statusCode = 401;
2483
- static description = `You do not have permission to delete the domain mapping for: {domain}`;
2484
- }
2485
- class FailedToCheckDomainMappingPermissionsError extends Error {
2486
- constructor(body) {
2487
- super(
2488
- `FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS: ${body.message}`
2489
- );
2490
- this.body = body;
2491
- this.name = "FailedToCheckDomainMappingPermissionsError";
2492
- }
2493
- static code = "FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS";
2494
- static statusCode = 502;
2495
- static description = `Failed to check permissions: {message}`;
2496
- }
2497
- class DomainOwnershipVerificationFailedError extends Error {
2498
- constructor(body) {
2499
- super(
2500
- `DOMAIN_OWNERSHIP_VERIFICATION_FAILED: ${body.message}`
2501
- );
2502
- this.body = body;
2503
- this.name = "DomainOwnershipVerificationFailedError";
2504
- }
2505
- static code = "DOMAIN_OWNERSHIP_VERIFICATION_FAILED";
2506
- static statusCode = 403;
2507
- static description = `Domain ownership verification failed`;
2508
- }
2509
- class ErrorDeletingRecordError extends Error {
2510
- constructor(body) {
2511
- super(
2512
- `ERROR_DELETING_RECORD: ${body.message}`
2513
- );
2514
- this.body = body;
2515
- this.name = "ErrorDeletingRecordError";
2516
- }
2517
- static code = "ERROR_DELETING_RECORD";
2518
- static statusCode = 500;
2519
- static description = `Error deleting DNS record for {domain}/{name}: {message}`;
2520
- }
2521
- class RecordOwnershipErrorError extends Error {
2522
- constructor(body) {
2523
- super(
2524
- `RECORD_OWNERSHIP_ERROR: ${body.message}`
2525
- );
2526
- this.body = body;
2527
- this.name = "RecordOwnershipErrorError";
2528
- }
2529
- static code = "RECORD_OWNERSHIP_ERROR";
2530
- static statusCode = 403;
2531
- static description = `Account {account_id} does not own record {record_id}`;
2532
- }
2533
- class ErrorCreatingRecordError extends Error {
2534
- constructor(body) {
2535
- super(
2536
- `ERROR_CREATING_RECORD: ${body.message}`
2537
- );
2538
- this.body = body;
2539
- this.name = "ErrorCreatingRecordError";
2540
- }
2541
- static code = "ERROR_CREATING_RECORD";
2542
- static statusCode = 500;
2543
- static description = `Error creating DNS record: {message}`;
2544
- }
2545
- class DomainOwnershipErrorError extends Error {
2546
- constructor(body) {
2547
- super(
2548
- `DOMAIN_OWNERSHIP_ERROR: ${body.message}`
2549
- );
2550
- this.body = body;
2551
- this.name = "DomainOwnershipErrorError";
2552
- }
2553
- static code = "DOMAIN_OWNERSHIP_ERROR";
2554
- static statusCode = 403;
2555
- static description = `Account {account_id} does not own domain {domain}`;
2556
- }
2557
- class CloudstateInternalErrorError extends Error {
2558
- constructor(body) {
2559
- super(
2560
- `CLOUDSTATE_INTERNAL_ERROR: ${body.message}`
2561
- );
2562
- this.body = body;
2563
- this.name = "CloudstateInternalErrorError";
2564
- }
2565
- static code = "CLOUDSTATE_INTERNAL_ERROR";
2566
- static statusCode = 500;
2567
- static description = `Internal error: {message}`;
2568
- }
2569
- class CloudstateDatabaseErrorError extends Error {
2570
- constructor(body) {
2571
- super(
2572
- `CLOUDSTATE_DATABASE_ERROR: ${body.message}`
2573
- );
2574
- this.body = body;
2575
- this.name = "CloudstateDatabaseErrorError";
2576
- }
2577
- static code = "CLOUDSTATE_DATABASE_ERROR";
2578
- static statusCode = 500;
2579
- static description = `Database operation failed: {message}`;
2580
- }
2581
- class CloudstateAccessDeniedError extends Error {
2582
- constructor(body) {
2583
- super(
2584
- `CLOUDSTATE_ACCESS_DENIED: ${body.message}`
2585
- );
2586
- this.body = body;
2587
- this.name = "CloudstateAccessDeniedError";
2588
- }
2589
- static code = "CLOUDSTATE_ACCESS_DENIED";
2590
- static statusCode = 403;
2591
- static description = `Access denied to project: {project_id}`;
2592
- }
2593
- class RestoreFailedError extends Error {
2594
- constructor(body) {
2595
- super(
2596
- `RESTORE_FAILED: ${body.message}`
2597
- );
2598
- this.body = body;
2599
- this.name = "RestoreFailedError";
2600
- }
2601
- static code = "RESTORE_FAILED";
2602
- static statusCode = 500;
2603
- static description = `Failed to restore from backup: {message}`;
2604
- }
2605
- class CreateBackupFailedError extends Error {
2606
- constructor(body) {
2607
- super(
2608
- `CREATE_BACKUP_FAILED: ${body.message}`
2609
- );
2610
- this.body = body;
2611
- this.name = "CreateBackupFailedError";
2612
- }
2613
- static code = "CREATE_BACKUP_FAILED";
2614
- static statusCode = 500;
2615
- static description = `Failed to create backup: {message}`;
2616
- }
2617
- class BackupFailedError extends Error {
2618
- constructor(body) {
2619
- super(
2620
- `BACKUP_FAILED: ${body.message}`
2621
- );
2622
- this.body = body;
2623
- this.name = "BackupFailedError";
2624
- }
2625
- static code = "BACKUP_FAILED";
2626
- static statusCode = 500;
2627
- static description = `Backup failed: {message}`;
2628
- }
2629
- class DeploymentFailedError extends Error {
2630
- constructor(body) {
2631
- super(
2632
- `DEPLOYMENT_FAILED: ${body.message}`
2633
- );
2634
- this.body = body;
2635
- this.name = "DeploymentFailedError";
2636
- }
2637
- static code = "DEPLOYMENT_FAILED";
2638
- static statusCode = 500;
2639
- static description = `Deployment failed: {message}`;
2640
- }
2641
- class InvalidDeploymentRequestError extends Error {
2642
- constructor(body) {
2643
- super(
2644
- `INVALID_DEPLOYMENT_REQUEST: ${body.message}`
2645
- );
2646
- this.body = body;
2647
- this.name = "InvalidDeploymentRequestError";
2648
- }
2649
- static code = "INVALID_DEPLOYMENT_REQUEST";
2650
- static statusCode = 400;
2651
- static description = `Invalid deployment request: {message}`;
2659
+ this.name = "FailedPermissionsCheckError";
2660
+ }
2661
+ static code = "FAILED_PERMISSIONS_CHECK";
2662
+ static statusCode = 401;
2663
+ static description = `You do not have permission to delete the domain mapping for: {domain}`;
2652
2664
  }
2653
- class ProjectNotFoundError extends Error {
2665
+ class FailedToCheckDomainMappingPermissionsError extends Error {
2654
2666
  constructor(body) {
2655
2667
  super(
2656
- `PROJECT_NOT_FOUND: ${body.message}`
2668
+ `FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS: ${body.message}`
2657
2669
  );
2658
2670
  this.body = body;
2659
- this.name = "ProjectNotFoundError";
2671
+ this.name = "FailedToCheckDomainMappingPermissionsError";
2660
2672
  }
2661
- static code = "PROJECT_NOT_FOUND";
2662
- static statusCode = 404;
2663
- static description = `Project not found: {project_id}`;
2673
+ static code = "FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS";
2674
+ static statusCode = 502;
2675
+ static description = `Failed to check permissions: {message}`;
2664
2676
  }
2665
2677
  class GitRepoLimitExceededError extends Error {
2666
2678
  constructor(body) {
@@ -2686,413 +2698,449 @@ class EmptyTagError extends Error {
2686
2698
  static statusCode = 400;
2687
2699
  static description = `Invalid request: tag cannot be empty`;
2688
2700
  }
2689
- class LimitExceededError extends Error {
2701
+ class PersistentVmsNotAllowedError extends Error {
2690
2702
  constructor(body) {
2691
2703
  super(
2692
- `LIMIT_EXCEEDED: ${body.message}`
2704
+ `PERSISTENT_VMS_NOT_ALLOWED: ${body.message}`
2693
2705
  );
2694
2706
  this.body = body;
2695
- this.name = "LimitExceededError";
2707
+ this.name = "PersistentVmsNotAllowedError";
2696
2708
  }
2697
- static code = "LIMIT_EXCEEDED";
2709
+ static code = "PERSISTENT_VMS_NOT_ALLOWED";
2698
2710
  static statusCode = 403;
2699
- static description = `Managed domains limit exceeded: your plan allows {limit} verified domains, you have {current}`;
2711
+ static description = `Your plan does not allow persistent VMs. Use sticky or ephemeral persistence instead, or upgrade your plan.`;
2700
2712
  }
2701
- class FailedToProvisionCertificateError extends Error {
2713
+ class TotalVmLimitExceededError extends Error {
2702
2714
  constructor(body) {
2703
2715
  super(
2704
- `FAILED_TO_PROVISION_CERTIFICATE: ${body.message}`
2716
+ `TOTAL_VM_LIMIT_EXCEEDED: ${body.message}`
2705
2717
  );
2706
2718
  this.body = body;
2707
- this.name = "FailedToProvisionCertificateError";
2719
+ this.name = "TotalVmLimitExceededError";
2708
2720
  }
2709
- static code = "FAILED_TO_PROVISION_CERTIFICATE";
2710
- static statusCode = 422;
2711
- static description = `Failed to provision certificate: {message}`;
2721
+ static code = "TOTAL_VM_LIMIT_EXCEEDED";
2722
+ static statusCode = 403;
2723
+ static description = `Total VM limit exceeded: your plan allows {limit} total VMs, you currently have {current}`;
2712
2724
  }
2713
- class FailedToInsertDomainMappingError extends Error {
2725
+ class VmLimitExceededError extends Error {
2714
2726
  constructor(body) {
2715
2727
  super(
2716
- `FAILED_TO_INSERT_DOMAIN_MAPPING: ${body.message}`
2728
+ `VM_LIMIT_EXCEEDED: ${body.message}`
2717
2729
  );
2718
2730
  this.body = body;
2719
- this.name = "FailedToInsertDomainMappingError";
2731
+ this.name = "VmLimitExceededError";
2720
2732
  }
2721
- static code = "FAILED_TO_INSERT_DOMAIN_MAPPING";
2722
- static statusCode = 500;
2723
- static description = `Failed to insert domain mapping: {message}`;
2733
+ static code = "VM_LIMIT_EXCEEDED";
2734
+ static statusCode = 403;
2735
+ static description = `VM limit exceeded: your plan allows {limit} VMs, you currently have {current}`;
2724
2736
  }
2725
- class PermissionDeniedError extends Error {
2737
+ class PermissionAlreadyExistsError extends Error {
2726
2738
  constructor(body) {
2727
2739
  super(
2728
- `PERMISSION_DENIED: ${body.message}`
2740
+ `PERMISSION_ALREADY_EXISTS: ${body.message}`
2729
2741
  );
2730
2742
  this.body = body;
2731
- this.name = "PermissionDeniedError";
2743
+ this.name = "PermissionAlreadyExistsError";
2732
2744
  }
2733
- static code = "PERMISSION_DENIED";
2734
- static statusCode = 401;
2735
- static description = `Permission denied: {message}`;
2745
+ static code = "PERMISSION_ALREADY_EXISTS";
2746
+ static statusCode = 409;
2747
+ static description = `Permission already exists`;
2736
2748
  }
2737
- class FailedToCheckPermissionsError extends Error {
2749
+ class ListTokensFailedError extends Error {
2738
2750
  constructor(body) {
2739
2751
  super(
2740
- `FAILED_TO_CHECK_PERMISSIONS: ${body.message}`
2752
+ `LIST_TOKENS_FAILED: ${body.message}`
2741
2753
  );
2742
2754
  this.body = body;
2743
- this.name = "FailedToCheckPermissionsError";
2755
+ this.name = "ListTokensFailedError";
2744
2756
  }
2745
- static code = "FAILED_TO_CHECK_PERMISSIONS";
2746
- static statusCode = 502;
2747
- static description = `Failed to check permissions: {message}`;
2757
+ static code = "LIST_TOKENS_FAILED";
2758
+ static statusCode = 500;
2759
+ static description = `Failed to list tokens: {message}`;
2748
2760
  }
2749
- class FailedToListDomainsError extends Error {
2761
+ class RevokeTokenFailedError extends Error {
2750
2762
  constructor(body) {
2751
2763
  super(
2752
- `FAILED_TO_LIST_DOMAINS: ${body.message}`
2764
+ `REVOKE_TOKEN_FAILED: ${body.message}`
2753
2765
  );
2754
2766
  this.body = body;
2755
- this.name = "FailedToListDomainsError";
2767
+ this.name = "RevokeTokenFailedError";
2756
2768
  }
2757
- static code = "FAILED_TO_LIST_DOMAINS";
2769
+ static code = "REVOKE_TOKEN_FAILED";
2758
2770
  static statusCode = 500;
2759
- static description = `Failed to list domains: {message}`;
2771
+ static description = `Failed to revoke token: {message}`;
2760
2772
  }
2761
- class FailedToListVerificationsError extends Error {
2773
+ class CreateTokenFailedError extends Error {
2762
2774
  constructor(body) {
2763
2775
  super(
2764
- `FAILED_TO_LIST_VERIFICATIONS: ${body.message}`
2776
+ `CREATE_TOKEN_FAILED: ${body.message}`
2765
2777
  );
2766
2778
  this.body = body;
2767
- this.name = "FailedToListVerificationsError";
2779
+ this.name = "CreateTokenFailedError";
2768
2780
  }
2769
- static code = "FAILED_TO_LIST_VERIFICATIONS";
2781
+ static code = "CREATE_TOKEN_FAILED";
2770
2782
  static statusCode = 500;
2771
- static description = `Failed to list verifications: {message}`;
2783
+ static description = `Failed to create token: {message}`;
2772
2784
  }
2773
- class FailedToVerifyDomainError extends Error {
2785
+ class ListPermissionsFailedError extends Error {
2774
2786
  constructor(body) {
2775
2787
  super(
2776
- `FAILED_TO_VERIFY_DOMAIN: ${body.message}`
2788
+ `LIST_PERMISSIONS_FAILED: ${body.message}`
2777
2789
  );
2778
2790
  this.body = body;
2779
- this.name = "FailedToVerifyDomainError";
2791
+ this.name = "ListPermissionsFailedError";
2780
2792
  }
2781
- static code = "FAILED_TO_VERIFY_DOMAIN";
2793
+ static code = "LIST_PERMISSIONS_FAILED";
2782
2794
  static statusCode = 500;
2783
- static description = `Failed to verify domain: {message}`;
2795
+ static description = `Failed to list permissions: {message}`;
2784
2796
  }
2785
- class VerificationFailedError extends Error {
2797
+ class GetPermissionFailedError extends Error {
2786
2798
  constructor(body) {
2787
2799
  super(
2788
- `VERIFICATION_FAILED: ${body.message}`
2800
+ `GET_PERMISSION_FAILED: ${body.message}`
2789
2801
  );
2790
2802
  this.body = body;
2791
- this.name = "VerificationFailedError";
2803
+ this.name = "GetPermissionFailedError";
2792
2804
  }
2793
- static code = "VERIFICATION_FAILED";
2794
- static statusCode = 400;
2795
- static description = `Domain verification failed: {message}`;
2805
+ static code = "GET_PERMISSION_FAILED";
2806
+ static statusCode = 500;
2807
+ static description = `Failed to get permission: {message}`;
2796
2808
  }
2797
- class FailedToDeleteVerificationError extends Error {
2809
+ class UpdatePermissionFailedError extends Error {
2798
2810
  constructor(body) {
2799
2811
  super(
2800
- `FAILED_TO_DELETE_VERIFICATION: ${body.message}`
2812
+ `UPDATE_PERMISSION_FAILED: ${body.message}`
2801
2813
  );
2802
2814
  this.body = body;
2803
- this.name = "FailedToDeleteVerificationError";
2815
+ this.name = "UpdatePermissionFailedError";
2804
2816
  }
2805
- static code = "FAILED_TO_DELETE_VERIFICATION";
2806
- static statusCode = 400;
2807
- static description = `Failed to delete verification: {message}`;
2817
+ static code = "UPDATE_PERMISSION_FAILED";
2818
+ static statusCode = 500;
2819
+ static description = `Failed to update permission: {message}`;
2808
2820
  }
2809
- class VerificationNotFoundError extends Error {
2821
+ class RevokePermissionFailedError extends Error {
2810
2822
  constructor(body) {
2811
2823
  super(
2812
- `VERIFICATION_NOT_FOUND: ${body.message}`
2824
+ `REVOKE_PERMISSION_FAILED: ${body.message}`
2813
2825
  );
2814
2826
  this.body = body;
2815
- this.name = "VerificationNotFoundError";
2827
+ this.name = "RevokePermissionFailedError";
2816
2828
  }
2817
- static code = "VERIFICATION_NOT_FOUND";
2818
- static statusCode = 404;
2819
- static description = `Verification request not found for domain: {domain}`;
2829
+ static code = "REVOKE_PERMISSION_FAILED";
2830
+ static statusCode = 500;
2831
+ static description = `Failed to revoke permission: {message}`;
2820
2832
  }
2821
- class FailedToCreateVerificationCodeError extends Error {
2833
+ class GrantPermissionFailedError extends Error {
2822
2834
  constructor(body) {
2823
2835
  super(
2824
- `FAILED_TO_CREATE_VERIFICATION_CODE: ${body.message}`
2836
+ `GRANT_PERMISSION_FAILED: ${body.message}`
2825
2837
  );
2826
2838
  this.body = body;
2827
- this.name = "FailedToCreateVerificationCodeError";
2839
+ this.name = "GrantPermissionFailedError";
2828
2840
  }
2829
- static code = "FAILED_TO_CREATE_VERIFICATION_CODE";
2830
- static statusCode = 400;
2831
- static description = `Failed to create verification code: {message}`;
2841
+ static code = "GRANT_PERMISSION_FAILED";
2842
+ static statusCode = 500;
2843
+ static description = `Failed to grant permission: {message}`;
2832
2844
  }
2833
- class InvalidDomainError extends Error {
2845
+ class ListIdentitiesFailedError extends Error {
2834
2846
  constructor(body) {
2835
2847
  super(
2836
- `INVALID_DOMAIN: ${body.message}`
2848
+ `LIST_IDENTITIES_FAILED: ${body.message}`
2837
2849
  );
2838
2850
  this.body = body;
2839
- this.name = "InvalidDomainError";
2851
+ this.name = "ListIdentitiesFailedError";
2840
2852
  }
2841
- static code = "INVALID_DOMAIN";
2842
- static statusCode = 400;
2843
- static description = `Invalid domain: {domain}`;
2853
+ static code = "LIST_IDENTITIES_FAILED";
2854
+ static statusCode = 500;
2855
+ static description = `Failed to list identities: {message}`;
2844
2856
  }
2845
- class AccessDeniedError extends Error {
2857
+ class DeleteIdentityFailedError extends Error {
2846
2858
  constructor(body) {
2847
2859
  super(
2848
- `ACCESS_DENIED: ${body.message}`
2860
+ `DELETE_IDENTITY_FAILED: ${body.message}`
2849
2861
  );
2850
2862
  this.body = body;
2851
- this.name = "AccessDeniedError";
2863
+ this.name = "DeleteIdentityFailedError";
2852
2864
  }
2853
- static code = "ACCESS_DENIED";
2854
- static statusCode = 403;
2855
- static description = `VM access denied`;
2865
+ static code = "DELETE_IDENTITY_FAILED";
2866
+ static statusCode = 500;
2867
+ static description = `Failed to delete identity: {message}`;
2856
2868
  }
2857
- class ObservabilityDatabaseErrorError extends Error {
2869
+ class CreateIdentityFailedError extends Error {
2858
2870
  constructor(body) {
2859
2871
  super(
2860
- `OBSERVABILITY_DATABASE_ERROR: ${body.message}`
2872
+ `CREATE_IDENTITY_FAILED: ${body.message}`
2861
2873
  );
2862
2874
  this.body = body;
2863
- this.name = "ObservabilityDatabaseErrorError";
2875
+ this.name = "CreateIdentityFailedError";
2864
2876
  }
2865
- static code = "OBSERVABILITY_DATABASE_ERROR";
2877
+ static code = "CREATE_IDENTITY_FAILED";
2866
2878
  static statusCode = 500;
2867
- static description = `Database operation failed: {message}`;
2879
+ static description = `Failed to create identity: {message}`;
2868
2880
  }
2869
- class ObservabilityAccessDeniedError extends Error {
2881
+ class VmPermissionNotFoundError extends Error {
2870
2882
  constructor(body) {
2871
2883
  super(
2872
- `OBSERVABILITY_ACCESS_DENIED: ${body.message}`
2884
+ `VM_PERMISSION_NOT_FOUND: ${body.message}`
2873
2885
  );
2874
2886
  this.body = body;
2875
- this.name = "ObservabilityAccessDeniedError";
2887
+ this.name = "VmPermissionNotFoundError";
2876
2888
  }
2877
- static code = "OBSERVABILITY_ACCESS_DENIED";
2889
+ static code = "VM_PERMISSION_NOT_FOUND";
2890
+ static statusCode = 404;
2891
+ static description = `VM permission not found`;
2892
+ }
2893
+ class PermissionNotFoundError extends Error {
2894
+ constructor(body) {
2895
+ super(
2896
+ `PERMISSION_NOT_FOUND: ${body.message}`
2897
+ );
2898
+ this.body = body;
2899
+ this.name = "PermissionNotFoundError";
2900
+ }
2901
+ static code = "PERMISSION_NOT_FOUND";
2902
+ static statusCode = 404;
2903
+ static description = `Permission not found`;
2904
+ }
2905
+ class GitRepositoryAccessDeniedError extends Error {
2906
+ constructor(body) {
2907
+ super(
2908
+ `GIT_REPOSITORY_ACCESS_DENIED: ${body.message}`
2909
+ );
2910
+ this.body = body;
2911
+ this.name = "GitRepositoryAccessDeniedError";
2912
+ }
2913
+ static code = "GIT_REPOSITORY_ACCESS_DENIED";
2878
2914
  static statusCode = 403;
2879
- static description = `Access denied to logs for deployment: {deployment_id}`;
2915
+ static description = `You are not allowed to access this repository`;
2880
2916
  }
2881
- class ParseLogsFailedError extends Error {
2917
+ class GitRepositoryNotFoundError extends Error {
2882
2918
  constructor(body) {
2883
2919
  super(
2884
- `PARSE_LOGS_FAILED: ${body.message}`
2920
+ `GIT_REPOSITORY_NOT_FOUND: ${body.message}`
2885
2921
  );
2886
2922
  this.body = body;
2887
- this.name = "ParseLogsFailedError";
2923
+ this.name = "GitRepositoryNotFoundError";
2888
2924
  }
2889
- static code = "PARSE_LOGS_FAILED";
2890
- static statusCode = 500;
2891
- static description = `Failed to parse logs: {message}`;
2925
+ static code = "GIT_REPOSITORY_NOT_FOUND";
2926
+ static statusCode = 404;
2927
+ static description = `Repository not found`;
2892
2928
  }
2893
- class RetrieveLogsFailedError extends Error {
2929
+ class CannotDeleteManagedIdentityError extends Error {
2894
2930
  constructor(body) {
2895
2931
  super(
2896
- `RETRIEVE_LOGS_FAILED: ${body.message}`
2932
+ `CANNOT_DELETE_MANAGED_IDENTITY: ${body.message}`
2897
2933
  );
2898
2934
  this.body = body;
2899
- this.name = "RetrieveLogsFailedError";
2935
+ this.name = "CannotDeleteManagedIdentityError";
2900
2936
  }
2901
- static code = "RETRIEVE_LOGS_FAILED";
2902
- static statusCode = 500;
2903
- static description = `Failed to retrieve logs: {message}`;
2937
+ static code = "CANNOT_DELETE_MANAGED_IDENTITY";
2938
+ static statusCode = 403;
2939
+ static description = `Cannot delete managed identities`;
2904
2940
  }
2905
- class InvalidQueryError extends Error {
2941
+ class CannotModifyManagedIdentityError extends Error {
2906
2942
  constructor(body) {
2907
2943
  super(
2908
- `INVALID_QUERY: ${body.message}`
2944
+ `CANNOT_MODIFY_MANAGED_IDENTITY: ${body.message}`
2909
2945
  );
2910
2946
  this.body = body;
2911
- this.name = "InvalidQueryError";
2947
+ this.name = "CannotModifyManagedIdentityError";
2912
2948
  }
2913
- static code = "INVALID_QUERY";
2914
- static statusCode = 400;
2915
- static description = `Invalid log query: {message}`;
2949
+ static code = "CANNOT_MODIFY_MANAGED_IDENTITY";
2950
+ static statusCode = 403;
2951
+ static description = `Cannot modify managed identities`;
2952
+ }
2953
+ class IdentityAccessDeniedError extends Error {
2954
+ constructor(body) {
2955
+ super(
2956
+ `IDENTITY_ACCESS_DENIED: ${body.message}`
2957
+ );
2958
+ this.body = body;
2959
+ this.name = "IdentityAccessDeniedError";
2960
+ }
2961
+ static code = "IDENTITY_ACCESS_DENIED";
2962
+ static statusCode = 403;
2963
+ static description = `You are not allowed to access this identity`;
2916
2964
  }
2917
- class LogsNotFoundError extends Error {
2965
+ class IdentityNotFoundError extends Error {
2918
2966
  constructor(body) {
2919
2967
  super(
2920
- `LOGS_NOT_FOUND: ${body.message}`
2968
+ `IDENTITY_NOT_FOUND: ${body.message}`
2921
2969
  );
2922
2970
  this.body = body;
2923
- this.name = "LogsNotFoundError";
2971
+ this.name = "IdentityNotFoundError";
2924
2972
  }
2925
- static code = "LOGS_NOT_FOUND";
2973
+ static code = "IDENTITY_NOT_FOUND";
2926
2974
  static statusCode = 404;
2927
- static description = `Logs not found for deployment: {deployment_id}`;
2975
+ static description = `Identity not found`;
2928
2976
  }
2929
- class ExecuteInternalErrorError extends Error {
2977
+ class DomainOwnershipVerificationFailedError extends Error {
2930
2978
  constructor(body) {
2931
2979
  super(
2932
- `EXECUTE_INTERNAL_ERROR: ${body.message}`
2980
+ `DOMAIN_OWNERSHIP_VERIFICATION_FAILED: ${body.message}`
2933
2981
  );
2934
2982
  this.body = body;
2935
- this.name = "ExecuteInternalErrorError";
2983
+ this.name = "DomainOwnershipVerificationFailedError";
2936
2984
  }
2937
- static code = "EXECUTE_INTERNAL_ERROR";
2938
- static statusCode = 500;
2939
- static description = `Internal error: {message}`;
2985
+ static code = "DOMAIN_OWNERSHIP_VERIFICATION_FAILED";
2986
+ static statusCode = 403;
2987
+ static description = `Domain ownership verification failed`;
2940
2988
  }
2941
- class ExecuteAccessDeniedError extends Error {
2989
+ class ErrorDeletingRecordError extends Error {
2942
2990
  constructor(body) {
2943
2991
  super(
2944
- `EXECUTE_ACCESS_DENIED: ${body.message}`
2992
+ `ERROR_DELETING_RECORD: ${body.message}`
2945
2993
  );
2946
2994
  this.body = body;
2947
- this.name = "ExecuteAccessDeniedError";
2995
+ this.name = "ErrorDeletingRecordError";
2948
2996
  }
2949
- static code = "EXECUTE_ACCESS_DENIED";
2950
- static statusCode = 403;
2951
- static description = `Access denied to execute run`;
2997
+ static code = "ERROR_DELETING_RECORD";
2998
+ static statusCode = 500;
2999
+ static description = `Error deleting DNS record for {domain}/{name}: {message}`;
2952
3000
  }
2953
- class ListRunsFailedError extends Error {
3001
+ class RecordOwnershipErrorError extends Error {
2954
3002
  constructor(body) {
2955
3003
  super(
2956
- `LIST_RUNS_FAILED: ${body.message}`
3004
+ `RECORD_OWNERSHIP_ERROR: ${body.message}`
2957
3005
  );
2958
3006
  this.body = body;
2959
- this.name = "ListRunsFailedError";
3007
+ this.name = "RecordOwnershipErrorError";
2960
3008
  }
2961
- static code = "LIST_RUNS_FAILED";
2962
- static statusCode = 500;
2963
- static description = `Failed to list execute runs: {message}`;
3009
+ static code = "RECORD_OWNERSHIP_ERROR";
3010
+ static statusCode = 403;
3011
+ static description = `Account {account_id} does not own record {record_id}`;
2964
3012
  }
2965
- class ExecutionErrorError extends Error {
3013
+ class ErrorCreatingRecordError extends Error {
2966
3014
  constructor(body) {
2967
3015
  super(
2968
- `EXECUTION_ERROR: ${body.message}`
3016
+ `ERROR_CREATING_RECORD: ${body.message}`
2969
3017
  );
2970
3018
  this.body = body;
2971
- this.name = "ExecutionErrorError";
3019
+ this.name = "ErrorCreatingRecordError";
2972
3020
  }
2973
- static code = "EXECUTION_ERROR";
3021
+ static code = "ERROR_CREATING_RECORD";
2974
3022
  static statusCode = 500;
2975
- static description = `Script execution error: {message}`;
3023
+ static description = `Error creating DNS record: {message}`;
2976
3024
  }
2977
- class ConnectionFailedError extends Error {
3025
+ class DomainOwnershipErrorError extends Error {
2978
3026
  constructor(body) {
2979
3027
  super(
2980
- `CONNECTION_FAILED: ${body.message}`
3028
+ `DOMAIN_OWNERSHIP_ERROR: ${body.message}`
2981
3029
  );
2982
3030
  this.body = body;
2983
- this.name = "ConnectionFailedError";
3031
+ this.name = "DomainOwnershipErrorError";
2984
3032
  }
2985
- static code = "CONNECTION_FAILED";
2986
- static statusCode = 500;
2987
- static description = `Failed to connect to execute server: {message}`;
3033
+ static code = "DOMAIN_OWNERSHIP_ERROR";
3034
+ static statusCode = 403;
3035
+ static description = `Account {account_id} does not own domain {domain}`;
2988
3036
  }
2989
- class MetadataWriteFailedError extends Error {
3037
+ class CloudstateInternalErrorError extends Error {
2990
3038
  constructor(body) {
2991
3039
  super(
2992
- `METADATA_WRITE_FAILED: ${body.message}`
3040
+ `CLOUDSTATE_INTERNAL_ERROR: ${body.message}`
2993
3041
  );
2994
3042
  this.body = body;
2995
- this.name = "MetadataWriteFailedError";
3043
+ this.name = "CloudstateInternalErrorError";
2996
3044
  }
2997
- static code = "METADATA_WRITE_FAILED";
3045
+ static code = "CLOUDSTATE_INTERNAL_ERROR";
2998
3046
  static statusCode = 500;
2999
- static description = `Failed to write metadata file: {message}`;
3047
+ static description = `Internal error: {message}`;
3000
3048
  }
3001
- class NodeModulesInstallFailedError extends Error {
3049
+ class CloudstateDatabaseErrorError extends Error {
3002
3050
  constructor(body) {
3003
3051
  super(
3004
- `NODE_MODULES_INSTALL_FAILED: ${body.message}`
3052
+ `CLOUDSTATE_DATABASE_ERROR: ${body.message}`
3005
3053
  );
3006
3054
  this.body = body;
3007
- this.name = "NodeModulesInstallFailedError";
3055
+ this.name = "CloudstateDatabaseErrorError";
3008
3056
  }
3009
- static code = "NODE_MODULES_INSTALL_FAILED";
3057
+ static code = "CLOUDSTATE_DATABASE_ERROR";
3010
3058
  static statusCode = 500;
3011
- static description = `Failed to install node modules: {message}`;
3059
+ static description = `Database operation failed: {message}`;
3012
3060
  }
3013
- class NodeModulesDownloadFailedError extends Error {
3061
+ class CloudstateAccessDeniedError extends Error {
3014
3062
  constructor(body) {
3015
3063
  super(
3016
- `NODE_MODULES_DOWNLOAD_FAILED: ${body.message}`
3064
+ `CLOUDSTATE_ACCESS_DENIED: ${body.message}`
3017
3065
  );
3018
3066
  this.body = body;
3019
- this.name = "NodeModulesDownloadFailedError";
3067
+ this.name = "CloudstateAccessDeniedError";
3020
3068
  }
3021
- static code = "NODE_MODULES_DOWNLOAD_FAILED";
3022
- static statusCode = 500;
3023
- static description = `Failed to download node modules: {message}`;
3069
+ static code = "CLOUDSTATE_ACCESS_DENIED";
3070
+ static statusCode = 403;
3071
+ static description = `Access denied to project: {project_id}`;
3024
3072
  }
3025
- class LockGenerationFailedError extends Error {
3073
+ class RestoreFailedError extends Error {
3026
3074
  constructor(body) {
3027
3075
  super(
3028
- `LOCK_GENERATION_FAILED: ${body.message}`
3076
+ `RESTORE_FAILED: ${body.message}`
3029
3077
  );
3030
3078
  this.body = body;
3031
- this.name = "LockGenerationFailedError";
3079
+ this.name = "RestoreFailedError";
3032
3080
  }
3033
- static code = "LOCK_GENERATION_FAILED";
3081
+ static code = "RESTORE_FAILED";
3034
3082
  static statusCode = 500;
3035
- static description = `Failed to generate lock file: {message}`;
3083
+ static description = `Failed to restore from backup: {message}`;
3036
3084
  }
3037
- class WriteScriptFailedError extends Error {
3085
+ class CreateBackupFailedError extends Error {
3038
3086
  constructor(body) {
3039
3087
  super(
3040
- `WRITE_SCRIPT_FAILED: ${body.message}`
3088
+ `CREATE_BACKUP_FAILED: ${body.message}`
3041
3089
  );
3042
3090
  this.body = body;
3043
- this.name = "WriteScriptFailedError";
3091
+ this.name = "CreateBackupFailedError";
3044
3092
  }
3045
- static code = "WRITE_SCRIPT_FAILED";
3093
+ static code = "CREATE_BACKUP_FAILED";
3046
3094
  static statusCode = 500;
3047
- static description = `Failed to write script file: {message}`;
3095
+ static description = `Failed to create backup: {message}`;
3048
3096
  }
3049
- class DirectoryCreationFailedError extends Error {
3097
+ class BackupFailedError extends Error {
3050
3098
  constructor(body) {
3051
3099
  super(
3052
- `DIRECTORY_CREATION_FAILED: ${body.message}`
3100
+ `BACKUP_FAILED: ${body.message}`
3053
3101
  );
3054
3102
  this.body = body;
3055
- this.name = "DirectoryCreationFailedError";
3103
+ this.name = "BackupFailedError";
3056
3104
  }
3057
- static code = "DIRECTORY_CREATION_FAILED";
3105
+ static code = "BACKUP_FAILED";
3058
3106
  static statusCode = 500;
3059
- static description = `Failed to create script directory: {message}`;
3107
+ static description = `Backup failed: {message}`;
3060
3108
  }
3061
- class NetworkPermissionsFailedError extends Error {
3109
+ class DeploymentFailedError extends Error {
3062
3110
  constructor(body) {
3063
3111
  super(
3064
- `NETWORK_PERMISSIONS_FAILED: ${body.message}`
3112
+ `DEPLOYMENT_FAILED: ${body.message}`
3065
3113
  );
3066
3114
  this.body = body;
3067
- this.name = "NetworkPermissionsFailedError";
3115
+ this.name = "DeploymentFailedError";
3068
3116
  }
3069
- static code = "NETWORK_PERMISSIONS_FAILED";
3117
+ static code = "DEPLOYMENT_FAILED";
3070
3118
  static statusCode = 500;
3071
- static description = `Failed to insert network permissions: {message}`;
3119
+ static description = `Deployment failed: {message}`;
3072
3120
  }
3073
- class LoggingFailedError extends Error {
3121
+ class InvalidDeploymentRequestError extends Error {
3074
3122
  constructor(body) {
3075
3123
  super(
3076
- `LOGGING_FAILED: ${body.message}`
3124
+ `INVALID_DEPLOYMENT_REQUEST: ${body.message}`
3077
3125
  );
3078
3126
  this.body = body;
3079
- this.name = "LoggingFailedError";
3127
+ this.name = "InvalidDeploymentRequestError";
3080
3128
  }
3081
- static code = "LOGGING_FAILED";
3082
- static statusCode = 500;
3083
- static description = `Failed to log execute run: {message}`;
3129
+ static code = "INVALID_DEPLOYMENT_REQUEST";
3130
+ static statusCode = 400;
3131
+ static description = `Invalid deployment request: {message}`;
3084
3132
  }
3085
- class RunNotFoundError extends Error {
3133
+ class ProjectNotFoundError extends Error {
3086
3134
  constructor(body) {
3087
3135
  super(
3088
- `RUN_NOT_FOUND: ${body.message}`
3136
+ `PROJECT_NOT_FOUND: ${body.message}`
3089
3137
  );
3090
3138
  this.body = body;
3091
- this.name = "RunNotFoundError";
3139
+ this.name = "ProjectNotFoundError";
3092
3140
  }
3093
- static code = "RUN_NOT_FOUND";
3141
+ static code = "PROJECT_NOT_FOUND";
3094
3142
  static statusCode = 404;
3095
- static description = `Execute run not found: {run_id}`;
3143
+ static description = `Project not found: {project_id}`;
3096
3144
  }
3097
3145
  const FREESTYLE_ERROR_CODE_MAP = {
3098
3146
  "BAD_PARSE": BadParseError,
@@ -3101,55 +3149,33 @@ const FREESTYLE_ERROR_CODE_MAP = {
3101
3149
  "BAD_HEADER": BadHeaderError,
3102
3150
  "BAD_KEY": BadKeyError,
3103
3151
  "GIT_ERROR": GitErrorError,
3104
- "PARTITION_NOT_FOUND": PartitionNotFoundError,
3105
- "VM_OPERATION_DENIED_DURING_TRANSACTION": VmOperationDeniedDuringTransactionError,
3106
- "VM_TRANSACTION_ID_MISMATCH": VmTransactionIdMismatchError,
3107
- "VM_NOT_IN_TRANSACTION": VmNotInTransactionError,
3108
- "VM_NOT_RUNNING": VmNotRunningError,
3109
- "FILE_NOT_FOUND": FileNotFoundError,
3110
- "FILES_BAD_REQUEST": FilesBadRequestError,
3111
- "INVALID_GIT_REPO_SPEC_ERROR": InvalidGitRepoSpecErrorError,
3112
- "INTERNAL_ERROR": InternalErrorError,
3113
- "FORK_VM_NOT_FOUND": ForkVmNotFoundError,
3114
- "CREATE_SNAPSHOT_BAD_REQUEST": CreateSnapshotBadRequestError,
3115
- "ACTIVE_TRANSACTION_ERROR": ActiveTransactionErrorError,
3116
- "SWAP_VM_TAP": SwapVmTapError,
3117
- "ROOTFS_COPY_ERROR": RootfsCopyErrorError,
3118
- "VM_NOT_FOUND_IN_FS": VmNotFoundInFsError,
3119
- "DATABASE_ERROR": DatabaseErrorError,
3120
- "INVALID_VM_ID": InvalidVmIdError,
3121
- "VM_NOT_FOUND": VmNotFoundError,
3122
- "INTERNAL_FORK_VM_NOT_FOUND": InternalForkVmNotFoundError,
3123
- "BAD_REQUEST": BadRequestError,
3124
- "INTERNAL_VM_NOT_FOUND": InternalVmNotFoundError,
3125
- "SNAPSHOT_SETUP_FAILED": SnapshotSetupFailedError,
3126
- "SNAPSHOT_VM_BAD_REQUEST": SnapshotVmBadRequestError,
3127
- "VM_DELETED": VmDeletedError,
3128
- "NO_DEFAULT_SNAPSHOT_AVAILABLE": NoDefaultSnapshotAvailableError,
3129
- "DOCKER_SNAPSHOT_FAILED": DockerSnapshotFailedError,
3130
- "SET_DEFAULT_SNAPSHOT_FAILED": SetDefaultSnapshotFailedError,
3131
- "SNAPSHOT_LAYER_CREATION_FAILED": SnapshotLayerCreationFailedError,
3132
- "SNAPSHOT_DIR_NOT_FOUND": SnapshotDirNotFoundError,
3133
- "SUBVOLUME_CREATION_FAILED": SubvolumeCreationFailedError,
3134
- "GET_DEFAULT_SNAPSHOT_FAILED": GetDefaultSnapshotFailedError,
3135
- "SUSPEND_FAILED_AND_STOP_FAILED": SuspendFailedAndStopFailedError,
3136
- "SUSPEND_FAILED_AND_STOPPED": SuspendFailedAndStoppedError,
3137
3152
  "SNAPSHOT_NOT_FOUND": SnapshotNotFoundError,
3138
3153
  "RESUMED_VM_NON_RESPONSIVE": ResumedVmNonResponsiveError,
3139
3154
  "SNAPSHOT_LOAD_TIMEOUT": SnapshotLoadTimeoutError,
3140
3155
  "UFFD_TIMEOUT_ERROR": UffdTimeoutErrorError,
3141
3156
  "KERNEL_PANIC": KernelPanicError,
3157
+ "VM_DELETED": VmDeletedError,
3142
3158
  "REQWEST": ReqwestError,
3143
3159
  "FIRECRACKER_PID_NOT_FOUND": FirecrackerPidNotFoundError,
3144
3160
  "FIRECRACKER_API_SOCKET_NOT_FOUND": FirecrackerApiSocketNotFoundError,
3145
3161
  "INVALID_SNAPSHOT_ID": InvalidSnapshotIdError,
3146
3162
  "VM_START_TIMEOUT": VmStartTimeoutError,
3163
+ "VM_IS_SUSPENDING": VmIsSuspendingError,
3147
3164
  "VM_EXIT_DURING_START": VmExitDuringStartError,
3148
3165
  "VM_ACCESS_DENIED": VmAccessDeniedError,
3149
3166
  "STD_IO": StdIoError,
3150
3167
  "FAILED_TO_SPAWN_UFFD": FailedToSpawnUffdError,
3151
3168
  "VM_SPAWN_PROCESS": VmSpawnProcessError,
3152
3169
  "VM_SUBNET_NOT_FOUND": VmSubnetNotFoundError,
3170
+ "VM_OPERATION_DENIED_DURING_TRANSACTION": VmOperationDeniedDuringTransactionError,
3171
+ "VM_TRANSACTION_ID_MISMATCH": VmTransactionIdMismatchError,
3172
+ "VM_NOT_IN_TRANSACTION": VmNotInTransactionError,
3173
+ "VM_NOT_FOUND_IN_FS": VmNotFoundInFsError,
3174
+ "VM_NOT_RUNNING": VmNotRunningError,
3175
+ "VM_NOT_FOUND": VmNotFoundError,
3176
+ "INTERNAL_FORK_VM_NOT_FOUND": InternalForkVmNotFoundError,
3177
+ "BAD_REQUEST": BadRequestError,
3178
+ "INTERNAL_VM_NOT_FOUND": InternalVmNotFoundError,
3153
3179
  "USER_NOT_FOUND": UserNotFoundError,
3154
3180
  "USER_ALREADY_EXISTS": UserAlreadyExistsError,
3155
3181
  "VALIDATION_ERROR": ValidationErrorError,
@@ -3166,6 +3192,29 @@ const FREESTYLE_ERROR_CODE_MAP = {
3166
3192
  "GROUP_NAME_INVALID_CHARS": GroupNameInvalidCharsError,
3167
3193
  "GROUP_NAME_TOO_LONG": GroupNameTooLongError,
3168
3194
  "GROUP_NAME_EMPTY": GroupNameEmptyError,
3195
+ "NO_DEFAULT_SNAPSHOT_AVAILABLE": NoDefaultSnapshotAvailableError,
3196
+ "DOCKER_SNAPSHOT_FAILED": DockerSnapshotFailedError,
3197
+ "SET_DEFAULT_SNAPSHOT_FAILED": SetDefaultSnapshotFailedError,
3198
+ "SNAPSHOT_LAYER_CREATION_FAILED": SnapshotLayerCreationFailedError,
3199
+ "SNAPSHOT_DIR_NOT_FOUND": SnapshotDirNotFoundError,
3200
+ "SUBVOLUME_CREATION_FAILED": SubvolumeCreationFailedError,
3201
+ "GET_DEFAULT_SNAPSHOT_FAILED": GetDefaultSnapshotFailedError,
3202
+ "SNAPSHOT_SETUP_FAILED": SnapshotSetupFailedError,
3203
+ "SNAPSHOT_VM_BAD_REQUEST": SnapshotVmBadRequestError,
3204
+ "DATABASE_ERROR": DatabaseErrorError,
3205
+ "PARTITION_NOT_FOUND": PartitionNotFoundError,
3206
+ "INVALID_VM_ID": InvalidVmIdError,
3207
+ "SUSPEND_FAILED_AND_STOP_FAILED": SuspendFailedAndStopFailedError,
3208
+ "SUSPEND_FAILED_AND_STOPPED": SuspendFailedAndStoppedError,
3209
+ "FILE_NOT_FOUND": FileNotFoundError,
3210
+ "FILES_BAD_REQUEST": FilesBadRequestError,
3211
+ "INVALID_GIT_REPO_SPEC_ERROR": InvalidGitRepoSpecErrorError,
3212
+ "INTERNAL_ERROR": InternalErrorError,
3213
+ "FORK_VM_NOT_FOUND": ForkVmNotFoundError,
3214
+ "CREATE_SNAPSHOT_BAD_REQUEST": CreateSnapshotBadRequestError,
3215
+ "ACTIVE_TRANSACTION_ERROR": ActiveTransactionErrorError,
3216
+ "SWAP_VM_TAP": SwapVmTapError,
3217
+ "ROOTFS_COPY_ERROR": RootfsCopyErrorError,
3169
3218
  "CREATE_VM_BAD_REQUEST": CreateVmBadRequestError,
3170
3219
  "VM_SETUP_FAILED": VmSetupFailedError,
3171
3220
  "WANTED_BY_EMPTY": WantedByEmptyError,
@@ -3195,38 +3244,38 @@ const FREESTYLE_ERROR_CODE_MAP = {
3195
3244
  "MAX_USES_EXCEEDED": MaxUsesExceededError,
3196
3245
  "EXPIRED": ExpiredError,
3197
3246
  "FORBIDDEN": ForbiddenError,
3198
- "UNSUPPORTED_TRANSFER": UnsupportedTransferError,
3199
- "TREE_NOT_FOUND": TreeNotFoundError,
3200
- "BRANCH_NOT_FOUND": BranchNotFoundError,
3201
- "PARENT_NOT_FOUND": ParentNotFoundError,
3202
- "INVALID_SERVICE": InvalidServiceError,
3203
- "EXPECTED_SERVICE": ExpectedServiceError,
3204
- "NOT_FOUND": NotFoundError,
3205
- "SEND_ERROR": SendErrorError,
3206
3247
  "UNAUTHORIZED": UnauthorizedError,
3207
- "INVALID_ACCOUNT_ID": InvalidAccountIdError,
3208
- "SOURCE_IMPORT_CONFLICT": SourceImportConflictError,
3209
- "SOURCE_UNAUTHORIZED": SourceUnauthorizedError,
3210
- "SOURCE_NOT_FOUND": SourceNotFoundError,
3211
- "IMPORT_SUBDIR_NOT_FOUND": ImportSubdirNotFoundError,
3212
- "REPO_ALREADY_EXISTS": RepoAlreadyExistsError,
3213
- "TAG_NOT_FOUND": TagNotFoundError,
3248
+ "BLOB_NOT_FOUND": BlobNotFoundError,
3214
3249
  "INVALID_RANGE": InvalidRangeError,
3215
3250
  "OFFSET_WITH_SELECTOR": OffsetWithSelectorError,
3216
3251
  "COMMIT_NOT_IN_BRANCH": CommitNotInBranchError,
3217
3252
  "COMMIT_NOT_FOUND": CommitNotFoundError,
3253
+ "BRANCH_NOT_FOUND": BranchNotFoundError,
3218
3254
  "NO_DEFAULT_BRANCH": NoDefaultBranchError,
3219
3255
  "INVALID_BASE64_CONTENT": InvalidBase64ContentError,
3220
3256
  "INVALID_FILE_CHANGE": InvalidFileChangeError,
3221
3257
  "INVALID_FILE_PATH": InvalidFilePathError,
3222
3258
  "CONFLICTING_PARENT": ConflictingParentError,
3223
3259
  "AMBIGUOUS": AmbiguousError,
3260
+ "NOT_FOUND": NotFoundError,
3224
3261
  "INVALID": InvalidError,
3262
+ "UNSUPPORTED_TRANSFER": UnsupportedTransferError,
3263
+ "TREE_NOT_FOUND": TreeNotFoundError,
3264
+ "PARENT_NOT_FOUND": ParentNotFoundError,
3265
+ "INVALID_SERVICE": InvalidServiceError,
3266
+ "EXPECTED_SERVICE": ExpectedServiceError,
3225
3267
  "PATH_NOT_FOUND": PathNotFoundError,
3226
3268
  "REFERENCE_NOT_FOUND": ReferenceNotFoundError,
3227
- "BLOB_NOT_FOUND": BlobNotFoundError,
3228
- "PACKFILE": PackfileError,
3269
+ "TAG_NOT_FOUND": TagNotFoundError,
3229
3270
  "INVALID_REVISION": InvalidRevisionError,
3271
+ "PACKFILE": PackfileError,
3272
+ "SEND_ERROR": SendErrorError,
3273
+ "INVALID_ACCOUNT_ID": InvalidAccountIdError,
3274
+ "SOURCE_IMPORT_CONFLICT": SourceImportConflictError,
3275
+ "SOURCE_UNAUTHORIZED": SourceUnauthorizedError,
3276
+ "SOURCE_NOT_FOUND": SourceNotFoundError,
3277
+ "IMPORT_SUBDIR_NOT_FOUND": ImportSubdirNotFoundError,
3278
+ "REPO_ALREADY_EXISTS": RepoAlreadyExistsError,
3230
3279
  "CONFLICT": ConflictError,
3231
3280
  "BRANCH_ALREADY_EXISTS": BranchAlreadyExistsError,
3232
3281
  "GIT_HUB_SYNC_CONFLICT": GitHubSyncConflictError,
@@ -3234,27 +3283,40 @@ const FREESTYLE_ERROR_CODE_MAP = {
3234
3283
  "UNAVAILABLE": UnavailableError,
3235
3284
  "SCHEDULE_NOT_FOUND": ScheduleNotFoundError,
3236
3285
  "SERVICE_UNAVAILABLE": ServiceUnavailableError,
3237
- "PERMISSION_ALREADY_EXISTS": PermissionAlreadyExistsError,
3238
- "LIST_TOKENS_FAILED": ListTokensFailedError,
3239
- "REVOKE_TOKEN_FAILED": RevokeTokenFailedError,
3240
- "CREATE_TOKEN_FAILED": CreateTokenFailedError,
3241
- "LIST_PERMISSIONS_FAILED": ListPermissionsFailedError,
3242
- "GET_PERMISSION_FAILED": GetPermissionFailedError,
3243
- "UPDATE_PERMISSION_FAILED": UpdatePermissionFailedError,
3244
- "REVOKE_PERMISSION_FAILED": RevokePermissionFailedError,
3245
- "GRANT_PERMISSION_FAILED": GrantPermissionFailedError,
3246
- "LIST_IDENTITIES_FAILED": ListIdentitiesFailedError,
3247
- "DELETE_IDENTITY_FAILED": DeleteIdentityFailedError,
3248
- "CREATE_IDENTITY_FAILED": CreateIdentityFailedError,
3249
- "VM_PERMISSION_NOT_FOUND": VmPermissionNotFoundError,
3250
- "PERMISSION_NOT_FOUND": PermissionNotFoundError,
3251
- "GIT_REPOSITORY_ACCESS_DENIED": GitRepositoryAccessDeniedError,
3252
- "GIT_REPOSITORY_NOT_FOUND": GitRepositoryNotFoundError,
3253
- "CANNOT_DELETE_MANAGED_IDENTITY": CannotDeleteManagedIdentityError,
3254
- "CANNOT_MODIFY_MANAGED_IDENTITY": CannotModifyManagedIdentityError,
3255
- "IDENTITY_ACCESS_DENIED": IdentityAccessDeniedError,
3256
- "IDENTITY_NOT_FOUND": IdentityNotFoundError,
3257
- "UNAUTHORIZED_ERROR": UnauthorizedErrorError,
3286
+ "EXECUTE_LIMIT_EXCEEDED": ExecuteLimitExceededError,
3287
+ "OBSERVABILITY_DATABASE_ERROR": ObservabilityDatabaseErrorError,
3288
+ "OBSERVABILITY_ACCESS_DENIED": ObservabilityAccessDeniedError,
3289
+ "PARSE_LOGS_FAILED": ParseLogsFailedError,
3290
+ "RETRIEVE_LOGS_FAILED": RetrieveLogsFailedError,
3291
+ "INVALID_QUERY": InvalidQueryError,
3292
+ "LOGS_NOT_FOUND": LogsNotFoundError,
3293
+ "EXECUTE_INTERNAL_ERROR": ExecuteInternalErrorError,
3294
+ "EXECUTE_ACCESS_DENIED": ExecuteAccessDeniedError,
3295
+ "LIST_RUNS_FAILED": ListRunsFailedError,
3296
+ "EXECUTION_ERROR": ExecutionErrorError,
3297
+ "CONNECTION_FAILED": ConnectionFailedError,
3298
+ "METADATA_WRITE_FAILED": MetadataWriteFailedError,
3299
+ "NODE_MODULES_INSTALL_FAILED": NodeModulesInstallFailedError,
3300
+ "NODE_MODULES_DOWNLOAD_FAILED": NodeModulesDownloadFailedError,
3301
+ "LOCK_GENERATION_FAILED": LockGenerationFailedError,
3302
+ "WRITE_SCRIPT_FAILED": WriteScriptFailedError,
3303
+ "DIRECTORY_CREATION_FAILED": DirectoryCreationFailedError,
3304
+ "NETWORK_PERMISSIONS_FAILED": NetworkPermissionsFailedError,
3305
+ "LOGGING_FAILED": LoggingFailedError,
3306
+ "RUN_NOT_FOUND": RunNotFoundError,
3307
+ "LIMIT_EXCEEDED": LimitExceededError,
3308
+ "FAILED_TO_PROVISION_CERTIFICATE": FailedToProvisionCertificateError,
3309
+ "FAILED_TO_INSERT_DOMAIN_MAPPING": FailedToInsertDomainMappingError,
3310
+ "PERMISSION_DENIED": PermissionDeniedError,
3311
+ "FAILED_TO_CHECK_PERMISSIONS": FailedToCheckPermissionsError,
3312
+ "FAILED_TO_LIST_DOMAINS": FailedToListDomainsError,
3313
+ "FAILED_TO_LIST_VERIFICATIONS": FailedToListVerificationsError,
3314
+ "FAILED_TO_VERIFY_DOMAIN": FailedToVerifyDomainError,
3315
+ "VERIFICATION_FAILED": VerificationFailedError,
3316
+ "FAILED_TO_DELETE_VERIFICATION": FailedToDeleteVerificationError,
3317
+ "VERIFICATION_NOT_FOUND": VerificationNotFoundError,
3318
+ "FAILED_TO_CREATE_VERIFICATION_CODE": FailedToCreateVerificationCodeError,
3319
+ "INVALID_DOMAIN": InvalidDomainError,
3258
3320
  "BUILD_FAILED": BuildFailedError,
3259
3321
  "SERVER_DEPLOYMENT_FAILED": ServerDeploymentFailedError,
3260
3322
  "LOCKFILE_ERROR": LockfileErrorError,
@@ -3266,13 +3328,14 @@ const FREESTYLE_ERROR_CODE_MAP = {
3266
3328
  "NO_DOMAIN_OWNERSHIP": NoDomainOwnershipError,
3267
3329
  "INVALID_DOMAINS": InvalidDomainsError,
3268
3330
  "WEB_DEPLOYMENT_BAD_REQUEST": WebDeploymentBadRequestError,
3331
+ "TIMEOUT_LIMIT_EXCEEDED": TimeoutLimitExceededError,
3269
3332
  "DEPLOYMENT_LIMIT_EXCEEDED": DeploymentLimitExceededError,
3270
3333
  "DEPLOYMENT_NOT_FOUND": DeploymentNotFoundError,
3271
3334
  "RESIZE_FAILED": ResizeFailedError,
3272
3335
  "INTERNAL_RESIZE_VM_NOT_FOUND": InternalResizeVmNotFoundError,
3336
+ "ACCESS_DENIED": AccessDeniedError,
3273
3337
  "BRANCH_NAME_EMPTY": BranchNameEmptyError,
3274
- "EXECUTE_LIMIT_EXCEEDED": ExecuteLimitExceededError,
3275
- "VM_LIMIT_EXCEEDED": VmLimitExceededError,
3338
+ "UNAUTHORIZED_ERROR": UnauthorizedErrorError,
3276
3339
  "TRIGGER_ERROR": TriggerErrorError,
3277
3340
  "TOKEN_ERROR": TokenErrorError,
3278
3341
  "PERMISSION_ERROR": PermissionErrorError,
@@ -3302,6 +3365,31 @@ const FREESTYLE_ERROR_CODE_MAP = {
3302
3365
  "FAILED_REMOVE_DOMAIN_MAPPING": FailedRemoveDomainMappingError,
3303
3366
  "FAILED_PERMISSIONS_CHECK": FailedPermissionsCheckError,
3304
3367
  "FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS": FailedToCheckDomainMappingPermissionsError,
3368
+ "GIT_REPO_LIMIT_EXCEEDED": GitRepoLimitExceededError,
3369
+ "EMPTY_TAG": EmptyTagError,
3370
+ "PERSISTENT_VMS_NOT_ALLOWED": PersistentVmsNotAllowedError,
3371
+ "TOTAL_VM_LIMIT_EXCEEDED": TotalVmLimitExceededError,
3372
+ "VM_LIMIT_EXCEEDED": VmLimitExceededError,
3373
+ "PERMISSION_ALREADY_EXISTS": PermissionAlreadyExistsError,
3374
+ "LIST_TOKENS_FAILED": ListTokensFailedError,
3375
+ "REVOKE_TOKEN_FAILED": RevokeTokenFailedError,
3376
+ "CREATE_TOKEN_FAILED": CreateTokenFailedError,
3377
+ "LIST_PERMISSIONS_FAILED": ListPermissionsFailedError,
3378
+ "GET_PERMISSION_FAILED": GetPermissionFailedError,
3379
+ "UPDATE_PERMISSION_FAILED": UpdatePermissionFailedError,
3380
+ "REVOKE_PERMISSION_FAILED": RevokePermissionFailedError,
3381
+ "GRANT_PERMISSION_FAILED": GrantPermissionFailedError,
3382
+ "LIST_IDENTITIES_FAILED": ListIdentitiesFailedError,
3383
+ "DELETE_IDENTITY_FAILED": DeleteIdentityFailedError,
3384
+ "CREATE_IDENTITY_FAILED": CreateIdentityFailedError,
3385
+ "VM_PERMISSION_NOT_FOUND": VmPermissionNotFoundError,
3386
+ "PERMISSION_NOT_FOUND": PermissionNotFoundError,
3387
+ "GIT_REPOSITORY_ACCESS_DENIED": GitRepositoryAccessDeniedError,
3388
+ "GIT_REPOSITORY_NOT_FOUND": GitRepositoryNotFoundError,
3389
+ "CANNOT_DELETE_MANAGED_IDENTITY": CannotDeleteManagedIdentityError,
3390
+ "CANNOT_MODIFY_MANAGED_IDENTITY": CannotModifyManagedIdentityError,
3391
+ "IDENTITY_ACCESS_DENIED": IdentityAccessDeniedError,
3392
+ "IDENTITY_NOT_FOUND": IdentityNotFoundError,
3305
3393
  "DOMAIN_OWNERSHIP_VERIFICATION_FAILED": DomainOwnershipVerificationFailedError,
3306
3394
  "ERROR_DELETING_RECORD": ErrorDeletingRecordError,
3307
3395
  "RECORD_OWNERSHIP_ERROR": RecordOwnershipErrorError,
@@ -3315,43 +3403,7 @@ const FREESTYLE_ERROR_CODE_MAP = {
3315
3403
  "BACKUP_FAILED": BackupFailedError,
3316
3404
  "DEPLOYMENT_FAILED": DeploymentFailedError,
3317
3405
  "INVALID_DEPLOYMENT_REQUEST": InvalidDeploymentRequestError,
3318
- "PROJECT_NOT_FOUND": ProjectNotFoundError,
3319
- "GIT_REPO_LIMIT_EXCEEDED": GitRepoLimitExceededError,
3320
- "EMPTY_TAG": EmptyTagError,
3321
- "LIMIT_EXCEEDED": LimitExceededError,
3322
- "FAILED_TO_PROVISION_CERTIFICATE": FailedToProvisionCertificateError,
3323
- "FAILED_TO_INSERT_DOMAIN_MAPPING": FailedToInsertDomainMappingError,
3324
- "PERMISSION_DENIED": PermissionDeniedError,
3325
- "FAILED_TO_CHECK_PERMISSIONS": FailedToCheckPermissionsError,
3326
- "FAILED_TO_LIST_DOMAINS": FailedToListDomainsError,
3327
- "FAILED_TO_LIST_VERIFICATIONS": FailedToListVerificationsError,
3328
- "FAILED_TO_VERIFY_DOMAIN": FailedToVerifyDomainError,
3329
- "VERIFICATION_FAILED": VerificationFailedError,
3330
- "FAILED_TO_DELETE_VERIFICATION": FailedToDeleteVerificationError,
3331
- "VERIFICATION_NOT_FOUND": VerificationNotFoundError,
3332
- "FAILED_TO_CREATE_VERIFICATION_CODE": FailedToCreateVerificationCodeError,
3333
- "INVALID_DOMAIN": InvalidDomainError,
3334
- "ACCESS_DENIED": AccessDeniedError,
3335
- "OBSERVABILITY_DATABASE_ERROR": ObservabilityDatabaseErrorError,
3336
- "OBSERVABILITY_ACCESS_DENIED": ObservabilityAccessDeniedError,
3337
- "PARSE_LOGS_FAILED": ParseLogsFailedError,
3338
- "RETRIEVE_LOGS_FAILED": RetrieveLogsFailedError,
3339
- "INVALID_QUERY": InvalidQueryError,
3340
- "LOGS_NOT_FOUND": LogsNotFoundError,
3341
- "EXECUTE_INTERNAL_ERROR": ExecuteInternalErrorError,
3342
- "EXECUTE_ACCESS_DENIED": ExecuteAccessDeniedError,
3343
- "LIST_RUNS_FAILED": ListRunsFailedError,
3344
- "EXECUTION_ERROR": ExecutionErrorError,
3345
- "CONNECTION_FAILED": ConnectionFailedError,
3346
- "METADATA_WRITE_FAILED": MetadataWriteFailedError,
3347
- "NODE_MODULES_INSTALL_FAILED": NodeModulesInstallFailedError,
3348
- "NODE_MODULES_DOWNLOAD_FAILED": NodeModulesDownloadFailedError,
3349
- "LOCK_GENERATION_FAILED": LockGenerationFailedError,
3350
- "WRITE_SCRIPT_FAILED": WriteScriptFailedError,
3351
- "DIRECTORY_CREATION_FAILED": DirectoryCreationFailedError,
3352
- "NETWORK_PERMISSIONS_FAILED": NetworkPermissionsFailedError,
3353
- "LOGGING_FAILED": LoggingFailedError,
3354
- "RUN_NOT_FOUND": RunNotFoundError
3406
+ "PROJECT_NOT_FOUND": ProjectNotFoundError
3355
3407
  };
3356
3408
 
3357
3409
  var errors = /*#__PURE__*/Object.freeze({
@@ -3525,6 +3577,7 @@ var errors = /*#__PURE__*/Object.freeze({
3525
3577
  PermissionDeniedError: PermissionDeniedError,
3526
3578
  PermissionErrorError: PermissionErrorError,
3527
3579
  PermissionNotFoundError: PermissionNotFoundError,
3580
+ PersistentVmsNotAllowedError: PersistentVmsNotAllowedError,
3528
3581
  ProjectNotFoundError: ProjectNotFoundError,
3529
3582
  RecordOwnershipErrorError: RecordOwnershipErrorError,
3530
3583
  ReferenceNotFoundError: ReferenceNotFoundError,
@@ -3572,7 +3625,9 @@ var errors = /*#__PURE__*/Object.freeze({
3572
3625
  SwapVmTapError: SwapVmTapError,
3573
3626
  SyntaxErrorError: SyntaxErrorError,
3574
3627
  TagNotFoundError: TagNotFoundError,
3628
+ TimeoutLimitExceededError: TimeoutLimitExceededError,
3575
3629
  TokenErrorError: TokenErrorError,
3630
+ TotalVmLimitExceededError: TotalVmLimitExceededError,
3576
3631
  TreeNotFoundError: TreeNotFoundError,
3577
3632
  TriggerErrorError: TriggerErrorError,
3578
3633
  UffdTimeoutErrorError: UffdTimeoutErrorError,
@@ -3598,6 +3653,7 @@ var errors = /*#__PURE__*/Object.freeze({
3598
3653
  VmAccessDeniedForMappingError: VmAccessDeniedForMappingError,
3599
3654
  VmDeletedError: VmDeletedError,
3600
3655
  VmExitDuringStartError: VmExitDuringStartError,
3656
+ VmIsSuspendingError: VmIsSuspendingError,
3601
3657
  VmLimitExceededError: VmLimitExceededError,
3602
3658
  VmNotFoundError: VmNotFoundError,
3603
3659
  VmNotFoundInFsError: VmNotFoundInFsError,
@@ -5527,6 +5583,7 @@ class VmWithInstance {
5527
5583
  }
5528
5584
  class VmWith {
5529
5585
  instance;
5586
+ defaultField;
5530
5587
  /**
5531
5588
  * Helper method to compose multiple configurations together.
5532
5589
  * Uses the same merging strategy as the main compose function.
@@ -5583,11 +5640,14 @@ function composeCreateVmOptions(arr) {
5583
5640
  if (options.workdir !== void 0) result.workdir = options.workdir;
5584
5641
  if (options.snapshotId !== void 0)
5585
5642
  result.snapshotId = options.snapshotId;
5643
+ if (options.baseImage !== void 0) result.baseImage = options.baseImage;
5586
5644
  if (options.recreate !== void 0) result.recreate = options.recreate;
5587
5645
  if (options.aptDeps !== void 0) result.aptDeps = options.aptDeps;
5588
5646
  if (options.domains !== void 0) result.domains = options.domains;
5589
5647
  if (options.activityThresholdBytes !== void 0)
5590
5648
  result.activityThresholdBytes = options.activityThresholdBytes;
5649
+ if (options.discriminator !== void 0)
5650
+ result.discriminator = options.discriminator;
5591
5651
  if (options.persistence !== void 0)
5592
5652
  result.persistence = options.persistence;
5593
5653
  if (options.ports !== void 0) {
@@ -5729,6 +5789,7 @@ function composeCreateVmOptions(arr) {
5729
5789
  result.template = {
5730
5790
  // Simple overrides - start with base, override with new
5731
5791
  snapshotId: newTemplate.snapshotId !== void 0 ? newTemplate.snapshotId : baseTemplate.snapshotId,
5792
+ baseImage: newTemplate.baseImage !== void 0 ? newTemplate.baseImage : baseTemplate.baseImage,
5732
5793
  rootfsSizeGb: newTemplate.rootfsSizeGb !== void 0 ? newTemplate.rootfsSizeGb : baseTemplate.rootfsSizeGb,
5733
5794
  memSizeGb: newTemplate.memSizeGb !== void 0 ? newTemplate.memSizeGb : baseTemplate.memSizeGb,
5734
5795
  aptDeps: newTemplate.aptDeps ?? baseTemplate.aptDeps,
@@ -5920,11 +5981,14 @@ function composeVmSpecs(specs) {
5920
5981
  rawConfigs
5921
5982
  );
5922
5983
  const mergedWith = {};
5984
+ const mergedWithDiscriminators = {};
5923
5985
  for (const spec of specs) {
5924
- for (const key in spec.with) {
5925
- const builder = spec.with[key];
5986
+ const builderDiscriminators = spec.getBuilderDiscriminators();
5987
+ for (const key in spec.builders) {
5988
+ const builder = spec.builders[key];
5926
5989
  if (builder) {
5927
5990
  mergedWith[key] = builder;
5991
+ mergedWithDiscriminators[key] = builderDiscriminators[key];
5928
5992
  }
5929
5993
  }
5930
5994
  }
@@ -5936,11 +6000,13 @@ function composeVmSpecs(specs) {
5936
6000
  const result = new VmSpec({
5937
6001
  ...composedRaw,
5938
6002
  snapshot: nestedSpec,
5939
- with: mergedWith
6003
+ with: mergedWith,
6004
+ __withDiscriminators: mergedWithDiscriminators
5940
6005
  });
5941
6006
  return result;
5942
6007
  }
5943
6008
 
6009
+ const DEFAULT_CONFIGURE_BASE_IMAGE = "FROM debian:trixie-slim";
5944
6010
  function processSystemdServices(services, existingFiles = {}) {
5945
6011
  const additionalFiles = { ...existingFiles };
5946
6012
  const processedServices = [];
@@ -6043,6 +6109,7 @@ class Vm {
6043
6109
  fs;
6044
6110
  terminals;
6045
6111
  systemd;
6112
+ _withInstances = {};
6046
6113
  /** @internal */
6047
6114
  _linux_username;
6048
6115
  constructor({ vmId, freestyle }) {
@@ -6069,6 +6136,13 @@ class Vm {
6069
6136
  vm._linux_username = username;
6070
6137
  return vm;
6071
6138
  }
6139
+ with(name) {
6140
+ return this._withInstances[name];
6141
+ }
6142
+ /** @internal */
6143
+ _attachWith(name, instance) {
6144
+ this._withInstances[name] = instance;
6145
+ }
6072
6146
  /**
6073
6147
  * Start the VM.
6074
6148
  * @param options Optional startup configuration
@@ -6205,6 +6279,64 @@ class Vm {
6205
6279
  });
6206
6280
  }
6207
6281
  }
6282
+ class VmBaseImage {
6283
+ layers;
6284
+ constructor(base) {
6285
+ if (!base) {
6286
+ this.layers = [];
6287
+ return;
6288
+ }
6289
+ if (typeof base === "string") {
6290
+ this.layers = [base.trimEnd()];
6291
+ return;
6292
+ }
6293
+ this.layers = base.dockerfileContent ? [base.dockerfileContent.trimEnd()] : [];
6294
+ }
6295
+ from(baseImage) {
6296
+ if (typeof baseImage === "string") {
6297
+ const line = /^\s*FROM\b/i.test(baseImage) ? baseImage.trimEnd() : `FROM ${baseImage.trim()}`;
6298
+ this.layers.push(line);
6299
+ return this;
6300
+ }
6301
+ if (baseImage instanceof VmBaseImage) {
6302
+ this.layers.push(...baseImage.layers);
6303
+ return this;
6304
+ }
6305
+ this.layers.push((baseImage.dockerfileContent || "").trimEnd());
6306
+ return this;
6307
+ }
6308
+ runCommands(...commands) {
6309
+ for (const command of commands) {
6310
+ const trimmed = command.trim();
6311
+ if (!trimmed) continue;
6312
+ this.layers.push(`RUN <<'FREESTYLE_EOF'
6313
+ ${trimmed}
6314
+ FREESTYLE_EOF`);
6315
+ }
6316
+ return this;
6317
+ }
6318
+ appendDockerfile(dockerfile) {
6319
+ const trimmed = dockerfile.trim();
6320
+ if (trimmed) {
6321
+ this.layers.push(trimmed);
6322
+ }
6323
+ return this;
6324
+ }
6325
+ hasFromInstruction() {
6326
+ return this.layers.some((layer) => /^\s*FROM\b/m.test(layer));
6327
+ }
6328
+ toRaw() {
6329
+ const dockerfileContent = this.layers.filter((layer) => layer.trim().length > 0).join("\n\n");
6330
+ if (dockerfileContent && !/^\s*FROM\b/m.test(dockerfileContent)) {
6331
+ throw new Error(
6332
+ 'VmBaseImage must include a FROM instruction before adding Dockerfile layers. Add .baseImage(new VmBaseImage("FROM ...")) on the spec.'
6333
+ );
6334
+ }
6335
+ return {
6336
+ dockerfileContent
6337
+ };
6338
+ }
6339
+ }
6208
6340
  class VmTemplate {
6209
6341
  raw;
6210
6342
  with;
@@ -6217,20 +6349,156 @@ class VmTemplate {
6217
6349
  class VmSpec {
6218
6350
  raw;
6219
6351
  with;
6220
- constructor(spec) {
6221
- const { with: withBuilders, ...rest } = spec;
6352
+ withDiscriminators;
6353
+ get builders() {
6354
+ return this.with;
6355
+ }
6356
+ constructor(spec = {}) {
6357
+ const {
6358
+ with: withBuilders,
6359
+ __withDiscriminators: existingWithDiscriminators,
6360
+ ...rest
6361
+ } = spec;
6222
6362
  this.raw = rest;
6223
- this.with = withBuilders ?? {};
6363
+ this.withDiscriminators = { ...existingWithDiscriminators ?? {} };
6364
+ const withFn = ((nameOrBuilder, maybeBuilder) => {
6365
+ const key = typeof nameOrBuilder === "string" ? nameOrBuilder : defaultVmWithName(nameOrBuilder);
6366
+ const builder = typeof nameOrBuilder === "string" ? maybeBuilder : nameOrBuilder;
6367
+ if (!builder) {
6368
+ throw new Error("VmSpec.with requires a VmWith instance");
6369
+ }
6370
+ this.with[key] = builder;
6371
+ this.withDiscriminators[key] = this.raw.discriminator;
6372
+ return this;
6373
+ });
6374
+ this.with = withFn;
6375
+ for (const [key, builder] of Object.entries(withBuilders ?? {})) {
6376
+ if (builder) {
6377
+ this.with[key] = builder;
6378
+ if (!(key in this.withDiscriminators)) {
6379
+ this.withDiscriminators[key] = void 0;
6380
+ }
6381
+ }
6382
+ }
6383
+ }
6384
+ getBuilderDiscriminator(key) {
6385
+ return this.withDiscriminators[key];
6386
+ }
6387
+ getBuilderDiscriminators() {
6388
+ return { ...this.withDiscriminators };
6389
+ }
6390
+ mergeRaw(options) {
6391
+ this.raw = composeCreateVmOptions([
6392
+ this.raw,
6393
+ options
6394
+ ]);
6395
+ return this;
6396
+ }
6397
+ clearBuilders() {
6398
+ for (const key of Object.keys(this.with)) {
6399
+ delete this.with[key];
6400
+ delete this.withDiscriminators[key];
6401
+ }
6402
+ }
6403
+ snapshot() {
6404
+ const { snapshot: existingSnapshot, ...currentLayer } = this.raw;
6405
+ const currentBuilders = { ...this.builders };
6406
+ const currentWithDiscriminators = this.getBuilderDiscriminators();
6407
+ const innerSnapshot = new VmSpec({
6408
+ ...currentLayer,
6409
+ with: currentBuilders,
6410
+ __withDiscriminators: currentWithDiscriminators
6411
+ });
6412
+ if (isVmSpecLike$1(existingSnapshot)) {
6413
+ innerSnapshot.raw.snapshot = existingSnapshot;
6414
+ }
6415
+ this.raw = {
6416
+ snapshot: innerSnapshot
6417
+ };
6418
+ this.clearBuilders();
6419
+ return this;
6420
+ }
6421
+ ensureSnapshot() {
6422
+ if (!isVmSpecLike$1(this.raw.snapshot)) {
6423
+ this.raw.snapshot = this.raw.discriminator !== void 0 ? new VmSpec({ discriminator: this.raw.discriminator }) : new VmSpec();
6424
+ }
6425
+ return this.raw.snapshot;
6426
+ }
6427
+ baseImage(baseImage) {
6428
+ this.raw.baseImage = baseImage;
6429
+ return this;
6430
+ }
6431
+ rootfsSizeGb(value) {
6432
+ return this.mergeRaw({ rootfsSizeGb: value });
6433
+ }
6434
+ memSizeGb(value) {
6435
+ return this.mergeRaw({ memSizeGb: value });
6436
+ }
6437
+ vcpuCount(value) {
6438
+ return this.mergeRaw({ vcpuCount: value });
6439
+ }
6440
+ idleTimeoutSeconds(value) {
6441
+ return this.mergeRaw({ idleTimeoutSeconds: value });
6442
+ }
6443
+ readySignalTimeoutSeconds(value) {
6444
+ return this.mergeRaw({ readySignalTimeoutSeconds: value });
6445
+ }
6446
+ waitForReadySignal(value) {
6447
+ return this.mergeRaw({ waitForReadySignal: value });
6448
+ }
6449
+ discriminator(value) {
6450
+ return this.mergeRaw({ discriminator: value });
6451
+ }
6452
+ workdir(path) {
6453
+ return this.mergeRaw({ workdir: path });
6454
+ }
6455
+ aptDeps(...deps) {
6456
+ const existing = this.raw.aptDeps ?? [];
6457
+ return this.mergeRaw({ aptDeps: [...existing, ...deps] });
6458
+ }
6459
+ additionalFiles(files) {
6460
+ const existing = this.raw.additionalFiles ?? {};
6461
+ this.raw.additionalFiles = {
6462
+ ...existing,
6463
+ ...files
6464
+ };
6465
+ return this;
6466
+ }
6467
+ runCommands(...commands) {
6468
+ const image = normalizeBaseImage(this.raw.baseImage) ?? new VmBaseImage();
6469
+ image.runCommands(...commands);
6470
+ this.raw.baseImage = image;
6471
+ return this;
6472
+ }
6473
+ repo(repo, path) {
6474
+ const existingGit = this.raw.git ?? { config: {}, repos: [] };
6475
+ const existingRepos = existingGit.repos ?? [];
6476
+ return this.mergeRaw({
6477
+ git: {
6478
+ ...existingGit,
6479
+ config: existingGit.config ?? {},
6480
+ repos: [...existingRepos, { repo, path }]
6481
+ }
6482
+ });
6483
+ }
6484
+ systemdService(service) {
6485
+ const existingSystemd = this.raw.systemd ?? {};
6486
+ const services = existingSystemd.services ?? [];
6487
+ this.raw.systemd = {
6488
+ ...existingSystemd,
6489
+ services: [...services, service]
6490
+ };
6491
+ return this;
6224
6492
  }
6225
6493
  }
6226
- function isVmSpecLike(value) {
6494
+ function isVmSpecLike$1(value) {
6227
6495
  return !!value && typeof value === "object" && "raw" in value && "with" in value;
6228
6496
  }
6229
6497
  function isVmTemplateLike(value) {
6230
6498
  return !!value && typeof value === "object" && "raw" in value && "with" in value;
6231
6499
  }
6232
6500
  async function convertSpecSnapshotsToTemplates(spec, processBuilders = true) {
6233
- if (!isVmSpecLike(spec.raw.snapshot)) {
6501
+ if (!isVmSpecLike$1(spec.raw.snapshot)) {
6234
6502
  return void 0;
6235
6503
  }
6236
6504
  let innerSpec = spec.raw.snapshot;
@@ -6239,28 +6507,35 @@ async function convertSpecSnapshotsToTemplates(spec, processBuilders = true) {
6239
6507
  }
6240
6508
  const { snapshot: nestedSnapshot, ...innerRaw } = innerSpec.raw;
6241
6509
  let nestedTemplate;
6242
- if (isVmSpecLike(nestedSnapshot)) {
6510
+ if (isVmSpecLike$1(nestedSnapshot)) {
6243
6511
  nestedTemplate = await convertSpecSnapshotsToTemplates(innerSpec, false);
6244
6512
  }
6245
6513
  return new VmTemplate({
6246
6514
  ...innerRaw,
6247
6515
  template: nestedTemplate,
6248
- with: innerSpec.with
6516
+ with: innerSpec.builders
6249
6517
  });
6250
6518
  }
6251
6519
  async function processOuterSpecBuilders(spec) {
6252
- for (const key in spec.with) {
6253
- const builder = spec.with[key];
6520
+ const builders = spec.builders ?? {} ?? {};
6521
+ for (const key in builders) {
6522
+ const builder = builders[key];
6254
6523
  if (builder) {
6255
6524
  if (builder.configureSpec) {
6256
6525
  spec = await builder.configureSpec(spec);
6257
6526
  }
6527
+ if (builder.configureBaseImage) {
6528
+ spec.raw.baseImage = await builder.configureBaseImage(
6529
+ prepareBaseImageForConfigure(spec.raw.baseImage)
6530
+ );
6531
+ }
6258
6532
  if (builder.configureSnapshotSpec) {
6259
6533
  let snapshotSpec;
6260
- if (isVmSpecLike(spec.raw.snapshot)) {
6534
+ if (isVmSpecLike$1(spec.raw.snapshot)) {
6261
6535
  snapshotSpec = spec.raw.snapshot;
6262
6536
  } else {
6263
- snapshotSpec = new VmSpec({});
6537
+ const inheritedDiscriminator = spec.getBuilderDiscriminator(key) ?? spec.raw.discriminator;
6538
+ snapshotSpec = inheritedDiscriminator !== void 0 ? new VmSpec({ discriminator: inheritedDiscriminator }) : new VmSpec({});
6264
6539
  spec.raw.snapshot = snapshotSpec;
6265
6540
  }
6266
6541
  spec.raw.snapshot = await builder.configureSnapshotSpec(snapshotSpec);
@@ -6270,39 +6545,44 @@ async function processOuterSpecBuilders(spec) {
6270
6545
  return spec;
6271
6546
  }
6272
6547
  async function processSpecTree(spec) {
6273
- for (const key in spec.with) {
6274
- const builder = spec.with[key];
6548
+ const builders = spec.builders ?? {} ?? {};
6549
+ for (const [key, builder] of Object.entries(builders)) {
6275
6550
  if (builder) {
6276
6551
  if (builder.configureSpec) {
6277
6552
  spec = await builder.configureSpec(spec);
6278
6553
  }
6554
+ if (builder.configureBaseImage) {
6555
+ spec.raw.baseImage = await builder.configureBaseImage(
6556
+ prepareBaseImageForConfigure(spec.raw.baseImage)
6557
+ );
6558
+ }
6279
6559
  if (builder.configureSnapshotSpec) {
6280
6560
  let snapshotSpec;
6281
- if (isVmSpecLike(spec.raw.snapshot)) {
6561
+ if (isVmSpecLike$1(spec.raw.snapshot)) {
6282
6562
  snapshotSpec = spec.raw.snapshot;
6283
6563
  } else {
6284
- snapshotSpec = new VmSpec({});
6564
+ const inheritedDiscriminator = spec.getBuilderDiscriminator(key) ?? spec.raw.discriminator;
6565
+ snapshotSpec = inheritedDiscriminator !== void 0 ? new VmSpec({ discriminator: inheritedDiscriminator }) : new VmSpec({});
6285
6566
  spec.raw.snapshot = snapshotSpec;
6286
6567
  }
6287
6568
  spec.raw.snapshot = await builder.configureSnapshotSpec(snapshotSpec);
6288
6569
  }
6289
6570
  }
6290
6571
  }
6291
- if (isVmSpecLike(spec.raw.snapshot)) {
6572
+ if (isVmSpecLike$1(spec.raw.snapshot)) {
6292
6573
  spec.raw.snapshot = await processSpecTree(spec.raw.snapshot);
6293
6574
  }
6294
6575
  return spec;
6295
6576
  }
6296
6577
  function collectSpecBuilders(spec) {
6297
6578
  let builders = {};
6298
- if (isVmSpecLike(spec.raw.snapshot)) {
6579
+ if (isVmSpecLike$1(spec.raw.snapshot)) {
6299
6580
  builders = collectSpecBuilders(spec.raw.snapshot);
6300
6581
  }
6301
- if (spec.with) {
6302
- for (const [key, builder] of Object.entries(spec.with)) {
6303
- if (builder) {
6304
- builders[key] = builder;
6305
- }
6582
+ const specBuilders = spec.builders ?? {} ?? {};
6583
+ for (const [key, builder] of Object.entries(specBuilders)) {
6584
+ if (builder) {
6585
+ builders[key] = builder;
6306
6586
  }
6307
6587
  }
6308
6588
  return builders;
@@ -6314,9 +6594,10 @@ function mergeWithBuildersIntoSpec(spec, withBuilders) {
6314
6594
  return new VmSpec({
6315
6595
  ...spec.raw,
6316
6596
  with: {
6317
- ...spec.with,
6597
+ ...spec.builders,
6318
6598
  ...withBuilders
6319
- }
6599
+ },
6600
+ __withDiscriminators: spec.getBuilderDiscriminators()
6320
6601
  });
6321
6602
  }
6322
6603
  class VmsNamespace {
@@ -6325,14 +6606,12 @@ class VmsNamespace {
6325
6606
  this.snapshots = new VmSnapshotsNamespace(freestyle._apiClient);
6326
6607
  }
6327
6608
  snapshots;
6328
- /**
6329
- * Create a new VM.
6330
- * @param options Optional VM configuration
6331
- * @returns A VM instance representing the created VM
6332
- */
6333
6609
  async create(options = {}) {
6334
- if (isVmSpecLike(options.snapshot)) {
6335
- if (isVmSpecLike(options.spec)) {
6610
+ if (isVmSpecLike$1(options)) {
6611
+ options = { spec: options };
6612
+ }
6613
+ if (isVmSpecLike$1(options.snapshot)) {
6614
+ if (isVmSpecLike$1(options.spec)) {
6336
6615
  if (!options.spec.raw.snapshot) {
6337
6616
  options.spec.raw.snapshot = options.snapshot;
6338
6617
  }
@@ -6341,20 +6620,22 @@ class VmsNamespace {
6341
6620
  }
6342
6621
  }
6343
6622
  if (options.systemd?.services) {
6344
- const normalizedServices = options.systemd.services.map((service) => {
6345
- return {
6346
- ...service,
6347
- after: service.after?.map(
6348
- (s) => s.includes(".") ? s : `${s}.service`
6349
- ),
6350
- requires: service.requires?.map(
6351
- (s) => s.includes(".") ? s : `${s}.service`
6352
- ),
6353
- wantedBy: service.wantedBy?.map(
6354
- (s) => s.includes(".") ? s : `${s}.service`
6355
- )
6356
- };
6357
- });
6623
+ const normalizedServices = options.systemd.services.map(
6624
+ (service) => {
6625
+ return {
6626
+ ...service,
6627
+ after: service.after?.map(
6628
+ (s) => s.includes(".") ? s : `${s}.service`
6629
+ ),
6630
+ requires: service.requires?.map(
6631
+ (s) => s.includes(".") ? s : `${s}.service`
6632
+ ),
6633
+ wantedBy: service.wantedBy?.map(
6634
+ (s) => s.includes(".") ? s : `${s}.service`
6635
+ )
6636
+ };
6637
+ }
6638
+ );
6358
6639
  const { services: processedServices, additionalFiles: bashFiles } = processSystemdServices(
6359
6640
  normalizedServices,
6360
6641
  options.additionalFiles ?? {}
@@ -6382,10 +6663,10 @@ class VmsNamespace {
6382
6663
  const { snapshot: _snapshot, ...rest } = options;
6383
6664
  options = rest;
6384
6665
  }
6385
- if (isVmSpecLike(options.spec) && options.with) {
6666
+ if (isVmSpecLike$1(options.spec) && options.with) {
6386
6667
  options.spec = mergeWithBuildersIntoSpec(options.spec, options.with);
6387
6668
  }
6388
- if (isVmSpecLike(options.spec)) {
6669
+ if (isVmSpecLike$1(options.spec)) {
6389
6670
  let spec = options.spec;
6390
6671
  spec = await processOuterSpecBuilders(spec);
6391
6672
  const { snapshot, ...outerSpecOptions } = spec.raw;
@@ -6401,11 +6682,13 @@ class VmsNamespace {
6401
6682
  ...options,
6402
6683
  ...mergedOptions
6403
6684
  };
6404
- if (!options.with && spec.with) {
6405
- options.with = spec.with;
6685
+ if (!options.with && spec.builders) {
6686
+ options.with = spec.builders;
6406
6687
  }
6407
6688
  }
6408
- const specBuilders = isVmSpecLike(options.spec) ? collectSpecBuilders(options.spec) : void 0;
6689
+ const specBuilders = isVmSpecLike$1(
6690
+ options.spec
6691
+ ) ? collectSpecBuilders(options.spec) : void 0;
6409
6692
  const templateBuilders = isVmTemplateLike(options.template) ? options.template.with : void 0;
6410
6693
  const builders = {
6411
6694
  ...templateBuilders || {},
@@ -6467,10 +6750,17 @@ class VmsNamespace {
6467
6750
  );
6468
6751
  }
6469
6752
  config.git = normalizeGitOptions(config.git);
6753
+ const serializedBaseImage = normalizeBaseImage(config.baseImage)?.toRaw();
6754
+ const rawTemplate = isVmTemplateLike(config.template) ? config.template.raw : config.template;
6755
+ const requestTemplate = serializedBaseImage ? {
6756
+ ...rawTemplate ?? {},
6757
+ baseImage: serializedBaseImage
6758
+ } : rawTemplate;
6759
+ const { baseImage: _baseImage, template: _template, ...requestConfig } = config;
6470
6760
  const response = await this.freestyle._apiClient.post("/v1/vms", {
6471
6761
  body: {
6472
- ...config,
6473
- template: isVmTemplateLike(config.template) ? config.template["raw"] : config.template,
6762
+ ...requestConfig,
6763
+ template: requestTemplate,
6474
6764
  // Cast systemd since we've processed SystemdServiceInput[] to RawSystemdService[]
6475
6765
  systemd: config.systemd,
6476
6766
  // Normalize git options - default config to {}
@@ -6487,6 +6777,7 @@ class VmsNamespace {
6487
6777
  if (builder) {
6488
6778
  const instance = builder.createInstance();
6489
6779
  instance._init(vm);
6780
+ vm._attachWith(key, instance);
6490
6781
  vm[key] = instance;
6491
6782
  }
6492
6783
  }
@@ -6525,6 +6816,7 @@ class VmsNamespace {
6525
6816
  if (builder) {
6526
6817
  const instance = builder.createInstance();
6527
6818
  instance._init(vm);
6819
+ vm._attachWith(key, instance);
6528
6820
  vm[key] = instance;
6529
6821
  }
6530
6822
  }
@@ -6545,6 +6837,7 @@ class VmsNamespace {
6545
6837
  if (builder) {
6546
6838
  const instance = builder.createInstance();
6547
6839
  instance._init(vm);
6840
+ vm._attachWith(key, instance);
6548
6841
  vm[key] = instance;
6549
6842
  }
6550
6843
  }
@@ -6565,14 +6858,44 @@ function enhanceError(e) {
6565
6858
  }
6566
6859
  return e;
6567
6860
  }
6861
+ function defaultVmWithName(builder) {
6862
+ if (builder.defaultField) {
6863
+ return builder.defaultField;
6864
+ }
6865
+ const constructorWithDefaults = builder.constructor;
6866
+ if (constructorWithDefaults.defaultField) {
6867
+ return constructorWithDefaults.defaultField;
6868
+ }
6869
+ if (constructorWithDefaults.defaultName) {
6870
+ return constructorWithDefaults.defaultName;
6871
+ }
6872
+ const className = constructorWithDefaults.name ?? "";
6873
+ const stripped = className.startsWith("Vm") ? className.slice(2) : className;
6874
+ return stripped ? stripped.toLowerCase() : "with";
6875
+ }
6876
+ function normalizeBaseImage(image) {
6877
+ if (!image) return void 0;
6878
+ if (image instanceof VmBaseImage) return image;
6879
+ return new VmBaseImage(image);
6880
+ }
6881
+ function prepareBaseImageForConfigure(image) {
6882
+ const normalized = normalizeBaseImage(image);
6883
+ if (!normalized) {
6884
+ return new VmBaseImage(DEFAULT_CONFIGURE_BASE_IMAGE);
6885
+ }
6886
+ if (normalized.hasFromInstruction()) {
6887
+ return normalized;
6888
+ }
6889
+ return new VmBaseImage(DEFAULT_CONFIGURE_BASE_IMAGE).from(normalized);
6890
+ }
6568
6891
  class VmSnapshotsNamespace {
6569
6892
  constructor(apiClient) {
6570
6893
  this.apiClient = apiClient;
6571
6894
  }
6572
6895
  async ensure(options) {
6573
6896
  let requestOptions = options;
6574
- if (isVmSpecLike(requestOptions.snapshot)) {
6575
- if (isVmSpecLike(requestOptions.spec)) {
6897
+ if (isVmSpecLike$1(requestOptions.snapshot)) {
6898
+ if (isVmSpecLike$1(requestOptions.spec)) {
6576
6899
  if (!requestOptions.spec.raw.snapshot) {
6577
6900
  requestOptions.spec.raw.snapshot = requestOptions.snapshot;
6578
6901
  }
@@ -6584,7 +6907,7 @@ class VmSnapshotsNamespace {
6584
6907
  const { snapshot: _snapshot, ...rest } = requestOptions;
6585
6908
  requestOptions = rest;
6586
6909
  }
6587
- if (isVmSpecLike(requestOptions.spec)) {
6910
+ if (isVmSpecLike$1(requestOptions.spec)) {
6588
6911
  let spec = requestOptions.spec;
6589
6912
  spec = await processSpecTree(spec);
6590
6913
  const { snapshot: _snapshotSpec, ...outerSpecOptions } = spec.raw;
@@ -6592,7 +6915,7 @@ class VmSnapshotsNamespace {
6592
6915
  requestOptions.template = new VmTemplate({
6593
6916
  ...outerSpecOptions,
6594
6917
  template: innerTemplate,
6595
- with: spec.with
6918
+ with: spec.builders
6596
6919
  });
6597
6920
  }
6598
6921
  if ("spec" in requestOptions) {
@@ -6628,6 +6951,11 @@ class VmSnapshotsNamespace {
6628
6951
  }
6629
6952
  }
6630
6953
  async function processTemplateTree(template) {
6954
+ if (template.raw.baseImage) {
6955
+ template.raw.baseImage = normalizeBaseImage(
6956
+ template.raw.baseImage
6957
+ )?.toRaw();
6958
+ }
6631
6959
  if (template.raw.git) {
6632
6960
  template.raw.git = normalizeGitOptions(
6633
6961
  template.raw.git
@@ -6659,6 +6987,11 @@ async function processTemplateTree(template) {
6659
6987
  template
6660
6988
  );
6661
6989
  }
6990
+ if (builder.configureBaseImage) {
6991
+ template.raw.baseImage = await builder.configureBaseImage(
6992
+ prepareBaseImageForConfigure(template.raw.baseImage)
6993
+ );
6994
+ }
6662
6995
  if (builder.configureNestedTemplate) {
6663
6996
  let nestedTemplate;
6664
6997
  if (isVmTemplateLike(template.raw.template)) {
@@ -6673,6 +7006,11 @@ async function processTemplateTree(template) {
6673
7006
  }
6674
7007
  }
6675
7008
  }
7009
+ if (template.raw.baseImage) {
7010
+ template.raw.baseImage = normalizeBaseImage(
7011
+ template.raw.baseImage
7012
+ )?.toRaw();
7013
+ }
6676
7014
  if (template.raw.git) {
6677
7015
  template.raw.git = normalizeGitOptions(
6678
7016
  template.raw.git
@@ -6697,20 +7035,18 @@ async function processTemplateTree(template) {
6697
7035
  template.raw.additionalFiles = bashFiles;
6698
7036
  }
6699
7037
  if (template.raw.systemd?.patchedServices) {
6700
- template.raw.systemd.patchedServices = template.raw.systemd.patchedServices.map(
6701
- (service) => ({
6702
- ...service,
6703
- after: service.after?.map(
6704
- (s) => s.includes(".") ? s : `${s}.service`
6705
- ),
6706
- requires: service.requires?.map(
6707
- (s) => s.includes(".") ? s : `${s}.service`
6708
- ),
6709
- wantedBy: service.wantedBy?.map(
6710
- (s) => s.includes(".") ? s : `${s}.service`
6711
- )
6712
- })
6713
- );
7038
+ template.raw.systemd.patchedServices = template.raw.systemd.patchedServices.map((service) => ({
7039
+ ...service,
7040
+ after: service.after?.map(
7041
+ (s) => s.includes(".") ? s : `${s}.service`
7042
+ ),
7043
+ requires: service.requires?.map(
7044
+ (s) => s.includes(".") ? s : `${s}.service`
7045
+ ),
7046
+ wantedBy: service.wantedBy?.map(
7047
+ (s) => s.includes(".") ? s : `${s}.service`
7048
+ )
7049
+ }));
6714
7050
  }
6715
7051
  if (isVmTemplateLike(template.raw.template)) {
6716
7052
  template.raw.template = await processTemplateTree(
@@ -6729,21 +7065,18 @@ async function ensureNestedTemplates(template, snapshots) {
6729
7065
  return await layerTemplates(templates, snapshots);
6730
7066
  }
6731
7067
  async function layerTemplates(templates, snapshots) {
6732
- let lastTemplate = templates.pop();
6733
- const { snapshotId } = await snapshots.ensure({
6734
- template: lastTemplate
6735
- });
6736
- let lastSnapshotId = snapshotId;
6737
- while (templates.length > 0) {
7068
+ if (templates.length === 1) {
7069
+ return templates[0];
7070
+ }
7071
+ let lastSnapshotId = (await snapshots.ensure({ template: templates.pop() })).snapshotId;
7072
+ while (templates.length > 1) {
6738
7073
  const template = templates.pop();
6739
7074
  template.raw.snapshotId = lastSnapshotId;
6740
- const { snapshotId: snapshotId2 } = await snapshots.ensure({
6741
- template
6742
- });
6743
- lastSnapshotId = snapshotId2;
6744
- lastTemplate = template;
7075
+ lastSnapshotId = (await snapshots.ensure({ template })).snapshotId;
6745
7076
  }
6746
- return lastTemplate;
7077
+ const outermost = templates.pop();
7078
+ outermost.raw.snapshotId = lastSnapshotId;
7079
+ return outermost;
6747
7080
  }
6748
7081
  function linuxUsernameHeader(linux_username) {
6749
7082
  return linux_username ? { "X-Freestyle-Vm-Linux-User-Id": linux_username } : void 0;
@@ -6908,7 +7241,8 @@ async function readFiles(directory) {
6908
7241
  return files;
6909
7242
  }
6910
7243
 
6911
- async function debugCreateRequests(freestyle, options = {}) {
7244
+ async function debugCreateRequests(freestyle, optionsOrSpec = {}) {
7245
+ const options = isVmSpecLike(optionsOrSpec) ? { spec: optionsOrSpec } : optionsOrSpec;
6912
7246
  const requests = [];
6913
7247
  let snapshotCounter = 0;
6914
7248
  let vmCounter = 0;
@@ -6952,6 +7286,9 @@ async function debugCreateRequests(freestyle, options = {}) {
6952
7286
  }
6953
7287
  return requests;
6954
7288
  }
7289
+ function isVmSpecLike(value) {
7290
+ return !!value && typeof value === "object" && "raw" in value && "with" in value;
7291
+ }
6955
7292
 
6956
7293
  class Freestyle {
6957
7294
  /**
@@ -7000,7 +7337,9 @@ class Freestyle {
7000
7337
  async whoami() {
7001
7338
  const response = await this._apiClient.fetch("/auth/v1/whoami");
7002
7339
  if (!response.ok) {
7003
- throw new Error(`Failed to get whoami: ${response.status} ${await response.text()}`);
7340
+ throw new Error(
7341
+ `Failed to get whoami: ${response.status} ${await response.text()}`
7342
+ );
7004
7343
  }
7005
7344
  return response.json();
7006
7345
  }
@@ -7042,6 +7381,7 @@ exports.Identity = Identity;
7042
7381
  exports.Systemd = Systemd;
7043
7382
  exports.SystemdService = SystemdService;
7044
7383
  exports.Vm = Vm;
7384
+ exports.VmBaseImage = VmBaseImage;
7045
7385
  exports.VmBuilder = VmBuilder;
7046
7386
  exports.VmService = VmService;
7047
7387
  exports.VmSpec = VmSpec;