@bytescale/sdk 3.0.0-alpha.2 → 3.0.0-alpha.5

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.
@@ -481,9 +481,6 @@ function FileApi_getPrototypeOf(o) { FileApi_getPrototypeOf = Object.setPrototyp
481
481
  */
482
482
  // @ts-ignore
483
483
 
484
- /**
485
- *
486
- */
487
484
  var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
488
485
  FileApi_inherits(FileApi, _runtime$BaseAPI);
489
486
  var _super = FileApi_createSuper(FileApi);
@@ -782,9 +779,6 @@ function FolderApi_getPrototypeOf(o) { FolderApi_getPrototypeOf = Object.setProt
782
779
  */
783
780
  // @ts-ignore
784
781
 
785
- /**
786
- *
787
- */
788
782
  var FolderApi = /*#__PURE__*/function (_runtime$BaseAPI) {
789
783
  FolderApi_inherits(FolderApi, _runtime$BaseAPI);
790
784
  var _super = FolderApi_createSuper(FolderApi);
@@ -1042,9 +1036,6 @@ function JobApi_getPrototypeOf(o) { JobApi_getPrototypeOf = Object.setPrototypeO
1042
1036
  */
1043
1037
  // @ts-ignore
1044
1038
 
1045
- /**
1046
- *
1047
- */
1048
1039
  var JobApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1049
1040
  JobApi_inherits(JobApi, _runtime$BaseAPI);
1050
1041
  var _super = JobApi_createSuper(JobApi);
@@ -1177,9 +1168,6 @@ function UploadApi_getPrototypeOf(o) { UploadApi_getPrototypeOf = Object.setProt
1177
1168
  */
1178
1169
  // @ts-ignore
1179
1170
 
1180
- /**
1181
- *
1182
- */
1183
1171
  var UploadApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1184
1172
  UploadApi_inherits(UploadApi, _runtime$BaseAPI);
1185
1173
  var _super = UploadApi_createSuper(UploadApi);
@@ -1400,7 +1388,7 @@ var UrlBuilder = /*#__PURE__*/function () {
1400
1388
  key: "url",
1401
1389
  value: function url(params) {
1402
1390
  var _a;
1403
- return ((_a = params.options) === null || _a === void 0 ? void 0 : _a.transformation) === undefined ? this.raw(params) : this.transformation(params, params.options.transformation);
1391
+ return ((_a = params.options) === null || _a === void 0 ? void 0 : _a.transformation) === undefined ? this.raw(params) : this.transformation(params, params.options);
1404
1392
  }
1405
1393
  }, {
1406
1394
  key: "raw",
@@ -1414,18 +1402,25 @@ var UrlBuilder = /*#__PURE__*/function () {
1414
1402
  key: "transformation",
1415
1403
  value: function transformation(params, trans) {
1416
1404
  var _a;
1417
- var baseUrl = this.getBaseUrl(params, trans.type === "preset" ? trans.preset : trans.type);
1418
- var transParams = this.getTransformationParams(trans, {
1419
- cachePermanently: "cache_perm"
1420
- });
1405
+ var baseUrl = this.getBaseUrl(params, trans.transformation === "preset" ? trans.transformationPreset : trans.transformation);
1406
+ var transParams = trans.transformation === "preset" ? [] : this.getTransformationParams(trans);
1421
1407
  var commonParams = this.getCommonQueryParams((_a = params.options) !== null && _a !== void 0 ? _a : {});
1422
- return this.addQueryParams(baseUrl, [].concat(_toConsumableArray(commonParams), _toConsumableArray(transParams)));
1408
+ var transCommonParams = this.getCommonTransformationQueryParams(trans);
1409
+ // This format puts "artifact" at the end, which isn't required, but is convention.
1410
+ return this.addQueryParams(baseUrl, [].concat(_toConsumableArray(transParams), _toConsumableArray(commonParams), _toConsumableArray(transCommonParams)));
1423
1411
  }
1424
1412
  }, {
1425
1413
  key: "getBaseUrl",
1426
1414
  value: function getBaseUrl(params, prefix) {
1427
1415
  return "".concat(this.cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
1428
1416
  }
1417
+ }, {
1418
+ key: "getCommonTransformationQueryParams",
1419
+ value: function getCommonTransformationQueryParams(trans) {
1420
+ return this.makeQueryParams(["cachePermanently", "large", "artifact"], {
1421
+ cachePermanently: "cache_perm"
1422
+ })(trans);
1423
+ }
1429
1424
  }, {
1430
1425
  key: "getCommonQueryParams",
1431
1426
  value: function getCommonQueryParams(params) {
@@ -1451,8 +1446,9 @@ var UrlBuilder = /*#__PURE__*/function () {
1451
1446
  }
1452
1447
  }, {
1453
1448
  key: "getTransformationParams",
1454
- value: function getTransformationParams(trans, keyRewrites) {
1455
- if (trans.params === undefined) {
1449
+ value: function getTransformationParams(trans) {
1450
+ var params = trans.transformationParams;
1451
+ if (params === undefined) {
1456
1452
  return [];
1457
1453
  }
1458
1454
  var serializeObj = function serializeObj(obj) {
@@ -1460,11 +1456,10 @@ var UrlBuilder = /*#__PURE__*/function () {
1460
1456
  var _ref2 = _slicedToArray(_ref, 2),
1461
1457
  key = _ref2[0],
1462
1458
  value = _ref2[1];
1463
- var _a;
1464
- return [(_a = keyRewrites[key]) !== null && _a !== void 0 ? _a : key, value.toString()];
1459
+ return [key, value.toString()];
1465
1460
  });
1466
1461
  };
1467
- return Array.isArray(trans.params) ? trans.params.flatMap(serializeObj) : serializeObj(trans.params);
1462
+ return Array.isArray(params) ? params.flatMap(serializeObj) : serializeObj(params);
1468
1463
  }
1469
1464
  }, {
1470
1465
  key: "addQueryParams",
@@ -503,9 +503,6 @@ function FileApi_getPrototypeOf(o) { FileApi_getPrototypeOf = Object.setPrototyp
503
503
  */
504
504
  // @ts-ignore
505
505
 
506
- /**
507
- *
508
- */
509
506
  var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
510
507
  FileApi_inherits(FileApi, _runtime$BaseAPI);
511
508
  var _super = FileApi_createSuper(FileApi);
@@ -804,9 +801,6 @@ function FolderApi_getPrototypeOf(o) { FolderApi_getPrototypeOf = Object.setProt
804
801
  */
805
802
  // @ts-ignore
806
803
 
807
- /**
808
- *
809
- */
810
804
  var FolderApi = /*#__PURE__*/function (_runtime$BaseAPI) {
811
805
  FolderApi_inherits(FolderApi, _runtime$BaseAPI);
812
806
  var _super = FolderApi_createSuper(FolderApi);
@@ -1064,9 +1058,6 @@ function JobApi_getPrototypeOf(o) { JobApi_getPrototypeOf = Object.setPrototypeO
1064
1058
  */
1065
1059
  // @ts-ignore
1066
1060
 
1067
- /**
1068
- *
1069
- */
1070
1061
  var JobApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1071
1062
  JobApi_inherits(JobApi, _runtime$BaseAPI);
1072
1063
  var _super = JobApi_createSuper(JobApi);
@@ -1199,9 +1190,6 @@ function UploadApi_getPrototypeOf(o) { UploadApi_getPrototypeOf = Object.setProt
1199
1190
  */
1200
1191
  // @ts-ignore
1201
1192
 
1202
- /**
1203
- *
1204
- */
1205
1193
  var UploadApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1206
1194
  UploadApi_inherits(UploadApi, _runtime$BaseAPI);
1207
1195
  var _super = UploadApi_createSuper(UploadApi);
@@ -1422,7 +1410,7 @@ var UrlBuilder = /*#__PURE__*/function () {
1422
1410
  key: "url",
1423
1411
  value: function url(params) {
1424
1412
  var _a;
1425
- return ((_a = params.options) === null || _a === void 0 ? void 0 : _a.transformation) === undefined ? this.raw(params) : this.transformation(params, params.options.transformation);
1413
+ return ((_a = params.options) === null || _a === void 0 ? void 0 : _a.transformation) === undefined ? this.raw(params) : this.transformation(params, params.options);
1426
1414
  }
1427
1415
  }, {
1428
1416
  key: "raw",
@@ -1436,18 +1424,25 @@ var UrlBuilder = /*#__PURE__*/function () {
1436
1424
  key: "transformation",
1437
1425
  value: function transformation(params, trans) {
1438
1426
  var _a;
1439
- var baseUrl = this.getBaseUrl(params, trans.type === "preset" ? trans.preset : trans.type);
1440
- var transParams = this.getTransformationParams(trans, {
1441
- cachePermanently: "cache_perm"
1442
- });
1427
+ var baseUrl = this.getBaseUrl(params, trans.transformation === "preset" ? trans.transformationPreset : trans.transformation);
1428
+ var transParams = trans.transformation === "preset" ? [] : this.getTransformationParams(trans);
1443
1429
  var commonParams = this.getCommonQueryParams((_a = params.options) !== null && _a !== void 0 ? _a : {});
1444
- return this.addQueryParams(baseUrl, [].concat(_toConsumableArray(commonParams), _toConsumableArray(transParams)));
1430
+ var transCommonParams = this.getCommonTransformationQueryParams(trans);
1431
+ // This format puts "artifact" at the end, which isn't required, but is convention.
1432
+ return this.addQueryParams(baseUrl, [].concat(_toConsumableArray(transParams), _toConsumableArray(commonParams), _toConsumableArray(transCommonParams)));
1445
1433
  }
1446
1434
  }, {
1447
1435
  key: "getBaseUrl",
1448
1436
  value: function getBaseUrl(params, prefix) {
1449
1437
  return "".concat(this.cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
1450
1438
  }
1439
+ }, {
1440
+ key: "getCommonTransformationQueryParams",
1441
+ value: function getCommonTransformationQueryParams(trans) {
1442
+ return this.makeQueryParams(["cachePermanently", "large", "artifact"], {
1443
+ cachePermanently: "cache_perm"
1444
+ })(trans);
1445
+ }
1451
1446
  }, {
1452
1447
  key: "getCommonQueryParams",
1453
1448
  value: function getCommonQueryParams(params) {
@@ -1473,8 +1468,9 @@ var UrlBuilder = /*#__PURE__*/function () {
1473
1468
  }
1474
1469
  }, {
1475
1470
  key: "getTransformationParams",
1476
- value: function getTransformationParams(trans, keyRewrites) {
1477
- if (trans.params === undefined) {
1471
+ value: function getTransformationParams(trans) {
1472
+ var params = trans.transformationParams;
1473
+ if (params === undefined) {
1478
1474
  return [];
1479
1475
  }
1480
1476
  var serializeObj = function serializeObj(obj) {
@@ -1482,11 +1478,10 @@ var UrlBuilder = /*#__PURE__*/function () {
1482
1478
  var _ref2 = _slicedToArray(_ref, 2),
1483
1479
  key = _ref2[0],
1484
1480
  value = _ref2[1];
1485
- var _a;
1486
- return [(_a = keyRewrites[key]) !== null && _a !== void 0 ? _a : key, value.toString()];
1481
+ return [key, value.toString()];
1487
1482
  });
1488
1483
  };
1489
- return Array.isArray(trans.params) ? trans.params.flatMap(serializeObj) : serializeObj(trans.params);
1484
+ return Array.isArray(params) ? params.flatMap(serializeObj) : serializeObj(params);
1490
1485
  }
1491
1486
  }, {
1492
1487
  key: "addQueryParams",
@@ -490,9 +490,6 @@ function FileApi_getPrototypeOf(o) { FileApi_getPrototypeOf = Object.setPrototyp
490
490
  */
491
491
  // @ts-ignore
492
492
 
493
- /**
494
- *
495
- */
496
493
  var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
497
494
  FileApi_inherits(FileApi, _runtime$BaseAPI);
498
495
  var _super = FileApi_createSuper(FileApi);
@@ -791,9 +788,6 @@ function FolderApi_getPrototypeOf(o) { FolderApi_getPrototypeOf = Object.setProt
791
788
  */
792
789
  // @ts-ignore
793
790
 
794
- /**
795
- *
796
- */
797
791
  var FolderApi = /*#__PURE__*/function (_runtime$BaseAPI) {
798
792
  FolderApi_inherits(FolderApi, _runtime$BaseAPI);
799
793
  var _super = FolderApi_createSuper(FolderApi);
@@ -1051,9 +1045,6 @@ function JobApi_getPrototypeOf(o) { JobApi_getPrototypeOf = Object.setPrototypeO
1051
1045
  */
1052
1046
  // @ts-ignore
1053
1047
 
1054
- /**
1055
- *
1056
- */
1057
1048
  var JobApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1058
1049
  JobApi_inherits(JobApi, _runtime$BaseAPI);
1059
1050
  var _super = JobApi_createSuper(JobApi);
@@ -1186,9 +1177,6 @@ function UploadApi_getPrototypeOf(o) { UploadApi_getPrototypeOf = Object.setProt
1186
1177
  */
1187
1178
  // @ts-ignore
1188
1179
 
1189
- /**
1190
- *
1191
- */
1192
1180
  var UploadApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1193
1181
  UploadApi_inherits(UploadApi, _runtime$BaseAPI);
1194
1182
  var _super = UploadApi_createSuper(UploadApi);
@@ -1409,7 +1397,7 @@ var UrlBuilder = /*#__PURE__*/function () {
1409
1397
  key: "url",
1410
1398
  value: function url(params) {
1411
1399
  var _a;
1412
- return ((_a = params.options) === null || _a === void 0 ? void 0 : _a.transformation) === undefined ? this.raw(params) : this.transformation(params, params.options.transformation);
1400
+ return ((_a = params.options) === null || _a === void 0 ? void 0 : _a.transformation) === undefined ? this.raw(params) : this.transformation(params, params.options);
1413
1401
  }
1414
1402
  }, {
1415
1403
  key: "raw",
@@ -1423,18 +1411,25 @@ var UrlBuilder = /*#__PURE__*/function () {
1423
1411
  key: "transformation",
1424
1412
  value: function transformation(params, trans) {
1425
1413
  var _a;
1426
- var baseUrl = this.getBaseUrl(params, trans.type === "preset" ? trans.preset : trans.type);
1427
- var transParams = this.getTransformationParams(trans, {
1428
- cachePermanently: "cache_perm"
1429
- });
1414
+ var baseUrl = this.getBaseUrl(params, trans.transformation === "preset" ? trans.transformationPreset : trans.transformation);
1415
+ var transParams = trans.transformation === "preset" ? [] : this.getTransformationParams(trans);
1430
1416
  var commonParams = this.getCommonQueryParams((_a = params.options) !== null && _a !== void 0 ? _a : {});
1431
- return this.addQueryParams(baseUrl, [].concat(_toConsumableArray(commonParams), _toConsumableArray(transParams)));
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)));
1432
1420
  }
1433
1421
  }, {
1434
1422
  key: "getBaseUrl",
1435
1423
  value: function getBaseUrl(params, prefix) {
1436
1424
  return "".concat(this.cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
1437
1425
  }
1426
+ }, {
1427
+ key: "getCommonTransformationQueryParams",
1428
+ value: function getCommonTransformationQueryParams(trans) {
1429
+ return this.makeQueryParams(["cachePermanently", "large", "artifact"], {
1430
+ cachePermanently: "cache_perm"
1431
+ })(trans);
1432
+ }
1438
1433
  }, {
1439
1434
  key: "getCommonQueryParams",
1440
1435
  value: function getCommonQueryParams(params) {
@@ -1460,8 +1455,9 @@ var UrlBuilder = /*#__PURE__*/function () {
1460
1455
  }
1461
1456
  }, {
1462
1457
  key: "getTransformationParams",
1463
- value: function getTransformationParams(trans, keyRewrites) {
1464
- if (trans.params === undefined) {
1458
+ value: function getTransformationParams(trans) {
1459
+ var params = trans.transformationParams;
1460
+ if (params === undefined) {
1465
1461
  return [];
1466
1462
  }
1467
1463
  var serializeObj = function serializeObj(obj) {
@@ -1469,11 +1465,10 @@ var UrlBuilder = /*#__PURE__*/function () {
1469
1465
  var _ref2 = _slicedToArray(_ref, 2),
1470
1466
  key = _ref2[0],
1471
1467
  value = _ref2[1];
1472
- var _a;
1473
- return [(_a = keyRewrites[key]) !== null && _a !== void 0 ? _a : key, value.toString()];
1468
+ return [key, value.toString()];
1474
1469
  });
1475
1470
  };
1476
- return Array.isArray(trans.params) ? trans.params.flatMap(serializeObj) : serializeObj(trans.params);
1471
+ return Array.isArray(params) ? params.flatMap(serializeObj) : serializeObj(params);
1477
1472
  }
1478
1473
  }, {
1479
1474
  key: "addQueryParams",
@@ -25,6 +25,7 @@ export declare class UrlBuilder {
25
25
  private raw;
26
26
  private transformation;
27
27
  private getBaseUrl;
28
+ private getCommonTransformationQueryParams;
28
29
  private getCommonQueryParams;
29
30
  private makeQueryParams;
30
31
  private getTransformationParams;
@@ -26,7 +26,10 @@ export interface UrlBuilderParams {
26
26
  */
27
27
  options?: UrlBuilderOptions;
28
28
  }
29
- export interface UrlBuilderOptions {
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 declare type UrlBuilderParamsTransformation = UrlBuilderParamsTransformationPreset | UrlBuilderParamsImageTransformation | UrlBuilderParamsVideoTransformation | UrlBuilderParamsAudioTransformation | UrlBuilderParamsArchiveTransformation;
71
- export interface UrlBuilderParamsTransformationOptions {
72
+ export interface UrlBuilderOptionsRaw extends UrlBuilderOptionsBase {
73
+ transformation?: undefined;
74
+ }
75
+ export interface UrlBuilderOptionsImage extends UrlBuilderOptionsTransformationApi<ParameterGroup> {
72
76
  /**
73
- * The transformation artifact to download.
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
- * Default: "/"
79
+ * https://www.bytescale.com/docs/image-processing-api
80
80
  */
81
- artifact?: string;
81
+ transformation: "image";
82
+ }
83
+ export interface UrlBuilderOptionsVideo extends UrlBuilderOptionsTransformationApi<ParameterGroup> {
82
84
  /**
83
- * Specifies whether to permanently cache the transformed result in the Bytescale CDN.
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
- * Default: Please refer to your account's default cache settings in the Bytescale Dashboard.
87
+ * https://www.bytescale.com/docs/video-processing-api
94
88
  */
95
- cachePermanently?: "auto" | boolean;
89
+ transformation: "video";
90
+ }
91
+ export interface UrlBuilderOptionsAudio extends UrlBuilderOptionsTransformationApi<ParameterGroup> {
96
92
  /**
97
- * Set to true to return transformed files over 6MB in the initial HTTP response.
93
+ * Set to "audio" to use Bytescale's Audio Processing API:
98
94
  *
99
- * By default, transformations that produce files larger than 6MB require a subsequent HTTP request to return the result: the initial HTTP request will process the file and return a JSON result instructing the requester the transformation has been performed. All subsequent requests will return the transformed file. Enable this flag to ensure the transformed file is always returned in the initial response.
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
- * Recommendation: set large=true only if you require transformation results over 6MB. A small amount of latency is incurred on edge cache misses when this flag is enabled. In general, we recommend adjusting your transformation parameters to keep files below this size, instead of enabling this flag.
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
- * Default: false
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
- large?: boolean;
114
+ transformationPreset: string;
106
115
  }
107
- export interface UrlBuilderParamsTransformationApiBase<T> {
116
+ export interface UrlBuilderOptionsTransformationApi<T> extends UrlBuilderOptionsTransformation {
108
117
  /**
109
- * Use the "params" field to pass parameters to the File Processing API.
118
+ * Use the "transformationParams" field to pass parameters to the File Processing API.
110
119
  *
111
- * Use the "type" field to specify which File Processing API to use:
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
- params?: (T & UrlBuilderParamsTransformationOptions) | Array<T & UrlBuilderParamsTransformationOptions>;
134
+ transformationParams?: T | T[];
126
135
  }
127
- export interface UrlBuilderParamsTransformationPreset {
128
- params?: UrlBuilderParamsTransformationOptions;
136
+ export interface UrlBuilderOptionsTransformation extends UrlBuilderOptionsBase {
129
137
  /**
130
- * The name of the transformation preset, as displayed in the Bytescale Dashboard.
138
+ * The transformation artifact to download.
131
139
  *
132
- * To specify transformation parameters on-the-fly, set "type" to a File Processing API (e.g. "image", "video", "audio"), and then use the "params" field to pass parameters to the File Processing API.
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
- * To specify transformation parameters on-the-fly, set "type" to a File Processing API (e.g. "image", "video", "audio"), and then use the "params" field to pass parameters to the File Processing API.
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
- * https://www.bytescale.com/docs/image-processing-api
144
+ * Default: "/"
147
145
  */
148
- type: "image";
149
- }
150
- export interface UrlBuilderParamsVideoTransformation extends UrlBuilderParamsTransformationApiBase<ParameterGroup> {
146
+ artifact?: string;
151
147
  /**
152
- * Set to "video" to use Bytescale's Video Processing API:
148
+ * Specifies whether to permanently cache the transformed result in the Bytescale CDN.
153
149
  *
154
- * https://www.bytescale.com/docs/video-processing-api
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
- * https://www.bytescale.com/docs/audio-processing-api
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
- type: "audio";
165
- }
166
- export interface UrlBuilderParamsArchiveTransformation extends UrlBuilderParamsTransformationApiBase<ParameterGroup> {
160
+ cachePermanently?: "auto" | boolean;
167
161
  /**
168
- * Set to "archive" to use Bytescale's Archive Processing API:
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
- * https://www.bytescale.com/docs/archive-processing-api
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
- type: "archive";
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.
@@ -1524,7 +1524,7 @@ export interface ProcessFileAndSaveRequest {
1524
1524
  */
1525
1525
  export declare type ProcessFileAndSaveResponse = ProcessFileAndSaveResponseAsync | ProcessFileAndSaveResponseSync;
1526
1526
  /**
1527
- * Response body for ProcessFileAndSave operations where the File Processing API operation is an asynchronous operation (e.g. a video transcoding job).
1527
+ * Response body for ProcessFileAndSave operations where the File Processing API operation is asynchronous (e.g. a video transcoding job).
1528
1528
  * @export
1529
1529
  * @interface ProcessFileAndSaveResponseAsync
1530
1530
  */
@@ -1617,7 +1617,7 @@ export declare type ProcessFileAndSaveResponseAsyncJobDocsEnum = "https://www.by
1617
1617
  */
1618
1618
  export declare type ProcessFileAndSaveResponseAsyncAsyncEnum = true;
1619
1619
  /**
1620
- * Response body for ProcessFileAndSave operations where the File Processing API operation is a synchronous operation (e.g. an image processing job).
1620
+ * Response body for ProcessFileAndSave operations where the File Processing API operation is synchronous (e.g. an image processing job).
1621
1621
  * @export
1622
1622
  * @interface ProcessFileAndSaveResponseSync
1623
1623
  */
@@ -1641,9 +1641,7 @@ export interface ProcessFileAndSaveResponseSync {
1641
1641
  */
1642
1642
  async: ProcessFileAndSaveResponseSyncAsyncEnum;
1643
1643
  /**
1644
- * The `filePath` of the transformed file.
1645
- *
1646
- * If the transformation outputs multiple artifacts, then each artifact's path will be a child of this path.
1644
+ * Absolute path to a file. Begins with a `/`.
1647
1645
  * @type {string}
1648
1646
  * @memberof ProcessFileAndSaveResponseSync
1649
1647
  */
@@ -1655,9 +1653,9 @@ export interface ProcessFileAndSaveResponseSync {
1655
1653
  */
1656
1654
  fileUrl: string;
1657
1655
  /**
1658
- * JSON response returned by certain transformation APIs.
1656
+ * JSON response returned by certain File Processing APIs.
1659
1657
  *
1660
- * Structure varies between transformation APIs (please consult the documentation of the individual transformation APIs).
1658
+ * Structure varies between File Processing APIs (please see the documentation of each individual File Processing API).
1661
1659
  * @type {{ [key: string]: any; }}
1662
1660
  * @memberof ProcessFileAndSaveResponseSync
1663
1661
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytescale/sdk",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.5",
4
4
  "description": "Bytescale JavaScript SDK",
5
5
  "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
6
6
  "license": "MIT",
@@ -16,8 +16,7 @@
16
16
  },
17
17
  "browser": {
18
18
  "require": "./dist/browser/cjs/main.js"
19
- },
20
- "default": "./dist/node/esm/main.mjs"
19
+ }
21
20
  }
22
21
  },
23
22
  "homepage": "https://www.bytescale.com/docs/sdks/javascript",
@@ -37,7 +37,7 @@ describe("UrlBuilder", () => {
37
37
  const actual = new UrlBuilder().url({
38
38
  accountId: "1234abc",
39
39
  filePath: "/example.jpg",
40
- options: { transformation: { type: "preset", preset: "thumbnail" } }
40
+ options: { transformation: "preset", transformationPreset: "thumbnail" }
41
41
  });
42
42
  const expected = "https://upcdn.io/1234abc/thumbnail/example.jpg";
43
43
  expect(actual).toEqual(expected);
@@ -47,7 +47,7 @@ describe("UrlBuilder", () => {
47
47
  const actual = new UrlBuilder().url({
48
48
  accountId: "1234abc",
49
49
  filePath: "/example.jpg",
50
- options: { transformation: { type: "preset", preset: "thumbnail", params: { artifact: "/foo" } } }
50
+ options: { transformation: "preset", transformationPreset: "thumbnail", artifact: "/foo" }
51
51
  });
52
52
  const expected = "https://upcdn.io/1234abc/thumbnail/example.jpg?artifact=%2Ffoo";
53
53
  expect(actual).toEqual(expected);
@@ -57,9 +57,7 @@ describe("UrlBuilder", () => {
57
57
  const actual = new UrlBuilder().url({
58
58
  accountId: "1234abc",
59
59
  filePath: "/example.jpg",
60
- options: {
61
- transformation: { type: "preset", preset: "thumbnail", params: { large: false, artifact: "/foo" } }
62
- }
60
+ options: { transformation: "preset", transformationPreset: "thumbnail", artifact: "/foo", large: false }
63
61
  });
64
62
  const expected = "https://upcdn.io/1234abc/thumbnail/example.jpg?large=false&artifact=%2Ffoo";
65
63
  expect(actual).toEqual(expected);
@@ -70,8 +68,10 @@ describe("UrlBuilder", () => {
70
68
  accountId: "1234abc",
71
69
  filePath: "/example.jpg",
72
70
  options: {
73
- // cachePermanently is rewritten to cache_perm
74
- transformation: { type: "preset", preset: "thumbnail", params: { cachePermanently: false, artifact: "/foo" } }
71
+ transformation: "preset",
72
+ transformationPreset: "thumbnail",
73
+ artifact: "/foo",
74
+ cachePermanently: false
75
75
  }
76
76
  });
77
77
  const expected = "https://upcdn.io/1234abc/thumbnail/example.jpg?cache_perm=false&artifact=%2Ffoo";
@@ -83,9 +83,7 @@ describe("UrlBuilder", () => {
83
83
  accountId: "1234abc",
84
84
  filePath: "/example.jpg",
85
85
  options: {
86
- transformation: {
87
- type: "image"
88
- }
86
+ transformation: "image"
89
87
  }
90
88
  });
91
89
  const expected = "https://upcdn.io/1234abc/image/example.jpg";
@@ -97,11 +95,9 @@ describe("UrlBuilder", () => {
97
95
  accountId: "1234abc",
98
96
  filePath: "/example.jpg",
99
97
  options: {
100
- transformation: {
101
- type: "image",
102
- params: {
103
- w: 42
104
- }
98
+ transformation: "image",
99
+ transformationParams: {
100
+ w: 42
105
101
  }
106
102
  }
107
103
  });
@@ -114,17 +110,20 @@ describe("UrlBuilder", () => {
114
110
  accountId: "1234abc",
115
111
  filePath: "/example.jpg",
116
112
  options: {
117
- transformation: {
118
- type: "image",
119
- params: {
120
- w: 42,
121
- h: 50
122
- }
113
+ transformation: "image",
114
+ transformationParams: {
115
+ w: 42,
116
+ h: 50
123
117
  },
118
+ cachePermanently: "auto",
119
+ artifact: "/foo",
120
+ large: true,
121
+ version: "50",
124
122
  auth: true
125
123
  }
126
124
  });
127
- const expected = "https://upcdn.io/1234abc/image/example.jpg?auth=true&w=42&h=50";
125
+ const expected =
126
+ "https://upcdn.io/1234abc/image/example.jpg?w=42&h=50&auth=true&version=50&cache_perm=auto&large=true&artifact=%2Ffoo";
128
127
  expect(actual).toEqual(expected);
129
128
  });
130
129
 
@@ -133,18 +132,16 @@ describe("UrlBuilder", () => {
133
132
  accountId: "1234abc",
134
133
  filePath: "/example.jpg",
135
134
  options: {
136
- transformation: {
137
- type: "image",
138
- params: {
139
- w: null,
140
- h: undefined,
141
- r: 52
142
- }
135
+ transformation: "image",
136
+ transformationParams: {
137
+ w: undefined,
138
+ h: null,
139
+ r: 52
143
140
  },
144
141
  auth: true
145
142
  }
146
143
  });
147
- const expected = "https://upcdn.io/1234abc/image/example.jpg?auth=true&r=52";
144
+ const expected = "https://upcdn.io/1234abc/image/example.jpg?r=52&auth=true";
148
145
  expect(actual).toEqual(expected);
149
146
  });
150
147
 
@@ -153,12 +150,10 @@ describe("UrlBuilder", () => {
153
150
  accountId: "1234abc",
154
151
  filePath: "/example.jpg",
155
152
  options: {
156
- transformation: {
157
- type: "image",
158
- params: {
159
- w: 42,
160
- h: 50
161
- }
153
+ transformation: "image",
154
+ transformationParams: {
155
+ w: 42,
156
+ h: 50
162
157
  }
163
158
  }
164
159
  });