@bytescale/sdk 3.0.0-alpha.14 → 3.0.0-alpha.16
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/README.md +11 -5
- package/dist/browser/cjs/main.js +11 -2
- package/dist/node/cjs/main.js +13 -3
- package/dist/node/esm/main.mjs +13 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/private/Mutex.d.ts +1 -1
- package/dist/worker/cjs/main.js +13 -3
- package/dist/worker/esm/main.mjs +13 -3
- package/package.json +2 -2
- package/dist/browser/esm/main.mjs +0 -2784
- package/dist/types/index.worker.d.ts +0 -2
package/README.md
CHANGED
|
@@ -83,7 +83,7 @@ import * as Bytescale from "@bytescale/sdk";
|
|
|
83
83
|
import nodeFetch from "node-fetch";
|
|
84
84
|
|
|
85
85
|
const uploadManager = new Bytescale.UploadManager({
|
|
86
|
-
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js
|
|
86
|
+
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
|
|
87
87
|
apiKey: "free" // Get API keys from: www.bytescale.com
|
|
88
88
|
});
|
|
89
89
|
|
|
@@ -110,6 +110,9 @@ uploadManager
|
|
|
110
110
|
// Required if 'data' is a stream, buffer, or string.
|
|
111
111
|
originalFileName: "my_file.txt"
|
|
112
112
|
|
|
113
|
+
// Reports progress: bytesTotal, bytesSent, progress.
|
|
114
|
+
// onProgress: ({ progress }) => console.log(progress),
|
|
115
|
+
|
|
113
116
|
// Controls multipart upload concurrency. Ignored if 'data' is a stream.
|
|
114
117
|
// maxConcurrentUploadParts: 4,
|
|
115
118
|
|
|
@@ -188,6 +191,9 @@ uploadManager
|
|
|
188
191
|
// Required if 'data' is a stream, buffer, or string. (Not required for DOM file inputs or blobs.)
|
|
189
192
|
// originalFileName: "my_file.txt",
|
|
190
193
|
|
|
194
|
+
// Reports progress: bytesTotal, bytesSent, progress.
|
|
195
|
+
// onProgress: ({ progress }) => console.log(progress),
|
|
196
|
+
|
|
191
197
|
// Controls multipart upload concurrency. Ignored if 'data' is a stream.
|
|
192
198
|
// maxConcurrentUploadParts: 4,
|
|
193
199
|
|
|
@@ -242,7 +248,7 @@ import * as Bytescale from "@bytescale/sdk";
|
|
|
242
248
|
import nodeFetch from "node-fetch"; // Only required for Node.js
|
|
243
249
|
|
|
244
250
|
const fileApi = new Bytescale.FileApi({
|
|
245
|
-
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js
|
|
251
|
+
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
|
|
246
252
|
apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx"
|
|
247
253
|
});
|
|
248
254
|
|
|
@@ -268,7 +274,7 @@ import fetch from "node-fetch"; // Only required for Node.js
|
|
|
268
274
|
import fs from "fs";
|
|
269
275
|
|
|
270
276
|
const fileApi = new Bytescale.FileApi({
|
|
271
|
-
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js
|
|
277
|
+
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
|
|
272
278
|
apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx"
|
|
273
279
|
});
|
|
274
280
|
|
|
@@ -309,7 +315,7 @@ import * as Bytescale from "@bytescale/sdk";
|
|
|
309
315
|
import fetch from "node-fetch"; // Only required for Node.js
|
|
310
316
|
|
|
311
317
|
const fileApi = new Bytescale.FileApi({
|
|
312
|
-
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js
|
|
318
|
+
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
|
|
313
319
|
apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx"
|
|
314
320
|
});
|
|
315
321
|
|
|
@@ -331,7 +337,7 @@ import * as Bytescale from "@bytescale/sdk";
|
|
|
331
337
|
import fetch from "node-fetch"; // Only required for Node.js
|
|
332
338
|
|
|
333
339
|
const folderApi = new Bytescale.FolderApi({
|
|
334
|
-
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js
|
|
340
|
+
fetchApi: nodeFetch, // import nodeFetch from "node-fetch"; // Only required for Node.js. TypeScript: 'nodeFetch as any' may be necessary.
|
|
335
341
|
apiKey: "YOUR_API_KEY" // e.g. "secret_xxxxx"
|
|
336
342
|
});
|
|
337
343
|
|
package/dist/browser/cjs/main.js
CHANGED
|
@@ -259,7 +259,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
259
259
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
260
260
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
261
261
|
/**
|
|
262
|
-
* A lightweight mutex. (Other libraries contain too many features and we want to keep
|
|
262
|
+
* A lightweight mutex. (Other libraries contain too many features and we want to keep size down).
|
|
263
263
|
*
|
|
264
264
|
* Characteristics:
|
|
265
265
|
* - Non-reentrant.
|
|
@@ -543,7 +543,16 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
543
543
|
var _a, _b;
|
|
544
544
|
var response;
|
|
545
545
|
return runtime_continue(_catch(function () {
|
|
546
|
-
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, init),
|
|
546
|
+
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, Object.assign(Object.assign({}, init), {
|
|
547
|
+
// This is specifically added to cater for Next.js's Fetch implementation, which caches POST requests...
|
|
548
|
+
//
|
|
549
|
+
// "fetch requests that use the POST method are also automatically cached."
|
|
550
|
+
// - https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data
|
|
551
|
+
//
|
|
552
|
+
// However, this is probably a good idea, even for all GET requests, as if the user is refreshing a JWT
|
|
553
|
+
// or downloading a file via 'FileApi.downloadFile', then they'll likely want the latest.
|
|
554
|
+
cache: "no-store"
|
|
555
|
+
})), function (_BytescaleApiClientCo) {
|
|
547
556
|
response = _BytescaleApiClientCo;
|
|
548
557
|
});
|
|
549
558
|
}, function (e) {
|
package/dist/node/cjs/main.js
CHANGED
|
@@ -259,7 +259,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
259
259
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
260
260
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
261
261
|
/**
|
|
262
|
-
* A lightweight mutex. (Other libraries contain too many features and we want to keep
|
|
262
|
+
* A lightweight mutex. (Other libraries contain too many features and we want to keep size down).
|
|
263
263
|
*
|
|
264
264
|
* Characteristics:
|
|
265
265
|
* - Non-reentrant.
|
|
@@ -543,7 +543,16 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
543
543
|
var _a, _b;
|
|
544
544
|
var response;
|
|
545
545
|
return runtime_continue(_catch(function () {
|
|
546
|
-
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, init),
|
|
546
|
+
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, Object.assign(Object.assign({}, init), {
|
|
547
|
+
// This is specifically added to cater for Next.js's Fetch implementation, which caches POST requests...
|
|
548
|
+
//
|
|
549
|
+
// "fetch requests that use the POST method are also automatically cached."
|
|
550
|
+
// - https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data
|
|
551
|
+
//
|
|
552
|
+
// However, this is probably a good idea, even for all GET requests, as if the user is refreshing a JWT
|
|
553
|
+
// or downloading a file via 'FileApi.downloadFile', then they'll likely want the latest.
|
|
554
|
+
cache: "no-store"
|
|
555
|
+
})), function (_BytescaleApiClientCo) {
|
|
547
556
|
response = _BytescaleApiClientCo;
|
|
548
557
|
});
|
|
549
558
|
}, function (e) {
|
|
@@ -2571,7 +2580,8 @@ var UploadManagerFetchUtils = /*#__PURE__*/function () {
|
|
|
2571
2580
|
method: "PUT",
|
|
2572
2581
|
headers: headers,
|
|
2573
2582
|
body: content,
|
|
2574
|
-
signal: signal
|
|
2583
|
+
signal: signal,
|
|
2584
|
+
cache: "no-store" // Required for Next.js's Fetch implementation, which caches POST/PUT requests by default.
|
|
2575
2585
|
}), function (response) {
|
|
2576
2586
|
return {
|
|
2577
2587
|
etag: (_a = response.headers.get("etag")) !== null && _a !== void 0 ? _a : undefined,
|
package/dist/node/esm/main.mjs
CHANGED
|
@@ -246,7 +246,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
246
246
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
247
247
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
248
248
|
/**
|
|
249
|
-
* A lightweight mutex. (Other libraries contain too many features and we want to keep
|
|
249
|
+
* A lightweight mutex. (Other libraries contain too many features and we want to keep size down).
|
|
250
250
|
*
|
|
251
251
|
* Characteristics:
|
|
252
252
|
* - Non-reentrant.
|
|
@@ -530,7 +530,16 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
530
530
|
var _a, _b;
|
|
531
531
|
var response;
|
|
532
532
|
return runtime_continue(_catch(function () {
|
|
533
|
-
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, init),
|
|
533
|
+
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, Object.assign(Object.assign({}, init), {
|
|
534
|
+
// This is specifically added to cater for Next.js's Fetch implementation, which caches POST requests...
|
|
535
|
+
//
|
|
536
|
+
// "fetch requests that use the POST method are also automatically cached."
|
|
537
|
+
// - https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data
|
|
538
|
+
//
|
|
539
|
+
// However, this is probably a good idea, even for all GET requests, as if the user is refreshing a JWT
|
|
540
|
+
// or downloading a file via 'FileApi.downloadFile', then they'll likely want the latest.
|
|
541
|
+
cache: "no-store"
|
|
542
|
+
})), function (_BytescaleApiClientCo) {
|
|
534
543
|
response = _BytescaleApiClientCo;
|
|
535
544
|
});
|
|
536
545
|
}, function (e) {
|
|
@@ -2562,7 +2571,8 @@ var UploadManagerFetchUtils = /*#__PURE__*/function () {
|
|
|
2562
2571
|
method: "PUT",
|
|
2563
2572
|
headers: headers,
|
|
2564
2573
|
body: content,
|
|
2565
|
-
signal: signal
|
|
2574
|
+
signal: signal,
|
|
2575
|
+
cache: "no-store" // Required for Next.js's Fetch implementation, which caches POST/PUT requests by default.
|
|
2566
2576
|
}), function (response) {
|
|
2567
2577
|
return {
|
|
2568
2578
|
etag: (_a = response.headers.get("etag")) !== null && _a !== void 0 ? _a : undefined,
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./public/shared";
|
|
2
|
-
export * from "./public/
|
|
2
|
+
export * from "./public/browser";
|
package/dist/worker/cjs/main.js
CHANGED
|
@@ -259,7 +259,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
259
259
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
260
260
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
261
261
|
/**
|
|
262
|
-
* A lightweight mutex. (Other libraries contain too many features and we want to keep
|
|
262
|
+
* A lightweight mutex. (Other libraries contain too many features and we want to keep size down).
|
|
263
263
|
*
|
|
264
264
|
* Characteristics:
|
|
265
265
|
* - Non-reentrant.
|
|
@@ -543,7 +543,16 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
543
543
|
var _a, _b;
|
|
544
544
|
var response;
|
|
545
545
|
return runtime_continue(_catch(function () {
|
|
546
|
-
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, init),
|
|
546
|
+
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, Object.assign(Object.assign({}, init), {
|
|
547
|
+
// This is specifically added to cater for Next.js's Fetch implementation, which caches POST requests...
|
|
548
|
+
//
|
|
549
|
+
// "fetch requests that use the POST method are also automatically cached."
|
|
550
|
+
// - https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data
|
|
551
|
+
//
|
|
552
|
+
// However, this is probably a good idea, even for all GET requests, as if the user is refreshing a JWT
|
|
553
|
+
// or downloading a file via 'FileApi.downloadFile', then they'll likely want the latest.
|
|
554
|
+
cache: "no-store"
|
|
555
|
+
})), function (_BytescaleApiClientCo) {
|
|
547
556
|
response = _BytescaleApiClientCo;
|
|
548
557
|
});
|
|
549
558
|
}, function (e) {
|
|
@@ -2426,7 +2435,8 @@ var UploadManagerFetchUtils = /*#__PURE__*/function () {
|
|
|
2426
2435
|
method: "PUT",
|
|
2427
2436
|
headers: headers,
|
|
2428
2437
|
body: content,
|
|
2429
|
-
signal: signal
|
|
2438
|
+
signal: signal,
|
|
2439
|
+
cache: "no-store" // Required for Next.js's Fetch implementation, which caches POST/PUT requests by default.
|
|
2430
2440
|
}), function (response) {
|
|
2431
2441
|
return {
|
|
2432
2442
|
etag: (_a = response.headers.get("etag")) !== null && _a !== void 0 ? _a : undefined,
|
package/dist/worker/esm/main.mjs
CHANGED
|
@@ -244,7 +244,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
244
244
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
245
245
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
246
246
|
/**
|
|
247
|
-
* A lightweight mutex. (Other libraries contain too many features and we want to keep
|
|
247
|
+
* A lightweight mutex. (Other libraries contain too many features and we want to keep size down).
|
|
248
248
|
*
|
|
249
249
|
* Characteristics:
|
|
250
250
|
* - Non-reentrant.
|
|
@@ -528,7 +528,16 @@ var BaseAPI = /*#__PURE__*/function () {
|
|
|
528
528
|
var _a, _b;
|
|
529
529
|
var response;
|
|
530
530
|
return runtime_continue(_catch(function () {
|
|
531
|
-
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, init),
|
|
531
|
+
return runtime_await(BytescaleApiClientConfigUtils.getFetchApi(_this4.config)(url, Object.assign(Object.assign({}, init), {
|
|
532
|
+
// This is specifically added to cater for Next.js's Fetch implementation, which caches POST requests...
|
|
533
|
+
//
|
|
534
|
+
// "fetch requests that use the POST method are also automatically cached."
|
|
535
|
+
// - https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#caching-data
|
|
536
|
+
//
|
|
537
|
+
// However, this is probably a good idea, even for all GET requests, as if the user is refreshing a JWT
|
|
538
|
+
// or downloading a file via 'FileApi.downloadFile', then they'll likely want the latest.
|
|
539
|
+
cache: "no-store"
|
|
540
|
+
})), function (_BytescaleApiClientCo) {
|
|
532
541
|
response = _BytescaleApiClientCo;
|
|
533
542
|
});
|
|
534
543
|
}, function (e) {
|
|
@@ -2411,7 +2420,8 @@ var UploadManagerFetchUtils = /*#__PURE__*/function () {
|
|
|
2411
2420
|
method: "PUT",
|
|
2412
2421
|
headers: headers,
|
|
2413
2422
|
body: content,
|
|
2414
|
-
signal: signal
|
|
2423
|
+
signal: signal,
|
|
2424
|
+
cache: "no-store" // Required for Next.js's Fetch implementation, which caches POST/PUT requests by default.
|
|
2415
2425
|
}), function (response) {
|
|
2416
2426
|
return {
|
|
2417
2427
|
etag: (_a = response.headers.get("etag")) !== null && _a !== void 0 ? _a : undefined,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bytescale/sdk",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.16",
|
|
4
4
|
"description": "Bytescale JavaScript SDK",
|
|
5
5
|
"author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
|
38
38
|
"typecheck": "tsc --noEmit",
|
|
39
39
|
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest --runInBand --silent=false --verbose=false",
|
|
40
|
-
"prepack": "npm run clean && webpack && tsc-alias && rm dist/types/index.
|
|
40
|
+
"prepack": "npm run clean && webpack && tsc-alias && rm dist/types/index.node.d.ts && rm dist/types/index.worker.d.ts && mv dist/types/index.browser.d.ts dist/types/index.d.ts",
|
|
41
41
|
"postpack": "[ ! -f bytescale-sdk-*.tgz ] || mv bytescale-sdk-*.tgz bytescale-sdk.tgz",
|
|
42
42
|
"prepare": "husky install",
|
|
43
43
|
"prepack:cdn": "npm run clean && webpack --config webpack.config.cdn.js && find dist -name \"*.ts\" -type f -delete && for f in dist/*.js; do cp -- \"$f\" \"${f%.js}\"; done",
|