@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/index.cjs CHANGED
@@ -4680,7 +4680,7 @@ async function undelegate(options, logger = noopLogger) {
4680
4680
  }
4681
4681
 
4682
4682
  // src/client/common/utils/userapi.ts
4683
- var import_axios = __toESM(require("axios"), 1);
4683
+ var import_axios2 = __toESM(require("axios"), 1);
4684
4684
 
4685
4685
  // src/client/common/utils/auth.ts
4686
4686
  var import_viem4 = require("viem");
@@ -4737,6 +4737,41 @@ async function calculateBillingAuthSignature(options) {
4737
4737
  return { signature, expiry };
4738
4738
  }
4739
4739
 
4740
+ // src/client/common/utils/retry.ts
4741
+ var import_axios = __toESM(require("axios"), 1);
4742
+ var MAX_RETRIES = 5;
4743
+ var INITIAL_BACKOFF_MS = 1e3;
4744
+ var MAX_BACKOFF_MS = 3e4;
4745
+ function sleep(ms) {
4746
+ return new Promise((resolve2) => setTimeout(resolve2, ms));
4747
+ }
4748
+ function getRetryDelay(res, attempt) {
4749
+ const backoff = Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
4750
+ const retryAfter = res.headers["retry-after"];
4751
+ if (retryAfter) {
4752
+ const seconds = parseInt(retryAfter, 10);
4753
+ if (!isNaN(seconds) && seconds > 0) {
4754
+ return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
4755
+ }
4756
+ }
4757
+ return backoff;
4758
+ }
4759
+ async function requestWithRetry(config) {
4760
+ let lastResponse;
4761
+ for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
4762
+ const res = await (0, import_axios.default)({ ...config, validateStatus: () => true });
4763
+ lastResponse = res;
4764
+ if (res.status !== 429) {
4765
+ return res;
4766
+ }
4767
+ if (attempt < MAX_RETRIES) {
4768
+ const delay = getRetryDelay(res, attempt);
4769
+ await sleep(delay);
4770
+ }
4771
+ }
4772
+ return lastResponse;
4773
+ }
4774
+
4740
4775
  // src/client/common/utils/userapi.ts
4741
4776
  init_session();
4742
4777
  function isJsonObject(value) {
@@ -4755,7 +4790,7 @@ var CanViewAppLogsPermission = "0x2fd3f2fe";
4755
4790
  var CanViewSensitiveAppInfoPermission = "0x0e67b22f";
4756
4791
  var CanUpdateAppProfilePermission = "0x036fef61";
4757
4792
  function getDefaultClientId() {
4758
- const version = true ? "0.3.3-dev" : "0.0.0";
4793
+ const version = true ? "0.3.4-dev" : "0.0.0";
4759
4794
  return `ecloud-sdk/v${version}`;
4760
4795
  }
4761
4796
  var UserApiClient = class {
@@ -4890,7 +4925,7 @@ var UserApiClient = class {
4890
4925
  Object.assign(headers, authHeaders);
4891
4926
  }
4892
4927
  try {
4893
- const response = await import_axios.default.post(endpoint, formData, {
4928
+ const response = await import_axios2.default.post(endpoint, formData, {
4894
4929
  headers,
4895
4930
  maxRedirects: 0,
4896
4931
  validateStatus: () => true,
@@ -4940,11 +4975,11 @@ Please check:
4940
4975
  Object.assign(headers, authHeaders);
4941
4976
  }
4942
4977
  try {
4943
- const response = await import_axios.default.get(url, {
4978
+ const response = await requestWithRetry({
4979
+ method: "GET",
4980
+ url,
4944
4981
  headers,
4945
4982
  maxRedirects: 0,
4946
- validateStatus: () => true,
4947
- // Don't throw on any status
4948
4983
  withCredentials: true
4949
4984
  // Include cookies for session auth
4950
4985
  });
@@ -5128,7 +5163,7 @@ async function watchUntilRunning(options, logger) {
5128
5163
  try {
5129
5164
  const info = await userApiClient.getInfos([appId], 1);
5130
5165
  if (info.length === 0) {
5131
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5166
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5132
5167
  continue;
5133
5168
  }
5134
5169
  const appInfo = info[0];
@@ -5137,10 +5172,10 @@ async function watchUntilRunning(options, logger) {
5137
5172
  if (stopCondition(currentStatus, currentIP)) {
5138
5173
  return currentIP || void 0;
5139
5174
  }
5140
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5175
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5141
5176
  } catch (error) {
5142
5177
  logger.warn(`Failed to fetch app info: ${error.message}`);
5143
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5178
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5144
5179
  }
5145
5180
  }
5146
5181
  }
@@ -5188,7 +5223,7 @@ async function watchUntilUpgradeComplete(options, logger) {
5188
5223
  try {
5189
5224
  const info = await userApiClient.getInfos([appId], 1);
5190
5225
  if (info.length === 0) {
5191
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5226
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5192
5227
  continue;
5193
5228
  }
5194
5229
  const appInfo = info[0];
@@ -5197,14 +5232,14 @@ async function watchUntilUpgradeComplete(options, logger) {
5197
5232
  if (stopCondition(currentStatus, currentIP)) {
5198
5233
  return;
5199
5234
  }
5200
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5235
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5201
5236
  } catch (error) {
5202
5237
  logger.warn(`Failed to fetch app info: ${error.message}`);
5203
- await sleep(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5238
+ await sleep2(WATCH_POLL_INTERVAL_SECONDS * 1e3);
5204
5239
  }
5205
5240
  }
5206
5241
  }
5207
- function sleep(ms) {
5242
+ function sleep2(ms) {
5208
5243
  return new Promise((resolve2) => setTimeout(resolve2, ms));
5209
5244
  }
5210
5245
 
@@ -5662,7 +5697,7 @@ function isSubscriptionActive(status) {
5662
5697
  }
5663
5698
 
5664
5699
  // src/client/common/utils/billingapi.ts
5665
- var import_axios2 = __toESM(require("axios"), 1);
5700
+ var import_axios3 = __toESM(require("axios"), 1);
5666
5701
 
5667
5702
  // src/client/common/auth/billingSession.ts
5668
5703
  var BillingSessionError = class extends Error {
@@ -5975,7 +6010,7 @@ Please check:
5975
6010
  headers["Content-Type"] = "application/json";
5976
6011
  }
5977
6012
  try {
5978
- const response = await (0, import_axios2.default)({
6013
+ const response = await (0, import_axios3.default)({
5979
6014
  method,
5980
6015
  url,
5981
6016
  headers,
@@ -8067,38 +8102,6 @@ function createBillingModule(config) {
8067
8102
  }
8068
8103
 
8069
8104
  // src/client/common/utils/buildapi.ts
8070
- var import_axios3 = __toESM(require("axios"), 1);
8071
- var MAX_RETRIES = 5;
8072
- var INITIAL_BACKOFF_MS = 1e3;
8073
- var MAX_BACKOFF_MS = 3e4;
8074
- async function sleep2(ms) {
8075
- return new Promise((resolve2) => setTimeout(resolve2, ms));
8076
- }
8077
- function getRetryDelay(res, attempt) {
8078
- const retryAfter = res.headers["retry-after"];
8079
- if (retryAfter) {
8080
- const seconds = parseInt(retryAfter, 10);
8081
- if (!isNaN(seconds)) {
8082
- return Math.min(seconds * 1e3, MAX_BACKOFF_MS);
8083
- }
8084
- }
8085
- return Math.min(INITIAL_BACKOFF_MS * Math.pow(2, attempt), MAX_BACKOFF_MS);
8086
- }
8087
- async function requestWithRetry(config) {
8088
- let lastResponse;
8089
- for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
8090
- const res = await (0, import_axios3.default)({ ...config, validateStatus: () => true });
8091
- lastResponse = res;
8092
- if (res.status !== 429) {
8093
- return res;
8094
- }
8095
- if (attempt < MAX_RETRIES) {
8096
- const delay = getRetryDelay(res, attempt);
8097
- await sleep2(delay);
8098
- }
8099
- }
8100
- return lastResponse;
8101
- }
8102
8105
  var BuildApiClient = class {
8103
8106
  constructor(options) {
8104
8107
  let url = options.baseUrl;