@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.
@@ -42,7 +42,7 @@ __lib_require__.d(__lib_exports__, {
42
42
  "AuthManager": function() { return /* reexport */ AuthManager; },
43
43
  "BaseAPI": function() { return /* reexport */ BaseAPI; },
44
44
  "BinaryResult": function() { return /* reexport */ BinaryResult; },
45
- "BytescaleApiClientConfigResolver": function() { return /* reexport */ BytescaleApiClientConfigResolver; },
45
+ "BytescaleApiClientConfigUtils": function() { return /* reexport */ BytescaleApiClientConfigUtils; },
46
46
  "BytescaleApiError": function() { return /* reexport */ BytescaleApiError; },
47
47
  "CancelledError": function() { return /* reexport */ CancelledError; },
48
48
  "CommonTypesNoOp": function() { return /* reexport */ CommonTypesNoOp; },
@@ -118,21 +118,21 @@ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoPr
118
118
  function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
119
119
  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); }
120
120
 
121
- var BytescaleApiClientConfigResolver = /*#__PURE__*/function () {
122
- function BytescaleApiClientConfigResolver() {
123
- runtime_classCallCheck(this, BytescaleApiClientConfigResolver);
121
+ var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
122
+ function BytescaleApiClientConfigUtils() {
123
+ runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
124
124
  }
125
- runtime_createClass(BytescaleApiClientConfigResolver, null, [{
125
+ runtime_createClass(BytescaleApiClientConfigUtils, null, [{
126
126
  key: "getApiUrl",
127
127
  value: function getApiUrl(config) {
128
128
  var _a;
129
- return (_a = config.apiUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigResolver.defaultApiUrl;
129
+ return (_a = config.apiUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultApiUrl;
130
130
  }
131
131
  }, {
132
132
  key: "getCdnUrl",
133
133
  value: function getCdnUrl(config) {
134
134
  var _a;
135
- return (_a = config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigResolver.defaultCdnUrl;
135
+ return (_a = config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultCdnUrl;
136
136
  }
137
137
  }, {
138
138
  key: "getFetchApi",
@@ -140,11 +140,48 @@ var BytescaleApiClientConfigResolver = /*#__PURE__*/function () {
140
140
  var _a;
141
141
  return (_a = config.fetchApi) !== null && _a !== void 0 ? _a : fetch;
142
142
  }
143
+ }, {
144
+ key: "getAccountId",
145
+ value: function getAccountId(config) {
146
+ var _a, _b;
147
+ var accountId;
148
+ if (BytescaleApiClientConfigUtils.specialApiKeys.includes(config.apiKey)) {
149
+ accountId = BytescaleApiClientConfigUtils.specialApiKeyAccountId;
150
+ } else {
151
+ accountId = (_b = (_a = config.apiKey.split("_")[1]) === null || _a === void 0 ? void 0 : _a.substr(0, BytescaleApiClientConfigUtils.accountIdLength)) !== null && _b !== void 0 ? _b : "";
152
+ if (accountId.length !== BytescaleApiClientConfigUtils.accountIdLength) {
153
+ throw new Error("Invalid Bytescale API key.");
154
+ }
155
+ }
156
+ return accountId;
157
+ }
158
+ }, {
159
+ key: "validate",
160
+ value: function validate(config) {
161
+ var _a;
162
+ // Defensive programming, for users not using TypeScript. Mainly because this is used by UploadWidget users.
163
+ if ((config !== null && config !== void 0 ? config : undefined) === undefined) {
164
+ throw new Error("Config parameter required.");
165
+ }
166
+ if (((_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined) === undefined) {
167
+ throw new Error("Please provide an API key via the 'apiKey' config parameter.");
168
+ }
169
+ if (config.apiKey.trim() !== config.apiKey) {
170
+ // We do not support API keys with whitespace (by trimming ourselves) because otherwise we'd need to support this
171
+ // everywhere in perpetuity (since removing the trimming would be a breaking change).
172
+ throw new Error("API key needs trimming (whitespace detected).");
173
+ }
174
+ // This performs futher validation on the API key...
175
+ BytescaleApiClientConfigUtils.getAccountId(config);
176
+ }
143
177
  }]);
144
- return BytescaleApiClientConfigResolver;
178
+ return BytescaleApiClientConfigUtils;
145
179
  }();
146
- BytescaleApiClientConfigResolver.defaultApiUrl = "https://api.bytescale.com";
147
- BytescaleApiClientConfigResolver.defaultCdnUrl = "https://upcdn.io";
180
+ BytescaleApiClientConfigUtils.defaultApiUrl = "https://api.bytescale.com";
181
+ BytescaleApiClientConfigUtils.defaultCdnUrl = "https://upcdn.io";
182
+ BytescaleApiClientConfigUtils.specialApiKeys = ["free", "demo"];
183
+ BytescaleApiClientConfigUtils.specialApiKeyAccountId = "W142hJk";
184
+ BytescaleApiClientConfigUtils.accountIdLength = 7; // Sync with: upload/shared/**/AccountIdUtils
148
185
  /**
149
186
  * This is the base class for all generated API classes.
150
187
  */
@@ -152,6 +189,7 @@ var BaseAPI = /*#__PURE__*/function () {
152
189
  function BaseAPI(config) {
153
190
  runtime_classCallCheck(this, BaseAPI);
154
191
  this.config = config;
192
+ BytescaleApiClientConfigUtils.validate(config);
155
193
  }
156
194
  runtime_createClass(BaseAPI, [{
157
195
  key: "request",
@@ -166,7 +204,7 @@ var BaseAPI = /*#__PURE__*/function () {
166
204
  }
167
205
  // Key: any possible value for 'baseUrlOverride'
168
206
  // Value: user-overridden value for that base URL from the config.
169
- var nonDefaultBasePaths = _defineProperty({}, BytescaleApiClientConfigResolver.defaultCdnUrl, BytescaleApiClientConfigResolver.getCdnUrl(_this2.config));
207
+ var nonDefaultBasePaths = _defineProperty({}, BytescaleApiClientConfigUtils.defaultCdnUrl, BytescaleApiClientConfigUtils.getCdnUrl(_this2.config));
170
208
  return _await(_this2.createFetchParams(context, initOverrides, baseUrlOverride === undefined ? undefined : (_b = nonDefaultBasePaths[baseUrlOverride]) !== null && _b !== void 0 ? _b : baseUrlOverride), function (_ref) {
171
209
  var url = _ref.url,
172
210
  init = _ref.init;
@@ -188,7 +226,7 @@ var BaseAPI = /*#__PURE__*/function () {
188
226
  var _a, _b;
189
227
  var response;
190
228
  return _continue(_catch(function () {
191
- return _await(BytescaleApiClientConfigResolver.getFetchApi(_this4.config)(url, init), function (_BytescaleApiClientCo) {
229
+ return _await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, init), function (_BytescaleApiClientCo) {
192
230
  response = _BytescaleApiClientCo;
193
231
  });
194
232
  }, function (e) {
@@ -242,7 +280,7 @@ var BaseAPI = /*#__PURE__*/function () {
242
280
  value: function createFetchParams(context, initOverrides, baseUrlOverride) {
243
281
  try {
244
282
  var _this6 = this;
245
- var url = (baseUrlOverride !== null && baseUrlOverride !== void 0 ? baseUrlOverride : BytescaleApiClientConfigResolver.getApiUrl(_this6.config)) + context.path;
283
+ var url = (baseUrlOverride !== null && baseUrlOverride !== void 0 ? baseUrlOverride : BytescaleApiClientConfigUtils.getApiUrl(_this6.config)) + context.path;
246
284
  if (context.query !== undefined && Object.keys(context.query).length !== 0) {
247
285
  // only add the querystring to the URL if there are query parameters.
248
286
  // this is done to avoid urls ending with a "?" character which buggy webservers
@@ -286,9 +324,6 @@ var BaseAPI = /*#__PURE__*/function () {
286
324
  }]);
287
325
  return BaseAPI;
288
326
  }();
289
- BaseAPI.specialApiKeys = ["free", "demo"];
290
- BaseAPI.specialApiKeyAccountId = "W142hJk";
291
- BaseAPI.accountIdLength = 7; // Sync with: upload/shared/**/AccountIdUtils
292
327
  var CancelledError = /*#__PURE__*/function (_Error) {
293
328
  _inherits(CancelledError, _Error);
294
329
  var _super = _createSuper(CancelledError);
@@ -446,9 +481,6 @@ function FileApi_getPrototypeOf(o) { FileApi_getPrototypeOf = Object.setPrototyp
446
481
  */
447
482
  // @ts-ignore
448
483
 
449
- /**
450
- *
451
- */
452
484
  var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
453
485
  FileApi_inherits(FileApi, _runtime$BaseAPI);
454
486
  var _super = FileApi_createSuper(FileApi);
@@ -747,9 +779,6 @@ function FolderApi_getPrototypeOf(o) { FolderApi_getPrototypeOf = Object.setProt
747
779
  */
748
780
  // @ts-ignore
749
781
 
750
- /**
751
- *
752
- */
753
782
  var FolderApi = /*#__PURE__*/function (_runtime$BaseAPI) {
754
783
  FolderApi_inherits(FolderApi, _runtime$BaseAPI);
755
784
  var _super = FolderApi_createSuper(FolderApi);
@@ -1007,9 +1036,6 @@ function JobApi_getPrototypeOf(o) { JobApi_getPrototypeOf = Object.setPrototypeO
1007
1036
  */
1008
1037
  // @ts-ignore
1009
1038
 
1010
- /**
1011
- *
1012
- */
1013
1039
  var JobApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1014
1040
  JobApi_inherits(JobApi, _runtime$BaseAPI);
1015
1041
  var _super = JobApi_createSuper(JobApi);
@@ -1142,9 +1168,6 @@ function UploadApi_getPrototypeOf(o) { UploadApi_getPrototypeOf = Object.setProt
1142
1168
  */
1143
1169
  // @ts-ignore
1144
1170
 
1145
- /**
1146
- *
1147
- */
1148
1171
  var UploadApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1149
1172
  UploadApi_inherits(UploadApi, _runtime$BaseAPI);
1150
1173
  var _super = UploadApi_createSuper(UploadApi);
@@ -1340,7 +1363,7 @@ var UrlBuilder = /*#__PURE__*/function () {
1340
1363
  function UrlBuilder(config) {
1341
1364
  UrlBuilder_classCallCheck(this, UrlBuilder);
1342
1365
  var _a;
1343
- this.cdnUrl = (_a = config === null || config === void 0 ? void 0 : config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigResolver.defaultCdnUrl;
1366
+ this.cdnUrl = (_a = config === null || config === void 0 ? void 0 : config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultCdnUrl;
1344
1367
  }
1345
1368
  /**
1346
1369
  * Builds a URL to either a raw file or a transformed file.
@@ -1365,7 +1388,7 @@ var UrlBuilder = /*#__PURE__*/function () {
1365
1388
  key: "url",
1366
1389
  value: function url(params) {
1367
1390
  var _a;
1368
- 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);
1369
1392
  }
1370
1393
  }, {
1371
1394
  key: "raw",
@@ -1379,18 +1402,25 @@ var UrlBuilder = /*#__PURE__*/function () {
1379
1402
  key: "transformation",
1380
1403
  value: function transformation(params, trans) {
1381
1404
  var _a;
1382
- var baseUrl = this.getBaseUrl(params, trans.type === "preset" ? trans.preset : trans.type);
1383
- var transParams = this.getTransformationParams(trans, {
1384
- cachePermanently: "cache_perm"
1385
- });
1405
+ var baseUrl = this.getBaseUrl(params, trans.transformation === "preset" ? trans.transformationPreset : trans.transformation);
1406
+ var transParams = trans.transformation === "preset" ? [] : this.getTransformationParams(trans);
1386
1407
  var commonParams = this.getCommonQueryParams((_a = params.options) !== null && _a !== void 0 ? _a : {});
1387
- 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)));
1388
1411
  }
1389
1412
  }, {
1390
1413
  key: "getBaseUrl",
1391
1414
  value: function getBaseUrl(params, prefix) {
1392
1415
  return "".concat(this.cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
1393
1416
  }
1417
+ }, {
1418
+ key: "getCommonTransformationQueryParams",
1419
+ value: function getCommonTransformationQueryParams(trans) {
1420
+ return this.makeQueryParams(["cachePermanently", "large", "artifact"], {
1421
+ cachePermanently: "cache_perm"
1422
+ })(trans);
1423
+ }
1394
1424
  }, {
1395
1425
  key: "getCommonQueryParams",
1396
1426
  value: function getCommonQueryParams(params) {
@@ -1416,8 +1446,9 @@ var UrlBuilder = /*#__PURE__*/function () {
1416
1446
  }
1417
1447
  }, {
1418
1448
  key: "getTransformationParams",
1419
- value: function getTransformationParams(trans, keyRewrites) {
1420
- if (trans.params === undefined) {
1449
+ value: function getTransformationParams(trans) {
1450
+ var params = trans.transformationParams;
1451
+ if (params === undefined) {
1421
1452
  return [];
1422
1453
  }
1423
1454
  var serializeObj = function serializeObj(obj) {
@@ -1425,11 +1456,10 @@ var UrlBuilder = /*#__PURE__*/function () {
1425
1456
  var _ref2 = _slicedToArray(_ref, 2),
1426
1457
  key = _ref2[0],
1427
1458
  value = _ref2[1];
1428
- var _a;
1429
- return [(_a = keyRewrites[key]) !== null && _a !== void 0 ? _a : key, value.toString()];
1459
+ return [key, value.toString()];
1430
1460
  });
1431
1461
  };
1432
- return Array.isArray(trans.params) ? trans.params.flatMap(serializeObj) : serializeObj(trans.params);
1462
+ return Array.isArray(params) ? params.flatMap(serializeObj) : serializeObj(params);
1433
1463
  }
1434
1464
  }, {
1435
1465
  key: "addQueryParams",
@@ -2446,7 +2476,6 @@ var AuthManager = /*#__PURE__*/function (_BaseAPI) {
2446
2476
  function AuthManager(config) {
2447
2477
  var _this;
2448
2478
  AuthManagerBrowser_classCallCheck(this, AuthManager);
2449
- var _a, _b;
2450
2479
  _this = _super.call(this, config);
2451
2480
  _this.authSessionMutex = new Mutex();
2452
2481
  _this.contentType = "content-type";
@@ -2455,16 +2484,9 @@ var AuthManager = /*#__PURE__*/function (_BaseAPI) {
2455
2484
  _this.minJwtTtlSeconds = 10;
2456
2485
  _this.retryAuthAfterErrorSeconds = 5;
2457
2486
  _this.refreshBeforeExpirySeconds = 20;
2458
- var accountId;
2459
- if (BaseAPI.specialApiKeys.includes(config.apiKey)) {
2460
- accountId = BaseAPI.specialApiKeyAccountId;
2461
- } else {
2462
- accountId = (_b = (_a = config.apiKey.split("_")[1]) === null || _a === void 0 ? void 0 : _a.substr(0, BaseAPI.accountIdLength)) !== null && _b !== void 0 ? _b : "";
2463
- if (accountId.length !== BaseAPI.accountIdLength) {
2464
- throw new Error("Invalid Bytescale API key.");
2465
- }
2466
- }
2467
- _this.accessTokenUrl = "".concat(BytescaleApiClientConfigResolver.getCdnUrl(config), "/api/v1/access_tokens/").concat(accountId);
2487
+ var cdnUrl = BytescaleApiClientConfigUtils.getCdnUrl(config);
2488
+ var accountId = BytescaleApiClientConfigUtils.getAccountId(config);
2489
+ _this.accessTokenUrl = "".concat(cdnUrl, "/api/v1/access_tokens/").concat(accountId);
2468
2490
  return _this;
2469
2491
  }
2470
2492
  AuthManagerBrowser_createClass(AuthManager, [{
@@ -64,7 +64,7 @@ __lib_require__.d(__lib_exports__, {
64
64
  "AuthManager": function() { return /* reexport */ AuthManager; },
65
65
  "BaseAPI": function() { return /* reexport */ BaseAPI; },
66
66
  "BinaryResult": function() { return /* reexport */ BinaryResult; },
67
- "BytescaleApiClientConfigResolver": function() { return /* reexport */ BytescaleApiClientConfigResolver; },
67
+ "BytescaleApiClientConfigUtils": function() { return /* reexport */ BytescaleApiClientConfigUtils; },
68
68
  "BytescaleApiError": function() { return /* reexport */ BytescaleApiError; },
69
69
  "CancelledError": function() { return /* reexport */ CancelledError; },
70
70
  "CommonTypesNoOp": function() { return /* reexport */ CommonTypesNoOp; },
@@ -140,21 +140,21 @@ function runtime_createClass(Constructor, protoProps, staticProps) { if (protoPr
140
140
  function runtime_toPropertyKey(arg) { var key = runtime_toPrimitive(arg, "string"); return runtime_typeof(key) === "symbol" ? key : String(key); }
141
141
  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); }
142
142
 
143
- var BytescaleApiClientConfigResolver = /*#__PURE__*/function () {
144
- function BytescaleApiClientConfigResolver() {
145
- runtime_classCallCheck(this, BytescaleApiClientConfigResolver);
143
+ var BytescaleApiClientConfigUtils = /*#__PURE__*/function () {
144
+ function BytescaleApiClientConfigUtils() {
145
+ runtime_classCallCheck(this, BytescaleApiClientConfigUtils);
146
146
  }
147
- runtime_createClass(BytescaleApiClientConfigResolver, null, [{
147
+ runtime_createClass(BytescaleApiClientConfigUtils, null, [{
148
148
  key: "getApiUrl",
149
149
  value: function getApiUrl(config) {
150
150
  var _a;
151
- return (_a = config.apiUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigResolver.defaultApiUrl;
151
+ return (_a = config.apiUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultApiUrl;
152
152
  }
153
153
  }, {
154
154
  key: "getCdnUrl",
155
155
  value: function getCdnUrl(config) {
156
156
  var _a;
157
- return (_a = config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigResolver.defaultCdnUrl;
157
+ return (_a = config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultCdnUrl;
158
158
  }
159
159
  }, {
160
160
  key: "getFetchApi",
@@ -162,11 +162,48 @@ var BytescaleApiClientConfigResolver = /*#__PURE__*/function () {
162
162
  var _a;
163
163
  return (_a = config.fetchApi) !== null && _a !== void 0 ? _a : fetch;
164
164
  }
165
+ }, {
166
+ key: "getAccountId",
167
+ value: function getAccountId(config) {
168
+ var _a, _b;
169
+ var accountId;
170
+ if (BytescaleApiClientConfigUtils.specialApiKeys.includes(config.apiKey)) {
171
+ accountId = BytescaleApiClientConfigUtils.specialApiKeyAccountId;
172
+ } else {
173
+ accountId = (_b = (_a = config.apiKey.split("_")[1]) === null || _a === void 0 ? void 0 : _a.substr(0, BytescaleApiClientConfigUtils.accountIdLength)) !== null && _b !== void 0 ? _b : "";
174
+ if (accountId.length !== BytescaleApiClientConfigUtils.accountIdLength) {
175
+ throw new Error("Invalid Bytescale API key.");
176
+ }
177
+ }
178
+ return accountId;
179
+ }
180
+ }, {
181
+ key: "validate",
182
+ value: function validate(config) {
183
+ var _a;
184
+ // Defensive programming, for users not using TypeScript. Mainly because this is used by UploadWidget users.
185
+ if ((config !== null && config !== void 0 ? config : undefined) === undefined) {
186
+ throw new Error("Config parameter required.");
187
+ }
188
+ if (((_a = config.apiKey) !== null && _a !== void 0 ? _a : undefined) === undefined) {
189
+ throw new Error("Please provide an API key via the 'apiKey' config parameter.");
190
+ }
191
+ if (config.apiKey.trim() !== config.apiKey) {
192
+ // We do not support API keys with whitespace (by trimming ourselves) because otherwise we'd need to support this
193
+ // everywhere in perpetuity (since removing the trimming would be a breaking change).
194
+ throw new Error("API key needs trimming (whitespace detected).");
195
+ }
196
+ // This performs futher validation on the API key...
197
+ BytescaleApiClientConfigUtils.getAccountId(config);
198
+ }
165
199
  }]);
166
- return BytescaleApiClientConfigResolver;
200
+ return BytescaleApiClientConfigUtils;
167
201
  }();
168
- BytescaleApiClientConfigResolver.defaultApiUrl = "https://api.bytescale.com";
169
- BytescaleApiClientConfigResolver.defaultCdnUrl = "https://upcdn.io";
202
+ BytescaleApiClientConfigUtils.defaultApiUrl = "https://api.bytescale.com";
203
+ BytescaleApiClientConfigUtils.defaultCdnUrl = "https://upcdn.io";
204
+ BytescaleApiClientConfigUtils.specialApiKeys = ["free", "demo"];
205
+ BytescaleApiClientConfigUtils.specialApiKeyAccountId = "W142hJk";
206
+ BytescaleApiClientConfigUtils.accountIdLength = 7; // Sync with: upload/shared/**/AccountIdUtils
170
207
  /**
171
208
  * This is the base class for all generated API classes.
172
209
  */
@@ -174,6 +211,7 @@ var BaseAPI = /*#__PURE__*/function () {
174
211
  function BaseAPI(config) {
175
212
  runtime_classCallCheck(this, BaseAPI);
176
213
  this.config = config;
214
+ BytescaleApiClientConfigUtils.validate(config);
177
215
  }
178
216
  runtime_createClass(BaseAPI, [{
179
217
  key: "request",
@@ -188,7 +226,7 @@ var BaseAPI = /*#__PURE__*/function () {
188
226
  }
189
227
  // Key: any possible value for 'baseUrlOverride'
190
228
  // Value: user-overridden value for that base URL from the config.
191
- var nonDefaultBasePaths = _defineProperty({}, BytescaleApiClientConfigResolver.defaultCdnUrl, BytescaleApiClientConfigResolver.getCdnUrl(_this2.config));
229
+ var nonDefaultBasePaths = _defineProperty({}, BytescaleApiClientConfigUtils.defaultCdnUrl, BytescaleApiClientConfigUtils.getCdnUrl(_this2.config));
192
230
  return _await(_this2.createFetchParams(context, initOverrides, baseUrlOverride === undefined ? undefined : (_b = nonDefaultBasePaths[baseUrlOverride]) !== null && _b !== void 0 ? _b : baseUrlOverride), function (_ref) {
193
231
  var url = _ref.url,
194
232
  init = _ref.init;
@@ -210,7 +248,7 @@ var BaseAPI = /*#__PURE__*/function () {
210
248
  var _a, _b;
211
249
  var response;
212
250
  return _continue(_catch(function () {
213
- return _await(BytescaleApiClientConfigResolver.getFetchApi(_this4.config)(url, init), function (_BytescaleApiClientCo) {
251
+ return _await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, init), function (_BytescaleApiClientCo) {
214
252
  response = _BytescaleApiClientCo;
215
253
  });
216
254
  }, function (e) {
@@ -264,7 +302,7 @@ var BaseAPI = /*#__PURE__*/function () {
264
302
  value: function createFetchParams(context, initOverrides, baseUrlOverride) {
265
303
  try {
266
304
  var _this6 = this;
267
- var url = (baseUrlOverride !== null && baseUrlOverride !== void 0 ? baseUrlOverride : BytescaleApiClientConfigResolver.getApiUrl(_this6.config)) + context.path;
305
+ var url = (baseUrlOverride !== null && baseUrlOverride !== void 0 ? baseUrlOverride : BytescaleApiClientConfigUtils.getApiUrl(_this6.config)) + context.path;
268
306
  if (context.query !== undefined && Object.keys(context.query).length !== 0) {
269
307
  // only add the querystring to the URL if there are query parameters.
270
308
  // this is done to avoid urls ending with a "?" character which buggy webservers
@@ -308,9 +346,6 @@ var BaseAPI = /*#__PURE__*/function () {
308
346
  }]);
309
347
  return BaseAPI;
310
348
  }();
311
- BaseAPI.specialApiKeys = ["free", "demo"];
312
- BaseAPI.specialApiKeyAccountId = "W142hJk";
313
- BaseAPI.accountIdLength = 7; // Sync with: upload/shared/**/AccountIdUtils
314
349
  var CancelledError = /*#__PURE__*/function (_Error) {
315
350
  _inherits(CancelledError, _Error);
316
351
  var _super = _createSuper(CancelledError);
@@ -468,9 +503,6 @@ function FileApi_getPrototypeOf(o) { FileApi_getPrototypeOf = Object.setPrototyp
468
503
  */
469
504
  // @ts-ignore
470
505
 
471
- /**
472
- *
473
- */
474
506
  var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
475
507
  FileApi_inherits(FileApi, _runtime$BaseAPI);
476
508
  var _super = FileApi_createSuper(FileApi);
@@ -769,9 +801,6 @@ function FolderApi_getPrototypeOf(o) { FolderApi_getPrototypeOf = Object.setProt
769
801
  */
770
802
  // @ts-ignore
771
803
 
772
- /**
773
- *
774
- */
775
804
  var FolderApi = /*#__PURE__*/function (_runtime$BaseAPI) {
776
805
  FolderApi_inherits(FolderApi, _runtime$BaseAPI);
777
806
  var _super = FolderApi_createSuper(FolderApi);
@@ -1029,9 +1058,6 @@ function JobApi_getPrototypeOf(o) { JobApi_getPrototypeOf = Object.setPrototypeO
1029
1058
  */
1030
1059
  // @ts-ignore
1031
1060
 
1032
- /**
1033
- *
1034
- */
1035
1061
  var JobApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1036
1062
  JobApi_inherits(JobApi, _runtime$BaseAPI);
1037
1063
  var _super = JobApi_createSuper(JobApi);
@@ -1164,9 +1190,6 @@ function UploadApi_getPrototypeOf(o) { UploadApi_getPrototypeOf = Object.setProt
1164
1190
  */
1165
1191
  // @ts-ignore
1166
1192
 
1167
- /**
1168
- *
1169
- */
1170
1193
  var UploadApi = /*#__PURE__*/function (_runtime$BaseAPI) {
1171
1194
  UploadApi_inherits(UploadApi, _runtime$BaseAPI);
1172
1195
  var _super = UploadApi_createSuper(UploadApi);
@@ -1362,7 +1385,7 @@ var UrlBuilder = /*#__PURE__*/function () {
1362
1385
  function UrlBuilder(config) {
1363
1386
  UrlBuilder_classCallCheck(this, UrlBuilder);
1364
1387
  var _a;
1365
- this.cdnUrl = (_a = config === null || config === void 0 ? void 0 : config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigResolver.defaultCdnUrl;
1388
+ this.cdnUrl = (_a = config === null || config === void 0 ? void 0 : config.cdnUrl) !== null && _a !== void 0 ? _a : BytescaleApiClientConfigUtils.defaultCdnUrl;
1366
1389
  }
1367
1390
  /**
1368
1391
  * Builds a URL to either a raw file or a transformed file.
@@ -1387,7 +1410,7 @@ var UrlBuilder = /*#__PURE__*/function () {
1387
1410
  key: "url",
1388
1411
  value: function url(params) {
1389
1412
  var _a;
1390
- 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);
1391
1414
  }
1392
1415
  }, {
1393
1416
  key: "raw",
@@ -1401,18 +1424,25 @@ var UrlBuilder = /*#__PURE__*/function () {
1401
1424
  key: "transformation",
1402
1425
  value: function transformation(params, trans) {
1403
1426
  var _a;
1404
- var baseUrl = this.getBaseUrl(params, trans.type === "preset" ? trans.preset : trans.type);
1405
- var transParams = this.getTransformationParams(trans, {
1406
- cachePermanently: "cache_perm"
1407
- });
1427
+ var baseUrl = this.getBaseUrl(params, trans.transformation === "preset" ? trans.transformationPreset : trans.transformation);
1428
+ var transParams = trans.transformation === "preset" ? [] : this.getTransformationParams(trans);
1408
1429
  var commonParams = this.getCommonQueryParams((_a = params.options) !== null && _a !== void 0 ? _a : {});
1409
- 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)));
1410
1433
  }
1411
1434
  }, {
1412
1435
  key: "getBaseUrl",
1413
1436
  value: function getBaseUrl(params, prefix) {
1414
1437
  return "".concat(this.cdnUrl, "/").concat(params.accountId, "/").concat(prefix).concat(params.filePath);
1415
1438
  }
1439
+ }, {
1440
+ key: "getCommonTransformationQueryParams",
1441
+ value: function getCommonTransformationQueryParams(trans) {
1442
+ return this.makeQueryParams(["cachePermanently", "large", "artifact"], {
1443
+ cachePermanently: "cache_perm"
1444
+ })(trans);
1445
+ }
1416
1446
  }, {
1417
1447
  key: "getCommonQueryParams",
1418
1448
  value: function getCommonQueryParams(params) {
@@ -1438,8 +1468,9 @@ var UrlBuilder = /*#__PURE__*/function () {
1438
1468
  }
1439
1469
  }, {
1440
1470
  key: "getTransformationParams",
1441
- value: function getTransformationParams(trans, keyRewrites) {
1442
- if (trans.params === undefined) {
1471
+ value: function getTransformationParams(trans) {
1472
+ var params = trans.transformationParams;
1473
+ if (params === undefined) {
1443
1474
  return [];
1444
1475
  }
1445
1476
  var serializeObj = function serializeObj(obj) {
@@ -1447,11 +1478,10 @@ var UrlBuilder = /*#__PURE__*/function () {
1447
1478
  var _ref2 = _slicedToArray(_ref, 2),
1448
1479
  key = _ref2[0],
1449
1480
  value = _ref2[1];
1450
- var _a;
1451
- return [(_a = keyRewrites[key]) !== null && _a !== void 0 ? _a : key, value.toString()];
1481
+ return [key, value.toString()];
1452
1482
  });
1453
1483
  };
1454
- return Array.isArray(trans.params) ? trans.params.flatMap(serializeObj) : serializeObj(trans.params);
1484
+ return Array.isArray(params) ? params.flatMap(serializeObj) : serializeObj(params);
1455
1485
  }
1456
1486
  }, {
1457
1487
  key: "addQueryParams",