@bytescale/sdk 3.60.0 → 3.62.0

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.
@@ -153,6 +153,177 @@ var FairMutex = /*#__PURE__*/function () {
153
153
  }]);
154
154
  }();
155
155
  ;// ./src/private/AuthSessionState.ts
156
+ function AuthSessionState_empty() {}
157
+ function AuthSessionState_awaitIgnored(value, direct) {
158
+ if (!direct) {
159
+ return value && value.then ? value.then(AuthSessionState_empty) : Promise.resolve();
160
+ }
161
+ }
162
+ function AuthSessionState_invoke(body, then) {
163
+ var result = body();
164
+ if (result && result.then) {
165
+ return result.then(then);
166
+ }
167
+ return then(result);
168
+ }
169
+ function _settle(pact, state, value) {
170
+ if (!pact.s) {
171
+ if (value instanceof _Pact) {
172
+ if (value.s) {
173
+ if (state & 1) {
174
+ state = value.s;
175
+ }
176
+ value = value.v;
177
+ } else {
178
+ value.o = _settle.bind(null, pact, state);
179
+ return;
180
+ }
181
+ }
182
+ if (value && value.then) {
183
+ value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
184
+ return;
185
+ }
186
+ pact.s = state;
187
+ pact.v = value;
188
+ var observer = pact.o;
189
+ if (observer) {
190
+ observer(pact);
191
+ }
192
+ }
193
+ }
194
+ var _Pact = /*#__PURE__*/function () {
195
+ function _Pact() {}
196
+ _Pact.prototype.then = function (onFulfilled, onRejected) {
197
+ var result = new _Pact();
198
+ var state = this.s;
199
+ if (state) {
200
+ var callback = state & 1 ? onFulfilled : onRejected;
201
+ if (callback) {
202
+ try {
203
+ _settle(result, 1, callback(this.v));
204
+ } catch (e) {
205
+ _settle(result, 2, e);
206
+ }
207
+ return result;
208
+ } else {
209
+ return this;
210
+ }
211
+ }
212
+ this.o = function (_this) {
213
+ try {
214
+ var value = _this.v;
215
+ if (_this.s & 1) {
216
+ _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
217
+ } else if (onRejected) {
218
+ _settle(result, 1, onRejected(value));
219
+ } else {
220
+ _settle(result, 2, value);
221
+ }
222
+ } catch (e) {
223
+ _settle(result, 2, e);
224
+ }
225
+ };
226
+ return result;
227
+ };
228
+ return _Pact;
229
+ }();
230
+ function _isSettledPact(thenable) {
231
+ return thenable instanceof _Pact && thenable.s & 1;
232
+ }
233
+ function _for(test, update, body) {
234
+ var stage;
235
+ for (;;) {
236
+ var shouldContinue = test();
237
+ if (_isSettledPact(shouldContinue)) {
238
+ shouldContinue = shouldContinue.v;
239
+ }
240
+ if (!shouldContinue) {
241
+ return result;
242
+ }
243
+ if (shouldContinue.then) {
244
+ stage = 0;
245
+ break;
246
+ }
247
+ var result = body();
248
+ if (result && result.then) {
249
+ if (_isSettledPact(result)) {
250
+ result = result.s;
251
+ } else {
252
+ stage = 1;
253
+ break;
254
+ }
255
+ }
256
+ if (update) {
257
+ var updateValue = update();
258
+ if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
259
+ stage = 2;
260
+ break;
261
+ }
262
+ }
263
+ }
264
+ var pact = new _Pact();
265
+ var reject = _settle.bind(null, pact, 2);
266
+ (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
267
+ return pact;
268
+ function _resumeAfterBody(value) {
269
+ result = value;
270
+ do {
271
+ if (update) {
272
+ updateValue = update();
273
+ if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
274
+ updateValue.then(_resumeAfterUpdate).then(void 0, reject);
275
+ return;
276
+ }
277
+ }
278
+ shouldContinue = test();
279
+ if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
280
+ _settle(pact, 1, result);
281
+ return;
282
+ }
283
+ if (shouldContinue.then) {
284
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
285
+ return;
286
+ }
287
+ result = body();
288
+ if (_isSettledPact(result)) {
289
+ result = result.v;
290
+ }
291
+ } while (!result || !result.then);
292
+ result.then(_resumeAfterBody).then(void 0, reject);
293
+ }
294
+ function _resumeAfterTest(shouldContinue) {
295
+ if (shouldContinue) {
296
+ result = body();
297
+ if (result && result.then) {
298
+ result.then(_resumeAfterBody).then(void 0, reject);
299
+ } else {
300
+ _resumeAfterBody(result);
301
+ }
302
+ } else {
303
+ _settle(pact, 1, result);
304
+ }
305
+ }
306
+ function _resumeAfterUpdate() {
307
+ if (shouldContinue = test()) {
308
+ if (shouldContinue.then) {
309
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
310
+ } else {
311
+ _resumeAfterTest(shouldContinue);
312
+ }
313
+ } else {
314
+ _settle(pact, 1, result);
315
+ }
316
+ }
317
+ }
318
+ function AuthSessionState_await(value, then, direct) {
319
+ if (direct) {
320
+ return then ? then(value) : value;
321
+ }
322
+ if (!value || !value.then) {
323
+ value = Promise.resolve(value);
324
+ }
325
+ return then ? value.then(then) : value;
326
+ }
156
327
  function AuthSessionState_typeof(o) { "@babel/helpers - typeof"; return AuthSessionState_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, AuthSessionState_typeof(o); }
157
328
  function AuthSessionState_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
158
329
  function AuthSessionState_defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, AuthSessionState_toPropertyKey(o.key), o); } }
@@ -259,6 +430,54 @@ var AuthSessionState = /*#__PURE__*/function () {
259
430
  jwt: undefined
260
431
  };
261
432
  }
433
+ /** Waits for request-time auth to be current before resolving it. */
434
+ }, {
435
+ key: "resolveAuthConfigAsync",
436
+ value: function resolveAuthConfigAsync(authConfigId, requireReadyDefault) {
437
+ try {
438
+ var _exit = false;
439
+ var _a, _b;
440
+ if (authConfigId === false) {
441
+ return AuthSessionState_await(undefined);
442
+ }
443
+ return AuthSessionState_await(_for(function () {
444
+ return !_exit;
445
+ }, void 0, function () {
446
+ var session = AuthSessionState.getSession();
447
+ if (session === undefined || !session.isActive || !Array.isArray(session.authConfigs)) {
448
+ var _AuthSessionState$res = AuthSessionState.resolveAuthConfig(authConfigId, requireReadyDefault);
449
+ _exit = true;
450
+ return _AuthSessionState$res;
451
+ }
452
+ var state = session.authConfigs.find(function (config) {
453
+ return config.config.authConfigId === authConfigId;
454
+ });
455
+ if (state === undefined) {
456
+ var _AuthSessionState$res2 = AuthSessionState.resolveAuthConfig(authConfigId, requireReadyDefault);
457
+ _exit = true;
458
+ return _AuthSessionState$res2;
459
+ }
460
+ var authenticationPromise = (_a = state.authenticationPromise) !== null && _a !== void 0 ? _a : state.refreshPromise;
461
+ return AuthSessionState_invoke(function () {
462
+ if (authenticationPromise !== undefined) {
463
+ return AuthSessionState_awaitIgnored(authenticationPromise);
464
+ }
465
+ }, function () {
466
+ if (AuthSessionState.getSession() !== session || !session.isActive) {
467
+ return;
468
+ }
469
+ var currentAuthenticationPromise = (_b = state.authenticationPromise) !== null && _b !== void 0 ? _b : state.refreshPromise;
470
+ if (currentAuthenticationPromise === undefined || currentAuthenticationPromise === authenticationPromise) {
471
+ var _AuthSessionState$res3 = AuthSessionState.resolveAuthConfig(authConfigId, true);
472
+ _exit = true;
473
+ return _AuthSessionState$res3;
474
+ }
475
+ });
476
+ }));
477
+ } catch (e) {
478
+ return Promise.reject(e);
479
+ }
480
+ }
262
481
  }]);
263
482
  }();
264
483
  AuthSessionState.stateKey = "BytescaleSessionState";
@@ -404,12 +623,43 @@ var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
404
623
  value: function getAccountId(config) {
405
624
  return BytescaleApiClientConfigUtils.resolveAuthentication(config).accountId;
406
625
  }
626
+ }, {
627
+ key: "getAccountIdAsync",
628
+ value: function getAccountIdAsync(config) {
629
+ try {
630
+ return runtime_await(BytescaleApiClientConfigUtils.resolveAuthenticationAsync(config), function (_BytescaleApiClientCo) {
631
+ return _BytescaleApiClientCo.accountId;
632
+ });
633
+ } catch (e) {
634
+ return Promise.reject(e);
635
+ }
636
+ }
407
637
  }, {
408
638
  key: "resolveAuthentication",
409
639
  value: function resolveAuthentication(config) {
410
- var _a, _b;
640
+ var _a;
411
641
  var apiKey = (_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined;
412
642
  var authConfig = AuthSessionState.resolveAuthConfig(config.authConfigId, apiKey === undefined);
643
+ return BytescaleApiClientConfigUtils.resolveAuthenticationWithAuthConfig(config, authConfig);
644
+ }
645
+ }, {
646
+ key: "resolveAuthenticationAsync",
647
+ value: function resolveAuthenticationAsync(config) {
648
+ try {
649
+ var _a;
650
+ var apiKey = (_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined;
651
+ return runtime_await(AuthSessionState.resolveAuthConfigAsync(config.authConfigId, apiKey === undefined), function (authConfig) {
652
+ return BytescaleApiClientConfigUtils.resolveAuthenticationWithAuthConfig(config, authConfig);
653
+ });
654
+ } catch (e) {
655
+ return Promise.reject(e);
656
+ }
657
+ }
658
+ }, {
659
+ key: "resolveAuthenticationWithAuthConfig",
660
+ value: function resolveAuthenticationWithAuthConfig(config, authConfig) {
661
+ var _a, _b;
662
+ var apiKey = (_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined;
413
663
  var apiKeyAccountId = apiKey === undefined ? undefined : BytescaleApiClientConfigUtils.getApiKeyAccountId(apiKey);
414
664
  if (apiKeyAccountId !== undefined && authConfig !== undefined && apiKeyAccountId !== authConfig.accountId) {
415
665
  throw new Error("The API key belongs to account '".concat(apiKeyAccountId, "', but AuthManager configuration '").concat((_b = config.authConfigId) !== null && _b !== void 0 ? _b : "default", "' belongs to account '").concat(authConfig.accountId, "'."));
@@ -496,7 +746,6 @@ var BaseAPI = /*#__PURE__*/function () {
496
746
  try {
497
747
  var _this = this;
498
748
  var _a;
499
- Object.assign(context.headers, BytescaleApiClientConfigUtils.resolveAuthentication(_this.config).headers);
500
749
  // Key: any possible value for 'baseUrlOverride'
501
750
  // Value: user-overridden value for that base URL from the config.
502
751
  var nonDefaultBasePaths = _defineProperty({}, BytescaleApiClientConfigUtils.defaultCdnUrl, BytescaleApiClientConfigUtils.getCdnUrl(_this.config));
@@ -537,44 +786,48 @@ var BaseAPI = /*#__PURE__*/function () {
537
786
  }
538
787
  var configHeaders = _this2.config.headers;
539
788
  return runtime_await(runtime_await(configHeaders === undefined ? {} : typeof configHeaders === "function" ? configHeaders() : configHeaders, function (resolvedConfigHeaders) {
540
- for (var _i = 0, _Object$keys = Object.keys(resolvedConfigHeaders); _i < _Object$keys.length; _i++) {
541
- var key = _Object$keys[_i];
542
- if (key.toLowerCase() === "authorization" || key.toLowerCase() === "authorization-token") {
543
- for (var _i2 = 0, _Object$keys2 = Object.keys(context.headers); _i2 < _Object$keys2.length; _i2++) {
544
- var generatedKey = _Object$keys2[_i2];
545
- if (generatedKey.toLowerCase() === key.toLowerCase()) {
546
- // Custom auth headers have documented precedence; remove the generated spelling to make that deterministic.
547
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
548
- delete context.headers[generatedKey];
789
+ var _context$headers = context.headers;
790
+ return runtime_await(BytescaleApiClientConfigUtils.resolveAuthenticationAsync(_this2.config), function (_BytescaleApiClientCo2) {
791
+ Object.assign(_context$headers, _BytescaleApiClientCo2.headers);
792
+ for (var _i = 0, _Object$keys = Object.keys(resolvedConfigHeaders); _i < _Object$keys.length; _i++) {
793
+ var key = _Object$keys[_i];
794
+ if (key.toLowerCase() === "authorization" || key.toLowerCase() === "authorization-token") {
795
+ for (var _i2 = 0, _Object$keys2 = Object.keys(context.headers); _i2 < _Object$keys2.length; _i2++) {
796
+ var generatedKey = _Object$keys2[_i2];
797
+ if (generatedKey.toLowerCase() === key.toLowerCase()) {
798
+ // Custom auth headers have documented precedence; remove the generated spelling to make that deterministic.
799
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
800
+ delete context.headers[generatedKey];
801
+ }
549
802
  }
550
803
  }
551
804
  }
552
- }
553
- var headers = Object.assign(Object.assign({}, context.headers), resolvedConfigHeaders);
554
- Object.keys(headers).forEach(function (key) {
555
- return headers[key] === undefined ? delete headers[key] : {};
556
- });
557
- var initOverrideFn = typeof initOverrides === "function" ? initOverrides : function () {
558
- return runtime_await(initOverrides);
559
- };
560
- var initParams = {
561
- method: context.method,
562
- headers: headers,
563
- body: context.body
564
- };
565
- var _Object$assign = Object.assign({}, initParams);
566
- return runtime_await(initOverrideFn({
567
- init: initParams,
568
- context: context
569
- }), function (_initOverrideFn) {
570
- var overriddenInit = Object.assign(_Object$assign, _initOverrideFn);
571
- var init = Object.assign(Object.assign({}, overriddenInit), {
572
- body: JSON.stringify(overriddenInit.body)
805
+ var headers = Object.assign(Object.assign({}, context.headers), resolvedConfigHeaders);
806
+ Object.keys(headers).forEach(function (key) {
807
+ return headers[key] === undefined ? delete headers[key] : {};
573
808
  });
574
- return {
575
- url: url,
576
- init: init
809
+ var initOverrideFn = typeof initOverrides === "function" ? initOverrides : function () {
810
+ return runtime_await(initOverrides);
577
811
  };
812
+ var initParams = {
813
+ method: context.method,
814
+ headers: headers,
815
+ body: context.body
816
+ };
817
+ var _Object$assign = Object.assign({}, initParams);
818
+ return runtime_await(initOverrideFn({
819
+ init: initParams,
820
+ context: context
821
+ }), function (_initOverrideFn) {
822
+ var overriddenInit = Object.assign(_Object$assign, _initOverrideFn);
823
+ var init = Object.assign(Object.assign({}, overriddenInit), {
824
+ body: JSON.stringify(overriddenInit.body)
825
+ });
826
+ return {
827
+ url: url,
828
+ init: init
829
+ };
830
+ });
578
831
  });
579
832
  }, configHeaders === undefined || !(typeof configHeaders === "function")));
580
833
  } catch (e) {
@@ -602,8 +855,8 @@ var BaseAPI = /*#__PURE__*/function () {
602
855
  // unless the following is set.
603
856
  // https://github.com/nodejs/node/issues/46221#issuecomment-1383246036
604
857
  duplex: "half"
605
- })), function (_BytescaleApiClientCo) {
606
- response = _BytescaleApiClientCo;
858
+ })), function (_BytescaleApiClientCo3) {
859
+ response = _BytescaleApiClientCo3;
607
860
  });
608
861
  }, function (e) {
609
862
  // Network-level errors, CORS errors, or HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies).
@@ -2014,21 +2267,21 @@ function _invokeIgnored(body) {
2014
2267
  return result.then(UploadManagerBase_empty);
2015
2268
  }
2016
2269
  }
2017
- function _settle(pact, state, value) {
2270
+ function UploadManagerBase_settle(pact, state, value) {
2018
2271
  if (!pact.s) {
2019
- if (value instanceof _Pact) {
2272
+ if (value instanceof UploadManagerBase_Pact) {
2020
2273
  if (value.s) {
2021
2274
  if (state & 1) {
2022
2275
  state = value.s;
2023
2276
  }
2024
2277
  value = value.v;
2025
2278
  } else {
2026
- value.o = _settle.bind(null, pact, state);
2279
+ value.o = UploadManagerBase_settle.bind(null, pact, state);
2027
2280
  return;
2028
2281
  }
2029
2282
  }
2030
2283
  if (value && value.then) {
2031
- value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
2284
+ value.then(UploadManagerBase_settle.bind(null, pact, state), UploadManagerBase_settle.bind(null, pact, 2));
2032
2285
  return;
2033
2286
  }
2034
2287
  pact.s = state;
@@ -2039,7 +2292,7 @@ function _settle(pact, state, value) {
2039
2292
  }
2040
2293
  }
2041
2294
  }
2042
- var _Pact = /*#__PURE__*/function () {
2295
+ var UploadManagerBase_Pact = /*#__PURE__*/function () {
2043
2296
  function _Pact() {}
2044
2297
  _Pact.prototype.then = function (onFulfilled, onRejected) {
2045
2298
  var result = new _Pact();
@@ -2048,9 +2301,9 @@ var _Pact = /*#__PURE__*/function () {
2048
2301
  var callback = state & 1 ? onFulfilled : onRejected;
2049
2302
  if (callback) {
2050
2303
  try {
2051
- _settle(result, 1, callback(this.v));
2304
+ UploadManagerBase_settle(result, 1, callback(this.v));
2052
2305
  } catch (e) {
2053
- _settle(result, 2, e);
2306
+ UploadManagerBase_settle(result, 2, e);
2054
2307
  }
2055
2308
  return result;
2056
2309
  } else {
@@ -2061,28 +2314,28 @@ var _Pact = /*#__PURE__*/function () {
2061
2314
  try {
2062
2315
  var value = _this.v;
2063
2316
  if (_this.s & 1) {
2064
- _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
2317
+ UploadManagerBase_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
2065
2318
  } else if (onRejected) {
2066
- _settle(result, 1, onRejected(value));
2319
+ UploadManagerBase_settle(result, 1, onRejected(value));
2067
2320
  } else {
2068
- _settle(result, 2, value);
2321
+ UploadManagerBase_settle(result, 2, value);
2069
2322
  }
2070
2323
  } catch (e) {
2071
- _settle(result, 2, e);
2324
+ UploadManagerBase_settle(result, 2, e);
2072
2325
  }
2073
2326
  };
2074
2327
  return result;
2075
2328
  };
2076
2329
  return _Pact;
2077
2330
  }();
2078
- function _isSettledPact(thenable) {
2079
- return thenable instanceof _Pact && thenable.s & 1;
2331
+ function UploadManagerBase_isSettledPact(thenable) {
2332
+ return thenable instanceof UploadManagerBase_Pact && thenable.s & 1;
2080
2333
  }
2081
- function _for(test, update, body) {
2334
+ function UploadManagerBase_for(test, update, body) {
2082
2335
  var stage;
2083
2336
  for (;;) {
2084
2337
  var shouldContinue = test();
2085
- if (_isSettledPact(shouldContinue)) {
2338
+ if (UploadManagerBase_isSettledPact(shouldContinue)) {
2086
2339
  shouldContinue = shouldContinue.v;
2087
2340
  }
2088
2341
  if (!shouldContinue) {
@@ -2094,7 +2347,7 @@ function _for(test, update, body) {
2094
2347
  }
2095
2348
  var result = body();
2096
2349
  if (result && result.then) {
2097
- if (_isSettledPact(result)) {
2350
+ if (UploadManagerBase_isSettledPact(result)) {
2098
2351
  result = result.s;
2099
2352
  } else {
2100
2353
  stage = 1;
@@ -2103,14 +2356,14 @@ function _for(test, update, body) {
2103
2356
  }
2104
2357
  if (update) {
2105
2358
  var updateValue = update();
2106
- if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
2359
+ if (updateValue && updateValue.then && !UploadManagerBase_isSettledPact(updateValue)) {
2107
2360
  stage = 2;
2108
2361
  break;
2109
2362
  }
2110
2363
  }
2111
2364
  }
2112
- var pact = new _Pact();
2113
- var reject = _settle.bind(null, pact, 2);
2365
+ var pact = new UploadManagerBase_Pact();
2366
+ var reject = UploadManagerBase_settle.bind(null, pact, 2);
2114
2367
  (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
2115
2368
  return pact;
2116
2369
  function _resumeAfterBody(value) {
@@ -2118,14 +2371,14 @@ function _for(test, update, body) {
2118
2371
  do {
2119
2372
  if (update) {
2120
2373
  updateValue = update();
2121
- if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
2374
+ if (updateValue && updateValue.then && !UploadManagerBase_isSettledPact(updateValue)) {
2122
2375
  updateValue.then(_resumeAfterUpdate).then(void 0, reject);
2123
2376
  return;
2124
2377
  }
2125
2378
  }
2126
2379
  shouldContinue = test();
2127
- if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
2128
- _settle(pact, 1, result);
2380
+ if (!shouldContinue || UploadManagerBase_isSettledPact(shouldContinue) && !shouldContinue.v) {
2381
+ UploadManagerBase_settle(pact, 1, result);
2129
2382
  return;
2130
2383
  }
2131
2384
  if (shouldContinue.then) {
@@ -2133,7 +2386,7 @@ function _for(test, update, body) {
2133
2386
  return;
2134
2387
  }
2135
2388
  result = body();
2136
- if (_isSettledPact(result)) {
2389
+ if (UploadManagerBase_isSettledPact(result)) {
2137
2390
  result = result.v;
2138
2391
  }
2139
2392
  } while (!result || !result.then);
@@ -2148,7 +2401,7 @@ function _for(test, update, body) {
2148
2401
  _resumeAfterBody(result);
2149
2402
  }
2150
2403
  } else {
2151
- _settle(pact, 1, result);
2404
+ UploadManagerBase_settle(pact, 1, result);
2152
2405
  }
2153
2406
  }
2154
2407
  function _resumeAfterUpdate() {
@@ -2159,7 +2412,7 @@ function _for(test, update, body) {
2159
2412
  _resumeAfterTest(shouldContinue);
2160
2413
  }
2161
2414
  } else {
2162
- _settle(pact, 1, result);
2415
+ UploadManagerBase_settle(pact, 1, result);
2163
2416
  }
2164
2417
  }
2165
2418
  }
@@ -2199,40 +2452,41 @@ var UploadManagerBase = /*#__PURE__*/function () {
2199
2452
  try {
2200
2453
  var _this = this;
2201
2454
  _this.assertNotCancelled(request);
2202
- var accountId = BytescaleApiClientConfigUtils.getAccountId(_this.config);
2203
- var source = _this.processUploadSource(request.data);
2204
- var preUploadInfo = _this.getPreUploadInfo(request, source);
2205
- var bytesTotal = preUploadInfo.size;
2206
- var makeOnProgressForPart = _this.makeOnProgressForPartFactory(request, bytesTotal);
2207
- var init = _this.preUpload(source);
2208
- // Raise initial progress event SYNCHRONOUSLY.
2209
- if (request.onProgress !== undefined) {
2210
- request.onProgress(_this.makeProgressEvent(0, bytesTotal));
2211
- }
2212
- return UploadManagerBase_await(_this.beginUpload(request, preUploadInfo, accountId), function (uploadInfo) {
2213
- var partCount = uploadInfo.uploadParts.count;
2214
- var parts = UploadManagerBase_toConsumableArray(Array(partCount).keys());
2215
- var _this$makeCancellatio = _this.makeCancellationMethods(),
2216
- cancel = _this$makeCancellatio.cancel,
2217
- addCancellationHandler = _this$makeCancellatio.addCancellationHandler;
2218
- var intervalHandle = setInterval(_this.onIntervalTick(request, cancel), _this.intervalMs);
2219
- var uploadedParts;
2220
- return UploadManagerBase_continue(UploadManagerBase_finallyRethrows(function () {
2221
- return UploadManagerBase_await(_this.mapAsync(parts, preUploadInfo.maxConcurrentUploadParts, _async(function (part) {
2222
- return _this.uploadPart(request, source, part, uploadInfo, makeOnProgressForPart(), addCancellationHandler, accountId);
2223
- })), function (_this$mapAsync) {
2224
- uploadedParts = _this$mapAsync;
2225
- return UploadManagerBase_awaitIgnored(_this.postUpload(init));
2226
- });
2227
- }, function (_wasThrown, _result) {
2228
- clearInterval(intervalHandle);
2229
- return UploadManagerBase_rethrow(_wasThrown, _result);
2230
- }), function () {
2231
- var etag = uploadedParts.flatMap(function (x) {
2232
- return x.status === "Completed" ? [x.etag] : [];
2233
- })[0];
2234
- return Object.assign(Object.assign({}, uploadInfo.file), {
2235
- etag: etag // The 'etag' in the original 'uploadInfo.file' will be null, so we set it to the final etag value here.
2455
+ return UploadManagerBase_await(BytescaleApiClientConfigUtils.getAccountIdAsync(_this.config), function (accountId) {
2456
+ var source = _this.processUploadSource(request.data);
2457
+ var preUploadInfo = _this.getPreUploadInfo(request, source);
2458
+ var bytesTotal = preUploadInfo.size;
2459
+ var makeOnProgressForPart = _this.makeOnProgressForPartFactory(request, bytesTotal);
2460
+ var init = _this.preUpload(source);
2461
+ // Raise initial progress event SYNCHRONOUSLY.
2462
+ if (request.onProgress !== undefined) {
2463
+ request.onProgress(_this.makeProgressEvent(0, bytesTotal));
2464
+ }
2465
+ return UploadManagerBase_await(_this.beginUpload(request, preUploadInfo, accountId), function (uploadInfo) {
2466
+ var partCount = uploadInfo.uploadParts.count;
2467
+ var parts = UploadManagerBase_toConsumableArray(Array(partCount).keys());
2468
+ var _this$makeCancellatio = _this.makeCancellationMethods(),
2469
+ cancel = _this$makeCancellatio.cancel,
2470
+ addCancellationHandler = _this$makeCancellatio.addCancellationHandler;
2471
+ var intervalHandle = setInterval(_this.onIntervalTick(request, cancel), _this.intervalMs);
2472
+ var uploadedParts;
2473
+ return UploadManagerBase_continue(UploadManagerBase_finallyRethrows(function () {
2474
+ return UploadManagerBase_await(_this.mapAsync(parts, preUploadInfo.maxConcurrentUploadParts, _async(function (part) {
2475
+ return _this.uploadPart(request, source, part, uploadInfo, makeOnProgressForPart(), addCancellationHandler, accountId);
2476
+ })), function (_this$mapAsync) {
2477
+ uploadedParts = _this$mapAsync;
2478
+ return UploadManagerBase_awaitIgnored(_this.postUpload(init));
2479
+ });
2480
+ }, function (_wasThrown, _result) {
2481
+ clearInterval(intervalHandle);
2482
+ return UploadManagerBase_rethrow(_wasThrown, _result);
2483
+ }), function () {
2484
+ var etag = uploadedParts.flatMap(function (x) {
2485
+ return x.status === "Completed" ? [x.etag] : [];
2486
+ })[0];
2487
+ return Object.assign(Object.assign({}, uploadInfo.file), {
2488
+ etag: etag // The 'etag' in the original 'uploadInfo.file' will be null, so we set it to the final etag value here.
2489
+ });
2236
2490
  });
2237
2491
  });
2238
2492
  });
@@ -2439,7 +2693,7 @@ var UploadManagerBase = /*#__PURE__*/function () {
2439
2693
  var result = [];
2440
2694
  var workQueue = UploadManagerBase_toConsumableArray(items);
2441
2695
  return UploadManagerBase_await(Promise.all(UploadManagerBase_toConsumableArray(Array(concurrency).keys()).map(_async(function () {
2442
- return _continueIgnored(_for(function () {
2696
+ return _continueIgnored(UploadManagerBase_for(function () {
2443
2697
  return workQueue.length > 0;
2444
2698
  }, void 0, function () {
2445
2699
  var work = workQueue.shift(); // IMPORTANT: use 'shift' instead of 'pop' to ensure 'items' are processed in order when 'concurrency = 1'.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytescale/sdk",
3
- "version": "3.60.0",
3
+ "version": "3.62.0",
4
4
  "description": "Bytescale JavaScript SDK",
5
5
  "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
6
6
  "license": "MIT",