@layr-labs/ecloud-sdk 0.3.3-dev → 0.3.4-dev

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.
package/dist/compute.cjs CHANGED
@@ -4461,7 +4461,7 @@ async function undelegate(options, logger = noopLogger) {
4461
4461
  }
4462
4462
 
4463
4463
  // src/client/common/utils/userapi.ts
4464
- var import_axios = __toESM(require("axios"), 1);
4464
+ var import_axios2 = __toESM(require("axios"), 1);
4465
4465
 
4466
4466
  // src/client/common/utils/auth.ts
4467
4467
  var import_viem4 = require("viem");
@@ -4487,6 +4487,41 @@ async function calculatePermissionSignature(options) {
4487
4487
  return { signature, digest };
4488
4488
  }
4489
4489
 
4490
+ // src/client/common/utils/retry.ts
4491
+ var import_axios = __toESM(require("axios"), 1);
4492
+ var MAX_RETRIES = 5;
4493
+ var INITIAL_BACKOFF_MS = 1e3;
4494
+ var MAX_BACKOFF_MS = 3e4;
4495
+ function sleep(ms) {
4496
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
4497
+ }
4498
+ function getRetryDelay(res, attempt) {
4499
+ const backoff = Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
4500
+ const retryAfter = res.headers["retry-after"];
4501
+ if (retryAfter) {
4502
+ const seconds = parseInt(retryAfter, 10);
4503
+ if (!isNaN(seconds) && seconds > 0) {
4504
+ return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
4505
+ }
4506
+ }
4507
+ return backoff;
4508
+ }
4509
+ async function requestWithRetry(config) {
4510
+ let lastResponse;
4511
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
4512
+ const res = await (0, import_axios.default)({ ...config, validateStatus: () => true });
4513
+ lastResponse = res;
4514
+ if (res.status !== 429) {
4515
+ return res;
4516
+ }
4517
+ if (attempt < MAX_RETRIES) {
4518
+ const delay = getRetryDelay(res, attempt);
4519
+ await sleep(delay);
4520
+ }
4521
+ }
4522
+ return lastResponse;
4523
+ }
4524
+
4490
4525
  // src/client/common/utils/userapi.ts
4491
4526
  init_session();
4492
4527
  function isJsonObject(value) {
@@ -4505,7 +4540,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
4505
4540
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
4506
4541
  var CanUpdateAppProfilePermission = "0x036fef61";
4507
4542
  function getDefaultClientId() {
4508
- const version = true ? "0.3.3-dev" : "0.0.0";
4543
+ const version = true ? "0.3.4-dev" : "0.0.0";
4509
4544
  return `ecloud-sdk/v${version}`;
4510
4545
  }
4511
4546
  var UserApiClient = class {
@@ -4640,7 +4675,7 @@ var UserApiClient = class {
4640
4675
  Object.assign(headers, authHeaders);
4641
4676
  }
4642
4677
  try {
4643
- const response = await import_axios.default.post(endpoint, formData, {
4678
+ const response = await import_axios2.default.post(endpoint, formData, {
4644
4679
  headers,
4645
4680
  maxRedirects: 0,
4646
4681
  validateStatus: () => true,
@@ -4690,11 +4725,11 @@ Please check:
4690
4725
  Object.assign(headers, authHeaders);
4691
4726
  }
4692
4727
  try {
4693
- const response = await import_axios.default.get(url, {
4728
+ const response = await requestWithRetry({
4729
+ method: "GET",
4730
+ url,
4694
4731
  headers,
4695
4732
  maxRedirects: 0,
4696
- validateStatus: () => true,
4697
- // Don't throw on any status
4698
4733
  withCredentials: true
4699
4734
  // Include cookies for session auth
4700
4735
  });
@@ -4878,7 +4913,7 @@ async function watchUntilRunning(options, logger) {
4878
4913
  try {
4879
4914
  const info = await userApiClient.getInfos([appId], 1);
4880
4915
  if (info.length === 0) {
4881
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4916
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4882
4917
  continue;
4883
4918
  }
4884
4919
  const appInfo = info[0];
@@ -4887,10 +4922,10 @@ async function watchUntilRunning(options, logger) {
4887
4922
  if (stopCondition(currentStatus, currentIP)) {
4888
4923
  return currentIP || void 0;
4889
4924
  }
4890
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4925
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4891
4926
  } catch (error) {
4892
4927
  logger.warn(`Failed to fetch app info: ${error.message}`);
4893
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4928
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4894
4929
  }
4895
4930
  }
4896
4931
  }
@@ -4938,7 +4973,7 @@ async function watchUntilUpgradeComplete(options, logger) {
4938
4973
  try {
4939
4974
  const info = await userApiClient.getInfos([appId], 1);
4940
4975
  if (info.length === 0) {
4941
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4976
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4942
4977
  continue;
4943
4978
  }
4944
4979
  const appInfo = info[0];
@@ -4947,14 +4982,14 @@ async function watchUntilUpgradeComplete(options, logger) {
4947
4982
  if (stopCondition(currentStatus, currentIP)) {
4948
4983
  return;
4949
4984
  }
4950
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4985
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4951
4986
  } catch (error) {
4952
4987
  logger.warn(`Failed to fetch app info: ${error.message}`);
4953
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4988
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
4954
4989
  }
4955
4990
  }
4956
4991
  }
4957
- function sleep(ms) {
4992
+ function sleep2(ms) {
4958
4993
  return new Promise((resolve2) => setTimeout(resolve2, ms));
4959
4994
  }
4960
4995
 
@@ -5178,7 +5213,7 @@ var getLogger = (verbose) => ({
5178
5213
  });
5179
5214
 
5180
5215
  // src/client/common/utils/billingapi.ts
5181
- var import_axios2 = __toESM(require("axios"), 1);
5216
+ var import_axios3 = __toESM(require("axios"), 1);
5182
5217
 
5183
5218
  // src/client/common/telemetry/noop.ts
5184
5219
  var NoopClient = class {