@budibase/backend-core 3.1.1 → 3.1.3

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.js CHANGED
@@ -62143,9 +62143,11 @@ __export(helpers_exports, {
62143
62143
  getUserLabel: () => getUserLabel,
62144
62144
  isGoogleSheets: () => isGoogleSheets,
62145
62145
  isSQL: () => isSQL,
62146
+ retry: () => retry,
62146
62147
  roles: () => roles_exports,
62147
62148
  schema: () => schema_exports,
62148
62149
  views: () => views_exports,
62150
+ wait: () => wait,
62149
62151
  withTimeout: () => withTimeout
62150
62152
  });
62151
62153
 
@@ -62243,6 +62245,30 @@ function isSQL(datasource2) {
62243
62245
  return SQL.indexOf(datasource2.source) !== -1 || datasource2.isSQL === true;
62244
62246
  }
62245
62247
 
62248
+ // ../shared-core/src/helpers/async.ts
62249
+ async function wait(ms) {
62250
+ return new Promise((resolve) => setTimeout(resolve, ms));
62251
+ }
62252
+
62253
+ // ../shared-core/src/helpers/retry.ts
62254
+ async function retry(fn, opts) {
62255
+ const { times = 3 } = opts || {};
62256
+ if (times < 1) {
62257
+ throw new Error(`invalid retry count: ${times}`);
62258
+ }
62259
+ let lastError;
62260
+ for (let i = 0; i < times; i++) {
62261
+ const backoff = 1.5 ** i * 1e3 * (Math.random() + 0.5);
62262
+ await wait(backoff);
62263
+ try {
62264
+ return await fn();
62265
+ } catch (e) {
62266
+ lastError = e;
62267
+ }
62268
+ }
62269
+ throw lastError;
62270
+ }
62271
+
62246
62272
  // ../shared-core/src/helpers/cron.ts
62247
62273
  var cron_exports = {};
62248
62274
  __export(cron_exports, {