@bytescale/sdk 3.0.0-alpha.1 → 3.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/cjs/main.js +73 -51
- package/dist/node/cjs/main.js +70 -40
- package/dist/node/esm/main.mjs +72 -42
- package/dist/types/public/shared/UrlBuilder.d.ts +1 -0
- package/dist/types/public/shared/UrlBuilderTypes.d.ts +65 -65
- package/dist/types/public/shared/generated/apis/FileApi.d.ts +104 -3
- package/dist/types/public/shared/generated/apis/FolderApi.d.ts +0 -3
- package/dist/types/public/shared/generated/apis/JobApi.d.ts +0 -3
- package/dist/types/public/shared/generated/apis/UploadApi.d.ts +6 -3
- package/dist/types/public/shared/generated/models/index.d.ts +5 -7
- package/dist/types/public/shared/generated/runtime.d.ts +8 -6
- package/package.json +1 -1
- package/tests/UrlBuilder.test.ts +31 -36
package/dist/node/esm/main.mjs
CHANGED
|
@@ -51,7 +51,7 @@ __lib_require__.d(__lib_exports__, {
|
|
|
51
51
|
"AuthManager": function() { return /* reexport */ AuthManager; },
|
|
52
52
|
"BaseAPI": function() { return /* reexport */ BaseAPI; },
|
|
53
53
|
"BinaryResult": function() { return /* reexport */ BinaryResult; },
|
|
54
|
-
"
|
|
54
|
+
"BytescaleApiClientConfigUtils": function() { return /* reexport */ BytescaleApiClientConfigUtils; },
|
|
55
55
|
"BytescaleApiError": function() { return /* reexport */ BytescaleApiError; },
|
|
56
56
|
"CancelledError": function() { return /* reexport */ CancelledError; },
|
|
57
57
|
"CommonTypesNoOp": function() { return /* reexport */ CommonTypesNoOp; },
|
|
@@ -127,21 +127,21 @@ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoPr
|
|
|
127
127
|
function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
|
|
128
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
129
|
|
|
130
|
-
var
|
|
131
|
-
function
|
|
132
|
-
runtime_classCallCheck(this,
|
|
130
|
+
var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
|
|
131
|
+
function BytescaleApiClientConfigUtils() {
|
|
132
|
+
runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
|
|
133
133
|
}
|
|
134
|
-
runtime_createClass(
|
|
134
|
+
runtime_createClass(BytescaleApiClientConfigUtils, null, [{
|
|
135
135
|
key: "getApiUrl",
|
|
136
136
|
value: function getApiUrl(config) {
|
|
137
137
|
var _a;
|
|
138
|
-
return (_a = config.apiUrl) !== null && _a !== void 0 ? _a :
|
|
138
|
+
return (_a = config.apiUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultApiUrl;
|
|
139
139
|
}
|
|
140
140
|
}, {
|
|
141
141
|
key: "getCdnUrl",
|
|
142
142
|
value: function getCdnUrl(config) {
|
|
143
143
|
var _a;
|
|
144
|
-
return (_a = config.cdnUrl) !== null && _a !== void 0 ? _a :
|
|
144
|
+
return (_a = config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultCdnUrl;
|
|
145
145
|
}
|
|
146
146
|
}, {
|
|
147
147
|
key: "getFetchApi",
|
|
@@ -149,11 +149,48 @@ var BytescaleApiClientConfigResolver = /*#__PURE__*/function () {
|
|
|
149
149
|
var _a;
|
|
150
150
|
return (_a = config.fetchApi) !== null && _a !== void 0 ? _a : fetch;
|
|
151
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
|
+
}
|
|
152
186
|
}]);
|
|
153
|
-
return
|
|
187
|
+
return BytescaleApiClientConfigUtils;
|
|
154
188
|
}();
|
|
155
|
-
|
|
156
|
-
|
|
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
|
|
157
194
|
/**
|
|
158
195
|
* This is the base class for all generated API classes.
|
|
159
196
|
*/
|
|
@@ -161,6 +198,7 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
161
198
|
function BaseAPI(config) {
|
|
162
199
|
runtime_classCallCheck(this, BaseAPI);
|
|
163
200
|
this.config = config;
|
|
201
|
+
BytescaleApiClientConfigUtils.validate(config);
|
|
164
202
|
}
|
|
165
203
|
runtime_createClass(BaseAPI, [{
|
|
166
204
|
key: "request",
|
|
@@ -175,7 +213,7 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
175
213
|
}
|
|
176
214
|
// Key: any possible value for 'baseUrlOverride'
|
|
177
215
|
// Value: user-overridden value for that base URL from the config.
|
|
178
|
-
var nonDefaultBasePaths = _defineProperty({},
|
|
216
|
+
var nonDefaultBasePaths = _defineProperty({}, BytescaleApiClientConfigUtils.defaultCdnUrl, BytescaleApiClientConfigUtils.getCdnUrl(_this2.config));
|
|
179
217
|
return _await(_this2.createFetchParams(context, initOverrides, baseUrlOverride === undefined ? undefined : (_b = nonDefaultBasePaths[baseUrlOverride]) !== null && _b !== void 0 ? _b : baseUrlOverride), function (_ref) {
|
|
180
218
|
var url = _ref.url,
|
|
181
219
|
init = _ref.init;
|
|
@@ -197,7 +235,7 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
197
235
|
var _a, _b;
|
|
198
236
|
var response;
|
|
199
237
|
return _continue(_catch(function () {
|
|
200
|
-
return _await(
|
|
238
|
+
return _await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, init), function (_BytescaleApiClientCo) {
|
|
201
239
|
response = _BytescaleApiClientCo;
|
|
202
240
|
});
|
|
203
241
|
}, function (e) {
|
|
@@ -251,7 +289,7 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
251
289
|
value: function createFetchParams(context, initOverrides, baseUrlOverride) {
|
|
252
290
|
try {
|
|
253
291
|
var _this6 = this;
|
|
254
|
-
var url = (baseUrlOverride !== null && baseUrlOverride !== void 0 ? baseUrlOverride :
|
|
292
|
+
var url = (baseUrlOverride !== null && baseUrlOverride !== void 0 ? baseUrlOverride : BytescaleApiClientConfigUtils.getApiUrl(_this6.config)) + context.path;
|
|
255
293
|
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
256
294
|
// only add the querystring to the URL if there are query parameters.
|
|
257
295
|
// this is done to avoid urls ending with a "?" character which buggy webservers
|
|
@@ -295,9 +333,6 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
295
333
|
}]);
|
|
296
334
|
return BaseAPI;
|
|
297
335
|
}();
|
|
298
|
-
BaseAPI.specialApiKeys = ["free", "demo"];
|
|
299
|
-
BaseAPI.specialApiKeyAccountId = "W142hJk";
|
|
300
|
-
BaseAPI.accountIdLength = 7; // Sync with: upload/shared/**/AccountIdUtils
|
|
301
336
|
var CancelledError = /*#__PURE__*/function (_Error) {
|
|
302
337
|
_inherits(CancelledError, _Error);
|
|
303
338
|
var _super = _createSuper(CancelledError);
|
|
@@ -455,9 +490,6 @@ function FileApi_getPrototypeOf(o) { FileApi_getPrototypeOf = Object.setPrototyp
|
|
|
455
490
|
*/
|
|
456
491
|
// @ts-ignore
|
|
457
492
|
|
|
458
|
-
/**
|
|
459
|
-
*
|
|
460
|
-
*/
|
|
461
493
|
var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
|
|
462
494
|
FileApi_inherits(FileApi, _runtime$BaseAPI);
|
|
463
495
|
var _super = FileApi_createSuper(FileApi);
|
|
@@ -756,9 +788,6 @@ function FolderApi_getPrototypeOf(o) { FolderApi_getPrototypeOf = Object.setProt
|
|
|
756
788
|
*/
|
|
757
789
|
// @ts-ignore
|
|
758
790
|
|
|
759
|
-
/**
|
|
760
|
-
*
|
|
761
|
-
*/
|
|
762
791
|
var FolderApi = /*#__PURE__*/function (_runtime$BaseAPI) {
|
|
763
792
|
FolderApi_inherits(FolderApi, _runtime$BaseAPI);
|
|
764
793
|
var _super = FolderApi_createSuper(FolderApi);
|
|
@@ -1016,9 +1045,6 @@ function JobApi_getPrototypeOf(o) { JobApi_getPrototypeOf = Object.setPrototypeO
|
|
|
1016
1045
|
*/
|
|
1017
1046
|
// @ts-ignore
|
|
1018
1047
|
|
|
1019
|
-
/**
|
|
1020
|
-
*
|
|
1021
|
-
*/
|
|
1022
1048
|
var JobApi = /*#__PURE__*/function (_runtime$BaseAPI) {
|
|
1023
1049
|
JobApi_inherits(JobApi, _runtime$BaseAPI);
|
|
1024
1050
|
var _super = JobApi_createSuper(JobApi);
|
|
@@ -1151,9 +1177,6 @@ function UploadApi_getPrototypeOf(o) { UploadApi_getPrototypeOf = Object.setProt
|
|
|
1151
1177
|
*/
|
|
1152
1178
|
// @ts-ignore
|
|
1153
1179
|
|
|
1154
|
-
/**
|
|
1155
|
-
*
|
|
1156
|
-
*/
|
|
1157
1180
|
var UploadApi = /*#__PURE__*/function (_runtime$BaseAPI) {
|
|
1158
1181
|
UploadApi_inherits(UploadApi, _runtime$BaseAPI);
|
|
1159
1182
|
var _super = UploadApi_createSuper(UploadApi);
|
|
@@ -1349,7 +1372,7 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1349
1372
|
function UrlBuilder(config) {
|
|
1350
1373
|
UrlBuilder_classCallCheck(this, UrlBuilder);
|
|
1351
1374
|
var _a;
|
|
1352
|
-
this.cdnUrl = (_a = config === null || config === void 0 ? void 0 : config.cdnUrl) !== null && _a !== void 0 ? _a :
|
|
1375
|
+
this.cdnUrl = (_a = config === null || config === void 0 ? void 0 : config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultCdnUrl;
|
|
1353
1376
|
}
|
|
1354
1377
|
/**
|
|
1355
1378
|
* Builds a URL to either a raw file or a transformed file.
|
|
@@ -1374,7 +1397,7 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1374
1397
|
key: "url",
|
|
1375
1398
|
value: function url(params) {
|
|
1376
1399
|
var _a;
|
|
1377
|
-
return ((_a = params.options) === null || _a === void 0 ? void 0 : _a.transformation) === undefined ? this.raw(params) : this.transformation(params, params.options
|
|
1400
|
+
return ((_a = params.options) === null || _a === void 0 ? void 0 : _a.transformation) === undefined ? this.raw(params) : this.transformation(params, params.options);
|
|
1378
1401
|
}
|
|
1379
1402
|
}, {
|
|
1380
1403
|
key: "raw",
|
|
@@ -1388,18 +1411,25 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1388
1411
|
key: "transformation",
|
|
1389
1412
|
value: function transformation(params, trans) {
|
|
1390
1413
|
var _a;
|
|
1391
|
-
var baseUrl = this.getBaseUrl(params, trans.
|
|
1392
|
-
var transParams = this.getTransformationParams(trans
|
|
1393
|
-
cachePermanently: "cache_perm"
|
|
1394
|
-
});
|
|
1414
|
+
var baseUrl = this.getBaseUrl(params, trans.transformation === "preset" ? trans.transformationPreset : trans.transformation);
|
|
1415
|
+
var transParams = trans.transformation === "preset" ? [] : this.getTransformationParams(trans);
|
|
1395
1416
|
var commonParams = this.getCommonQueryParams((_a = params.options) !== null && _a !== void 0 ? _a : {});
|
|
1396
|
-
|
|
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)));
|
|
1397
1420
|
}
|
|
1398
1421
|
}, {
|
|
1399
1422
|
key: "getBaseUrl",
|
|
1400
1423
|
value: function getBaseUrl(params, prefix) {
|
|
1401
1424
|
return "".concat(this.cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
|
|
1402
1425
|
}
|
|
1426
|
+
}, {
|
|
1427
|
+
key: "getCommonTransformationQueryParams",
|
|
1428
|
+
value: function getCommonTransformationQueryParams(trans) {
|
|
1429
|
+
return this.makeQueryParams(["cachePermanently", "large", "artifact"], {
|
|
1430
|
+
cachePermanently: "cache_perm"
|
|
1431
|
+
})(trans);
|
|
1432
|
+
}
|
|
1403
1433
|
}, {
|
|
1404
1434
|
key: "getCommonQueryParams",
|
|
1405
1435
|
value: function getCommonQueryParams(params) {
|
|
@@ -1425,8 +1455,9 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1425
1455
|
}
|
|
1426
1456
|
}, {
|
|
1427
1457
|
key: "getTransformationParams",
|
|
1428
|
-
value: function getTransformationParams(trans
|
|
1429
|
-
|
|
1458
|
+
value: function getTransformationParams(trans) {
|
|
1459
|
+
var params = trans.transformationParams;
|
|
1460
|
+
if (params === undefined) {
|
|
1430
1461
|
return [];
|
|
1431
1462
|
}
|
|
1432
1463
|
var serializeObj = function serializeObj(obj) {
|
|
@@ -1434,11 +1465,10 @@ var UrlBuilder = /*#__PURE__*/function () {
|
|
|
1434
1465
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
1435
1466
|
key = _ref2[0],
|
|
1436
1467
|
value = _ref2[1];
|
|
1437
|
-
|
|
1438
|
-
return [(_a = keyRewrites[key]) !== null && _a !== void 0 ? _a : key, value.toString()];
|
|
1468
|
+
return [key, value.toString()];
|
|
1439
1469
|
});
|
|
1440
1470
|
};
|
|
1441
|
-
return Array.isArray(
|
|
1471
|
+
return Array.isArray(params) ? params.flatMap(serializeObj) : serializeObj(params);
|
|
1442
1472
|
}
|
|
1443
1473
|
}, {
|
|
1444
1474
|
key: "addQueryParams",
|
|
@@ -2624,7 +2654,7 @@ var AuthManager = /*#__PURE__*/function () {
|
|
|
2624
2654
|
var __lib_exports__AuthManager = __lib_exports__.AuthManager;
|
|
2625
2655
|
var __lib_exports__BaseAPI = __lib_exports__.BaseAPI;
|
|
2626
2656
|
var __lib_exports__BinaryResult = __lib_exports__.BinaryResult;
|
|
2627
|
-
var
|
|
2657
|
+
var __lib_exports__BytescaleApiClientConfigUtils = __lib_exports__.BytescaleApiClientConfigUtils;
|
|
2628
2658
|
var __lib_exports__BytescaleApiError = __lib_exports__.BytescaleApiError;
|
|
2629
2659
|
var __lib_exports__CancelledError = __lib_exports__.CancelledError;
|
|
2630
2660
|
var __lib_exports__CommonTypesNoOp = __lib_exports__.CommonTypesNoOp;
|
|
@@ -2638,4 +2668,4 @@ var __lib_exports__UrlBuilder = __lib_exports__.UrlBuilder;
|
|
|
2638
2668
|
var __lib_exports__UrlBuilderTypesNoOp = __lib_exports__.UrlBuilderTypesNoOp;
|
|
2639
2669
|
var __lib_exports__VoidApiResponse = __lib_exports__.VoidApiResponse;
|
|
2640
2670
|
var __lib_exports__querystring = __lib_exports__.querystring;
|
|
2641
|
-
export { __lib_exports__AuthManager as AuthManager, __lib_exports__BaseAPI as BaseAPI, __lib_exports__BinaryResult as BinaryResult,
|
|
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 };
|
|
@@ -26,7 +26,10 @@ export interface UrlBuilderParams {
|
|
|
26
26
|
*/
|
|
27
27
|
options?: UrlBuilderOptions;
|
|
28
28
|
}
|
|
29
|
-
export
|
|
29
|
+
export declare type UrlBuilderOptions = UrlBuilderOptionsRaw | UrlBuilderTransformationOptions;
|
|
30
|
+
export declare type UrlBuilderTransformationOptions = UrlBuilderTransformationApiOptions | UrlBuilderOptionsPreset;
|
|
31
|
+
export declare type UrlBuilderTransformationApiOptions = UrlBuilderOptionsImage | UrlBuilderOptionsVideo | UrlBuilderOptionsAudio | UrlBuilderOptionsArchive;
|
|
32
|
+
export interface UrlBuilderOptionsBase {
|
|
30
33
|
/**
|
|
31
34
|
* Set to 'true' to download a private file. Requires an active auth session. See AuthManager.beginAuthSession.
|
|
32
35
|
*
|
|
@@ -57,7 +60,6 @@ export interface UrlBuilderOptions {
|
|
|
57
60
|
* Default: false
|
|
58
61
|
*/
|
|
59
62
|
forceDownloadPrompt?: boolean;
|
|
60
|
-
transformation?: UrlBuilderParamsTransformation;
|
|
61
63
|
/**
|
|
62
64
|
* Downloads the latest version of your file (if you have overwritten it) when added to the URL with a unique value.
|
|
63
65
|
*
|
|
@@ -67,48 +69,55 @@ export interface UrlBuilderOptions {
|
|
|
67
69
|
*/
|
|
68
70
|
version?: string;
|
|
69
71
|
}
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
+
export interface UrlBuilderOptionsRaw extends UrlBuilderOptionsBase {
|
|
73
|
+
transformation?: undefined;
|
|
74
|
+
}
|
|
75
|
+
export interface UrlBuilderOptionsImage extends UrlBuilderOptionsTransformationApi<ParameterGroup> {
|
|
72
76
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* Some transformations produce multiple files. The 'artifact' parameter is used to select which file to download.
|
|
76
|
-
*
|
|
77
|
-
* Must begin with: "/"
|
|
77
|
+
* Set to "image" to use Bytescale's Image Processing API:
|
|
78
78
|
*
|
|
79
|
-
*
|
|
79
|
+
* https://www.bytescale.com/docs/image-processing-api
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
transformation: "image";
|
|
82
|
+
}
|
|
83
|
+
export interface UrlBuilderOptionsVideo extends UrlBuilderOptionsTransformationApi<ParameterGroup> {
|
|
82
84
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* Permanently cached files can be deleted via a manual action in the Bytescale Dashboard.
|
|
86
|
-
*
|
|
87
|
-
* When cache=false this parameter is automatically set to false.
|
|
88
|
-
*
|
|
89
|
-
* When cachePermanently="auto" the permanent cache will only be used for files that take more than 1000ms to process.
|
|
90
|
-
*
|
|
91
|
-
* When the permanent cache is used, approximately 200ms of latency is added to the initial request. Thereafter, files will be served from the Bytescale CDN's edge cache or permanent cache, so will have minimal latency.
|
|
85
|
+
* Set to "video" to use Bytescale's Video Processing API:
|
|
92
86
|
*
|
|
93
|
-
*
|
|
87
|
+
* https://www.bytescale.com/docs/video-processing-api
|
|
94
88
|
*/
|
|
95
|
-
|
|
89
|
+
transformation: "video";
|
|
90
|
+
}
|
|
91
|
+
export interface UrlBuilderOptionsAudio extends UrlBuilderOptionsTransformationApi<ParameterGroup> {
|
|
96
92
|
/**
|
|
97
|
-
* Set to
|
|
93
|
+
* Set to "audio" to use Bytescale's Audio Processing API:
|
|
98
94
|
*
|
|
99
|
-
*
|
|
95
|
+
* https://www.bytescale.com/docs/audio-processing-api
|
|
96
|
+
*/
|
|
97
|
+
transformation: "audio";
|
|
98
|
+
}
|
|
99
|
+
export interface UrlBuilderOptionsArchive extends UrlBuilderOptionsTransformationApi<ParameterGroup> {
|
|
100
|
+
/**
|
|
101
|
+
* Set to "archive" to use Bytescale's Archive Processing API:
|
|
100
102
|
*
|
|
101
|
-
*
|
|
103
|
+
* https://www.bytescale.com/docs/archive-processing-api
|
|
104
|
+
*/
|
|
105
|
+
transformation: "archive";
|
|
106
|
+
}
|
|
107
|
+
export interface UrlBuilderOptionsPreset extends UrlBuilderOptionsTransformation {
|
|
108
|
+
transformation: "preset";
|
|
109
|
+
/**
|
|
110
|
+
* The name of the transformation preset, as displayed in the Bytescale Dashboard.
|
|
102
111
|
*
|
|
103
|
-
*
|
|
112
|
+
* To specify transformation parameters on-the-fly, set "transformation" to a File Processing API (e.g. "image", "video", "audio"), and then use the "transformationParams" field to pass parameters to the File Processing API.
|
|
104
113
|
*/
|
|
105
|
-
|
|
114
|
+
transformationPreset: string;
|
|
106
115
|
}
|
|
107
|
-
export interface
|
|
116
|
+
export interface UrlBuilderOptionsTransformationApi<T> extends UrlBuilderOptionsTransformation {
|
|
108
117
|
/**
|
|
109
|
-
* Use the "
|
|
118
|
+
* Use the "transformationParams" field to pass parameters to the File Processing API.
|
|
110
119
|
*
|
|
111
|
-
* Use the "
|
|
120
|
+
* Use the "transformation" field to specify which File Processing API to use:
|
|
112
121
|
*
|
|
113
122
|
* - https://www.bytescale.com/docs/image-processing-api
|
|
114
123
|
* - https://www.bytescale.com/docs/video-processing-api
|
|
@@ -122,52 +131,43 @@ export interface UrlBuilderParamsTransformationApiBase<T> {
|
|
|
122
131
|
* Order is sensitive both within and across parameter groups for certain transformation operations, please consult
|
|
123
132
|
* the documentation for the File Processing API you are using (see links above).
|
|
124
133
|
*/
|
|
125
|
-
|
|
134
|
+
transformationParams?: T | T[];
|
|
126
135
|
}
|
|
127
|
-
export interface
|
|
128
|
-
params?: UrlBuilderParamsTransformationOptions;
|
|
136
|
+
export interface UrlBuilderOptionsTransformation extends UrlBuilderOptionsBase {
|
|
129
137
|
/**
|
|
130
|
-
* The
|
|
138
|
+
* The transformation artifact to download.
|
|
131
139
|
*
|
|
132
|
-
*
|
|
133
|
-
*/
|
|
134
|
-
preset: string;
|
|
135
|
-
/**
|
|
136
|
-
* Use a transformation preset that was created in the Bytescale Dashboard.
|
|
140
|
+
* Some transformations produce multiple files. The 'artifact' parameter is used to select which file to download.
|
|
137
141
|
*
|
|
138
|
-
*
|
|
139
|
-
*/
|
|
140
|
-
type: "preset";
|
|
141
|
-
}
|
|
142
|
-
export interface UrlBuilderParamsImageTransformation extends UrlBuilderParamsTransformationApiBase<ParameterGroup> {
|
|
143
|
-
/**
|
|
144
|
-
* Set to "image" to use Bytescale's Image Processing API:
|
|
142
|
+
* Must begin with: "/"
|
|
145
143
|
*
|
|
146
|
-
*
|
|
144
|
+
* Default: "/"
|
|
147
145
|
*/
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
export interface UrlBuilderParamsVideoTransformation extends UrlBuilderParamsTransformationApiBase<ParameterGroup> {
|
|
146
|
+
artifact?: string;
|
|
151
147
|
/**
|
|
152
|
-
*
|
|
148
|
+
* Specifies whether to permanently cache the transformed result in the Bytescale CDN.
|
|
153
149
|
*
|
|
154
|
-
*
|
|
155
|
-
*/
|
|
156
|
-
type: "video";
|
|
157
|
-
}
|
|
158
|
-
export interface UrlBuilderParamsAudioTransformation extends UrlBuilderParamsTransformationApiBase<ParameterGroup> {
|
|
159
|
-
/**
|
|
160
|
-
* Set to "audio" to use Bytescale's Audio Processing API:
|
|
150
|
+
* Permanently cached files can be deleted via a manual action in the Bytescale Dashboard.
|
|
161
151
|
*
|
|
162
|
-
*
|
|
152
|
+
* When cache=false this parameter is automatically set to false.
|
|
153
|
+
*
|
|
154
|
+
* When cachePermanently="auto" the permanent cache will only be used for files that take more than 1000ms to process.
|
|
155
|
+
*
|
|
156
|
+
* When the permanent cache is used, approximately 200ms of latency is added to the initial request. Thereafter, files will be served from the Bytescale CDN's edge cache or permanent cache, so will have minimal latency.
|
|
157
|
+
*
|
|
158
|
+
* Default: Please refer to your account's default cache settings in the Bytescale Dashboard.
|
|
163
159
|
*/
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
export interface UrlBuilderParamsArchiveTransformation extends UrlBuilderParamsTransformationApiBase<ParameterGroup> {
|
|
160
|
+
cachePermanently?: "auto" | boolean;
|
|
167
161
|
/**
|
|
168
|
-
*
|
|
162
|
+
* Only set this parameter to `true` if you expect the HTTP response body for the transformation request to be over 6MB.
|
|
169
163
|
*
|
|
170
|
-
*
|
|
164
|
+
* We recommend leaving this parameter unset (so it defaults to `false`) and controlling the HTTP response body size via transformation parameters. E.g. for Image Processing API requests, you can shrink the HTTP response body by reducing the output image's dimensions and/or quality.
|
|
165
|
+
*
|
|
166
|
+
* Setting this parameter to `true` will route the request via an alternative CDN path, which allows responses over 6MB, but incurs a ~200ms latency on all CDN edge cache misses for the URL.
|
|
167
|
+
*
|
|
168
|
+
* Setting this parameter to `false` (default) results in faster routing. If a response over 6MB is returned, the initial response will be a JSON error indicating the response was too large to return. All subsequent requests to the same URL will successfully return the transformed file (forever).
|
|
169
|
+
*
|
|
170
|
+
* Default: false
|
|
171
171
|
*/
|
|
172
|
-
|
|
172
|
+
large?: boolean;
|
|
173
173
|
}
|
|
@@ -30,8 +30,25 @@ export interface DeleteFileBatchOperationParams {
|
|
|
30
30
|
export interface DownloadFileParams {
|
|
31
31
|
accountId: string;
|
|
32
32
|
filePath: string;
|
|
33
|
+
/**
|
|
34
|
+
* Specifies whether to cache the raw file in the Bytescale CDN.
|
|
35
|
+
*
|
|
36
|
+
* Default: true
|
|
37
|
+
*/
|
|
33
38
|
cache?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Specifies the maximum amount of time, in seconds, the file will be cached on the user's device and in the Bytescale CDN's edge cache.
|
|
41
|
+
*
|
|
42
|
+
* Default: Please refer to your account's default cache settings in the Bytescale Dashboard.
|
|
43
|
+
*/
|
|
34
44
|
cacheTtl?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Downloads the latest version of your file (if you have overwritten it) when added to the URL with a unique value.
|
|
47
|
+
*
|
|
48
|
+
* The value of the `version` parameter can be anything, e.g. an incremental number, a timestamp, etc.
|
|
49
|
+
*
|
|
50
|
+
* You only need to provide and update this value if/when you overwrite your file.
|
|
51
|
+
*/
|
|
35
52
|
version?: string;
|
|
36
53
|
}
|
|
37
54
|
export interface GetFileDetailsParams {
|
|
@@ -41,29 +58,113 @@ export interface GetFileDetailsParams {
|
|
|
41
58
|
export interface ProcessFileParams {
|
|
42
59
|
accountId: string;
|
|
43
60
|
filePath: string;
|
|
61
|
+
/**
|
|
62
|
+
* The name of the File Processing API (e.g. "image", "video", "audio") or transformation preset (created in the Bytescale Dashboard) to use when processing the file.
|
|
63
|
+
*/
|
|
44
64
|
transformation: string;
|
|
65
|
+
/**
|
|
66
|
+
* Some transformations output multiple files, called artifacts.
|
|
67
|
+
*
|
|
68
|
+
* You can download each individual transformation artifact by specifying its path with this parameter
|
|
69
|
+
*/
|
|
45
70
|
artifact?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Specifies whether to cache the transformed result.
|
|
73
|
+
*
|
|
74
|
+
* If set to `false` the transformation will be executed on every request.
|
|
75
|
+
*
|
|
76
|
+
* *Recommendation:* instead of disabling the cache, a more performant solution is to use the `version` parameter and to increment it each time you require an updated result.
|
|
77
|
+
*
|
|
78
|
+
* Default: true
|
|
79
|
+
*/
|
|
46
80
|
cache?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Specifies whether to cache the transformed result in the Bytescale CDN perma-cache.
|
|
83
|
+
*
|
|
84
|
+
* Perma-caching works by storing your file permanently, or until a manual cache purge is performed.
|
|
85
|
+
*
|
|
86
|
+
* When `cache=false` this parameter is automatically set to `false`.
|
|
87
|
+
*
|
|
88
|
+
* When `cache_perm=auto` the perma-cache will only be used for files that take more than 1000ms to process.
|
|
89
|
+
*
|
|
90
|
+
* When the perma-cache is used, approximately 200ms of latency is added to the initial request. Thereafter, files will be served from the Bytescale CDN's edge cache or perma-cache, so will have minimal latency.
|
|
91
|
+
*
|
|
92
|
+
* Default: Please refer to your account's default cache settings in the Bytescale Dashboard.
|
|
93
|
+
*/
|
|
47
94
|
cachePerm?: ProcessFileCachePermEnum;
|
|
95
|
+
/**
|
|
96
|
+
* Specifies the maximum amount of time, in seconds, the transformed result will be cached on the user's device and in the Bytescale CDN's edge cache.
|
|
97
|
+
*
|
|
98
|
+
* If the file is perma-cached, then the file will not be reprocessed on edge cache misses.
|
|
99
|
+
*
|
|
100
|
+
* If the file is not perma-cached, then the file will be reprocessed on edge cache misses.
|
|
101
|
+
*
|
|
102
|
+
* For more information on perma-caching, see: `cache_perm`
|
|
103
|
+
*
|
|
104
|
+
* Default: Please refer to your account's default cache settings in the Bytescale Dashboard.
|
|
105
|
+
*/
|
|
48
106
|
cacheTtl?: number;
|
|
107
|
+
/**
|
|
108
|
+
* Only set this parameter to `true` if you expect the HTTP response body for the transformation request to be over 6MB.
|
|
109
|
+
*
|
|
110
|
+
* We recommend leaving this parameter unset (so it defaults to `false`) and controlling the HTTP response body size via transformation parameters. E.g. for Image Processing API requests, you can shrink the HTTP response body by reducing the output image's dimensions and/or quality.
|
|
111
|
+
*
|
|
112
|
+
* Setting this parameter to `true` will route the request via an alternative CDN path, which allows responses over 6MB, but incurs a ~200ms latency on all CDN edge cache misses for the URL.
|
|
113
|
+
*
|
|
114
|
+
* Setting this parameter to `false` (default) results in faster routing. If a response over 6MB is returned, the initial response will be a JSON error indicating the response was too large to return. All subsequent requests to the same URL will successfully return the transformed file (forever).
|
|
115
|
+
*
|
|
116
|
+
* Default: `false`
|
|
117
|
+
*/
|
|
49
118
|
large?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Parameters to submit to the File Processing API (e.g. the Image Processing API).
|
|
121
|
+
*
|
|
122
|
+
* Please see the documentation for each File Processing API to determine which values can appear here:
|
|
123
|
+
*
|
|
124
|
+
* - https://www.bytescale.com/docs/image-processing-api
|
|
125
|
+
* - https://www.bytescale.com/docs/video-processing-api
|
|
126
|
+
* - https://www.bytescale.com/docs/audio-processing-api
|
|
127
|
+
* - https://www.bytescale.com/docs/archive-processing-api
|
|
128
|
+
*/
|
|
50
129
|
transformationParams?: {
|
|
51
130
|
[key: string]: ProcessFileTransformationParamsParameterValue;
|
|
52
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* Add this parameter and increment its value to force the file to be reprocessed.
|
|
134
|
+
*
|
|
135
|
+
* The Bytescale CDN caches files based on the full URL (including the querystring), meaning this parameter is useful when dealing with changes made to transformation presets. By contrast, File Processing APIs (like the Image Processing API) shouldn't ever require this parameter, since the URL/querystring naturally changes each time you adjust a parameter, causing a cache miss and the file to be reprocessed with the new querystring parameters.
|
|
136
|
+
*
|
|
137
|
+
* The value of the `version` parameter can be anything, e.g. an incremental number, a timestamp, etc.
|
|
138
|
+
*
|
|
139
|
+
* You only need to provide and update this value if/when you make changes to a transformation preset's settings.
|
|
140
|
+
*/
|
|
53
141
|
version?: string;
|
|
54
142
|
}
|
|
55
143
|
export interface ProcessFileAndSaveOperationParams {
|
|
56
144
|
accountId: string;
|
|
57
145
|
filePath: string;
|
|
146
|
+
/**
|
|
147
|
+
* The name of the File Processing API (e.g. "image", "video", "audio") or transformation preset (created in the Bytescale Dashboard) to use when processing the file.
|
|
148
|
+
*/
|
|
58
149
|
transformation: string;
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
*/
|
|
59
153
|
processFileAndSaveRequest: ProcessFileAndSaveRequest;
|
|
154
|
+
/**
|
|
155
|
+
* Parameters to submit to the File Processing API (e.g. the Image Processing API).
|
|
156
|
+
*
|
|
157
|
+
* Please see the documentation for each File Processing API to determine which values can appear here:
|
|
158
|
+
*
|
|
159
|
+
* - https://www.bytescale.com/docs/image-processing-api
|
|
160
|
+
* - https://www.bytescale.com/docs/video-processing-api
|
|
161
|
+
* - https://www.bytescale.com/docs/audio-processing-api
|
|
162
|
+
* - https://www.bytescale.com/docs/archive-processing-api
|
|
163
|
+
*/
|
|
60
164
|
transformationParams?: {
|
|
61
165
|
[key: string]: ProcessFileTransformationParamsParameterValue;
|
|
62
166
|
};
|
|
63
167
|
}
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
*/
|
|
67
168
|
export declare class FileApi extends runtime.BaseAPI {
|
|
68
169
|
/**
|
|
69
170
|
* Copies a file synchronously.
|
|
@@ -47,9 +47,6 @@ export interface PutFolderOperationParams {
|
|
|
47
47
|
accountId: string;
|
|
48
48
|
putFolderRequest: PutFolderRequest;
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
50
|
export declare class FolderApi extends runtime.BaseAPI {
|
|
54
51
|
/**
|
|
55
52
|
* 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.
|
|
@@ -25,9 +25,6 @@ export interface ListRecentJobsParams {
|
|
|
25
25
|
accountId: string;
|
|
26
26
|
jobType: Array<AccountJobType>;
|
|
27
27
|
}
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
28
|
export declare class JobApi extends runtime.BaseAPI {
|
|
32
29
|
/**
|
|
33
30
|
* Cancels an in-progress background job. Requires a `secret_*` API key.
|
|
@@ -13,6 +13,9 @@ import * as runtime from "../runtime";
|
|
|
13
13
|
import type { BasicUploadResponse, BeginMultipartUploadRequest, BeginMultipartUploadResponse, CompleteUploadPartRequest, UploadFromUrlRequest, UploadPart, UploadPartList } from "../models";
|
|
14
14
|
export interface BeginMultipartUploadOperationParams {
|
|
15
15
|
accountId: string;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
16
19
|
beginMultipartUploadRequest: BeginMultipartUploadRequest;
|
|
17
20
|
}
|
|
18
21
|
export interface CompleteUploadPartOperationParams {
|
|
@@ -32,11 +35,11 @@ export interface ListUploadPartsParams {
|
|
|
32
35
|
}
|
|
33
36
|
export interface UploadFromUrlOperationParams {
|
|
34
37
|
accountId: string;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
35
41
|
uploadFromUrlRequest: UploadFromUrlRequest;
|
|
36
42
|
}
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
*/
|
|
40
43
|
export declare class UploadApi extends runtime.BaseAPI {
|
|
41
44
|
/**
|
|
42
45
|
* Begins a new multipart file upload process.
|