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