@edgestore/server 0.1.5-alpha.14 → 0.1.5-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/dist/adapters/express/index.d.ts +1 -3
- package/dist/adapters/express/index.d.ts.map +1 -1
- package/dist/adapters/express/index.js +13 -12
- package/dist/adapters/express/index.mjs +3 -2
- package/dist/adapters/next/app/index.d.ts +1 -3
- package/dist/adapters/next/app/index.d.ts.map +1 -1
- package/dist/adapters/next/app/index.js +14 -13
- package/dist/adapters/next/app/index.mjs +3 -2
- package/dist/adapters/next/pages/index.d.ts +1 -3
- package/dist/adapters/next/pages/index.d.ts.map +1 -1
- package/dist/adapters/next/pages/index.js +14 -13
- package/dist/adapters/next/pages/index.mjs +3 -2
- package/dist/adapters/shared.d.ts +7 -43
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/core/client/index.d.ts +2 -3
- package/dist/core/client/index.d.ts.map +1 -1
- package/dist/core/index.d.ts +0 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +3 -13
- package/dist/core/index.mjs +5 -14
- package/dist/core/sdk/index.d.ts +1 -2
- package/dist/core/sdk/index.d.ts.map +1 -1
- package/dist/{index-23d1ede9.mjs → index-28efdacf.mjs} +2 -37
- package/dist/{index-a2e7ca9e.js → index-4491caf0.js} +2 -39
- package/dist/{index-0c401ce1.js → index-beed799d.js} +2 -32
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -215
- package/dist/index.mjs +1 -218
- package/dist/providers/aws/index.d.ts +1 -1
- package/dist/providers/aws/index.d.ts.map +1 -1
- package/dist/providers/azure/index.d.ts +1 -1
- package/dist/providers/azure/index.d.ts.map +1 -1
- package/dist/providers/edgestore/index.d.ts +1 -1
- package/dist/providers/edgestore/index.d.ts.map +1 -1
- package/dist/providers/edgestore/index.js +4 -4
- package/dist/providers/edgestore/index.mjs +2 -2
- package/dist/{shared-d7ea66fb.mjs → shared-039276af.mjs} +1 -1
- package/dist/{shared-06cb0d86.js → shared-7c700083.js} +20 -20
- package/dist/{shared-d474acc6.js → shared-83f288f6.js} +1 -1
- package/package.json +5 -13
- package/src/adapters/express/index.ts +7 -6
- package/src/adapters/next/app/index.ts +7 -6
- package/src/adapters/next/pages/index.ts +7 -6
- package/src/adapters/shared.ts +14 -17
- package/src/core/client/index.ts +7 -5
- package/src/core/index.ts +0 -15
- package/src/core/sdk/index.ts +6 -3
- package/src/index.ts +1 -1
- package/src/providers/aws/index.ts +1 -1
- package/src/providers/azure/index.ts +1 -1
- package/src/providers/edgestore/index.ts +5 -2
- package/dist/adapters/index.d.ts +0 -2
- package/dist/adapters/index.d.ts.map +0 -1
- package/dist/adapters/index.js +0 -2
- package/dist/adapters/index.mjs +0 -1
- package/dist/core/internals/bucketBuilder.d.ts +0 -269
- package/dist/core/internals/bucketBuilder.d.ts.map +0 -1
- package/dist/core/internals/createPathParamProxy.d.ts +0 -21
- package/dist/core/internals/createPathParamProxy.d.ts.map +0 -1
- package/dist/libs/errors/EdgeStoreApiClientError.d.ts +0 -8
- package/dist/libs/errors/EdgeStoreApiClientError.d.ts.map +0 -1
- package/dist/libs/errors/EdgeStoreError.d.ts +0 -48
- package/dist/libs/errors/EdgeStoreError.d.ts.map +0 -1
- package/dist/providers/index.d.ts +0 -2
- package/dist/providers/index.d.ts.map +0 -1
- package/dist/providers/index.js +0 -2
- package/dist/providers/index.mjs +0 -1
- package/dist/providers/types.d.ts +0 -114
- package/dist/providers/types.d.ts.map +0 -1
- package/dist/types.d.ts +0 -94
- package/dist/types.d.ts.map +0 -1
- package/src/adapters/index.ts +0 -6
- package/src/core/internals/bucketBuilder.ts +0 -555
- package/src/core/internals/createPathParamProxy.ts +0 -40
- package/src/libs/errors/EdgeStoreApiClientError.ts +0 -14
- package/src/libs/errors/EdgeStoreError.ts +0 -92
- package/src/providers/index.ts +0 -1
- package/src/providers/types.ts +0 -140
- package/src/types.ts +0 -148
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('
|
|
5
|
+
var shared = require('@edgestore/shared');
|
|
6
|
+
var index = require('../../index-4491caf0.js');
|
|
7
7
|
|
|
8
8
|
const DEFAULT_BASE_URL = 'https://files.edgestore.dev';
|
|
9
9
|
function EdgeStoreProvider(options) {
|
|
@@ -82,7 +82,7 @@ function EdgeStoreProvider(options) {
|
|
|
82
82
|
thumbnailUrl: res.thumbnailUrl
|
|
83
83
|
};
|
|
84
84
|
} else {
|
|
85
|
-
throw new
|
|
85
|
+
throw new shared.EdgeStoreError({
|
|
86
86
|
message: 'Could not get upload url',
|
|
87
87
|
code: 'SERVER_ERROR'
|
|
88
88
|
});
|
|
@@ -100,7 +100,7 @@ function EdgeStoreProvider(options) {
|
|
|
100
100
|
thumbnailUrl: res.thumbnailUrl
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
throw new
|
|
103
|
+
throw new shared.EdgeStoreError({
|
|
104
104
|
message: 'Could not get upload url',
|
|
105
105
|
code: 'SERVER_ERROR'
|
|
106
106
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '
|
|
1
|
+
import { EdgeStoreError } from '@edgestore/shared';
|
|
2
|
+
import { E as EdgeStoreCredentialsError, i as initEdgeStoreSdk } from '../../index-28efdacf.mjs';
|
|
3
3
|
|
|
4
4
|
const DEFAULT_BASE_URL = 'https://files.edgestore.dev';
|
|
5
5
|
function EdgeStoreProvider(options) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { EdgeStoreError } from '@edgestore/shared';
|
|
1
2
|
import { hkdf } from '@panva/hkdf';
|
|
2
3
|
import { serialize } from 'cookie';
|
|
3
4
|
import { EncryptJWT, jwtDecrypt } from 'jose';
|
|
4
5
|
import { v4 } from 'uuid';
|
|
5
|
-
import { E as EdgeStoreError } from './index-23d1ede9.mjs';
|
|
6
6
|
|
|
7
7
|
const IMAGE_MIME_TYPES = [
|
|
8
8
|
'image/jpeg',
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var shared = require('@edgestore/shared');
|
|
3
4
|
var hkdf = require('@panva/hkdf');
|
|
4
5
|
var cookie = require('cookie');
|
|
5
6
|
var jose = require('jose');
|
|
6
7
|
var uuid = require('uuid');
|
|
7
|
-
var index = require('./index-a2e7ca9e.js');
|
|
8
8
|
|
|
9
9
|
const IMAGE_MIME_TYPES = [
|
|
10
10
|
'image/jpeg',
|
|
@@ -64,7 +64,7 @@ async function requestUpload(params) {
|
|
|
64
64
|
fileInfo
|
|
65
65
|
});
|
|
66
66
|
if (!ctxToken) {
|
|
67
|
-
throw new
|
|
67
|
+
throw new shared.EdgeStoreError({
|
|
68
68
|
message: 'Missing edgestore-ctx cookie',
|
|
69
69
|
code: 'UNAUTHORIZED'
|
|
70
70
|
});
|
|
@@ -75,7 +75,7 @@ async function requestUpload(params) {
|
|
|
75
75
|
});
|
|
76
76
|
const bucket = router.buckets[bucketName];
|
|
77
77
|
if (!bucket) {
|
|
78
|
-
throw new
|
|
78
|
+
throw new shared.EdgeStoreError({
|
|
79
79
|
message: `Bucket ${bucketName} not found`,
|
|
80
80
|
code: 'BAD_REQUEST'
|
|
81
81
|
});
|
|
@@ -98,7 +98,7 @@ async function requestUpload(params) {
|
|
|
98
98
|
canUpload
|
|
99
99
|
});
|
|
100
100
|
if (!canUpload) {
|
|
101
|
-
throw new
|
|
101
|
+
throw new shared.EdgeStoreError({
|
|
102
102
|
message: 'Upload not allowed for the current context',
|
|
103
103
|
code: 'UPLOAD_NOT_ALLOWED'
|
|
104
104
|
});
|
|
@@ -106,7 +106,7 @@ async function requestUpload(params) {
|
|
|
106
106
|
}
|
|
107
107
|
if (bucket._def.type === 'IMAGE') {
|
|
108
108
|
if (!IMAGE_MIME_TYPES.includes(fileInfo.type)) {
|
|
109
|
-
throw new
|
|
109
|
+
throw new shared.EdgeStoreError({
|
|
110
110
|
code: 'MIME_TYPE_NOT_ALLOWED',
|
|
111
111
|
message: 'Only images are allowed in this bucket',
|
|
112
112
|
details: {
|
|
@@ -118,7 +118,7 @@ async function requestUpload(params) {
|
|
|
118
118
|
}
|
|
119
119
|
if (bucket._def.bucketConfig?.maxSize) {
|
|
120
120
|
if (fileInfo.size > bucket._def.bucketConfig.maxSize) {
|
|
121
|
-
throw new
|
|
121
|
+
throw new shared.EdgeStoreError({
|
|
122
122
|
code: 'FILE_TOO_LARGE',
|
|
123
123
|
message: `File size is too big. Max size is ${bucket._def.bucketConfig.maxSize}`,
|
|
124
124
|
details: {
|
|
@@ -144,7 +144,7 @@ async function requestUpload(params) {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
if (!accepted) {
|
|
147
|
-
throw new
|
|
147
|
+
throw new shared.EdgeStoreError({
|
|
148
148
|
code: 'MIME_TYPE_NOT_ALLOWED',
|
|
149
149
|
message: `"${fileInfo.type}" is not allowed. Accepted types are ${JSON.stringify(accept)}`,
|
|
150
150
|
details: {
|
|
@@ -202,7 +202,7 @@ async function requestUploadParts(params) {
|
|
|
202
202
|
path
|
|
203
203
|
});
|
|
204
204
|
if (!ctxToken) {
|
|
205
|
-
throw new
|
|
205
|
+
throw new shared.EdgeStoreError({
|
|
206
206
|
message: 'Missing edgestore-ctx cookie',
|
|
207
207
|
code: 'UNAUTHORIZED'
|
|
208
208
|
});
|
|
@@ -224,7 +224,7 @@ async function completeMultipartUpload(params) {
|
|
|
224
224
|
key
|
|
225
225
|
});
|
|
226
226
|
if (!ctxToken) {
|
|
227
|
-
throw new
|
|
227
|
+
throw new shared.EdgeStoreError({
|
|
228
228
|
message: 'Missing edgestore-ctx cookie',
|
|
229
229
|
code: 'UNAUTHORIZED'
|
|
230
230
|
});
|
|
@@ -232,7 +232,7 @@ async function completeMultipartUpload(params) {
|
|
|
232
232
|
await getContext(ctxToken); // just to check if the token is valid
|
|
233
233
|
const bucket = router.buckets[bucketName];
|
|
234
234
|
if (!bucket) {
|
|
235
|
-
throw new
|
|
235
|
+
throw new shared.EdgeStoreError({
|
|
236
236
|
message: `Bucket ${bucketName} not found`,
|
|
237
237
|
code: 'BAD_REQUEST'
|
|
238
238
|
});
|
|
@@ -253,7 +253,7 @@ async function confirmUpload(params) {
|
|
|
253
253
|
url
|
|
254
254
|
});
|
|
255
255
|
if (!ctxToken) {
|
|
256
|
-
throw new
|
|
256
|
+
throw new shared.EdgeStoreError({
|
|
257
257
|
message: 'Missing edgestore-ctx cookie',
|
|
258
258
|
code: 'UNAUTHORIZED'
|
|
259
259
|
});
|
|
@@ -261,7 +261,7 @@ async function confirmUpload(params) {
|
|
|
261
261
|
await getContext(ctxToken); // just to check if the token is valid
|
|
262
262
|
const bucket = router.buckets[bucketName];
|
|
263
263
|
if (!bucket) {
|
|
264
|
-
throw new
|
|
264
|
+
throw new shared.EdgeStoreError({
|
|
265
265
|
message: `Bucket ${bucketName} not found`,
|
|
266
266
|
code: 'BAD_REQUEST'
|
|
267
267
|
});
|
|
@@ -281,7 +281,7 @@ async function deleteFile(params) {
|
|
|
281
281
|
url
|
|
282
282
|
});
|
|
283
283
|
if (!ctxToken) {
|
|
284
|
-
throw new
|
|
284
|
+
throw new shared.EdgeStoreError({
|
|
285
285
|
message: 'Missing edgestore-ctx cookie',
|
|
286
286
|
code: 'UNAUTHORIZED'
|
|
287
287
|
});
|
|
@@ -289,13 +289,13 @@ async function deleteFile(params) {
|
|
|
289
289
|
const ctx = await getContext(ctxToken);
|
|
290
290
|
const bucket = router.buckets[bucketName];
|
|
291
291
|
if (!bucket) {
|
|
292
|
-
throw new
|
|
292
|
+
throw new shared.EdgeStoreError({
|
|
293
293
|
message: `Bucket ${bucketName} not found`,
|
|
294
294
|
code: 'BAD_REQUEST'
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
297
|
if (!bucket._def.beforeDelete) {
|
|
298
|
-
throw new
|
|
298
|
+
throw new shared.EdgeStoreError({
|
|
299
299
|
message: 'You need to define beforeDelete if you want to delete files directly from the frontend.',
|
|
300
300
|
code: 'SERVER_ERROR'
|
|
301
301
|
});
|
|
@@ -308,7 +308,7 @@ async function deleteFile(params) {
|
|
|
308
308
|
fileInfo
|
|
309
309
|
});
|
|
310
310
|
if (!canDelete) {
|
|
311
|
-
throw new
|
|
311
|
+
throw new shared.EdgeStoreError({
|
|
312
312
|
message: 'Delete not allowed for the current context',
|
|
313
313
|
code: 'DELETE_NOT_ALLOWED'
|
|
314
314
|
});
|
|
@@ -323,7 +323,7 @@ async function deleteFile(params) {
|
|
|
323
323
|
async function encryptJWT(ctx) {
|
|
324
324
|
const secret = process.env.EDGE_STORE_JWT_SECRET ?? process.env.EDGE_STORE_SECRET_KEY;
|
|
325
325
|
if (!secret) {
|
|
326
|
-
throw new
|
|
326
|
+
throw new shared.EdgeStoreError({
|
|
327
327
|
message: 'EDGE_STORE_JWT_SECRET or EDGE_STORE_SECRET_KEY is not defined',
|
|
328
328
|
code: 'SERVER_ERROR'
|
|
329
329
|
});
|
|
@@ -337,7 +337,7 @@ async function encryptJWT(ctx) {
|
|
|
337
337
|
async function decryptJWT(token) {
|
|
338
338
|
const secret = process.env.EDGE_STORE_JWT_SECRET ?? process.env.EDGE_STORE_SECRET_KEY;
|
|
339
339
|
if (!secret) {
|
|
340
|
-
throw new
|
|
340
|
+
throw new shared.EdgeStoreError({
|
|
341
341
|
message: 'EDGE_STORE_JWT_SECRET or EDGE_STORE_SECRET_KEY is not defined',
|
|
342
342
|
code: 'SERVER_ERROR'
|
|
343
343
|
});
|
|
@@ -357,7 +357,7 @@ function buildPath(params) {
|
|
|
357
357
|
const path = pathParams.map((param)=>{
|
|
358
358
|
const paramEntries = Object.entries(param);
|
|
359
359
|
if (paramEntries[0] === undefined) {
|
|
360
|
-
throw new
|
|
360
|
+
throw new shared.EdgeStoreError({
|
|
361
361
|
message: `Empty path param found in: ${JSON.stringify(pathParams)}`,
|
|
362
362
|
code: 'SERVER_ERROR'
|
|
363
363
|
});
|
|
@@ -366,7 +366,7 @@ function buildPath(params) {
|
|
|
366
366
|
// this is a string like: "ctx.xxx" or "input.yyy.zzz"
|
|
367
367
|
const currParamVal = value().split('.').reduce((acc2, key)=>{
|
|
368
368
|
if (acc2[key] === undefined) {
|
|
369
|
-
throw new
|
|
369
|
+
throw new shared.EdgeStoreError({
|
|
370
370
|
message: `Missing key ${key} in ${JSON.stringify(acc2)}`,
|
|
371
371
|
code: 'BAD_REQUEST'
|
|
372
372
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { EdgeStoreError } from '@edgestore/shared';
|
|
1
2
|
import { hkdf } from '@panva/hkdf';
|
|
2
3
|
import { serialize } from 'cookie';
|
|
3
4
|
import { EncryptJWT, jwtDecrypt } from 'jose';
|
|
4
5
|
import { v4 } from 'uuid';
|
|
5
|
-
import { E as EdgeStoreError } from './index-0c401ce1.js';
|
|
6
6
|
|
|
7
7
|
const IMAGE_MIME_TYPES = [
|
|
8
8
|
'image/jpeg',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgestore/server",
|
|
3
|
-
"version": "0.1.5-alpha.
|
|
3
|
+
"version": "0.1.5-alpha.16",
|
|
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",
|
|
@@ -37,11 +37,6 @@
|
|
|
37
37
|
"require": "./dist/core/index.js",
|
|
38
38
|
"default": "./dist/core/index.js"
|
|
39
39
|
},
|
|
40
|
-
"./adapters": {
|
|
41
|
-
"import": "./dist/adapters/index.mjs",
|
|
42
|
-
"require": "./dist/adapters/index.js",
|
|
43
|
-
"default": "./dist/adapters/index.js"
|
|
44
|
-
},
|
|
45
40
|
"./adapters/express": {
|
|
46
41
|
"import": "./dist/adapters/express/index.mjs",
|
|
47
42
|
"require": "./dist/adapters/express/index.js",
|
|
@@ -71,11 +66,6 @@
|
|
|
71
66
|
"import": "./dist/providers/edgestore/index.mjs",
|
|
72
67
|
"require": "./dist/providers/edgestore/index.js",
|
|
73
68
|
"default": "./dist/providers/edgestore/index.js"
|
|
74
|
-
},
|
|
75
|
-
"./providers": {
|
|
76
|
-
"import": "./dist/providers/index.mjs",
|
|
77
|
-
"require": "./dist/providers/index.js",
|
|
78
|
-
"default": "./dist/providers/index.js"
|
|
79
69
|
}
|
|
80
70
|
},
|
|
81
71
|
"files": [
|
|
@@ -103,6 +93,7 @@
|
|
|
103
93
|
"@aws-sdk/client-s3": ">=3.0.0",
|
|
104
94
|
"@aws-sdk/s3-request-presigner": ">=3.0.0",
|
|
105
95
|
"@azure/storage-blob": "^12.17.0",
|
|
96
|
+
"@edgestore/shared": "0.1.5-alpha.16",
|
|
106
97
|
"zod": ">=3.0.0"
|
|
107
98
|
},
|
|
108
99
|
"peerDependenciesMeta": {
|
|
@@ -123,6 +114,7 @@
|
|
|
123
114
|
"@aws-sdk/client-s3": "^3.420.0",
|
|
124
115
|
"@aws-sdk/s3-request-presigner": "^3.420.0",
|
|
125
116
|
"@azure/storage-blob": "^12.17.0",
|
|
117
|
+
"@edgestore/shared": "0.1.5-alpha.16",
|
|
126
118
|
"@types/cookie": "^0.5.1",
|
|
127
119
|
"@types/node": "^18.11.18",
|
|
128
120
|
"@types/uuid": "^9.0.1",
|
|
@@ -130,7 +122,7 @@
|
|
|
130
122
|
"react": "^18.2.0",
|
|
131
123
|
"react-dom": "^18.2.0",
|
|
132
124
|
"typescript": "^5.1.6",
|
|
133
|
-
"zod": "
|
|
125
|
+
"zod": "3.21.4"
|
|
134
126
|
},
|
|
135
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "2f11a326b8412df19c375a75f1f8a329b6b9287b"
|
|
136
128
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type EdgeStoreRouter } from '../../core/internals/bucketBuilder';
|
|
3
|
-
import EdgeStoreError, {
|
|
1
|
+
import {
|
|
4
2
|
EDGE_STORE_ERROR_CODES,
|
|
3
|
+
EdgeStoreError,
|
|
5
4
|
type EdgeStoreErrorCodeKey,
|
|
6
|
-
|
|
5
|
+
type EdgeStoreRouter,
|
|
6
|
+
type MaybePromise,
|
|
7
|
+
type Provider,
|
|
8
|
+
} from '@edgestore/shared';
|
|
9
|
+
import { type Request, type Response } from 'express';
|
|
7
10
|
import Logger, { type LogLevel } from '../../libs/logger';
|
|
8
11
|
import { EdgeStoreProvider } from '../../providers/edgestore';
|
|
9
|
-
import { type Provider } from '../../providers/types';
|
|
10
|
-
import { type MaybePromise } from '../../types';
|
|
11
12
|
import {
|
|
12
13
|
completeMultipartUpload,
|
|
13
14
|
confirmUpload,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type EdgeStoreRouter } from '../../../core/internals/bucketBuilder';
|
|
3
|
-
import EdgeStoreError, {
|
|
1
|
+
import {
|
|
4
2
|
EDGE_STORE_ERROR_CODES,
|
|
3
|
+
EdgeStoreError,
|
|
5
4
|
type EdgeStoreErrorCodeKey,
|
|
6
|
-
|
|
5
|
+
type EdgeStoreRouter,
|
|
6
|
+
type MaybePromise,
|
|
7
|
+
type Provider,
|
|
8
|
+
} from '@edgestore/shared';
|
|
9
|
+
import { type NextRequest } from 'next/server';
|
|
7
10
|
import Logger, { type LogLevel } from '../../../libs/logger';
|
|
8
11
|
import { EdgeStoreProvider } from '../../../providers/edgestore';
|
|
9
|
-
import { type Provider } from '../../../providers/types';
|
|
10
|
-
import { type MaybePromise } from '../../../types';
|
|
11
12
|
import {
|
|
12
13
|
completeMultipartUpload,
|
|
13
14
|
confirmUpload,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type EdgeStoreRouter } from '../../../core/internals/bucketBuilder';
|
|
3
|
-
import EdgeStoreError, {
|
|
1
|
+
import {
|
|
4
2
|
EDGE_STORE_ERROR_CODES,
|
|
3
|
+
EdgeStoreError,
|
|
5
4
|
type EdgeStoreErrorCodeKey,
|
|
6
|
-
|
|
5
|
+
type EdgeStoreRouter,
|
|
6
|
+
type MaybePromise,
|
|
7
|
+
type Provider,
|
|
8
|
+
} from '@edgestore/shared';
|
|
9
|
+
import { type NextApiRequest, type NextApiResponse } from 'next/types';
|
|
7
10
|
import Logger, { type LogLevel } from '../../../libs/logger';
|
|
8
11
|
import { EdgeStoreProvider } from '../../../providers/edgestore';
|
|
9
|
-
import { type Provider } from '../../../providers/types';
|
|
10
|
-
import { type MaybePromise } from '../../../types';
|
|
11
12
|
import {
|
|
12
13
|
completeMultipartUpload,
|
|
13
14
|
confirmUpload,
|
package/src/adapters/shared.ts
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EdgeStoreError,
|
|
3
|
+
type AnyBuilder,
|
|
4
|
+
type EdgeStoreRouter,
|
|
5
|
+
type Provider,
|
|
6
|
+
type SharedDeleteFileRes,
|
|
7
|
+
type SharedInitRes,
|
|
8
|
+
type SharedRequestUploadPartsRes,
|
|
9
|
+
type SharedRequestUploadRes,
|
|
10
|
+
} from '@edgestore/shared';
|
|
1
11
|
import { hkdf } from '@panva/hkdf';
|
|
2
12
|
import { serialize } from 'cookie';
|
|
3
13
|
import { EncryptJWT, jwtDecrypt } from 'jose';
|
|
4
14
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
-
import {
|
|
6
|
-
type AnyBuilder,
|
|
7
|
-
type EdgeStoreRouter,
|
|
8
|
-
} from '../core/internals/bucketBuilder';
|
|
9
|
-
import EdgeStoreError from '../libs/errors/EdgeStoreError';
|
|
10
15
|
import type Logger from '../libs/logger';
|
|
11
|
-
import { type Provider } from '../providers/types';
|
|
12
16
|
import { IMAGE_MIME_TYPES } from './imageTypes';
|
|
13
17
|
|
|
14
18
|
// TODO: change it to 1 hour when we have a way to refresh the token
|
|
@@ -22,7 +26,7 @@ export async function init<TCtx>(params: {
|
|
|
22
26
|
provider: Provider;
|
|
23
27
|
router: EdgeStoreRouter<TCtx>;
|
|
24
28
|
ctx: TCtx;
|
|
25
|
-
}) {
|
|
29
|
+
}): Promise<SharedInitRes> {
|
|
26
30
|
const log = globalThis._EDGE_STORE_LOGGER;
|
|
27
31
|
const { ctx, provider, router } = params;
|
|
28
32
|
log.debug('Running [init]', { ctx });
|
|
@@ -74,7 +78,7 @@ export async function requestUpload<TCtx>(params: {
|
|
|
74
78
|
router: EdgeStoreRouter<TCtx>;
|
|
75
79
|
ctxToken: string | undefined;
|
|
76
80
|
body: RequestUploadBody;
|
|
77
|
-
}) {
|
|
81
|
+
}): Promise<SharedRequestUploadRes> {
|
|
78
82
|
const {
|
|
79
83
|
provider,
|
|
80
84
|
router,
|
|
@@ -231,7 +235,7 @@ export async function requestUploadParts<TCtx>(params: {
|
|
|
231
235
|
router: EdgeStoreRouter<TCtx>;
|
|
232
236
|
ctxToken: string | undefined;
|
|
233
237
|
body: RequestUploadPartsParams;
|
|
234
|
-
}) {
|
|
238
|
+
}): Promise<SharedRequestUploadPartsRes> {
|
|
235
239
|
const {
|
|
236
240
|
provider,
|
|
237
241
|
ctxToken,
|
|
@@ -370,7 +374,7 @@ export async function deleteFile<TCtx>(params: {
|
|
|
370
374
|
router: EdgeStoreRouter<TCtx>;
|
|
371
375
|
ctxToken: string | undefined;
|
|
372
376
|
body: DeleteFileBody;
|
|
373
|
-
}) {
|
|
377
|
+
}): Promise<SharedDeleteFileRes> {
|
|
374
378
|
const {
|
|
375
379
|
provider,
|
|
376
380
|
router,
|
|
@@ -544,10 +548,3 @@ function unproxyUrl(url: string) {
|
|
|
544
548
|
}
|
|
545
549
|
return url;
|
|
546
550
|
}
|
|
547
|
-
|
|
548
|
-
export type InitRes = Awaited<ReturnType<typeof init>>;
|
|
549
|
-
export type RequestUploadRes = Awaited<ReturnType<typeof requestUpload>>;
|
|
550
|
-
export type RequestUploadPartsRes = Awaited<
|
|
551
|
-
ReturnType<typeof requestUploadParts>
|
|
552
|
-
>;
|
|
553
|
-
export type DeleteFileRes = Awaited<ReturnType<typeof deleteFile>>;
|
package/src/core/client/index.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
-
import { type z, type ZodNever } from 'zod';
|
|
3
|
-
import { type AnyRouter, type Comparison } from '..';
|
|
4
|
-
import { buildPath, parsePath } from '../../adapters/shared';
|
|
5
|
-
import { type Prettify, type Simplify } from '../../types';
|
|
6
2
|
import {
|
|
7
3
|
type AnyBuilder,
|
|
4
|
+
type AnyRouter,
|
|
8
5
|
type InferBucketPathKeys,
|
|
9
6
|
type InferBucketPathObject,
|
|
10
7
|
type InferMetadataObject,
|
|
11
|
-
|
|
8
|
+
type Prettify,
|
|
9
|
+
type Simplify,
|
|
10
|
+
} from '@edgestore/shared';
|
|
11
|
+
import { type z, type ZodNever } from 'zod';
|
|
12
|
+
import { type Comparison } from '..';
|
|
13
|
+
import { buildPath, parsePath } from '../../adapters/shared';
|
|
12
14
|
import { initEdgeStoreSdk } from '../sdk';
|
|
13
15
|
|
|
14
16
|
export type GetFileRes<TBucket extends AnyBuilder> = {
|
package/src/core/index.ts
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
import { type EdgeStoreRouter } from './internals/bucketBuilder';
|
|
2
|
-
|
|
3
1
|
export * from './client';
|
|
4
2
|
export * from './sdk';
|
|
5
|
-
export type {
|
|
6
|
-
InferBucketPathKeys,
|
|
7
|
-
InferBucketPathObject,
|
|
8
|
-
InferMetadataObject,
|
|
9
|
-
} from './internals/bucketBuilder';
|
|
10
|
-
export type {
|
|
11
|
-
EdgeStoreErrorCodeKey,
|
|
12
|
-
EdgeStoreErrorDetails,
|
|
13
|
-
EdgeStoreJsonResponse,
|
|
14
|
-
} from '../libs/errors/EdgeStoreError';
|
|
15
|
-
export { EdgeStoreApiClientError } from '../libs/errors/EdgeStoreApiClientError';
|
|
16
|
-
|
|
17
|
-
export type AnyRouter = EdgeStoreRouter<any>;
|
package/src/core/sdk/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
EdgeStoreError,
|
|
3
|
+
type AnyContext,
|
|
4
|
+
type AnyMetadata,
|
|
5
|
+
type AnyRouter,
|
|
6
|
+
} from '@edgestore/shared';
|
|
2
7
|
import EdgeStoreCredentialsError from '../../libs/errors/EdgeStoreCredentialsError';
|
|
3
|
-
import EdgeStoreError from '../../libs/errors/EdgeStoreError';
|
|
4
|
-
import { type AnyContext, type AnyMetadata } from '../internals/bucketBuilder';
|
|
5
8
|
|
|
6
9
|
const API_ENDPOINT =
|
|
7
10
|
process.env.EDGE_STORE_API_ENDPOINT ?? 'https://api.edgestore.dev';
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { initEdgeStore } from '
|
|
1
|
+
export { initEdgeStore } from '@edgestore/shared';
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
S3Client,
|
|
6
6
|
} from '@aws-sdk/client-s3';
|
|
7
7
|
import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
8
|
+
import { type Provider } from '@edgestore/shared';
|
|
8
9
|
import { v4 as uuidv4 } from 'uuid';
|
|
9
|
-
import { type Provider } from '../types';
|
|
10
10
|
|
|
11
11
|
export type AWSProviderOptions = {
|
|
12
12
|
/**
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EdgeStoreError,
|
|
3
|
+
type Provider,
|
|
4
|
+
type RequestUploadRes,
|
|
5
|
+
} from '@edgestore/shared';
|
|
1
6
|
import { initEdgeStoreSdk } from '../../core/sdk';
|
|
2
7
|
import EdgeStoreCredentialsError from '../../libs/errors/EdgeStoreCredentialsError';
|
|
3
|
-
import EdgeStoreError from '../../libs/errors/EdgeStoreError';
|
|
4
|
-
import { type Provider, type RequestUploadRes } from '../types';
|
|
5
8
|
|
|
6
9
|
const DEFAULT_BASE_URL = 'https://files.edgestore.dev';
|
|
7
10
|
|
package/dist/adapters/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,OAAO,EACP,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,GACd,MAAM,UAAU,CAAC"}
|
package/dist/adapters/index.js
DELETED
package/dist/adapters/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|