@bytescale/sdk 3.60.0 → 3.61.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.
@@ -193,6 +193,177 @@ var FairMutex = /*#__PURE__*/function () {
193
193
  }]);
194
194
  }();
195
195
  ;// ./src/private/AuthSessionState.ts
196
+ function AuthSessionState_empty() {}
197
+ function AuthSessionState_awaitIgnored(value, direct) {
198
+ if (!direct) {
199
+ return value && value.then ? value.then(AuthSessionState_empty) : Promise.resolve();
200
+ }
201
+ }
202
+ function AuthSessionState_invoke(body, then) {
203
+ var result = body();
204
+ if (result && result.then) {
205
+ return result.then(then);
206
+ }
207
+ return then(result);
208
+ }
209
+ function _settle(pact, state, value) {
210
+ if (!pact.s) {
211
+ if (value instanceof _Pact) {
212
+ if (value.s) {
213
+ if (state & 1) {
214
+ state = value.s;
215
+ }
216
+ value = value.v;
217
+ } else {
218
+ value.o = _settle.bind(null, pact, state);
219
+ return;
220
+ }
221
+ }
222
+ if (value && value.then) {
223
+ value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
224
+ return;
225
+ }
226
+ pact.s = state;
227
+ pact.v = value;
228
+ var observer = pact.o;
229
+ if (observer) {
230
+ observer(pact);
231
+ }
232
+ }
233
+ }
234
+ var _Pact = /*#__PURE__*/function () {
235
+ function _Pact() {}
236
+ _Pact.prototype.then = function (onFulfilled, onRejected) {
237
+ var result = new _Pact();
238
+ var state = this.s;
239
+ if (state) {
240
+ var callback = state & 1 ? onFulfilled : onRejected;
241
+ if (callback) {
242
+ try {
243
+ _settle(result, 1, callback(this.v));
244
+ } catch (e) {
245
+ _settle(result, 2, e);
246
+ }
247
+ return result;
248
+ } else {
249
+ return this;
250
+ }
251
+ }
252
+ this.o = function (_this) {
253
+ try {
254
+ var value = _this.v;
255
+ if (_this.s & 1) {
256
+ _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
257
+ } else if (onRejected) {
258
+ _settle(result, 1, onRejected(value));
259
+ } else {
260
+ _settle(result, 2, value);
261
+ }
262
+ } catch (e) {
263
+ _settle(result, 2, e);
264
+ }
265
+ };
266
+ return result;
267
+ };
268
+ return _Pact;
269
+ }();
270
+ function _isSettledPact(thenable) {
271
+ return thenable instanceof _Pact && thenable.s & 1;
272
+ }
273
+ function _for(test, update, body) {
274
+ var stage;
275
+ for (;;) {
276
+ var shouldContinue = test();
277
+ if (_isSettledPact(shouldContinue)) {
278
+ shouldContinue = shouldContinue.v;
279
+ }
280
+ if (!shouldContinue) {
281
+ return result;
282
+ }
283
+ if (shouldContinue.then) {
284
+ stage = 0;
285
+ break;
286
+ }
287
+ var result = body();
288
+ if (result && result.then) {
289
+ if (_isSettledPact(result)) {
290
+ result = result.s;
291
+ } else {
292
+ stage = 1;
293
+ break;
294
+ }
295
+ }
296
+ if (update) {
297
+ var updateValue = update();
298
+ if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
299
+ stage = 2;
300
+ break;
301
+ }
302
+ }
303
+ }
304
+ var pact = new _Pact();
305
+ var reject = _settle.bind(null, pact, 2);
306
+ (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
307
+ return pact;
308
+ function _resumeAfterBody(value) {
309
+ result = value;
310
+ do {
311
+ if (update) {
312
+ updateValue = update();
313
+ if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
314
+ updateValue.then(_resumeAfterUpdate).then(void 0, reject);
315
+ return;
316
+ }
317
+ }
318
+ shouldContinue = test();
319
+ if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
320
+ _settle(pact, 1, result);
321
+ return;
322
+ }
323
+ if (shouldContinue.then) {
324
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
325
+ return;
326
+ }
327
+ result = body();
328
+ if (_isSettledPact(result)) {
329
+ result = result.v;
330
+ }
331
+ } while (!result || !result.then);
332
+ result.then(_resumeAfterBody).then(void 0, reject);
333
+ }
334
+ function _resumeAfterTest(shouldContinue) {
335
+ if (shouldContinue) {
336
+ result = body();
337
+ if (result && result.then) {
338
+ result.then(_resumeAfterBody).then(void 0, reject);
339
+ } else {
340
+ _resumeAfterBody(result);
341
+ }
342
+ } else {
343
+ _settle(pact, 1, result);
344
+ }
345
+ }
346
+ function _resumeAfterUpdate() {
347
+ if (shouldContinue = test()) {
348
+ if (shouldContinue.then) {
349
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
350
+ } else {
351
+ _resumeAfterTest(shouldContinue);
352
+ }
353
+ } else {
354
+ _settle(pact, 1, result);
355
+ }
356
+ }
357
+ }
358
+ function AuthSessionState_await(value, then, direct) {
359
+ if (direct) {
360
+ return then ? then(value) : value;
361
+ }
362
+ if (!value || !value.then) {
363
+ value = Promise.resolve(value);
364
+ }
365
+ return then ? value.then(then) : value;
366
+ }
196
367
  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); }
197
368
  function AuthSessionState_classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
198
369
  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); } }
@@ -299,6 +470,54 @@ var AuthSessionState = /*#__PURE__*/function () {
299
470
  jwt: undefined
300
471
  };
301
472
  }
473
+ /** Waits for request-time auth to be current before resolving it. */
474
+ }, {
475
+ key: "resolveAuthConfigAsync",
476
+ value: function resolveAuthConfigAsync(authConfigId, requireReadyDefault) {
477
+ try {
478
+ var _exit = false;
479
+ var _a, _b;
480
+ if (authConfigId === false) {
481
+ return AuthSessionState_await(undefined);
482
+ }
483
+ return AuthSessionState_await(_for(function () {
484
+ return !_exit;
485
+ }, void 0, function () {
486
+ var session = AuthSessionState.getSession();
487
+ if (session === undefined || !session.isActive || !Array.isArray(session.authConfigs)) {
488
+ var _AuthSessionState$res = AuthSessionState.resolveAuthConfig(authConfigId, requireReadyDefault);
489
+ _exit = true;
490
+ return _AuthSessionState$res;
491
+ }
492
+ var state = session.authConfigs.find(function (config) {
493
+ return config.config.authConfigId === authConfigId;
494
+ });
495
+ if (state === undefined) {
496
+ var _AuthSessionState$res2 = AuthSessionState.resolveAuthConfig(authConfigId, requireReadyDefault);
497
+ _exit = true;
498
+ return _AuthSessionState$res2;
499
+ }
500
+ var authenticationPromise = (_a = state.authenticationPromise) !== null && _a !== void 0 ? _a : state.refreshPromise;
501
+ return AuthSessionState_invoke(function () {
502
+ if (authenticationPromise !== undefined) {
503
+ return AuthSessionState_awaitIgnored(authenticationPromise);
504
+ }
505
+ }, function () {
506
+ if (AuthSessionState.getSession() !== session || !session.isActive) {
507
+ return;
508
+ }
509
+ var currentAuthenticationPromise = (_b = state.authenticationPromise) !== null && _b !== void 0 ? _b : state.refreshPromise;
510
+ if (currentAuthenticationPromise === undefined || currentAuthenticationPromise === authenticationPromise) {
511
+ var _AuthSessionState$res3 = AuthSessionState.resolveAuthConfig(authConfigId, true);
512
+ _exit = true;
513
+ return _AuthSessionState$res3;
514
+ }
515
+ });
516
+ }));
517
+ } catch (e) {
518
+ return Promise.reject(e);
519
+ }
520
+ }
302
521
  }]);
303
522
  }();
304
523
  AuthSessionState.stateKey = "BytescaleSessionState";
@@ -444,12 +663,43 @@ var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
444
663
  value: function getAccountId(config) {
445
664
  return BytescaleApiClientConfigUtils.resolveAuthentication(config).accountId;
446
665
  }
666
+ }, {
667
+ key: "getAccountIdAsync",
668
+ value: function getAccountIdAsync(config) {
669
+ try {
670
+ return runtime_await(BytescaleApiClientConfigUtils.resolveAuthenticationAsync(config), function (_BytescaleApiClientCo) {
671
+ return _BytescaleApiClientCo.accountId;
672
+ });
673
+ } catch (e) {
674
+ return Promise.reject(e);
675
+ }
676
+ }
447
677
  }, {
448
678
  key: "resolveAuthentication",
449
679
  value: function resolveAuthentication(config) {
450
- var _a, _b;
680
+ var _a;
451
681
  var apiKey = (_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined;
452
682
  var authConfig = AuthSessionState.resolveAuthConfig(config.authConfigId, apiKey === undefined);
683
+ return BytescaleApiClientConfigUtils.resolveAuthenticationWithAuthConfig(config, authConfig);
684
+ }
685
+ }, {
686
+ key: "resolveAuthenticationAsync",
687
+ value: function resolveAuthenticationAsync(config) {
688
+ try {
689
+ var _a;
690
+ var apiKey = (_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined;
691
+ return runtime_await(AuthSessionState.resolveAuthConfigAsync(config.authConfigId, apiKey === undefined), function (authConfig) {
692
+ return BytescaleApiClientConfigUtils.resolveAuthenticationWithAuthConfig(config, authConfig);
693
+ });
694
+ } catch (e) {
695
+ return Promise.reject(e);
696
+ }
697
+ }
698
+ }, {
699
+ key: "resolveAuthenticationWithAuthConfig",
700
+ value: function resolveAuthenticationWithAuthConfig(config, authConfig) {
701
+ var _a, _b;
702
+ var apiKey = (_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined;
453
703
  var apiKeyAccountId = apiKey === undefined ? undefined : BytescaleApiClientConfigUtils.getApiKeyAccountId(apiKey);
454
704
  if (apiKeyAccountId !== undefined && authConfig !== undefined && apiKeyAccountId !== authConfig.accountId) {
455
705
  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, "'."));
@@ -536,7 +786,6 @@ var BaseAPI = /*#__PURE__*/function () {
536
786
  try {
537
787
  var _this = this;
538
788
  var _a;
539
- Object.assign(context.headers, BytescaleApiClientConfigUtils.resolveAuthentication(_this.config).headers);
540
789
  // Key: any possible value for 'baseUrlOverride'
541
790
  // Value: user-overridden value for that base URL from the config.
542
791
  var nonDefaultBasePaths = _defineProperty({}, BytescaleApiClientConfigUtils.defaultCdnUrl, BytescaleApiClientConfigUtils.getCdnUrl(_this.config));
@@ -577,44 +826,48 @@ var BaseAPI = /*#__PURE__*/function () {
577
826
  }
578
827
  var configHeaders = _this2.config.headers;
579
828
  return runtime_await(runtime_await(configHeaders === undefined ? {} : typeof configHeaders === "function" ? configHeaders() : configHeaders, function (resolvedConfigHeaders) {
580
- for (var _i = 0, _Object$keys = Object.keys(resolvedConfigHeaders); _i < _Object$keys.length; _i++) {
581
- var key = _Object$keys[_i];
582
- if (key.toLowerCase() === "authorization" || key.toLowerCase() === "authorization-token") {
583
- for (var _i2 = 0, _Object$keys2 = Object.keys(context.headers); _i2 < _Object$keys2.length; _i2++) {
584
- var generatedKey = _Object$keys2[_i2];
585
- if (generatedKey.toLowerCase() === key.toLowerCase()) {
586
- // Custom auth headers have documented precedence; remove the generated spelling to make that deterministic.
587
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
588
- delete context.headers[generatedKey];
829
+ var _context$headers = context.headers;
830
+ return runtime_await(BytescaleApiClientConfigUtils.resolveAuthenticationAsync(_this2.config), function (_BytescaleApiClientCo2) {
831
+ Object.assign(_context$headers, _BytescaleApiClientCo2.headers);
832
+ for (var _i = 0, _Object$keys = Object.keys(resolvedConfigHeaders); _i < _Object$keys.length; _i++) {
833
+ var key = _Object$keys[_i];
834
+ if (key.toLowerCase() === "authorization" || key.toLowerCase() === "authorization-token") {
835
+ for (var _i2 = 0, _Object$keys2 = Object.keys(context.headers); _i2 < _Object$keys2.length; _i2++) {
836
+ var generatedKey = _Object$keys2[_i2];
837
+ if (generatedKey.toLowerCase() === key.toLowerCase()) {
838
+ // Custom auth headers have documented precedence; remove the generated spelling to make that deterministic.
839
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
840
+ delete context.headers[generatedKey];
841
+ }
589
842
  }
590
843
  }
591
844
  }
592
- }
593
- var headers = Object.assign(Object.assign({}, context.headers), resolvedConfigHeaders);
594
- Object.keys(headers).forEach(function (key) {
595
- return headers[key] === undefined ? delete headers[key] : {};
596
- });
597
- var initOverrideFn = typeof initOverrides === "function" ? initOverrides : function () {
598
- return runtime_await(initOverrides);
599
- };
600
- var initParams = {
601
- method: context.method,
602
- headers: headers,
603
- body: context.body
604
- };
605
- var _Object$assign = Object.assign({}, initParams);
606
- return runtime_await(initOverrideFn({
607
- init: initParams,
608
- context: context
609
- }), function (_initOverrideFn) {
610
- var overriddenInit = Object.assign(_Object$assign, _initOverrideFn);
611
- var init = Object.assign(Object.assign({}, overriddenInit), {
612
- body: JSON.stringify(overriddenInit.body)
845
+ var headers = Object.assign(Object.assign({}, context.headers), resolvedConfigHeaders);
846
+ Object.keys(headers).forEach(function (key) {
847
+ return headers[key] === undefined ? delete headers[key] : {};
613
848
  });
614
- return {
615
- url: url,
616
- init: init
849
+ var initOverrideFn = typeof initOverrides === "function" ? initOverrides : function () {
850
+ return runtime_await(initOverrides);
617
851
  };
852
+ var initParams = {
853
+ method: context.method,
854
+ headers: headers,
855
+ body: context.body
856
+ };
857
+ var _Object$assign = Object.assign({}, initParams);
858
+ return runtime_await(initOverrideFn({
859
+ init: initParams,
860
+ context: context
861
+ }), function (_initOverrideFn) {
862
+ var overriddenInit = Object.assign(_Object$assign, _initOverrideFn);
863
+ var init = Object.assign(Object.assign({}, overriddenInit), {
864
+ body: JSON.stringify(overriddenInit.body)
865
+ });
866
+ return {
867
+ url: url,
868
+ init: init
869
+ };
870
+ });
618
871
  });
619
872
  }, configHeaders === undefined || !(typeof configHeaders === "function")));
620
873
  } catch (e) {
@@ -642,8 +895,8 @@ var BaseAPI = /*#__PURE__*/function () {
642
895
  // unless the following is set.
643
896
  // https://github.com/nodejs/node/issues/46221#issuecomment-1383246036
644
897
  duplex: "half"
645
- })), function (_BytescaleApiClientCo) {
646
- response = _BytescaleApiClientCo;
898
+ })), function (_BytescaleApiClientCo3) {
899
+ response = _BytescaleApiClientCo3;
647
900
  });
648
901
  }, function (e) {
649
902
  // Network-level errors, CORS errors, or HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies).
@@ -2054,21 +2307,21 @@ function _invokeIgnored(body) {
2054
2307
  return result.then(UploadManagerBase_empty);
2055
2308
  }
2056
2309
  }
2057
- function _settle(pact, state, value) {
2310
+ function UploadManagerBase_settle(pact, state, value) {
2058
2311
  if (!pact.s) {
2059
- if (value instanceof _Pact) {
2312
+ if (value instanceof UploadManagerBase_Pact) {
2060
2313
  if (value.s) {
2061
2314
  if (state & 1) {
2062
2315
  state = value.s;
2063
2316
  }
2064
2317
  value = value.v;
2065
2318
  } else {
2066
- value.o = _settle.bind(null, pact, state);
2319
+ value.o = UploadManagerBase_settle.bind(null, pact, state);
2067
2320
  return;
2068
2321
  }
2069
2322
  }
2070
2323
  if (value && value.then) {
2071
- value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
2324
+ value.then(UploadManagerBase_settle.bind(null, pact, state), UploadManagerBase_settle.bind(null, pact, 2));
2072
2325
  return;
2073
2326
  }
2074
2327
  pact.s = state;
@@ -2079,7 +2332,7 @@ function _settle(pact, state, value) {
2079
2332
  }
2080
2333
  }
2081
2334
  }
2082
- var _Pact = /*#__PURE__*/function () {
2335
+ var UploadManagerBase_Pact = /*#__PURE__*/function () {
2083
2336
  function _Pact() {}
2084
2337
  _Pact.prototype.then = function (onFulfilled, onRejected) {
2085
2338
  var result = new _Pact();
@@ -2088,9 +2341,9 @@ var _Pact = /*#__PURE__*/function () {
2088
2341
  var callback = state & 1 ? onFulfilled : onRejected;
2089
2342
  if (callback) {
2090
2343
  try {
2091
- _settle(result, 1, callback(this.v));
2344
+ UploadManagerBase_settle(result, 1, callback(this.v));
2092
2345
  } catch (e) {
2093
- _settle(result, 2, e);
2346
+ UploadManagerBase_settle(result, 2, e);
2094
2347
  }
2095
2348
  return result;
2096
2349
  } else {
@@ -2101,28 +2354,28 @@ var _Pact = /*#__PURE__*/function () {
2101
2354
  try {
2102
2355
  var value = _this.v;
2103
2356
  if (_this.s & 1) {
2104
- _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
2357
+ UploadManagerBase_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
2105
2358
  } else if (onRejected) {
2106
- _settle(result, 1, onRejected(value));
2359
+ UploadManagerBase_settle(result, 1, onRejected(value));
2107
2360
  } else {
2108
- _settle(result, 2, value);
2361
+ UploadManagerBase_settle(result, 2, value);
2109
2362
  }
2110
2363
  } catch (e) {
2111
- _settle(result, 2, e);
2364
+ UploadManagerBase_settle(result, 2, e);
2112
2365
  }
2113
2366
  };
2114
2367
  return result;
2115
2368
  };
2116
2369
  return _Pact;
2117
2370
  }();
2118
- function _isSettledPact(thenable) {
2119
- return thenable instanceof _Pact && thenable.s & 1;
2371
+ function UploadManagerBase_isSettledPact(thenable) {
2372
+ return thenable instanceof UploadManagerBase_Pact && thenable.s & 1;
2120
2373
  }
2121
- function _for(test, update, body) {
2374
+ function UploadManagerBase_for(test, update, body) {
2122
2375
  var stage;
2123
2376
  for (;;) {
2124
2377
  var shouldContinue = test();
2125
- if (_isSettledPact(shouldContinue)) {
2378
+ if (UploadManagerBase_isSettledPact(shouldContinue)) {
2126
2379
  shouldContinue = shouldContinue.v;
2127
2380
  }
2128
2381
  if (!shouldContinue) {
@@ -2134,7 +2387,7 @@ function _for(test, update, body) {
2134
2387
  }
2135
2388
  var result = body();
2136
2389
  if (result && result.then) {
2137
- if (_isSettledPact(result)) {
2390
+ if (UploadManagerBase_isSettledPact(result)) {
2138
2391
  result = result.s;
2139
2392
  } else {
2140
2393
  stage = 1;
@@ -2143,14 +2396,14 @@ function _for(test, update, body) {
2143
2396
  }
2144
2397
  if (update) {
2145
2398
  var updateValue = update();
2146
- if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
2399
+ if (updateValue && updateValue.then && !UploadManagerBase_isSettledPact(updateValue)) {
2147
2400
  stage = 2;
2148
2401
  break;
2149
2402
  }
2150
2403
  }
2151
2404
  }
2152
- var pact = new _Pact();
2153
- var reject = _settle.bind(null, pact, 2);
2405
+ var pact = new UploadManagerBase_Pact();
2406
+ var reject = UploadManagerBase_settle.bind(null, pact, 2);
2154
2407
  (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
2155
2408
  return pact;
2156
2409
  function _resumeAfterBody(value) {
@@ -2158,14 +2411,14 @@ function _for(test, update, body) {
2158
2411
  do {
2159
2412
  if (update) {
2160
2413
  updateValue = update();
2161
- if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
2414
+ if (updateValue && updateValue.then && !UploadManagerBase_isSettledPact(updateValue)) {
2162
2415
  updateValue.then(_resumeAfterUpdate).then(void 0, reject);
2163
2416
  return;
2164
2417
  }
2165
2418
  }
2166
2419
  shouldContinue = test();
2167
- if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
2168
- _settle(pact, 1, result);
2420
+ if (!shouldContinue || UploadManagerBase_isSettledPact(shouldContinue) && !shouldContinue.v) {
2421
+ UploadManagerBase_settle(pact, 1, result);
2169
2422
  return;
2170
2423
  }
2171
2424
  if (shouldContinue.then) {
@@ -2173,7 +2426,7 @@ function _for(test, update, body) {
2173
2426
  return;
2174
2427
  }
2175
2428
  result = body();
2176
- if (_isSettledPact(result)) {
2429
+ if (UploadManagerBase_isSettledPact(result)) {
2177
2430
  result = result.v;
2178
2431
  }
2179
2432
  } while (!result || !result.then);
@@ -2188,7 +2441,7 @@ function _for(test, update, body) {
2188
2441
  _resumeAfterBody(result);
2189
2442
  }
2190
2443
  } else {
2191
- _settle(pact, 1, result);
2444
+ UploadManagerBase_settle(pact, 1, result);
2192
2445
  }
2193
2446
  }
2194
2447
  function _resumeAfterUpdate() {
@@ -2199,7 +2452,7 @@ function _for(test, update, body) {
2199
2452
  _resumeAfterTest(shouldContinue);
2200
2453
  }
2201
2454
  } else {
2202
- _settle(pact, 1, result);
2455
+ UploadManagerBase_settle(pact, 1, result);
2203
2456
  }
2204
2457
  }
2205
2458
  }
@@ -2239,40 +2492,41 @@ var UploadManagerBase = /*#__PURE__*/function () {
2239
2492
  try {
2240
2493
  var _this = this;
2241
2494
  _this.assertNotCancelled(request);
2242
- var accountId = BytescaleApiClientConfigUtils.getAccountId(_this.config);
2243
- var source = _this.processUploadSource(request.data);
2244
- var preUploadInfo = _this.getPreUploadInfo(request, source);
2245
- var bytesTotal = preUploadInfo.size;
2246
- var makeOnProgressForPart = _this.makeOnProgressForPartFactory(request, bytesTotal);
2247
- var init = _this.preUpload(source);
2248
- // Raise initial progress event SYNCHRONOUSLY.
2249
- if (request.onProgress !== undefined) {
2250
- request.onProgress(_this.makeProgressEvent(0, bytesTotal));
2251
- }
2252
- return UploadManagerBase_await(_this.beginUpload(request, preUploadInfo, accountId), function (uploadInfo) {
2253
- var partCount = uploadInfo.uploadParts.count;
2254
- var parts = UploadManagerBase_toConsumableArray(Array(partCount).keys());
2255
- var _this$makeCancellatio = _this.makeCancellationMethods(),
2256
- cancel = _this$makeCancellatio.cancel,
2257
- addCancellationHandler = _this$makeCancellatio.addCancellationHandler;
2258
- var intervalHandle = setInterval(_this.onIntervalTick(request, cancel), _this.intervalMs);
2259
- var uploadedParts;
2260
- return UploadManagerBase_continue(UploadManagerBase_finallyRethrows(function () {
2261
- return UploadManagerBase_await(_this.mapAsync(parts, preUploadInfo.maxConcurrentUploadParts, _async(function (part) {
2262
- return _this.uploadPart(request, source, part, uploadInfo, makeOnProgressForPart(), addCancellationHandler, accountId);
2263
- })), function (_this$mapAsync) {
2264
- uploadedParts = _this$mapAsync;
2265
- return UploadManagerBase_awaitIgnored(_this.postUpload(init));
2266
- });
2267
- }, function (_wasThrown, _result) {
2268
- clearInterval(intervalHandle);
2269
- return UploadManagerBase_rethrow(_wasThrown, _result);
2270
- }), function () {
2271
- var etag = uploadedParts.flatMap(function (x) {
2272
- return x.status === "Completed" ? [x.etag] : [];
2273
- })[0];
2274
- return Object.assign(Object.assign({}, uploadInfo.file), {
2275
- etag: etag // The 'etag' in the original 'uploadInfo.file' will be null, so we set it to the final etag value here.
2495
+ return UploadManagerBase_await(BytescaleApiClientConfigUtils.getAccountIdAsync(_this.config), function (accountId) {
2496
+ var source = _this.processUploadSource(request.data);
2497
+ var preUploadInfo = _this.getPreUploadInfo(request, source);
2498
+ var bytesTotal = preUploadInfo.size;
2499
+ var makeOnProgressForPart = _this.makeOnProgressForPartFactory(request, bytesTotal);
2500
+ var init = _this.preUpload(source);
2501
+ // Raise initial progress event SYNCHRONOUSLY.
2502
+ if (request.onProgress !== undefined) {
2503
+ request.onProgress(_this.makeProgressEvent(0, bytesTotal));
2504
+ }
2505
+ return UploadManagerBase_await(_this.beginUpload(request, preUploadInfo, accountId), function (uploadInfo) {
2506
+ var partCount = uploadInfo.uploadParts.count;
2507
+ var parts = UploadManagerBase_toConsumableArray(Array(partCount).keys());
2508
+ var _this$makeCancellatio = _this.makeCancellationMethods(),
2509
+ cancel = _this$makeCancellatio.cancel,
2510
+ addCancellationHandler = _this$makeCancellatio.addCancellationHandler;
2511
+ var intervalHandle = setInterval(_this.onIntervalTick(request, cancel), _this.intervalMs);
2512
+ var uploadedParts;
2513
+ return UploadManagerBase_continue(UploadManagerBase_finallyRethrows(function () {
2514
+ return UploadManagerBase_await(_this.mapAsync(parts, preUploadInfo.maxConcurrentUploadParts, _async(function (part) {
2515
+ return _this.uploadPart(request, source, part, uploadInfo, makeOnProgressForPart(), addCancellationHandler, accountId);
2516
+ })), function (_this$mapAsync) {
2517
+ uploadedParts = _this$mapAsync;
2518
+ return UploadManagerBase_awaitIgnored(_this.postUpload(init));
2519
+ });
2520
+ }, function (_wasThrown, _result) {
2521
+ clearInterval(intervalHandle);
2522
+ return UploadManagerBase_rethrow(_wasThrown, _result);
2523
+ }), function () {
2524
+ var etag = uploadedParts.flatMap(function (x) {
2525
+ return x.status === "Completed" ? [x.etag] : [];
2526
+ })[0];
2527
+ return Object.assign(Object.assign({}, uploadInfo.file), {
2528
+ etag: etag // The 'etag' in the original 'uploadInfo.file' will be null, so we set it to the final etag value here.
2529
+ });
2276
2530
  });
2277
2531
  });
2278
2532
  });
@@ -2479,7 +2733,7 @@ var UploadManagerBase = /*#__PURE__*/function () {
2479
2733
  var result = [];
2480
2734
  var workQueue = UploadManagerBase_toConsumableArray(items);
2481
2735
  return UploadManagerBase_await(Promise.all(UploadManagerBase_toConsumableArray(Array(concurrency).keys()).map(_async(function () {
2482
- return _continueIgnored(_for(function () {
2736
+ return _continueIgnored(UploadManagerBase_for(function () {
2483
2737
  return workQueue.length > 0;
2484
2738
  }, void 0, function () {
2485
2739
  var work = workQueue.shift(); // IMPORTANT: use 'shift' instead of 'pop' to ensure 'items' are processed in order when 'concurrency = 1'.