balena-sdk 16.13.0 → 16.13.2

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/CHANGELOG.md CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file
4
4
  automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
5
5
  This project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## 16.13.2 - 2022-01-26
8
+
9
+ * Deprecate the logoUrl field of the DeviceTypeJson.DeviceType type [Thodoris Greasidis]
10
+
11
+ ## 16.13.1 - 2022-01-21
12
+
13
+ * Replace internal use of release.contains__image with release_image [Thodoris Greasidis]
14
+
7
15
  ## 16.13.0 - 2022-01-21
8
16
 
9
17
  * models: Deprecate the release.contains__image in favor of the term form [Thodoris Greasidis]
@@ -10471,7 +10471,7 @@ const getReleaseModel = function (deps, opts) {
10471
10471
  };
10472
10472
  const baseReleaseOptions = {
10473
10473
  $expand: {
10474
- contains__image: {
10474
+ release_image: {
10475
10475
  $expand: {
10476
10476
  image: (0, util_1.mergePineOptions)(baseImageOptions, options.image),
10477
10477
  },
@@ -10483,9 +10483,9 @@ const getReleaseModel = function (deps, opts) {
10483
10483
  };
10484
10484
  const rawRelease = (yield get(commitOrId, (0, util_1.mergePineOptions)(baseReleaseOptions, options.release)));
10485
10485
  const release = rawRelease;
10486
- // Squash .contains__image[x].image[0] into a simple array
10487
- const images = rawRelease.contains__image.map((imageJoin) => imageJoin.image[0]);
10488
- delete release.contains__image;
10486
+ // Squash .release_image[x].image[0] into a simple array
10487
+ const images = rawRelease.release_image.map((imageJoin) => imageJoin.image[0]);
10488
+ delete release.release_image;
10489
10489
  release.images = images
10490
10490
  .map(function (_a) {
10491
10491
  var { is_a_build_of__service } = _a, imageData = (0, tslib_1.__rest)(_a, ["is_a_build_of__service"]);
@@ -12110,7 +12110,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12110
12110
  // being embedded in the dist of the consumer project
12111
12111
  // which we want to avoid, both b/c of the dist size increase &
12112
12112
  // the security concerns of including the versions of the dependencies
12113
- const sdkVersion = '16.13.0';
12113
+ const sdkVersion = '16.13.2';
12114
12114
  exports.default = sdkVersion;
12115
12115
 
12116
12116
  },{}],46:[function(require,module,exports){
@@ -46432,12 +46432,14 @@ const validParams = [
46432
46432
  'apiPrefix',
46433
46433
  'passthrough',
46434
46434
  'passthroughByMethod',
46435
+ 'retry',
46435
46436
  ];
46436
46437
  class PinejsClientCore {
46437
46438
  constructor(params) {
46438
46439
  this.apiPrefix = '/';
46439
46440
  this.passthrough = {};
46440
46441
  this.passthroughByMethod = {};
46442
+ this.retry = false;
46441
46443
  if (isString(params)) {
46442
46444
  params = { apiPrefix: params };
46443
46445
  }
@@ -46450,6 +46452,54 @@ class PinejsClientCore {
46450
46452
  }
46451
46453
  }
46452
46454
  }
46455
+ canRetryDefaultHandler(err) {
46456
+ const code = err === null || err === void 0 ? void 0 : err.statusCode;
46457
+ return code == null || code === 429 || (code >= 500 && code < 600);
46458
+ }
46459
+ callWithRetry(fnCall, retry) {
46460
+ var _a, _b, _c, _d, _e, _f;
46461
+ return __awaiter(this, void 0, void 0, function* () {
46462
+ if (retry === false || (retry == null && this.retry === false)) {
46463
+ return yield fnCall();
46464
+ }
46465
+ const retryDefaultParameters = this.retry || {};
46466
+ const retryParameters = retry || {};
46467
+ const minDelayMs = (_a = retryParameters.minDelayMs) !== null && _a !== void 0 ? _a : retryDefaultParameters.minDelayMs;
46468
+ const maxDelayMs = (_b = retryParameters.maxDelayMs) !== null && _b !== void 0 ? _b : retryDefaultParameters.maxDelayMs;
46469
+ const maxAttempts = (_c = retryParameters.maxAttempts) !== null && _c !== void 0 ? _c : retryDefaultParameters.maxAttempts;
46470
+ if (minDelayMs == null || minDelayMs <= 0) {
46471
+ throw new Error(`pinejs-client minDelayMs must be a positive integer, got: '${minDelayMs}'`);
46472
+ }
46473
+ if (maxDelayMs == null || maxDelayMs <= 0) {
46474
+ throw new Error(`pinejs-client maxDelayMs must be a positive integer, got: '${maxDelayMs}'`);
46475
+ }
46476
+ if (maxAttempts == null || maxAttempts <= 0) {
46477
+ throw new Error(`pinejs-client maxAttempts be a positive integer, got: '${maxDelayMs}'`);
46478
+ }
46479
+ if (minDelayMs > maxDelayMs) {
46480
+ throw new Error('pinejs-client maxDelayMs must be greater than or equal to minDelayMs');
46481
+ }
46482
+ const onRetryHandler = (_d = retryParameters.onRetry) !== null && _d !== void 0 ? _d : retryDefaultParameters.onRetry;
46483
+ let attempt = 1;
46484
+ const canRetryHandler = (_f = (_e = retryParameters.canRetry) !== null && _e !== void 0 ? _e : retryDefaultParameters.canRetry) !== null && _f !== void 0 ? _f : this.canRetryDefaultHandler;
46485
+ while (true) {
46486
+ try {
46487
+ return yield fnCall();
46488
+ }
46489
+ catch (err) {
46490
+ if (attempt >= maxAttempts || !canRetryHandler(err)) {
46491
+ throw err;
46492
+ }
46493
+ const delayMs = Math.min(Math.pow(2, (attempt - 1)) * minDelayMs, maxDelayMs);
46494
+ attempt++;
46495
+ onRetryHandler === null || onRetryHandler === void 0 ? void 0 : onRetryHandler(err, delayMs, attempt, maxAttempts);
46496
+ yield new Promise((resolve) => {
46497
+ setTimeout(resolve, delayMs);
46498
+ });
46499
+ }
46500
+ }
46501
+ });
46502
+ }
46453
46503
  clone(params, backendParams) {
46454
46504
  if (isString(params)) {
46455
46505
  params = { apiPrefix: params };
@@ -46706,7 +46756,7 @@ class PinejsClientCore {
46706
46756
  throw new Error('`request(url)` is no longer supported, please use `request({ url })` instead.');
46707
46757
  }
46708
46758
  let { method, apiPrefix } = params;
46709
- const { body, passthrough = {} } = params;
46759
+ const { body, passthrough = {}, retry } = params;
46710
46760
  apiPrefix = apiPrefix !== null && apiPrefix !== void 0 ? apiPrefix : this.apiPrefix;
46711
46761
  const url = apiPrefix + this.compile(params);
46712
46762
  method = method !== null && method !== void 0 ? method : 'GET';
@@ -46714,7 +46764,9 @@ class PinejsClientCore {
46714
46764
  const opts = Object.assign(Object.assign(Object.assign(Object.assign({}, this.passthrough), ((_a = this.passthroughByMethod[method]) !== null && _a !== void 0 ? _a : {})), passthrough), { url,
46715
46765
  body,
46716
46766
  method });
46717
- return this._request(opts);
46767
+ return this.callWithRetry(() => __awaiter(this, void 0, void 0, function* () {
46768
+ return yield this._request(opts);
46769
+ }), retry);
46718
46770
  }
46719
46771
  }
46720
46772
  exports.PinejsClientCore = PinejsClientCore;