@edgestore/server 0.7.0 → 0.8.1

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.
Files changed (70) hide show
  1. package/dist/adapters/astro/index.d.ts.map +1 -1
  2. package/dist/adapters/astro/index.js +2 -26
  3. package/dist/adapters/astro/index.mjs +2 -26
  4. package/dist/adapters/express/index.d.ts.map +1 -1
  5. package/dist/adapters/express/index.js +2 -20
  6. package/dist/adapters/express/index.mjs +2 -20
  7. package/dist/adapters/fastify/index.d.ts +1 -1
  8. package/dist/adapters/fastify/index.d.ts.map +1 -1
  9. package/dist/adapters/fastify/index.js +2 -21
  10. package/dist/adapters/fastify/index.mjs +2 -21
  11. package/dist/adapters/hono/index.d.ts +4 -70
  12. package/dist/adapters/hono/index.d.ts.map +1 -1
  13. package/dist/adapters/hono/index.js +5 -22
  14. package/dist/adapters/hono/index.mjs +5 -22
  15. package/dist/adapters/next/app/index.d.ts.map +1 -1
  16. package/dist/adapters/next/app/index.js +2 -26
  17. package/dist/adapters/next/app/index.mjs +2 -26
  18. package/dist/adapters/next/pages/index.d.ts.map +1 -1
  19. package/dist/adapters/next/pages/index.js +2 -20
  20. package/dist/adapters/next/pages/index.mjs +2 -20
  21. package/dist/adapters/remix/index.d.ts.map +1 -1
  22. package/dist/adapters/remix/index.js +2 -25
  23. package/dist/adapters/remix/index.mjs +2 -25
  24. package/dist/adapters/shared.d.ts.map +1 -1
  25. package/dist/adapters/shared.js +20 -12
  26. package/dist/adapters/shared.mjs +20 -12
  27. package/dist/adapters/start/index.d.ts.map +1 -1
  28. package/dist/adapters/start/index.js +2 -26
  29. package/dist/adapters/start/index.mjs +2 -26
  30. package/dist/core/client/index.d.ts +114 -74
  31. package/dist/core/client/index.d.ts.map +1 -1
  32. package/dist/core/client/index.js +54 -24
  33. package/dist/core/client/index.mjs +55 -25
  34. package/dist/core/sdk/index.d.ts +44 -2
  35. package/dist/core/sdk/index.d.ts.map +1 -1
  36. package/dist/core/sdk/index.js +36 -6
  37. package/dist/core/sdk/index.mjs +36 -6
  38. package/dist/providers/aws/index.d.ts +1 -1
  39. package/dist/providers/aws/index.d.ts.map +1 -1
  40. package/dist/providers/aws/index.js +3 -3
  41. package/dist/providers/aws/index.mjs +3 -3
  42. package/dist/providers/azure/index.d.ts.map +1 -1
  43. package/dist/providers/azure/index.js +33 -7
  44. package/dist/providers/azure/index.mjs +33 -7
  45. package/dist/providers/edgestore/index.d.ts.map +1 -1
  46. package/dist/providers/edgestore/index.js +24 -4
  47. package/dist/providers/edgestore/index.mjs +24 -4
  48. package/dist/test-utils/edgestoreSmoke.d.ts +32 -0
  49. package/dist/test-utils/edgestoreSmoke.d.ts.map +1 -0
  50. package/dist/version.d.ts +3 -0
  51. package/dist/version.d.ts.map +1 -0
  52. package/dist/version.js +7 -0
  53. package/dist/version.mjs +4 -0
  54. package/package.json +11 -2
  55. package/src/adapters/astro/index.ts +2 -32
  56. package/src/adapters/express/index.ts +2 -25
  57. package/src/adapters/fastify/index.ts +3 -31
  58. package/src/adapters/hono/index.ts +7 -33
  59. package/src/adapters/next/app/index.ts +6 -36
  60. package/src/adapters/next/pages/index.ts +2 -25
  61. package/src/adapters/remix/index.ts +2 -22
  62. package/src/adapters/shared.ts +25 -9
  63. package/src/adapters/start/index.ts +2 -20
  64. package/src/core/client/index.ts +204 -104
  65. package/src/core/sdk/index.ts +75 -0
  66. package/src/providers/aws/index.ts +4 -4
  67. package/src/providers/azure/index.ts +40 -10
  68. package/src/providers/edgestore/index.ts +29 -0
  69. package/src/test-utils/edgestoreSmoke.ts +141 -0
  70. package/src/version.ts +2 -0
@@ -48,9 +48,8 @@ function AWSProvider(options) {
48
48
  }
49
49
  // Default S3 key (accessPath) construction logic
50
50
  const pathPrefix = `${esBucketName}${fileInfo.isPublic ? '/_public' : ''}`;
51
- const nameId = v4();
52
51
  const extension = fileInfo.extension ? `.${fileInfo.extension.replace('.', '')}` : '';
53
- const defaultResolvedFileName = fileInfo.fileName ?? `${nameId}${extension}`;
52
+ const defaultResolvedFileName = fileInfo.fileName ?? `${v4()}${extension}`;
54
53
  const defaultFilePathFromMetadata = fileInfo.path.reduce((acc, item)=>{
55
54
  return `${acc}/${item.value}`;
56
55
  }, '');
@@ -62,6 +61,7 @@ function AWSProvider(options) {
62
61
  defaultAccessPath: accessPath
63
62
  });
64
63
  }
64
+ accessPath = accessPath.replace(/^\/+/, '');
65
65
  const command = new PutObjectCommand({
66
66
  Bucket: bucketName,
67
67
  Key: accessPath
@@ -69,7 +69,7 @@ function AWSProvider(options) {
69
69
  const signedUrl = await getSignedUrl(s3Client, command, {
70
70
  expiresIn: 60 * 60
71
71
  });
72
- const finalAccessUrl = `${baseUrl}/${accessPath.startsWith('/') ? accessPath.substring(1) : accessPath}`;
72
+ const finalAccessUrl = `${baseUrl}/${accessPath}`;
73
73
  return {
74
74
  uploadUrl: signedUrl,
75
75
  accessUrl: finalAccessUrl
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/azure/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIlD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,QAAQ,CAqEtE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/azure/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAIlD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,QAAQ,CAmGtE"}
@@ -9,6 +9,35 @@ function AzureProvider(options) {
9
9
  const baseUrl = customBaseUrl ?? `https://${storageAccountName}.blob.core.windows.net`;
10
10
  const blobServiceClient = new storageBlob.BlobServiceClient(`${baseUrl}?${sasToken}`);
11
11
  const containerClient = blobServiceClient.getContainerClient(containerName ?? '');
12
+ function getBlobNameFromUrl(url) {
13
+ try {
14
+ const blobUrl = new URL(url);
15
+ const containerUrl = new URL(containerClient.url);
16
+ const containerPath = containerUrl.pathname.replace(/\/$/, '');
17
+ if (blobUrl.origin !== containerUrl.origin) {
18
+ return url;
19
+ }
20
+ if (!blobUrl.pathname.startsWith(`${containerPath}/`)) {
21
+ return url;
22
+ }
23
+ return decodeURIComponent(blobUrl.pathname.slice(containerPath.length + 1));
24
+ } catch {
25
+ return url;
26
+ }
27
+ }
28
+ function getBlobName(params) {
29
+ const { bucketName: esBucketName, fileInfo } = params;
30
+ const extension = fileInfo.extension ? `.${fileInfo.extension.replace('.', '')}` : '';
31
+ const fileName = fileInfo.fileName ?? `${uuid.v4()}${extension}`;
32
+ return [
33
+ esBucketName,
34
+ ...fileInfo.isPublic ? [
35
+ '_public'
36
+ ] : [],
37
+ ...fileInfo.path.map((item)=>item.value),
38
+ fileName
39
+ ].join('/');
40
+ }
12
41
  return {
13
42
  name: 'azure',
14
43
  async init () {
@@ -18,7 +47,7 @@ function AzureProvider(options) {
18
47
  return baseUrl;
19
48
  },
20
49
  async getFile ({ url }) {
21
- const blobClient = containerClient.getBlobClient(url);
50
+ const blobClient = containerClient.getBlobClient(getBlobNameFromUrl(url));
22
51
  const { contentLength, lastModified } = await blobClient.getProperties();
23
52
  return {
24
53
  url: url,
@@ -28,11 +57,8 @@ function AzureProvider(options) {
28
57
  uploadedAt: lastModified ?? new Date()
29
58
  };
30
59
  },
31
- async requestUpload ({ fileInfo }) {
32
- const nameId = uuid.v4();
33
- const extension = fileInfo.extension ? `.${fileInfo.extension.replace('.', '')}` : '';
34
- const fileName = fileInfo.fileName ?? `${nameId}${extension}`;
35
- const blobClient = containerClient.getBlobClient(fileName);
60
+ async requestUpload (params) {
61
+ const blobClient = containerClient.getBlobClient(getBlobName(params));
36
62
  const url = blobClient.url;
37
63
  return {
38
64
  uploadUrl: url,
@@ -49,7 +75,7 @@ function AzureProvider(options) {
49
75
  throw new Error('Not implemented');
50
76
  },
51
77
  async deleteFile ({ url }) {
52
- const blobClient = containerClient.getBlobClient(url);
78
+ const blobClient = containerClient.getBlobClient(getBlobNameFromUrl(url));
53
79
  await blobClient.delete();
54
80
  return {
55
81
  success: true
@@ -7,6 +7,35 @@ function AzureProvider(options) {
7
7
  const baseUrl = customBaseUrl ?? `https://${storageAccountName}.blob.core.windows.net`;
8
8
  const blobServiceClient = new BlobServiceClient(`${baseUrl}?${sasToken}`);
9
9
  const containerClient = blobServiceClient.getContainerClient(containerName ?? '');
10
+ function getBlobNameFromUrl(url) {
11
+ try {
12
+ const blobUrl = new URL(url);
13
+ const containerUrl = new URL(containerClient.url);
14
+ const containerPath = containerUrl.pathname.replace(/\/$/, '');
15
+ if (blobUrl.origin !== containerUrl.origin) {
16
+ return url;
17
+ }
18
+ if (!blobUrl.pathname.startsWith(`${containerPath}/`)) {
19
+ return url;
20
+ }
21
+ return decodeURIComponent(blobUrl.pathname.slice(containerPath.length + 1));
22
+ } catch {
23
+ return url;
24
+ }
25
+ }
26
+ function getBlobName(params) {
27
+ const { bucketName: esBucketName, fileInfo } = params;
28
+ const extension = fileInfo.extension ? `.${fileInfo.extension.replace('.', '')}` : '';
29
+ const fileName = fileInfo.fileName ?? `${v4()}${extension}`;
30
+ return [
31
+ esBucketName,
32
+ ...fileInfo.isPublic ? [
33
+ '_public'
34
+ ] : [],
35
+ ...fileInfo.path.map((item)=>item.value),
36
+ fileName
37
+ ].join('/');
38
+ }
10
39
  return {
11
40
  name: 'azure',
12
41
  async init () {
@@ -16,7 +45,7 @@ function AzureProvider(options) {
16
45
  return baseUrl;
17
46
  },
18
47
  async getFile ({ url }) {
19
- const blobClient = containerClient.getBlobClient(url);
48
+ const blobClient = containerClient.getBlobClient(getBlobNameFromUrl(url));
20
49
  const { contentLength, lastModified } = await blobClient.getProperties();
21
50
  return {
22
51
  url: url,
@@ -26,11 +55,8 @@ function AzureProvider(options) {
26
55
  uploadedAt: lastModified ?? new Date()
27
56
  };
28
57
  },
29
- async requestUpload ({ fileInfo }) {
30
- const nameId = v4();
31
- const extension = fileInfo.extension ? `.${fileInfo.extension.replace('.', '')}` : '';
32
- const fileName = fileInfo.fileName ?? `${nameId}${extension}`;
33
- const blobClient = containerClient.getBlobClient(fileName);
58
+ async requestUpload (params) {
59
+ const blobClient = containerClient.getBlobClient(getBlobName(params));
34
60
  const url = blobClient.url;
35
61
  return {
36
62
  uploadUrl: url,
@@ -47,7 +73,7 @@ function AzureProvider(options) {
47
73
  throw new Error('Not implemented');
48
74
  },
49
75
  async deleteFile ({ url }) {
50
- const blobClient = containerClient.getBlobClient(url);
76
+ const blobClient = containerClient.getBlobClient(getBlobNameFromUrl(url));
51
77
  await blobClient.delete();
52
78
  return {
53
79
  success: true
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/edgestore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,mBAAmB,CAAC;AAO3B,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,wBAAwB,GACjC,QAAQ,CAqJV"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/edgestore/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,mBAAmB,CAAC;AAO3B,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,wBAAwB,GACjC,QAAQ,CAkKV"}
@@ -41,7 +41,7 @@ function EdgeStoreProvider(options) {
41
41
  ...rest
42
42
  };
43
43
  },
44
- async requestUpload ({ bucketName, bucketType, fileInfo }) {
44
+ async requestUpload ({ bucketName, bucketType, fileInfo, autoSignedUrls }) {
45
45
  // multipart upload if file is bigger than a certain size
46
46
  const MULTIPART_THRESHOLD = 10 * 1024 * 1024; // 10MB
47
47
  let partSize = 5 * 1024 * 1024; // 5MB
@@ -56,6 +56,7 @@ function EdgeStoreProvider(options) {
56
56
  bucketName,
57
57
  bucketType,
58
58
  fileInfo,
59
+ autoSignedUrls,
59
60
  multipart: {
60
61
  parts: Array.from({
61
62
  length: totalParts
@@ -76,13 +77,15 @@ function EdgeStoreProvider(options) {
76
77
  return {
77
78
  accessUrl: res.accessUrl,
78
79
  thumbnailUrl: res.thumbnailUrl,
80
+ ...mapSignedUploadAccess(res),
79
81
  multipart
80
82
  };
81
83
  } else if (res.signedUrl) {
82
84
  return {
83
85
  accessUrl: res.accessUrl,
84
86
  uploadUrl: res.signedUrl,
85
- thumbnailUrl: res.thumbnailUrl
87
+ thumbnailUrl: res.thumbnailUrl,
88
+ ...mapSignedUploadAccess(res)
86
89
  };
87
90
  } else {
88
91
  throw new shared$1.EdgeStoreError({
@@ -94,13 +97,15 @@ function EdgeStoreProvider(options) {
94
97
  const res = await edgeStoreSdk.requestUpload({
95
98
  bucketName,
96
99
  bucketType,
97
- fileInfo
100
+ fileInfo,
101
+ autoSignedUrls
98
102
  });
99
103
  if (res.signedUrl) {
100
104
  return {
101
105
  accessUrl: res.accessUrl,
102
106
  uploadUrl: res.signedUrl,
103
- thumbnailUrl: res.thumbnailUrl
107
+ thumbnailUrl: res.thumbnailUrl,
108
+ ...mapSignedUploadAccess(res)
104
109
  };
105
110
  }
106
111
  throw new shared$1.EdgeStoreError({
@@ -123,6 +128,13 @@ function EdgeStoreProvider(options) {
123
128
  }
124
129
  };
125
130
  },
131
+ getSignedUrls: async (params)=>{
132
+ const res = await edgeStoreSdk.getSignedUrls(params);
133
+ return res.map((item)=>({
134
+ ...item,
135
+ expiresAt: new Date(item.expiresAt)
136
+ }));
137
+ },
126
138
  completeMultipartUpload: async ({ uploadId, key, parts })=>{
127
139
  return await edgeStoreSdk.completeMultipartUpload({
128
140
  uploadId,
@@ -142,5 +154,13 @@ function EdgeStoreProvider(options) {
142
154
  }
143
155
  };
144
156
  }
157
+ function mapSignedUploadAccess(res) {
158
+ return {
159
+ accessSignedUrl: res.accessSignedUrl,
160
+ accessSignedThumbnailUrl: res.accessSignedThumbnailUrl,
161
+ accessSignedUrlExpiresAt: res.accessSignedUrlExpiresAt ? new Date(res.accessSignedUrlExpiresAt) : undefined,
162
+ accessSignedUrlExpiresIn: res.accessSignedUrlExpiresIn
163
+ };
164
+ }
145
165
 
146
166
  exports.EdgeStoreProvider = EdgeStoreProvider;
@@ -39,7 +39,7 @@ function EdgeStoreProvider(options) {
39
39
  ...rest
40
40
  };
41
41
  },
42
- async requestUpload ({ bucketName, bucketType, fileInfo }) {
42
+ async requestUpload ({ bucketName, bucketType, fileInfo, autoSignedUrls }) {
43
43
  // multipart upload if file is bigger than a certain size
44
44
  const MULTIPART_THRESHOLD = 10 * 1024 * 1024; // 10MB
45
45
  let partSize = 5 * 1024 * 1024; // 5MB
@@ -54,6 +54,7 @@ function EdgeStoreProvider(options) {
54
54
  bucketName,
55
55
  bucketType,
56
56
  fileInfo,
57
+ autoSignedUrls,
57
58
  multipart: {
58
59
  parts: Array.from({
59
60
  length: totalParts
@@ -74,13 +75,15 @@ function EdgeStoreProvider(options) {
74
75
  return {
75
76
  accessUrl: res.accessUrl,
76
77
  thumbnailUrl: res.thumbnailUrl,
78
+ ...mapSignedUploadAccess(res),
77
79
  multipart
78
80
  };
79
81
  } else if (res.signedUrl) {
80
82
  return {
81
83
  accessUrl: res.accessUrl,
82
84
  uploadUrl: res.signedUrl,
83
- thumbnailUrl: res.thumbnailUrl
85
+ thumbnailUrl: res.thumbnailUrl,
86
+ ...mapSignedUploadAccess(res)
84
87
  };
85
88
  } else {
86
89
  throw new EdgeStoreError({
@@ -92,13 +95,15 @@ function EdgeStoreProvider(options) {
92
95
  const res = await edgeStoreSdk.requestUpload({
93
96
  bucketName,
94
97
  bucketType,
95
- fileInfo
98
+ fileInfo,
99
+ autoSignedUrls
96
100
  });
97
101
  if (res.signedUrl) {
98
102
  return {
99
103
  accessUrl: res.accessUrl,
100
104
  uploadUrl: res.signedUrl,
101
- thumbnailUrl: res.thumbnailUrl
105
+ thumbnailUrl: res.thumbnailUrl,
106
+ ...mapSignedUploadAccess(res)
102
107
  };
103
108
  }
104
109
  throw new EdgeStoreError({
@@ -121,6 +126,13 @@ function EdgeStoreProvider(options) {
121
126
  }
122
127
  };
123
128
  },
129
+ getSignedUrls: async (params)=>{
130
+ const res = await edgeStoreSdk.getSignedUrls(params);
131
+ return res.map((item)=>({
132
+ ...item,
133
+ expiresAt: new Date(item.expiresAt)
134
+ }));
135
+ },
124
136
  completeMultipartUpload: async ({ uploadId, key, parts })=>{
125
137
  return await edgeStoreSdk.completeMultipartUpload({
126
138
  uploadId,
@@ -140,5 +152,13 @@ function EdgeStoreProvider(options) {
140
152
  }
141
153
  };
142
154
  }
155
+ function mapSignedUploadAccess(res) {
156
+ return {
157
+ accessSignedUrl: res.accessSignedUrl,
158
+ accessSignedThumbnailUrl: res.accessSignedThumbnailUrl,
159
+ accessSignedUrlExpiresAt: res.accessSignedUrlExpiresAt ? new Date(res.accessSignedUrlExpiresAt) : undefined,
160
+ accessSignedUrlExpiresIn: res.accessSignedUrlExpiresIn
161
+ };
162
+ }
143
163
 
144
164
  export { EdgeStoreProvider };
@@ -0,0 +1,32 @@
1
+ export declare const SMOKE_CONTENT = "edgestore smoke test";
2
+ export declare function getSmokeApiEndpoint(): string;
3
+ export declare function getSmokeBucketName(): string;
4
+ export declare function getSmokeBasicAuthHeader(): string;
5
+ export declare function createSmokeFileName(prefix: string): string;
6
+ export declare function requireSmokeCredentials(): void;
7
+ export declare function retryUntilSuccess(params: {
8
+ action: () => Promise<{
9
+ success: boolean;
10
+ }>;
11
+ description: string;
12
+ }): Promise<{
13
+ success: boolean;
14
+ }>;
15
+ type SmokeFileResult = {
16
+ size: number;
17
+ url: string;
18
+ };
19
+ export declare function runSmokeUploadLifecycle(params: {
20
+ confirmUpload: (url: string) => Promise<{
21
+ success: boolean;
22
+ }>;
23
+ deleteFile: (url: string) => Promise<{
24
+ success: boolean;
25
+ }>;
26
+ deleteDescription: string;
27
+ expectedSize: number;
28
+ getFile?: (url: string) => Promise<SmokeFileResult>;
29
+ upload: () => Promise<SmokeFileResult>;
30
+ }): Promise<SmokeFileResult>;
31
+ export {};
32
+ //# sourceMappingURL=edgestoreSmoke.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edgestoreSmoke.d.ts","sourceRoot":"","sources":["../../src/test-utils/edgestoreSmoke.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,yBAAyB,CAAC;AAEpD,wBAAgB,mBAAmB,WAElC;AAED,wBAAgB,kBAAkB,WAEjC;AAED,wBAAgB,uBAAuB,WAKtC;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,UAEjD;AAED,wBAAgB,uBAAuB,SAStC;AAMD,wBAAsB,iBAAiB,CAAC,MAAM,EAAE;IAC9C,MAAM,EAAE,MAAM,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC5C,WAAW,EAAE,MAAM,CAAC;CACrB;aAE4B,OAAO;GAkCnC;AAED,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAuBF,wBAAsB,uBAAuB,CAAC,MAAM,EAAE;IACpD,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC9D,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAC3D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IACpD,MAAM,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAAC;CACxC,4BA4BA"}
@@ -0,0 +1,3 @@
1
+ export declare const EDGE_STORE_PACKAGE_NAME = "@edgestore/server";
2
+ export declare const EDGE_STORE_PACKAGE_VERSION = "0.8.1";
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,sBAAsB,CAAC;AAC3D,eAAO,MAAM,0BAA0B,UAAU,CAAC"}
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const EDGE_STORE_PACKAGE_NAME = '@edgestore/server';
4
+ const EDGE_STORE_PACKAGE_VERSION = '0.8.1';
5
+
6
+ exports.EDGE_STORE_PACKAGE_NAME = EDGE_STORE_PACKAGE_NAME;
7
+ exports.EDGE_STORE_PACKAGE_VERSION = EDGE_STORE_PACKAGE_VERSION;
@@ -0,0 +1,4 @@
1
+ const EDGE_STORE_PACKAGE_NAME = '@edgestore/server';
2
+ const EDGE_STORE_PACKAGE_VERSION = '0.8.1';
3
+
4
+ export { EDGE_STORE_PACKAGE_NAME, EDGE_STORE_PACKAGE_VERSION };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgestore/server",
3
- "version": "0.7.0",
3
+ "version": "0.8.1",
4
4
  "description": "Upload files with ease from React/Next.js",
5
5
  "homepage": "https://edgestore.dev",
6
6
  "license": "MIT",
@@ -109,7 +109,7 @@
109
109
  "!**/__tests__"
110
110
  ],
111
111
  "dependencies": {
112
- "@edgestore/shared": "0.7.0",
112
+ "@edgestore/shared": "0.8.1",
113
113
  "@panva/hkdf": "^1.0.4",
114
114
  "cookie": "^0.7.0",
115
115
  "jose": "^4.13.1",
@@ -144,6 +144,7 @@
144
144
  "@types/node": "25.0.3",
145
145
  "@types/uuid": "^9.0.1",
146
146
  "astro": "^5.7.12",
147
+ "dotenv": "^16.4.7",
147
148
  "express": "^4.18.2",
148
149
  "fastify": "^5.3.2",
149
150
  "hono": "^4.7.9",
@@ -158,6 +159,14 @@
158
159
  "build": "rollup --config rollup.config.ts --configPlugin rollup-plugin-swc3",
159
160
  "dev": "pnpm build --watch",
160
161
  "codegen:entrypoints": "tsx entrypoints.script.ts",
162
+ "test": "vitest run --config vitest.config.ts",
163
+ "test:smoke": "vitest run --config vitest.smoke.config.ts",
164
+ "test:smoke:dev": "TEST_ENV=dev vitest run --config vitest.smoke.config.ts",
165
+ "test:smoke:prod": "TEST_ENV=prod vitest run --config vitest.smoke.config.ts",
166
+ "test:smoke:adapter": "vitest run --config vitest.smoke.config.ts src/adapters/edgestore.smoke.test.ts",
167
+ "test:smoke:client": "vitest run --config vitest.smoke.config.ts src/core/client/edgestore.smoke.test.ts",
168
+ "test:smoke:errors": "vitest run --config vitest.smoke.config.ts src/core/sdk/edgestore.errors.smoke.test.ts",
169
+ "typecheck": "tsc --noEmit -p tsconfig.json",
161
170
  "lint": "eslint --cache --ext \".js,.ts,.tsx\" --ignore-path ../../.gitignore --report-unused-disable-directives src"
162
171
  }
163
172
  }
@@ -89,7 +89,7 @@ export function createEdgeStoreAstroHandler<TCtx>(config: Config<TCtx>) {
89
89
  cause: err instanceof Error ? err : undefined,
90
90
  });
91
91
  }
92
- const { newCookies, token, baseUrl, providerName } = await init({
92
+ const { newCookies, ...body } = await init({
93
93
  ctx,
94
94
  provider,
95
95
  router: config.router,
@@ -108,14 +108,7 @@ export function createEdgeStoreAstroHandler<TCtx>(config: Config<TCtx>) {
108
108
  headers.append('Set-Cookie', newCookies);
109
109
  }
110
110
 
111
- return new Response(
112
- JSON.stringify({
113
- token,
114
- baseUrl,
115
- providerName,
116
- }),
117
- { headers },
118
- );
111
+ return new Response(JSON.stringify(body), { headers });
119
112
  } else if (matchPath(url.pathname, 'request-upload')) {
120
113
  const body = (await request.json()) as RequestUploadBody;
121
114
  const result = await requestUpload({
@@ -174,29 +167,6 @@ export function createEdgeStoreAstroHandler<TCtx>(config: Config<TCtx>) {
174
167
  return new Response(JSON.stringify(result), {
175
168
  headers: { 'Content-Type': 'application/json' },
176
169
  });
177
- } else if (matchPath(url.pathname, 'proxy-file')) {
178
- const url = new URL(request.url).searchParams.get('url');
179
-
180
- if (typeof url === 'string') {
181
- const cookieHeader = request.headers.get('cookie') ?? '';
182
-
183
- const proxyRes = await fetch(url, {
184
- headers: {
185
- cookie: cookieHeader,
186
- },
187
- });
188
-
189
- const data = await proxyRes.arrayBuffer();
190
- const headers = new Headers();
191
- headers.set(
192
- 'Content-Type',
193
- proxyRes.headers.get('Content-Type') ?? 'application/octet-stream',
194
- );
195
-
196
- return new Response(data, { headers });
197
- } else {
198
- return new Response(null, { status: 400 });
199
- }
200
170
  } else {
201
171
  return new Response(null, { status: 404 });
202
172
  }
@@ -76,18 +76,14 @@ export function createEdgeStoreExpressHandler<TCtx>(config: Config<TCtx>) {
76
76
  cause: err instanceof Error ? err : undefined,
77
77
  });
78
78
  }
79
- const { newCookies, token, baseUrl, providerName } = await init({
79
+ const { newCookies, ...body } = await init({
80
80
  ctx,
81
81
  provider,
82
82
  router: config.router,
83
83
  cookieConfig,
84
84
  });
85
85
  res.setHeader('Set-Cookie', newCookies);
86
- res.json({
87
- token,
88
- baseUrl,
89
- providerName,
90
- });
86
+ res.json(body);
91
87
  } else if (matchPath(pathname, '/request-upload')) {
92
88
  res.json(
93
89
  await requestUpload({
@@ -132,25 +128,6 @@ export function createEdgeStoreExpressHandler<TCtx>(config: Config<TCtx>) {
132
128
  ctxToken: req.cookies[resolvedCookieConfig.ctx.name],
133
129
  }),
134
130
  );
135
- } else if (matchPath(pathname, '/proxy-file')) {
136
- const { url } = req.query;
137
- if (typeof url === 'string') {
138
- const proxyRes = await fetch(url, {
139
- headers: {
140
- cookie: req.headers.cookie ?? '',
141
- },
142
- });
143
-
144
- const data = await proxyRes.arrayBuffer();
145
- res.setHeader(
146
- 'Content-Type',
147
- proxyRes.headers.get('Content-Type') ?? 'application/octet-stream',
148
- );
149
-
150
- res.end(Buffer.from(data));
151
- } else {
152
- res.status(400).end();
153
- }
154
131
  } else {
155
132
  res.status(404).end();
156
133
  }
@@ -80,7 +80,7 @@ export function createEdgeStoreFastifyHandler<TCtx>(config: Config<TCtx>) {
80
80
 
81
81
  const resolvedCookieConfig = getCookieConfig(cookieConfig);
82
82
 
83
- return async (req: FastifyRequest, reply: FastifyReply) => {
83
+ return async (req: FastifyRequest, reply: FastifyReply): Promise<void> => {
84
84
  try {
85
85
  // Get the URL from the request - simplified approach
86
86
  const pathname = req.url;
@@ -101,7 +101,7 @@ export function createEdgeStoreFastifyHandler<TCtx>(config: Config<TCtx>) {
101
101
  cause: err instanceof Error ? err : undefined,
102
102
  });
103
103
  }
104
- const { newCookies, token, baseUrl, providerName } = await init({
104
+ const { newCookies, ...body } = await init({
105
105
  ctx,
106
106
  provider,
107
107
  router: config.router,
@@ -120,11 +120,7 @@ export function createEdgeStoreFastifyHandler<TCtx>(config: Config<TCtx>) {
120
120
  void reply.header('Set-Cookie', newCookies);
121
121
  }
122
122
 
123
- return reply.send({
124
- token,
125
- baseUrl,
126
- providerName,
127
- });
123
+ return reply.send(body);
128
124
  } else if (matchPath(pathname, '/request-upload')) {
129
125
  return reply.send(
130
126
  await requestUpload({
@@ -169,30 +165,6 @@ export function createEdgeStoreFastifyHandler<TCtx>(config: Config<TCtx>) {
169
165
  ctxToken: getCookie(req, resolvedCookieConfig.ctx.name),
170
166
  }),
171
167
  );
172
- } else if (matchPath(pathname, '/proxy-file')) {
173
- const url = req.query
174
- ? (req.query as Record<string, any>).url
175
- : undefined;
176
-
177
- if (typeof url === 'string') {
178
- const cookieHeader = req.headers.cookie ?? '';
179
-
180
- const proxyRes = await fetch(url, {
181
- headers: {
182
- cookie: cookieHeader,
183
- },
184
- });
185
-
186
- const data = await proxyRes.arrayBuffer();
187
- void reply.header(
188
- 'Content-Type',
189
- proxyRes.headers.get('Content-Type') ?? 'application/octet-stream',
190
- );
191
-
192
- return reply.send(Buffer.from(data));
193
- } else {
194
- return reply.status(400).send();
195
- }
196
168
  } else {
197
169
  return reply.status(404).send();
198
170
  }