@bytescale/sdk 3.22.0 → 3.24.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.
- package/dist/browser/cjs/main.js +52 -40
- package/dist/browser/esm/main.mjs +52 -40
- package/dist/node/cjs/main.js +52 -6
- package/dist/node/esm/main.mjs +52 -6
- package/dist/types/public/shared/UrlBuilderTypes.d.ts +4 -0
- package/dist/types/public/shared/generated/runtime.d.ts +5 -1
- package/dist/worker/cjs/main.js +52 -6
- package/dist/worker/esm/main.mjs +52 -6
- package/package.json +1 -1
- package/tests/utils/RandomStream.ts +16 -1
package/dist/browser/cjs/main.js
CHANGED
|
@@ -253,6 +253,40 @@ var AuthSessionState = /*#__PURE__*/function () {
|
|
|
253
253
|
}();
|
|
254
254
|
AuthSessionState.stateKey = "BytescaleSessionState";
|
|
255
255
|
AuthSessionState.mutexKey = "BytescaleSessionStateMutex";
|
|
256
|
+
;// CONCATENATED MODULE: ./src/private/ConsoleUtils.ts
|
|
257
|
+
function ConsoleUtils_typeof(obj) { "@babel/helpers - typeof"; return ConsoleUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ConsoleUtils_typeof(obj); }
|
|
258
|
+
function ConsoleUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
259
|
+
function ConsoleUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ConsoleUtils_toPropertyKey(descriptor.key), descriptor); } }
|
|
260
|
+
function ConsoleUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ConsoleUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ConsoleUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
261
|
+
function ConsoleUtils_toPropertyKey(arg) { var key = ConsoleUtils_toPrimitive(arg, "string"); return ConsoleUtils_typeof(key) === "symbol" ? key : String(key); }
|
|
262
|
+
function ConsoleUtils_toPrimitive(input, hint) { if (ConsoleUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (ConsoleUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
263
|
+
var ConsoleUtils = /*#__PURE__*/function () {
|
|
264
|
+
function ConsoleUtils() {
|
|
265
|
+
ConsoleUtils_classCallCheck(this, ConsoleUtils);
|
|
266
|
+
}
|
|
267
|
+
ConsoleUtils_createClass(ConsoleUtils, null, [{
|
|
268
|
+
key: "debug",
|
|
269
|
+
value: function debug(message) {
|
|
270
|
+
console.log(ConsoleUtils.prefix(message));
|
|
271
|
+
}
|
|
272
|
+
}, {
|
|
273
|
+
key: "warn",
|
|
274
|
+
value: function warn(message) {
|
|
275
|
+
console.warn(ConsoleUtils.prefix(message));
|
|
276
|
+
}
|
|
277
|
+
}, {
|
|
278
|
+
key: "error",
|
|
279
|
+
value: function error(message) {
|
|
280
|
+
console.error(ConsoleUtils.prefix(message));
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "prefix",
|
|
284
|
+
value: function prefix(message) {
|
|
285
|
+
return "[bytescale-sdk] ".concat(message);
|
|
286
|
+
}
|
|
287
|
+
}]);
|
|
288
|
+
return ConsoleUtils;
|
|
289
|
+
}();
|
|
256
290
|
;// CONCATENATED MODULE: ./src/public/shared/generated/runtime.ts
|
|
257
291
|
function runtime_typeof(obj) { "@babel/helpers - typeof"; return runtime_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, runtime_typeof(obj); }
|
|
258
292
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
@@ -303,6 +337,7 @@ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoPr
|
|
|
303
337
|
function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
|
|
304
338
|
function runtime_toPrimitive(input, hint) { if (runtime_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (runtime_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
305
339
|
|
|
340
|
+
|
|
306
341
|
var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
|
|
307
342
|
function BytescaleApiClientConfigUtils() {
|
|
308
343
|
runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
|
|
@@ -493,14 +528,24 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
493
528
|
if (_exit3) return _result;
|
|
494
529
|
return response.status >= 200 && response.status < 300 ? response : runtime_invoke(function () {
|
|
495
530
|
if (config.isBytescaleApi) {
|
|
496
|
-
var
|
|
531
|
+
var errorText = undefined;
|
|
532
|
+
var errorJson = undefined;
|
|
497
533
|
return _continue(_catch(function () {
|
|
498
|
-
return runtime_await(response.
|
|
499
|
-
|
|
534
|
+
return runtime_await(response.text(), function (_response$text) {
|
|
535
|
+
errorText = _response$text;
|
|
536
|
+
errorJson = JSON.parse(errorText);
|
|
500
537
|
});
|
|
501
538
|
}, runtime_empty), function () {
|
|
502
|
-
if (typeof ((_a =
|
|
503
|
-
throw new BytescaleApiError(
|
|
539
|
+
if (typeof ((_a = errorJson === null || errorJson === void 0 ? void 0 : errorJson.error) === null || _a === void 0 ? void 0 : _a.code) === "string") {
|
|
540
|
+
throw new BytescaleApiError(errorJson);
|
|
541
|
+
}
|
|
542
|
+
if (config.debug === true) {
|
|
543
|
+
ConsoleUtils.debug("Error response header:");
|
|
544
|
+
response.headers.forEach(function (headerValue, headerKey) {
|
|
545
|
+
return ConsoleUtils.debug("".concat(headerKey, ": ").concat(headerValue));
|
|
546
|
+
});
|
|
547
|
+
ConsoleUtils.debug("Error response body:");
|
|
548
|
+
ConsoleUtils.debug(errorText !== null && errorText !== void 0 ? errorText : "<empty>");
|
|
504
549
|
}
|
|
505
550
|
// HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies). On the browser,
|
|
506
551
|
// this error is unlikely to be triggered since these errors will masqurade as CORS errors (see above) but in Node.js
|
|
@@ -1604,7 +1649,8 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1604
1649
|
}, {
|
|
1605
1650
|
key: "getBaseUrl",
|
|
1606
1651
|
value: function getBaseUrl(params, prefix) {
|
|
1607
|
-
var
|
|
1652
|
+
var _a, _b;
|
|
1653
|
+
var cdnUrl = (_b = (_a = params.options) === null || _a === void 0 ? void 0 : _a.cdnUrl) !== null && _b !== void 0 ? _b : BytescaleApiClientConfigUtils.defaultCdnUrl;
|
|
1608
1654
|
return "".concat(cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
|
|
1609
1655
|
}
|
|
1610
1656
|
}, {
|
|
@@ -2360,40 +2406,6 @@ var UploadManager = /*#__PURE__*/function (_UploadManagerBrowser) {
|
|
|
2360
2406
|
}]);
|
|
2361
2407
|
return UploadManager;
|
|
2362
2408
|
}(UploadManagerBrowserWorkerBase);
|
|
2363
|
-
;// CONCATENATED MODULE: ./src/private/ConsoleUtils.ts
|
|
2364
|
-
function ConsoleUtils_typeof(obj) { "@babel/helpers - typeof"; return ConsoleUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ConsoleUtils_typeof(obj); }
|
|
2365
|
-
function ConsoleUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2366
|
-
function ConsoleUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ConsoleUtils_toPropertyKey(descriptor.key), descriptor); } }
|
|
2367
|
-
function ConsoleUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ConsoleUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ConsoleUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
2368
|
-
function ConsoleUtils_toPropertyKey(arg) { var key = ConsoleUtils_toPrimitive(arg, "string"); return ConsoleUtils_typeof(key) === "symbol" ? key : String(key); }
|
|
2369
|
-
function ConsoleUtils_toPrimitive(input, hint) { if (ConsoleUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (ConsoleUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
2370
|
-
var ConsoleUtils = /*#__PURE__*/function () {
|
|
2371
|
-
function ConsoleUtils() {
|
|
2372
|
-
ConsoleUtils_classCallCheck(this, ConsoleUtils);
|
|
2373
|
-
}
|
|
2374
|
-
ConsoleUtils_createClass(ConsoleUtils, null, [{
|
|
2375
|
-
key: "debug",
|
|
2376
|
-
value: function debug(message) {
|
|
2377
|
-
console.log(ConsoleUtils.prefix(message));
|
|
2378
|
-
}
|
|
2379
|
-
}, {
|
|
2380
|
-
key: "warn",
|
|
2381
|
-
value: function warn(message) {
|
|
2382
|
-
console.warn(ConsoleUtils.prefix(message));
|
|
2383
|
-
}
|
|
2384
|
-
}, {
|
|
2385
|
-
key: "error",
|
|
2386
|
-
value: function error(message) {
|
|
2387
|
-
console.error(ConsoleUtils.prefix(message));
|
|
2388
|
-
}
|
|
2389
|
-
}, {
|
|
2390
|
-
key: "prefix",
|
|
2391
|
-
value: function prefix(message) {
|
|
2392
|
-
return "[bytescale-sdk] ".concat(message);
|
|
2393
|
-
}
|
|
2394
|
-
}]);
|
|
2395
|
-
return ConsoleUtils;
|
|
2396
|
-
}();
|
|
2397
2409
|
;// CONCATENATED MODULE: ./src/private/ServiceWorkerUtils.ts
|
|
2398
2410
|
function ServiceWorkerUtils_typeof(obj) { "@babel/helpers - typeof"; return ServiceWorkerUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ServiceWorkerUtils_typeof(obj); }
|
|
2399
2411
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = ServiceWorkerUtils_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
@@ -238,6 +238,40 @@ var AuthSessionState = /*#__PURE__*/function () {
|
|
|
238
238
|
}();
|
|
239
239
|
AuthSessionState.stateKey = "BytescaleSessionState";
|
|
240
240
|
AuthSessionState.mutexKey = "BytescaleSessionStateMutex";
|
|
241
|
+
;// CONCATENATED MODULE: ./src/private/ConsoleUtils.ts
|
|
242
|
+
function ConsoleUtils_typeof(obj) { "@babel/helpers - typeof"; return ConsoleUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ConsoleUtils_typeof(obj); }
|
|
243
|
+
function ConsoleUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
244
|
+
function ConsoleUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ConsoleUtils_toPropertyKey(descriptor.key), descriptor); } }
|
|
245
|
+
function ConsoleUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ConsoleUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ConsoleUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
246
|
+
function ConsoleUtils_toPropertyKey(arg) { var key = ConsoleUtils_toPrimitive(arg, "string"); return ConsoleUtils_typeof(key) === "symbol" ? key : String(key); }
|
|
247
|
+
function ConsoleUtils_toPrimitive(input, hint) { if (ConsoleUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (ConsoleUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
248
|
+
var ConsoleUtils = /*#__PURE__*/function () {
|
|
249
|
+
function ConsoleUtils() {
|
|
250
|
+
ConsoleUtils_classCallCheck(this, ConsoleUtils);
|
|
251
|
+
}
|
|
252
|
+
ConsoleUtils_createClass(ConsoleUtils, null, [{
|
|
253
|
+
key: "debug",
|
|
254
|
+
value: function debug(message) {
|
|
255
|
+
console.log(ConsoleUtils.prefix(message));
|
|
256
|
+
}
|
|
257
|
+
}, {
|
|
258
|
+
key: "warn",
|
|
259
|
+
value: function warn(message) {
|
|
260
|
+
console.warn(ConsoleUtils.prefix(message));
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
key: "error",
|
|
264
|
+
value: function error(message) {
|
|
265
|
+
console.error(ConsoleUtils.prefix(message));
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
key: "prefix",
|
|
269
|
+
value: function prefix(message) {
|
|
270
|
+
return "[bytescale-sdk] ".concat(message);
|
|
271
|
+
}
|
|
272
|
+
}]);
|
|
273
|
+
return ConsoleUtils;
|
|
274
|
+
}();
|
|
241
275
|
;// CONCATENATED MODULE: ./src/public/shared/generated/runtime.ts
|
|
242
276
|
function runtime_typeof(obj) { "@babel/helpers - typeof"; return runtime_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, runtime_typeof(obj); }
|
|
243
277
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
@@ -288,6 +322,7 @@ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoPr
|
|
|
288
322
|
function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
|
|
289
323
|
function runtime_toPrimitive(input, hint) { if (runtime_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (runtime_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
290
324
|
|
|
325
|
+
|
|
291
326
|
var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
|
|
292
327
|
function BytescaleApiClientConfigUtils() {
|
|
293
328
|
runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
|
|
@@ -478,14 +513,24 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
478
513
|
if (_exit3) return _result;
|
|
479
514
|
return response.status >= 200 && response.status < 300 ? response : runtime_invoke(function () {
|
|
480
515
|
if (config.isBytescaleApi) {
|
|
481
|
-
var
|
|
516
|
+
var errorText = undefined;
|
|
517
|
+
var errorJson = undefined;
|
|
482
518
|
return _continue(_catch(function () {
|
|
483
|
-
return runtime_await(response.
|
|
484
|
-
|
|
519
|
+
return runtime_await(response.text(), function (_response$text) {
|
|
520
|
+
errorText = _response$text;
|
|
521
|
+
errorJson = JSON.parse(errorText);
|
|
485
522
|
});
|
|
486
523
|
}, runtime_empty), function () {
|
|
487
|
-
if (typeof ((_a =
|
|
488
|
-
throw new BytescaleApiError(
|
|
524
|
+
if (typeof ((_a = errorJson === null || errorJson === void 0 ? void 0 : errorJson.error) === null || _a === void 0 ? void 0 : _a.code) === "string") {
|
|
525
|
+
throw new BytescaleApiError(errorJson);
|
|
526
|
+
}
|
|
527
|
+
if (config.debug === true) {
|
|
528
|
+
ConsoleUtils.debug("Error response header:");
|
|
529
|
+
response.headers.forEach(function (headerValue, headerKey) {
|
|
530
|
+
return ConsoleUtils.debug("".concat(headerKey, ": ").concat(headerValue));
|
|
531
|
+
});
|
|
532
|
+
ConsoleUtils.debug("Error response body:");
|
|
533
|
+
ConsoleUtils.debug(errorText !== null && errorText !== void 0 ? errorText : "<empty>");
|
|
489
534
|
}
|
|
490
535
|
// HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies). On the browser,
|
|
491
536
|
// this error is unlikely to be triggered since these errors will masqurade as CORS errors (see above) but in Node.js
|
|
@@ -1589,7 +1634,8 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1589
1634
|
}, {
|
|
1590
1635
|
key: "getBaseUrl",
|
|
1591
1636
|
value: function getBaseUrl(params, prefix) {
|
|
1592
|
-
var
|
|
1637
|
+
var _a, _b;
|
|
1638
|
+
var cdnUrl = (_b = (_a = params.options) === null || _a === void 0 ? void 0 : _a.cdnUrl) !== null && _b !== void 0 ? _b : BytescaleApiClientConfigUtils.defaultCdnUrl;
|
|
1593
1639
|
return "".concat(cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
|
|
1594
1640
|
}
|
|
1595
1641
|
}, {
|
|
@@ -2345,40 +2391,6 @@ var UploadManager = /*#__PURE__*/function (_UploadManagerBrowser) {
|
|
|
2345
2391
|
}]);
|
|
2346
2392
|
return UploadManager;
|
|
2347
2393
|
}(UploadManagerBrowserWorkerBase);
|
|
2348
|
-
;// CONCATENATED MODULE: ./src/private/ConsoleUtils.ts
|
|
2349
|
-
function ConsoleUtils_typeof(obj) { "@babel/helpers - typeof"; return ConsoleUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ConsoleUtils_typeof(obj); }
|
|
2350
|
-
function ConsoleUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2351
|
-
function ConsoleUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ConsoleUtils_toPropertyKey(descriptor.key), descriptor); } }
|
|
2352
|
-
function ConsoleUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ConsoleUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ConsoleUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
2353
|
-
function ConsoleUtils_toPropertyKey(arg) { var key = ConsoleUtils_toPrimitive(arg, "string"); return ConsoleUtils_typeof(key) === "symbol" ? key : String(key); }
|
|
2354
|
-
function ConsoleUtils_toPrimitive(input, hint) { if (ConsoleUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (ConsoleUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
2355
|
-
var ConsoleUtils = /*#__PURE__*/function () {
|
|
2356
|
-
function ConsoleUtils() {
|
|
2357
|
-
ConsoleUtils_classCallCheck(this, ConsoleUtils);
|
|
2358
|
-
}
|
|
2359
|
-
ConsoleUtils_createClass(ConsoleUtils, null, [{
|
|
2360
|
-
key: "debug",
|
|
2361
|
-
value: function debug(message) {
|
|
2362
|
-
console.log(ConsoleUtils.prefix(message));
|
|
2363
|
-
}
|
|
2364
|
-
}, {
|
|
2365
|
-
key: "warn",
|
|
2366
|
-
value: function warn(message) {
|
|
2367
|
-
console.warn(ConsoleUtils.prefix(message));
|
|
2368
|
-
}
|
|
2369
|
-
}, {
|
|
2370
|
-
key: "error",
|
|
2371
|
-
value: function error(message) {
|
|
2372
|
-
console.error(ConsoleUtils.prefix(message));
|
|
2373
|
-
}
|
|
2374
|
-
}, {
|
|
2375
|
-
key: "prefix",
|
|
2376
|
-
value: function prefix(message) {
|
|
2377
|
-
return "[bytescale-sdk] ".concat(message);
|
|
2378
|
-
}
|
|
2379
|
-
}]);
|
|
2380
|
-
return ConsoleUtils;
|
|
2381
|
-
}();
|
|
2382
2394
|
;// CONCATENATED MODULE: ./src/private/ServiceWorkerUtils.ts
|
|
2383
2395
|
function ServiceWorkerUtils_typeof(obj) { "@babel/helpers - typeof"; return ServiceWorkerUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ServiceWorkerUtils_typeof(obj); }
|
|
2384
2396
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = ServiceWorkerUtils_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
package/dist/node/cjs/main.js
CHANGED
|
@@ -253,6 +253,40 @@ var AuthSessionState = /*#__PURE__*/function () {
|
|
|
253
253
|
}();
|
|
254
254
|
AuthSessionState.stateKey = "BytescaleSessionState";
|
|
255
255
|
AuthSessionState.mutexKey = "BytescaleSessionStateMutex";
|
|
256
|
+
;// CONCATENATED MODULE: ./src/private/ConsoleUtils.ts
|
|
257
|
+
function ConsoleUtils_typeof(obj) { "@babel/helpers - typeof"; return ConsoleUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ConsoleUtils_typeof(obj); }
|
|
258
|
+
function ConsoleUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
259
|
+
function ConsoleUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ConsoleUtils_toPropertyKey(descriptor.key), descriptor); } }
|
|
260
|
+
function ConsoleUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ConsoleUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ConsoleUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
261
|
+
function ConsoleUtils_toPropertyKey(arg) { var key = ConsoleUtils_toPrimitive(arg, "string"); return ConsoleUtils_typeof(key) === "symbol" ? key : String(key); }
|
|
262
|
+
function ConsoleUtils_toPrimitive(input, hint) { if (ConsoleUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (ConsoleUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
263
|
+
var ConsoleUtils = /*#__PURE__*/function () {
|
|
264
|
+
function ConsoleUtils() {
|
|
265
|
+
ConsoleUtils_classCallCheck(this, ConsoleUtils);
|
|
266
|
+
}
|
|
267
|
+
ConsoleUtils_createClass(ConsoleUtils, null, [{
|
|
268
|
+
key: "debug",
|
|
269
|
+
value: function debug(message) {
|
|
270
|
+
console.log(ConsoleUtils.prefix(message));
|
|
271
|
+
}
|
|
272
|
+
}, {
|
|
273
|
+
key: "warn",
|
|
274
|
+
value: function warn(message) {
|
|
275
|
+
console.warn(ConsoleUtils.prefix(message));
|
|
276
|
+
}
|
|
277
|
+
}, {
|
|
278
|
+
key: "error",
|
|
279
|
+
value: function error(message) {
|
|
280
|
+
console.error(ConsoleUtils.prefix(message));
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "prefix",
|
|
284
|
+
value: function prefix(message) {
|
|
285
|
+
return "[bytescale-sdk] ".concat(message);
|
|
286
|
+
}
|
|
287
|
+
}]);
|
|
288
|
+
return ConsoleUtils;
|
|
289
|
+
}();
|
|
256
290
|
;// CONCATENATED MODULE: ./src/public/shared/generated/runtime.ts
|
|
257
291
|
function runtime_typeof(obj) { "@babel/helpers - typeof"; return runtime_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, runtime_typeof(obj); }
|
|
258
292
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
@@ -303,6 +337,7 @@ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoPr
|
|
|
303
337
|
function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
|
|
304
338
|
function runtime_toPrimitive(input, hint) { if (runtime_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (runtime_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
305
339
|
|
|
340
|
+
|
|
306
341
|
var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
|
|
307
342
|
function BytescaleApiClientConfigUtils() {
|
|
308
343
|
runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
|
|
@@ -493,14 +528,24 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
493
528
|
if (_exit3) return _result;
|
|
494
529
|
return response.status >= 200 && response.status < 300 ? response : runtime_invoke(function () {
|
|
495
530
|
if (config.isBytescaleApi) {
|
|
496
|
-
var
|
|
531
|
+
var errorText = undefined;
|
|
532
|
+
var errorJson = undefined;
|
|
497
533
|
return _continue(_catch(function () {
|
|
498
|
-
return runtime_await(response.
|
|
499
|
-
|
|
534
|
+
return runtime_await(response.text(), function (_response$text) {
|
|
535
|
+
errorText = _response$text;
|
|
536
|
+
errorJson = JSON.parse(errorText);
|
|
500
537
|
});
|
|
501
538
|
}, runtime_empty), function () {
|
|
502
|
-
if (typeof ((_a =
|
|
503
|
-
throw new BytescaleApiError(
|
|
539
|
+
if (typeof ((_a = errorJson === null || errorJson === void 0 ? void 0 : errorJson.error) === null || _a === void 0 ? void 0 : _a.code) === "string") {
|
|
540
|
+
throw new BytescaleApiError(errorJson);
|
|
541
|
+
}
|
|
542
|
+
if (config.debug === true) {
|
|
543
|
+
ConsoleUtils.debug("Error response header:");
|
|
544
|
+
response.headers.forEach(function (headerValue, headerKey) {
|
|
545
|
+
return ConsoleUtils.debug("".concat(headerKey, ": ").concat(headerValue));
|
|
546
|
+
});
|
|
547
|
+
ConsoleUtils.debug("Error response body:");
|
|
548
|
+
ConsoleUtils.debug(errorText !== null && errorText !== void 0 ? errorText : "<empty>");
|
|
504
549
|
}
|
|
505
550
|
// HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies). On the browser,
|
|
506
551
|
// this error is unlikely to be triggered since these errors will masqurade as CORS errors (see above) but in Node.js
|
|
@@ -1604,7 +1649,8 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1604
1649
|
}, {
|
|
1605
1650
|
key: "getBaseUrl",
|
|
1606
1651
|
value: function getBaseUrl(params, prefix) {
|
|
1607
|
-
var
|
|
1652
|
+
var _a, _b;
|
|
1653
|
+
var cdnUrl = (_b = (_a = params.options) === null || _a === void 0 ? void 0 : _a.cdnUrl) !== null && _b !== void 0 ? _b : BytescaleApiClientConfigUtils.defaultCdnUrl;
|
|
1608
1654
|
return "".concat(cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
|
|
1609
1655
|
}
|
|
1610
1656
|
}, {
|
package/dist/node/esm/main.mjs
CHANGED
|
@@ -240,6 +240,40 @@ var AuthSessionState = /*#__PURE__*/function () {
|
|
|
240
240
|
}();
|
|
241
241
|
AuthSessionState.stateKey = "BytescaleSessionState";
|
|
242
242
|
AuthSessionState.mutexKey = "BytescaleSessionStateMutex";
|
|
243
|
+
;// CONCATENATED MODULE: ./src/private/ConsoleUtils.ts
|
|
244
|
+
function ConsoleUtils_typeof(obj) { "@babel/helpers - typeof"; return ConsoleUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ConsoleUtils_typeof(obj); }
|
|
245
|
+
function ConsoleUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
246
|
+
function ConsoleUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ConsoleUtils_toPropertyKey(descriptor.key), descriptor); } }
|
|
247
|
+
function ConsoleUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ConsoleUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ConsoleUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
248
|
+
function ConsoleUtils_toPropertyKey(arg) { var key = ConsoleUtils_toPrimitive(arg, "string"); return ConsoleUtils_typeof(key) === "symbol" ? key : String(key); }
|
|
249
|
+
function ConsoleUtils_toPrimitive(input, hint) { if (ConsoleUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (ConsoleUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
250
|
+
var ConsoleUtils = /*#__PURE__*/function () {
|
|
251
|
+
function ConsoleUtils() {
|
|
252
|
+
ConsoleUtils_classCallCheck(this, ConsoleUtils);
|
|
253
|
+
}
|
|
254
|
+
ConsoleUtils_createClass(ConsoleUtils, null, [{
|
|
255
|
+
key: "debug",
|
|
256
|
+
value: function debug(message) {
|
|
257
|
+
console.log(ConsoleUtils.prefix(message));
|
|
258
|
+
}
|
|
259
|
+
}, {
|
|
260
|
+
key: "warn",
|
|
261
|
+
value: function warn(message) {
|
|
262
|
+
console.warn(ConsoleUtils.prefix(message));
|
|
263
|
+
}
|
|
264
|
+
}, {
|
|
265
|
+
key: "error",
|
|
266
|
+
value: function error(message) {
|
|
267
|
+
console.error(ConsoleUtils.prefix(message));
|
|
268
|
+
}
|
|
269
|
+
}, {
|
|
270
|
+
key: "prefix",
|
|
271
|
+
value: function prefix(message) {
|
|
272
|
+
return "[bytescale-sdk] ".concat(message);
|
|
273
|
+
}
|
|
274
|
+
}]);
|
|
275
|
+
return ConsoleUtils;
|
|
276
|
+
}();
|
|
243
277
|
;// CONCATENATED MODULE: ./src/public/shared/generated/runtime.ts
|
|
244
278
|
function runtime_typeof(obj) { "@babel/helpers - typeof"; return runtime_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, runtime_typeof(obj); }
|
|
245
279
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
@@ -290,6 +324,7 @@ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoPr
|
|
|
290
324
|
function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
|
|
291
325
|
function runtime_toPrimitive(input, hint) { if (runtime_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (runtime_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
292
326
|
|
|
327
|
+
|
|
293
328
|
var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
|
|
294
329
|
function BytescaleApiClientConfigUtils() {
|
|
295
330
|
runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
|
|
@@ -480,14 +515,24 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
480
515
|
if (_exit3) return _result;
|
|
481
516
|
return response.status >= 200 && response.status < 300 ? response : runtime_invoke(function () {
|
|
482
517
|
if (config.isBytescaleApi) {
|
|
483
|
-
var
|
|
518
|
+
var errorText = undefined;
|
|
519
|
+
var errorJson = undefined;
|
|
484
520
|
return _continue(_catch(function () {
|
|
485
|
-
return runtime_await(response.
|
|
486
|
-
|
|
521
|
+
return runtime_await(response.text(), function (_response$text) {
|
|
522
|
+
errorText = _response$text;
|
|
523
|
+
errorJson = JSON.parse(errorText);
|
|
487
524
|
});
|
|
488
525
|
}, runtime_empty), function () {
|
|
489
|
-
if (typeof ((_a =
|
|
490
|
-
throw new BytescaleApiError(
|
|
526
|
+
if (typeof ((_a = errorJson === null || errorJson === void 0 ? void 0 : errorJson.error) === null || _a === void 0 ? void 0 : _a.code) === "string") {
|
|
527
|
+
throw new BytescaleApiError(errorJson);
|
|
528
|
+
}
|
|
529
|
+
if (config.debug === true) {
|
|
530
|
+
ConsoleUtils.debug("Error response header:");
|
|
531
|
+
response.headers.forEach(function (headerValue, headerKey) {
|
|
532
|
+
return ConsoleUtils.debug("".concat(headerKey, ": ").concat(headerValue));
|
|
533
|
+
});
|
|
534
|
+
ConsoleUtils.debug("Error response body:");
|
|
535
|
+
ConsoleUtils.debug(errorText !== null && errorText !== void 0 ? errorText : "<empty>");
|
|
491
536
|
}
|
|
492
537
|
// HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies). On the browser,
|
|
493
538
|
// this error is unlikely to be triggered since these errors will masqurade as CORS errors (see above) but in Node.js
|
|
@@ -1591,7 +1636,8 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1591
1636
|
}, {
|
|
1592
1637
|
key: "getBaseUrl",
|
|
1593
1638
|
value: function getBaseUrl(params, prefix) {
|
|
1594
|
-
var
|
|
1639
|
+
var _a, _b;
|
|
1640
|
+
var cdnUrl = (_b = (_a = params.options) === null || _a === void 0 ? void 0 : _a.cdnUrl) !== null && _b !== void 0 ? _b : BytescaleApiClientConfigUtils.defaultCdnUrl;
|
|
1595
1641
|
return "".concat(cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
|
|
1596
1642
|
}
|
|
1597
1643
|
}, {
|
|
@@ -42,6 +42,10 @@ export interface UrlBuilderOptionsBase {
|
|
|
42
42
|
* Default: Please refer to your account's default cache settings in the Bytescale Dashboard.
|
|
43
43
|
*/
|
|
44
44
|
cacheTtl?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The base URL of the Bytescale CDN. (Excludes trailing "/".)
|
|
47
|
+
*/
|
|
48
|
+
cdnUrl?: string;
|
|
45
49
|
/**
|
|
46
50
|
* Forces the browser to display a download prompt for the file, instead of displaying the file in the browser.
|
|
47
51
|
*
|
|
@@ -31,6 +31,10 @@ export interface BytescaleApiClientConfig {
|
|
|
31
31
|
* The base URL of the Bytescale CDN. (Excludes trailing "/".)
|
|
32
32
|
*/
|
|
33
33
|
cdnUrl?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Enables additional debug information.
|
|
36
|
+
*/
|
|
37
|
+
debug?: boolean;
|
|
34
38
|
/**
|
|
35
39
|
* Headers to include in all API requests.
|
|
36
40
|
*
|
|
@@ -59,7 +63,7 @@ export declare class BaseAPI {
|
|
|
59
63
|
/**
|
|
60
64
|
* Returns a successful response (2**) else throws an error.
|
|
61
65
|
*/
|
|
62
|
-
static fetch(url: string, init: RequestInit, config: Pick<BytescaleApiClientConfig, "fetchApi"> & {
|
|
66
|
+
static fetch(url: string, init: RequestInit, config: Pick<BytescaleApiClientConfig, "fetchApi" | "debug"> & {
|
|
63
67
|
isBytescaleApi: boolean;
|
|
64
68
|
}): Promise<Response>;
|
|
65
69
|
protected request(context: RequestOpts, initOverrides: RequestInit | InitOverrideFunction | undefined, baseUrlOverride: string | undefined): Promise<Response>;
|
package/dist/worker/cjs/main.js
CHANGED
|
@@ -253,6 +253,40 @@ var AuthSessionState = /*#__PURE__*/function () {
|
|
|
253
253
|
}();
|
|
254
254
|
AuthSessionState.stateKey = "BytescaleSessionState";
|
|
255
255
|
AuthSessionState.mutexKey = "BytescaleSessionStateMutex";
|
|
256
|
+
;// CONCATENATED MODULE: ./src/private/ConsoleUtils.ts
|
|
257
|
+
function ConsoleUtils_typeof(obj) { "@babel/helpers - typeof"; return ConsoleUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ConsoleUtils_typeof(obj); }
|
|
258
|
+
function ConsoleUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
259
|
+
function ConsoleUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ConsoleUtils_toPropertyKey(descriptor.key), descriptor); } }
|
|
260
|
+
function ConsoleUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ConsoleUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ConsoleUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
261
|
+
function ConsoleUtils_toPropertyKey(arg) { var key = ConsoleUtils_toPrimitive(arg, "string"); return ConsoleUtils_typeof(key) === "symbol" ? key : String(key); }
|
|
262
|
+
function ConsoleUtils_toPrimitive(input, hint) { if (ConsoleUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (ConsoleUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
263
|
+
var ConsoleUtils = /*#__PURE__*/function () {
|
|
264
|
+
function ConsoleUtils() {
|
|
265
|
+
ConsoleUtils_classCallCheck(this, ConsoleUtils);
|
|
266
|
+
}
|
|
267
|
+
ConsoleUtils_createClass(ConsoleUtils, null, [{
|
|
268
|
+
key: "debug",
|
|
269
|
+
value: function debug(message) {
|
|
270
|
+
console.log(ConsoleUtils.prefix(message));
|
|
271
|
+
}
|
|
272
|
+
}, {
|
|
273
|
+
key: "warn",
|
|
274
|
+
value: function warn(message) {
|
|
275
|
+
console.warn(ConsoleUtils.prefix(message));
|
|
276
|
+
}
|
|
277
|
+
}, {
|
|
278
|
+
key: "error",
|
|
279
|
+
value: function error(message) {
|
|
280
|
+
console.error(ConsoleUtils.prefix(message));
|
|
281
|
+
}
|
|
282
|
+
}, {
|
|
283
|
+
key: "prefix",
|
|
284
|
+
value: function prefix(message) {
|
|
285
|
+
return "[bytescale-sdk] ".concat(message);
|
|
286
|
+
}
|
|
287
|
+
}]);
|
|
288
|
+
return ConsoleUtils;
|
|
289
|
+
}();
|
|
256
290
|
;// CONCATENATED MODULE: ./src/public/shared/generated/runtime.ts
|
|
257
291
|
function runtime_typeof(obj) { "@babel/helpers - typeof"; return runtime_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, runtime_typeof(obj); }
|
|
258
292
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
@@ -303,6 +337,7 @@ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoPr
|
|
|
303
337
|
function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
|
|
304
338
|
function runtime_toPrimitive(input, hint) { if (runtime_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (runtime_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
305
339
|
|
|
340
|
+
|
|
306
341
|
var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
|
|
307
342
|
function BytescaleApiClientConfigUtils() {
|
|
308
343
|
runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
|
|
@@ -493,14 +528,24 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
493
528
|
if (_exit3) return _result;
|
|
494
529
|
return response.status >= 200 && response.status < 300 ? response : runtime_invoke(function () {
|
|
495
530
|
if (config.isBytescaleApi) {
|
|
496
|
-
var
|
|
531
|
+
var errorText = undefined;
|
|
532
|
+
var errorJson = undefined;
|
|
497
533
|
return _continue(_catch(function () {
|
|
498
|
-
return runtime_await(response.
|
|
499
|
-
|
|
534
|
+
return runtime_await(response.text(), function (_response$text) {
|
|
535
|
+
errorText = _response$text;
|
|
536
|
+
errorJson = JSON.parse(errorText);
|
|
500
537
|
});
|
|
501
538
|
}, runtime_empty), function () {
|
|
502
|
-
if (typeof ((_a =
|
|
503
|
-
throw new BytescaleApiError(
|
|
539
|
+
if (typeof ((_a = errorJson === null || errorJson === void 0 ? void 0 : errorJson.error) === null || _a === void 0 ? void 0 : _a.code) === "string") {
|
|
540
|
+
throw new BytescaleApiError(errorJson);
|
|
541
|
+
}
|
|
542
|
+
if (config.debug === true) {
|
|
543
|
+
ConsoleUtils.debug("Error response header:");
|
|
544
|
+
response.headers.forEach(function (headerValue, headerKey) {
|
|
545
|
+
return ConsoleUtils.debug("".concat(headerKey, ": ").concat(headerValue));
|
|
546
|
+
});
|
|
547
|
+
ConsoleUtils.debug("Error response body:");
|
|
548
|
+
ConsoleUtils.debug(errorText !== null && errorText !== void 0 ? errorText : "<empty>");
|
|
504
549
|
}
|
|
505
550
|
// HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies). On the browser,
|
|
506
551
|
// this error is unlikely to be triggered since these errors will masqurade as CORS errors (see above) but in Node.js
|
|
@@ -1604,7 +1649,8 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1604
1649
|
}, {
|
|
1605
1650
|
key: "getBaseUrl",
|
|
1606
1651
|
value: function getBaseUrl(params, prefix) {
|
|
1607
|
-
var
|
|
1652
|
+
var _a, _b;
|
|
1653
|
+
var cdnUrl = (_b = (_a = params.options) === null || _a === void 0 ? void 0 : _a.cdnUrl) !== null && _b !== void 0 ? _b : BytescaleApiClientConfigUtils.defaultCdnUrl;
|
|
1608
1654
|
return "".concat(cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
|
|
1609
1655
|
}
|
|
1610
1656
|
}, {
|
package/dist/worker/esm/main.mjs
CHANGED
|
@@ -238,6 +238,40 @@ var AuthSessionState = /*#__PURE__*/function () {
|
|
|
238
238
|
}();
|
|
239
239
|
AuthSessionState.stateKey = "BytescaleSessionState";
|
|
240
240
|
AuthSessionState.mutexKey = "BytescaleSessionStateMutex";
|
|
241
|
+
;// CONCATENATED MODULE: ./src/private/ConsoleUtils.ts
|
|
242
|
+
function ConsoleUtils_typeof(obj) { "@babel/helpers - typeof"; return ConsoleUtils_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, ConsoleUtils_typeof(obj); }
|
|
243
|
+
function ConsoleUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
244
|
+
function ConsoleUtils_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, ConsoleUtils_toPropertyKey(descriptor.key), descriptor); } }
|
|
245
|
+
function ConsoleUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) ConsoleUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) ConsoleUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
246
|
+
function ConsoleUtils_toPropertyKey(arg) { var key = ConsoleUtils_toPrimitive(arg, "string"); return ConsoleUtils_typeof(key) === "symbol" ? key : String(key); }
|
|
247
|
+
function ConsoleUtils_toPrimitive(input, hint) { if (ConsoleUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (ConsoleUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
248
|
+
var ConsoleUtils = /*#__PURE__*/function () {
|
|
249
|
+
function ConsoleUtils() {
|
|
250
|
+
ConsoleUtils_classCallCheck(this, ConsoleUtils);
|
|
251
|
+
}
|
|
252
|
+
ConsoleUtils_createClass(ConsoleUtils, null, [{
|
|
253
|
+
key: "debug",
|
|
254
|
+
value: function debug(message) {
|
|
255
|
+
console.log(ConsoleUtils.prefix(message));
|
|
256
|
+
}
|
|
257
|
+
}, {
|
|
258
|
+
key: "warn",
|
|
259
|
+
value: function warn(message) {
|
|
260
|
+
console.warn(ConsoleUtils.prefix(message));
|
|
261
|
+
}
|
|
262
|
+
}, {
|
|
263
|
+
key: "error",
|
|
264
|
+
value: function error(message) {
|
|
265
|
+
console.error(ConsoleUtils.prefix(message));
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
key: "prefix",
|
|
269
|
+
value: function prefix(message) {
|
|
270
|
+
return "[bytescale-sdk] ".concat(message);
|
|
271
|
+
}
|
|
272
|
+
}]);
|
|
273
|
+
return ConsoleUtils;
|
|
274
|
+
}();
|
|
241
275
|
;// CONCATENATED MODULE: ./src/public/shared/generated/runtime.ts
|
|
242
276
|
function runtime_typeof(obj) { "@babel/helpers - typeof"; return runtime_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, runtime_typeof(obj); }
|
|
243
277
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
@@ -288,6 +322,7 @@ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoPr
|
|
|
288
322
|
function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
|
|
289
323
|
function runtime_toPrimitive(input, hint) { if (runtime_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (runtime_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
290
324
|
|
|
325
|
+
|
|
291
326
|
var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
|
|
292
327
|
function BytescaleApiClientConfigUtils() {
|
|
293
328
|
runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
|
|
@@ -478,14 +513,24 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
478
513
|
if (_exit3) return _result;
|
|
479
514
|
return response.status >= 200 && response.status < 300 ? response : runtime_invoke(function () {
|
|
480
515
|
if (config.isBytescaleApi) {
|
|
481
|
-
var
|
|
516
|
+
var errorText = undefined;
|
|
517
|
+
var errorJson = undefined;
|
|
482
518
|
return _continue(_catch(function () {
|
|
483
|
-
return runtime_await(response.
|
|
484
|
-
|
|
519
|
+
return runtime_await(response.text(), function (_response$text) {
|
|
520
|
+
errorText = _response$text;
|
|
521
|
+
errorJson = JSON.parse(errorText);
|
|
485
522
|
});
|
|
486
523
|
}, runtime_empty), function () {
|
|
487
|
-
if (typeof ((_a =
|
|
488
|
-
throw new BytescaleApiError(
|
|
524
|
+
if (typeof ((_a = errorJson === null || errorJson === void 0 ? void 0 : errorJson.error) === null || _a === void 0 ? void 0 : _a.code) === "string") {
|
|
525
|
+
throw new BytescaleApiError(errorJson);
|
|
526
|
+
}
|
|
527
|
+
if (config.debug === true) {
|
|
528
|
+
ConsoleUtils.debug("Error response header:");
|
|
529
|
+
response.headers.forEach(function (headerValue, headerKey) {
|
|
530
|
+
return ConsoleUtils.debug("".concat(headerKey, ": ").concat(headerValue));
|
|
531
|
+
});
|
|
532
|
+
ConsoleUtils.debug("Error response body:");
|
|
533
|
+
ConsoleUtils.debug(errorText !== null && errorText !== void 0 ? errorText : "<empty>");
|
|
489
534
|
}
|
|
490
535
|
// HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies). On the browser,
|
|
491
536
|
// this error is unlikely to be triggered since these errors will masqurade as CORS errors (see above) but in Node.js
|
|
@@ -1589,7 +1634,8 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1589
1634
|
}, {
|
|
1590
1635
|
key: "getBaseUrl",
|
|
1591
1636
|
value: function getBaseUrl(params, prefix) {
|
|
1592
|
-
var
|
|
1637
|
+
var _a, _b;
|
|
1638
|
+
var cdnUrl = (_b = (_a = params.options) === null || _a === void 0 ? void 0 : _a.cdnUrl) !== null && _b !== void 0 ? _b : BytescaleApiClientConfigUtils.defaultCdnUrl;
|
|
1593
1639
|
return "".concat(cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
|
|
1594
1640
|
}
|
|
1595
1641
|
}, {
|
package/package.json
CHANGED
|
@@ -15,10 +15,21 @@ import * as Path from "path";
|
|
|
15
15
|
function createRandomStream(sizeInBytes: number): NodeJS.ReadableStream {
|
|
16
16
|
const dictionary = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split("");
|
|
17
17
|
|
|
18
|
+
// Ensure the chunk size is small enough to cause enough entropy (as we pick a new character for reach chunk).
|
|
19
|
+
const minRandomBlocks = 10;
|
|
20
|
+
const maxChunkSize = Math.min(64 * 1024, Math.ceil(sizeInBytes / minRandomBlocks));
|
|
21
|
+
|
|
18
22
|
let producedSize = 0;
|
|
19
23
|
let iteration = 0;
|
|
20
24
|
return new Readable({
|
|
21
|
-
read(
|
|
25
|
+
read(requestedReadSize) {
|
|
26
|
+
const maxRequestedReadSize = Math.min(requestedReadSize, maxChunkSize);
|
|
27
|
+
|
|
28
|
+
// This ensures streams of the same size are unique, else they would have the same contents, assuming chunk size is the same.
|
|
29
|
+
// We use 0.8-1 to prevent really small chunks, which may create inefficiencies.
|
|
30
|
+
const randomness = randomBetween(0.8, 1);
|
|
31
|
+
|
|
32
|
+
let readSize = Math.ceil(maxRequestedReadSize * randomness);
|
|
22
33
|
let shouldEnd = false;
|
|
23
34
|
|
|
24
35
|
if (producedSize + readSize >= sizeInBytes) {
|
|
@@ -48,6 +59,10 @@ function createRandomStream(sizeInBytes: number): NodeJS.ReadableStream {
|
|
|
48
59
|
});
|
|
49
60
|
}
|
|
50
61
|
|
|
62
|
+
function randomBetween(min: number, max: number): number {
|
|
63
|
+
return Math.random() * (max - min) + min;
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
async function writeToDisk(reader: NodeJS.ReadableStream, path: string): Promise<void> {
|
|
52
67
|
await new Promise((resolve, reject) => {
|
|
53
68
|
const writer = fs.createWriteStream(path);
|