@edgestore/react 0.1.5-alpha.17 → 0.1.5-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -5
- package/dist/index.mjs +11 -5
- package/dist/libs/errors/handleError.d.ts.map +1 -1
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +12 -0
- package/dist/shared/index.mjs +1 -0
- package/package.json +11 -4
- package/shared/index.d.ts +1 -0
- package/shared/index.js +1 -0
- package/src/contextProvider.tsx +1 -0
- package/src/createNextProxy.ts +4 -0
- package/src/libs/errors/handleError.ts +3 -2
- package/src/shared/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -33,14 +33,15 @@ class EdgeStoreClientError extends Error {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async function handleError(res) {
|
|
36
|
+
let json = {};
|
|
36
37
|
try {
|
|
37
|
-
|
|
38
|
-
throw new shared.EdgeStoreApiClientError({
|
|
39
|
-
response: json
|
|
40
|
-
});
|
|
38
|
+
json = await res.json();
|
|
41
39
|
} catch (err) {
|
|
42
40
|
throw new EdgeStoreClientError(`Failed to parse response. Make sure the api is correctly configured at ${res.url}`);
|
|
43
41
|
}
|
|
42
|
+
throw new shared.EdgeStoreApiClientError({
|
|
43
|
+
response: json
|
|
44
|
+
});
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
function createNextProxy({ apiPath, uploadingCountRef, maxConcurrentUploads = 5 }) {
|
|
@@ -92,6 +93,7 @@ async function uploadFile({ file, input, onProgressChange, options }, { apiPath,
|
|
|
92
93
|
onProgressChange?.(0);
|
|
93
94
|
const res = await fetch(`${apiPath}/request-upload`, {
|
|
94
95
|
method: 'POST',
|
|
96
|
+
credentials: 'include',
|
|
95
97
|
body: JSON.stringify({
|
|
96
98
|
bucketName,
|
|
97
99
|
input,
|
|
@@ -228,6 +230,7 @@ async function multipartUpload(params) {
|
|
|
228
230
|
// Complete multipart upload
|
|
229
231
|
const res = await fetch(`${apiPath}/complete-multipart-upload`, {
|
|
230
232
|
method: 'POST',
|
|
233
|
+
credentials: 'include',
|
|
231
234
|
body: JSON.stringify({
|
|
232
235
|
bucketName,
|
|
233
236
|
uploadId,
|
|
@@ -245,6 +248,7 @@ async function multipartUpload(params) {
|
|
|
245
248
|
async function confirmUpload({ url }, { apiPath, bucketName }) {
|
|
246
249
|
const res = await fetch(`${apiPath}/confirm-upload`, {
|
|
247
250
|
method: 'POST',
|
|
251
|
+
credentials: 'include',
|
|
248
252
|
body: JSON.stringify({
|
|
249
253
|
url,
|
|
250
254
|
bucketName
|
|
@@ -261,6 +265,7 @@ async function confirmUpload({ url }, { apiPath, bucketName }) {
|
|
|
261
265
|
async function deleteFile({ url }, { apiPath, bucketName }) {
|
|
262
266
|
const res = await fetch(`${apiPath}/delete-file`, {
|
|
263
267
|
method: 'POST',
|
|
268
|
+
credentials: 'include',
|
|
264
269
|
body: JSON.stringify({
|
|
265
270
|
url,
|
|
266
271
|
bucketName
|
|
@@ -365,7 +370,8 @@ function EdgeStoreProviderInner({ children, context, basePath, maxConcurrentUplo
|
|
|
365
370
|
error: false
|
|
366
371
|
});
|
|
367
372
|
const res = await fetch(`${apiPath}/init`, {
|
|
368
|
-
method: 'POST'
|
|
373
|
+
method: 'POST',
|
|
374
|
+
credentials: 'include'
|
|
369
375
|
});
|
|
370
376
|
if (res.ok) {
|
|
371
377
|
const json = await res.json();
|
package/dist/index.mjs
CHANGED
|
@@ -9,14 +9,15 @@ class EdgeStoreClientError extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
async function handleError(res) {
|
|
12
|
+
let json = {};
|
|
12
13
|
try {
|
|
13
|
-
|
|
14
|
-
throw new EdgeStoreApiClientError({
|
|
15
|
-
response: json
|
|
16
|
-
});
|
|
14
|
+
json = await res.json();
|
|
17
15
|
} catch (err) {
|
|
18
16
|
throw new EdgeStoreClientError(`Failed to parse response. Make sure the api is correctly configured at ${res.url}`);
|
|
19
17
|
}
|
|
18
|
+
throw new EdgeStoreApiClientError({
|
|
19
|
+
response: json
|
|
20
|
+
});
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
function createNextProxy({ apiPath, uploadingCountRef, maxConcurrentUploads = 5 }) {
|
|
@@ -68,6 +69,7 @@ async function uploadFile({ file, input, onProgressChange, options }, { apiPath,
|
|
|
68
69
|
onProgressChange?.(0);
|
|
69
70
|
const res = await fetch(`${apiPath}/request-upload`, {
|
|
70
71
|
method: 'POST',
|
|
72
|
+
credentials: 'include',
|
|
71
73
|
body: JSON.stringify({
|
|
72
74
|
bucketName,
|
|
73
75
|
input,
|
|
@@ -204,6 +206,7 @@ async function multipartUpload(params) {
|
|
|
204
206
|
// Complete multipart upload
|
|
205
207
|
const res = await fetch(`${apiPath}/complete-multipart-upload`, {
|
|
206
208
|
method: 'POST',
|
|
209
|
+
credentials: 'include',
|
|
207
210
|
body: JSON.stringify({
|
|
208
211
|
bucketName,
|
|
209
212
|
uploadId,
|
|
@@ -221,6 +224,7 @@ async function multipartUpload(params) {
|
|
|
221
224
|
async function confirmUpload({ url }, { apiPath, bucketName }) {
|
|
222
225
|
const res = await fetch(`${apiPath}/confirm-upload`, {
|
|
223
226
|
method: 'POST',
|
|
227
|
+
credentials: 'include',
|
|
224
228
|
body: JSON.stringify({
|
|
225
229
|
url,
|
|
226
230
|
bucketName
|
|
@@ -237,6 +241,7 @@ async function confirmUpload({ url }, { apiPath, bucketName }) {
|
|
|
237
241
|
async function deleteFile({ url }, { apiPath, bucketName }) {
|
|
238
242
|
const res = await fetch(`${apiPath}/delete-file`, {
|
|
239
243
|
method: 'POST',
|
|
244
|
+
credentials: 'include',
|
|
240
245
|
body: JSON.stringify({
|
|
241
246
|
url,
|
|
242
247
|
bucketName
|
|
@@ -341,7 +346,8 @@ function EdgeStoreProviderInner({ children, context, basePath, maxConcurrentUplo
|
|
|
341
346
|
error: false
|
|
342
347
|
});
|
|
343
348
|
const res = await fetch(`${apiPath}/init`, {
|
|
344
|
-
method: 'POST'
|
|
349
|
+
method: 'POST',
|
|
350
|
+
credentials: 'include'
|
|
345
351
|
});
|
|
346
352
|
if (res.ok) {
|
|
347
353
|
const json = await res.json();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handleError.d.ts","sourceRoot":"","sources":["../../../src/libs/errors/handleError.ts"],"names":[],"mappings":"AAGA,wBAAsB,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"handleError.d.ts","sourceRoot":"","sources":["../../../src/libs/errors/handleError.ts"],"names":[],"mappings":"AAGA,wBAAsB,WAAW,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,CAU/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var shared = require('@edgestore/shared');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, 'EdgeStoreApiClientError', {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return shared.EdgeStoreApiClientError; }
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EdgeStoreApiClientError } from '@edgestore/shared';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgestore/react",
|
|
3
|
-
"version": "0.1.5-alpha.
|
|
3
|
+
"version": "0.1.5-alpha.19",
|
|
4
4
|
"description": "Upload files with ease from React/Next.js",
|
|
5
5
|
"homepage": "https://edgestore.dev",
|
|
6
6
|
"repository": "https://github.com/edgestorejs/edgestore.git",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"import": "./dist/utils/index.mjs",
|
|
37
37
|
"require": "./dist/utils/index.js",
|
|
38
38
|
"default": "./dist/utils/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./shared": {
|
|
41
|
+
"import": "./dist/shared/index.mjs",
|
|
42
|
+
"require": "./dist/shared/index.js",
|
|
43
|
+
"default": "./dist/shared/index.js"
|
|
39
44
|
}
|
|
40
45
|
},
|
|
41
46
|
"files": [
|
|
@@ -44,6 +49,7 @@
|
|
|
44
49
|
"README.md",
|
|
45
50
|
"package.json",
|
|
46
51
|
"utils",
|
|
52
|
+
"shared",
|
|
47
53
|
"!**/*.test.*"
|
|
48
54
|
],
|
|
49
55
|
"private": false,
|
|
@@ -60,14 +66,15 @@
|
|
|
60
66
|
"uuid": "^9.0.0"
|
|
61
67
|
},
|
|
62
68
|
"peerDependencies": {
|
|
63
|
-
"@edgestore/shared": "0.1.5-alpha.
|
|
69
|
+
"@edgestore/shared": "0.1.5-alpha.19",
|
|
64
70
|
"next": "*",
|
|
65
71
|
"react": ">=16.8.0",
|
|
66
72
|
"react-dom": ">=16.8.0",
|
|
67
73
|
"zod": ">=3.0.0"
|
|
68
74
|
},
|
|
69
75
|
"devDependencies": {
|
|
70
|
-
"@edgestore/shared": "0.1.5-alpha.
|
|
76
|
+
"@edgestore/shared": "0.1.5-alpha.19",
|
|
77
|
+
"@swc/helpers": "0.5.3",
|
|
71
78
|
"@types/cookie": "^0.5.1",
|
|
72
79
|
"@types/node": "^18.11.18",
|
|
73
80
|
"@types/uuid": "^9.0.1",
|
|
@@ -77,5 +84,5 @@
|
|
|
77
84
|
"typescript": "^5.1.6",
|
|
78
85
|
"zod": "3.21.4"
|
|
79
86
|
},
|
|
80
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "c26eeb3eb8ae427eaf76cc782fa50f6b293d5651"
|
|
81
88
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/shared';
|
package/shared/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/shared');
|
package/src/contextProvider.tsx
CHANGED
package/src/createNextProxy.ts
CHANGED
|
@@ -144,6 +144,7 @@ async function uploadFile(
|
|
|
144
144
|
onProgressChange?.(0);
|
|
145
145
|
const res = await fetch(`${apiPath}/request-upload`, {
|
|
146
146
|
method: 'POST',
|
|
147
|
+
credentials: 'include',
|
|
147
148
|
body: JSON.stringify({
|
|
148
149
|
bucketName,
|
|
149
150
|
input,
|
|
@@ -325,6 +326,7 @@ async function multipartUpload(params: {
|
|
|
325
326
|
// Complete multipart upload
|
|
326
327
|
const res = await fetch(`${apiPath}/complete-multipart-upload`, {
|
|
327
328
|
method: 'POST',
|
|
329
|
+
credentials: 'include',
|
|
328
330
|
body: JSON.stringify({
|
|
329
331
|
bucketName,
|
|
330
332
|
uploadId,
|
|
@@ -356,6 +358,7 @@ async function confirmUpload(
|
|
|
356
358
|
) {
|
|
357
359
|
const res = await fetch(`${apiPath}/confirm-upload`, {
|
|
358
360
|
method: 'POST',
|
|
361
|
+
credentials: 'include',
|
|
359
362
|
body: JSON.stringify({
|
|
360
363
|
url,
|
|
361
364
|
bucketName,
|
|
@@ -386,6 +389,7 @@ async function deleteFile(
|
|
|
386
389
|
) {
|
|
387
390
|
const res = await fetch(`${apiPath}/delete-file`, {
|
|
388
391
|
method: 'POST',
|
|
392
|
+
credentials: 'include',
|
|
389
393
|
body: JSON.stringify({
|
|
390
394
|
url,
|
|
391
395
|
bucketName,
|
|
@@ -2,12 +2,13 @@ import { EdgeStoreApiClientError } from '@edgestore/shared';
|
|
|
2
2
|
import EdgeStoreClientError from './EdgeStoreClientError';
|
|
3
3
|
|
|
4
4
|
export async function handleError(res: Response): Promise<never> {
|
|
5
|
+
let json: any = {};
|
|
5
6
|
try {
|
|
6
|
-
|
|
7
|
-
throw new EdgeStoreApiClientError({ response: json });
|
|
7
|
+
json = await res.json();
|
|
8
8
|
} catch (err) {
|
|
9
9
|
throw new EdgeStoreClientError(
|
|
10
10
|
`Failed to parse response. Make sure the api is correctly configured at ${res.url}`,
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
|
+
throw new EdgeStoreApiClientError({ response: json });
|
|
13
14
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EdgeStoreApiClientError } from '@edgestore/shared';
|