freestyle-sandboxes 0.1.5 → 0.1.7

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 (5) hide show
  1. package/index.cjs +1009 -809
  2. package/index.d.cts +824 -663
  3. package/index.d.mts +824 -663
  4. package/index.mjs +1009 -810
  5. package/package.json +1 -1
package/index.cjs CHANGED
@@ -20,29 +20,65 @@ class GitErrorError extends Error {
20
20
  static statusCode = 500;
21
21
  static description = `{message}`;
22
22
  }
23
- class SnapshotVmBadRequestError extends Error {
23
+ class InternalErrorError extends Error {
24
24
  constructor(body) {
25
25
  super(
26
- `SNAPSHOT_VM_BAD_REQUEST: ${body.message}`
26
+ `INTERNAL_ERROR: ${body.message}`
27
27
  );
28
28
  this.body = body;
29
- this.name = "SnapshotVmBadRequestError";
29
+ this.name = "InternalErrorError";
30
30
  }
31
- static code = "SNAPSHOT_VM_BAD_REQUEST";
31
+ static code = "INTERNAL_ERROR";
32
+ static statusCode = 500;
33
+ static description = `Internal error: {message}`;
34
+ }
35
+ class DockerImportBadRequestError extends Error {
36
+ constructor(body) {
37
+ super(
38
+ `DOCKER_IMPORT_BAD_REQUEST: ${body.message}`
39
+ );
40
+ this.body = body;
41
+ this.name = "DockerImportBadRequestError";
42
+ }
43
+ static code = "DOCKER_IMPORT_BAD_REQUEST";
32
44
  static statusCode = 400;
33
45
  static description = `Bad request: {message}`;
34
46
  }
35
- class InternalErrorError extends Error {
47
+ class VmOperationDeniedDuringTransactionError extends Error {
36
48
  constructor(body) {
37
49
  super(
38
- `INTERNAL_ERROR: ${body.message}`
50
+ `VM_OPERATION_DENIED_DURING_TRANSACTION: ${body.message}`
39
51
  );
40
52
  this.body = body;
41
- this.name = "InternalErrorError";
53
+ this.name = "VmOperationDeniedDuringTransactionError";
42
54
  }
43
- static code = "INTERNAL_ERROR";
44
- static statusCode = 500;
45
- static description = `Internal error: {message}`;
55
+ static code = "VM_OPERATION_DENIED_DURING_TRANSACTION";
56
+ static statusCode = 409;
57
+ static description = `VM operation denied during active transaction for VM {vm_id} in transaction {transaction_id}`;
58
+ }
59
+ class VmTransactionIdMismatchError extends Error {
60
+ constructor(body) {
61
+ super(
62
+ `VM_TRANSACTION_ID_MISMATCH: ${body.message}`
63
+ );
64
+ this.body = body;
65
+ this.name = "VmTransactionIdMismatchError";
66
+ }
67
+ static code = "VM_TRANSACTION_ID_MISMATCH";
68
+ static statusCode = 400;
69
+ static description = `Transaction ID {provided_transaction_id} does not match the current VM transaction {expected_transaction_id} for VM {vm_id}`;
70
+ }
71
+ class VmNotInTransactionError extends Error {
72
+ constructor(body) {
73
+ super(
74
+ `VM_NOT_IN_TRANSACTION: ${body.message}`
75
+ );
76
+ this.body = body;
77
+ this.name = "VmNotInTransactionError";
78
+ }
79
+ static code = "VM_NOT_IN_TRANSACTION";
80
+ static statusCode = 404;
81
+ static description = `VM not in a transaction: {vm_id}`;
46
82
  }
47
83
  class ForkVmNotFoundError extends Error {
48
84
  constructor(body) {
@@ -68,6 +104,18 @@ class CreateSnapshotBadRequestError extends Error {
68
104
  static statusCode = 400;
69
105
  static description = `Bad request: {message}`;
70
106
  }
107
+ class SnapshotVmBadRequestError extends Error {
108
+ constructor(body) {
109
+ super(
110
+ `SNAPSHOT_VM_BAD_REQUEST: ${body.message}`
111
+ );
112
+ this.body = body;
113
+ this.name = "SnapshotVmBadRequestError";
114
+ }
115
+ static code = "SNAPSHOT_VM_BAD_REQUEST";
116
+ static statusCode = 400;
117
+ static description = `Bad request: {message}`;
118
+ }
71
119
  class VmDeletedError extends Error {
72
120
  constructor(body) {
73
121
  super(
@@ -200,42 +248,6 @@ class FilesBadRequestError extends Error {
200
248
  static statusCode = 400;
201
249
  static description = `Bad request: {message}`;
202
250
  }
203
- class VmMustBeStoppedError extends Error {
204
- constructor(body) {
205
- super(
206
- `VM_MUST_BE_STOPPED: ${body.message}`
207
- );
208
- this.body = body;
209
- this.name = "VmMustBeStoppedError";
210
- }
211
- static code = "VM_MUST_BE_STOPPED";
212
- static statusCode = 400;
213
- static description = `VM must be stopped before converting to base`;
214
- }
215
- class AlreadyHasBaseError extends Error {
216
- constructor(body) {
217
- super(
218
- `ALREADY_HAS_BASE: ${body.message}`
219
- );
220
- this.body = body;
221
- this.name = "AlreadyHasBaseError";
222
- }
223
- static code = "ALREADY_HAS_BASE";
224
- static statusCode = 400;
225
- static description = `VM already has a base rootfs`;
226
- }
227
- class NotFoundError extends Error {
228
- constructor(body) {
229
- super(
230
- `NOT_FOUND: ${body.message}`
231
- );
232
- this.body = body;
233
- this.name = "NotFoundError";
234
- }
235
- static code = "NOT_FOUND";
236
- static statusCode = 404;
237
- static description = `VM not found`;
238
- }
239
251
  class VmNotFoundInFsError extends Error {
240
252
  constructor(body) {
241
253
  super(
@@ -308,53 +320,41 @@ class InternalVmNotFoundError extends Error {
308
320
  static statusCode = 404;
309
321
  static description = `VM not found: {vm_id}`;
310
322
  }
311
- class DockerImportBadRequestError extends Error {
323
+ class VmMustBeStoppedError extends Error {
312
324
  constructor(body) {
313
325
  super(
314
- `DOCKER_IMPORT_BAD_REQUEST: ${body.message}`
326
+ `VM_MUST_BE_STOPPED: ${body.message}`
315
327
  );
316
328
  this.body = body;
317
- this.name = "DockerImportBadRequestError";
329
+ this.name = "VmMustBeStoppedError";
318
330
  }
319
- static code = "DOCKER_IMPORT_BAD_REQUEST";
331
+ static code = "VM_MUST_BE_STOPPED";
320
332
  static statusCode = 400;
321
- static description = `Bad request: {message}`;
322
- }
323
- class VmOperationDeniedDuringTransactionError extends Error {
324
- constructor(body) {
325
- super(
326
- `VM_OPERATION_DENIED_DURING_TRANSACTION: ${body.message}`
327
- );
328
- this.body = body;
329
- this.name = "VmOperationDeniedDuringTransactionError";
330
- }
331
- static code = "VM_OPERATION_DENIED_DURING_TRANSACTION";
332
- static statusCode = 409;
333
- static description = `VM operation denied during active transaction for VM {vm_id} in transaction {transaction_id}`;
333
+ static description = `VM must be stopped before converting to base`;
334
334
  }
335
- class VmTransactionIdMismatchError extends Error {
335
+ class AlreadyHasBaseError extends Error {
336
336
  constructor(body) {
337
337
  super(
338
- `VM_TRANSACTION_ID_MISMATCH: ${body.message}`
338
+ `ALREADY_HAS_BASE: ${body.message}`
339
339
  );
340
340
  this.body = body;
341
- this.name = "VmTransactionIdMismatchError";
341
+ this.name = "AlreadyHasBaseError";
342
342
  }
343
- static code = "VM_TRANSACTION_ID_MISMATCH";
343
+ static code = "ALREADY_HAS_BASE";
344
344
  static statusCode = 400;
345
- static description = `Transaction ID {provided_transaction_id} does not match the current VM transaction {expected_transaction_id} for VM {vm_id}`;
345
+ static description = `VM already has a base rootfs`;
346
346
  }
347
- class VmNotInTransactionError extends Error {
347
+ class NotFoundError extends Error {
348
348
  constructor(body) {
349
349
  super(
350
- `VM_NOT_IN_TRANSACTION: ${body.message}`
350
+ `NOT_FOUND: ${body.message}`
351
351
  );
352
352
  this.body = body;
353
- this.name = "VmNotInTransactionError";
353
+ this.name = "NotFoundError";
354
354
  }
355
- static code = "VM_NOT_IN_TRANSACTION";
355
+ static code = "NOT_FOUND";
356
356
  static statusCode = 404;
357
- static description = `VM not in a transaction: {vm_id}`;
357
+ static description = `VM not found`;
358
358
  }
359
359
  class CreateVmBadRequestError extends Error {
360
360
  constructor(body) {
@@ -776,6 +776,30 @@ class RepoNotFoundError extends Error {
776
776
  static statusCode = 404;
777
777
  static description = `Repository not found: {repo_id}`;
778
778
  }
779
+ class RuntimeErrorError extends Error {
780
+ constructor(body) {
781
+ super(
782
+ `RUNTIME_ERROR: ${body.message}`
783
+ );
784
+ this.body = body;
785
+ this.name = "RuntimeErrorError";
786
+ }
787
+ static code = "RUNTIME_ERROR";
788
+ static statusCode = 500;
789
+ static description = `The script execution resulted in a runtime error: {message}`;
790
+ }
791
+ class SyntaxErrorError extends Error {
792
+ constructor(body) {
793
+ super(
794
+ `SYNTAX_ERROR: ${body.message}`
795
+ );
796
+ this.body = body;
797
+ this.name = "SyntaxErrorError";
798
+ }
799
+ static code = "SYNTAX_ERROR";
800
+ static statusCode = 503;
801
+ static description = `The provided script has a syntax error: {message}`;
802
+ }
779
803
  class InternalError extends Error {
780
804
  constructor(body) {
781
805
  super(
@@ -848,53 +872,53 @@ class ExpiredError extends Error {
848
872
  static statusCode = 403;
849
873
  static description = `Session has expired`;
850
874
  }
851
- class ConflictError extends Error {
875
+ class ForbiddenError extends Error {
852
876
  constructor(body) {
853
877
  super(
854
- `CONFLICT: ${body.message}`
878
+ `FORBIDDEN: ${body.message}`
855
879
  );
856
880
  this.body = body;
857
- this.name = "ConflictError";
881
+ this.name = "ForbiddenError";
858
882
  }
859
- static code = "CONFLICT";
860
- static statusCode = 409;
861
- static description = `Sync conflict: {message}`;
883
+ static code = "FORBIDDEN";
884
+ static statusCode = 403;
885
+ static description = `You do not have permission to push to this repository`;
862
886
  }
863
- class BranchNotFoundError extends Error {
887
+ class UnauthorizedError extends Error {
864
888
  constructor(body) {
865
889
  super(
866
- `BRANCH_NOT_FOUND: ${body.message}`
890
+ `UNAUTHORIZED: ${body.message}`
867
891
  );
868
892
  this.body = body;
869
- this.name = "BranchNotFoundError";
893
+ this.name = "UnauthorizedError";
870
894
  }
871
- static code = "BRANCH_NOT_FOUND";
872
- static statusCode = 404;
873
- static description = `Branch not found: {branch}`;
895
+ static code = "UNAUTHORIZED";
896
+ static statusCode = 401;
897
+ static description = `Unauthorized`;
874
898
  }
875
- class SendErrorError extends Error {
899
+ class InvalidServiceError extends Error {
876
900
  constructor(body) {
877
901
  super(
878
- `SEND_ERROR: ${body.message}`
902
+ `INVALID_SERVICE: ${body.message}`
879
903
  );
880
904
  this.body = body;
881
- this.name = "SendErrorError";
905
+ this.name = "InvalidServiceError";
882
906
  }
883
- static code = "SEND_ERROR";
884
- static statusCode = 500;
885
- static description = `Stream receiver dropped`;
907
+ static code = "INVALID_SERVICE";
908
+ static statusCode = 403;
909
+ static description = `Invalid service '{invalid}', expected 'git-upload-pack' or 'git-receive-pack'`;
886
910
  }
887
- class ForbiddenError extends Error {
911
+ class ExpectedServiceError extends Error {
888
912
  constructor(body) {
889
913
  super(
890
- `FORBIDDEN: ${body.message}`
914
+ `EXPECTED_SERVICE: ${body.message}`
891
915
  );
892
916
  this.body = body;
893
- this.name = "ForbiddenError";
917
+ this.name = "ExpectedServiceError";
894
918
  }
895
- static code = "FORBIDDEN";
919
+ static code = "EXPECTED_SERVICE";
896
920
  static statusCode = 403;
897
- static description = `Forbidden: {message}`;
921
+ static description = `Expected 'service' query parameter`;
898
922
  }
899
923
  class UnsupportedTransferError extends Error {
900
924
  constructor(body) {
@@ -908,113 +932,113 @@ class UnsupportedTransferError extends Error {
908
932
  static statusCode = 400;
909
933
  static description = `Unsupported LFS transfer protocol(s)`;
910
934
  }
911
- class ReferenceNotFoundError extends Error {
935
+ class ConflictError extends Error {
912
936
  constructor(body) {
913
937
  super(
914
- `REFERENCE_NOT_FOUND: ${body.message}`
938
+ `CONFLICT: ${body.message}`
915
939
  );
916
940
  this.body = body;
917
- this.name = "ReferenceNotFoundError";
941
+ this.name = "ConflictError";
918
942
  }
919
- static code = "REFERENCE_NOT_FOUND";
920
- static statusCode = 404;
921
- static description = `Reference not found: {reference}`;
943
+ static code = "CONFLICT";
944
+ static statusCode = 409;
945
+ static description = `Sync conflict: {message}`;
922
946
  }
923
- class InvalidRangeError extends Error {
947
+ class BranchNotFoundError extends Error {
924
948
  constructor(body) {
925
949
  super(
926
- `INVALID_RANGE: ${body.message}`
950
+ `BRANCH_NOT_FOUND: ${body.message}`
927
951
  );
928
952
  this.body = body;
929
- this.name = "InvalidRangeError";
953
+ this.name = "BranchNotFoundError";
930
954
  }
931
- static code = "INVALID_RANGE";
932
- static statusCode = 400;
933
- 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.`;
955
+ static code = "BRANCH_NOT_FOUND";
956
+ static statusCode = 404;
957
+ static description = `Branch not found: {branch}`;
934
958
  }
935
- class OffsetWithSelectorError extends Error {
959
+ class SourceImportConflictError extends Error {
936
960
  constructor(body) {
937
961
  super(
938
- `OFFSET_WITH_SELECTOR: ${body.message}`
962
+ `SOURCE_IMPORT_CONFLICT: ${body.message}`
939
963
  );
940
964
  this.body = body;
941
- this.name = "OffsetWithSelectorError";
965
+ this.name = "SourceImportConflictError";
942
966
  }
943
- static code = "OFFSET_WITH_SELECTOR";
967
+ static code = "SOURCE_IMPORT_CONFLICT";
944
968
  static statusCode = 400;
945
- static description = `Cannot use 'offset' parameter together with 'since' or 'until'. Use 'since' for cursor-based pagination.`;
969
+ static description = `Source and import are mutually exclusive`;
946
970
  }
947
- class CommitNotInBranchError extends Error {
971
+ class SourceUnauthorizedError extends Error {
948
972
  constructor(body) {
949
973
  super(
950
- `COMMIT_NOT_IN_BRANCH: ${body.message}`
974
+ `SOURCE_UNAUTHORIZED: ${body.message}`
951
975
  );
952
976
  this.body = body;
953
- this.name = "CommitNotInBranchError";
977
+ this.name = "SourceUnauthorizedError";
954
978
  }
955
- static code = "COMMIT_NOT_IN_BRANCH";
979
+ static code = "SOURCE_UNAUTHORIZED";
956
980
  static statusCode = 400;
957
- static description = `Commit {sha} is not in the history of branch {branch}`;
981
+ static description = `Unauthorized to access source repository at {url}`;
958
982
  }
959
- class CommitNotFoundError extends Error {
983
+ class SourceNotFoundError extends Error {
960
984
  constructor(body) {
961
985
  super(
962
- `COMMIT_NOT_FOUND: ${body.message}`
986
+ `SOURCE_NOT_FOUND: ${body.message}`
963
987
  );
964
988
  this.body = body;
965
- this.name = "CommitNotFoundError";
989
+ this.name = "SourceNotFoundError";
966
990
  }
967
- static code = "COMMIT_NOT_FOUND";
991
+ static code = "SOURCE_NOT_FOUND";
968
992
  static statusCode = 400;
969
- static description = `Commit not found: {sha}`;
993
+ static description = `Source repository not found at {url}`;
970
994
  }
971
- class BlobNotFoundError extends Error {
995
+ class ImportSubdirNotFoundError extends Error {
972
996
  constructor(body) {
973
997
  super(
974
- `BLOB_NOT_FOUND: ${body.message}`
998
+ `IMPORT_SUBDIR_NOT_FOUND: ${body.message}`
975
999
  );
976
1000
  this.body = body;
977
- this.name = "BlobNotFoundError";
1001
+ this.name = "ImportSubdirNotFoundError";
978
1002
  }
979
- static code = "BLOB_NOT_FOUND";
980
- static statusCode = 404;
981
- static description = `Blob not found: {hash}`;
1003
+ static code = "IMPORT_SUBDIR_NOT_FOUND";
1004
+ static statusCode = 400;
1005
+ static description = `Directory not found in {source}: {dir}`;
982
1006
  }
983
- class TreeNotFoundError extends Error {
1007
+ class RepoAlreadyExistsError extends Error {
984
1008
  constructor(body) {
985
1009
  super(
986
- `TREE_NOT_FOUND: ${body.message}`
1010
+ `REPO_ALREADY_EXISTS: ${body.message}`
987
1011
  );
988
1012
  this.body = body;
989
- this.name = "TreeNotFoundError";
1013
+ this.name = "RepoAlreadyExistsError";
990
1014
  }
991
- static code = "TREE_NOT_FOUND";
992
- static statusCode = 404;
993
- static description = `Tree not found: {hash}`;
1015
+ static code = "REPO_ALREADY_EXISTS";
1016
+ static statusCode = 409;
1017
+ static description = `Repo '{repo_id}' already exists`;
994
1018
  }
995
- class InvalidRevisionError extends Error {
1019
+ class PathNotFoundError extends Error {
996
1020
  constructor(body) {
997
1021
  super(
998
- `INVALID_REVISION: ${body.message}`
1022
+ `PATH_NOT_FOUND: ${body.message}`
999
1023
  );
1000
1024
  this.body = body;
1001
- this.name = "InvalidRevisionError";
1025
+ this.name = "PathNotFoundError";
1002
1026
  }
1003
- static code = "INVALID_REVISION";
1004
- static statusCode = 400;
1005
- static description = `Invalid revision: {revision}`;
1027
+ static code = "PATH_NOT_FOUND";
1028
+ static statusCode = 404;
1029
+ static description = `Path not found: {path}`;
1006
1030
  }
1007
- class UnauthorizedError extends Error {
1031
+ class ReferenceNotFoundError extends Error {
1008
1032
  constructor(body) {
1009
1033
  super(
1010
- `UNAUTHORIZED: ${body.message}`
1034
+ `REFERENCE_NOT_FOUND: ${body.message}`
1011
1035
  );
1012
1036
  this.body = body;
1013
- this.name = "UnauthorizedError";
1037
+ this.name = "ReferenceNotFoundError";
1014
1038
  }
1015
- static code = "UNAUTHORIZED";
1016
- static statusCode = 401;
1017
- static description = `Unauthorized`;
1039
+ static code = "REFERENCE_NOT_FOUND";
1040
+ static statusCode = 404;
1041
+ static description = `Reference not found: {reference}`;
1018
1042
  }
1019
1043
  class TagNotFoundError extends Error {
1020
1044
  constructor(body) {
@@ -1026,19 +1050,19 @@ class TagNotFoundError extends Error {
1026
1050
  }
1027
1051
  static code = "TAG_NOT_FOUND";
1028
1052
  static statusCode = 404;
1029
- static description = `Tag not found: {tag}`;
1053
+ static description = `Tag not found: {hash}`;
1030
1054
  }
1031
- class RepoAlreadyExistsError extends Error {
1055
+ class SendErrorError extends Error {
1032
1056
  constructor(body) {
1033
1057
  super(
1034
- `REPO_ALREADY_EXISTS: ${body.message}`
1058
+ `SEND_ERROR: ${body.message}`
1035
1059
  );
1036
1060
  this.body = body;
1037
- this.name = "RepoAlreadyExistsError";
1061
+ this.name = "SendErrorError";
1038
1062
  }
1039
- static code = "REPO_ALREADY_EXISTS";
1040
- static statusCode = 409;
1041
- static description = `Repository {repo_id} already exists`;
1063
+ static code = "SEND_ERROR";
1064
+ static statusCode = 500;
1065
+ static description = `Stream receiver dropped`;
1042
1066
  }
1043
1067
  class GitHubSyncConflictError extends Error {
1044
1068
  constructor(body) {
@@ -1064,197 +1088,149 @@ class InvalidObjectIdError extends Error {
1064
1088
  static statusCode = 400;
1065
1089
  static description = `Invalid object ID: {hash}`;
1066
1090
  }
1067
- class SourceImportConflictError extends Error {
1091
+ class CommitNotFoundError extends Error {
1068
1092
  constructor(body) {
1069
1093
  super(
1070
- `SOURCE_IMPORT_CONFLICT: ${body.message}`
1094
+ `COMMIT_NOT_FOUND: ${body.message}`
1071
1095
  );
1072
1096
  this.body = body;
1073
- this.name = "SourceImportConflictError";
1097
+ this.name = "CommitNotFoundError";
1074
1098
  }
1075
- static code = "SOURCE_IMPORT_CONFLICT";
1076
- static statusCode = 400;
1077
- static description = `Source and import are mutually exclusive`;
1099
+ static code = "COMMIT_NOT_FOUND";
1100
+ static statusCode = 404;
1101
+ static description = `Commit {commit_hash} not found in repository {repo_id}`;
1078
1102
  }
1079
- class SourceUnauthorizedError extends Error {
1103
+ class TreeNotFoundError extends Error {
1080
1104
  constructor(body) {
1081
1105
  super(
1082
- `SOURCE_UNAUTHORIZED: ${body.message}`
1106
+ `TREE_NOT_FOUND: ${body.message}`
1083
1107
  );
1084
1108
  this.body = body;
1085
- this.name = "SourceUnauthorizedError";
1109
+ this.name = "TreeNotFoundError";
1086
1110
  }
1087
- static code = "SOURCE_UNAUTHORIZED";
1088
- static statusCode = 400;
1089
- static description = `Unauthorized to access source repository at {url}`;
1111
+ static code = "TREE_NOT_FOUND";
1112
+ static statusCode = 404;
1113
+ static description = `Tree not found: {hash}`;
1090
1114
  }
1091
- class SourceNotFoundError extends Error {
1115
+ class InvalidRevisionError extends Error {
1092
1116
  constructor(body) {
1093
1117
  super(
1094
- `SOURCE_NOT_FOUND: ${body.message}`
1118
+ `INVALID_REVISION: ${body.message}`
1095
1119
  );
1096
1120
  this.body = body;
1097
- this.name = "SourceNotFoundError";
1121
+ this.name = "InvalidRevisionError";
1098
1122
  }
1099
- static code = "SOURCE_NOT_FOUND";
1123
+ static code = "INVALID_REVISION";
1100
1124
  static statusCode = 400;
1101
- static description = `Source repository not found at {url}`;
1125
+ static description = `Invalid revision: {revision}`;
1102
1126
  }
1103
- class ImportSubdirNotFoundError extends Error {
1127
+ class InvalidRangeError extends Error {
1104
1128
  constructor(body) {
1105
1129
  super(
1106
- `IMPORT_SUBDIR_NOT_FOUND: ${body.message}`
1130
+ `INVALID_RANGE: ${body.message}`
1107
1131
  );
1108
1132
  this.body = body;
1109
- this.name = "ImportSubdirNotFoundError";
1133
+ this.name = "InvalidRangeError";
1110
1134
  }
1111
- static code = "IMPORT_SUBDIR_NOT_FOUND";
1135
+ static code = "INVALID_RANGE";
1112
1136
  static statusCode = 400;
1113
- static description = `Directory not found in {source}: {dir}`;
1114
- }
1115
- class PackfileError extends Error {
1116
- constructor(body) {
1117
- super(
1118
- `PACKFILE: ${body.message}`
1119
- );
1120
- this.body = body;
1121
- this.name = "PackfileError";
1122
- }
1123
- static code = "PACKFILE";
1124
- static statusCode = 500;
1125
- static description = `Error building packfile`;
1126
- }
1127
- class PathNotFoundError extends Error {
1128
- constructor(body) {
1129
- super(
1130
- `PATH_NOT_FOUND: ${body.message}`
1131
- );
1132
- this.body = body;
1133
- this.name = "PathNotFoundError";
1134
- }
1135
- static code = "PATH_NOT_FOUND";
1136
- static statusCode = 404;
1137
- static description = `Path not found: {path}`;
1138
- }
1139
- class InvalidServiceError extends Error {
1140
- constructor(body) {
1141
- super(
1142
- `INVALID_SERVICE: ${body.message}`
1143
- );
1144
- this.body = body;
1145
- this.name = "InvalidServiceError";
1146
- }
1147
- static code = "INVALID_SERVICE";
1148
- static statusCode = 403;
1149
- static description = `Invalid service '{invalid}', expected 'git-upload-pack' or 'git-receive-pack'`;
1150
- }
1151
- class ExpectedServiceError extends Error {
1152
- constructor(body) {
1153
- super(
1154
- `EXPECTED_SERVICE: ${body.message}`
1155
- );
1156
- this.body = body;
1157
- this.name = "ExpectedServiceError";
1158
- }
1159
- static code = "EXPECTED_SERVICE";
1160
- static statusCode = 403;
1161
- static description = `Expected 'service' query parameter`;
1137
+ 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.`;
1162
1138
  }
1163
- class DatabaseErrorError extends Error {
1139
+ class OffsetWithSelectorError extends Error {
1164
1140
  constructor(body) {
1165
1141
  super(
1166
- `DATABASE_ERROR: ${body.message}`
1142
+ `OFFSET_WITH_SELECTOR: ${body.message}`
1167
1143
  );
1168
1144
  this.body = body;
1169
- this.name = "DatabaseErrorError";
1145
+ this.name = "OffsetWithSelectorError";
1170
1146
  }
1171
- static code = "DATABASE_ERROR";
1172
- static statusCode = 500;
1173
- static description = `Database error: {0}`;
1147
+ static code = "OFFSET_WITH_SELECTOR";
1148
+ static statusCode = 400;
1149
+ static description = `Cannot use 'offset' parameter together with 'since' or 'until'. Use 'since' for cursor-based pagination.`;
1174
1150
  }
1175
- class WaitTimeoutError extends Error {
1151
+ class CommitNotInBranchError extends Error {
1176
1152
  constructor(body) {
1177
1153
  super(
1178
- `WAIT_TIMEOUT: ${body.message}`
1154
+ `COMMIT_NOT_IN_BRANCH: ${body.message}`
1179
1155
  );
1180
1156
  this.body = body;
1181
- this.name = "WaitTimeoutError";
1157
+ this.name = "CommitNotInBranchError";
1182
1158
  }
1183
- static code = "WAIT_TIMEOUT";
1184
- static statusCode = 504;
1185
- static description = `Timed out waiting for certificate validation`;
1159
+ static code = "COMMIT_NOT_IN_BRANCH";
1160
+ static statusCode = 400;
1161
+ static description = `Commit {sha} is not in the history of branch {branch}`;
1186
1162
  }
1187
- class PreVerifyChallengeMismatchError extends Error {
1163
+ class BlobNotFoundError extends Error {
1188
1164
  constructor(body) {
1189
1165
  super(
1190
- `PRE_VERIFY_CHALLENGE_MISMATCH: ${body.message}`
1166
+ `BLOB_NOT_FOUND: ${body.message}`
1191
1167
  );
1192
1168
  this.body = body;
1193
- this.name = "PreVerifyChallengeMismatchError";
1169
+ this.name = "BlobNotFoundError";
1194
1170
  }
1195
- static code = "PRE_VERIFY_CHALLENGE_MISMATCH";
1196
- static statusCode = 400;
1197
- static description = `Certificate challenge verification failed - response did not match`;
1171
+ static code = "BLOB_NOT_FOUND";
1172
+ static statusCode = 404;
1173
+ static description = `Blob not found: {hash}`;
1198
1174
  }
1199
- class PreVerifyFailedParseError extends Error {
1175
+ class AmbiguousError extends Error {
1200
1176
  constructor(body) {
1201
1177
  super(
1202
- `PRE_VERIFY_FAILED_PARSE: ${body.message}`
1178
+ `AMBIGUOUS: ${body.message}`
1203
1179
  );
1204
1180
  this.body = body;
1205
- this.name = "PreVerifyFailedParseError";
1181
+ this.name = "AmbiguousError";
1206
1182
  }
1207
- static code = "PRE_VERIFY_FAILED_PARSE";
1183
+ static code = "AMBIGUOUS";
1208
1184
  static statusCode = 400;
1209
- static description = `Invalid response from domain during certificate verification`;
1185
+ static description = `rev is ambiguous: {rev}`;
1210
1186
  }
1211
- class PreVerifyFailedFetchError extends Error {
1187
+ class InvalidError extends Error {
1212
1188
  constructor(body) {
1213
1189
  super(
1214
- `PRE_VERIFY_FAILED_FETCH: ${body.message}`
1190
+ `INVALID: ${body.message}`
1215
1191
  );
1216
1192
  this.body = body;
1217
- this.name = "PreVerifyFailedFetchError";
1193
+ this.name = "InvalidError";
1218
1194
  }
1219
- static code = "PRE_VERIFY_FAILED_FETCH";
1195
+ static code = "INVALID";
1220
1196
  static statusCode = 400;
1221
- static description = `Could not reach domain for certificate verification - check DNS settings`;
1197
+ static description = `invalid rev syntax: {rev}`;
1222
1198
  }
1223
- class PreVerifyRouteNotFoundError extends Error {
1199
+ class PackfileError extends Error {
1224
1200
  constructor(body) {
1225
1201
  super(
1226
- `PRE_VERIFY_ROUTE_NOT_FOUND: ${body.message}`
1202
+ `PACKFILE: ${body.message}`
1227
1203
  );
1228
1204
  this.body = body;
1229
- this.name = "PreVerifyRouteNotFoundError";
1205
+ this.name = "PackfileError";
1230
1206
  }
1231
- static code = "PRE_VERIFY_ROUTE_NOT_FOUND";
1232
- static statusCode = 400;
1233
- static description = `Domain does not resolve to Freestyle servers`;
1207
+ static code = "PACKFILE";
1208
+ static statusCode = 500;
1209
+ static description = `Error building packfile`;
1234
1210
  }
1235
- class AuthorizationNotFoundError extends Error {
1211
+ class DatabaseErrorError extends Error {
1236
1212
  constructor(body) {
1237
1213
  super(
1238
- `AUTHORIZATION_NOT_FOUND: ${body.message}`
1214
+ `DATABASE_ERROR: ${body.message}`
1239
1215
  );
1240
1216
  this.body = body;
1241
- this.name = "AuthorizationNotFoundError";
1217
+ this.name = "DatabaseErrorError";
1242
1218
  }
1243
- static code = "AUTHORIZATION_NOT_FOUND";
1244
- static statusCode = 404;
1245
- static description = `No authorization found for domain`;
1219
+ static code = "DATABASE_ERROR";
1220
+ static statusCode = 500;
1221
+ static description = `Database error: {0}`;
1246
1222
  }
1247
- class OrderNotFoundError extends Error {
1223
+ class EmptyTagError extends Error {
1248
1224
  constructor(body) {
1249
1225
  super(
1250
- `ORDER_NOT_FOUND: ${body.message}`
1226
+ `EMPTY_TAG: ${body.message}`
1251
1227
  );
1252
1228
  this.body = body;
1253
- this.name = "OrderNotFoundError";
1229
+ this.name = "EmptyTagError";
1254
1230
  }
1255
- static code = "ORDER_NOT_FOUND";
1256
- static statusCode = 404;
1257
- static description = `No certificate order found for domain`;
1231
+ static code = "EMPTY_TAG";
1232
+ static statusCode = 400;
1233
+ static description = `Invalid request: tag cannot be empty`;
1258
1234
  }
1259
1235
  class ResizeFailedError extends Error {
1260
1236
  constructor(body) {
@@ -1508,73 +1484,349 @@ class DevServerNotFoundError extends Error {
1508
1484
  static statusCode = 404;
1509
1485
  static description = `Dev server not found: {server_id}`;
1510
1486
  }
1511
- class ExecuteInternalErrorError extends Error {
1487
+ class AnyhowError extends Error {
1512
1488
  constructor(body) {
1513
1489
  super(
1514
- `EXECUTE_INTERNAL_ERROR: ${body.message}`
1490
+ `ANYHOW: ${body.message}`
1515
1491
  );
1516
1492
  this.body = body;
1517
- this.name = "ExecuteInternalErrorError";
1493
+ this.name = "AnyhowError";
1518
1494
  }
1519
- static code = "EXECUTE_INTERNAL_ERROR";
1495
+ static code = "ANYHOW";
1520
1496
  static statusCode = 500;
1521
- static description = `Internal error: {message}`;
1497
+ static description = `Internal server error: {0}`;
1522
1498
  }
1523
- class ExecuteAccessDeniedError extends Error {
1499
+ class BranchNameEmptyError extends Error {
1524
1500
  constructor(body) {
1525
1501
  super(
1526
- `EXECUTE_ACCESS_DENIED: ${body.message}`
1502
+ `BRANCH_NAME_EMPTY: ${body.message}`
1527
1503
  );
1528
1504
  this.body = body;
1529
- this.name = "ExecuteAccessDeniedError";
1505
+ this.name = "BranchNameEmptyError";
1530
1506
  }
1531
- static code = "EXECUTE_ACCESS_DENIED";
1532
- static statusCode = 403;
1533
- static description = `Access denied to execute run`;
1507
+ static code = "BRANCH_NAME_EMPTY";
1508
+ static statusCode = 400;
1509
+ static description = `Branch name cannot be empty`;
1534
1510
  }
1535
- class ListRunsFailedError extends Error {
1511
+ class PermissionAlreadyExistsError extends Error {
1536
1512
  constructor(body) {
1537
1513
  super(
1538
- `LIST_RUNS_FAILED: ${body.message}`
1514
+ `PERMISSION_ALREADY_EXISTS: ${body.message}`
1539
1515
  );
1540
1516
  this.body = body;
1541
- this.name = "ListRunsFailedError";
1517
+ this.name = "PermissionAlreadyExistsError";
1542
1518
  }
1543
- static code = "LIST_RUNS_FAILED";
1544
- static statusCode = 500;
1545
- static description = `Failed to list execute runs: {message}`;
1519
+ static code = "PERMISSION_ALREADY_EXISTS";
1520
+ static statusCode = 409;
1521
+ static description = `Permission already exists`;
1546
1522
  }
1547
- class ExecutionErrorError extends Error {
1523
+ class ListTokensFailedError extends Error {
1548
1524
  constructor(body) {
1549
1525
  super(
1550
- `EXECUTION_ERROR: ${body.message}`
1526
+ `LIST_TOKENS_FAILED: ${body.message}`
1551
1527
  );
1552
1528
  this.body = body;
1553
- this.name = "ExecutionErrorError";
1529
+ this.name = "ListTokensFailedError";
1554
1530
  }
1555
- static code = "EXECUTION_ERROR";
1531
+ static code = "LIST_TOKENS_FAILED";
1556
1532
  static statusCode = 500;
1557
- static description = `Script execution error: {message}`;
1533
+ static description = `Failed to list tokens: {message}`;
1558
1534
  }
1559
- class ConnectionFailedError extends Error {
1535
+ class RevokeTokenFailedError extends Error {
1560
1536
  constructor(body) {
1561
1537
  super(
1562
- `CONNECTION_FAILED: ${body.message}`
1538
+ `REVOKE_TOKEN_FAILED: ${body.message}`
1563
1539
  );
1564
1540
  this.body = body;
1565
- this.name = "ConnectionFailedError";
1541
+ this.name = "RevokeTokenFailedError";
1566
1542
  }
1567
- static code = "CONNECTION_FAILED";
1543
+ static code = "REVOKE_TOKEN_FAILED";
1568
1544
  static statusCode = 500;
1569
- static description = `Failed to connect to execute server: {message}`;
1545
+ static description = `Failed to revoke token: {message}`;
1570
1546
  }
1571
- class MetadataWriteFailedError extends Error {
1547
+ class CreateTokenFailedError extends Error {
1572
1548
  constructor(body) {
1573
1549
  super(
1574
- `METADATA_WRITE_FAILED: ${body.message}`
1550
+ `CREATE_TOKEN_FAILED: ${body.message}`
1575
1551
  );
1576
1552
  this.body = body;
1577
- this.name = "MetadataWriteFailedError";
1553
+ this.name = "CreateTokenFailedError";
1554
+ }
1555
+ static code = "CREATE_TOKEN_FAILED";
1556
+ static statusCode = 500;
1557
+ static description = `Failed to create token: {message}`;
1558
+ }
1559
+ class ListPermissionsFailedError extends Error {
1560
+ constructor(body) {
1561
+ super(
1562
+ `LIST_PERMISSIONS_FAILED: ${body.message}`
1563
+ );
1564
+ this.body = body;
1565
+ this.name = "ListPermissionsFailedError";
1566
+ }
1567
+ static code = "LIST_PERMISSIONS_FAILED";
1568
+ static statusCode = 500;
1569
+ static description = `Failed to list permissions: {message}`;
1570
+ }
1571
+ class GetPermissionFailedError extends Error {
1572
+ constructor(body) {
1573
+ super(
1574
+ `GET_PERMISSION_FAILED: ${body.message}`
1575
+ );
1576
+ this.body = body;
1577
+ this.name = "GetPermissionFailedError";
1578
+ }
1579
+ static code = "GET_PERMISSION_FAILED";
1580
+ static statusCode = 500;
1581
+ static description = `Failed to get permission: {message}`;
1582
+ }
1583
+ class UpdatePermissionFailedError extends Error {
1584
+ constructor(body) {
1585
+ super(
1586
+ `UPDATE_PERMISSION_FAILED: ${body.message}`
1587
+ );
1588
+ this.body = body;
1589
+ this.name = "UpdatePermissionFailedError";
1590
+ }
1591
+ static code = "UPDATE_PERMISSION_FAILED";
1592
+ static statusCode = 500;
1593
+ static description = `Failed to update permission: {message}`;
1594
+ }
1595
+ class RevokePermissionFailedError extends Error {
1596
+ constructor(body) {
1597
+ super(
1598
+ `REVOKE_PERMISSION_FAILED: ${body.message}`
1599
+ );
1600
+ this.body = body;
1601
+ this.name = "RevokePermissionFailedError";
1602
+ }
1603
+ static code = "REVOKE_PERMISSION_FAILED";
1604
+ static statusCode = 500;
1605
+ static description = `Failed to revoke permission: {message}`;
1606
+ }
1607
+ class GrantPermissionFailedError extends Error {
1608
+ constructor(body) {
1609
+ super(
1610
+ `GRANT_PERMISSION_FAILED: ${body.message}`
1611
+ );
1612
+ this.body = body;
1613
+ this.name = "GrantPermissionFailedError";
1614
+ }
1615
+ static code = "GRANT_PERMISSION_FAILED";
1616
+ static statusCode = 500;
1617
+ static description = `Failed to grant permission: {message}`;
1618
+ }
1619
+ class ListIdentitiesFailedError extends Error {
1620
+ constructor(body) {
1621
+ super(
1622
+ `LIST_IDENTITIES_FAILED: ${body.message}`
1623
+ );
1624
+ this.body = body;
1625
+ this.name = "ListIdentitiesFailedError";
1626
+ }
1627
+ static code = "LIST_IDENTITIES_FAILED";
1628
+ static statusCode = 500;
1629
+ static description = `Failed to list identities: {message}`;
1630
+ }
1631
+ class DeleteIdentityFailedError extends Error {
1632
+ constructor(body) {
1633
+ super(
1634
+ `DELETE_IDENTITY_FAILED: ${body.message}`
1635
+ );
1636
+ this.body = body;
1637
+ this.name = "DeleteIdentityFailedError";
1638
+ }
1639
+ static code = "DELETE_IDENTITY_FAILED";
1640
+ static statusCode = 500;
1641
+ static description = `Failed to delete identity: {message}`;
1642
+ }
1643
+ class CreateIdentityFailedError extends Error {
1644
+ constructor(body) {
1645
+ super(
1646
+ `CREATE_IDENTITY_FAILED: ${body.message}`
1647
+ );
1648
+ this.body = body;
1649
+ this.name = "CreateIdentityFailedError";
1650
+ }
1651
+ static code = "CREATE_IDENTITY_FAILED";
1652
+ static statusCode = 500;
1653
+ static description = `Failed to create identity: {message}`;
1654
+ }
1655
+ class VmPermissionNotFoundError extends Error {
1656
+ constructor(body) {
1657
+ super(
1658
+ `VM_PERMISSION_NOT_FOUND: ${body.message}`
1659
+ );
1660
+ this.body = body;
1661
+ this.name = "VmPermissionNotFoundError";
1662
+ }
1663
+ static code = "VM_PERMISSION_NOT_FOUND";
1664
+ static statusCode = 404;
1665
+ static description = `VM permission not found`;
1666
+ }
1667
+ class PermissionNotFoundError extends Error {
1668
+ constructor(body) {
1669
+ super(
1670
+ `PERMISSION_NOT_FOUND: ${body.message}`
1671
+ );
1672
+ this.body = body;
1673
+ this.name = "PermissionNotFoundError";
1674
+ }
1675
+ static code = "PERMISSION_NOT_FOUND";
1676
+ static statusCode = 404;
1677
+ static description = `Permission not found`;
1678
+ }
1679
+ class VmAccessDeniedError extends Error {
1680
+ constructor(body) {
1681
+ super(
1682
+ `VM_ACCESS_DENIED: ${body.message}`
1683
+ );
1684
+ this.body = body;
1685
+ this.name = "VmAccessDeniedError";
1686
+ }
1687
+ static code = "VM_ACCESS_DENIED";
1688
+ static statusCode = 403;
1689
+ static description = `You are not allowed to access this VM`;
1690
+ }
1691
+ class GitRepositoryAccessDeniedError extends Error {
1692
+ constructor(body) {
1693
+ super(
1694
+ `GIT_REPOSITORY_ACCESS_DENIED: ${body.message}`
1695
+ );
1696
+ this.body = body;
1697
+ this.name = "GitRepositoryAccessDeniedError";
1698
+ }
1699
+ static code = "GIT_REPOSITORY_ACCESS_DENIED";
1700
+ static statusCode = 403;
1701
+ static description = `You are not allowed to access this repository`;
1702
+ }
1703
+ class GitRepositoryNotFoundError extends Error {
1704
+ constructor(body) {
1705
+ super(
1706
+ `GIT_REPOSITORY_NOT_FOUND: ${body.message}`
1707
+ );
1708
+ this.body = body;
1709
+ this.name = "GitRepositoryNotFoundError";
1710
+ }
1711
+ static code = "GIT_REPOSITORY_NOT_FOUND";
1712
+ static statusCode = 404;
1713
+ static description = `Repository not found`;
1714
+ }
1715
+ class CannotDeleteManagedIdentityError extends Error {
1716
+ constructor(body) {
1717
+ super(
1718
+ `CANNOT_DELETE_MANAGED_IDENTITY: ${body.message}`
1719
+ );
1720
+ this.body = body;
1721
+ this.name = "CannotDeleteManagedIdentityError";
1722
+ }
1723
+ static code = "CANNOT_DELETE_MANAGED_IDENTITY";
1724
+ static statusCode = 403;
1725
+ static description = `Cannot delete managed identities`;
1726
+ }
1727
+ class CannotModifyManagedIdentityError extends Error {
1728
+ constructor(body) {
1729
+ super(
1730
+ `CANNOT_MODIFY_MANAGED_IDENTITY: ${body.message}`
1731
+ );
1732
+ this.body = body;
1733
+ this.name = "CannotModifyManagedIdentityError";
1734
+ }
1735
+ static code = "CANNOT_MODIFY_MANAGED_IDENTITY";
1736
+ static statusCode = 403;
1737
+ static description = `Cannot modify managed identities`;
1738
+ }
1739
+ class IdentityAccessDeniedError extends Error {
1740
+ constructor(body) {
1741
+ super(
1742
+ `IDENTITY_ACCESS_DENIED: ${body.message}`
1743
+ );
1744
+ this.body = body;
1745
+ this.name = "IdentityAccessDeniedError";
1746
+ }
1747
+ static code = "IDENTITY_ACCESS_DENIED";
1748
+ static statusCode = 403;
1749
+ static description = `You are not allowed to access this identity`;
1750
+ }
1751
+ class IdentityNotFoundError extends Error {
1752
+ constructor(body) {
1753
+ super(
1754
+ `IDENTITY_NOT_FOUND: ${body.message}`
1755
+ );
1756
+ this.body = body;
1757
+ this.name = "IdentityNotFoundError";
1758
+ }
1759
+ static code = "IDENTITY_NOT_FOUND";
1760
+ static statusCode = 404;
1761
+ static description = `Identity not found`;
1762
+ }
1763
+ class ExecuteInternalErrorError extends Error {
1764
+ constructor(body) {
1765
+ super(
1766
+ `EXECUTE_INTERNAL_ERROR: ${body.message}`
1767
+ );
1768
+ this.body = body;
1769
+ this.name = "ExecuteInternalErrorError";
1770
+ }
1771
+ static code = "EXECUTE_INTERNAL_ERROR";
1772
+ static statusCode = 500;
1773
+ static description = `Internal error: {message}`;
1774
+ }
1775
+ class ExecuteAccessDeniedError extends Error {
1776
+ constructor(body) {
1777
+ super(
1778
+ `EXECUTE_ACCESS_DENIED: ${body.message}`
1779
+ );
1780
+ this.body = body;
1781
+ this.name = "ExecuteAccessDeniedError";
1782
+ }
1783
+ static code = "EXECUTE_ACCESS_DENIED";
1784
+ static statusCode = 403;
1785
+ static description = `Access denied to execute run`;
1786
+ }
1787
+ class ListRunsFailedError extends Error {
1788
+ constructor(body) {
1789
+ super(
1790
+ `LIST_RUNS_FAILED: ${body.message}`
1791
+ );
1792
+ this.body = body;
1793
+ this.name = "ListRunsFailedError";
1794
+ }
1795
+ static code = "LIST_RUNS_FAILED";
1796
+ static statusCode = 500;
1797
+ static description = `Failed to list execute runs: {message}`;
1798
+ }
1799
+ class ExecutionErrorError extends Error {
1800
+ constructor(body) {
1801
+ super(
1802
+ `EXECUTION_ERROR: ${body.message}`
1803
+ );
1804
+ this.body = body;
1805
+ this.name = "ExecutionErrorError";
1806
+ }
1807
+ static code = "EXECUTION_ERROR";
1808
+ static statusCode = 500;
1809
+ static description = `Script execution error: {message}`;
1810
+ }
1811
+ class ConnectionFailedError extends Error {
1812
+ constructor(body) {
1813
+ super(
1814
+ `CONNECTION_FAILED: ${body.message}`
1815
+ );
1816
+ this.body = body;
1817
+ this.name = "ConnectionFailedError";
1818
+ }
1819
+ static code = "CONNECTION_FAILED";
1820
+ static statusCode = 500;
1821
+ static description = `Failed to connect to execute server: {message}`;
1822
+ }
1823
+ class MetadataWriteFailedError extends Error {
1824
+ constructor(body) {
1825
+ super(
1826
+ `METADATA_WRITE_FAILED: ${body.message}`
1827
+ );
1828
+ this.body = body;
1829
+ this.name = "MetadataWriteFailedError";
1578
1830
  }
1579
1831
  static code = "METADATA_WRITE_FAILED";
1580
1832
  static statusCode = 500;
@@ -1676,42 +1928,6 @@ class RunNotFoundError extends Error {
1676
1928
  static statusCode = 404;
1677
1929
  static description = `Execute run not found: {run_id}`;
1678
1930
  }
1679
- class EmptyTagError extends Error {
1680
- constructor(body) {
1681
- super(
1682
- `EMPTY_TAG: ${body.message}`
1683
- );
1684
- this.body = body;
1685
- this.name = "EmptyTagError";
1686
- }
1687
- static code = "EMPTY_TAG";
1688
- static statusCode = 400;
1689
- static description = `Invalid request: tag cannot be empty`;
1690
- }
1691
- class AnyhowError extends Error {
1692
- constructor(body) {
1693
- super(
1694
- `ANYHOW: ${body.message}`
1695
- );
1696
- this.body = body;
1697
- this.name = "AnyhowError";
1698
- }
1699
- static code = "ANYHOW";
1700
- static statusCode = 500;
1701
- static description = `Internal server error: {0}`;
1702
- }
1703
- class BranchNameEmptyError extends Error {
1704
- constructor(body) {
1705
- super(
1706
- `BRANCH_NAME_EMPTY: ${body.message}`
1707
- );
1708
- this.body = body;
1709
- this.name = "BranchNameEmptyError";
1710
- }
1711
- static code = "BRANCH_NAME_EMPTY";
1712
- static statusCode = 400;
1713
- static description = `Branch name cannot be empty`;
1714
- }
1715
1931
  class CloudstateInternalErrorError extends Error {
1716
1932
  constructor(body) {
1717
1933
  super(
@@ -1820,269 +2036,161 @@ class ProjectNotFoundError extends Error {
1820
2036
  static statusCode = 404;
1821
2037
  static description = `Project not found: {project_id}`;
1822
2038
  }
1823
- class PermissionAlreadyExistsError extends Error {
1824
- constructor(body) {
1825
- super(
1826
- `PERMISSION_ALREADY_EXISTS: ${body.message}`
1827
- );
1828
- this.body = body;
1829
- this.name = "PermissionAlreadyExistsError";
1830
- }
1831
- static code = "PERMISSION_ALREADY_EXISTS";
1832
- static statusCode = 409;
1833
- static description = `Permission already exists`;
1834
- }
1835
- class ListTokensFailedError extends Error {
1836
- constructor(body) {
1837
- super(
1838
- `LIST_TOKENS_FAILED: ${body.message}`
1839
- );
1840
- this.body = body;
1841
- this.name = "ListTokensFailedError";
1842
- }
1843
- static code = "LIST_TOKENS_FAILED";
1844
- static statusCode = 500;
1845
- static description = `Failed to list tokens: {message}`;
1846
- }
1847
- class RevokeTokenFailedError extends Error {
1848
- constructor(body) {
1849
- super(
1850
- `REVOKE_TOKEN_FAILED: ${body.message}`
1851
- );
1852
- this.body = body;
1853
- this.name = "RevokeTokenFailedError";
1854
- }
1855
- static code = "REVOKE_TOKEN_FAILED";
1856
- static statusCode = 500;
1857
- static description = `Failed to revoke token: {message}`;
1858
- }
1859
- class CreateTokenFailedError extends Error {
1860
- constructor(body) {
1861
- super(
1862
- `CREATE_TOKEN_FAILED: ${body.message}`
1863
- );
1864
- this.body = body;
1865
- this.name = "CreateTokenFailedError";
1866
- }
1867
- static code = "CREATE_TOKEN_FAILED";
1868
- static statusCode = 500;
1869
- static description = `Failed to create token: {message}`;
1870
- }
1871
- class ListPermissionsFailedError extends Error {
1872
- constructor(body) {
1873
- super(
1874
- `LIST_PERMISSIONS_FAILED: ${body.message}`
1875
- );
1876
- this.body = body;
1877
- this.name = "ListPermissionsFailedError";
1878
- }
1879
- static code = "LIST_PERMISSIONS_FAILED";
1880
- static statusCode = 500;
1881
- static description = `Failed to list permissions: {message}`;
1882
- }
1883
- class GetPermissionFailedError extends Error {
1884
- constructor(body) {
1885
- super(
1886
- `GET_PERMISSION_FAILED: ${body.message}`
1887
- );
1888
- this.body = body;
1889
- this.name = "GetPermissionFailedError";
1890
- }
1891
- static code = "GET_PERMISSION_FAILED";
1892
- static statusCode = 500;
1893
- static description = `Failed to get permission: {message}`;
1894
- }
1895
- class UpdatePermissionFailedError extends Error {
2039
+ class UnauthorizedErrorError extends Error {
1896
2040
  constructor(body) {
1897
2041
  super(
1898
- `UPDATE_PERMISSION_FAILED: ${body.message}`
2042
+ `UNAUTHORIZED_ERROR: ${body.message}`
1899
2043
  );
1900
2044
  this.body = body;
1901
- this.name = "UpdatePermissionFailedError";
2045
+ this.name = "UnauthorizedErrorError";
1902
2046
  }
1903
- static code = "UPDATE_PERMISSION_FAILED";
1904
- static statusCode = 500;
1905
- static description = `Failed to update permission: {message}`;
2047
+ static code = "UNAUTHORIZED_ERROR";
2048
+ static statusCode = 401;
2049
+ static description = `Unauthorized request to {route}`;
1906
2050
  }
1907
- class RevokePermissionFailedError extends Error {
2051
+ class BuildFailedError extends Error {
1908
2052
  constructor(body) {
1909
2053
  super(
1910
- `REVOKE_PERMISSION_FAILED: ${body.message}`
2054
+ `BUILD_FAILED: ${body.message}`
1911
2055
  );
1912
2056
  this.body = body;
1913
- this.name = "RevokePermissionFailedError";
2057
+ this.name = "BuildFailedError";
1914
2058
  }
1915
- static code = "REVOKE_PERMISSION_FAILED";
2059
+ static code = "BUILD_FAILED";
1916
2060
  static statusCode = 500;
1917
- static description = `Failed to revoke permission: {message}`;
2061
+ static description = `Build failed on VM {vm_id}`;
1918
2062
  }
1919
- class GrantPermissionFailedError extends Error {
2063
+ class ServerDeploymentFailedError extends Error {
1920
2064
  constructor(body) {
1921
2065
  super(
1922
- `GRANT_PERMISSION_FAILED: ${body.message}`
2066
+ `SERVER_DEPLOYMENT_FAILED: ${body.message}`
1923
2067
  );
1924
2068
  this.body = body;
1925
- this.name = "GrantPermissionFailedError";
2069
+ this.name = "ServerDeploymentFailedError";
1926
2070
  }
1927
- static code = "GRANT_PERMISSION_FAILED";
1928
- static statusCode = 500;
1929
- static description = `Failed to grant permission: {message}`;
2071
+ static code = "SERVER_DEPLOYMENT_FAILED";
2072
+ static statusCode = 502;
2073
+ static description = `Failed to deploy to servers`;
1930
2074
  }
1931
- class ListIdentitiesFailedError extends Error {
2075
+ class LockfileErrorError extends Error {
1932
2076
  constructor(body) {
1933
2077
  super(
1934
- `LIST_IDENTITIES_FAILED: ${body.message}`
2078
+ `LOCKFILE_ERROR: ${body.message}`
1935
2079
  );
1936
2080
  this.body = body;
1937
- this.name = "ListIdentitiesFailedError";
2081
+ this.name = "LockfileErrorError";
1938
2082
  }
1939
- static code = "LIST_IDENTITIES_FAILED";
2083
+ static code = "LOCKFILE_ERROR";
1940
2084
  static statusCode = 500;
1941
- static description = `Failed to list identities: {message}`;
2085
+ static description = `Failed to generate dependency lockfile: {message}`;
1942
2086
  }
1943
- class DeleteIdentityFailedError extends Error {
2087
+ class UploadErrorError extends Error {
1944
2088
  constructor(body) {
1945
2089
  super(
1946
- `DELETE_IDENTITY_FAILED: ${body.message}`
2090
+ `UPLOAD_ERROR: ${body.message}`
1947
2091
  );
1948
2092
  this.body = body;
1949
- this.name = "DeleteIdentityFailedError";
2093
+ this.name = "UploadErrorError";
1950
2094
  }
1951
- static code = "DELETE_IDENTITY_FAILED";
2095
+ static code = "UPLOAD_ERROR";
1952
2096
  static statusCode = 500;
1953
- static description = `Failed to delete identity: {message}`;
2097
+ static description = `Failed to upload deployment to storage`;
1954
2098
  }
1955
- class CreateIdentityFailedError extends Error {
2099
+ class DomainMappingErrorError extends Error {
1956
2100
  constructor(body) {
1957
2101
  super(
1958
- `CREATE_IDENTITY_FAILED: ${body.message}`
2102
+ `DOMAIN_MAPPING_ERROR: ${body.message}`
1959
2103
  );
1960
2104
  this.body = body;
1961
- this.name = "CreateIdentityFailedError";
2105
+ this.name = "DomainMappingErrorError";
1962
2106
  }
1963
- static code = "CREATE_IDENTITY_FAILED";
2107
+ static code = "DOMAIN_MAPPING_ERROR";
1964
2108
  static statusCode = 500;
1965
- static description = `Failed to create identity: {message}`;
1966
- }
1967
- class VmPermissionNotFoundError extends Error {
1968
- constructor(body) {
1969
- super(
1970
- `VM_PERMISSION_NOT_FOUND: ${body.message}`
1971
- );
1972
- this.body = body;
1973
- this.name = "VmPermissionNotFoundError";
1974
- }
1975
- static code = "VM_PERMISSION_NOT_FOUND";
1976
- static statusCode = 404;
1977
- static description = `VM permission not found`;
1978
- }
1979
- class PermissionNotFoundError extends Error {
1980
- constructor(body) {
1981
- super(
1982
- `PERMISSION_NOT_FOUND: ${body.message}`
1983
- );
1984
- this.body = body;
1985
- this.name = "PermissionNotFoundError";
1986
- }
1987
- static code = "PERMISSION_NOT_FOUND";
1988
- static statusCode = 404;
1989
- static description = `Permission not found`;
1990
- }
1991
- class VmAccessDeniedError extends Error {
1992
- constructor(body) {
1993
- super(
1994
- `VM_ACCESS_DENIED: ${body.message}`
1995
- );
1996
- this.body = body;
1997
- this.name = "VmAccessDeniedError";
1998
- }
1999
- static code = "VM_ACCESS_DENIED";
2000
- static statusCode = 403;
2001
- static description = `You are not allowed to access this VM`;
2109
+ static description = `Failed to configure domain mapping for: {domain}`;
2002
2110
  }
2003
- class GitRepositoryAccessDeniedError extends Error {
2111
+ class CertificateProvisioningErrorError extends Error {
2004
2112
  constructor(body) {
2005
2113
  super(
2006
- `GIT_REPOSITORY_ACCESS_DENIED: ${body.message}`
2114
+ `CERTIFICATE_PROVISIONING_ERROR: ${body.message}`
2007
2115
  );
2008
2116
  this.body = body;
2009
- this.name = "GitRepositoryAccessDeniedError";
2010
- }
2011
- static code = "GIT_REPOSITORY_ACCESS_DENIED";
2012
- static statusCode = 403;
2013
- static description = `You are not allowed to access this repository`;
2117
+ this.name = "CertificateProvisioningErrorError";
2118
+ }
2119
+ static code = "CERTIFICATE_PROVISIONING_ERROR";
2120
+ static statusCode = 502;
2121
+ static description = `Failed to provision certificate for domain: {domain}`;
2014
2122
  }
2015
- class GitRepositoryNotFoundError extends Error {
2123
+ class NoEntrypointFoundError extends Error {
2016
2124
  constructor(body) {
2017
2125
  super(
2018
- `GIT_REPOSITORY_NOT_FOUND: ${body.message}`
2126
+ `NO_ENTRYPOINT_FOUND: ${body.message}`
2019
2127
  );
2020
2128
  this.body = body;
2021
- this.name = "GitRepositoryNotFoundError";
2129
+ this.name = "NoEntrypointFoundError";
2022
2130
  }
2023
- static code = "GIT_REPOSITORY_NOT_FOUND";
2024
- static statusCode = 404;
2025
- static description = `Repository not found`;
2131
+ static code = "NO_ENTRYPOINT_FOUND";
2132
+ static statusCode = 400;
2133
+ static description = `No entrypoint found in deployment`;
2026
2134
  }
2027
- class CannotDeleteManagedIdentityError extends Error {
2135
+ class EntrypointNotFoundError extends Error {
2028
2136
  constructor(body) {
2029
2137
  super(
2030
- `CANNOT_DELETE_MANAGED_IDENTITY: ${body.message}`
2138
+ `ENTRYPOINT_NOT_FOUND: ${body.message}`
2031
2139
  );
2032
2140
  this.body = body;
2033
- this.name = "CannotDeleteManagedIdentityError";
2141
+ this.name = "EntrypointNotFoundError";
2034
2142
  }
2035
- static code = "CANNOT_DELETE_MANAGED_IDENTITY";
2036
- static statusCode = 403;
2037
- static description = `Cannot delete managed identities`;
2143
+ static code = "ENTRYPOINT_NOT_FOUND";
2144
+ static statusCode = 400;
2145
+ static description = `Entrypoint not found: {entrypoint}`;
2038
2146
  }
2039
- class CannotModifyManagedIdentityError extends Error {
2147
+ class NoDomainOwnershipError extends Error {
2040
2148
  constructor(body) {
2041
2149
  super(
2042
- `CANNOT_MODIFY_MANAGED_IDENTITY: ${body.message}`
2150
+ `NO_DOMAIN_OWNERSHIP: ${body.message}`
2043
2151
  );
2044
2152
  this.body = body;
2045
- this.name = "CannotModifyManagedIdentityError";
2153
+ this.name = "NoDomainOwnershipError";
2046
2154
  }
2047
- static code = "CANNOT_MODIFY_MANAGED_IDENTITY";
2155
+ static code = "NO_DOMAIN_OWNERSHIP";
2048
2156
  static statusCode = 403;
2049
- static description = `Cannot modify managed identities`;
2157
+ static description = `No domain ownership for: {domain}`;
2050
2158
  }
2051
- class IdentityAccessDeniedError extends Error {
2159
+ class InvalidDomainsError extends Error {
2052
2160
  constructor(body) {
2053
2161
  super(
2054
- `IDENTITY_ACCESS_DENIED: ${body.message}`
2162
+ `INVALID_DOMAINS: ${body.message}`
2055
2163
  );
2056
2164
  this.body = body;
2057
- this.name = "IdentityAccessDeniedError";
2165
+ this.name = "InvalidDomainsError";
2058
2166
  }
2059
- static code = "IDENTITY_ACCESS_DENIED";
2060
- static statusCode = 403;
2061
- static description = `You are not allowed to access this identity`;
2167
+ static code = "INVALID_DOMAINS";
2168
+ static statusCode = 400;
2169
+ static description = `Invalid domains provided`;
2062
2170
  }
2063
- class IdentityNotFoundError extends Error {
2171
+ class WebDeploymentBadRequestError extends Error {
2064
2172
  constructor(body) {
2065
2173
  super(
2066
- `IDENTITY_NOT_FOUND: ${body.message}`
2174
+ `WEB_DEPLOYMENT_BAD_REQUEST: ${body.message}`
2067
2175
  );
2068
2176
  this.body = body;
2069
- this.name = "IdentityNotFoundError";
2177
+ this.name = "WebDeploymentBadRequestError";
2070
2178
  }
2071
- static code = "IDENTITY_NOT_FOUND";
2072
- static statusCode = 404;
2073
- static description = `Identity not found`;
2179
+ static code = "WEB_DEPLOYMENT_BAD_REQUEST";
2180
+ static statusCode = 400;
2181
+ static description = `Bad request: {message}`;
2074
2182
  }
2075
- class UnauthorizedErrorError extends Error {
2183
+ class DeploymentNotFoundError extends Error {
2076
2184
  constructor(body) {
2077
2185
  super(
2078
- `UNAUTHORIZED_ERROR: ${body.message}`
2186
+ `DEPLOYMENT_NOT_FOUND: ${body.message}`
2079
2187
  );
2080
2188
  this.body = body;
2081
- this.name = "UnauthorizedErrorError";
2189
+ this.name = "DeploymentNotFoundError";
2082
2190
  }
2083
- static code = "UNAUTHORIZED_ERROR";
2084
- static statusCode = 401;
2085
- static description = `Unauthorized request to {route}`;
2191
+ static code = "DEPLOYMENT_NOT_FOUND";
2192
+ static statusCode = 404;
2193
+ static description = `Deployment not found`;
2086
2194
  }
2087
2195
  class ObservabilityDatabaseErrorError extends Error {
2088
2196
  constructor(body) {
@@ -2528,150 +2636,6 @@ class InvalidDomainError extends Error {
2528
2636
  static statusCode = 400;
2529
2637
  static description = `Invalid domain: {domain}`;
2530
2638
  }
2531
- class BuildFailedError extends Error {
2532
- constructor(body) {
2533
- super(
2534
- `BUILD_FAILED: ${body.message}`
2535
- );
2536
- this.body = body;
2537
- this.name = "BuildFailedError";
2538
- }
2539
- static code = "BUILD_FAILED";
2540
- static statusCode = 500;
2541
- static description = `Build failed on VM {vm_id}`;
2542
- }
2543
- class ServerDeploymentFailedError extends Error {
2544
- constructor(body) {
2545
- super(
2546
- `SERVER_DEPLOYMENT_FAILED: ${body.message}`
2547
- );
2548
- this.body = body;
2549
- this.name = "ServerDeploymentFailedError";
2550
- }
2551
- static code = "SERVER_DEPLOYMENT_FAILED";
2552
- static statusCode = 502;
2553
- static description = `Failed to deploy to servers`;
2554
- }
2555
- class LockfileErrorError extends Error {
2556
- constructor(body) {
2557
- super(
2558
- `LOCKFILE_ERROR: ${body.message}`
2559
- );
2560
- this.body = body;
2561
- this.name = "LockfileErrorError";
2562
- }
2563
- static code = "LOCKFILE_ERROR";
2564
- static statusCode = 500;
2565
- static description = `Failed to generate dependency lockfile: {message}`;
2566
- }
2567
- class UploadErrorError extends Error {
2568
- constructor(body) {
2569
- super(
2570
- `UPLOAD_ERROR: ${body.message}`
2571
- );
2572
- this.body = body;
2573
- this.name = "UploadErrorError";
2574
- }
2575
- static code = "UPLOAD_ERROR";
2576
- static statusCode = 500;
2577
- static description = `Failed to upload deployment to storage`;
2578
- }
2579
- class DomainMappingErrorError extends Error {
2580
- constructor(body) {
2581
- super(
2582
- `DOMAIN_MAPPING_ERROR: ${body.message}`
2583
- );
2584
- this.body = body;
2585
- this.name = "DomainMappingErrorError";
2586
- }
2587
- static code = "DOMAIN_MAPPING_ERROR";
2588
- static statusCode = 500;
2589
- static description = `Failed to configure domain mapping for: {domain}`;
2590
- }
2591
- class CertificateProvisioningErrorError extends Error {
2592
- constructor(body) {
2593
- super(
2594
- `CERTIFICATE_PROVISIONING_ERROR: ${body.message}`
2595
- );
2596
- this.body = body;
2597
- this.name = "CertificateProvisioningErrorError";
2598
- }
2599
- static code = "CERTIFICATE_PROVISIONING_ERROR";
2600
- static statusCode = 502;
2601
- static description = `Failed to provision certificate for domain: {domain}`;
2602
- }
2603
- class NoEntrypointFoundError extends Error {
2604
- constructor(body) {
2605
- super(
2606
- `NO_ENTRYPOINT_FOUND: ${body.message}`
2607
- );
2608
- this.body = body;
2609
- this.name = "NoEntrypointFoundError";
2610
- }
2611
- static code = "NO_ENTRYPOINT_FOUND";
2612
- static statusCode = 400;
2613
- static description = `No entrypoint found in deployment`;
2614
- }
2615
- class EntrypointNotFoundError extends Error {
2616
- constructor(body) {
2617
- super(
2618
- `ENTRYPOINT_NOT_FOUND: ${body.message}`
2619
- );
2620
- this.body = body;
2621
- this.name = "EntrypointNotFoundError";
2622
- }
2623
- static code = "ENTRYPOINT_NOT_FOUND";
2624
- static statusCode = 400;
2625
- static description = `Entrypoint not found: {entrypoint}`;
2626
- }
2627
- class NoDomainOwnershipError extends Error {
2628
- constructor(body) {
2629
- super(
2630
- `NO_DOMAIN_OWNERSHIP: ${body.message}`
2631
- );
2632
- this.body = body;
2633
- this.name = "NoDomainOwnershipError";
2634
- }
2635
- static code = "NO_DOMAIN_OWNERSHIP";
2636
- static statusCode = 403;
2637
- static description = `No domain ownership for: {domain}`;
2638
- }
2639
- class InvalidDomainsError extends Error {
2640
- constructor(body) {
2641
- super(
2642
- `INVALID_DOMAINS: ${body.message}`
2643
- );
2644
- this.body = body;
2645
- this.name = "InvalidDomainsError";
2646
- }
2647
- static code = "INVALID_DOMAINS";
2648
- static statusCode = 400;
2649
- static description = `Invalid domains provided`;
2650
- }
2651
- class WebDeploymentBadRequestError extends Error {
2652
- constructor(body) {
2653
- super(
2654
- `WEB_DEPLOYMENT_BAD_REQUEST: ${body.message}`
2655
- );
2656
- this.body = body;
2657
- this.name = "WebDeploymentBadRequestError";
2658
- }
2659
- static code = "WEB_DEPLOYMENT_BAD_REQUEST";
2660
- static statusCode = 400;
2661
- static description = `Bad request: {message}`;
2662
- }
2663
- class DeploymentNotFoundError extends Error {
2664
- constructor(body) {
2665
- super(
2666
- `DEPLOYMENT_NOT_FOUND: ${body.message}`
2667
- );
2668
- this.body = body;
2669
- this.name = "DeploymentNotFoundError";
2670
- }
2671
- static code = "DEPLOYMENT_NOT_FOUND";
2672
- static statusCode = 404;
2673
- static description = `Deployment not found`;
2674
- }
2675
2639
  class DomainAlreadyExistsError extends Error {
2676
2640
  constructor(body) {
2677
2641
  super(
@@ -2734,10 +2698,14 @@ class FailedToCheckDomainMappingPermissionsError extends Error {
2734
2698
  }
2735
2699
  const FREESTYLE_ERROR_CODE_MAP = {
2736
2700
  "GIT_ERROR": GitErrorError,
2737
- "SNAPSHOT_VM_BAD_REQUEST": SnapshotVmBadRequestError,
2738
2701
  "INTERNAL_ERROR": InternalErrorError,
2702
+ "DOCKER_IMPORT_BAD_REQUEST": DockerImportBadRequestError,
2703
+ "VM_OPERATION_DENIED_DURING_TRANSACTION": VmOperationDeniedDuringTransactionError,
2704
+ "VM_TRANSACTION_ID_MISMATCH": VmTransactionIdMismatchError,
2705
+ "VM_NOT_IN_TRANSACTION": VmNotInTransactionError,
2739
2706
  "FORK_VM_NOT_FOUND": ForkVmNotFoundError,
2740
2707
  "CREATE_SNAPSHOT_BAD_REQUEST": CreateSnapshotBadRequestError,
2708
+ "SNAPSHOT_VM_BAD_REQUEST": SnapshotVmBadRequestError,
2741
2709
  "VM_DELETED": VmDeletedError,
2742
2710
  "REQWEST": ReqwestError,
2743
2711
  "FIRECRACKER_PID_NOT_FOUND": FirecrackerPidNotFoundError,
@@ -2749,19 +2717,15 @@ const FREESTYLE_ERROR_CODE_MAP = {
2749
2717
  "VM_SUBNET_NOT_FOUND": VmSubnetNotFoundError,
2750
2718
  "FILE_NOT_FOUND": FileNotFoundError,
2751
2719
  "FILES_BAD_REQUEST": FilesBadRequestError,
2752
- "VM_MUST_BE_STOPPED": VmMustBeStoppedError,
2753
- "ALREADY_HAS_BASE": AlreadyHasBaseError,
2754
- "NOT_FOUND": NotFoundError,
2755
2720
  "VM_NOT_FOUND_IN_FS": VmNotFoundInFsError,
2756
2721
  "VM_NOT_RUNNING": VmNotRunningError,
2757
2722
  "VM_NOT_FOUND": VmNotFoundError,
2758
2723
  "INTERNAL_FORK_VM_NOT_FOUND": InternalForkVmNotFoundError,
2759
2724
  "BAD_REQUEST": BadRequestError,
2760
2725
  "INTERNAL_VM_NOT_FOUND": InternalVmNotFoundError,
2761
- "DOCKER_IMPORT_BAD_REQUEST": DockerImportBadRequestError,
2762
- "VM_OPERATION_DENIED_DURING_TRANSACTION": VmOperationDeniedDuringTransactionError,
2763
- "VM_TRANSACTION_ID_MISMATCH": VmTransactionIdMismatchError,
2764
- "VM_NOT_IN_TRANSACTION": VmNotInTransactionError,
2726
+ "VM_MUST_BE_STOPPED": VmMustBeStoppedError,
2727
+ "ALREADY_HAS_BASE": AlreadyHasBaseError,
2728
+ "NOT_FOUND": NotFoundError,
2765
2729
  "CREATE_VM_BAD_REQUEST": CreateVmBadRequestError,
2766
2730
  "USER_NOT_FOUND": UserNotFoundError,
2767
2731
  "USER_ALREADY_EXISTS": UserAlreadyExistsError,
@@ -2797,46 +2761,44 @@ const FREESTYLE_ERROR_CODE_MAP = {
2797
2761
  "SERVICE_NOT_FOUND": ServiceNotFoundError,
2798
2762
  "INVALID_REQUEST": InvalidRequestError,
2799
2763
  "REPO_NOT_FOUND": RepoNotFoundError,
2764
+ "RUNTIME_ERROR": RuntimeErrorError,
2765
+ "SYNTAX_ERROR": SyntaxErrorError,
2800
2766
  "INTERNAL": InternalError,
2801
2767
  "SIGNING": SigningError,
2802
2768
  "INVALID_SIGNATURE": InvalidSignatureError,
2803
2769
  "INVALID_PARAMETERS": InvalidParametersError,
2804
2770
  "MAX_USES_EXCEEDED": MaxUsesExceededError,
2805
2771
  "EXPIRED": ExpiredError,
2806
- "CONFLICT": ConflictError,
2807
- "BRANCH_NOT_FOUND": BranchNotFoundError,
2808
- "SEND_ERROR": SendErrorError,
2809
2772
  "FORBIDDEN": ForbiddenError,
2810
- "UNSUPPORTED_TRANSFER": UnsupportedTransferError,
2811
- "REFERENCE_NOT_FOUND": ReferenceNotFoundError,
2812
- "INVALID_RANGE": InvalidRangeError,
2813
- "OFFSET_WITH_SELECTOR": OffsetWithSelectorError,
2814
- "COMMIT_NOT_IN_BRANCH": CommitNotInBranchError,
2815
- "COMMIT_NOT_FOUND": CommitNotFoundError,
2816
- "BLOB_NOT_FOUND": BlobNotFoundError,
2817
- "TREE_NOT_FOUND": TreeNotFoundError,
2818
- "INVALID_REVISION": InvalidRevisionError,
2819
2773
  "UNAUTHORIZED": UnauthorizedError,
2820
- "TAG_NOT_FOUND": TagNotFoundError,
2821
- "REPO_ALREADY_EXISTS": RepoAlreadyExistsError,
2822
- "GIT_HUB_SYNC_CONFLICT": GitHubSyncConflictError,
2823
- "INVALID_OBJECT_ID": InvalidObjectIdError,
2774
+ "INVALID_SERVICE": InvalidServiceError,
2775
+ "EXPECTED_SERVICE": ExpectedServiceError,
2776
+ "UNSUPPORTED_TRANSFER": UnsupportedTransferError,
2777
+ "CONFLICT": ConflictError,
2778
+ "BRANCH_NOT_FOUND": BranchNotFoundError,
2824
2779
  "SOURCE_IMPORT_CONFLICT": SourceImportConflictError,
2825
2780
  "SOURCE_UNAUTHORIZED": SourceUnauthorizedError,
2826
2781
  "SOURCE_NOT_FOUND": SourceNotFoundError,
2827
2782
  "IMPORT_SUBDIR_NOT_FOUND": ImportSubdirNotFoundError,
2828
- "PACKFILE": PackfileError,
2783
+ "REPO_ALREADY_EXISTS": RepoAlreadyExistsError,
2829
2784
  "PATH_NOT_FOUND": PathNotFoundError,
2830
- "INVALID_SERVICE": InvalidServiceError,
2831
- "EXPECTED_SERVICE": ExpectedServiceError,
2785
+ "REFERENCE_NOT_FOUND": ReferenceNotFoundError,
2786
+ "TAG_NOT_FOUND": TagNotFoundError,
2787
+ "SEND_ERROR": SendErrorError,
2788
+ "GIT_HUB_SYNC_CONFLICT": GitHubSyncConflictError,
2789
+ "INVALID_OBJECT_ID": InvalidObjectIdError,
2790
+ "COMMIT_NOT_FOUND": CommitNotFoundError,
2791
+ "TREE_NOT_FOUND": TreeNotFoundError,
2792
+ "INVALID_REVISION": InvalidRevisionError,
2793
+ "INVALID_RANGE": InvalidRangeError,
2794
+ "OFFSET_WITH_SELECTOR": OffsetWithSelectorError,
2795
+ "COMMIT_NOT_IN_BRANCH": CommitNotInBranchError,
2796
+ "BLOB_NOT_FOUND": BlobNotFoundError,
2797
+ "AMBIGUOUS": AmbiguousError,
2798
+ "INVALID": InvalidError,
2799
+ "PACKFILE": PackfileError,
2832
2800
  "DATABASE_ERROR": DatabaseErrorError,
2833
- "WAIT_TIMEOUT": WaitTimeoutError,
2834
- "PRE_VERIFY_CHALLENGE_MISMATCH": PreVerifyChallengeMismatchError,
2835
- "PRE_VERIFY_FAILED_PARSE": PreVerifyFailedParseError,
2836
- "PRE_VERIFY_FAILED_FETCH": PreVerifyFailedFetchError,
2837
- "PRE_VERIFY_ROUTE_NOT_FOUND": PreVerifyRouteNotFoundError,
2838
- "AUTHORIZATION_NOT_FOUND": AuthorizationNotFoundError,
2839
- "ORDER_NOT_FOUND": OrderNotFoundError,
2801
+ "EMPTY_TAG": EmptyTagError,
2840
2802
  "RESIZE_FAILED": ResizeFailedError,
2841
2803
  "INTERNAL_RESIZE_VM_NOT_FOUND": InternalResizeVmNotFoundError,
2842
2804
  "DOMAIN_OWNERSHIP_VERIFICATION_FAILED": DomainOwnershipVerificationFailedError,
@@ -2858,32 +2820,8 @@ const FREESTYLE_ERROR_CODE_MAP = {
2858
2820
  "DEV_SERVER_FILE_NOT_FOUND": DevServerFileNotFoundError,
2859
2821
  "DEV_SERVER_INVALID_REQUEST": DevServerInvalidRequestError,
2860
2822
  "DEV_SERVER_NOT_FOUND": DevServerNotFoundError,
2861
- "EXECUTE_INTERNAL_ERROR": ExecuteInternalErrorError,
2862
- "EXECUTE_ACCESS_DENIED": ExecuteAccessDeniedError,
2863
- "LIST_RUNS_FAILED": ListRunsFailedError,
2864
- "EXECUTION_ERROR": ExecutionErrorError,
2865
- "CONNECTION_FAILED": ConnectionFailedError,
2866
- "METADATA_WRITE_FAILED": MetadataWriteFailedError,
2867
- "NODE_MODULES_INSTALL_FAILED": NodeModulesInstallFailedError,
2868
- "NODE_MODULES_DOWNLOAD_FAILED": NodeModulesDownloadFailedError,
2869
- "LOCK_GENERATION_FAILED": LockGenerationFailedError,
2870
- "WRITE_SCRIPT_FAILED": WriteScriptFailedError,
2871
- "DIRECTORY_CREATION_FAILED": DirectoryCreationFailedError,
2872
- "NETWORK_PERMISSIONS_FAILED": NetworkPermissionsFailedError,
2873
- "LOGGING_FAILED": LoggingFailedError,
2874
- "RUN_NOT_FOUND": RunNotFoundError,
2875
- "EMPTY_TAG": EmptyTagError,
2876
2823
  "ANYHOW": AnyhowError,
2877
2824
  "BRANCH_NAME_EMPTY": BranchNameEmptyError,
2878
- "CLOUDSTATE_INTERNAL_ERROR": CloudstateInternalErrorError,
2879
- "CLOUDSTATE_DATABASE_ERROR": CloudstateDatabaseErrorError,
2880
- "CLOUDSTATE_ACCESS_DENIED": CloudstateAccessDeniedError,
2881
- "RESTORE_FAILED": RestoreFailedError,
2882
- "CREATE_BACKUP_FAILED": CreateBackupFailedError,
2883
- "BACKUP_FAILED": BackupFailedError,
2884
- "DEPLOYMENT_FAILED": DeploymentFailedError,
2885
- "INVALID_DEPLOYMENT_REQUEST": InvalidDeploymentRequestError,
2886
- "PROJECT_NOT_FOUND": ProjectNotFoundError,
2887
2825
  "PERMISSION_ALREADY_EXISTS": PermissionAlreadyExistsError,
2888
2826
  "LIST_TOKENS_FAILED": ListTokensFailedError,
2889
2827
  "REVOKE_TOKEN_FAILED": RevokeTokenFailedError,
@@ -2905,7 +2843,42 @@ const FREESTYLE_ERROR_CODE_MAP = {
2905
2843
  "CANNOT_MODIFY_MANAGED_IDENTITY": CannotModifyManagedIdentityError,
2906
2844
  "IDENTITY_ACCESS_DENIED": IdentityAccessDeniedError,
2907
2845
  "IDENTITY_NOT_FOUND": IdentityNotFoundError,
2846
+ "EXECUTE_INTERNAL_ERROR": ExecuteInternalErrorError,
2847
+ "EXECUTE_ACCESS_DENIED": ExecuteAccessDeniedError,
2848
+ "LIST_RUNS_FAILED": ListRunsFailedError,
2849
+ "EXECUTION_ERROR": ExecutionErrorError,
2850
+ "CONNECTION_FAILED": ConnectionFailedError,
2851
+ "METADATA_WRITE_FAILED": MetadataWriteFailedError,
2852
+ "NODE_MODULES_INSTALL_FAILED": NodeModulesInstallFailedError,
2853
+ "NODE_MODULES_DOWNLOAD_FAILED": NodeModulesDownloadFailedError,
2854
+ "LOCK_GENERATION_FAILED": LockGenerationFailedError,
2855
+ "WRITE_SCRIPT_FAILED": WriteScriptFailedError,
2856
+ "DIRECTORY_CREATION_FAILED": DirectoryCreationFailedError,
2857
+ "NETWORK_PERMISSIONS_FAILED": NetworkPermissionsFailedError,
2858
+ "LOGGING_FAILED": LoggingFailedError,
2859
+ "RUN_NOT_FOUND": RunNotFoundError,
2860
+ "CLOUDSTATE_INTERNAL_ERROR": CloudstateInternalErrorError,
2861
+ "CLOUDSTATE_DATABASE_ERROR": CloudstateDatabaseErrorError,
2862
+ "CLOUDSTATE_ACCESS_DENIED": CloudstateAccessDeniedError,
2863
+ "RESTORE_FAILED": RestoreFailedError,
2864
+ "CREATE_BACKUP_FAILED": CreateBackupFailedError,
2865
+ "BACKUP_FAILED": BackupFailedError,
2866
+ "DEPLOYMENT_FAILED": DeploymentFailedError,
2867
+ "INVALID_DEPLOYMENT_REQUEST": InvalidDeploymentRequestError,
2868
+ "PROJECT_NOT_FOUND": ProjectNotFoundError,
2908
2869
  "UNAUTHORIZED_ERROR": UnauthorizedErrorError,
2870
+ "BUILD_FAILED": BuildFailedError,
2871
+ "SERVER_DEPLOYMENT_FAILED": ServerDeploymentFailedError,
2872
+ "LOCKFILE_ERROR": LockfileErrorError,
2873
+ "UPLOAD_ERROR": UploadErrorError,
2874
+ "DOMAIN_MAPPING_ERROR": DomainMappingErrorError,
2875
+ "CERTIFICATE_PROVISIONING_ERROR": CertificateProvisioningErrorError,
2876
+ "NO_ENTRYPOINT_FOUND": NoEntrypointFoundError,
2877
+ "ENTRYPOINT_NOT_FOUND": EntrypointNotFoundError,
2878
+ "NO_DOMAIN_OWNERSHIP": NoDomainOwnershipError,
2879
+ "INVALID_DOMAINS": InvalidDomainsError,
2880
+ "WEB_DEPLOYMENT_BAD_REQUEST": WebDeploymentBadRequestError,
2881
+ "DEPLOYMENT_NOT_FOUND": DeploymentNotFoundError,
2909
2882
  "OBSERVABILITY_DATABASE_ERROR": ObservabilityDatabaseErrorError,
2910
2883
  "OBSERVABILITY_ACCESS_DENIED": ObservabilityAccessDeniedError,
2911
2884
  "PARSE_LOGS_FAILED": ParseLogsFailedError,
@@ -2943,18 +2916,6 @@ const FREESTYLE_ERROR_CODE_MAP = {
2943
2916
  "VERIFICATION_NOT_FOUND": VerificationNotFoundError,
2944
2917
  "FAILED_TO_CREATE_VERIFICATION_CODE": FailedToCreateVerificationCodeError,
2945
2918
  "INVALID_DOMAIN": InvalidDomainError,
2946
- "BUILD_FAILED": BuildFailedError,
2947
- "SERVER_DEPLOYMENT_FAILED": ServerDeploymentFailedError,
2948
- "LOCKFILE_ERROR": LockfileErrorError,
2949
- "UPLOAD_ERROR": UploadErrorError,
2950
- "DOMAIN_MAPPING_ERROR": DomainMappingErrorError,
2951
- "CERTIFICATE_PROVISIONING_ERROR": CertificateProvisioningErrorError,
2952
- "NO_ENTRYPOINT_FOUND": NoEntrypointFoundError,
2953
- "ENTRYPOINT_NOT_FOUND": EntrypointNotFoundError,
2954
- "NO_DOMAIN_OWNERSHIP": NoDomainOwnershipError,
2955
- "INVALID_DOMAINS": InvalidDomainsError,
2956
- "WEB_DEPLOYMENT_BAD_REQUEST": WebDeploymentBadRequestError,
2957
- "DEPLOYMENT_NOT_FOUND": DeploymentNotFoundError,
2958
2919
  "DOMAIN_ALREADY_EXISTS": DomainAlreadyExistsError,
2959
2920
  "FAILED_TO_INSERT_OWNERSHIP": FailedToInsertOwnershipError,
2960
2921
  "FAILED_REMOVE_DOMAIN_MAPPING": FailedRemoveDomainMappingError,
@@ -2966,8 +2927,8 @@ var errors = /*#__PURE__*/Object.freeze({
2966
2927
  __proto__: null,
2967
2928
  AfterArrayContainsEmptyError: AfterArrayContainsEmptyError,
2968
2929
  AlreadyHasBaseError: AlreadyHasBaseError,
2930
+ AmbiguousError: AmbiguousError,
2969
2931
  AnyhowError: AnyhowError,
2970
- AuthorizationNotFoundError: AuthorizationNotFoundError,
2971
2932
  BackupFailedError: BackupFailedError,
2972
2933
  BadRequestError: BadRequestError,
2973
2934
  BlobNotFoundError: BlobNotFoundError,
@@ -3072,6 +3033,7 @@ var errors = /*#__PURE__*/Object.freeze({
3072
3033
  InvalidDeploymentRequestError: InvalidDeploymentRequestError,
3073
3034
  InvalidDomainError: InvalidDomainError,
3074
3035
  InvalidDomainsError: InvalidDomainsError,
3036
+ InvalidError: InvalidError,
3075
3037
  InvalidObjectIdError: InvalidObjectIdError,
3076
3038
  InvalidParametersError: InvalidParametersError,
3077
3039
  InvalidQueryError: InvalidQueryError,
@@ -3102,7 +3064,6 @@ var errors = /*#__PURE__*/Object.freeze({
3102
3064
  ObservabilityDatabaseErrorError: ObservabilityDatabaseErrorError,
3103
3065
  OffsetWithSelectorError: OffsetWithSelectorError,
3104
3066
  OnFailureArrayContainsEmptyError: OnFailureArrayContainsEmptyError,
3105
- OrderNotFoundError: OrderNotFoundError,
3106
3067
  PackfileError: PackfileError,
3107
3068
  ParseLogsFailedError: ParseLogsFailedError,
3108
3069
  ParseResponseErrorError: ParseResponseErrorError,
@@ -3111,10 +3072,6 @@ var errors = /*#__PURE__*/Object.freeze({
3111
3072
  PermissionDeniedError: PermissionDeniedError,
3112
3073
  PermissionErrorError: PermissionErrorError,
3113
3074
  PermissionNotFoundError: PermissionNotFoundError,
3114
- PreVerifyChallengeMismatchError: PreVerifyChallengeMismatchError,
3115
- PreVerifyFailedFetchError: PreVerifyFailedFetchError,
3116
- PreVerifyFailedParseError: PreVerifyFailedParseError,
3117
- PreVerifyRouteNotFoundError: PreVerifyRouteNotFoundError,
3118
3075
  ProjectNotFoundError: ProjectNotFoundError,
3119
3076
  ReadFileFailedError: ReadFileFailedError,
3120
3077
  RecordOwnershipErrorError: RecordOwnershipErrorError,
@@ -3133,6 +3090,7 @@ var errors = /*#__PURE__*/Object.freeze({
3133
3090
  RevokePermissionFailedError: RevokePermissionFailedError,
3134
3091
  RevokeTokenFailedError: RevokeTokenFailedError,
3135
3092
  RunNotFoundError: RunNotFoundError,
3093
+ RuntimeErrorError: RuntimeErrorError,
3136
3094
  SendErrorError: SendErrorError,
3137
3095
  SerializationErrorError: SerializationErrorError,
3138
3096
  ServerDeploymentFailedError: ServerDeploymentFailedError,
@@ -3150,6 +3108,7 @@ var errors = /*#__PURE__*/Object.freeze({
3150
3108
  SourceUnauthorizedError: SourceUnauthorizedError,
3151
3109
  StatusFailedError: StatusFailedError,
3152
3110
  StdIoError: StdIoError,
3111
+ SyntaxErrorError: SyntaxErrorError,
3153
3112
  TagNotFoundError: TagNotFoundError,
3154
3113
  TokenErrorError: TokenErrorError,
3155
3114
  TreeNotFoundError: TreeNotFoundError,
@@ -3185,7 +3144,6 @@ var errors = /*#__PURE__*/Object.freeze({
3185
3144
  VmStartTimeoutError: VmStartTimeoutError,
3186
3145
  VmSubnetNotFoundError: VmSubnetNotFoundError,
3187
3146
  VmTransactionIdMismatchError: VmTransactionIdMismatchError,
3188
- WaitTimeoutError: WaitTimeoutError,
3189
3147
  WantedByEmptyError: WantedByEmptyError,
3190
3148
  WatchFilesFailedError: WatchFilesFailedError,
3191
3149
  WebDeploymentBadRequestError: WebDeploymentBadRequestError,
@@ -4404,35 +4362,15 @@ class RunsNamespace {
4404
4362
  */
4405
4363
  async create({
4406
4364
  code,
4407
- config,
4408
- outgoingHeaders,
4409
- outgoingProxy
4365
+ ...config
4410
4366
  }) {
4411
- const response = await this.apiClient.post("/execute/v1/script", {
4367
+ const response = await this.apiClient.post("/execute/v2/script", {
4412
4368
  body: {
4413
4369
  script: code,
4414
- config: {
4415
- proxy: outgoingProxy,
4416
- customHeaders: outgoingHeaders,
4417
- networkPermissions: config.networkPermissions?.map((np) => ({
4418
- action: np.action,
4419
- query: np.domain,
4420
- behavior: np.behavior
4421
- })),
4422
- envVars: config.envVars,
4423
- nodeModules: config.nodeModules,
4424
- timeout: config.timeoutMs
4425
- // entrypoint: config.entrypointPath,
4426
- }
4370
+ config
4427
4371
  }
4428
4372
  });
4429
- if (!response.result && !response.logs) {
4430
- throw new Error("Execution failed");
4431
- }
4432
- return {
4433
- result: response.result,
4434
- logs: response.logs || []
4435
- };
4373
+ return response;
4436
4374
  }
4437
4375
  /**
4438
4376
  * List execution runs.
@@ -4686,6 +4624,32 @@ class VmWith {
4686
4624
  compose(...configs) {
4687
4625
  return composeCreateVmOptions(configs);
4688
4626
  }
4627
+ /**
4628
+ * Helper method to compose multiple VmSpecs together.
4629
+ * Uses the same merging strategy as the main compose function.
4630
+ * Useful in configureSpec and configureSnapshotSpec methods.
4631
+ */
4632
+ composeSpecs(...specs) {
4633
+ return composeVmSpecs(specs);
4634
+ }
4635
+ /**
4636
+ * @deprecated Use composeSpecs instead
4637
+ * Helper method to compose multiple VmTemplates together.
4638
+ * Uses the same merging strategy as the main compose function.
4639
+ * Useful in configureTemplate and configureNestedTemplate methods.
4640
+ */
4641
+ composeTemplates(...templates) {
4642
+ return composeVmTemplates(templates);
4643
+ }
4644
+ // Add a new method to VmWith to configure returned VMs with helpers
4645
+ async configureReturnedVm(vm, template) {
4646
+ if (template.raw) {
4647
+ await this.configure(template.raw);
4648
+ const instance = this.createInstance();
4649
+ instance._init(vm);
4650
+ this.instance = instance;
4651
+ }
4652
+ }
4689
4653
  }
4690
4654
  const VmService = VmWith;
4691
4655
  const VmBuilder = VmWith;
@@ -4937,6 +4901,73 @@ function composeCreateVmOptions(arr) {
4937
4901
  }
4938
4902
  return result;
4939
4903
  }
4904
+ function composeVmTemplates(templates) {
4905
+ if (templates.length === 0) {
4906
+ return new VmTemplate({});
4907
+ }
4908
+ if (templates.length === 1) {
4909
+ return templates[0];
4910
+ }
4911
+ const rawConfigs = templates.map((t) => t.raw);
4912
+ const composedRaw = composeCreateVmOptions(
4913
+ rawConfigs
4914
+ );
4915
+ const mergedWith = {};
4916
+ for (const template of templates) {
4917
+ for (const key in template.with) {
4918
+ const builder = template.with[key];
4919
+ if (builder) {
4920
+ mergedWith[key] = builder;
4921
+ }
4922
+ }
4923
+ }
4924
+ const nestedTemplates = templates.map((t) => t.raw.template).filter((t) => t instanceof VmTemplate);
4925
+ let nestedTemplate;
4926
+ if (nestedTemplates.length > 0) {
4927
+ nestedTemplate = composeVmTemplates(nestedTemplates);
4928
+ }
4929
+ const result = new VmTemplate({
4930
+ ...composedRaw,
4931
+ template: nestedTemplate,
4932
+ with: mergedWith
4933
+ });
4934
+ return result;
4935
+ }
4936
+ function composeVmSpecs(specs) {
4937
+ if (specs.length === 0) {
4938
+ return new VmSpec({});
4939
+ }
4940
+ if (specs.length === 1) {
4941
+ return specs[0];
4942
+ }
4943
+ const rawConfigs = specs.map((s) => {
4944
+ const { snapshot, ...rest } = s.raw;
4945
+ return rest;
4946
+ });
4947
+ const composedRaw = composeCreateVmOptions(
4948
+ rawConfigs
4949
+ );
4950
+ const mergedWith = {};
4951
+ for (const spec of specs) {
4952
+ for (const key in spec.with) {
4953
+ const builder = spec.with[key];
4954
+ if (builder) {
4955
+ mergedWith[key] = builder;
4956
+ }
4957
+ }
4958
+ }
4959
+ const nestedSpecs = specs.map((s) => s.raw.snapshot).filter((s) => s instanceof VmSpec);
4960
+ let nestedSpec;
4961
+ if (nestedSpecs.length > 0) {
4962
+ nestedSpec = composeVmSpecs(nestedSpecs);
4963
+ }
4964
+ const result = new VmSpec({
4965
+ ...composedRaw,
4966
+ snapshot: nestedSpec,
4967
+ with: mergedWith
4968
+ });
4969
+ return result;
4970
+ }
4940
4971
 
4941
4972
  class VmTerminals {
4942
4973
  constructor(vmId, client) {
@@ -5116,51 +5147,121 @@ class Vm {
5116
5147
  return this.apiClient.post("/v1/vms/{id}/resize", {
5117
5148
  params: { id: this.vmId },
5118
5149
  body: { memSizeGb, rootfsSizeGb, vcpuCount }
5150
+ // Temporarily cast to any
5119
5151
  });
5120
5152
  }
5121
- }
5122
- class VmSnapshotsNamespace {
5123
- constructor(apiClient) {
5124
- this.apiClient = apiClient;
5153
+ /**
5154
+ * Create a VM instance by ID without making an api call.
5155
+ */
5156
+ ref({ vmId }) {
5157
+ return new Vm(vmId, this.apiClient);
5125
5158
  }
5126
- async ensure(options) {
5127
- if (options.template.raw.template instanceof VmTemplate) {
5128
- options.template = await ensureNestedTemplates(options.template, this);
5129
- }
5130
- return this.apiClient.post("/v1/vms/snapshots", {
5131
- body: {
5132
- ...options,
5133
- // @ts-ignore
5134
- template: options.template?.raw
5135
- }
5159
+ async delete({ vmId }) {
5160
+ return this.apiClient.delete("/v1/vms/{vm_id}", {
5161
+ params: { vm_id: vmId }
5136
5162
  });
5137
5163
  }
5138
5164
  }
5139
- async function ensureNestedTemplates(template, snapshots) {
5140
- let templates = [template];
5141
- while (templates.at(-1)?.raw.template instanceof VmTemplate) {
5142
- let innerTemplate = templates.at(-1).raw.template;
5143
- templates.at(-1).raw.template = void 0;
5144
- templates.push(innerTemplate);
5165
+ class VmTemplate {
5166
+ raw;
5167
+ with;
5168
+ constructor(template) {
5169
+ const { with: withBuilders, ...rest } = template;
5170
+ this.raw = rest;
5171
+ this.with = withBuilders ?? {};
5145
5172
  }
5146
- return await layerTemplates(templates, snapshots);
5147
5173
  }
5148
- async function layerTemplates(templates, snapshots) {
5149
- let lastTemplate = templates.pop();
5150
- const { snapshotId } = await snapshots.ensure({
5151
- template: lastTemplate
5174
+ class VmSpec {
5175
+ raw;
5176
+ with;
5177
+ constructor(spec) {
5178
+ const { with: withBuilders, ...rest } = spec;
5179
+ this.raw = rest;
5180
+ this.with = withBuilders ?? {};
5181
+ }
5182
+ }
5183
+ async function convertSpecSnapshotsToTemplates(spec, processBuilders = true) {
5184
+ if (!spec.raw.snapshot) {
5185
+ return void 0;
5186
+ }
5187
+ let innerSpec = spec.raw.snapshot;
5188
+ if (processBuilders) {
5189
+ innerSpec = await processSpecTree(innerSpec);
5190
+ }
5191
+ const { snapshot: nestedSnapshot, ...innerRaw } = innerSpec.raw;
5192
+ let nestedTemplate;
5193
+ if (nestedSnapshot instanceof VmSpec) {
5194
+ nestedTemplate = await convertSpecSnapshotsToTemplates(innerSpec, false);
5195
+ }
5196
+ return new VmTemplate({
5197
+ ...innerRaw,
5198
+ template: nestedTemplate,
5199
+ with: innerSpec.with
5152
5200
  });
5153
- let lastSnapshotId = snapshotId;
5154
- while (templates.length > 0) {
5155
- const template = templates.pop();
5156
- template.raw.snapshotId = lastSnapshotId;
5157
- const { snapshotId: snapshotId2 } = await snapshots.ensure({
5158
- template
5159
- });
5160
- lastSnapshotId = snapshotId2;
5161
- lastTemplate = template;
5201
+ }
5202
+ async function processOuterSpecBuilders(spec) {
5203
+ for (const key in spec.with) {
5204
+ const builder = spec.with[key];
5205
+ if (builder) {
5206
+ if (builder.configureSpec) {
5207
+ spec = await builder.configureSpec(spec);
5208
+ }
5209
+ if (builder.configureSnapshotSpec) {
5210
+ let snapshotSpec;
5211
+ if (spec.raw.snapshot instanceof VmSpec) {
5212
+ snapshotSpec = spec.raw.snapshot;
5213
+ } else {
5214
+ snapshotSpec = new VmSpec({});
5215
+ spec.raw.snapshot = snapshotSpec;
5216
+ }
5217
+ spec.raw.snapshot = await builder.configureSnapshotSpec(snapshotSpec);
5218
+ }
5219
+ }
5162
5220
  }
5163
- return lastTemplate;
5221
+ return spec;
5222
+ }
5223
+ async function processSpecTree(spec) {
5224
+ for (const key in spec.with) {
5225
+ const builder = spec.with[key];
5226
+ if (builder) {
5227
+ if (builder.configureSpec) {
5228
+ spec = await builder.configureSpec(spec);
5229
+ }
5230
+ if (builder.configureSnapshotSpec) {
5231
+ let snapshotSpec;
5232
+ if (spec.raw.snapshot instanceof VmSpec) {
5233
+ snapshotSpec = spec.raw.snapshot;
5234
+ } else {
5235
+ snapshotSpec = new VmSpec({});
5236
+ spec.raw.snapshot = snapshotSpec;
5237
+ }
5238
+ spec.raw.snapshot = await builder.configureSnapshotSpec(snapshotSpec);
5239
+ }
5240
+ }
5241
+ }
5242
+ if (spec.raw.snapshot instanceof VmSpec) {
5243
+ spec.raw.snapshot = await processSpecTree(spec.raw.snapshot);
5244
+ }
5245
+ return spec;
5246
+ }
5247
+ function collectSpecBuilders(spec) {
5248
+ const builders = {};
5249
+ if (spec.with) {
5250
+ for (const [key, builder] of Object.entries(spec.with)) {
5251
+ if (builder) {
5252
+ builders[key] = builder;
5253
+ }
5254
+ }
5255
+ }
5256
+ if (spec.raw.snapshot instanceof VmSpec) {
5257
+ const nestedBuilders = collectSpecBuilders(spec.raw.snapshot);
5258
+ for (const [key, builder] of Object.entries(nestedBuilders)) {
5259
+ if (!builders[key] && builder) {
5260
+ builders[key] = builder;
5261
+ }
5262
+ }
5263
+ }
5264
+ return builders;
5164
5265
  }
5165
5266
  class VmsNamespace {
5166
5267
  constructor(apiClient) {
@@ -5174,9 +5275,32 @@ class VmsNamespace {
5174
5275
  * @returns A VM instance representing the created VM
5175
5276
  */
5176
5277
  async create(options = {}) {
5177
- const builders = options.with || {};
5278
+ if (options.spec instanceof VmSpec) {
5279
+ let spec = options.spec;
5280
+ spec = await processOuterSpecBuilders(spec);
5281
+ const { snapshot, ...outerSpecOptions } = spec.raw;
5282
+ const innerTemplate = await convertSpecSnapshotsToTemplates(spec);
5283
+ if (innerTemplate) {
5284
+ options.template = innerTemplate;
5285
+ }
5286
+ const mergedOptions = composeCreateVmOptions([
5287
+ outerSpecOptions,
5288
+ options
5289
+ ]);
5290
+ options = {
5291
+ ...options,
5292
+ ...mergedOptions
5293
+ };
5294
+ if (!options.with && spec.with) {
5295
+ options.with = spec.with;
5296
+ }
5297
+ }
5298
+ const builders = options.with || options.template?.with || {};
5178
5299
  const { with: _, ...baseConfig } = options;
5179
5300
  let config = baseConfig;
5301
+ if (config.template instanceof VmTemplate) {
5302
+ config.template = await processTemplateTree(config.template);
5303
+ }
5180
5304
  if (config.template instanceof VmTemplate) {
5181
5305
  config.template = await ensureNestedTemplates(
5182
5306
  config.template,
@@ -5202,12 +5326,6 @@ class VmsNamespace {
5202
5326
  const builder = builders[key];
5203
5327
  if (builder) {
5204
5328
  const instance = builder.createInstance();
5205
- builder.createInstance = () => {
5206
- throw new Error(
5207
- `Attempted to create multiple instances from the same VmWith ${key}: ${builder.constructor.name}`
5208
- );
5209
- };
5210
- builder.instance = instance;
5211
5329
  instance._init(vm);
5212
5330
  vm[key] = instance;
5213
5331
  }
@@ -5226,6 +5344,30 @@ class VmsNamespace {
5226
5344
  async list() {
5227
5345
  return this.apiClient.get("/v1/vms", void 0);
5228
5346
  }
5347
+ /**
5348
+ * Get VM by ID.
5349
+ * @param vmId The ID of the VM
5350
+ * @param allowedSpecs Array of allowed specs (currently only 1 supported, always uses the first)
5351
+ * @returns The VM instance configured with builders from the spec
5352
+ */
5353
+ async get({
5354
+ vmId,
5355
+ allowedSpecs
5356
+ }) {
5357
+ const vm = new Vm(vmId, this.apiClient);
5358
+ const spec = allowedSpecs?.[0];
5359
+ if (spec) {
5360
+ const allBuilders = collectSpecBuilders(spec);
5361
+ for (const [key, builder] of Object.entries(allBuilders)) {
5362
+ if (builder) {
5363
+ const instance = builder.createInstance();
5364
+ instance._init(vm);
5365
+ vm[key] = instance;
5366
+ }
5367
+ }
5368
+ }
5369
+ return { vm, spec };
5370
+ }
5229
5371
  /**
5230
5372
  * Create a VM instance by ID without making an api call.
5231
5373
  */
@@ -5238,11 +5380,68 @@ class VmsNamespace {
5238
5380
  });
5239
5381
  }
5240
5382
  }
5241
- class VmTemplate {
5242
- raw;
5243
- constructor(template) {
5244
- this.raw = template;
5383
+ class VmSnapshotsNamespace {
5384
+ constructor(apiClient) {
5385
+ this.apiClient = apiClient;
5386
+ }
5387
+ async ensure(options) {
5388
+ return this.apiClient.post("/v1/vms/snapshots", {
5389
+ body: {
5390
+ ...options,
5391
+ template: options.template?.raw
5392
+ }
5393
+ });
5394
+ }
5395
+ }
5396
+ async function processTemplateTree(template) {
5397
+ for (const key in template.with) {
5398
+ const builder = template.with[key];
5399
+ if (builder) {
5400
+ if (builder.configureTemplate) {
5401
+ template = await builder.configureTemplate(template);
5402
+ }
5403
+ if (builder.configureNestedTemplate) {
5404
+ let nestedTemplate;
5405
+ if (template.raw.template instanceof VmTemplate) {
5406
+ nestedTemplate = template.raw.template;
5407
+ } else {
5408
+ nestedTemplate = new VmTemplate({});
5409
+ template.raw.template = nestedTemplate;
5410
+ }
5411
+ template.raw.template = await builder.configureNestedTemplate(nestedTemplate);
5412
+ }
5413
+ }
5414
+ }
5415
+ if (template.raw.template instanceof VmTemplate) {
5416
+ template.raw.template = await processTemplateTree(template.raw.template);
5417
+ }
5418
+ return template;
5419
+ }
5420
+ async function ensureNestedTemplates(template, snapshots) {
5421
+ let templates = [template];
5422
+ while (templates.at(-1)?.raw.template instanceof VmTemplate) {
5423
+ let innerTemplate = templates.at(-1).raw.template;
5424
+ templates.at(-1).raw.template = void 0;
5425
+ templates.push(innerTemplate);
5426
+ }
5427
+ return await layerTemplates(templates, snapshots);
5428
+ }
5429
+ async function layerTemplates(templates, snapshots) {
5430
+ let lastTemplate = templates.pop();
5431
+ const { snapshotId } = await snapshots.ensure({
5432
+ template: lastTemplate
5433
+ });
5434
+ let lastSnapshotId = snapshotId;
5435
+ while (templates.length > 0) {
5436
+ const template = templates.pop();
5437
+ template.raw.snapshotId = lastSnapshotId;
5438
+ const { snapshotId: snapshotId2 } = await snapshots.ensure({
5439
+ template
5440
+ });
5441
+ lastSnapshotId = snapshotId2;
5442
+ lastTemplate = template;
5245
5443
  }
5444
+ return lastTemplate;
5246
5445
  }
5247
5446
 
5248
5447
  class Freestyle {
@@ -5317,6 +5516,7 @@ exports.Identity = Identity;
5317
5516
  exports.Vm = Vm;
5318
5517
  exports.VmBuilder = VmBuilder;
5319
5518
  exports.VmService = VmService;
5519
+ exports.VmSpec = VmSpec;
5320
5520
  exports.VmTemplate = VmTemplate;
5321
5521
  exports.VmWith = VmWith;
5322
5522
  exports.VmWithInstance = VmWithInstance;