@bytescale/sdk 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -316,33 +316,17 @@ var BytescaleApiError = /*#__PURE__*/function (_Error2) {
316
316
  return runtime_createClass(BytescaleApiError);
317
317
  }( /*#__PURE__*/_wrapNativeSuper(Error));
318
318
  function querystring(params) {
319
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
320
319
  return Object.keys(params).map(function (key) {
321
- return querystringSingleKey(key, params[key], prefix);
320
+ return querystringSingleKey(key, params[key]);
322
321
  }).filter(function (part) {
323
322
  return part.length > 0;
324
323
  }).join("&");
325
324
  }
326
325
  function querystringSingleKey(key, value) {
327
- var keyPrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
328
- var fullKey = keyPrefix + (keyPrefix.length ? "[".concat(key, "]") : key);
329
- if (value instanceof Array) {
330
- var multiValue = value.map(function (singleValue) {
331
- return encodeURIComponent(String(singleValue));
332
- }).join("&".concat(encodeURIComponent(fullKey), "="));
333
- return "".concat(encodeURIComponent(fullKey), "=").concat(multiValue);
334
- }
335
- if (value instanceof Set) {
336
- var valueAsArray = Array.from(value);
337
- return querystringSingleKey(key, valueAsArray, keyPrefix);
338
- }
339
- if (value instanceof Date) {
340
- return "".concat(encodeURIComponent(fullKey), "=").concat(encodeURIComponent(value.toISOString()));
341
- }
342
326
  if (value instanceof Object) {
343
- return querystring(value, fullKey);
327
+ return querystring(value);
344
328
  }
345
- return "".concat(encodeURIComponent(fullKey), "=").concat(encodeURIComponent(String(value)));
329
+ return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(String(value)));
346
330
  }
347
331
  var JSONApiResponse = /*#__PURE__*/function () {
348
332
  function JSONApiResponse(raw) {
@@ -664,6 +648,9 @@ var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
664
648
  if (params.large !== undefined) {
665
649
  query["large"] = params.large;
666
650
  }
651
+ if (params.transformationParams !== undefined) {
652
+ query["transformationParams"] = params.transformationParams;
653
+ }
667
654
  if (params.version !== undefined) {
668
655
  query["version"] = params.version;
669
656
  }
@@ -695,6 +682,9 @@ var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
695
682
  try {
696
683
  var _this16 = this;
697
684
  var query = {};
685
+ if (params.transformationParams !== undefined) {
686
+ query["transformationParams"] = params.transformationParams;
687
+ }
698
688
  var headers = {};
699
689
  headers["Content-Type"] = "application/json";
700
690
  return FileApi_await(_this16.request({
@@ -1355,17 +1345,21 @@ var UrlBuilder = /*#__PURE__*/function () {
1355
1345
  /**
1356
1346
  * Builds a URL to either a raw file or a transformed file.
1357
1347
  *
1358
- * Example 1) Raw file:
1348
+ * Example 1) Getting a publicly-accessible raw file URL:
1359
1349
  *
1360
1350
  * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg" })
1361
1351
  *
1362
- * Example 2) Image resized to 500x500:
1352
+ * Example 2) Getting a publicly-accessible image URL, resized to 500x500:
1353
+ *
1354
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } } } })
1355
+ *
1356
+ * Example 3) Getting a privately-accessible image URL, resized to 500x500 (requires 'AuthManager.beginAuthSession' to be called before accessing the URL):
1363
1357
  *
1364
- * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } } })
1358
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } }, auth: true } })
1365
1359
  *
1366
- * Example 3) Image resized to 500x500, which is privately accessible (i.e. requires 'AuthManager.beginAuthSession' before it can be accessed):
1360
+ * Example 4) Getting a publicly-accessible image URL, resized using a transformation preset called "thumbnail" that was created manually in the Bytescale Dashboard:
1367
1361
  *
1368
- * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } }, auth: true })
1362
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "preset", preset: "thumbnail" } } })
1369
1363
  */
1370
1364
  UrlBuilder_createClass(UrlBuilder, [{
1371
1365
  key: "url",
@@ -338,33 +338,17 @@ var BytescaleApiError = /*#__PURE__*/function (_Error2) {
338
338
  return runtime_createClass(BytescaleApiError);
339
339
  }( /*#__PURE__*/_wrapNativeSuper(Error));
340
340
  function querystring(params) {
341
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
342
341
  return Object.keys(params).map(function (key) {
343
- return querystringSingleKey(key, params[key], prefix);
342
+ return querystringSingleKey(key, params[key]);
344
343
  }).filter(function (part) {
345
344
  return part.length > 0;
346
345
  }).join("&");
347
346
  }
348
347
  function querystringSingleKey(key, value) {
349
- var keyPrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
350
- var fullKey = keyPrefix + (keyPrefix.length ? "[".concat(key, "]") : key);
351
- if (value instanceof Array) {
352
- var multiValue = value.map(function (singleValue) {
353
- return encodeURIComponent(String(singleValue));
354
- }).join("&".concat(encodeURIComponent(fullKey), "="));
355
- return "".concat(encodeURIComponent(fullKey), "=").concat(multiValue);
356
- }
357
- if (value instanceof Set) {
358
- var valueAsArray = Array.from(value);
359
- return querystringSingleKey(key, valueAsArray, keyPrefix);
360
- }
361
- if (value instanceof Date) {
362
- return "".concat(encodeURIComponent(fullKey), "=").concat(encodeURIComponent(value.toISOString()));
363
- }
364
348
  if (value instanceof Object) {
365
- return querystring(value, fullKey);
349
+ return querystring(value);
366
350
  }
367
- return "".concat(encodeURIComponent(fullKey), "=").concat(encodeURIComponent(String(value)));
351
+ return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(String(value)));
368
352
  }
369
353
  var JSONApiResponse = /*#__PURE__*/function () {
370
354
  function JSONApiResponse(raw) {
@@ -686,6 +670,9 @@ var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
686
670
  if (params.large !== undefined) {
687
671
  query["large"] = params.large;
688
672
  }
673
+ if (params.transformationParams !== undefined) {
674
+ query["transformationParams"] = params.transformationParams;
675
+ }
689
676
  if (params.version !== undefined) {
690
677
  query["version"] = params.version;
691
678
  }
@@ -717,6 +704,9 @@ var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
717
704
  try {
718
705
  var _this16 = this;
719
706
  var query = {};
707
+ if (params.transformationParams !== undefined) {
708
+ query["transformationParams"] = params.transformationParams;
709
+ }
720
710
  var headers = {};
721
711
  headers["Content-Type"] = "application/json";
722
712
  return FileApi_await(_this16.request({
@@ -1377,17 +1367,21 @@ var UrlBuilder = /*#__PURE__*/function () {
1377
1367
  /**
1378
1368
  * Builds a URL to either a raw file or a transformed file.
1379
1369
  *
1380
- * Example 1) Raw file:
1370
+ * Example 1) Getting a publicly-accessible raw file URL:
1381
1371
  *
1382
1372
  * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg" })
1383
1373
  *
1384
- * Example 2) Image resized to 500x500:
1374
+ * Example 2) Getting a publicly-accessible image URL, resized to 500x500:
1375
+ *
1376
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } } } })
1377
+ *
1378
+ * Example 3) Getting a privately-accessible image URL, resized to 500x500 (requires 'AuthManager.beginAuthSession' to be called before accessing the URL):
1385
1379
  *
1386
- * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } } })
1380
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } }, auth: true } })
1387
1381
  *
1388
- * Example 3) Image resized to 500x500, which is privately accessible (i.e. requires 'AuthManager.beginAuthSession' before it can be accessed):
1382
+ * Example 4) Getting a publicly-accessible image URL, resized using a transformation preset called "thumbnail" that was created manually in the Bytescale Dashboard:
1389
1383
  *
1390
- * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } }, auth: true })
1384
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "preset", preset: "thumbnail" } } })
1391
1385
  */
1392
1386
  UrlBuilder_createClass(UrlBuilder, [{
1393
1387
  key: "url",
@@ -325,33 +325,17 @@ var BytescaleApiError = /*#__PURE__*/function (_Error2) {
325
325
  return runtime_createClass(BytescaleApiError);
326
326
  }( /*#__PURE__*/_wrapNativeSuper(Error));
327
327
  function querystring(params) {
328
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
329
328
  return Object.keys(params).map(function (key) {
330
- return querystringSingleKey(key, params[key], prefix);
329
+ return querystringSingleKey(key, params[key]);
331
330
  }).filter(function (part) {
332
331
  return part.length > 0;
333
332
  }).join("&");
334
333
  }
335
334
  function querystringSingleKey(key, value) {
336
- var keyPrefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
337
- var fullKey = keyPrefix + (keyPrefix.length ? "[".concat(key, "]") : key);
338
- if (value instanceof Array) {
339
- var multiValue = value.map(function (singleValue) {
340
- return encodeURIComponent(String(singleValue));
341
- }).join("&".concat(encodeURIComponent(fullKey), "="));
342
- return "".concat(encodeURIComponent(fullKey), "=").concat(multiValue);
343
- }
344
- if (value instanceof Set) {
345
- var valueAsArray = Array.from(value);
346
- return querystringSingleKey(key, valueAsArray, keyPrefix);
347
- }
348
- if (value instanceof Date) {
349
- return "".concat(encodeURIComponent(fullKey), "=").concat(encodeURIComponent(value.toISOString()));
350
- }
351
335
  if (value instanceof Object) {
352
- return querystring(value, fullKey);
336
+ return querystring(value);
353
337
  }
354
- return "".concat(encodeURIComponent(fullKey), "=").concat(encodeURIComponent(String(value)));
338
+ return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(String(value)));
355
339
  }
356
340
  var JSONApiResponse = /*#__PURE__*/function () {
357
341
  function JSONApiResponse(raw) {
@@ -673,6 +657,9 @@ var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
673
657
  if (params.large !== undefined) {
674
658
  query["large"] = params.large;
675
659
  }
660
+ if (params.transformationParams !== undefined) {
661
+ query["transformationParams"] = params.transformationParams;
662
+ }
676
663
  if (params.version !== undefined) {
677
664
  query["version"] = params.version;
678
665
  }
@@ -704,6 +691,9 @@ var FileApi = /*#__PURE__*/function (_runtime$BaseAPI) {
704
691
  try {
705
692
  var _this16 = this;
706
693
  var query = {};
694
+ if (params.transformationParams !== undefined) {
695
+ query["transformationParams"] = params.transformationParams;
696
+ }
707
697
  var headers = {};
708
698
  headers["Content-Type"] = "application/json";
709
699
  return FileApi_await(_this16.request({
@@ -1364,17 +1354,21 @@ var UrlBuilder = /*#__PURE__*/function () {
1364
1354
  /**
1365
1355
  * Builds a URL to either a raw file or a transformed file.
1366
1356
  *
1367
- * Example 1) Raw file:
1357
+ * Example 1) Getting a publicly-accessible raw file URL:
1368
1358
  *
1369
1359
  * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg" })
1370
1360
  *
1371
- * Example 2) Image resized to 500x500:
1361
+ * Example 2) Getting a publicly-accessible image URL, resized to 500x500:
1362
+ *
1363
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } } } })
1364
+ *
1365
+ * Example 3) Getting a privately-accessible image URL, resized to 500x500 (requires 'AuthManager.beginAuthSession' to be called before accessing the URL):
1372
1366
  *
1373
- * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } } })
1367
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } }, auth: true } })
1374
1368
  *
1375
- * Example 3) Image resized to 500x500, which is privately accessible (i.e. requires 'AuthManager.beginAuthSession' before it can be accessed):
1369
+ * Example 4) Getting a publicly-accessible image URL, resized using a transformation preset called "thumbnail" that was created manually in the Bytescale Dashboard:
1376
1370
  *
1377
- * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } }, auth: true })
1371
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "preset", preset: "thumbnail" } } })
1378
1372
  */
1379
1373
  UrlBuilder_createClass(UrlBuilder, [{
1380
1374
  key: "url",
@@ -5,17 +5,21 @@ export declare class UrlBuilder {
5
5
  /**
6
6
  * Builds a URL to either a raw file or a transformed file.
7
7
  *
8
- * Example 1) Raw file:
8
+ * Example 1) Getting a publicly-accessible raw file URL:
9
9
  *
10
10
  * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg" })
11
11
  *
12
- * Example 2) Image resized to 500x500:
12
+ * Example 2) Getting a publicly-accessible image URL, resized to 500x500:
13
13
  *
14
- * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } } })
14
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } } } })
15
15
  *
16
- * Example 3) Image resized to 500x500, which is privately accessible (i.e. requires 'AuthManager.beginAuthSession' before it can be accessed):
16
+ * Example 3) Getting a privately-accessible image URL, resized to 500x500 (requires 'AuthManager.beginAuthSession' to be called before accessing the URL):
17
17
  *
18
- * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } }, auth: true })
18
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "image", params: { w: 500, h: 500, fit: "crop" } }, auth: true } })
19
+ *
20
+ * Example 4) Getting a publicly-accessible image URL, resized using a transformation preset called "thumbnail" that was created manually in the Bytescale Dashboard:
21
+ *
22
+ * new UrlBuilder().url({ accountId: "1234abc", filePath: "/example.jpg", options: { transformation: { type: "preset", preset: "thumbnail" } } })
19
23
  */
20
24
  url(params: UrlBuilderParams): string;
21
25
  private raw;
@@ -10,7 +10,7 @@
10
10
  * Do not edit the class manually.
11
11
  */
12
12
  import * as runtime from "../runtime";
13
- import type { AsyncResponse, CopyFileBatchRequest, CopyFileRequest, CopyFileResponse, DeleteFileBatchRequest, FileDetails, ProcessFileAndSaveRequest, ProcessFileAndSaveResponse } from "../models";
13
+ import type { AsyncResponse, CopyFileBatchRequest, CopyFileRequest, CopyFileResponse, DeleteFileBatchRequest, FileDetails, ProcessFileAndSaveRequest, ProcessFileAndSaveResponse, ProcessFileTransformationParamsParameterValue } from "../models";
14
14
  export interface CopyFileOperationParams {
15
15
  accountId: string;
16
16
  copyFileRequest: CopyFileRequest;
@@ -47,6 +47,9 @@ export interface ProcessFileParams {
47
47
  cachePerm?: ProcessFileCachePermEnum;
48
48
  cacheTtl?: number;
49
49
  large?: boolean;
50
+ transformationParams?: {
51
+ [key: string]: ProcessFileTransformationParamsParameterValue;
52
+ };
50
53
  version?: string;
51
54
  }
52
55
  export interface ProcessFileAndSaveOperationParams {
@@ -54,6 +57,9 @@ export interface ProcessFileAndSaveOperationParams {
54
57
  filePath: string;
55
58
  transformation: string;
56
59
  processFileAndSaveRequest: ProcessFileAndSaveRequest;
60
+ transformationParams?: {
61
+ [key: string]: ProcessFileTransformationParamsParameterValue;
62
+ };
57
63
  }
58
64
  /**
59
65
  *
@@ -1,15 +1,5 @@
1
1
  /**
2
- * "Created" is only used when issuing jobs non-transactionally (which we do if we want the job to be picked up sooner).
3
- * In this case, a two-phase transaction is performed.
4
2
  *
5
- * T=0) "Created" job tracker created.
6
- * T=1) SQS job enqueued.
7
- * T=2) "Pending" is set into job tracker.
8
- * T=3) Response returned to use
9
- * T=4) SQS picks up job. If status is "Created" it fails the job attempt. This keeps going until eventually the job perm-fails, or it sees "Pending". It should typically (always?) see "Pending" on the first attempt, if T=2 succeeded.
10
- * T=5) SQS processes the job as normal.
11
- *
12
- * As such, the "Created" state is an internal detail, and we never expose jobs in this state to the user.
13
3
  * @export
14
4
  */
15
5
  export declare type AccountJobStatus = "Created" | "Pending" | "Running" | "Rollback" | "Failed" | "Succeeded" | "Cancelling" | "Cancelled";
@@ -1678,6 +1668,12 @@ export interface ProcessFileAndSaveResponse {
1678
1668
  [key: string]: any;
1679
1669
  };
1680
1670
  }
1671
+ /**
1672
+ * @type ProcessFileTransformationParamsParameterValue
1673
+ *
1674
+ * @export
1675
+ */
1676
+ export declare type ProcessFileTransformationParamsParameterValue = boolean | number | string;
1681
1677
  /**
1682
1678
  * Permissions applied to anonymous users who attempt to download files from a folder.
1683
1679
  *
@@ -79,7 +79,7 @@ export declare type HTTPHeaders = {
79
79
  [key: string]: string;
80
80
  };
81
81
  export declare type HTTPQuery = {
82
- [key: string]: string | number | null | boolean | Array<string | number | null | boolean> | Set<string | number | null | boolean> | HTTPQuery;
82
+ [key: string]: string | number | null | boolean | HTTPQuery;
83
83
  };
84
84
  export declare type HTTPBody = Json | FormData | URLSearchParams;
85
85
  export declare type HTTPRequestInit = {
@@ -98,7 +98,7 @@ export interface RequestOpts {
98
98
  query?: HTTPQuery;
99
99
  body?: HTTPBody;
100
100
  }
101
- export declare function querystring(params: HTTPQuery, prefix?: string): string;
101
+ export declare function querystring(params: HTTPQuery): string;
102
102
  export interface ApiResponse<T> {
103
103
  raw: Response;
104
104
  value(): Promise<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytescale/sdk",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Bytescale JavaScript SDK",
5
5
  "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
6
6
  "license": "MIT",