@bytescale/sdk 3.0.0-alpha.9 → 3.2.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.
Files changed (31) hide show
  1. package/README.md +388 -48
  2. package/dist/browser/cjs/main.js +704 -568
  3. package/dist/browser/esm/main.mjs +2803 -0
  4. package/dist/node/cjs/main.js +622 -240
  5. package/dist/node/esm/main.mjs +622 -240
  6. package/dist/types/index.d.ts +1 -1
  7. package/dist/types/private/AuthSessionState.d.ts +25 -8
  8. package/dist/types/private/EnvChecker.d.ts +1 -1
  9. package/dist/types/private/Mutex.d.ts +1 -1
  10. package/dist/types/private/StreamUtils.d.ts +1 -0
  11. package/dist/types/private/UploadManagerBase.d.ts +6 -1
  12. package/dist/types/private/UploadManagerBrowserWorkerBase.d.ts +19 -0
  13. package/dist/types/private/UploadManagerFetchUtils.d.ts +8 -0
  14. package/dist/types/private/model/AuthManagerInterface.d.ts +22 -5
  15. package/dist/types/private/model/AuthSession.d.ts +2 -2
  16. package/dist/types/private/model/OnPartProgress.d.ts +1 -1
  17. package/dist/types/private/model/UploadSourceProcessed.d.ts +6 -1
  18. package/dist/types/public/browser/AuthManagerBrowser.d.ts +10 -6
  19. package/dist/types/public/browser/UploadManagerBrowser.d.ts +3 -12
  20. package/dist/types/public/node/AuthManagerNode.d.ts +8 -3
  21. package/dist/types/public/shared/CommonTypes.d.ts +0 -1
  22. package/dist/types/public/shared/UrlBuilder.d.ts +10 -12
  23. package/dist/types/public/shared/UrlBuilderTypes.d.ts +0 -6
  24. package/dist/types/public/shared/generated/runtime.d.ts +7 -5
  25. package/dist/types/public/worker/UploadManagerWorker.d.ts +8 -0
  26. package/dist/types/public/worker/index.d.ts +2 -0
  27. package/dist/worker/cjs/main.js +2578 -0
  28. package/dist/worker/esm/main.mjs +2578 -0
  29. package/package.json +11 -4
  30. package/tests/UploadManager.test.ts +0 -7
  31. package/tests/UrlBuilder.test.ts +33 -27
@@ -0,0 +1,2578 @@
1
+ /******/ (function() { // webpackBootstrap
2
+ /******/ "use strict";
3
+ /******/ // The require scope
4
+ /******/ var __lib_require__ = {};
5
+ /******/
6
+ /************************************************************************/
7
+ /******/ /* webpack/runtime/define property getters */
8
+ /******/ !function() {
9
+ /******/ // define getter functions for harmony exports
10
+ /******/ __lib_require__.d = function(exports, definition) {
11
+ /******/ for(var key in definition) {
12
+ /******/ if(__lib_require__.o(definition, key) && !__lib_require__.o(exports, key)) {
13
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
+ /******/ }
15
+ /******/ }
16
+ /******/ };
17
+ /******/ }();
18
+ /******/
19
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
+ /******/ !function() {
21
+ /******/ __lib_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
22
+ /******/ }();
23
+ /******/
24
+ /******/ /* webpack/runtime/make namespace object */
25
+ /******/ !function() {
26
+ /******/ // define __esModule on exports
27
+ /******/ __lib_require__.r = function(exports) {
28
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30
+ /******/ }
31
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
32
+ /******/ };
33
+ /******/ }();
34
+ /******/
35
+ /************************************************************************/
36
+ var __lib_exports__ = {};
37
+ // ESM COMPAT FLAG
38
+ __lib_require__.r(__lib_exports__);
39
+
40
+ // EXPORTS
41
+ __lib_require__.d(__lib_exports__, {
42
+ "AuthManager": function() { return /* reexport */ AuthManager; },
43
+ "BaseAPI": function() { return /* reexport */ BaseAPI; },
44
+ "BinaryResult": function() { return /* reexport */ BinaryResult; },
45
+ "BytescaleApiClientConfigUtils": function() { return /* reexport */ BytescaleApiClientConfigUtils; },
46
+ "BytescaleApiError": function() { return /* reexport */ BytescaleApiError; },
47
+ "CancelledError": function() { return /* reexport */ CancelledError; },
48
+ "CommonTypesNoOp": function() { return /* reexport */ CommonTypesNoOp; },
49
+ "FileApi": function() { return /* reexport */ FileApi; },
50
+ "FolderApi": function() { return /* reexport */ FolderApi; },
51
+ "JSONApiResponse": function() { return /* reexport */ JSONApiResponse; },
52
+ "JobApi": function() { return /* reexport */ JobApi; },
53
+ "UploadApi": function() { return /* reexport */ UploadApi; },
54
+ "UploadManager": function() { return /* reexport */ UploadManager; },
55
+ "UrlBuilder": function() { return /* reexport */ UrlBuilder; },
56
+ "UrlBuilderTypesNoOp": function() { return /* reexport */ UrlBuilderTypesNoOp; },
57
+ "VoidApiResponse": function() { return /* reexport */ VoidApiResponse; },
58
+ "querystring": function() { return /* reexport */ querystring; }
59
+ });
60
+
61
+ ;// CONCATENATED MODULE: ./src/private/Mutex.ts
62
+ function _typeof(obj) { "@babel/helpers - typeof"; return _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; }, _typeof(obj); }
63
+ function _call(body, then, direct) {
64
+ if (direct) {
65
+ return then ? then(body()) : body();
66
+ }
67
+ try {
68
+ var result = Promise.resolve(body());
69
+ return then ? result.then(then) : result;
70
+ } catch (e) {
71
+ return Promise.reject(e);
72
+ }
73
+ }
74
+ function _rethrow(thrown, value) {
75
+ if (thrown) throw value;
76
+ return value;
77
+ }
78
+ function _finallyRethrows(body, finalizer) {
79
+ try {
80
+ var result = body();
81
+ } catch (e) {
82
+ return finalizer(true, e);
83
+ }
84
+ if (result && result.then) {
85
+ return result.then(finalizer.bind(null, false), finalizer.bind(null, true));
86
+ }
87
+ return finalizer(false, result);
88
+ }
89
+ function _await(value, then, direct) {
90
+ if (direct) {
91
+ return then ? then(value) : value;
92
+ }
93
+ if (!value || !value.then) {
94
+ value = Promise.resolve(value);
95
+ }
96
+ return then ? value.then(then) : value;
97
+ }
98
+ function _empty() {}
99
+ function _awaitIgnored(value, direct) {
100
+ if (!direct) {
101
+ return value && value.then ? value.then(_empty) : Promise.resolve();
102
+ }
103
+ }
104
+ function _settle(pact, state, value) {
105
+ if (!pact.s) {
106
+ if (value instanceof _Pact) {
107
+ if (value.s) {
108
+ if (state & 1) {
109
+ state = value.s;
110
+ }
111
+ value = value.v;
112
+ } else {
113
+ value.o = _settle.bind(null, pact, state);
114
+ return;
115
+ }
116
+ }
117
+ if (value && value.then) {
118
+ value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
119
+ return;
120
+ }
121
+ pact.s = state;
122
+ pact.v = value;
123
+ var observer = pact.o;
124
+ if (observer) {
125
+ observer(pact);
126
+ }
127
+ }
128
+ }
129
+ var _Pact = /*#__PURE__*/function () {
130
+ function _Pact() {}
131
+ _Pact.prototype.then = function (onFulfilled, onRejected) {
132
+ var result = new _Pact();
133
+ var state = this.s;
134
+ if (state) {
135
+ var callback = state & 1 ? onFulfilled : onRejected;
136
+ if (callback) {
137
+ try {
138
+ _settle(result, 1, callback(this.v));
139
+ } catch (e) {
140
+ _settle(result, 2, e);
141
+ }
142
+ return result;
143
+ } else {
144
+ return this;
145
+ }
146
+ }
147
+ this.o = function (_this) {
148
+ try {
149
+ var value = _this.v;
150
+ if (_this.s & 1) {
151
+ _settle(result, 1, onFulfilled ? onFulfilled(value) : value);
152
+ } else if (onRejected) {
153
+ _settle(result, 1, onRejected(value));
154
+ } else {
155
+ _settle(result, 2, value);
156
+ }
157
+ } catch (e) {
158
+ _settle(result, 2, e);
159
+ }
160
+ };
161
+ return result;
162
+ };
163
+ return _Pact;
164
+ }();
165
+ function _isSettledPact(thenable) {
166
+ return thenable instanceof _Pact && thenable.s & 1;
167
+ }
168
+ function _for(test, update, body) {
169
+ var stage;
170
+ for (;;) {
171
+ var shouldContinue = test();
172
+ if (_isSettledPact(shouldContinue)) {
173
+ shouldContinue = shouldContinue.v;
174
+ }
175
+ if (!shouldContinue) {
176
+ return result;
177
+ }
178
+ if (shouldContinue.then) {
179
+ stage = 0;
180
+ break;
181
+ }
182
+ var result = body();
183
+ if (result && result.then) {
184
+ if (_isSettledPact(result)) {
185
+ result = result.s;
186
+ } else {
187
+ stage = 1;
188
+ break;
189
+ }
190
+ }
191
+ if (update) {
192
+ var updateValue = update();
193
+ if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
194
+ stage = 2;
195
+ break;
196
+ }
197
+ }
198
+ }
199
+ var pact = new _Pact();
200
+ var reject = _settle.bind(null, pact, 2);
201
+ (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
202
+ return pact;
203
+ function _resumeAfterBody(value) {
204
+ result = value;
205
+ do {
206
+ if (update) {
207
+ updateValue = update();
208
+ if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
209
+ updateValue.then(_resumeAfterUpdate).then(void 0, reject);
210
+ return;
211
+ }
212
+ }
213
+ shouldContinue = test();
214
+ if (!shouldContinue || _isSettledPact(shouldContinue) && !shouldContinue.v) {
215
+ _settle(pact, 1, result);
216
+ return;
217
+ }
218
+ if (shouldContinue.then) {
219
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
220
+ return;
221
+ }
222
+ result = body();
223
+ if (_isSettledPact(result)) {
224
+ result = result.v;
225
+ }
226
+ } while (!result || !result.then);
227
+ result.then(_resumeAfterBody).then(void 0, reject);
228
+ }
229
+ function _resumeAfterTest(shouldContinue) {
230
+ if (shouldContinue) {
231
+ result = body();
232
+ if (result && result.then) {
233
+ result.then(_resumeAfterBody).then(void 0, reject);
234
+ } else {
235
+ _resumeAfterBody(result);
236
+ }
237
+ } else {
238
+ _settle(pact, 1, result);
239
+ }
240
+ }
241
+ function _resumeAfterUpdate() {
242
+ if (shouldContinue = test()) {
243
+ if (shouldContinue.then) {
244
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
245
+ } else {
246
+ _resumeAfterTest(shouldContinue);
247
+ }
248
+ } else {
249
+ _settle(pact, 1, result);
250
+ }
251
+ }
252
+ }
253
+ function _continue(value, then) {
254
+ return value && value.then ? value.then(then) : then(value);
255
+ }
256
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
257
+ function _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, _toPropertyKey(descriptor.key), descriptor); } }
258
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
259
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
260
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
261
+ /**
262
+ * A lightweight mutex. (Other libraries contain too many features and we want to keep size down).
263
+ *
264
+ * Characteristics:
265
+ * - Non-reentrant.
266
+ * - Unfair. (Multiple callers awaiting 'acquire' will be granted the mutex in no order.)
267
+ * - When calling `safe` consecutively with no 'awaits' in-between, the current context will synchronously acquire
268
+ * the mutex every time.
269
+ */
270
+ var Mutex = /*#__PURE__*/function () {
271
+ function Mutex() {
272
+ _classCallCheck(this, Mutex);
273
+ this.mutex = undefined;
274
+ this.resolver = undefined;
275
+ }
276
+ _createClass(Mutex, [{
277
+ key: "safe",
278
+ value: function safe(callback) {
279
+ try {
280
+ var _this2 = this;
281
+ return _await(_this2.acquire(), function () {
282
+ return _finallyRethrows(callback, function (_wasThrown, _result) {
283
+ _this2.release();
284
+ return _rethrow(_wasThrown, _result);
285
+ });
286
+ });
287
+ } catch (e) {
288
+ return Promise.reject(e);
289
+ }
290
+ }
291
+ }, {
292
+ key: "acquire",
293
+ value: function acquire() {
294
+ try {
295
+ var _this4 = this;
296
+ // Loop necessary for when multiple calls are made to 'acquire' before a 'release' is called, else the call to
297
+ // 'release' will resume every caller currently waiting on 'acquire'.
298
+ return _continue(_for(function () {
299
+ return _this4.mutex !== undefined;
300
+ }, void 0, function () {
301
+ return _awaitIgnored(_this4.mutex);
302
+ }), function () {
303
+ _this4.mutex = new Promise(function (resolve) {
304
+ _this4.resolver = resolve;
305
+ });
306
+ });
307
+ } catch (e) {
308
+ return Promise.reject(e);
309
+ }
310
+ }
311
+ }, {
312
+ key: "release",
313
+ value: function release() {
314
+ if (this.resolver === undefined) {
315
+ throw new Error("Unable to release mutex: already released.");
316
+ }
317
+ this.resolver();
318
+ this.resolver = undefined;
319
+ this.mutex = undefined;
320
+ }
321
+ }]);
322
+ return Mutex;
323
+ }();
324
+ ;// CONCATENATED MODULE: ./src/private/AuthSessionState.ts
325
+ function AuthSessionState_typeof(obj) { "@babel/helpers - typeof"; return AuthSessionState_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; }, AuthSessionState_typeof(obj); }
326
+ function AuthSessionState_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
327
+ function AuthSessionState_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, AuthSessionState_toPropertyKey(descriptor.key), descriptor); } }
328
+ function AuthSessionState_createClass(Constructor, protoProps, staticProps) { if (protoProps) AuthSessionState_defineProperties(Constructor.prototype, protoProps); if (staticProps) AuthSessionState_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
329
+ function AuthSessionState_toPropertyKey(arg) { var key = AuthSessionState_toPrimitive(arg, "string"); return AuthSessionState_typeof(key) === "symbol" ? key : String(key); }
330
+ function AuthSessionState_toPrimitive(input, hint) { if (AuthSessionState_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (AuthSessionState_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
331
+
332
+ /**
333
+ * Maintains a global session state, even across package versions.
334
+ *
335
+ * This is to allow users to start auth sessions via the Bytescale JavaScript SDK, where due to versioning or other
336
+ * bundling issues, the Bytescale Upload Widget has been bundled with a different Bytescale JavaScript SDK. In this
337
+ * scenario, the user wouldn't be able to start an auth session with the Bytescale Upload Widget. Therefore, we use
338
+ * global state (i.e. on the window) to ensure the session state can be shared between the user's instance of the
339
+ * Bytescale JavaScript SDK and the Upload Widget's version of the Bytescale JavaScript SDK.
340
+ *
341
+ * Users also frequently have problems caused by them not keeping track of *Api and *Manager instances correctly, so
342
+ * making this global prevents a lot of common mistakes.
343
+ */
344
+ var AuthSessionState = /*#__PURE__*/function () {
345
+ function AuthSessionState() {
346
+ AuthSessionState_classCallCheck(this, AuthSessionState);
347
+ }
348
+ AuthSessionState_createClass(AuthSessionState, null, [{
349
+ key: "getMutex",
350
+ value:
351
+ /**
352
+ * Called in the browser only.
353
+ */
354
+ function getMutex() {
355
+ var key = AuthSessionState.mutexKey;
356
+ var mutex = window[key];
357
+ if (mutex === undefined) {
358
+ mutex = new Mutex();
359
+ window[key] = mutex;
360
+ }
361
+ return mutex;
362
+ }
363
+ /**
364
+ * Called in the browser only.
365
+ */
366
+ }, {
367
+ key: "setSession",
368
+ value: function setSession(session) {
369
+ window[AuthSessionState.stateKey] = session;
370
+ }
371
+ /**
372
+ * Called in the browser and in Node.js (so we check the env before calling env-specific code).
373
+ */
374
+ }, {
375
+ key: "getSession",
376
+ value: function getSession() {
377
+ if (typeof window === "undefined") {
378
+ return undefined;
379
+ }
380
+ return window[AuthSessionState.stateKey];
381
+ }
382
+ }]);
383
+ return AuthSessionState;
384
+ }();
385
+ AuthSessionState.stateKey = "BytescaleSessionState";
386
+ AuthSessionState.mutexKey = "BytescaleSessionStateMutex";
387
+ ;// CONCATENATED MODULE: ./src/public/shared/generated/runtime.ts
388
+ 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); }
389
+ 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); }
390
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
391
+ function _possibleConstructorReturn(self, call) { if (call && (runtime_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
392
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
393
+ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
394
+ function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
395
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
396
+ function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
397
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
398
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
399
+ function _catch(body, recover) {
400
+ try {
401
+ var result = body();
402
+ } catch (e) {
403
+ return recover(e);
404
+ }
405
+ if (result && result.then) {
406
+ return result.then(void 0, recover);
407
+ }
408
+ return result;
409
+ }
410
+ function runtime_empty() {}
411
+ function runtime_continue(value, then) {
412
+ return value && value.then ? value.then(then) : then(value);
413
+ }
414
+ function _invoke(body, then) {
415
+ var result = body();
416
+ if (result && result.then) {
417
+ return result.then(then);
418
+ }
419
+ return then(result);
420
+ }
421
+ function _defineProperty(obj, key, value) { key = runtime_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
422
+ function runtime_await(value, then, direct) {
423
+ if (direct) {
424
+ return then ? then(value) : value;
425
+ }
426
+ if (!value || !value.then) {
427
+ value = Promise.resolve(value);
428
+ }
429
+ return then ? value.then(then) : value;
430
+ }
431
+ function runtime_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
432
+ function runtime_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, runtime_toPropertyKey(descriptor.key), descriptor); } }
433
+ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoProps) runtime_defineProperties(Constructor.prototype, protoProps); if (staticProps) runtime_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
434
+ function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
435
+ 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); }
436
+
437
+ var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
438
+ function BytescaleApiClientConfigUtils() {
439
+ runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
440
+ }
441
+ runtime_createClass(BytescaleApiClientConfigUtils, null, [{
442
+ key: "getApiUrl",
443
+ value: function getApiUrl(config) {
444
+ var _a;
445
+ return (_a = config.apiUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultApiUrl;
446
+ }
447
+ }, {
448
+ key: "getCdnUrl",
449
+ value: function getCdnUrl(config) {
450
+ var _a;
451
+ return (_a = config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultCdnUrl;
452
+ }
453
+ }, {
454
+ key: "getFetchApi",
455
+ value: function getFetchApi(config) {
456
+ var _a;
457
+ return (_a = config.fetchApi) !== null && _a !== void 0 ? _a : fetch;
458
+ }
459
+ }, {
460
+ key: "getAccountId",
461
+ value: function getAccountId(config) {
462
+ var _a, _b;
463
+ var accountId;
464
+ if (BytescaleApiClientConfigUtils.specialApiKeys.includes(config.apiKey)) {
465
+ accountId = BytescaleApiClientConfigUtils.specialApiKeyAccountId;
466
+ } else {
467
+ accountId = (_b = (_a = config.apiKey.split("_")[1]) === null || _a === void 0 ? void 0 : _a.substr(0, BytescaleApiClientConfigUtils.accountIdLength)) !== null && _b !== void 0 ? _b : "";
468
+ if (accountId.length !== BytescaleApiClientConfigUtils.accountIdLength) {
469
+ throw new Error("Invalid Bytescale API key.");
470
+ }
471
+ }
472
+ return accountId;
473
+ }
474
+ }, {
475
+ key: "validate",
476
+ value: function validate(config) {
477
+ var _a;
478
+ // Defensive programming, for users not using TypeScript. Mainly because this is used by UploadWidget users.
479
+ if ((config !== null && config !== void 0 ? config : undefined) === undefined) {
480
+ throw new Error("Config parameter required.");
481
+ }
482
+ if (((_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined) === undefined) {
483
+ throw new Error("Please provide an API key via the 'apiKey' config parameter.");
484
+ }
485
+ if (config.apiKey.trim() !== config.apiKey) {
486
+ // We do not support API keys with whitespace (by trimming ourselves) because otherwise we'd need to support this
487
+ // everywhere in perpetuity (since removing the trimming would be a breaking change).
488
+ throw new Error("API key needs trimming (whitespace detected).");
489
+ }
490
+ // This performs futher validation on the API key...
491
+ BytescaleApiClientConfigUtils.getAccountId(config);
492
+ }
493
+ }]);
494
+ return BytescaleApiClientConfigUtils;
495
+ }();
496
+ BytescaleApiClientConfigUtils.defaultApiUrl = "https://api.bytescale.com";
497
+ BytescaleApiClientConfigUtils.defaultCdnUrl = "https://upcdn.io";
498
+ BytescaleApiClientConfigUtils.specialApiKeys = ["free", "demo"];
499
+ BytescaleApiClientConfigUtils.specialApiKeyAccountId = "W142hJk";
500
+ BytescaleApiClientConfigUtils.accountIdLength = 7; // Sync with: upload/shared/**/AccountIdUtils
501
+ /**
502
+ * This is the base class for all generated API classes.
503
+ */
504
+ var BaseAPI = /*#__PURE__*/function () {
505
+ function BaseAPI(config) {
506
+ runtime_classCallCheck(this, BaseAPI);
507
+ this.config = config;
508
+ BytescaleApiClientConfigUtils.validate(config);
509
+ }
510
+ /**
511
+ * Returns a successful response (2**) else throws an error.
512
+ */
513
+ runtime_createClass(BaseAPI, [{
514
+ key: "request",
515
+ value: function request(context, initOverrides, baseUrlOverride) {
516
+ try {
517
+ var _this2 = this;
518
+ var _a;
519
+ var apiKey = _this2.config.apiKey;
520
+ context.headers["Authorization"] = "Bearer ".concat(apiKey); // authorization-header authentication
521
+ var session = AuthSessionState.getSession();
522
+ if ((session === null || session === void 0 ? void 0 : session.accessToken) !== undefined) {
523
+ context.headers["Authorization-Token"] = session.accessToken;
524
+ }
525
+ // Key: any possible value for 'baseUrlOverride'
526
+ // Value: user-overridden value for that base URL from the config.
527
+ var nonDefaultBasePaths = _defineProperty({}, BytescaleApiClientConfigUtils.defaultCdnUrl, BytescaleApiClientConfigUtils.getCdnUrl(_this2.config));
528
+ return runtime_await(_this2.createFetchParams(context, initOverrides, baseUrlOverride === undefined ? undefined : (_a = nonDefaultBasePaths[baseUrlOverride]) !== null && _a !== void 0 ? _a : baseUrlOverride), function (_ref) {
529
+ var url = _ref.url,
530
+ init = _ref.init;
531
+ return BaseAPI.fetch(url, init, Object.assign(Object.assign({}, _this2.config), {
532
+ isBytescaleApi: true
533
+ }));
534
+ });
535
+ } catch (e) {
536
+ return Promise.reject(e);
537
+ }
538
+ }
539
+ }, {
540
+ key: "encodeParam",
541
+ value: function encodeParam(paramName, paramValue) {
542
+ if (paramName === "filePath") {
543
+ if (!paramValue.startsWith("/")) {
544
+ // Non-obvious errors are returned by the Bytescale CDN if forward slashes are omitted, so catch it client-side:
545
+ throw new Error("The 'filePath' parameter must begin with a '/' character.");
546
+ }
547
+ // We must not encode the filePath param (as slashes are valid).
548
+ return paramValue;
549
+ }
550
+ return encodeURIComponent(paramValue);
551
+ }
552
+ }, {
553
+ key: "createFetchParams",
554
+ value: function createFetchParams(context, initOverrides, baseUrlOverride) {
555
+ try {
556
+ var _this4 = this;
557
+ var url = (baseUrlOverride !== null && baseUrlOverride !== void 0 ? baseUrlOverride : BytescaleApiClientConfigUtils.getApiUrl(_this4.config)) + context.path;
558
+ if (context.query !== undefined && Object.keys(context.query).length !== 0) {
559
+ // only add the querystring to the URL if there are query parameters.
560
+ // this is done to avoid urls ending with a "?" character which buggy webservers
561
+ // do not handle correctly sometimes.
562
+ url += "?" + querystring(context.query);
563
+ }
564
+ var configHeaders = _this4.config.headers;
565
+ var _Object$assign3 = Object.assign({}, context.headers);
566
+ return runtime_await(configHeaders === undefined ? {} : configHeaders(), function (_configHeaders) {
567
+ var headers = Object.assign(_Object$assign3, _configHeaders);
568
+ Object.keys(headers).forEach(function (key) {
569
+ return headers[key] === undefined ? delete headers[key] : {};
570
+ });
571
+ var initOverrideFn = typeof initOverrides === "function" ? initOverrides : function () {
572
+ return runtime_await(initOverrides);
573
+ };
574
+ var initParams = {
575
+ method: context.method,
576
+ headers: headers,
577
+ body: context.body
578
+ };
579
+ var _Object$assign2 = Object.assign({}, initParams);
580
+ return runtime_await(initOverrideFn({
581
+ init: initParams,
582
+ context: context
583
+ }), function (_initOverrideFn) {
584
+ var overriddenInit = Object.assign(_Object$assign2, _initOverrideFn);
585
+ var init = Object.assign(Object.assign({}, overriddenInit), {
586
+ body: JSON.stringify(overriddenInit.body)
587
+ });
588
+ return {
589
+ url: url,
590
+ init: init
591
+ };
592
+ });
593
+ }, configHeaders === undefined);
594
+ } catch (e) {
595
+ return Promise.reject(e);
596
+ }
597
+ }
598
+ }], [{
599
+ key: "fetch",
600
+ value: function fetch(url, init, config) {
601
+ try {
602
+ var _exit3 = false;
603
+ var _a, _b;
604
+ var response;
605
+ return runtime_continue(_catch(function () {
606
+ return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(config)(url, Object.assign(Object.assign({}, init), {
607
+ // This is specifically added to cater for Next.js's Fetch implementation, which caches POST requests...
608
+ //
609
+ // "fetch requests that use the POST method are also automatically cached."
610
+ // - https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data
611
+ //
612
+ // However, this is probably a good idea, even for all GET requests, as if the user is refreshing a JWT
613
+ // or downloading a file via 'FileApi.downloadFile', then they'll likely want the latest.
614
+ cache: "no-store"
615
+ })), function (_BytescaleApiClientCo) {
616
+ response = _BytescaleApiClientCo;
617
+ });
618
+ }, function (e) {
619
+ // Network-level errors, CORS errors, or HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies).
620
+ // HTTP-level errors from external services (e.g. AWS or the user's own proxy) will appear as CORS errors as their response headers won't include the appropriate CORS values.
621
+ throw new Error(config.isBytescaleApi ? "Unable to resolve the Bytescale API: ".concat(e.message, " If the problem persists, and your network connection is OK, then please contact support@bytescale.com and provide: (a) time of failed request in UTC (b) screenshot of failed network response header + body (c) screenshot of failed network request header + body (d) browser and OS version.") : "Unable to resolve URL (".concat(url, "): ").concat(e.message));
622
+ }), function (_result) {
623
+ var _exit2 = false;
624
+ if (_exit3) return _result;
625
+ return response.status >= 200 && response.status < 300 ? response : _invoke(function () {
626
+ if (config.isBytescaleApi) {
627
+ var jsonError = undefined;
628
+ return runtime_continue(_catch(function () {
629
+ return runtime_await(response.json(), function (_response$json) {
630
+ jsonError = _response$json;
631
+ });
632
+ }, runtime_empty), function () {
633
+ if (typeof ((_a = jsonError === null || jsonError === void 0 ? void 0 : jsonError.error) === null || _a === void 0 ? void 0 : _a.code) === "string") {
634
+ throw new BytescaleApiError(jsonError);
635
+ }
636
+ // HTTP-level errors from intermediary services (e.g. AWS or the user's own infrastructure/proxies). On the browser,
637
+ // this error is unlikely to be triggered since these errors will masqurade as CORS errors (see above) but in Node.js
638
+ // this error will appear from any intermediary service failure.
639
+ throw new Error("Unable to connect to the Bytescale API (".concat(response.status, "): please try again."));
640
+ });
641
+ }
642
+ }, function (_result2) {
643
+ if (_exit2) return _result2;
644
+ throw new Error("Failure status code (".concat(response.status, ") received for request: ").concat((_b = init.method) !== null && _b !== void 0 ? _b : "GET", " ").concat(url));
645
+ });
646
+ });
647
+ } catch (e) {
648
+ return Promise.reject(e);
649
+ }
650
+ }
651
+ }]);
652
+ return BaseAPI;
653
+ }();
654
+ var CancelledError = /*#__PURE__*/function (_Error) {
655
+ _inherits(CancelledError, _Error);
656
+ var _super = _createSuper(CancelledError);
657
+ function CancelledError() {
658
+ var _this5;
659
+ runtime_classCallCheck(this, CancelledError);
660
+ _this5 = _super.call(this, "Operation cancelled by caller.");
661
+ _this5.name = "CancelledError";
662
+ return _this5;
663
+ }
664
+ return runtime_createClass(CancelledError);
665
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
666
+ var BytescaleApiError = /*#__PURE__*/function (_Error2) {
667
+ _inherits(BytescaleApiError, _Error2);
668
+ var _super2 = _createSuper(BytescaleApiError);
669
+ function BytescaleApiError(response) {
670
+ var _this6;
671
+ runtime_classCallCheck(this, BytescaleApiError);
672
+ _this6 = _super2.call(this, response.error.message);
673
+ _this6.name = "BytescaleApiError";
674
+ _this6.errorCode = response.error.code;
675
+ _this6.details = response.error.details;
676
+ return _this6;
677
+ }
678
+ return runtime_createClass(BytescaleApiError);
679
+ }( /*#__PURE__*/_wrapNativeSuper(Error));
680
+ function querystring(params) {
681
+ return Object.keys(params).map(function (key) {
682
+ return querystringSingleKey(key, params[key]);
683
+ }).filter(function (part) {
684
+ return part.length > 0;
685
+ }).join("&");
686
+ }
687
+ function querystringSingleKey(key, value) {
688
+ if (value instanceof Object) {
689
+ return querystring(value);
690
+ }
691
+ return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(String(value)));
692
+ }
693
+ var JSONApiResponse = /*#__PURE__*/function () {
694
+ function JSONApiResponse(raw) {
695
+ runtime_classCallCheck(this, JSONApiResponse);
696
+ this.raw = raw;
697
+ }
698
+ runtime_createClass(JSONApiResponse, [{
699
+ key: "value",
700
+ value: function value() {
701
+ try {
702
+ var _this8 = this;
703
+ return runtime_await(_this8.raw.json());
704
+ } catch (e) {
705
+ return Promise.reject(e);
706
+ }
707
+ }
708
+ }]);
709
+ return JSONApiResponse;
710
+ }();
711
+ var VoidApiResponse = /*#__PURE__*/function () {
712
+ function VoidApiResponse(raw) {
713
+ runtime_classCallCheck(this, VoidApiResponse);
714
+ this.raw = raw;
715
+ }
716
+ runtime_createClass(VoidApiResponse, [{
717
+ key: "value",
718
+ value: function value() {
719
+ return runtime_await(undefined);
720
+ }
721
+ }]);
722
+ return VoidApiResponse;
723
+ }();
724
+ var BinaryResult = /*#__PURE__*/function () {
725
+ function BinaryResult(raw) {
726
+ runtime_classCallCheck(this, BinaryResult);
727
+ this.raw = raw;
728
+ }
729
+ runtime_createClass(BinaryResult, [{
730
+ key: "stream",
731
+ value: function stream() {
732
+ if (this.raw.bodyUsed) {
733
+ throw new Error("Response body has already been consumed.");
734
+ }
735
+ if (this.raw.body === null) {
736
+ throw new Error("Response body does not exist.");
737
+ }
738
+ return this.raw.body;
739
+ }
740
+ }, {
741
+ key: "text",
742
+ value: function text() {
743
+ try {
744
+ var _this10 = this;
745
+ return runtime_await(_this10.raw.text());
746
+ } catch (e) {
747
+ return Promise.reject(e);
748
+ }
749
+ }
750
+ }, {
751
+ key: "blob",
752
+ value: function blob() {
753
+ try {
754
+ var _this12 = this;
755
+ return runtime_await(_this12.raw.blob());
756
+ } catch (e) {
757
+ return Promise.reject(e);
758
+ }
759
+ }
760
+ }, {
761
+ key: "json",
762
+ value: function json() {
763
+ try {
764
+ var _this14 = this;
765
+ return runtime_await(_this14.raw.json());
766
+ } catch (e) {
767
+ return Promise.reject(e);
768
+ }
769
+ }
770
+ }]);
771
+ return BinaryResult;
772
+ }();
773
+ ;// CONCATENATED MODULE: ./src/public/shared/generated/apis/FileApi.ts
774
+ function FileApi_typeof(obj) { "@babel/helpers - typeof"; return FileApi_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; }, FileApi_typeof(obj); }
775
+ function FileApi_await(value, then, direct) {
776
+ if (direct) {
777
+ return then ? then(value) : value;
778
+ }
779
+ if (!value || !value.then) {
780
+ value = Promise.resolve(value);
781
+ }
782
+ return then ? value.then(then) : value;
783
+ }
784
+ function FileApi_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
785
+ function FileApi_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, FileApi_toPropertyKey(descriptor.key), descriptor); } }
786
+ function FileApi_createClass(Constructor, protoProps, staticProps) { if (protoProps) FileApi_defineProperties(Constructor.prototype, protoProps); if (staticProps) FileApi_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
787
+ function FileApi_toPropertyKey(arg) { var key = FileApi_toPrimitive(arg, "string"); return FileApi_typeof(key) === "symbol" ? key : String(key); }
788
+ function FileApi_toPrimitive(input, hint) { if (FileApi_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (FileApi_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
789
+ function FileApi_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) FileApi_setPrototypeOf(subClass, superClass); }
790
+ function FileApi_setPrototypeOf(o, p) { FileApi_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return FileApi_setPrototypeOf(o, p); }
791
+ function FileApi_createSuper(Derived) { var hasNativeReflectConstruct = FileApi_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = FileApi_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = FileApi_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return FileApi_possibleConstructorReturn(this, result); }; }
792
+ function FileApi_possibleConstructorReturn(self, call) { if (call && (FileApi_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return FileApi_assertThisInitialized(self); }
793
+ function FileApi_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
794
+ function FileApi_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
795
+ function FileApi_getPrototypeOf(o) { FileApi_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return FileApi_getPrototypeOf(o); }
796
+ /* tslint:disable */
797
+ /* eslint-disable */
798
+ /**
799
+ * @bytescale/api
800
+ * Bytescale API
801
+ *
802
+ * The version of the OpenAPI document: 2.0.0
803
+ * Contact: hello@bytescale.com
804
+ *
805
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
806
+ * https://openapi-generator.tech
807
+ * Do not edit the class manually.
808
+ */
809
+ // @ts-ignore
810
+
811
+ var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
812
+ FileApi_inherits(FileApi, _runtime$BaseAPI);
813
+ var _super = FileApi_createSuper(FileApi);
814
+ function FileApi() {
815
+ FileApi_classCallCheck(this, FileApi);
816
+ return _super.apply(this, arguments);
817
+ }
818
+ FileApi_createClass(FileApi, [{
819
+ key: "copyFile",
820
+ value:
821
+ /**
822
+ * Copies a file synchronously.
823
+ */
824
+ function copyFile(params) {
825
+ try {
826
+ var _this2 = this;
827
+ var query = {};
828
+ var headers = {};
829
+ headers["Content-Type"] = "application/json";
830
+ return FileApi_await(_this2.request({
831
+ path: "/v2/accounts/{accountId}/files/copy".replace("{".concat("accountId", "}"),
832
+ // @ts-ignore
833
+ _this2.encodeParam("accountId", params.accountId)),
834
+ method: "POST",
835
+ headers: headers,
836
+ query: query,
837
+ body: params.copyFileRequest
838
+ }, undefined, [][0]), function (response) {
839
+ return FileApi_await(new JSONApiResponse(response).value());
840
+ });
841
+ } catch (e) {
842
+ return Promise.reject(e);
843
+ }
844
+ }
845
+ /**
846
+ * Copies multiple files asynchronously.
847
+ */
848
+ }, {
849
+ key: "copyFileBatch",
850
+ value: function copyFileBatch(params) {
851
+ try {
852
+ var _this4 = this;
853
+ var query = {};
854
+ var headers = {};
855
+ headers["Content-Type"] = "application/json";
856
+ return FileApi_await(_this4.request({
857
+ path: "/v2/accounts/{accountId}/files/copy/batch".replace("{".concat("accountId", "}"),
858
+ // @ts-ignore
859
+ _this4.encodeParam("accountId", params.accountId)),
860
+ method: "POST",
861
+ headers: headers,
862
+ query: query,
863
+ body: params.copyFileBatchRequest
864
+ }, undefined, [][0]), function (response) {
865
+ return FileApi_await(new JSONApiResponse(response).value());
866
+ });
867
+ } catch (e) {
868
+ return Promise.reject(e);
869
+ }
870
+ }
871
+ /**
872
+ * Deletes a file synchronously.
873
+ */
874
+ }, {
875
+ key: "deleteFile",
876
+ value: function deleteFile(params) {
877
+ try {
878
+ var _this6 = this;
879
+ var query = {};
880
+ if (params.filePath !== undefined) {
881
+ query["filePath"] = params.filePath;
882
+ }
883
+ var headers = {};
884
+ return FileApi_await(_this6.request({
885
+ path: "/v2/accounts/{accountId}/files".replace("{".concat("accountId", "}"),
886
+ // @ts-ignore
887
+ _this6.encodeParam("accountId", params.accountId)),
888
+ method: "DELETE",
889
+ headers: headers,
890
+ query: query
891
+ }, undefined, [][0]), function (response) {
892
+ return FileApi_await(new VoidApiResponse(response).value());
893
+ });
894
+ } catch (e) {
895
+ return Promise.reject(e);
896
+ }
897
+ }
898
+ /**
899
+ * Deletes multiple files asynchronously.
900
+ */
901
+ }, {
902
+ key: "deleteFileBatch",
903
+ value: function deleteFileBatch(params) {
904
+ try {
905
+ var _this8 = this;
906
+ var query = {};
907
+ var headers = {};
908
+ headers["Content-Type"] = "application/json";
909
+ return FileApi_await(_this8.request({
910
+ path: "/v2/accounts/{accountId}/files/batch".replace("{".concat("accountId", "}"),
911
+ // @ts-ignore
912
+ _this8.encodeParam("accountId", params.accountId)),
913
+ method: "DELETE",
914
+ headers: headers,
915
+ query: query,
916
+ body: params.deleteFileBatchRequest
917
+ }, undefined, [][0]), function (response) {
918
+ return FileApi_await(new JSONApiResponse(response).value());
919
+ });
920
+ } catch (e) {
921
+ return Promise.reject(e);
922
+ }
923
+ }
924
+ /**
925
+ * Downloads a file in its original/unprocessed state.
926
+ */
927
+ }, {
928
+ key: "downloadFile",
929
+ value: function downloadFile(params) {
930
+ try {
931
+ var _this10 = this;
932
+ var query = {};
933
+ if (params.cache !== undefined) {
934
+ query["cache"] = params.cache;
935
+ }
936
+ if (params.cacheTtl !== undefined) {
937
+ query["cache_ttl"] = params.cacheTtl;
938
+ }
939
+ if (params.version !== undefined) {
940
+ query["version"] = params.version;
941
+ }
942
+ var headers = {};
943
+ return FileApi_await(_this10.request({
944
+ path: "/{accountId}/raw{filePath}".replace("{".concat("accountId", "}"),
945
+ // @ts-ignore
946
+ _this10.encodeParam("accountId", params.accountId)).replace("{".concat("filePath", "}"),
947
+ // @ts-ignore
948
+ _this10.encodeParam("filePath", params.filePath)),
949
+ method: "GET",
950
+ headers: headers,
951
+ query: query
952
+ }, undefined, ["https://upcdn.io"][0]), function (response) {
953
+ return new BinaryResult(response);
954
+ });
955
+ } catch (e) {
956
+ return Promise.reject(e);
957
+ }
958
+ }
959
+ /**
960
+ * Gets the full details (e.g. metadata, tags, etc.) for a file.
961
+ */
962
+ }, {
963
+ key: "getFileDetails",
964
+ value: function getFileDetails(params) {
965
+ try {
966
+ var _this12 = this;
967
+ var query = {};
968
+ if (params.filePath !== undefined) {
969
+ query["filePath"] = params.filePath;
970
+ }
971
+ var headers = {};
972
+ return FileApi_await(_this12.request({
973
+ path: "/v2/accounts/{accountId}/files/details".replace("{".concat("accountId", "}"),
974
+ // @ts-ignore
975
+ _this12.encodeParam("accountId", params.accountId)),
976
+ method: "GET",
977
+ headers: headers,
978
+ query: query
979
+ }, undefined, [][0]), function (response) {
980
+ return FileApi_await(new JSONApiResponse(response).value());
981
+ });
982
+ } catch (e) {
983
+ return Promise.reject(e);
984
+ }
985
+ }
986
+ /**
987
+ * Processes a file and returns the result.
988
+ */
989
+ }, {
990
+ key: "processFile",
991
+ value: function processFile(params) {
992
+ try {
993
+ var _this14 = this;
994
+ var query = {};
995
+ if (params.artifact !== undefined) {
996
+ query["artifact"] = params.artifact;
997
+ }
998
+ if (params.cache !== undefined) {
999
+ query["cache"] = params.cache;
1000
+ }
1001
+ if (params.cachePerm !== undefined) {
1002
+ query["cache_perm"] = params.cachePerm;
1003
+ }
1004
+ if (params.cacheTtl !== undefined) {
1005
+ query["cache_ttl"] = params.cacheTtl;
1006
+ }
1007
+ if (params.large !== undefined) {
1008
+ query["large"] = params.large;
1009
+ }
1010
+ if (params.transformationParams !== undefined) {
1011
+ query["transformationParams"] = params.transformationParams;
1012
+ }
1013
+ if (params.version !== undefined) {
1014
+ query["version"] = params.version;
1015
+ }
1016
+ var headers = {};
1017
+ return FileApi_await(_this14.request({
1018
+ path: "/{accountId}/{transformation}{filePath}".replace("{".concat("accountId", "}"),
1019
+ // @ts-ignore
1020
+ _this14.encodeParam("accountId", params.accountId)).replace("{".concat("filePath", "}"),
1021
+ // @ts-ignore
1022
+ _this14.encodeParam("filePath", params.filePath)).replace("{".concat("transformation", "}"),
1023
+ // @ts-ignore
1024
+ _this14.encodeParam("transformation", params.transformation)),
1025
+ method: "GET",
1026
+ headers: headers,
1027
+ query: query
1028
+ }, undefined, ["https://upcdn.io"][0]), function (response) {
1029
+ return new BinaryResult(response);
1030
+ });
1031
+ } catch (e) {
1032
+ return Promise.reject(e);
1033
+ }
1034
+ }
1035
+ /**
1036
+ * Processes a file and saves the result.
1037
+ */
1038
+ }, {
1039
+ key: "processFileAndSave",
1040
+ value: function processFileAndSave(params) {
1041
+ try {
1042
+ var _this16 = this;
1043
+ var query = {};
1044
+ if (params.transformationParams !== undefined) {
1045
+ query["transformationParams"] = params.transformationParams;
1046
+ }
1047
+ var headers = {};
1048
+ headers["Content-Type"] = "application/json";
1049
+ return FileApi_await(_this16.request({
1050
+ path: "/{accountId}/save/{transformation}{filePath}".replace("{".concat("accountId", "}"),
1051
+ // @ts-ignore
1052
+ _this16.encodeParam("accountId", params.accountId)).replace("{".concat("filePath", "}"),
1053
+ // @ts-ignore
1054
+ _this16.encodeParam("filePath", params.filePath)).replace("{".concat("transformation", "}"),
1055
+ // @ts-ignore
1056
+ _this16.encodeParam("transformation", params.transformation)),
1057
+ method: "POST",
1058
+ headers: headers,
1059
+ query: query,
1060
+ body: params.processFileAndSaveRequest
1061
+ }, undefined, ["https://upcdn.io"][0]), function (response) {
1062
+ return FileApi_await(new JSONApiResponse(response).value());
1063
+ });
1064
+ } catch (e) {
1065
+ return Promise.reject(e);
1066
+ }
1067
+ }
1068
+ }]);
1069
+ return FileApi;
1070
+ }(BaseAPI);
1071
+ ;// CONCATENATED MODULE: ./src/public/shared/generated/apis/FolderApi.ts
1072
+ function FolderApi_typeof(obj) { "@babel/helpers - typeof"; return FolderApi_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; }, FolderApi_typeof(obj); }
1073
+ function FolderApi_await(value, then, direct) {
1074
+ if (direct) {
1075
+ return then ? then(value) : value;
1076
+ }
1077
+ if (!value || !value.then) {
1078
+ value = Promise.resolve(value);
1079
+ }
1080
+ return then ? value.then(then) : value;
1081
+ }
1082
+ function FolderApi_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1083
+ function FolderApi_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, FolderApi_toPropertyKey(descriptor.key), descriptor); } }
1084
+ function FolderApi_createClass(Constructor, protoProps, staticProps) { if (protoProps) FolderApi_defineProperties(Constructor.prototype, protoProps); if (staticProps) FolderApi_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1085
+ function FolderApi_toPropertyKey(arg) { var key = FolderApi_toPrimitive(arg, "string"); return FolderApi_typeof(key) === "symbol" ? key : String(key); }
1086
+ function FolderApi_toPrimitive(input, hint) { if (FolderApi_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (FolderApi_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1087
+ function FolderApi_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) FolderApi_setPrototypeOf(subClass, superClass); }
1088
+ function FolderApi_setPrototypeOf(o, p) { FolderApi_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return FolderApi_setPrototypeOf(o, p); }
1089
+ function FolderApi_createSuper(Derived) { var hasNativeReflectConstruct = FolderApi_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = FolderApi_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = FolderApi_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return FolderApi_possibleConstructorReturn(this, result); }; }
1090
+ function FolderApi_possibleConstructorReturn(self, call) { if (call && (FolderApi_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return FolderApi_assertThisInitialized(self); }
1091
+ function FolderApi_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1092
+ function FolderApi_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1093
+ function FolderApi_getPrototypeOf(o) { FolderApi_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return FolderApi_getPrototypeOf(o); }
1094
+ /* tslint:disable */
1095
+ /* eslint-disable */
1096
+ /**
1097
+ * @bytescale/api
1098
+ * Bytescale API
1099
+ *
1100
+ * The version of the OpenAPI document: 2.0.0
1101
+ * Contact: hello@bytescale.com
1102
+ *
1103
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1104
+ * https://openapi-generator.tech
1105
+ * Do not edit the class manually.
1106
+ */
1107
+ // @ts-ignore
1108
+
1109
+ var FolderApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1110
+ FolderApi_inherits(FolderApi, _runtime$BaseAPI);
1111
+ var _super = FolderApi_createSuper(FolderApi);
1112
+ function FolderApi() {
1113
+ FolderApi_classCallCheck(this, FolderApi);
1114
+ return _super.apply(this, arguments);
1115
+ }
1116
+ FolderApi_createClass(FolderApi, [{
1117
+ key: "copyFolder",
1118
+ value:
1119
+ /**
1120
+ * Copies a folder asynchronously. You can use ListFolder to preview the operation: set `dryRun=true` with ```recursive```, ```includeFiles```, ```includeOverriddenStorage``` and ```includeVirtualFolders``` set to match the values you\'re using here. Leave all other flags unset.
1121
+ */
1122
+ function copyFolder(params) {
1123
+ try {
1124
+ var _this2 = this;
1125
+ var query = {};
1126
+ var headers = {};
1127
+ headers["Content-Type"] = "application/json";
1128
+ return FolderApi_await(_this2.request({
1129
+ path: "/v2/accounts/{accountId}/folders/copy".replace("{".concat("accountId", "}"),
1130
+ // @ts-ignore
1131
+ _this2.encodeParam("accountId", params.accountId)),
1132
+ method: "POST",
1133
+ headers: headers,
1134
+ query: query,
1135
+ body: params.copyFolderRequest
1136
+ }, undefined, [][0]), function (response) {
1137
+ return FolderApi_await(new JSONApiResponse(response).value());
1138
+ });
1139
+ } catch (e) {
1140
+ return Promise.reject(e);
1141
+ }
1142
+ }
1143
+ /**
1144
+ * Copies multiple folders asynchronously. You can use ListFolder to preview the operation: set `dryRun=true` with ```recursive```, ```includeFiles```, ```includeOverriddenStorage``` and ```includeVirtualFolders``` set to match the values you\'re using here. Leave all other flags unset.
1145
+ */
1146
+ }, {
1147
+ key: "copyFolderBatch",
1148
+ value: function copyFolderBatch(params) {
1149
+ try {
1150
+ var _this4 = this;
1151
+ var query = {};
1152
+ var headers = {};
1153
+ headers["Content-Type"] = "application/json";
1154
+ return FolderApi_await(_this4.request({
1155
+ path: "/v2/accounts/{accountId}/folders/copy/batch".replace("{".concat("accountId", "}"),
1156
+ // @ts-ignore
1157
+ _this4.encodeParam("accountId", params.accountId)),
1158
+ method: "POST",
1159
+ headers: headers,
1160
+ query: query,
1161
+ body: params.copyFolderBatchRequest
1162
+ }, undefined, [][0]), function (response) {
1163
+ return FolderApi_await(new JSONApiResponse(response).value());
1164
+ });
1165
+ } catch (e) {
1166
+ return Promise.reject(e);
1167
+ }
1168
+ }
1169
+ /**
1170
+ * Deletes a folder asynchronously. If the folder has overridden storage settings, then no files will be deleted. You can use ListFolder to preview the operation: set `dryRun=true` with ```recursive```, ```includeFiles``` and ```includeVirtualFolders``` set to match the values you\'re using here. Leave all other flags unset.
1171
+ */
1172
+ }, {
1173
+ key: "deleteFolder",
1174
+ value: function deleteFolder(params) {
1175
+ try {
1176
+ var _this6 = this;
1177
+ var query = {};
1178
+ var headers = {};
1179
+ headers["Content-Type"] = "application/json";
1180
+ return FolderApi_await(_this6.request({
1181
+ path: "/v2/accounts/{accountId}/folders".replace("{".concat("accountId", "}"),
1182
+ // @ts-ignore
1183
+ _this6.encodeParam("accountId", params.accountId)),
1184
+ method: "DELETE",
1185
+ headers: headers,
1186
+ query: query,
1187
+ body: params.deleteFolderRequest
1188
+ }, undefined, [][0]), function (response) {
1189
+ return FolderApi_await(new JSONApiResponse(response).value());
1190
+ });
1191
+ } catch (e) {
1192
+ return Promise.reject(e);
1193
+ }
1194
+ }
1195
+ /**
1196
+ * Deletes multiple folders asynchronously. If the folder has overridden storage settings, then no files will be deleted. You can use ListFolder to preview the operation: set `dryRun=true` with ```recursive```, ```includeFiles``` and ```includeVirtualFolders``` set to match the values you\'re using here. Leave all other flags unset.
1197
+ */
1198
+ }, {
1199
+ key: "deleteFolderBatch",
1200
+ value: function deleteFolderBatch(params) {
1201
+ try {
1202
+ var _this8 = this;
1203
+ var query = {};
1204
+ var headers = {};
1205
+ headers["Content-Type"] = "application/json";
1206
+ return FolderApi_await(_this8.request({
1207
+ path: "/v2/accounts/{accountId}/folders/batch".replace("{".concat("accountId", "}"),
1208
+ // @ts-ignore
1209
+ _this8.encodeParam("accountId", params.accountId)),
1210
+ method: "DELETE",
1211
+ headers: headers,
1212
+ query: query,
1213
+ body: params.deleteFolderBatchRequest
1214
+ }, undefined, [][0]), function (response) {
1215
+ return FolderApi_await(new JSONApiResponse(response).value());
1216
+ });
1217
+ } catch (e) {
1218
+ return Promise.reject(e);
1219
+ }
1220
+ }
1221
+ /**
1222
+ * Gets the full details (e.g. permission, storage layer, etc.) for a folder. Returns an empty object if no settings have been configured for this folder.
1223
+ */
1224
+ }, {
1225
+ key: "getFolderDetails",
1226
+ value: function getFolderDetails(params) {
1227
+ try {
1228
+ var _this10 = this;
1229
+ var query = {};
1230
+ if (params.folderPath !== undefined) {
1231
+ query["folderPath"] = params.folderPath;
1232
+ }
1233
+ var headers = {};
1234
+ return FolderApi_await(_this10.request({
1235
+ path: "/v2/accounts/{accountId}/folders".replace("{".concat("accountId", "}"),
1236
+ // @ts-ignore
1237
+ _this10.encodeParam("accountId", params.accountId)),
1238
+ method: "GET",
1239
+ headers: headers,
1240
+ query: query
1241
+ }, undefined, [][0]), function (response) {
1242
+ return FolderApi_await(new JSONApiResponse(response).value());
1243
+ });
1244
+ } catch (e) {
1245
+ return Promise.reject(e);
1246
+ }
1247
+ }
1248
+ /**
1249
+ * Lists the folder\'s contents. The result may be paginated: subsequent pages can be requested by passing the ```cursor``` from the response into the ```cursor``` request parameter. Pagination is complete when the response includes `isPaginationComplete=true`.
1250
+ */
1251
+ }, {
1252
+ key: "listFolder",
1253
+ value: function listFolder(params) {
1254
+ try {
1255
+ var _this12 = this;
1256
+ var query = {};
1257
+ if (params.cursor !== undefined) {
1258
+ query["cursor"] = params.cursor;
1259
+ }
1260
+ if (params.dryRun !== undefined) {
1261
+ query["dryRun"] = params.dryRun;
1262
+ }
1263
+ if (params.folderPath !== undefined) {
1264
+ query["folderPath"] = params.folderPath;
1265
+ }
1266
+ if (params.includeFiles !== undefined) {
1267
+ query["includeFiles"] = params.includeFiles;
1268
+ }
1269
+ if (params.includeOverriddenStorage !== undefined) {
1270
+ query["includeOverriddenStorage"] = params.includeOverriddenStorage;
1271
+ }
1272
+ if (params.includePhysicalFolders !== undefined) {
1273
+ query["includePhysicalFolders"] = params.includePhysicalFolders;
1274
+ }
1275
+ if (params.includeVirtualFolders !== undefined) {
1276
+ query["includeVirtualFolders"] = params.includeVirtualFolders;
1277
+ }
1278
+ if (params.limit !== undefined) {
1279
+ query["limit"] = params.limit;
1280
+ }
1281
+ if (params.recursive !== undefined) {
1282
+ query["recursive"] = params.recursive;
1283
+ }
1284
+ var headers = {};
1285
+ return FolderApi_await(_this12.request({
1286
+ path: "/v2/accounts/{accountId}/folders/list".replace("{".concat("accountId", "}"),
1287
+ // @ts-ignore
1288
+ _this12.encodeParam("accountId", params.accountId)),
1289
+ method: "GET",
1290
+ headers: headers,
1291
+ query: query
1292
+ }, undefined, [][0]), function (response) {
1293
+ return FolderApi_await(new JSONApiResponse(response).value());
1294
+ });
1295
+ } catch (e) {
1296
+ return Promise.reject(e);
1297
+ }
1298
+ }
1299
+ /**
1300
+ * Creates or updates the folder specified by the `folderPath`. If the folder\'s ancestors do not exist, they will be created automatically (with empty FolderSettings). Note: you don\'t need to create folders before uploading files to them.
1301
+ */
1302
+ }, {
1303
+ key: "putFolder",
1304
+ value: function putFolder(params) {
1305
+ try {
1306
+ var _this14 = this;
1307
+ var query = {};
1308
+ var headers = {};
1309
+ headers["Content-Type"] = "application/json";
1310
+ return FolderApi_await(_this14.request({
1311
+ path: "/v2/accounts/{accountId}/folders".replace("{".concat("accountId", "}"),
1312
+ // @ts-ignore
1313
+ _this14.encodeParam("accountId", params.accountId)),
1314
+ method: "PUT",
1315
+ headers: headers,
1316
+ query: query,
1317
+ body: params.putFolderRequest
1318
+ }, undefined, [][0]), function (response) {
1319
+ return FolderApi_await(new JSONApiResponse(response).value());
1320
+ });
1321
+ } catch (e) {
1322
+ return Promise.reject(e);
1323
+ }
1324
+ }
1325
+ }]);
1326
+ return FolderApi;
1327
+ }(BaseAPI);
1328
+ ;// CONCATENATED MODULE: ./src/public/shared/generated/apis/JobApi.ts
1329
+ function JobApi_typeof(obj) { "@babel/helpers - typeof"; return JobApi_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; }, JobApi_typeof(obj); }
1330
+ function JobApi_await(value, then, direct) {
1331
+ if (direct) {
1332
+ return then ? then(value) : value;
1333
+ }
1334
+ if (!value || !value.then) {
1335
+ value = Promise.resolve(value);
1336
+ }
1337
+ return then ? value.then(then) : value;
1338
+ }
1339
+ function JobApi_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1340
+ function JobApi_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, JobApi_toPropertyKey(descriptor.key), descriptor); } }
1341
+ function JobApi_createClass(Constructor, protoProps, staticProps) { if (protoProps) JobApi_defineProperties(Constructor.prototype, protoProps); if (staticProps) JobApi_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1342
+ function JobApi_toPropertyKey(arg) { var key = JobApi_toPrimitive(arg, "string"); return JobApi_typeof(key) === "symbol" ? key : String(key); }
1343
+ function JobApi_toPrimitive(input, hint) { if (JobApi_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (JobApi_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1344
+ function JobApi_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) JobApi_setPrototypeOf(subClass, superClass); }
1345
+ function JobApi_setPrototypeOf(o, p) { JobApi_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return JobApi_setPrototypeOf(o, p); }
1346
+ function JobApi_createSuper(Derived) { var hasNativeReflectConstruct = JobApi_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = JobApi_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = JobApi_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return JobApi_possibleConstructorReturn(this, result); }; }
1347
+ function JobApi_possibleConstructorReturn(self, call) { if (call && (JobApi_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return JobApi_assertThisInitialized(self); }
1348
+ function JobApi_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1349
+ function JobApi_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1350
+ function JobApi_getPrototypeOf(o) { JobApi_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return JobApi_getPrototypeOf(o); }
1351
+ /* tslint:disable */
1352
+ /* eslint-disable */
1353
+ /**
1354
+ * @bytescale/api
1355
+ * Bytescale API
1356
+ *
1357
+ * The version of the OpenAPI document: 2.0.0
1358
+ * Contact: hello@bytescale.com
1359
+ *
1360
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1361
+ * https://openapi-generator.tech
1362
+ * Do not edit the class manually.
1363
+ */
1364
+ // @ts-ignore
1365
+
1366
+ var JobApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1367
+ JobApi_inherits(JobApi, _runtime$BaseAPI);
1368
+ var _super = JobApi_createSuper(JobApi);
1369
+ function JobApi() {
1370
+ JobApi_classCallCheck(this, JobApi);
1371
+ return _super.apply(this, arguments);
1372
+ }
1373
+ JobApi_createClass(JobApi, [{
1374
+ key: "cancelJob",
1375
+ value:
1376
+ /**
1377
+ * Cancels an in-progress background job. Requires a `secret_*` API key.
1378
+ */
1379
+ function cancelJob(params) {
1380
+ try {
1381
+ var _this2 = this;
1382
+ var query = {};
1383
+ var headers = {};
1384
+ return JobApi_await(_this2.request({
1385
+ path: "/v2/accounts/{accountId}/jobs/{jobType}/{jobId}".replace("{".concat("accountId", "}"),
1386
+ // @ts-ignore
1387
+ _this2.encodeParam("accountId", params.accountId)).replace("{".concat("jobId", "}"),
1388
+ // @ts-ignore
1389
+ _this2.encodeParam("jobId", params.jobId)).replace("{".concat("jobType", "}"),
1390
+ // @ts-ignore
1391
+ _this2.encodeParam("jobType", params.jobType)),
1392
+ method: "DELETE",
1393
+ headers: headers,
1394
+ query: query
1395
+ }, undefined, [][0]), function (response) {
1396
+ return JobApi_await(new VoidApiResponse(response).value());
1397
+ });
1398
+ } catch (e) {
1399
+ return Promise.reject(e);
1400
+ }
1401
+ }
1402
+ /**
1403
+ * Gets information on a background job. Requires a `secret_*` API key.
1404
+ */
1405
+ }, {
1406
+ key: "getJob",
1407
+ value: function getJob(params) {
1408
+ try {
1409
+ var _this4 = this;
1410
+ var query = {};
1411
+ var headers = {};
1412
+ return JobApi_await(_this4.request({
1413
+ path: "/v2/accounts/{accountId}/jobs/{jobType}/{jobId}".replace("{".concat("accountId", "}"),
1414
+ // @ts-ignore
1415
+ _this4.encodeParam("accountId", params.accountId)).replace("{".concat("jobId", "}"),
1416
+ // @ts-ignore
1417
+ _this4.encodeParam("jobId", params.jobId)).replace("{".concat("jobType", "}"),
1418
+ // @ts-ignore
1419
+ _this4.encodeParam("jobType", params.jobType)),
1420
+ method: "GET",
1421
+ headers: headers,
1422
+ query: query
1423
+ }, undefined, [][0]), function (response) {
1424
+ return JobApi_await(new JSONApiResponse(response).value());
1425
+ });
1426
+ } catch (e) {
1427
+ return Promise.reject(e);
1428
+ }
1429
+ }
1430
+ /**
1431
+ * Lists the most recently issued background jobs. Requires a `secret_*` API key.
1432
+ */
1433
+ }, {
1434
+ key: "listRecentJobs",
1435
+ value: function listRecentJobs(params) {
1436
+ try {
1437
+ var _this6 = this;
1438
+ var query = {};
1439
+ if (params.jobType) {
1440
+ query["jobType"] = params.jobType;
1441
+ }
1442
+ var headers = {};
1443
+ return JobApi_await(_this6.request({
1444
+ path: "/v2/accounts/{accountId}/jobs".replace("{".concat("accountId", "}"),
1445
+ // @ts-ignore
1446
+ _this6.encodeParam("accountId", params.accountId)),
1447
+ method: "GET",
1448
+ headers: headers,
1449
+ query: query
1450
+ }, undefined, [][0]), function (response) {
1451
+ return JobApi_await(new JSONApiResponse(response).value());
1452
+ });
1453
+ } catch (e) {
1454
+ return Promise.reject(e);
1455
+ }
1456
+ }
1457
+ }]);
1458
+ return JobApi;
1459
+ }(BaseAPI);
1460
+ ;// CONCATENATED MODULE: ./src/public/shared/generated/apis/UploadApi.ts
1461
+ function UploadApi_typeof(obj) { "@babel/helpers - typeof"; return UploadApi_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; }, UploadApi_typeof(obj); }
1462
+ function UploadApi_await(value, then, direct) {
1463
+ if (direct) {
1464
+ return then ? then(value) : value;
1465
+ }
1466
+ if (!value || !value.then) {
1467
+ value = Promise.resolve(value);
1468
+ }
1469
+ return then ? value.then(then) : value;
1470
+ }
1471
+ function UploadApi_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1472
+ function UploadApi_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, UploadApi_toPropertyKey(descriptor.key), descriptor); } }
1473
+ function UploadApi_createClass(Constructor, protoProps, staticProps) { if (protoProps) UploadApi_defineProperties(Constructor.prototype, protoProps); if (staticProps) UploadApi_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1474
+ function UploadApi_toPropertyKey(arg) { var key = UploadApi_toPrimitive(arg, "string"); return UploadApi_typeof(key) === "symbol" ? key : String(key); }
1475
+ function UploadApi_toPrimitive(input, hint) { if (UploadApi_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (UploadApi_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1476
+ function UploadApi_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) UploadApi_setPrototypeOf(subClass, superClass); }
1477
+ function UploadApi_setPrototypeOf(o, p) { UploadApi_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return UploadApi_setPrototypeOf(o, p); }
1478
+ function UploadApi_createSuper(Derived) { var hasNativeReflectConstruct = UploadApi_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = UploadApi_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = UploadApi_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return UploadApi_possibleConstructorReturn(this, result); }; }
1479
+ function UploadApi_possibleConstructorReturn(self, call) { if (call && (UploadApi_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return UploadApi_assertThisInitialized(self); }
1480
+ function UploadApi_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1481
+ function UploadApi_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1482
+ function UploadApi_getPrototypeOf(o) { UploadApi_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return UploadApi_getPrototypeOf(o); }
1483
+ /* tslint:disable */
1484
+ /* eslint-disable */
1485
+ /**
1486
+ * @bytescale/api
1487
+ * Bytescale API
1488
+ *
1489
+ * The version of the OpenAPI document: 2.0.0
1490
+ * Contact: hello@bytescale.com
1491
+ *
1492
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1493
+ * https://openapi-generator.tech
1494
+ * Do not edit the class manually.
1495
+ */
1496
+ // @ts-ignore
1497
+
1498
+ var UploadApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1499
+ UploadApi_inherits(UploadApi, _runtime$BaseAPI);
1500
+ var _super = UploadApi_createSuper(UploadApi);
1501
+ function UploadApi() {
1502
+ UploadApi_classCallCheck(this, UploadApi);
1503
+ return _super.apply(this, arguments);
1504
+ }
1505
+ UploadApi_createClass(UploadApi, [{
1506
+ key: "beginMultipartUpload",
1507
+ value:
1508
+ /**
1509
+ * Begins a new multipart file upload process.
1510
+ */
1511
+ function beginMultipartUpload(params) {
1512
+ try {
1513
+ var _this2 = this;
1514
+ var query = {};
1515
+ var headers = {};
1516
+ headers["Content-Type"] = "application/json";
1517
+ return UploadApi_await(_this2.request({
1518
+ path: "/v2/accounts/{accountId}/uploads".replace("{".concat("accountId", "}"),
1519
+ // @ts-ignore
1520
+ _this2.encodeParam("accountId", params.accountId)),
1521
+ method: "POST",
1522
+ headers: headers,
1523
+ query: query,
1524
+ body: params.beginMultipartUploadRequest
1525
+ }, undefined, [][0]), function (response) {
1526
+ return UploadApi_await(new JSONApiResponse(response).value());
1527
+ });
1528
+ } catch (e) {
1529
+ return Promise.reject(e);
1530
+ }
1531
+ }
1532
+ /**
1533
+ * Marks an upload part as uploaded. You must call this endpoint after you have successfully issued a `PUT` request to the `uploadUrl` on the corresponding UploadPart.
1534
+ */
1535
+ }, {
1536
+ key: "completeUploadPart",
1537
+ value: function completeUploadPart(params) {
1538
+ try {
1539
+ var _this4 = this;
1540
+ var query = {};
1541
+ var headers = {};
1542
+ headers["Content-Type"] = "application/json";
1543
+ return UploadApi_await(_this4.request({
1544
+ path: "/v2/accounts/{accountId}/uploads/{uploadId}/parts/{uploadPartIndex}".replace("{".concat("accountId", "}"),
1545
+ // @ts-ignore
1546
+ _this4.encodeParam("accountId", params.accountId)).replace("{".concat("uploadId", "}"),
1547
+ // @ts-ignore
1548
+ _this4.encodeParam("uploadId", params.uploadId)).replace("{".concat("uploadPartIndex", "}"),
1549
+ // @ts-ignore
1550
+ _this4.encodeParam("uploadPartIndex", params.uploadPartIndex)),
1551
+ method: "PUT",
1552
+ headers: headers,
1553
+ query: query,
1554
+ body: params.completeUploadPartRequest
1555
+ }, undefined, [][0]), function (response) {
1556
+ return UploadApi_await(new VoidApiResponse(response).value());
1557
+ });
1558
+ } catch (e) {
1559
+ return Promise.reject(e);
1560
+ }
1561
+ }
1562
+ /**
1563
+ * Gets a remaining upload part for a multipart file upload.
1564
+ */
1565
+ }, {
1566
+ key: "getUploadPart",
1567
+ value: function getUploadPart(params) {
1568
+ try {
1569
+ var _this6 = this;
1570
+ var query = {};
1571
+ var headers = {};
1572
+ return UploadApi_await(_this6.request({
1573
+ path: "/v2/accounts/{accountId}/uploads/{uploadId}/parts/{uploadPartIndex}".replace("{".concat("accountId", "}"),
1574
+ // @ts-ignore
1575
+ _this6.encodeParam("accountId", params.accountId)).replace("{".concat("uploadId", "}"),
1576
+ // @ts-ignore
1577
+ _this6.encodeParam("uploadId", params.uploadId)).replace("{".concat("uploadPartIndex", "}"),
1578
+ // @ts-ignore
1579
+ _this6.encodeParam("uploadPartIndex", params.uploadPartIndex)),
1580
+ method: "GET",
1581
+ headers: headers,
1582
+ query: query
1583
+ }, undefined, [][0]), function (response) {
1584
+ return UploadApi_await(new JSONApiResponse(response).value());
1585
+ });
1586
+ } catch (e) {
1587
+ return Promise.reject(e);
1588
+ }
1589
+ }
1590
+ /**
1591
+ * Lists the remaining upload parts for a multipart file upload. An empty array is returned when the upload is complete.
1592
+ */
1593
+ }, {
1594
+ key: "listUploadParts",
1595
+ value: function listUploadParts(params) {
1596
+ try {
1597
+ var _this8 = this;
1598
+ var query = {};
1599
+ var headers = {};
1600
+ return UploadApi_await(_this8.request({
1601
+ path: "/v2/accounts/{accountId}/uploads/{uploadId}/parts".replace("{".concat("accountId", "}"),
1602
+ // @ts-ignore
1603
+ _this8.encodeParam("accountId", params.accountId)).replace("{".concat("uploadId", "}"),
1604
+ // @ts-ignore
1605
+ _this8.encodeParam("uploadId", params.uploadId)),
1606
+ method: "GET",
1607
+ headers: headers,
1608
+ query: query
1609
+ }, undefined, [][0]), function (response) {
1610
+ return UploadApi_await(new JSONApiResponse(response).value());
1611
+ });
1612
+ } catch (e) {
1613
+ return Promise.reject(e);
1614
+ }
1615
+ }
1616
+ /**
1617
+ * Upload from a URL with a single HTTP request:
1618
+ */
1619
+ }, {
1620
+ key: "uploadFromUrl",
1621
+ value: function uploadFromUrl(params) {
1622
+ try {
1623
+ var _this10 = this;
1624
+ var query = {};
1625
+ var headers = {};
1626
+ headers["Content-Type"] = "application/json";
1627
+ return UploadApi_await(_this10.request({
1628
+ path: "/v2/accounts/{accountId}/uploads/url".replace("{".concat("accountId", "}"),
1629
+ // @ts-ignore
1630
+ _this10.encodeParam("accountId", params.accountId)),
1631
+ method: "POST",
1632
+ headers: headers,
1633
+ query: query,
1634
+ body: params.uploadFromUrlRequest
1635
+ }, undefined, [][0]), function (response) {
1636
+ return UploadApi_await(new JSONApiResponse(response).value());
1637
+ });
1638
+ } catch (e) {
1639
+ return Promise.reject(e);
1640
+ }
1641
+ }
1642
+ }]);
1643
+ return UploadApi;
1644
+ }(BaseAPI);
1645
+ ;// CONCATENATED MODULE: ./src/public/shared/generated/apis/index.ts
1646
+ /* tslint:disable */
1647
+ /* eslint-disable */
1648
+
1649
+
1650
+
1651
+
1652
+ ;// CONCATENATED MODULE: ./src/public/shared/generated/index.ts
1653
+ /* tslint:disable */
1654
+ /* eslint-disable */
1655
+
1656
+
1657
+
1658
+ ;// CONCATENATED MODULE: ./src/public/shared/CommonTypes.ts
1659
+ /**
1660
+ * Workaround for tsc aliases, where we cannot export implementation-less modules in our dists.
1661
+ */
1662
+ var CommonTypesNoOp = false;
1663
+ ;// CONCATENATED MODULE: ./src/private/TypeUtils.ts
1664
+ function assertUnreachable(x) {
1665
+ throw new Error("Didn't expect to get here: ".concat(JSON.stringify(x)));
1666
+ }
1667
+ function isDefinedEntry(object) {
1668
+ return object[1] !== undefined && object[1] !== null;
1669
+ }
1670
+ ;// CONCATENATED MODULE: ./src/public/shared/UrlBuilder.ts
1671
+ function UrlBuilder_typeof(obj) { "@babel/helpers - typeof"; return UrlBuilder_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; }, UrlBuilder_typeof(obj); }
1672
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
1673
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1674
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
1675
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1676
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1677
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1678
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1679
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
1680
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
1681
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1682
+ function UrlBuilder_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1683
+ function UrlBuilder_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, UrlBuilder_toPropertyKey(descriptor.key), descriptor); } }
1684
+ function UrlBuilder_createClass(Constructor, protoProps, staticProps) { if (protoProps) UrlBuilder_defineProperties(Constructor.prototype, protoProps); if (staticProps) UrlBuilder_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
1685
+ function UrlBuilder_toPropertyKey(arg) { var key = UrlBuilder_toPrimitive(arg, "string"); return UrlBuilder_typeof(key) === "symbol" ? key : String(key); }
1686
+ function UrlBuilder_toPrimitive(input, hint) { if (UrlBuilder_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (UrlBuilder_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1687
+
1688
+
1689
+ var UrlBuilder = /*#__PURE__*/function () {
1690
+ function UrlBuilder() {
1691
+ UrlBuilder_classCallCheck(this, UrlBuilder);
1692
+ }
1693
+ UrlBuilder_createClass(UrlBuilder, null, [{
1694
+ key: "url",
1695
+ value:
1696
+ /**
1697
+ * Builds a URL to either a raw file or a transformed file.
1698
+ *
1699
+ * Example 1) Getting a publicly-accessible raw file URL:
1700
+ *
1701
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg" })
1702
+ *
1703
+ * Example 2) Getting a publicly-accessible image URL, resized to 500x500:
1704
+ *
1705
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } } } })
1706
+ *
1707
+ * Example 3) Getting a privately-accessible image URL, resized to 500x500 (requires 'AuthManager.beginAuthSession' to be called before accessing the URL):
1708
+ *
1709
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } }, auth: true } })
1710
+ *
1711
+ * Example 4) Getting a publicly-accessible image URL, resized using a transformation preset called "thumbnail" that was created manually in the Bytescale Dashboard:
1712
+ *
1713
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "preset", preset: "thumbnail" } } })
1714
+ */
1715
+ function url(params) {
1716
+ var _a;
1717
+ return ((_a = params.options) === null || _a === void 0 ? void 0 : _a.transformation) === undefined ? this.raw(params) : this.transformation(params, params.options);
1718
+ }
1719
+ }, {
1720
+ key: "raw",
1721
+ value: function raw(params) {
1722
+ var _a;
1723
+ var baseUrl = this.getBaseUrl(params, "raw");
1724
+ var commonParams = this.getCommonQueryParams((_a = params.options) !== null && _a !== void 0 ? _a : {});
1725
+ return this.addQueryParams(baseUrl, commonParams);
1726
+ }
1727
+ }, {
1728
+ key: "transformation",
1729
+ value: function transformation(params, trans) {
1730
+ var _a;
1731
+ var baseUrl = this.getBaseUrl(params, trans.transformation === "preset" ? trans.transformationPreset : trans.transformation);
1732
+ var transParams = trans.transformation === "preset" ? [] : this.getTransformationParams(trans);
1733
+ var commonParams = this.getCommonQueryParams((_a = params.options) !== null && _a !== void 0 ? _a : {});
1734
+ var transCommonParams = this.getCommonTransformationQueryParams(trans);
1735
+ // This format puts "artifact" at the end, which isn't required, but is convention.
1736
+ return this.addQueryParams(baseUrl, [].concat(_toConsumableArray(transParams), _toConsumableArray(commonParams), _toConsumableArray(transCommonParams)));
1737
+ }
1738
+ }, {
1739
+ key: "getBaseUrl",
1740
+ value: function getBaseUrl(params, prefix) {
1741
+ var cdnUrl = BytescaleApiClientConfigUtils.defaultCdnUrl;
1742
+ return "".concat(cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
1743
+ }
1744
+ }, {
1745
+ key: "getCommonTransformationQueryParams",
1746
+ value: function getCommonTransformationQueryParams(trans) {
1747
+ return this.makeQueryParams(["cachePermanently", "large", "artifact"], {
1748
+ cachePermanently: "cache_perm"
1749
+ })(trans);
1750
+ }
1751
+ }, {
1752
+ key: "getCommonQueryParams",
1753
+ value: function getCommonQueryParams(params) {
1754
+ return this.makeQueryParams(["auth", "cache", "cacheTtl", "version", "forceDownloadPrompt"], {
1755
+ cacheTtl: "cache_ttl",
1756
+ forceDownloadPrompt: "download"
1757
+ })(params);
1758
+ }
1759
+ }, {
1760
+ key: "makeQueryParams",
1761
+ value: function makeQueryParams(keys, keyOverrides) {
1762
+ return function (data) {
1763
+ var result = [];
1764
+ keys.forEach(function (key) {
1765
+ var _a;
1766
+ var value = data[key];
1767
+ if (value !== undefined) {
1768
+ result.push([(_a = keyOverrides[key]) !== null && _a !== void 0 ? _a : key, value.toString()]);
1769
+ }
1770
+ });
1771
+ return result;
1772
+ };
1773
+ }
1774
+ }, {
1775
+ key: "getTransformationParams",
1776
+ value: function getTransformationParams(trans) {
1777
+ var params = trans.transformationParams;
1778
+ if (params === undefined) {
1779
+ return [];
1780
+ }
1781
+ var serializeObj = function serializeObj(obj) {
1782
+ return Object.entries(obj).filter(isDefinedEntry).map(function (_ref) {
1783
+ var _ref2 = _slicedToArray(_ref, 2),
1784
+ key = _ref2[0],
1785
+ value = _ref2[1];
1786
+ return [key, value.toString()];
1787
+ });
1788
+ };
1789
+ return Array.isArray(params) ? params.flatMap(serializeObj) : serializeObj(params);
1790
+ }
1791
+ }, {
1792
+ key: "addQueryParams",
1793
+ value: function addQueryParams(baseUrl, params) {
1794
+ if (params.length === 0) {
1795
+ return baseUrl;
1796
+ }
1797
+ return "".concat(baseUrl, "?").concat(params.map(function (_ref3) {
1798
+ var _ref4 = _slicedToArray(_ref3, 2),
1799
+ key = _ref4[0],
1800
+ value = _ref4[1];
1801
+ return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
1802
+ }).join("&"));
1803
+ }
1804
+ }]);
1805
+ return UrlBuilder;
1806
+ }();
1807
+ ;// CONCATENATED MODULE: ./src/public/shared/UrlBuilderTypes.ts
1808
+ /**
1809
+ * Workaround for tsc aliases, where we cannot export implementation-less modules in our dists.
1810
+ */
1811
+ var UrlBuilderTypesNoOp = false;
1812
+ ;// CONCATENATED MODULE: ./src/public/shared/index.ts
1813
+
1814
+
1815
+
1816
+
1817
+ ;// CONCATENATED MODULE: ./src/private/UploadManagerBase.ts
1818
+ function UploadManagerBase_typeof(obj) { "@babel/helpers - typeof"; return UploadManagerBase_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; }, UploadManagerBase_typeof(obj); }
1819
+ function _async(f) {
1820
+ return function () {
1821
+ for (var args = [], i = 0; i < arguments.length; i++) {
1822
+ args[i] = arguments[i];
1823
+ }
1824
+ try {
1825
+ return Promise.resolve(f.apply(this, args));
1826
+ } catch (e) {
1827
+ return Promise.reject(e);
1828
+ }
1829
+ };
1830
+ }
1831
+ function _invokeIgnored(body) {
1832
+ var result = body();
1833
+ if (result && result.then) {
1834
+ return result.then(UploadManagerBase_empty);
1835
+ }
1836
+ }
1837
+ function UploadManagerBase_settle(pact, state, value) {
1838
+ if (!pact.s) {
1839
+ if (value instanceof UploadManagerBase_Pact) {
1840
+ if (value.s) {
1841
+ if (state & 1) {
1842
+ state = value.s;
1843
+ }
1844
+ value = value.v;
1845
+ } else {
1846
+ value.o = UploadManagerBase_settle.bind(null, pact, state);
1847
+ return;
1848
+ }
1849
+ }
1850
+ if (value && value.then) {
1851
+ value.then(UploadManagerBase_settle.bind(null, pact, state), UploadManagerBase_settle.bind(null, pact, 2));
1852
+ return;
1853
+ }
1854
+ pact.s = state;
1855
+ pact.v = value;
1856
+ var observer = pact.o;
1857
+ if (observer) {
1858
+ observer(pact);
1859
+ }
1860
+ }
1861
+ }
1862
+ var UploadManagerBase_Pact = /*#__PURE__*/function () {
1863
+ function _Pact() {}
1864
+ _Pact.prototype.then = function (onFulfilled, onRejected) {
1865
+ var result = new _Pact();
1866
+ var state = this.s;
1867
+ if (state) {
1868
+ var callback = state & 1 ? onFulfilled : onRejected;
1869
+ if (callback) {
1870
+ try {
1871
+ UploadManagerBase_settle(result, 1, callback(this.v));
1872
+ } catch (e) {
1873
+ UploadManagerBase_settle(result, 2, e);
1874
+ }
1875
+ return result;
1876
+ } else {
1877
+ return this;
1878
+ }
1879
+ }
1880
+ this.o = function (_this) {
1881
+ try {
1882
+ var value = _this.v;
1883
+ if (_this.s & 1) {
1884
+ UploadManagerBase_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
1885
+ } else if (onRejected) {
1886
+ UploadManagerBase_settle(result, 1, onRejected(value));
1887
+ } else {
1888
+ UploadManagerBase_settle(result, 2, value);
1889
+ }
1890
+ } catch (e) {
1891
+ UploadManagerBase_settle(result, 2, e);
1892
+ }
1893
+ };
1894
+ return result;
1895
+ };
1896
+ return _Pact;
1897
+ }();
1898
+ function UploadManagerBase_isSettledPact(thenable) {
1899
+ return thenable instanceof UploadManagerBase_Pact && thenable.s & 1;
1900
+ }
1901
+ function UploadManagerBase_for(test, update, body) {
1902
+ var stage;
1903
+ for (;;) {
1904
+ var shouldContinue = test();
1905
+ if (UploadManagerBase_isSettledPact(shouldContinue)) {
1906
+ shouldContinue = shouldContinue.v;
1907
+ }
1908
+ if (!shouldContinue) {
1909
+ return result;
1910
+ }
1911
+ if (shouldContinue.then) {
1912
+ stage = 0;
1913
+ break;
1914
+ }
1915
+ var result = body();
1916
+ if (result && result.then) {
1917
+ if (UploadManagerBase_isSettledPact(result)) {
1918
+ result = result.s;
1919
+ } else {
1920
+ stage = 1;
1921
+ break;
1922
+ }
1923
+ }
1924
+ if (update) {
1925
+ var updateValue = update();
1926
+ if (updateValue && updateValue.then && !UploadManagerBase_isSettledPact(updateValue)) {
1927
+ stage = 2;
1928
+ break;
1929
+ }
1930
+ }
1931
+ }
1932
+ var pact = new UploadManagerBase_Pact();
1933
+ var reject = UploadManagerBase_settle.bind(null, pact, 2);
1934
+ (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
1935
+ return pact;
1936
+ function _resumeAfterBody(value) {
1937
+ result = value;
1938
+ do {
1939
+ if (update) {
1940
+ updateValue = update();
1941
+ if (updateValue && updateValue.then && !UploadManagerBase_isSettledPact(updateValue)) {
1942
+ updateValue.then(_resumeAfterUpdate).then(void 0, reject);
1943
+ return;
1944
+ }
1945
+ }
1946
+ shouldContinue = test();
1947
+ if (!shouldContinue || UploadManagerBase_isSettledPact(shouldContinue) && !shouldContinue.v) {
1948
+ UploadManagerBase_settle(pact, 1, result);
1949
+ return;
1950
+ }
1951
+ if (shouldContinue.then) {
1952
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
1953
+ return;
1954
+ }
1955
+ result = body();
1956
+ if (UploadManagerBase_isSettledPact(result)) {
1957
+ result = result.v;
1958
+ }
1959
+ } while (!result || !result.then);
1960
+ result.then(_resumeAfterBody).then(void 0, reject);
1961
+ }
1962
+ function _resumeAfterTest(shouldContinue) {
1963
+ if (shouldContinue) {
1964
+ result = body();
1965
+ if (result && result.then) {
1966
+ result.then(_resumeAfterBody).then(void 0, reject);
1967
+ } else {
1968
+ _resumeAfterBody(result);
1969
+ }
1970
+ } else {
1971
+ UploadManagerBase_settle(pact, 1, result);
1972
+ }
1973
+ }
1974
+ function _resumeAfterUpdate() {
1975
+ if (shouldContinue = test()) {
1976
+ if (shouldContinue.then) {
1977
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
1978
+ } else {
1979
+ _resumeAfterTest(shouldContinue);
1980
+ }
1981
+ } else {
1982
+ UploadManagerBase_settle(pact, 1, result);
1983
+ }
1984
+ }
1985
+ }
1986
+ function _continueIgnored(value) {
1987
+ if (value && value.then) {
1988
+ return value.then(UploadManagerBase_empty);
1989
+ }
1990
+ }
1991
+ function UploadManagerBase_toConsumableArray(arr) { return UploadManagerBase_arrayWithoutHoles(arr) || UploadManagerBase_iterableToArray(arr) || UploadManagerBase_unsupportedIterableToArray(arr) || UploadManagerBase_nonIterableSpread(); }
1992
+ function UploadManagerBase_nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1993
+ function UploadManagerBase_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return UploadManagerBase_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return UploadManagerBase_arrayLikeToArray(o, minLen); }
1994
+ function UploadManagerBase_iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
1995
+ function UploadManagerBase_arrayWithoutHoles(arr) { if (Array.isArray(arr)) return UploadManagerBase_arrayLikeToArray(arr); }
1996
+ function UploadManagerBase_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1997
+ function UploadManagerBase_empty() {}
1998
+ function UploadManagerBase_awaitIgnored(value, direct) {
1999
+ if (!direct) {
2000
+ return value && value.then ? value.then(UploadManagerBase_empty) : Promise.resolve();
2001
+ }
2002
+ }
2003
+ function UploadManagerBase_await(value, then, direct) {
2004
+ if (direct) {
2005
+ return then ? then(value) : value;
2006
+ }
2007
+ if (!value || !value.then) {
2008
+ value = Promise.resolve(value);
2009
+ }
2010
+ return then ? value.then(then) : value;
2011
+ }
2012
+ function UploadManagerBase_rethrow(thrown, value) {
2013
+ if (thrown) throw value;
2014
+ return value;
2015
+ }
2016
+ function UploadManagerBase_finallyRethrows(body, finalizer) {
2017
+ try {
2018
+ var result = body();
2019
+ } catch (e) {
2020
+ return finalizer(true, e);
2021
+ }
2022
+ if (result && result.then) {
2023
+ return result.then(finalizer.bind(null, false), finalizer.bind(null, true));
2024
+ }
2025
+ return finalizer(false, result);
2026
+ }
2027
+ function UploadManagerBase_continue(value, then) {
2028
+ return value && value.then ? value.then(then) : then(value);
2029
+ }
2030
+ function UploadManagerBase_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2031
+ function UploadManagerBase_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, UploadManagerBase_toPropertyKey(descriptor.key), descriptor); } }
2032
+ function UploadManagerBase_createClass(Constructor, protoProps, staticProps) { if (protoProps) UploadManagerBase_defineProperties(Constructor.prototype, protoProps); if (staticProps) UploadManagerBase_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2033
+ function UploadManagerBase_toPropertyKey(arg) { var key = UploadManagerBase_toPrimitive(arg, "string"); return UploadManagerBase_typeof(key) === "symbol" ? key : String(key); }
2034
+ function UploadManagerBase_toPrimitive(input, hint) { if (UploadManagerBase_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (UploadManagerBase_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2035
+
2036
+ /**
2037
+ * Methods common to UploadManagerNode and UploadManagerBrowser.
2038
+ */
2039
+ var UploadManagerBase = /*#__PURE__*/function () {
2040
+ function UploadManagerBase(config) {
2041
+ UploadManagerBase_classCallCheck(this, UploadManagerBase);
2042
+ this.config = config;
2043
+ this.stringMimeType = "text/plain";
2044
+ this.defaultMaxConcurrentUploadParts = 4;
2045
+ this.intervalMs = 500;
2046
+ this.uploadApi = new UploadApi(config);
2047
+ this.accountId = BytescaleApiClientConfigUtils.getAccountId(config);
2048
+ }
2049
+ UploadManagerBase_createClass(UploadManagerBase, [{
2050
+ key: "upload",
2051
+ value: function upload(request) {
2052
+ try {
2053
+ var _this2 = this;
2054
+ _this2.assertNotCancelled(request);
2055
+ var source = _this2.processUploadSource(request.data);
2056
+ var preUploadInfo = _this2.getPreUploadInfo(request, source);
2057
+ var bytesTotal = preUploadInfo.size;
2058
+ var makeOnProgressForPart = _this2.makeOnProgressForPartFactory(request, bytesTotal);
2059
+ var init = _this2.preUpload(source);
2060
+ // Raise initial progress event SYNCHRONOUSLY.
2061
+ if (request.onProgress !== undefined) {
2062
+ request.onProgress(_this2.makeProgressEvent(0, bytesTotal));
2063
+ }
2064
+ return UploadManagerBase_await(_this2.beginUpload(request, preUploadInfo), function (uploadInfo) {
2065
+ var partCount = uploadInfo.uploadParts.count;
2066
+ var parts = UploadManagerBase_toConsumableArray(Array(partCount).keys());
2067
+ var _this2$makeCancellati = _this2.makeCancellationMethods(),
2068
+ cancel = _this2$makeCancellati.cancel,
2069
+ addCancellationHandler = _this2$makeCancellati.addCancellationHandler;
2070
+ var intervalHandle = setInterval(_this2.onIntervalTick(request, cancel), _this2.intervalMs);
2071
+ return UploadManagerBase_continue(UploadManagerBase_finallyRethrows(function () {
2072
+ return UploadManagerBase_await(_this2.mapAsync(parts, preUploadInfo.maxConcurrentUploadParts, _async(function (part) {
2073
+ return _this2.uploadPart(request, source, part, uploadInfo, makeOnProgressForPart(), addCancellationHandler);
2074
+ })), function () {
2075
+ return UploadManagerBase_awaitIgnored(_this2.postUpload(init));
2076
+ });
2077
+ }, function (_wasThrown, _result) {
2078
+ clearInterval(intervalHandle);
2079
+ return UploadManagerBase_rethrow(_wasThrown, _result);
2080
+ }), function () {
2081
+ return uploadInfo.file;
2082
+ });
2083
+ });
2084
+ } catch (e) {
2085
+ return Promise.reject(e);
2086
+ }
2087
+ }
2088
+ }, {
2089
+ key: "getBlobInfo",
2090
+ value: function getBlobInfo(_ref) {
2091
+ var _ref$value = _ref.value,
2092
+ name = _ref$value.name,
2093
+ size = _ref$value.size,
2094
+ type = _ref$value.type;
2095
+ return {
2096
+ mime: type,
2097
+ size: size,
2098
+ originalFileName: name,
2099
+ maxConcurrentUploadParts: undefined
2100
+ };
2101
+ }
2102
+ }, {
2103
+ key: "onIntervalTick",
2104
+ value: function onIntervalTick(request, cancel) {
2105
+ var _this3 = this;
2106
+ return function () {
2107
+ if (_this3.isCancelled(request)) {
2108
+ cancel();
2109
+ }
2110
+ };
2111
+ }
2112
+ }, {
2113
+ key: "makeCancellationMethods",
2114
+ value: function makeCancellationMethods() {
2115
+ var cancellationHandlers = [];
2116
+ var addCancellationHandler = function addCancellationHandler(ca) {
2117
+ cancellationHandlers.push(ca);
2118
+ };
2119
+ var cancel = function cancel() {
2120
+ return cancellationHandlers.forEach(function (x) {
2121
+ return x();
2122
+ });
2123
+ };
2124
+ return {
2125
+ cancel: cancel,
2126
+ addCancellationHandler: addCancellationHandler
2127
+ };
2128
+ }
2129
+ /**
2130
+ * Returns a callback, which when called, returns a callback that can be used by ONE specific part to report its progress.
2131
+ */
2132
+ }, {
2133
+ key: "makeOnProgressForPartFactory",
2134
+ value: function makeOnProgressForPartFactory(request, bytesTotal) {
2135
+ var _this4 = this;
2136
+ var onProgress = request.onProgress;
2137
+ if (onProgress === undefined) {
2138
+ return function () {
2139
+ return function () {};
2140
+ };
2141
+ }
2142
+ var bytesSent = 0;
2143
+ return function () {
2144
+ var bytesSentForPart = 0;
2145
+ return function (bytesSentTotalForPart) {
2146
+ var delta = bytesSentTotalForPart - bytesSentForPart;
2147
+ bytesSentForPart += delta;
2148
+ bytesSent += delta;
2149
+ onProgress(_this4.makeProgressEvent(bytesSent, bytesTotal));
2150
+ };
2151
+ };
2152
+ }
2153
+ }, {
2154
+ key: "makeProgressEvent",
2155
+ value: function makeProgressEvent(bytesSent, bytesTotal) {
2156
+ return {
2157
+ bytesTotal: bytesTotal,
2158
+ bytesSent: bytesSent,
2159
+ progress: Math.round(bytesSent / bytesTotal * 100)
2160
+ };
2161
+ }
2162
+ }, {
2163
+ key: "assertNotCancelled",
2164
+ value: function assertNotCancelled(request) {
2165
+ if (this.isCancelled(request)) {
2166
+ throw new CancelledError();
2167
+ }
2168
+ }
2169
+ }, {
2170
+ key: "isCancelled",
2171
+ value: function isCancelled(request) {
2172
+ var _a;
2173
+ return ((_a = request.cancellationToken) === null || _a === void 0 ? void 0 : _a.isCancelled) === true;
2174
+ }
2175
+ }, {
2176
+ key: "beginUpload",
2177
+ value: function beginUpload(request, _ref2) {
2178
+ var size = _ref2.size,
2179
+ mime = _ref2.mime,
2180
+ originalFileName = _ref2.originalFileName;
2181
+ try {
2182
+ var _this6 = this;
2183
+ return UploadManagerBase_await(_this6.uploadApi.beginMultipartUpload({
2184
+ accountId: _this6.accountId,
2185
+ beginMultipartUploadRequest: {
2186
+ metadata: request.metadata,
2187
+ mime: mime,
2188
+ originalFileName: originalFileName,
2189
+ path: request.path,
2190
+ protocol: "1.1",
2191
+ size: size,
2192
+ tags: request.tags
2193
+ }
2194
+ }));
2195
+ } catch (e) {
2196
+ return Promise.reject(e);
2197
+ }
2198
+ }
2199
+ }, {
2200
+ key: "uploadPart",
2201
+ value: function uploadPart(request, source, partIndex, uploadInfo, onProgress, addCancellationHandler) {
2202
+ try {
2203
+ var _this8 = this;
2204
+ _this8.assertNotCancelled(request);
2205
+ return UploadManagerBase_await(_this8.getUploadPart(partIndex, uploadInfo), function (part) {
2206
+ _this8.assertNotCancelled(request);
2207
+ return UploadManagerBase_await(_this8.putUploadPart(part, source, onProgress, addCancellationHandler), function (etag) {
2208
+ _this8.assertNotCancelled(request);
2209
+ return UploadManagerBase_awaitIgnored(_this8.uploadApi.completeUploadPart({
2210
+ accountId: _this8.accountId,
2211
+ uploadId: uploadInfo.uploadId,
2212
+ uploadPartIndex: partIndex,
2213
+ completeUploadPartRequest: {
2214
+ etag: etag
2215
+ }
2216
+ }));
2217
+ });
2218
+ });
2219
+ } catch (e) {
2220
+ return Promise.reject(e);
2221
+ }
2222
+ }
2223
+ /**
2224
+ * Returns etag for the part.
2225
+ */
2226
+ }, {
2227
+ key: "putUploadPart",
2228
+ value: function putUploadPart(part, source, onProgress, addCancellationHandler) {
2229
+ try {
2230
+ var _this10 = this;
2231
+ var contentLength = part.range.inclusiveEnd + 1 - part.range.inclusiveStart;
2232
+ return UploadManagerBase_await(_this10.doPutUploadPart(part, contentLength, source, onProgress, addCancellationHandler), function (_ref3) {
2233
+ var status = _ref3.status,
2234
+ etag = _ref3.etag;
2235
+ if (Math.floor(status / 100) !== 2) {
2236
+ throw new Error("Failed to upload part (".concat(status, ")."));
2237
+ }
2238
+ if (etag === undefined) {
2239
+ throw new Error("No 'etag' response header found in upload part response.");
2240
+ }
2241
+ // Always send 100% for part, as some UploadManager implementations either don't report progress, or may not report the last chunk uploaded.
2242
+ onProgress(contentLength);
2243
+ return etag;
2244
+ });
2245
+ } catch (e) {
2246
+ return Promise.reject(e);
2247
+ }
2248
+ }
2249
+ }, {
2250
+ key: "getUploadPart",
2251
+ value: function getUploadPart(partIndex, uploadInfo) {
2252
+ try {
2253
+ var _this12 = this;
2254
+ if (partIndex === 0) {
2255
+ return uploadInfo.uploadParts.first;
2256
+ }
2257
+ return UploadManagerBase_await(_this12.uploadApi.getUploadPart({
2258
+ uploadId: uploadInfo.uploadId,
2259
+ accountId: _this12.accountId,
2260
+ uploadPartIndex: partIndex
2261
+ }));
2262
+ } catch (e) {
2263
+ return Promise.reject(e);
2264
+ }
2265
+ }
2266
+ }, {
2267
+ key: "getPreUploadInfo",
2268
+ value: function getPreUploadInfo(request, source) {
2269
+ var _a, _b, _c;
2270
+ var partial = this.getPreUploadInfoPartial(request, source);
2271
+ return {
2272
+ maxConcurrentUploadParts: (_a = partial.maxConcurrentUploadParts) !== null && _a !== void 0 ? _a : this.defaultMaxConcurrentUploadParts,
2273
+ originalFileName: (_b = request.originalFileName) !== null && _b !== void 0 ? _b : partial.originalFileName,
2274
+ mime: (_c = request.mime) !== null && _c !== void 0 ? _c : partial.mime,
2275
+ size: partial.size
2276
+ };
2277
+ }
2278
+ }, {
2279
+ key: "mapAsync",
2280
+ value: function mapAsync(items, concurrency, callback) {
2281
+ try {
2282
+ var workQueue = UploadManagerBase_toConsumableArray(items);
2283
+ return UploadManagerBase_awaitIgnored(Promise.all(UploadManagerBase_toConsumableArray(Array(concurrency).keys()).map(_async(function () {
2284
+ return _continueIgnored(UploadManagerBase_for(function () {
2285
+ return workQueue.length > 0;
2286
+ }, void 0, function () {
2287
+ var work = workQueue.shift(); // IMPORTANT: use 'shift' instead of 'pop' to ensure 'items' are processed in order when 'concurrency = 1'.
2288
+ return _invokeIgnored(function () {
2289
+ if (work !== undefined) {
2290
+ return UploadManagerBase_awaitIgnored(callback(work));
2291
+ }
2292
+ });
2293
+ }));
2294
+ }))));
2295
+ } catch (e) {
2296
+ return Promise.reject(e);
2297
+ }
2298
+ }
2299
+ }]);
2300
+ return UploadManagerBase;
2301
+ }();
2302
+ ;// CONCATENATED MODULE: ./src/private/UploadManagerBrowserWorkerBase.ts
2303
+ function UploadManagerBrowserWorkerBase_typeof(obj) { "@babel/helpers - typeof"; return UploadManagerBrowserWorkerBase_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; }, UploadManagerBrowserWorkerBase_typeof(obj); }
2304
+ function UploadManagerBrowserWorkerBase_await(value, then, direct) {
2305
+ if (direct) {
2306
+ return then ? then(value) : value;
2307
+ }
2308
+ if (!value || !value.then) {
2309
+ value = Promise.resolve(value);
2310
+ }
2311
+ return then ? value.then(then) : value;
2312
+ }
2313
+ function UploadManagerBrowserWorkerBase_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2314
+ function UploadManagerBrowserWorkerBase_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, UploadManagerBrowserWorkerBase_toPropertyKey(descriptor.key), descriptor); } }
2315
+ function UploadManagerBrowserWorkerBase_createClass(Constructor, protoProps, staticProps) { if (protoProps) UploadManagerBrowserWorkerBase_defineProperties(Constructor.prototype, protoProps); if (staticProps) UploadManagerBrowserWorkerBase_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2316
+ function UploadManagerBrowserWorkerBase_toPropertyKey(arg) { var key = UploadManagerBrowserWorkerBase_toPrimitive(arg, "string"); return UploadManagerBrowserWorkerBase_typeof(key) === "symbol" ? key : String(key); }
2317
+ function UploadManagerBrowserWorkerBase_toPrimitive(input, hint) { if (UploadManagerBrowserWorkerBase_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (UploadManagerBrowserWorkerBase_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2318
+ function UploadManagerBrowserWorkerBase_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) UploadManagerBrowserWorkerBase_setPrototypeOf(subClass, superClass); }
2319
+ function UploadManagerBrowserWorkerBase_setPrototypeOf(o, p) { UploadManagerBrowserWorkerBase_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return UploadManagerBrowserWorkerBase_setPrototypeOf(o, p); }
2320
+ function UploadManagerBrowserWorkerBase_createSuper(Derived) { var hasNativeReflectConstruct = UploadManagerBrowserWorkerBase_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = UploadManagerBrowserWorkerBase_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = UploadManagerBrowserWorkerBase_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return UploadManagerBrowserWorkerBase_possibleConstructorReturn(this, result); }; }
2321
+ function UploadManagerBrowserWorkerBase_possibleConstructorReturn(self, call) { if (call && (UploadManagerBrowserWorkerBase_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return UploadManagerBrowserWorkerBase_assertThisInitialized(self); }
2322
+ function UploadManagerBrowserWorkerBase_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2323
+ function UploadManagerBrowserWorkerBase_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2324
+ function UploadManagerBrowserWorkerBase_getPrototypeOf(o) { UploadManagerBrowserWorkerBase_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return UploadManagerBrowserWorkerBase_getPrototypeOf(o); }
2325
+
2326
+
2327
+ /**
2328
+ * The "browser" and "worker" runtimes support the same input types, but the former uses XHR and the latter uses Fetch.
2329
+ */
2330
+ var UploadManagerBrowserWorkerBase = /*#__PURE__*/function (_UploadManagerBase) {
2331
+ UploadManagerBrowserWorkerBase_inherits(UploadManagerBrowserWorkerBase, _UploadManagerBase);
2332
+ var _super = UploadManagerBrowserWorkerBase_createSuper(UploadManagerBrowserWorkerBase);
2333
+ function UploadManagerBrowserWorkerBase() {
2334
+ UploadManagerBrowserWorkerBase_classCallCheck(this, UploadManagerBrowserWorkerBase);
2335
+ return _super.apply(this, arguments);
2336
+ }
2337
+ UploadManagerBrowserWorkerBase_createClass(UploadManagerBrowserWorkerBase, [{
2338
+ key: "processUploadSource",
2339
+ value: function processUploadSource(data) {
2340
+ if (typeof data === "string") {
2341
+ // 'Blob' must be from 'global' (i.e. not imported) as we're in a browser context here, so is globally available.
2342
+ return {
2343
+ type: "Blob",
2344
+ value: new Blob([data], {
2345
+ type: this.stringMimeType
2346
+ })
2347
+ };
2348
+ }
2349
+ if (data.byteLength !== undefined) {
2350
+ return {
2351
+ type: "ArrayBuffer",
2352
+ value: data
2353
+ };
2354
+ }
2355
+ if (data.size !== undefined) {
2356
+ return {
2357
+ type: "Blob",
2358
+ value: data
2359
+ };
2360
+ }
2361
+ throw new Error("Unsupported type for 'data' parameter. Please provide a String, Blob, ArrayBuffer, or File object (from a file input element).");
2362
+ }
2363
+ }, {
2364
+ key: "getPreUploadInfoPartial",
2365
+ value: function getPreUploadInfoPartial(_request, data) {
2366
+ switch (data.type) {
2367
+ case "Blob":
2368
+ return this.getBlobInfo(data);
2369
+ case "ArrayBuffer":
2370
+ return {
2371
+ mime: undefined,
2372
+ size: data.value.byteLength,
2373
+ originalFileName: undefined,
2374
+ maxConcurrentUploadParts: undefined
2375
+ };
2376
+ default:
2377
+ assertUnreachable(data);
2378
+ }
2379
+ }
2380
+ }, {
2381
+ key: "preUpload",
2382
+ value: function preUpload(_source) {
2383
+ return undefined;
2384
+ }
2385
+ }, {
2386
+ key: "postUpload",
2387
+ value: function postUpload(_init) {
2388
+ return UploadManagerBrowserWorkerBase_await();
2389
+ } // NO-OP.
2390
+ }, {
2391
+ key: "getRequestBody",
2392
+ value: function getRequestBody(part, blob) {
2393
+ return part.range.inclusiveEnd === -1 ? new Blob() : blob.value.slice(part.range.inclusiveStart, part.range.inclusiveEnd + 1);
2394
+ }
2395
+ }]);
2396
+ return UploadManagerBrowserWorkerBase;
2397
+ }(UploadManagerBase);
2398
+ ;// CONCATENATED MODULE: ./src/private/UploadManagerFetchUtils.ts
2399
+ function UploadManagerFetchUtils_typeof(obj) { "@babel/helpers - typeof"; return UploadManagerFetchUtils_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; }, UploadManagerFetchUtils_typeof(obj); }
2400
+ function UploadManagerFetchUtils_await(value, then, direct) {
2401
+ if (direct) {
2402
+ return then ? then(value) : value;
2403
+ }
2404
+ if (!value || !value.then) {
2405
+ value = Promise.resolve(value);
2406
+ }
2407
+ return then ? value.then(then) : value;
2408
+ }
2409
+ function UploadManagerFetchUtils_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2410
+ function UploadManagerFetchUtils_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, UploadManagerFetchUtils_toPropertyKey(descriptor.key), descriptor); } }
2411
+ function UploadManagerFetchUtils_createClass(Constructor, protoProps, staticProps) { if (protoProps) UploadManagerFetchUtils_defineProperties(Constructor.prototype, protoProps); if (staticProps) UploadManagerFetchUtils_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2412
+ function UploadManagerFetchUtils_toPropertyKey(arg) { var key = UploadManagerFetchUtils_toPrimitive(arg, "string"); return UploadManagerFetchUtils_typeof(key) === "symbol" ? key : String(key); }
2413
+ function UploadManagerFetchUtils_toPrimitive(input, hint) { if (UploadManagerFetchUtils_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (UploadManagerFetchUtils_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2414
+
2415
+ var UploadManagerFetchUtils = /*#__PURE__*/function () {
2416
+ function UploadManagerFetchUtils() {
2417
+ UploadManagerFetchUtils_classCallCheck(this, UploadManagerFetchUtils);
2418
+ }
2419
+ UploadManagerFetchUtils_createClass(UploadManagerFetchUtils, null, [{
2420
+ key: "doPutUploadPart",
2421
+ value: function doPutUploadPart(config, part, content, contentLength, addCancellationHandler) {
2422
+ try {
2423
+ var _a;
2424
+ var fetchApi = BytescaleApiClientConfigUtils.getFetchApi(config);
2425
+ // Configure cancellation:
2426
+ var controller = new AbortController();
2427
+ var signal = controller.signal;
2428
+ addCancellationHandler(function () {
2429
+ return controller.abort();
2430
+ });
2431
+ var headers = {
2432
+ // Required to prevent fetch using "Transfer-Encoding: Chunked" when body is a stream.
2433
+ "content-length": contentLength.toString()
2434
+ };
2435
+ return UploadManagerFetchUtils_await(fetchApi(part.uploadUrl, {
2436
+ method: "PUT",
2437
+ headers: headers,
2438
+ body: content,
2439
+ signal: signal,
2440
+ cache: "no-store" // Required for Next.js's Fetch implementation, which caches POST/PUT requests by default.
2441
+ }), function (response) {
2442
+ return {
2443
+ etag: (_a = response.headers.get("etag")) !== null && _a !== void 0 ? _a : undefined,
2444
+ status: response.status
2445
+ };
2446
+ });
2447
+ } catch (e) {
2448
+ return Promise.reject(e);
2449
+ }
2450
+ }
2451
+ }]);
2452
+ return UploadManagerFetchUtils;
2453
+ }();
2454
+ ;// CONCATENATED MODULE: ./src/public/worker/UploadManagerWorker.ts
2455
+ function UploadManagerWorker_typeof(obj) { "@babel/helpers - typeof"; return UploadManagerWorker_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; }, UploadManagerWorker_typeof(obj); }
2456
+ function UploadManagerWorker_await(value, then, direct) {
2457
+ if (direct) {
2458
+ return then ? then(value) : value;
2459
+ }
2460
+ if (!value || !value.then) {
2461
+ value = Promise.resolve(value);
2462
+ }
2463
+ return then ? value.then(then) : value;
2464
+ }
2465
+ function UploadManagerWorker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2466
+ function UploadManagerWorker_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, UploadManagerWorker_toPropertyKey(descriptor.key), descriptor); } }
2467
+ function UploadManagerWorker_createClass(Constructor, protoProps, staticProps) { if (protoProps) UploadManagerWorker_defineProperties(Constructor.prototype, protoProps); if (staticProps) UploadManagerWorker_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2468
+ function UploadManagerWorker_toPropertyKey(arg) { var key = UploadManagerWorker_toPrimitive(arg, "string"); return UploadManagerWorker_typeof(key) === "symbol" ? key : String(key); }
2469
+ function UploadManagerWorker_toPrimitive(input, hint) { if (UploadManagerWorker_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (UploadManagerWorker_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2470
+ function UploadManagerWorker_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) UploadManagerWorker_setPrototypeOf(subClass, superClass); }
2471
+ function UploadManagerWorker_setPrototypeOf(o, p) { UploadManagerWorker_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return UploadManagerWorker_setPrototypeOf(o, p); }
2472
+ function UploadManagerWorker_createSuper(Derived) { var hasNativeReflectConstruct = UploadManagerWorker_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = UploadManagerWorker_getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = UploadManagerWorker_getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return UploadManagerWorker_possibleConstructorReturn(this, result); }; }
2473
+ function UploadManagerWorker_possibleConstructorReturn(self, call) { if (call && (UploadManagerWorker_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return UploadManagerWorker_assertThisInitialized(self); }
2474
+ function UploadManagerWorker_assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2475
+ function UploadManagerWorker_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2476
+ function UploadManagerWorker_getPrototypeOf(o) { UploadManagerWorker_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return UploadManagerWorker_getPrototypeOf(o); }
2477
+
2478
+
2479
+ var UploadManager = /*#__PURE__*/function (_UploadManagerBrowser) {
2480
+ UploadManagerWorker_inherits(UploadManager, _UploadManagerBrowser);
2481
+ var _super = UploadManagerWorker_createSuper(UploadManager);
2482
+ function UploadManager() {
2483
+ UploadManagerWorker_classCallCheck(this, UploadManager);
2484
+ return _super.apply(this, arguments);
2485
+ }
2486
+ UploadManagerWorker_createClass(UploadManager, [{
2487
+ key: "doPutUploadPart",
2488
+ value: function doPutUploadPart(part, contentLength, source, _onProgress, addCancellationHandler) {
2489
+ try {
2490
+ var _this2 = this;
2491
+ return UploadManagerWorker_await(UploadManagerFetchUtils.doPutUploadPart(_this2.config, part, _this2.getRequestBody(part, source), contentLength, addCancellationHandler));
2492
+ } catch (e) {
2493
+ return Promise.reject(e);
2494
+ }
2495
+ }
2496
+ }]);
2497
+ return UploadManager;
2498
+ }(UploadManagerBrowserWorkerBase);
2499
+ ;// CONCATENATED MODULE: ./src/private/EnvChecker.ts
2500
+ function EnvChecker_typeof(obj) { "@babel/helpers - typeof"; return EnvChecker_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; }, EnvChecker_typeof(obj); }
2501
+ function EnvChecker_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2502
+ function EnvChecker_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, EnvChecker_toPropertyKey(descriptor.key), descriptor); } }
2503
+ function EnvChecker_createClass(Constructor, protoProps, staticProps) { if (protoProps) EnvChecker_defineProperties(Constructor.prototype, protoProps); if (staticProps) EnvChecker_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2504
+ function EnvChecker_toPropertyKey(arg) { var key = EnvChecker_toPrimitive(arg, "string"); return EnvChecker_typeof(key) === "symbol" ? key : String(key); }
2505
+ function EnvChecker_toPrimitive(input, hint) { if (EnvChecker_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (EnvChecker_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2506
+ var EnvChecker = /*#__PURE__*/function () {
2507
+ function EnvChecker() {
2508
+ EnvChecker_classCallCheck(this, EnvChecker);
2509
+ }
2510
+ EnvChecker_createClass(EnvChecker, null, [{
2511
+ key: "isBrowser",
2512
+ value: function isBrowser() {
2513
+ return typeof window !== "undefined";
2514
+ }
2515
+ }, {
2516
+ key: "methodRequiresBrowser",
2517
+ value: function methodRequiresBrowser(methodName) {
2518
+ if (!EnvChecker.isBrowser()) {
2519
+ return new Error("You must call '".concat(methodName, "' in your client-side code. (You have called it in your server-side code.)"));
2520
+ }
2521
+ return new Error("The '".concat(methodName, "' method cannot be called because you have bundled a non-browser implementation of the Bytescale JavaScript SDK into your client-side code. Please ensure your bundling tool (Webpack, Rollup, etc.) is honouring the \"browser\" field of the \"package.json\" file for this package, as this will allow the browser implementation of the Bytescale JavaScript SDK to be included in your client-side code."));
2522
+ }
2523
+ }]);
2524
+ return EnvChecker;
2525
+ }();
2526
+ ;// CONCATENATED MODULE: ./src/public/node/AuthManagerNode.ts
2527
+ function AuthManagerNode_typeof(obj) { "@babel/helpers - typeof"; return AuthManagerNode_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; }, AuthManagerNode_typeof(obj); }
2528
+ function AuthManagerNode_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2529
+ function AuthManagerNode_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, AuthManagerNode_toPropertyKey(descriptor.key), descriptor); } }
2530
+ function AuthManagerNode_createClass(Constructor, protoProps, staticProps) { if (protoProps) AuthManagerNode_defineProperties(Constructor.prototype, protoProps); if (staticProps) AuthManagerNode_defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
2531
+ function AuthManagerNode_toPropertyKey(arg) { var key = AuthManagerNode_toPrimitive(arg, "string"); return AuthManagerNode_typeof(key) === "symbol" ? key : String(key); }
2532
+ function AuthManagerNode_toPrimitive(input, hint) { if (AuthManagerNode_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (AuthManagerNode_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2533
+
2534
+ var AuthManagerImpl = /*#__PURE__*/function () {
2535
+ function AuthManagerImpl() {
2536
+ AuthManagerNode_classCallCheck(this, AuthManagerImpl);
2537
+ }
2538
+ AuthManagerNode_createClass(AuthManagerImpl, [{
2539
+ key: "beginAuthSession",
2540
+ value: function beginAuthSession(_params) {
2541
+ try {
2542
+ throw EnvChecker.methodRequiresBrowser("beginAuthSession");
2543
+ } catch (e) {
2544
+ return Promise.reject(e);
2545
+ }
2546
+ }
2547
+ }, {
2548
+ key: "endAuthSession",
2549
+ value: function endAuthSession() {
2550
+ try {
2551
+ throw EnvChecker.methodRequiresBrowser("endAuthSession");
2552
+ } catch (e) {
2553
+ return Promise.reject(e);
2554
+ }
2555
+ }
2556
+ }, {
2557
+ key: "isAuthSessionActive",
2558
+ value: function isAuthSessionActive() {
2559
+ return false;
2560
+ }
2561
+ }]);
2562
+ return AuthManagerImpl;
2563
+ }();
2564
+ /**
2565
+ * Alternative way of implementing a static class (i.e. all methods static). We do this so we can use a interface on the class (interfaces can't define static methods).
2566
+ */
2567
+ var AuthManager = new AuthManagerImpl();
2568
+ ;// CONCATENATED MODULE: ./src/public/worker/index.ts
2569
+
2570
+
2571
+ ;// CONCATENATED MODULE: ./src/index.worker.ts
2572
+ /* tslint:disable */
2573
+ /* eslint-disable */
2574
+
2575
+
2576
+ module.exports = __lib_exports__;
2577
+ /******/ })()
2578
+ ;