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