freestyle-sandboxes 0.1.15 → 0.1.16

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 +672 -461
  2. package/index.d.cts +690 -433
  3. package/index.d.mts +690 -433
  4. package/index.mjs +671 -462
  5. package/package.json +1 -1
package/index.cjs CHANGED
@@ -1,5 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var glob = require('glob');
4
+ var path = require('path');
5
+ var fs = require('fs/promises');
6
+
3
7
  function errorFromJSON(body) {
4
8
  const ErrorClass = FREESTYLE_ERROR_CODE_MAP[body.code];
5
9
  if (ErrorClass) {
@@ -1292,269 +1296,173 @@ class InvalidRevisionError extends Error {
1292
1296
  static statusCode = 400;
1293
1297
  static description = `Invalid revision: {revision}`;
1294
1298
  }
1295
- class DevServerNotFoundError extends Error {
1299
+ class UnavailableError extends Error {
1296
1300
  constructor(body) {
1297
1301
  super(
1298
- `DEV_SERVER_NOT_FOUND: ${body.message}`
1302
+ `UNAVAILABLE: ${body.message}`
1299
1303
  );
1300
1304
  this.body = body;
1301
- this.name = "DevServerNotFoundError";
1305
+ this.name = "UnavailableError";
1302
1306
  }
1303
- static code = "DEV_SERVER_NOT_FOUND";
1304
- static statusCode = 404;
1305
- static description = `dev server not found`;
1307
+ static code = "UNAVAILABLE";
1308
+ static statusCode = 503;
1309
+ static description = `Cron service unavailable`;
1306
1310
  }
1307
- class BranchNameEmptyError extends Error {
1311
+ class DevServerNotFoundError extends Error {
1308
1312
  constructor(body) {
1309
1313
  super(
1310
- `BRANCH_NAME_EMPTY: ${body.message}`
1314
+ `DEV_SERVER_NOT_FOUND: ${body.message}`
1311
1315
  );
1312
1316
  this.body = body;
1313
- this.name = "BranchNameEmptyError";
1317
+ this.name = "DevServerNotFoundError";
1314
1318
  }
1315
- static code = "BRANCH_NAME_EMPTY";
1316
- static statusCode = 400;
1317
- static description = `Branch name cannot be empty`;
1319
+ static code = "DEV_SERVER_NOT_FOUND";
1320
+ static statusCode = 404;
1321
+ static description = `dev server not found`;
1318
1322
  }
1319
- class ObservabilityDatabaseErrorError extends Error {
1323
+ class BuildFailedError extends Error {
1320
1324
  constructor(body) {
1321
1325
  super(
1322
- `OBSERVABILITY_DATABASE_ERROR: ${body.message}`
1326
+ `BUILD_FAILED: ${body.message}`
1323
1327
  );
1324
1328
  this.body = body;
1325
- this.name = "ObservabilityDatabaseErrorError";
1329
+ this.name = "BuildFailedError";
1326
1330
  }
1327
- static code = "OBSERVABILITY_DATABASE_ERROR";
1331
+ static code = "BUILD_FAILED";
1328
1332
  static statusCode = 500;
1329
- static description = `Database operation failed: {message}`;
1333
+ static description = `Build failed on VM {vm_id}`;
1330
1334
  }
1331
- class ObservabilityAccessDeniedError extends Error {
1335
+ class ServerDeploymentFailedError extends Error {
1332
1336
  constructor(body) {
1333
1337
  super(
1334
- `OBSERVABILITY_ACCESS_DENIED: ${body.message}`
1338
+ `SERVER_DEPLOYMENT_FAILED: ${body.message}`
1335
1339
  );
1336
1340
  this.body = body;
1337
- this.name = "ObservabilityAccessDeniedError";
1341
+ this.name = "ServerDeploymentFailedError";
1338
1342
  }
1339
- static code = "OBSERVABILITY_ACCESS_DENIED";
1340
- static statusCode = 403;
1341
- static description = `Access denied to logs for deployment: {deployment_id}`;
1343
+ static code = "SERVER_DEPLOYMENT_FAILED";
1344
+ static statusCode = 502;
1345
+ static description = `Failed to deploy to servers`;
1342
1346
  }
1343
- class ParseLogsFailedError extends Error {
1347
+ class LockfileErrorError extends Error {
1344
1348
  constructor(body) {
1345
1349
  super(
1346
- `PARSE_LOGS_FAILED: ${body.message}`
1350
+ `LOCKFILE_ERROR: ${body.message}`
1347
1351
  );
1348
1352
  this.body = body;
1349
- this.name = "ParseLogsFailedError";
1353
+ this.name = "LockfileErrorError";
1350
1354
  }
1351
- static code = "PARSE_LOGS_FAILED";
1355
+ static code = "LOCKFILE_ERROR";
1352
1356
  static statusCode = 500;
1353
- static description = `Failed to parse logs: {message}`;
1357
+ static description = `Failed to generate dependency lockfile: {message}`;
1354
1358
  }
1355
- class RetrieveLogsFailedError extends Error {
1359
+ class UploadErrorError extends Error {
1356
1360
  constructor(body) {
1357
1361
  super(
1358
- `RETRIEVE_LOGS_FAILED: ${body.message}`
1362
+ `UPLOAD_ERROR: ${body.message}`
1359
1363
  );
1360
1364
  this.body = body;
1361
- this.name = "RetrieveLogsFailedError";
1365
+ this.name = "UploadErrorError";
1362
1366
  }
1363
- static code = "RETRIEVE_LOGS_FAILED";
1367
+ static code = "UPLOAD_ERROR";
1364
1368
  static statusCode = 500;
1365
- static description = `Failed to retrieve logs: {message}`;
1366
- }
1367
- class InvalidQueryError extends Error {
1368
- constructor(body) {
1369
- super(
1370
- `INVALID_QUERY: ${body.message}`
1371
- );
1372
- this.body = body;
1373
- this.name = "InvalidQueryError";
1374
- }
1375
- static code = "INVALID_QUERY";
1376
- static statusCode = 400;
1377
- static description = `Invalid log query: {message}`;
1378
- }
1379
- class LogsNotFoundError extends Error {
1380
- constructor(body) {
1381
- super(
1382
- `LOGS_NOT_FOUND: ${body.message}`
1383
- );
1384
- this.body = body;
1385
- this.name = "LogsNotFoundError";
1386
- }
1387
- static code = "LOGS_NOT_FOUND";
1388
- static statusCode = 404;
1389
- static description = `Logs not found for deployment: {deployment_id}`;
1390
- }
1391
- class FailedToProvisionCertificateError extends Error {
1392
- constructor(body) {
1393
- super(
1394
- `FAILED_TO_PROVISION_CERTIFICATE: ${body.message}`
1395
- );
1396
- this.body = body;
1397
- this.name = "FailedToProvisionCertificateError";
1398
- }
1399
- static code = "FAILED_TO_PROVISION_CERTIFICATE";
1400
- static statusCode = 422;
1401
- static description = `Failed to provision certificate: {message}`;
1369
+ static description = `Failed to upload deployment to storage`;
1402
1370
  }
1403
- class FailedToInsertDomainMappingError extends Error {
1371
+ class DomainMappingErrorError extends Error {
1404
1372
  constructor(body) {
1405
1373
  super(
1406
- `FAILED_TO_INSERT_DOMAIN_MAPPING: ${body.message}`
1374
+ `DOMAIN_MAPPING_ERROR: ${body.message}`
1407
1375
  );
1408
1376
  this.body = body;
1409
- this.name = "FailedToInsertDomainMappingError";
1377
+ this.name = "DomainMappingErrorError";
1410
1378
  }
1411
- static code = "FAILED_TO_INSERT_DOMAIN_MAPPING";
1379
+ static code = "DOMAIN_MAPPING_ERROR";
1412
1380
  static statusCode = 500;
1413
- static description = `Failed to insert domain mapping: {message}`;
1414
- }
1415
- class PermissionDeniedError extends Error {
1416
- constructor(body) {
1417
- super(
1418
- `PERMISSION_DENIED: ${body.message}`
1419
- );
1420
- this.body = body;
1421
- this.name = "PermissionDeniedError";
1422
- }
1423
- static code = "PERMISSION_DENIED";
1424
- static statusCode = 401;
1425
- static description = `Permission denied: {message}`;
1381
+ static description = `Failed to configure domain mapping for: {domain}`;
1426
1382
  }
1427
- class FailedToCheckPermissionsError extends Error {
1383
+ class CertificateProvisioningErrorError extends Error {
1428
1384
  constructor(body) {
1429
1385
  super(
1430
- `FAILED_TO_CHECK_PERMISSIONS: ${body.message}`
1386
+ `CERTIFICATE_PROVISIONING_ERROR: ${body.message}`
1431
1387
  );
1432
1388
  this.body = body;
1433
- this.name = "FailedToCheckPermissionsError";
1389
+ this.name = "CertificateProvisioningErrorError";
1434
1390
  }
1435
- static code = "FAILED_TO_CHECK_PERMISSIONS";
1391
+ static code = "CERTIFICATE_PROVISIONING_ERROR";
1436
1392
  static statusCode = 502;
1437
- static description = `Failed to check permissions: {message}`;
1438
- }
1439
- class FailedToListDomainsError extends Error {
1440
- constructor(body) {
1441
- super(
1442
- `FAILED_TO_LIST_DOMAINS: ${body.message}`
1443
- );
1444
- this.body = body;
1445
- this.name = "FailedToListDomainsError";
1446
- }
1447
- static code = "FAILED_TO_LIST_DOMAINS";
1448
- static statusCode = 500;
1449
- static description = `Failed to list domains: {message}`;
1450
- }
1451
- class FailedToListVerificationsError extends Error {
1452
- constructor(body) {
1453
- super(
1454
- `FAILED_TO_LIST_VERIFICATIONS: ${body.message}`
1455
- );
1456
- this.body = body;
1457
- this.name = "FailedToListVerificationsError";
1458
- }
1459
- static code = "FAILED_TO_LIST_VERIFICATIONS";
1460
- static statusCode = 500;
1461
- static description = `Failed to list verifications: {message}`;
1462
- }
1463
- class FailedToVerifyDomainError extends Error {
1464
- constructor(body) {
1465
- super(
1466
- `FAILED_TO_VERIFY_DOMAIN: ${body.message}`
1467
- );
1468
- this.body = body;
1469
- this.name = "FailedToVerifyDomainError";
1470
- }
1471
- static code = "FAILED_TO_VERIFY_DOMAIN";
1472
- static statusCode = 500;
1473
- static description = `Failed to verify domain: {message}`;
1393
+ static description = `Failed to provision certificate for domain: {domain}`;
1474
1394
  }
1475
- class VerificationFailedError extends Error {
1395
+ class NoEntrypointFoundError extends Error {
1476
1396
  constructor(body) {
1477
1397
  super(
1478
- `VERIFICATION_FAILED: ${body.message}`
1398
+ `NO_ENTRYPOINT_FOUND: ${body.message}`
1479
1399
  );
1480
1400
  this.body = body;
1481
- this.name = "VerificationFailedError";
1401
+ this.name = "NoEntrypointFoundError";
1482
1402
  }
1483
- static code = "VERIFICATION_FAILED";
1403
+ static code = "NO_ENTRYPOINT_FOUND";
1484
1404
  static statusCode = 400;
1485
- static description = `Domain verification failed: {message}`;
1405
+ static description = `No entrypoint found in deployment`;
1486
1406
  }
1487
- class FailedToDeleteVerificationError extends Error {
1407
+ class EntrypointNotFoundError extends Error {
1488
1408
  constructor(body) {
1489
1409
  super(
1490
- `FAILED_TO_DELETE_VERIFICATION: ${body.message}`
1410
+ `ENTRYPOINT_NOT_FOUND: ${body.message}`
1491
1411
  );
1492
1412
  this.body = body;
1493
- this.name = "FailedToDeleteVerificationError";
1413
+ this.name = "EntrypointNotFoundError";
1494
1414
  }
1495
- static code = "FAILED_TO_DELETE_VERIFICATION";
1415
+ static code = "ENTRYPOINT_NOT_FOUND";
1496
1416
  static statusCode = 400;
1497
- static description = `Failed to delete verification: {message}`;
1417
+ static description = `Entrypoint not found: {entrypoint}`;
1498
1418
  }
1499
- class VerificationNotFoundError extends Error {
1419
+ class NoDomainOwnershipError extends Error {
1500
1420
  constructor(body) {
1501
1421
  super(
1502
- `VERIFICATION_NOT_FOUND: ${body.message}`
1422
+ `NO_DOMAIN_OWNERSHIP: ${body.message}`
1503
1423
  );
1504
1424
  this.body = body;
1505
- this.name = "VerificationNotFoundError";
1425
+ this.name = "NoDomainOwnershipError";
1506
1426
  }
1507
- static code = "VERIFICATION_NOT_FOUND";
1508
- static statusCode = 404;
1509
- static description = `Verification request not found for domain: {domain}`;
1427
+ static code = "NO_DOMAIN_OWNERSHIP";
1428
+ static statusCode = 403;
1429
+ static description = `No domain ownership for: {domain}`;
1510
1430
  }
1511
- class FailedToCreateVerificationCodeError extends Error {
1431
+ class InvalidDomainsError extends Error {
1512
1432
  constructor(body) {
1513
1433
  super(
1514
- `FAILED_TO_CREATE_VERIFICATION_CODE: ${body.message}`
1434
+ `INVALID_DOMAINS: ${body.message}`
1515
1435
  );
1516
1436
  this.body = body;
1517
- this.name = "FailedToCreateVerificationCodeError";
1437
+ this.name = "InvalidDomainsError";
1518
1438
  }
1519
- static code = "FAILED_TO_CREATE_VERIFICATION_CODE";
1439
+ static code = "INVALID_DOMAINS";
1520
1440
  static statusCode = 400;
1521
- static description = `Failed to create verification code: {message}`;
1441
+ static description = `Invalid domains provided`;
1522
1442
  }
1523
- class InvalidDomainError extends Error {
1443
+ class WebDeploymentBadRequestError extends Error {
1524
1444
  constructor(body) {
1525
1445
  super(
1526
- `INVALID_DOMAIN: ${body.message}`
1446
+ `WEB_DEPLOYMENT_BAD_REQUEST: ${body.message}`
1527
1447
  );
1528
1448
  this.body = body;
1529
- this.name = "InvalidDomainError";
1449
+ this.name = "WebDeploymentBadRequestError";
1530
1450
  }
1531
- static code = "INVALID_DOMAIN";
1451
+ static code = "WEB_DEPLOYMENT_BAD_REQUEST";
1532
1452
  static statusCode = 400;
1533
- static description = `Invalid domain: {domain}`;
1534
- }
1535
- class ResizeFailedError extends Error {
1536
- constructor(body) {
1537
- super(
1538
- `RESIZE_FAILED: ${body.message}`
1539
- );
1540
- this.body = body;
1541
- this.name = "ResizeFailedError";
1542
- }
1543
- static code = "RESIZE_FAILED";
1544
- static statusCode = 500;
1545
- static description = `Failed to resize VM: {message}`;
1453
+ static description = `Bad request: {message}`;
1546
1454
  }
1547
- class InternalResizeVmNotFoundError extends Error {
1455
+ class DeploymentNotFoundError extends Error {
1548
1456
  constructor(body) {
1549
1457
  super(
1550
- `INTERNAL_RESIZE_VM_NOT_FOUND: ${body.message}`
1458
+ `DEPLOYMENT_NOT_FOUND: ${body.message}`
1551
1459
  );
1552
1460
  this.body = body;
1553
- this.name = "InternalResizeVmNotFoundError";
1461
+ this.name = "DeploymentNotFoundError";
1554
1462
  }
1555
- static code = "INTERNAL_RESIZE_VM_NOT_FOUND";
1463
+ static code = "DEPLOYMENT_NOT_FOUND";
1556
1464
  static statusCode = 404;
1557
- static description = `VM not found`;
1465
+ static description = `Deployment not found`;
1558
1466
  }
1559
1467
  class PermissionAlreadyExistsError extends Error {
1560
1468
  constructor(body) {
@@ -2300,521 +2208,653 @@ class ProjectNotFoundError extends Error {
2300
2208
  static statusCode = 404;
2301
2209
  static description = `Project not found: {project_id}`;
2302
2210
  }
2303
- class UnauthorizedErrorError extends Error {
2211
+ class ScheduleNotFoundError extends Error {
2304
2212
  constructor(body) {
2305
2213
  super(
2306
- `UNAUTHORIZED_ERROR: ${body.message}`
2214
+ `SCHEDULE_NOT_FOUND: ${body.message}`
2307
2215
  );
2308
2216
  this.body = body;
2309
- this.name = "UnauthorizedErrorError";
2217
+ this.name = "ScheduleNotFoundError";
2310
2218
  }
2311
- static code = "UNAUTHORIZED_ERROR";
2312
- static statusCode = 401;
2313
- static description = `Unauthorized request to {route}`;
2219
+ static code = "SCHEDULE_NOT_FOUND";
2220
+ static statusCode = 404;
2221
+ static description = `Schedule not found`;
2314
2222
  }
2315
- class BuildFailedError extends Error {
2223
+ class ServiceUnavailableError extends Error {
2316
2224
  constructor(body) {
2317
2225
  super(
2318
- `BUILD_FAILED: ${body.message}`
2226
+ `SERVICE_UNAVAILABLE: ${body.message}`
2319
2227
  );
2320
2228
  this.body = body;
2321
- this.name = "BuildFailedError";
2229
+ this.name = "ServiceUnavailableError";
2322
2230
  }
2323
- static code = "BUILD_FAILED";
2324
- static statusCode = 500;
2325
- static description = `Build failed on VM {vm_id}`;
2231
+ static code = "SERVICE_UNAVAILABLE";
2232
+ static statusCode = 503;
2233
+ static description = `Cron service not configured`;
2326
2234
  }
2327
- class ServerDeploymentFailedError extends Error {
2235
+ class UnauthorizedErrorError extends Error {
2328
2236
  constructor(body) {
2329
2237
  super(
2330
- `SERVER_DEPLOYMENT_FAILED: ${body.message}`
2238
+ `UNAUTHORIZED_ERROR: ${body.message}`
2331
2239
  );
2332
2240
  this.body = body;
2333
- this.name = "ServerDeploymentFailedError";
2241
+ this.name = "UnauthorizedErrorError";
2334
2242
  }
2335
- static code = "SERVER_DEPLOYMENT_FAILED";
2336
- static statusCode = 502;
2337
- static description = `Failed to deploy to servers`;
2243
+ static code = "UNAUTHORIZED_ERROR";
2244
+ static statusCode = 401;
2245
+ static description = `Unauthorized request to {route}`;
2338
2246
  }
2339
- class LockfileErrorError extends Error {
2247
+ class AnyhowError extends Error {
2340
2248
  constructor(body) {
2341
2249
  super(
2342
- `LOCKFILE_ERROR: ${body.message}`
2250
+ `ANYHOW: ${body.message}`
2343
2251
  );
2344
2252
  this.body = body;
2345
- this.name = "LockfileErrorError";
2253
+ this.name = "AnyhowError";
2346
2254
  }
2347
- static code = "LOCKFILE_ERROR";
2255
+ static code = "ANYHOW";
2348
2256
  static statusCode = 500;
2349
- static description = `Failed to generate dependency lockfile: {message}`;
2257
+ static description = `Internal server error: {0}`;
2350
2258
  }
2351
- class UploadErrorError extends Error {
2259
+ class BrowserOperationFailedError extends Error {
2352
2260
  constructor(body) {
2353
2261
  super(
2354
- `UPLOAD_ERROR: ${body.message}`
2262
+ `BROWSER_OPERATION_FAILED: ${body.message}`
2355
2263
  );
2356
2264
  this.body = body;
2357
- this.name = "UploadErrorError";
2265
+ this.name = "BrowserOperationFailedError";
2358
2266
  }
2359
- static code = "UPLOAD_ERROR";
2267
+ static code = "BROWSER_OPERATION_FAILED";
2360
2268
  static statusCode = 500;
2361
- static description = `Failed to upload deployment to storage`;
2269
+ static description = `Browser operation failed: {message}`;
2362
2270
  }
2363
- class DomainMappingErrorError extends Error {
2271
+ class WatchFilesFailedError extends Error {
2364
2272
  constructor(body) {
2365
2273
  super(
2366
- `DOMAIN_MAPPING_ERROR: ${body.message}`
2274
+ `WATCH_FILES_FAILED: ${body.message}`
2367
2275
  );
2368
2276
  this.body = body;
2369
- this.name = "DomainMappingErrorError";
2277
+ this.name = "WatchFilesFailedError";
2370
2278
  }
2371
- static code = "DOMAIN_MAPPING_ERROR";
2279
+ static code = "WATCH_FILES_FAILED";
2372
2280
  static statusCode = 500;
2373
- static description = `Failed to configure domain mapping for: {domain}`;
2281
+ static description = `Failed to watch files: {message}`;
2374
2282
  }
2375
- class CertificateProvisioningErrorError extends Error {
2283
+ class LogsFailedError extends Error {
2376
2284
  constructor(body) {
2377
2285
  super(
2378
- `CERTIFICATE_PROVISIONING_ERROR: ${body.message}`
2286
+ `LOGS_FAILED: ${body.message}`
2379
2287
  );
2380
2288
  this.body = body;
2381
- this.name = "CertificateProvisioningErrorError";
2289
+ this.name = "LogsFailedError";
2382
2290
  }
2383
- static code = "CERTIFICATE_PROVISIONING_ERROR";
2384
- static statusCode = 502;
2385
- static description = `Failed to provision certificate for domain: {domain}`;
2291
+ static code = "LOGS_FAILED";
2292
+ static statusCode = 500;
2293
+ static description = `Failed to get logs: {message}`;
2386
2294
  }
2387
- class NoEntrypointFoundError extends Error {
2295
+ class StatusFailedError extends Error {
2388
2296
  constructor(body) {
2389
2297
  super(
2390
- `NO_ENTRYPOINT_FOUND: ${body.message}`
2298
+ `STATUS_FAILED: ${body.message}`
2391
2299
  );
2392
2300
  this.body = body;
2393
- this.name = "NoEntrypointFoundError";
2301
+ this.name = "StatusFailedError";
2394
2302
  }
2395
- static code = "NO_ENTRYPOINT_FOUND";
2396
- static statusCode = 400;
2397
- static description = `No entrypoint found in deployment`;
2303
+ static code = "STATUS_FAILED";
2304
+ static statusCode = 500;
2305
+ static description = `Failed to get dev server status: {message}`;
2398
2306
  }
2399
- class EntrypointNotFoundError extends Error {
2307
+ class RestartFailedError extends Error {
2400
2308
  constructor(body) {
2401
2309
  super(
2402
- `ENTRYPOINT_NOT_FOUND: ${body.message}`
2310
+ `RESTART_FAILED: ${body.message}`
2403
2311
  );
2404
2312
  this.body = body;
2405
- this.name = "EntrypointNotFoundError";
2313
+ this.name = "RestartFailedError";
2406
2314
  }
2407
- static code = "ENTRYPOINT_NOT_FOUND";
2408
- static statusCode = 400;
2409
- static description = `Entrypoint not found: {entrypoint}`;
2315
+ static code = "RESTART_FAILED";
2316
+ static statusCode = 500;
2317
+ static description = `Failed to restart dev server: {message}`;
2410
2318
  }
2411
- class NoDomainOwnershipError extends Error {
2319
+ class ShutdownFailedError extends Error {
2412
2320
  constructor(body) {
2413
2321
  super(
2414
- `NO_DOMAIN_OWNERSHIP: ${body.message}`
2322
+ `SHUTDOWN_FAILED: ${body.message}`
2415
2323
  );
2416
2324
  this.body = body;
2417
- this.name = "NoDomainOwnershipError";
2325
+ this.name = "ShutdownFailedError";
2418
2326
  }
2419
- static code = "NO_DOMAIN_OWNERSHIP";
2420
- static statusCode = 403;
2421
- static description = `No domain ownership for: {domain}`;
2327
+ static code = "SHUTDOWN_FAILED";
2328
+ static statusCode = 500;
2329
+ static description = `Failed to shutdown dev server: {message}`;
2422
2330
  }
2423
- class InvalidDomainsError extends Error {
2331
+ class CommitFailedError extends Error {
2424
2332
  constructor(body) {
2425
2333
  super(
2426
- `INVALID_DOMAINS: ${body.message}`
2334
+ `COMMIT_FAILED: ${body.message}`
2427
2335
  );
2428
2336
  this.body = body;
2429
- this.name = "InvalidDomainsError";
2337
+ this.name = "CommitFailedError";
2430
2338
  }
2431
- static code = "INVALID_DOMAINS";
2432
- static statusCode = 400;
2433
- static description = `Invalid domains provided`;
2339
+ static code = "COMMIT_FAILED";
2340
+ static statusCode = 500;
2341
+ static description = `Failed to commit changes: {message}`;
2434
2342
  }
2435
- class WebDeploymentBadRequestError extends Error {
2343
+ class WriteFileFailedError extends Error {
2436
2344
  constructor(body) {
2437
2345
  super(
2438
- `WEB_DEPLOYMENT_BAD_REQUEST: ${body.message}`
2346
+ `WRITE_FILE_FAILED: ${body.message}`
2439
2347
  );
2440
2348
  this.body = body;
2441
- this.name = "WebDeploymentBadRequestError";
2349
+ this.name = "WriteFileFailedError";
2442
2350
  }
2443
- static code = "WEB_DEPLOYMENT_BAD_REQUEST";
2444
- static statusCode = 400;
2445
- static description = `Bad request: {message}`;
2351
+ static code = "WRITE_FILE_FAILED";
2352
+ static statusCode = 500;
2353
+ static description = `Failed to write file: {message}`;
2446
2354
  }
2447
- class DeploymentNotFoundError extends Error {
2355
+ class ReadFileFailedError extends Error {
2448
2356
  constructor(body) {
2449
2357
  super(
2450
- `DEPLOYMENT_NOT_FOUND: ${body.message}`
2358
+ `READ_FILE_FAILED: ${body.message}`
2451
2359
  );
2452
2360
  this.body = body;
2453
- this.name = "DeploymentNotFoundError";
2361
+ this.name = "ReadFileFailedError";
2454
2362
  }
2455
- static code = "DEPLOYMENT_NOT_FOUND";
2456
- static statusCode = 404;
2457
- static description = `Deployment not found`;
2363
+ static code = "READ_FILE_FAILED";
2364
+ static statusCode = 500;
2365
+ static description = `Failed to read file: {message}`;
2458
2366
  }
2459
- class DomainOwnershipVerificationFailedError extends Error {
2367
+ class ExecutionFailedError extends Error {
2460
2368
  constructor(body) {
2461
2369
  super(
2462
- `DOMAIN_OWNERSHIP_VERIFICATION_FAILED: ${body.message}`
2370
+ `EXECUTION_FAILED: ${body.message}`
2463
2371
  );
2464
2372
  this.body = body;
2465
- this.name = "DomainOwnershipVerificationFailedError";
2373
+ this.name = "ExecutionFailedError";
2466
2374
  }
2467
- static code = "DOMAIN_OWNERSHIP_VERIFICATION_FAILED";
2468
- static statusCode = 403;
2469
- static description = `Domain ownership verification failed`;
2375
+ static code = "EXECUTION_FAILED";
2376
+ static statusCode = 500;
2377
+ static description = `Failed to execute command: {message}`;
2470
2378
  }
2471
- class ErrorDeletingRecordError extends Error {
2379
+ class RequestFailedError extends Error {
2472
2380
  constructor(body) {
2473
2381
  super(
2474
- `ERROR_DELETING_RECORD: ${body.message}`
2382
+ `REQUEST_FAILED: ${body.message}`
2475
2383
  );
2476
2384
  this.body = body;
2477
- this.name = "ErrorDeletingRecordError";
2385
+ this.name = "RequestFailedError";
2478
2386
  }
2479
- static code = "ERROR_DELETING_RECORD";
2387
+ static code = "REQUEST_FAILED";
2480
2388
  static statusCode = 500;
2481
- static description = `Error deleting DNS record for {domain}/{name}: {message}`;
2389
+ static description = `Failed to request dev server: {message}`;
2482
2390
  }
2483
- class RecordOwnershipErrorError extends Error {
2391
+ class DevServerFileNotFoundError extends Error {
2484
2392
  constructor(body) {
2485
2393
  super(
2486
- `RECORD_OWNERSHIP_ERROR: ${body.message}`
2394
+ `DEV_SERVER_FILE_NOT_FOUND: ${body.message}`
2487
2395
  );
2488
2396
  this.body = body;
2489
- this.name = "RecordOwnershipErrorError";
2397
+ this.name = "DevServerFileNotFoundError";
2490
2398
  }
2491
- static code = "RECORD_OWNERSHIP_ERROR";
2492
- static statusCode = 403;
2493
- static description = `Account {account_id} does not own record {record_id}`;
2399
+ static code = "DEV_SERVER_FILE_NOT_FOUND";
2400
+ static statusCode = 404;
2401
+ static description = `Dev server file not found: {path}`;
2494
2402
  }
2495
- class ErrorCreatingRecordError extends Error {
2403
+ class DevServerInvalidRequestError extends Error {
2496
2404
  constructor(body) {
2497
2405
  super(
2498
- `ERROR_CREATING_RECORD: ${body.message}`
2406
+ `DEV_SERVER_INVALID_REQUEST: ${body.message}`
2499
2407
  );
2500
2408
  this.body = body;
2501
- this.name = "ErrorCreatingRecordError";
2409
+ this.name = "DevServerInvalidRequestError";
2502
2410
  }
2503
- static code = "ERROR_CREATING_RECORD";
2504
- static statusCode = 500;
2505
- static description = `Error creating DNS record: {message}`;
2411
+ static code = "DEV_SERVER_INVALID_REQUEST";
2412
+ static statusCode = 400;
2413
+ static description = `Invalid dev server request: {message}`;
2506
2414
  }
2507
- class DomainOwnershipErrorError extends Error {
2415
+ class EmptyTagError extends Error {
2508
2416
  constructor(body) {
2509
2417
  super(
2510
- `DOMAIN_OWNERSHIP_ERROR: ${body.message}`
2418
+ `EMPTY_TAG: ${body.message}`
2511
2419
  );
2512
2420
  this.body = body;
2513
- this.name = "DomainOwnershipErrorError";
2421
+ this.name = "EmptyTagError";
2514
2422
  }
2515
- static code = "DOMAIN_OWNERSHIP_ERROR";
2516
- static statusCode = 403;
2517
- static description = `Account {account_id} does not own domain {domain}`;
2423
+ static code = "EMPTY_TAG";
2424
+ static statusCode = 400;
2425
+ static description = `Invalid request: tag cannot be empty`;
2518
2426
  }
2519
- class AnyhowError extends Error {
2427
+ class BranchNameEmptyError extends Error {
2520
2428
  constructor(body) {
2521
2429
  super(
2522
- `ANYHOW: ${body.message}`
2430
+ `BRANCH_NAME_EMPTY: ${body.message}`
2523
2431
  );
2524
2432
  this.body = body;
2525
- this.name = "AnyhowError";
2433
+ this.name = "BranchNameEmptyError";
2526
2434
  }
2527
- static code = "ANYHOW";
2528
- static statusCode = 500;
2529
- static description = `Internal server error: {0}`;
2435
+ static code = "BRANCH_NAME_EMPTY";
2436
+ static statusCode = 400;
2437
+ static description = `Branch name cannot be empty`;
2530
2438
  }
2531
- class EmptyTagError extends Error {
2439
+ class ResizeFailedError extends Error {
2532
2440
  constructor(body) {
2533
2441
  super(
2534
- `EMPTY_TAG: ${body.message}`
2442
+ `RESIZE_FAILED: ${body.message}`
2535
2443
  );
2536
2444
  this.body = body;
2537
- this.name = "EmptyTagError";
2445
+ this.name = "ResizeFailedError";
2538
2446
  }
2539
- static code = "EMPTY_TAG";
2540
- static statusCode = 400;
2541
- static description = `Invalid request: tag cannot be empty`;
2447
+ static code = "RESIZE_FAILED";
2448
+ static statusCode = 500;
2449
+ static description = `Failed to resize VM: {message}`;
2542
2450
  }
2543
- class DomainOwnershipNotVerifiedError extends Error {
2451
+ class InternalResizeVmNotFoundError extends Error {
2544
2452
  constructor(body) {
2545
2453
  super(
2546
- `DOMAIN_OWNERSHIP_NOT_VERIFIED: ${body.message}`
2454
+ `INTERNAL_RESIZE_VM_NOT_FOUND: ${body.message}`
2547
2455
  );
2548
2456
  this.body = body;
2549
- this.name = "DomainOwnershipNotVerifiedError";
2457
+ this.name = "InternalResizeVmNotFoundError";
2550
2458
  }
2551
- static code = "DOMAIN_OWNERSHIP_NOT_VERIFIED";
2552
- static statusCode = 401;
2553
- static description = `You have not verified ownership of domain: {domain}`;
2459
+ static code = "INTERNAL_RESIZE_VM_NOT_FOUND";
2460
+ static statusCode = 404;
2461
+ static description = `VM not found`;
2554
2462
  }
2555
- class VmAccessDeniedForMappingError extends Error {
2463
+ class ObservabilityDatabaseErrorError extends Error {
2556
2464
  constructor(body) {
2557
2465
  super(
2558
- `VM_ACCESS_DENIED_FOR_MAPPING: ${body.message}`
2466
+ `OBSERVABILITY_DATABASE_ERROR: ${body.message}`
2559
2467
  );
2560
2468
  this.body = body;
2561
- this.name = "VmAccessDeniedForMappingError";
2469
+ this.name = "ObservabilityDatabaseErrorError";
2562
2470
  }
2563
- static code = "VM_ACCESS_DENIED_FOR_MAPPING";
2564
- static statusCode = 401;
2565
- static description = `You do not have permission to map to this VM: {vm_id}`;
2471
+ static code = "OBSERVABILITY_DATABASE_ERROR";
2472
+ static statusCode = 500;
2473
+ static description = `Database operation failed: {message}`;
2566
2474
  }
2567
- class DeploymentAccessDeniedError extends Error {
2475
+ class ObservabilityAccessDeniedError extends Error {
2568
2476
  constructor(body) {
2569
2477
  super(
2570
- `DEPLOYMENT_ACCESS_DENIED: ${body.message}`
2478
+ `OBSERVABILITY_ACCESS_DENIED: ${body.message}`
2571
2479
  );
2572
2480
  this.body = body;
2573
- this.name = "DeploymentAccessDeniedError";
2481
+ this.name = "ObservabilityAccessDeniedError";
2574
2482
  }
2575
- static code = "DEPLOYMENT_ACCESS_DENIED";
2576
- static statusCode = 401;
2577
- static description = `You do not have permission to map to this deployment: {deployment_id}`;
2483
+ static code = "OBSERVABILITY_ACCESS_DENIED";
2484
+ static statusCode = 403;
2485
+ static description = `Access denied to logs for deployment: {deployment_id}`;
2578
2486
  }
2579
- class FailedToProvisionCertificateForMappingError extends Error {
2487
+ class ParseLogsFailedError extends Error {
2580
2488
  constructor(body) {
2581
2489
  super(
2582
- `FAILED_TO_PROVISION_CERTIFICATE_FOR_MAPPING: ${body.message}`
2490
+ `PARSE_LOGS_FAILED: ${body.message}`
2583
2491
  );
2584
2492
  this.body = body;
2585
- this.name = "FailedToProvisionCertificateForMappingError";
2493
+ this.name = "ParseLogsFailedError";
2586
2494
  }
2587
- static code = "FAILED_TO_PROVISION_CERTIFICATE_FOR_MAPPING";
2588
- static statusCode = 422;
2589
- static description = `Failed to provision certificate for mapping: {message}`;
2495
+ static code = "PARSE_LOGS_FAILED";
2496
+ static statusCode = 500;
2497
+ static description = `Failed to parse logs: {message}`;
2590
2498
  }
2591
- class FailedInsertDomainMappingError extends Error {
2499
+ class RetrieveLogsFailedError extends Error {
2592
2500
  constructor(body) {
2593
2501
  super(
2594
- `FAILED_INSERT_DOMAIN_MAPPING: ${body.message}`
2502
+ `RETRIEVE_LOGS_FAILED: ${body.message}`
2595
2503
  );
2596
2504
  this.body = body;
2597
- this.name = "FailedInsertDomainMappingError";
2505
+ this.name = "RetrieveLogsFailedError";
2598
2506
  }
2599
- static code = "FAILED_INSERT_DOMAIN_MAPPING";
2507
+ static code = "RETRIEVE_LOGS_FAILED";
2600
2508
  static statusCode = 500;
2601
- static description = `Failed to insert domain mapping: {message}`;
2509
+ static description = `Failed to retrieve logs: {message}`;
2602
2510
  }
2603
- class DomainAlreadyExistsError extends Error {
2511
+ class InvalidQueryError extends Error {
2604
2512
  constructor(body) {
2605
2513
  super(
2606
- `DOMAIN_ALREADY_EXISTS: ${body.message}`
2514
+ `INVALID_QUERY: ${body.message}`
2607
2515
  );
2608
2516
  this.body = body;
2609
- this.name = "DomainAlreadyExistsError";
2517
+ this.name = "InvalidQueryError";
2610
2518
  }
2611
- static code = "DOMAIN_ALREADY_EXISTS";
2519
+ static code = "INVALID_QUERY";
2612
2520
  static statusCode = 400;
2613
- static description = `Domain already exists: {domain}`;
2521
+ static description = `Invalid log query: {message}`;
2614
2522
  }
2615
- class FailedToInsertOwnershipError extends Error {
2523
+ class LogsNotFoundError extends Error {
2616
2524
  constructor(body) {
2617
2525
  super(
2618
- `FAILED_TO_INSERT_OWNERSHIP: ${body.message}`
2526
+ `LOGS_NOT_FOUND: ${body.message}`
2619
2527
  );
2620
2528
  this.body = body;
2621
- this.name = "FailedToInsertOwnershipError";
2529
+ this.name = "LogsNotFoundError";
2622
2530
  }
2623
- static code = "FAILED_TO_INSERT_OWNERSHIP";
2624
- static statusCode = 500;
2625
- static description = `Failed to insert domain ownership: {message}`;
2531
+ static code = "LOGS_NOT_FOUND";
2532
+ static statusCode = 404;
2533
+ static description = `Logs not found for deployment: {deployment_id}`;
2626
2534
  }
2627
- class FailedRemoveDomainMappingError extends Error {
2535
+ class FailedToProvisionCertificateError extends Error {
2628
2536
  constructor(body) {
2629
2537
  super(
2630
- `FAILED_REMOVE_DOMAIN_MAPPING: ${body.message}`
2538
+ `FAILED_TO_PROVISION_CERTIFICATE: ${body.message}`
2631
2539
  );
2632
2540
  this.body = body;
2633
- this.name = "FailedRemoveDomainMappingError";
2541
+ this.name = "FailedToProvisionCertificateError";
2634
2542
  }
2635
- static code = "FAILED_REMOVE_DOMAIN_MAPPING";
2543
+ static code = "FAILED_TO_PROVISION_CERTIFICATE";
2544
+ static statusCode = 422;
2545
+ static description = `Failed to provision certificate: {message}`;
2546
+ }
2547
+ class FailedToInsertDomainMappingError extends Error {
2548
+ constructor(body) {
2549
+ super(
2550
+ `FAILED_TO_INSERT_DOMAIN_MAPPING: ${body.message}`
2551
+ );
2552
+ this.body = body;
2553
+ this.name = "FailedToInsertDomainMappingError";
2554
+ }
2555
+ static code = "FAILED_TO_INSERT_DOMAIN_MAPPING";
2636
2556
  static statusCode = 500;
2637
- static description = `Failed to remove domain mapping: {message}`;
2557
+ static description = `Failed to insert domain mapping: {message}`;
2638
2558
  }
2639
- class FailedPermissionsCheckError extends Error {
2559
+ class PermissionDeniedError extends Error {
2640
2560
  constructor(body) {
2641
2561
  super(
2642
- `FAILED_PERMISSIONS_CHECK: ${body.message}`
2562
+ `PERMISSION_DENIED: ${body.message}`
2643
2563
  );
2644
2564
  this.body = body;
2645
- this.name = "FailedPermissionsCheckError";
2565
+ this.name = "PermissionDeniedError";
2646
2566
  }
2647
- static code = "FAILED_PERMISSIONS_CHECK";
2567
+ static code = "PERMISSION_DENIED";
2648
2568
  static statusCode = 401;
2649
- static description = `You do not have permission to delete the domain mapping for: {domain}`;
2569
+ static description = `Permission denied: {message}`;
2650
2570
  }
2651
- class FailedToCheckDomainMappingPermissionsError extends Error {
2571
+ class FailedToCheckPermissionsError extends Error {
2652
2572
  constructor(body) {
2653
2573
  super(
2654
- `FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS: ${body.message}`
2574
+ `FAILED_TO_CHECK_PERMISSIONS: ${body.message}`
2655
2575
  );
2656
2576
  this.body = body;
2657
- this.name = "FailedToCheckDomainMappingPermissionsError";
2577
+ this.name = "FailedToCheckPermissionsError";
2658
2578
  }
2659
- static code = "FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS";
2579
+ static code = "FAILED_TO_CHECK_PERMISSIONS";
2660
2580
  static statusCode = 502;
2661
2581
  static description = `Failed to check permissions: {message}`;
2662
2582
  }
2663
- class BrowserOperationFailedError extends Error {
2583
+ class FailedToListDomainsError extends Error {
2664
2584
  constructor(body) {
2665
2585
  super(
2666
- `BROWSER_OPERATION_FAILED: ${body.message}`
2586
+ `FAILED_TO_LIST_DOMAINS: ${body.message}`
2667
2587
  );
2668
2588
  this.body = body;
2669
- this.name = "BrowserOperationFailedError";
2589
+ this.name = "FailedToListDomainsError";
2670
2590
  }
2671
- static code = "BROWSER_OPERATION_FAILED";
2591
+ static code = "FAILED_TO_LIST_DOMAINS";
2672
2592
  static statusCode = 500;
2673
- static description = `Browser operation failed: {message}`;
2593
+ static description = `Failed to list domains: {message}`;
2674
2594
  }
2675
- class WatchFilesFailedError extends Error {
2595
+ class FailedToListVerificationsError extends Error {
2676
2596
  constructor(body) {
2677
2597
  super(
2678
- `WATCH_FILES_FAILED: ${body.message}`
2598
+ `FAILED_TO_LIST_VERIFICATIONS: ${body.message}`
2679
2599
  );
2680
2600
  this.body = body;
2681
- this.name = "WatchFilesFailedError";
2601
+ this.name = "FailedToListVerificationsError";
2682
2602
  }
2683
- static code = "WATCH_FILES_FAILED";
2603
+ static code = "FAILED_TO_LIST_VERIFICATIONS";
2684
2604
  static statusCode = 500;
2685
- static description = `Failed to watch files: {message}`;
2605
+ static description = `Failed to list verifications: {message}`;
2686
2606
  }
2687
- class LogsFailedError extends Error {
2607
+ class FailedToVerifyDomainError extends Error {
2688
2608
  constructor(body) {
2689
2609
  super(
2690
- `LOGS_FAILED: ${body.message}`
2610
+ `FAILED_TO_VERIFY_DOMAIN: ${body.message}`
2691
2611
  );
2692
2612
  this.body = body;
2693
- this.name = "LogsFailedError";
2613
+ this.name = "FailedToVerifyDomainError";
2694
2614
  }
2695
- static code = "LOGS_FAILED";
2615
+ static code = "FAILED_TO_VERIFY_DOMAIN";
2696
2616
  static statusCode = 500;
2697
- static description = `Failed to get logs: {message}`;
2617
+ static description = `Failed to verify domain: {message}`;
2698
2618
  }
2699
- class StatusFailedError extends Error {
2619
+ class VerificationFailedError extends Error {
2700
2620
  constructor(body) {
2701
2621
  super(
2702
- `STATUS_FAILED: ${body.message}`
2622
+ `VERIFICATION_FAILED: ${body.message}`
2703
2623
  );
2704
2624
  this.body = body;
2705
- this.name = "StatusFailedError";
2625
+ this.name = "VerificationFailedError";
2706
2626
  }
2707
- static code = "STATUS_FAILED";
2627
+ static code = "VERIFICATION_FAILED";
2628
+ static statusCode = 400;
2629
+ static description = `Domain verification failed: {message}`;
2630
+ }
2631
+ class FailedToDeleteVerificationError extends Error {
2632
+ constructor(body) {
2633
+ super(
2634
+ `FAILED_TO_DELETE_VERIFICATION: ${body.message}`
2635
+ );
2636
+ this.body = body;
2637
+ this.name = "FailedToDeleteVerificationError";
2638
+ }
2639
+ static code = "FAILED_TO_DELETE_VERIFICATION";
2640
+ static statusCode = 400;
2641
+ static description = `Failed to delete verification: {message}`;
2642
+ }
2643
+ class VerificationNotFoundError extends Error {
2644
+ constructor(body) {
2645
+ super(
2646
+ `VERIFICATION_NOT_FOUND: ${body.message}`
2647
+ );
2648
+ this.body = body;
2649
+ this.name = "VerificationNotFoundError";
2650
+ }
2651
+ static code = "VERIFICATION_NOT_FOUND";
2652
+ static statusCode = 404;
2653
+ static description = `Verification request not found for domain: {domain}`;
2654
+ }
2655
+ class FailedToCreateVerificationCodeError extends Error {
2656
+ constructor(body) {
2657
+ super(
2658
+ `FAILED_TO_CREATE_VERIFICATION_CODE: ${body.message}`
2659
+ );
2660
+ this.body = body;
2661
+ this.name = "FailedToCreateVerificationCodeError";
2662
+ }
2663
+ static code = "FAILED_TO_CREATE_VERIFICATION_CODE";
2664
+ static statusCode = 400;
2665
+ static description = `Failed to create verification code: {message}`;
2666
+ }
2667
+ class InvalidDomainError extends Error {
2668
+ constructor(body) {
2669
+ super(
2670
+ `INVALID_DOMAIN: ${body.message}`
2671
+ );
2672
+ this.body = body;
2673
+ this.name = "InvalidDomainError";
2674
+ }
2675
+ static code = "INVALID_DOMAIN";
2676
+ static statusCode = 400;
2677
+ static description = `Invalid domain: {domain}`;
2678
+ }
2679
+ class DomainOwnershipNotVerifiedError extends Error {
2680
+ constructor(body) {
2681
+ super(
2682
+ `DOMAIN_OWNERSHIP_NOT_VERIFIED: ${body.message}`
2683
+ );
2684
+ this.body = body;
2685
+ this.name = "DomainOwnershipNotVerifiedError";
2686
+ }
2687
+ static code = "DOMAIN_OWNERSHIP_NOT_VERIFIED";
2688
+ static statusCode = 401;
2689
+ static description = `You have not verified ownership of domain: {domain}`;
2690
+ }
2691
+ class VmAccessDeniedForMappingError extends Error {
2692
+ constructor(body) {
2693
+ super(
2694
+ `VM_ACCESS_DENIED_FOR_MAPPING: ${body.message}`
2695
+ );
2696
+ this.body = body;
2697
+ this.name = "VmAccessDeniedForMappingError";
2698
+ }
2699
+ static code = "VM_ACCESS_DENIED_FOR_MAPPING";
2700
+ static statusCode = 401;
2701
+ static description = `You do not have permission to map to this VM: {vm_id}`;
2702
+ }
2703
+ class DeploymentAccessDeniedError extends Error {
2704
+ constructor(body) {
2705
+ super(
2706
+ `DEPLOYMENT_ACCESS_DENIED: ${body.message}`
2707
+ );
2708
+ this.body = body;
2709
+ this.name = "DeploymentAccessDeniedError";
2710
+ }
2711
+ static code = "DEPLOYMENT_ACCESS_DENIED";
2712
+ static statusCode = 401;
2713
+ static description = `You do not have permission to map to this deployment: {deployment_id}`;
2714
+ }
2715
+ class FailedToProvisionCertificateForMappingError extends Error {
2716
+ constructor(body) {
2717
+ super(
2718
+ `FAILED_TO_PROVISION_CERTIFICATE_FOR_MAPPING: ${body.message}`
2719
+ );
2720
+ this.body = body;
2721
+ this.name = "FailedToProvisionCertificateForMappingError";
2722
+ }
2723
+ static code = "FAILED_TO_PROVISION_CERTIFICATE_FOR_MAPPING";
2724
+ static statusCode = 422;
2725
+ static description = `Failed to provision certificate for mapping: {message}`;
2726
+ }
2727
+ class FailedInsertDomainMappingError extends Error {
2728
+ constructor(body) {
2729
+ super(
2730
+ `FAILED_INSERT_DOMAIN_MAPPING: ${body.message}`
2731
+ );
2732
+ this.body = body;
2733
+ this.name = "FailedInsertDomainMappingError";
2734
+ }
2735
+ static code = "FAILED_INSERT_DOMAIN_MAPPING";
2708
2736
  static statusCode = 500;
2709
- static description = `Failed to get dev server status: {message}`;
2737
+ static description = `Failed to insert domain mapping: {message}`;
2710
2738
  }
2711
- class RestartFailedError extends Error {
2739
+ class DomainAlreadyExistsError extends Error {
2712
2740
  constructor(body) {
2713
2741
  super(
2714
- `RESTART_FAILED: ${body.message}`
2742
+ `DOMAIN_ALREADY_EXISTS: ${body.message}`
2715
2743
  );
2716
2744
  this.body = body;
2717
- this.name = "RestartFailedError";
2745
+ this.name = "DomainAlreadyExistsError";
2746
+ }
2747
+ static code = "DOMAIN_ALREADY_EXISTS";
2748
+ static statusCode = 400;
2749
+ static description = `Domain already exists: {domain}`;
2750
+ }
2751
+ class FailedToInsertOwnershipError extends Error {
2752
+ constructor(body) {
2753
+ super(
2754
+ `FAILED_TO_INSERT_OWNERSHIP: ${body.message}`
2755
+ );
2756
+ this.body = body;
2757
+ this.name = "FailedToInsertOwnershipError";
2718
2758
  }
2719
- static code = "RESTART_FAILED";
2759
+ static code = "FAILED_TO_INSERT_OWNERSHIP";
2720
2760
  static statusCode = 500;
2721
- static description = `Failed to restart dev server: {message}`;
2761
+ static description = `Failed to insert domain ownership: {message}`;
2722
2762
  }
2723
- class ShutdownFailedError extends Error {
2763
+ class FailedRemoveDomainMappingError extends Error {
2724
2764
  constructor(body) {
2725
2765
  super(
2726
- `SHUTDOWN_FAILED: ${body.message}`
2766
+ `FAILED_REMOVE_DOMAIN_MAPPING: ${body.message}`
2727
2767
  );
2728
2768
  this.body = body;
2729
- this.name = "ShutdownFailedError";
2769
+ this.name = "FailedRemoveDomainMappingError";
2730
2770
  }
2731
- static code = "SHUTDOWN_FAILED";
2771
+ static code = "FAILED_REMOVE_DOMAIN_MAPPING";
2732
2772
  static statusCode = 500;
2733
- static description = `Failed to shutdown dev server: {message}`;
2773
+ static description = `Failed to remove domain mapping: {message}`;
2734
2774
  }
2735
- class CommitFailedError extends Error {
2775
+ class FailedPermissionsCheckError extends Error {
2736
2776
  constructor(body) {
2737
2777
  super(
2738
- `COMMIT_FAILED: ${body.message}`
2778
+ `FAILED_PERMISSIONS_CHECK: ${body.message}`
2739
2779
  );
2740
2780
  this.body = body;
2741
- this.name = "CommitFailedError";
2781
+ this.name = "FailedPermissionsCheckError";
2742
2782
  }
2743
- static code = "COMMIT_FAILED";
2744
- static statusCode = 500;
2745
- static description = `Failed to commit changes: {message}`;
2783
+ static code = "FAILED_PERMISSIONS_CHECK";
2784
+ static statusCode = 401;
2785
+ static description = `You do not have permission to delete the domain mapping for: {domain}`;
2746
2786
  }
2747
- class WriteFileFailedError extends Error {
2787
+ class FailedToCheckDomainMappingPermissionsError extends Error {
2748
2788
  constructor(body) {
2749
2789
  super(
2750
- `WRITE_FILE_FAILED: ${body.message}`
2790
+ `FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS: ${body.message}`
2751
2791
  );
2752
2792
  this.body = body;
2753
- this.name = "WriteFileFailedError";
2793
+ this.name = "FailedToCheckDomainMappingPermissionsError";
2754
2794
  }
2755
- static code = "WRITE_FILE_FAILED";
2756
- static statusCode = 500;
2757
- static description = `Failed to write file: {message}`;
2795
+ static code = "FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS";
2796
+ static statusCode = 502;
2797
+ static description = `Failed to check permissions: {message}`;
2758
2798
  }
2759
- class ReadFileFailedError extends Error {
2799
+ class DomainOwnershipVerificationFailedError extends Error {
2760
2800
  constructor(body) {
2761
2801
  super(
2762
- `READ_FILE_FAILED: ${body.message}`
2802
+ `DOMAIN_OWNERSHIP_VERIFICATION_FAILED: ${body.message}`
2763
2803
  );
2764
2804
  this.body = body;
2765
- this.name = "ReadFileFailedError";
2805
+ this.name = "DomainOwnershipVerificationFailedError";
2766
2806
  }
2767
- static code = "READ_FILE_FAILED";
2768
- static statusCode = 500;
2769
- static description = `Failed to read file: {message}`;
2807
+ static code = "DOMAIN_OWNERSHIP_VERIFICATION_FAILED";
2808
+ static statusCode = 403;
2809
+ static description = `Domain ownership verification failed`;
2770
2810
  }
2771
- class ExecutionFailedError extends Error {
2811
+ class ErrorDeletingRecordError extends Error {
2772
2812
  constructor(body) {
2773
2813
  super(
2774
- `EXECUTION_FAILED: ${body.message}`
2814
+ `ERROR_DELETING_RECORD: ${body.message}`
2775
2815
  );
2776
2816
  this.body = body;
2777
- this.name = "ExecutionFailedError";
2817
+ this.name = "ErrorDeletingRecordError";
2778
2818
  }
2779
- static code = "EXECUTION_FAILED";
2819
+ static code = "ERROR_DELETING_RECORD";
2780
2820
  static statusCode = 500;
2781
- static description = `Failed to execute command: {message}`;
2821
+ static description = `Error deleting DNS record for {domain}/{name}: {message}`;
2782
2822
  }
2783
- class RequestFailedError extends Error {
2823
+ class RecordOwnershipErrorError extends Error {
2784
2824
  constructor(body) {
2785
2825
  super(
2786
- `REQUEST_FAILED: ${body.message}`
2826
+ `RECORD_OWNERSHIP_ERROR: ${body.message}`
2787
2827
  );
2788
2828
  this.body = body;
2789
- this.name = "RequestFailedError";
2829
+ this.name = "RecordOwnershipErrorError";
2790
2830
  }
2791
- static code = "REQUEST_FAILED";
2792
- static statusCode = 500;
2793
- static description = `Failed to request dev server: {message}`;
2831
+ static code = "RECORD_OWNERSHIP_ERROR";
2832
+ static statusCode = 403;
2833
+ static description = `Account {account_id} does not own record {record_id}`;
2794
2834
  }
2795
- class DevServerFileNotFoundError extends Error {
2835
+ class ErrorCreatingRecordError extends Error {
2796
2836
  constructor(body) {
2797
2837
  super(
2798
- `DEV_SERVER_FILE_NOT_FOUND: ${body.message}`
2838
+ `ERROR_CREATING_RECORD: ${body.message}`
2799
2839
  );
2800
2840
  this.body = body;
2801
- this.name = "DevServerFileNotFoundError";
2841
+ this.name = "ErrorCreatingRecordError";
2802
2842
  }
2803
- static code = "DEV_SERVER_FILE_NOT_FOUND";
2804
- static statusCode = 404;
2805
- static description = `Dev server file not found: {path}`;
2843
+ static code = "ERROR_CREATING_RECORD";
2844
+ static statusCode = 500;
2845
+ static description = `Error creating DNS record: {message}`;
2806
2846
  }
2807
- class DevServerInvalidRequestError extends Error {
2847
+ class DomainOwnershipErrorError extends Error {
2808
2848
  constructor(body) {
2809
2849
  super(
2810
- `DEV_SERVER_INVALID_REQUEST: ${body.message}`
2850
+ `DOMAIN_OWNERSHIP_ERROR: ${body.message}`
2811
2851
  );
2812
2852
  this.body = body;
2813
- this.name = "DevServerInvalidRequestError";
2853
+ this.name = "DomainOwnershipErrorError";
2814
2854
  }
2815
- static code = "DEV_SERVER_INVALID_REQUEST";
2816
- static statusCode = 400;
2817
- static description = `Invalid dev server request: {message}`;
2855
+ static code = "DOMAIN_OWNERSHIP_ERROR";
2856
+ static statusCode = 403;
2857
+ static description = `Account {account_id} does not own domain {domain}`;
2818
2858
  }
2819
2859
  const FREESTYLE_ERROR_CODE_MAP = {
2820
2860
  "GIT_ERROR": GitErrorError,
@@ -2924,28 +2964,20 @@ const FREESTYLE_ERROR_CODE_MAP = {
2924
2964
  "IMPORT_SUBDIR_NOT_FOUND": ImportSubdirNotFoundError,
2925
2965
  "CONFLICT": ConflictError,
2926
2966
  "INVALID_REVISION": InvalidRevisionError,
2967
+ "UNAVAILABLE": UnavailableError,
2927
2968
  "DEV_SERVER_NOT_FOUND": DevServerNotFoundError,
2928
- "BRANCH_NAME_EMPTY": BranchNameEmptyError,
2929
- "OBSERVABILITY_DATABASE_ERROR": ObservabilityDatabaseErrorError,
2930
- "OBSERVABILITY_ACCESS_DENIED": ObservabilityAccessDeniedError,
2931
- "PARSE_LOGS_FAILED": ParseLogsFailedError,
2932
- "RETRIEVE_LOGS_FAILED": RetrieveLogsFailedError,
2933
- "INVALID_QUERY": InvalidQueryError,
2934
- "LOGS_NOT_FOUND": LogsNotFoundError,
2935
- "FAILED_TO_PROVISION_CERTIFICATE": FailedToProvisionCertificateError,
2936
- "FAILED_TO_INSERT_DOMAIN_MAPPING": FailedToInsertDomainMappingError,
2937
- "PERMISSION_DENIED": PermissionDeniedError,
2938
- "FAILED_TO_CHECK_PERMISSIONS": FailedToCheckPermissionsError,
2939
- "FAILED_TO_LIST_DOMAINS": FailedToListDomainsError,
2940
- "FAILED_TO_LIST_VERIFICATIONS": FailedToListVerificationsError,
2941
- "FAILED_TO_VERIFY_DOMAIN": FailedToVerifyDomainError,
2942
- "VERIFICATION_FAILED": VerificationFailedError,
2943
- "FAILED_TO_DELETE_VERIFICATION": FailedToDeleteVerificationError,
2944
- "VERIFICATION_NOT_FOUND": VerificationNotFoundError,
2945
- "FAILED_TO_CREATE_VERIFICATION_CODE": FailedToCreateVerificationCodeError,
2946
- "INVALID_DOMAIN": InvalidDomainError,
2947
- "RESIZE_FAILED": ResizeFailedError,
2948
- "INTERNAL_RESIZE_VM_NOT_FOUND": InternalResizeVmNotFoundError,
2969
+ "BUILD_FAILED": BuildFailedError,
2970
+ "SERVER_DEPLOYMENT_FAILED": ServerDeploymentFailedError,
2971
+ "LOCKFILE_ERROR": LockfileErrorError,
2972
+ "UPLOAD_ERROR": UploadErrorError,
2973
+ "DOMAIN_MAPPING_ERROR": DomainMappingErrorError,
2974
+ "CERTIFICATE_PROVISIONING_ERROR": CertificateProvisioningErrorError,
2975
+ "NO_ENTRYPOINT_FOUND": NoEntrypointFoundError,
2976
+ "ENTRYPOINT_NOT_FOUND": EntrypointNotFoundError,
2977
+ "NO_DOMAIN_OWNERSHIP": NoDomainOwnershipError,
2978
+ "INVALID_DOMAINS": InvalidDomainsError,
2979
+ "WEB_DEPLOYMENT_BAD_REQUEST": WebDeploymentBadRequestError,
2980
+ "DEPLOYMENT_NOT_FOUND": DeploymentNotFoundError,
2949
2981
  "PERMISSION_ALREADY_EXISTS": PermissionAlreadyExistsError,
2950
2982
  "LIST_TOKENS_FAILED": ListTokensFailedError,
2951
2983
  "REVOKE_TOKEN_FAILED": RevokeTokenFailedError,
@@ -3008,36 +3040,10 @@ const FREESTYLE_ERROR_CODE_MAP = {
3008
3040
  "DEPLOYMENT_FAILED": DeploymentFailedError,
3009
3041
  "INVALID_DEPLOYMENT_REQUEST": InvalidDeploymentRequestError,
3010
3042
  "PROJECT_NOT_FOUND": ProjectNotFoundError,
3043
+ "SCHEDULE_NOT_FOUND": ScheduleNotFoundError,
3044
+ "SERVICE_UNAVAILABLE": ServiceUnavailableError,
3011
3045
  "UNAUTHORIZED_ERROR": UnauthorizedErrorError,
3012
- "BUILD_FAILED": BuildFailedError,
3013
- "SERVER_DEPLOYMENT_FAILED": ServerDeploymentFailedError,
3014
- "LOCKFILE_ERROR": LockfileErrorError,
3015
- "UPLOAD_ERROR": UploadErrorError,
3016
- "DOMAIN_MAPPING_ERROR": DomainMappingErrorError,
3017
- "CERTIFICATE_PROVISIONING_ERROR": CertificateProvisioningErrorError,
3018
- "NO_ENTRYPOINT_FOUND": NoEntrypointFoundError,
3019
- "ENTRYPOINT_NOT_FOUND": EntrypointNotFoundError,
3020
- "NO_DOMAIN_OWNERSHIP": NoDomainOwnershipError,
3021
- "INVALID_DOMAINS": InvalidDomainsError,
3022
- "WEB_DEPLOYMENT_BAD_REQUEST": WebDeploymentBadRequestError,
3023
- "DEPLOYMENT_NOT_FOUND": DeploymentNotFoundError,
3024
- "DOMAIN_OWNERSHIP_VERIFICATION_FAILED": DomainOwnershipVerificationFailedError,
3025
- "ERROR_DELETING_RECORD": ErrorDeletingRecordError,
3026
- "RECORD_OWNERSHIP_ERROR": RecordOwnershipErrorError,
3027
- "ERROR_CREATING_RECORD": ErrorCreatingRecordError,
3028
- "DOMAIN_OWNERSHIP_ERROR": DomainOwnershipErrorError,
3029
3046
  "ANYHOW": AnyhowError,
3030
- "EMPTY_TAG": EmptyTagError,
3031
- "DOMAIN_OWNERSHIP_NOT_VERIFIED": DomainOwnershipNotVerifiedError,
3032
- "VM_ACCESS_DENIED_FOR_MAPPING": VmAccessDeniedForMappingError,
3033
- "DEPLOYMENT_ACCESS_DENIED": DeploymentAccessDeniedError,
3034
- "FAILED_TO_PROVISION_CERTIFICATE_FOR_MAPPING": FailedToProvisionCertificateForMappingError,
3035
- "FAILED_INSERT_DOMAIN_MAPPING": FailedInsertDomainMappingError,
3036
- "DOMAIN_ALREADY_EXISTS": DomainAlreadyExistsError,
3037
- "FAILED_TO_INSERT_OWNERSHIP": FailedToInsertOwnershipError,
3038
- "FAILED_REMOVE_DOMAIN_MAPPING": FailedRemoveDomainMappingError,
3039
- "FAILED_PERMISSIONS_CHECK": FailedPermissionsCheckError,
3040
- "FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS": FailedToCheckDomainMappingPermissionsError,
3041
3047
  "BROWSER_OPERATION_FAILED": BrowserOperationFailedError,
3042
3048
  "WATCH_FILES_FAILED": WatchFilesFailedError,
3043
3049
  "LOGS_FAILED": LogsFailedError,
@@ -3050,7 +3056,44 @@ const FREESTYLE_ERROR_CODE_MAP = {
3050
3056
  "EXECUTION_FAILED": ExecutionFailedError,
3051
3057
  "REQUEST_FAILED": RequestFailedError,
3052
3058
  "DEV_SERVER_FILE_NOT_FOUND": DevServerFileNotFoundError,
3053
- "DEV_SERVER_INVALID_REQUEST": DevServerInvalidRequestError
3059
+ "DEV_SERVER_INVALID_REQUEST": DevServerInvalidRequestError,
3060
+ "EMPTY_TAG": EmptyTagError,
3061
+ "BRANCH_NAME_EMPTY": BranchNameEmptyError,
3062
+ "RESIZE_FAILED": ResizeFailedError,
3063
+ "INTERNAL_RESIZE_VM_NOT_FOUND": InternalResizeVmNotFoundError,
3064
+ "OBSERVABILITY_DATABASE_ERROR": ObservabilityDatabaseErrorError,
3065
+ "OBSERVABILITY_ACCESS_DENIED": ObservabilityAccessDeniedError,
3066
+ "PARSE_LOGS_FAILED": ParseLogsFailedError,
3067
+ "RETRIEVE_LOGS_FAILED": RetrieveLogsFailedError,
3068
+ "INVALID_QUERY": InvalidQueryError,
3069
+ "LOGS_NOT_FOUND": LogsNotFoundError,
3070
+ "FAILED_TO_PROVISION_CERTIFICATE": FailedToProvisionCertificateError,
3071
+ "FAILED_TO_INSERT_DOMAIN_MAPPING": FailedToInsertDomainMappingError,
3072
+ "PERMISSION_DENIED": PermissionDeniedError,
3073
+ "FAILED_TO_CHECK_PERMISSIONS": FailedToCheckPermissionsError,
3074
+ "FAILED_TO_LIST_DOMAINS": FailedToListDomainsError,
3075
+ "FAILED_TO_LIST_VERIFICATIONS": FailedToListVerificationsError,
3076
+ "FAILED_TO_VERIFY_DOMAIN": FailedToVerifyDomainError,
3077
+ "VERIFICATION_FAILED": VerificationFailedError,
3078
+ "FAILED_TO_DELETE_VERIFICATION": FailedToDeleteVerificationError,
3079
+ "VERIFICATION_NOT_FOUND": VerificationNotFoundError,
3080
+ "FAILED_TO_CREATE_VERIFICATION_CODE": FailedToCreateVerificationCodeError,
3081
+ "INVALID_DOMAIN": InvalidDomainError,
3082
+ "DOMAIN_OWNERSHIP_NOT_VERIFIED": DomainOwnershipNotVerifiedError,
3083
+ "VM_ACCESS_DENIED_FOR_MAPPING": VmAccessDeniedForMappingError,
3084
+ "DEPLOYMENT_ACCESS_DENIED": DeploymentAccessDeniedError,
3085
+ "FAILED_TO_PROVISION_CERTIFICATE_FOR_MAPPING": FailedToProvisionCertificateForMappingError,
3086
+ "FAILED_INSERT_DOMAIN_MAPPING": FailedInsertDomainMappingError,
3087
+ "DOMAIN_ALREADY_EXISTS": DomainAlreadyExistsError,
3088
+ "FAILED_TO_INSERT_OWNERSHIP": FailedToInsertOwnershipError,
3089
+ "FAILED_REMOVE_DOMAIN_MAPPING": FailedRemoveDomainMappingError,
3090
+ "FAILED_PERMISSIONS_CHECK": FailedPermissionsCheckError,
3091
+ "FAILED_TO_CHECK_DOMAIN_MAPPING_PERMISSIONS": FailedToCheckDomainMappingPermissionsError,
3092
+ "DOMAIN_OWNERSHIP_VERIFICATION_FAILED": DomainOwnershipVerificationFailedError,
3093
+ "ERROR_DELETING_RECORD": ErrorDeletingRecordError,
3094
+ "RECORD_OWNERSHIP_ERROR": RecordOwnershipErrorError,
3095
+ "ERROR_CREATING_RECORD": ErrorCreatingRecordError,
3096
+ "DOMAIN_OWNERSHIP_ERROR": DomainOwnershipErrorError
3054
3097
  };
3055
3098
 
3056
3099
  var errors = /*#__PURE__*/Object.freeze({
@@ -3230,6 +3273,7 @@ var errors = /*#__PURE__*/Object.freeze({
3230
3273
  RevokeTokenFailedError: RevokeTokenFailedError,
3231
3274
  RunNotFoundError: RunNotFoundError,
3232
3275
  RuntimeErrorError: RuntimeErrorError,
3276
+ ScheduleNotFoundError: ScheduleNotFoundError,
3233
3277
  SendErrorError: SendErrorError,
3234
3278
  SerializationErrorError: SerializationErrorError,
3235
3279
  ServerDeploymentFailedError: ServerDeploymentFailedError,
@@ -3239,6 +3283,7 @@ var errors = /*#__PURE__*/Object.freeze({
3239
3283
  ServiceNameInvalidPrefixError: ServiceNameInvalidPrefixError,
3240
3284
  ServiceNameTooLongError: ServiceNameTooLongError,
3241
3285
  ServiceNotFoundError: ServiceNotFoundError,
3286
+ ServiceUnavailableError: ServiceUnavailableError,
3242
3287
  ShutdownFailedError: ShutdownFailedError,
3243
3288
  SigningError: SigningError,
3244
3289
  SnapshotVmBadRequestError: SnapshotVmBadRequestError,
@@ -3254,6 +3299,7 @@ var errors = /*#__PURE__*/Object.freeze({
3254
3299
  TriggerErrorError: TriggerErrorError,
3255
3300
  UnauthorizedError: UnauthorizedError,
3256
3301
  UnauthorizedErrorError: UnauthorizedErrorError,
3302
+ UnavailableError: UnavailableError,
3257
3303
  UnsupportedTransferError: UnsupportedTransferError,
3258
3304
  UpdateDefaultBranchFailedError: UpdateDefaultBranchFailedError,
3259
3305
  UpdatePermissionFailedError: UpdatePermissionFailedError,
@@ -4449,6 +4495,65 @@ class Deployment {
4449
4495
  query: { deploymentId: this.deploymentId }
4450
4496
  });
4451
4497
  }
4498
+ /**
4499
+ * Fetch content from this deployment.
4500
+ * Makes a request directly to nginx-web with the deployment ID header.
4501
+ *
4502
+ * @param url - The URL path to fetch (e.g., "/api/hello" or "https://example.com/path")
4503
+ * @param init - Fetch options (headers, method, body, etc.)
4504
+ * @returns The response from the deployment
4505
+ *
4506
+ * @example
4507
+ * // Relative path
4508
+ * await deployment.fetch("/api/hello")
4509
+ *
4510
+ * @example
4511
+ * // Absolute URL (domain is ignored, only path is used)
4512
+ * await deployment.fetch("https://example.com/api/hello")
4513
+ *
4514
+ * @example
4515
+ * // With custom headers and method
4516
+ * await deployment.fetch("/api/data", {
4517
+ * method: "POST",
4518
+ * headers: { "Content-Type": "application/json" },
4519
+ * body: JSON.stringify({ key: "value" })
4520
+ * })
4521
+ */
4522
+ async fetch(url, init) {
4523
+ let requestUrl;
4524
+ try {
4525
+ const parsedUrl = new URL(url);
4526
+ requestUrl = parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;
4527
+ } catch {
4528
+ requestUrl = url;
4529
+ }
4530
+ const apiPath = `/web/v1/deployments/{deployment_id}/fetch`;
4531
+ const headers = {
4532
+ "X-Freestyle-Request-Url": requestUrl
4533
+ };
4534
+ if (init?.headers) {
4535
+ const userHeaders = init.headers;
4536
+ if (userHeaders instanceof Headers) {
4537
+ userHeaders.forEach((value, key) => {
4538
+ headers[key] = value;
4539
+ });
4540
+ } else if (Array.isArray(userHeaders)) {
4541
+ userHeaders.forEach(([key, value]) => {
4542
+ headers[key] = value;
4543
+ });
4544
+ } else {
4545
+ Object.assign(headers, userHeaders);
4546
+ }
4547
+ }
4548
+ return this.apiClient.fetch(
4549
+ this.apiClient.buildUrl(apiPath, { deployment_id: this.deploymentId }),
4550
+ {
4551
+ ...init,
4552
+ method: init?.method || "GET",
4553
+ headers
4554
+ }
4555
+ );
4556
+ }
4452
4557
  }
4453
4558
  class DeploymentsNamespace {
4454
4559
  constructor(apiClient) {
@@ -5971,6 +6076,108 @@ function linuxUsernameHeader(linux_username) {
5971
6076
  return linux_username ? { "X-Freestyle-Vm-Linux-User-Id": linux_username } : void 0;
5972
6077
  }
5973
6078
 
6079
+ class CronNamespace {
6080
+ constructor(apiClient) {
6081
+ this.apiClient = apiClient;
6082
+ }
6083
+ /**
6084
+ * Create a cron schedule.
6085
+ */
6086
+ async schedule({
6087
+ deploymentId,
6088
+ cron,
6089
+ timezone,
6090
+ payload,
6091
+ path
6092
+ }) {
6093
+ const response = await this.apiClient.post("/v1/cron/schedules", {
6094
+ body: {
6095
+ deploymentId,
6096
+ cron,
6097
+ timezone: timezone ?? "UTC",
6098
+ payload: payload ?? {},
6099
+ path
6100
+ }
6101
+ });
6102
+ return {
6103
+ job: new CronJob({
6104
+ apiClient: this.apiClient,
6105
+ schedule: response.schedule
6106
+ })
6107
+ };
6108
+ }
6109
+ /**
6110
+ * List cron schedules.
6111
+ */
6112
+ async list({
6113
+ deploymentId
6114
+ } = {}) {
6115
+ const response = await this.apiClient.get("/v1/cron/schedules", {
6116
+ query: deploymentId ? { deployment_id: deploymentId } : {}
6117
+ });
6118
+ return {
6119
+ jobs: response.schedules.map(
6120
+ (schedule) => new CronJob({ apiClient: this.apiClient, schedule })
6121
+ )
6122
+ };
6123
+ }
6124
+ }
6125
+ class CronJob {
6126
+ schedule;
6127
+ #apiClient;
6128
+ constructor({
6129
+ apiClient,
6130
+ schedule
6131
+ }) {
6132
+ this.#apiClient = apiClient;
6133
+ this.schedule = schedule;
6134
+ }
6135
+ /**
6136
+ * Enable this cron schedule.
6137
+ */
6138
+ async enable() {
6139
+ await this.#apiClient.patch("/v1/cron/schedules/{id}", {
6140
+ params: { id: this.schedule.id },
6141
+ body: { active: true }
6142
+ });
6143
+ }
6144
+ /**
6145
+ * Disable this cron schedule.
6146
+ */
6147
+ async disable() {
6148
+ await this.#apiClient.patch("/v1/cron/schedules/{id}", {
6149
+ params: { id: this.schedule.id },
6150
+ body: { active: false }
6151
+ });
6152
+ }
6153
+ }
6154
+
6155
+ async function readFiles(directory) {
6156
+ const files = [];
6157
+ const patterns = await glob.glob("**/*", {
6158
+ cwd: directory,
6159
+ nodir: true,
6160
+ ignore: ["**/node_modules/**"],
6161
+ absolute: false,
6162
+ dot: true,
6163
+ posix: true
6164
+ });
6165
+ for (const relativePath of patterns) {
6166
+ try {
6167
+ const filePath = path.join(directory, relativePath);
6168
+ const content = await fs.readFile(filePath, "base64");
6169
+ files.push({
6170
+ content,
6171
+ path: relativePath,
6172
+ encoding: "base64"
6173
+ });
6174
+ } catch (error) {
6175
+ console.error(`Error reading file ${relativePath}:`, error);
6176
+ }
6177
+ }
6178
+ return files;
6179
+ }
6180
+
5974
6181
  class Freestyle {
5975
6182
  /**
5976
6183
  * @internal
@@ -5984,6 +6191,7 @@ class Freestyle {
5984
6191
  dns;
5985
6192
  serverless;
5986
6193
  vms;
6194
+ cron;
5987
6195
  constructor(options = {}) {
5988
6196
  if (!options.baseUrl) {
5989
6197
  options.baseUrl = process.env.FREESTYLE_API_URL;
@@ -6009,6 +6217,7 @@ class Freestyle {
6009
6217
  this.dns = new DnsNamespace(this._apiClient);
6010
6218
  this.serverless = new ServerlessNamespace(this._apiClient);
6011
6219
  this.vms = new VmsNamespace(this);
6220
+ this.cron = new CronNamespace(this._apiClient);
6012
6221
  }
6013
6222
  /**
6014
6223
  * Helper method to make raw fetch requests to the API.
@@ -6038,6 +6247,7 @@ function createLazyFreestyle(options = {}) {
6038
6247
  }
6039
6248
  const freestyle = createLazyFreestyle();
6040
6249
 
6250
+ exports.CronNamespace = CronNamespace;
6041
6251
  exports.Deployment = Deployment;
6042
6252
  exports.Errors = errors;
6043
6253
  exports.FileSystem = FileSystem;
@@ -6054,3 +6264,4 @@ exports.VmTemplate = VmTemplate;
6054
6264
  exports.VmWith = VmWith;
6055
6265
  exports.VmWithInstance = VmWithInstance;
6056
6266
  exports.freestyle = freestyle;
6267
+ exports.readFiles = readFiles;