@edgestore/server 0.7.0 → 1.0.0-next.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.
Files changed (113) hide show
  1. package/adapters/astro/index.d.ts +1 -1
  2. package/adapters/astro/index.js +1 -1
  3. package/adapters/express/index.d.ts +1 -1
  4. package/adapters/express/index.js +1 -1
  5. package/adapters/fastify/index.d.ts +1 -1
  6. package/adapters/fastify/index.js +1 -1
  7. package/adapters/hono/index.d.ts +1 -1
  8. package/adapters/hono/index.js +1 -1
  9. package/adapters/next/app/index.d.ts +1 -1
  10. package/adapters/next/app/index.js +1 -1
  11. package/adapters/next/pages/index.d.ts +1 -1
  12. package/adapters/next/pages/index.js +1 -1
  13. package/adapters/remix/index.d.ts +1 -1
  14. package/adapters/remix/index.js +1 -1
  15. package/adapters/start/index.d.ts +1 -1
  16. package/adapters/start/index.js +1 -1
  17. package/core/index.d.ts +1 -1
  18. package/core/index.js +1 -1
  19. package/dist/adapters/astro/index.d.ts +2 -2
  20. package/dist/adapters/astro/index.d.ts.map +1 -1
  21. package/dist/adapters/astro/index.js +35 -43
  22. package/dist/adapters/express/index.d.ts +2 -2
  23. package/dist/adapters/express/index.d.ts.map +1 -1
  24. package/dist/adapters/express/index.js +34 -41
  25. package/dist/adapters/fastify/index.d.ts +3 -3
  26. package/dist/adapters/fastify/index.d.ts.map +1 -1
  27. package/dist/adapters/fastify/index.js +33 -42
  28. package/dist/adapters/hono/index.d.ts +6 -72
  29. package/dist/adapters/hono/index.d.ts.map +1 -1
  30. package/dist/adapters/hono/index.js +38 -41
  31. package/dist/adapters/imageTypes.js +1 -3
  32. package/dist/adapters/next/app/index.d.ts +2 -2
  33. package/dist/adapters/next/app/index.d.ts.map +1 -1
  34. package/dist/adapters/next/app/index.js +34 -42
  35. package/dist/adapters/next/pages/index.d.ts +2 -2
  36. package/dist/adapters/next/pages/index.d.ts.map +1 -1
  37. package/dist/adapters/next/pages/index.js +35 -42
  38. package/dist/adapters/remix/index.d.ts +2 -2
  39. package/dist/adapters/remix/index.d.ts.map +1 -1
  40. package/dist/adapters/remix/index.js +35 -42
  41. package/dist/adapters/shared.d.ts +8 -0
  42. package/dist/adapters/shared.d.ts.map +1 -1
  43. package/dist/adapters/shared.js +79 -56
  44. package/dist/adapters/start/index.d.ts +2 -2
  45. package/dist/adapters/start/index.d.ts.map +1 -1
  46. package/dist/adapters/start/index.js +35 -43
  47. package/dist/core/client/index.d.ts +112 -69
  48. package/dist/core/client/index.d.ts.map +1 -1
  49. package/dist/core/client/index.js +59 -13
  50. package/dist/core/index.d.ts +2 -2
  51. package/dist/core/index.js +2 -10
  52. package/dist/core/sdk/index.d.ts +44 -2
  53. package/dist/core/sdk/index.d.ts.map +1 -1
  54. package/dist/core/sdk/index.js +43 -16
  55. package/dist/index.js +1 -10
  56. package/dist/libs/errors/EdgeStoreCredentialsError.js +1 -3
  57. package/dist/libs/logger.js +5 -9
  58. package/dist/libs/utils.js +1 -3
  59. package/dist/providers/aws/index.d.ts +1 -1
  60. package/dist/providers/aws/index.d.ts.map +1 -1
  61. package/dist/providers/aws/index.js +14 -17
  62. package/dist/providers/azure/index.d.ts.map +1 -1
  63. package/dist/providers/azure/index.js +38 -15
  64. package/dist/providers/edgestore/index.d.ts.map +1 -1
  65. package/dist/providers/edgestore/index.js +36 -18
  66. package/dist/test-utils/edgestoreSmoke.d.ts +32 -0
  67. package/dist/test-utils/edgestoreSmoke.d.ts.map +1 -0
  68. package/dist/version.d.ts +3 -0
  69. package/dist/version.d.ts.map +1 -0
  70. package/dist/version.js +4 -0
  71. package/package.json +59 -49
  72. package/providers/aws/index.d.ts +1 -1
  73. package/providers/aws/index.js +1 -1
  74. package/providers/azure/index.d.ts +1 -1
  75. package/providers/azure/index.js +1 -1
  76. package/providers/edgestore/index.d.ts +1 -1
  77. package/providers/edgestore/index.js +1 -1
  78. package/src/adapters/astro/index.ts +11 -21
  79. package/src/adapters/express/index.ts +10 -16
  80. package/src/adapters/fastify/index.ts +13 -19
  81. package/src/adapters/hono/index.ts +19 -23
  82. package/src/adapters/next/app/index.ts +12 -22
  83. package/src/adapters/next/pages/index.ts +11 -16
  84. package/src/adapters/remix/index.ts +11 -12
  85. package/src/adapters/shared.ts +61 -17
  86. package/src/adapters/start/index.ts +11 -12
  87. package/src/core/client/index.ts +199 -75
  88. package/src/core/sdk/index.ts +76 -8
  89. package/src/providers/aws/index.ts +4 -5
  90. package/src/providers/azure/index.ts +40 -11
  91. package/src/providers/edgestore/index.ts +29 -0
  92. package/src/test-utils/edgestoreSmoke.ts +141 -0
  93. package/src/version.ts +2 -0
  94. package/dist/adapters/astro/index.mjs +0 -178
  95. package/dist/adapters/express/index.mjs +0 -113
  96. package/dist/adapters/fastify/index.mjs +0 -142
  97. package/dist/adapters/hono/index.mjs +0 -132
  98. package/dist/adapters/imageTypes.mjs +0 -12
  99. package/dist/adapters/next/app/index.mjs +0 -169
  100. package/dist/adapters/next/pages/index.mjs +0 -117
  101. package/dist/adapters/remix/index.mjs +0 -153
  102. package/dist/adapters/shared.mjs +0 -443
  103. package/dist/adapters/start/index.mjs +0 -187
  104. package/dist/core/client/index.mjs +0 -173
  105. package/dist/core/index.mjs +0 -2
  106. package/dist/core/sdk/index.mjs +0 -223
  107. package/dist/index.mjs +0 -1
  108. package/dist/libs/errors/EdgeStoreCredentialsError.mjs +0 -10
  109. package/dist/libs/logger.mjs +0 -53
  110. package/dist/libs/utils.mjs +0 -10
  111. package/dist/providers/aws/index.mjs +0 -103
  112. package/dist/providers/azure/index.mjs +0 -59
  113. package/dist/providers/edgestore/index.mjs +0 -144
@@ -1,187 +0,0 @@
1
- import { EdgeStoreError, EDGE_STORE_ERROR_CODES } from '@edgestore/shared';
2
- import Logger from '../../libs/logger.mjs';
3
- import { matchPath } from '../../libs/utils.mjs';
4
- import { EdgeStoreProvider } from '../../providers/edgestore/index.mjs';
5
- import { getCookieConfig, init, requestUpload, requestUploadParts, completeMultipartUpload, confirmUpload, deleteFile } from '../shared.mjs';
6
-
7
- // Helper to extract a cookie from the request's cookie header
8
- function getCookie(req, cookieName) {
9
- const cookieHeader = req.headers.get('cookie');
10
- if (!cookieHeader) return undefined;
11
- return cookieHeader.split(';').map((cookieStr)=>cookieStr.trim()).reduce((acc, cookieStr)=>{
12
- const [name, ...rest] = cookieStr.split('=');
13
- if (name && rest.length > 0) {
14
- acc[name] = rest.join('=');
15
- }
16
- return acc;
17
- }, {})[cookieName];
18
- }
19
- function createEdgeStoreStartHandler(config) {
20
- const { provider = EdgeStoreProvider(), cookieConfig } = config;
21
- const log = new Logger(config.logLevel);
22
- globalThis._EDGE_STORE_LOGGER = log;
23
- log.debug('Creating EdgeStore TanStack Start handler');
24
- const resolvedCookieConfig = getCookieConfig(cookieConfig);
25
- return async ({ request })=>{
26
- try {
27
- const { pathname } = new URL(request.url);
28
- if (matchPath(pathname, '/health')) {
29
- return new Response('OK', {
30
- status: 200
31
- });
32
- } else if (matchPath(pathname, '/init')) {
33
- let ctx = {};
34
- try {
35
- ctx = 'createContext' in config ? await config.createContext({
36
- req: request
37
- }) : {};
38
- } catch (err) {
39
- throw new EdgeStoreError({
40
- message: 'Error creating context',
41
- code: 'CREATE_CONTEXT_ERROR',
42
- cause: err instanceof Error ? err : undefined
43
- });
44
- }
45
- const { newCookies, token, baseUrl, providerName } = await init({
46
- ctx,
47
- provider,
48
- router: config.router,
49
- cookieConfig
50
- });
51
- const headers = new Headers();
52
- newCookies.forEach((cookie)=>{
53
- headers.append('Set-Cookie', cookie);
54
- });
55
- headers.set('Content-Type', 'application/json');
56
- return new Response(JSON.stringify({
57
- token,
58
- baseUrl,
59
- providerName
60
- }), {
61
- status: 200,
62
- headers
63
- });
64
- } else if (matchPath(pathname, '/request-upload')) {
65
- const body = await request.json();
66
- const ctxToken = getCookie(request, resolvedCookieConfig.ctx.name);
67
- const result = await requestUpload({
68
- provider,
69
- router: config.router,
70
- body: body,
71
- ctxToken
72
- });
73
- return new Response(JSON.stringify(result), {
74
- status: 200,
75
- headers: {
76
- 'Content-Type': 'application/json'
77
- }
78
- });
79
- } else if (matchPath(pathname, '/request-upload-parts')) {
80
- const body = await request.json();
81
- const ctxToken = getCookie(request, resolvedCookieConfig.ctx.name);
82
- const result = await requestUploadParts({
83
- provider,
84
- router: config.router,
85
- body: body,
86
- ctxToken
87
- });
88
- return new Response(JSON.stringify(result), {
89
- status: 200,
90
- headers: {
91
- 'Content-Type': 'application/json'
92
- }
93
- });
94
- } else if (matchPath(pathname, '/complete-multipart-upload')) {
95
- const body = await request.json();
96
- const ctxToken = getCookie(request, resolvedCookieConfig.ctx.name);
97
- await completeMultipartUpload({
98
- provider,
99
- router: config.router,
100
- body: body,
101
- ctxToken
102
- });
103
- return new Response(null, {
104
- status: 200
105
- });
106
- } else if (matchPath(pathname, '/confirm-upload')) {
107
- const body = await request.json();
108
- const ctxToken = getCookie(request, resolvedCookieConfig.ctx.name);
109
- const result = await confirmUpload({
110
- provider,
111
- router: config.router,
112
- body: body,
113
- ctxToken
114
- });
115
- return new Response(JSON.stringify(result), {
116
- status: 200,
117
- headers: {
118
- 'Content-Type': 'application/json'
119
- }
120
- });
121
- } else if (matchPath(pathname, '/delete-file')) {
122
- const body = await request.json();
123
- const ctxToken = getCookie(request, resolvedCookieConfig.ctx.name);
124
- const result = await deleteFile({
125
- provider,
126
- router: config.router,
127
- body: body,
128
- ctxToken
129
- });
130
- return new Response(JSON.stringify(result), {
131
- status: 200,
132
- headers: {
133
- 'Content-Type': 'application/json'
134
- }
135
- });
136
- } else if (matchPath(pathname, '/proxy-file')) {
137
- const urlParam = new URL(request.url).searchParams.get('url');
138
- if (typeof urlParam === 'string') {
139
- const proxyRes = await fetch(urlParam, {
140
- headers: {
141
- cookie: request.headers.get('cookie') ?? ''
142
- }
143
- });
144
- const data = await proxyRes.arrayBuffer();
145
- const headers = new Headers();
146
- headers.set('Content-Type', proxyRes.headers.get('Content-Type') ?? 'application/octet-stream');
147
- return new Response(data, {
148
- status: proxyRes.status,
149
- headers
150
- });
151
- } else {
152
- return new Response(null, {
153
- status: 400
154
- });
155
- }
156
- } else {
157
- return new Response(null, {
158
- status: 404
159
- });
160
- }
161
- } catch (err) {
162
- if (err instanceof EdgeStoreError) {
163
- log[err.level](err.formattedMessage());
164
- if (err.cause) log[err.level](err.cause);
165
- const status = EDGE_STORE_ERROR_CODES[err.code] || 500;
166
- return new Response(JSON.stringify(err.formattedJson()), {
167
- status,
168
- headers: {
169
- 'Content-Type': 'application/json'
170
- }
171
- });
172
- }
173
- log.error(err);
174
- return new Response(JSON.stringify(new EdgeStoreError({
175
- message: 'Internal server error',
176
- code: 'SERVER_ERROR'
177
- }).formattedJson()), {
178
- status: 500,
179
- headers: {
180
- 'Content-Type': 'application/json'
181
- }
182
- });
183
- }
184
- };
185
- }
186
-
187
- export { createEdgeStoreStartHandler };
@@ -1,173 +0,0 @@
1
- import { buildPath, parsePath, isDev } from '../../adapters/shared.mjs';
2
- import { initEdgeStoreSdk } from '../sdk/index.mjs';
3
-
4
- // type guard for `content`
5
- function isTextContent(content) {
6
- return typeof content === 'string';
7
- }
8
- function isBlobContent(content) {
9
- return typeof content !== 'string' && 'blob' in content;
10
- }
11
- function initEdgeStoreClient(config) {
12
- const sdk = initEdgeStoreSdk({
13
- accessKey: config.accessKey,
14
- secretKey: config.secretKey
15
- });
16
- return new Proxy({}, {
17
- get (_target, key) {
18
- const bucketName = key;
19
- const bucket = config.router.buckets[bucketName];
20
- if (!bucket) {
21
- throw new Error(`Bucket ${bucketName} not found`);
22
- }
23
- const client = {
24
- async upload (params) {
25
- const content = params.content;
26
- const ctx = 'ctx' in params ? params.ctx : {};
27
- const input = 'input' in params ? params.input : {};
28
- const { blob, extension } = await (async ()=>{
29
- if (isTextContent(content)) {
30
- return {
31
- blob: new Blob([
32
- content
33
- ], {
34
- type: 'text/plain'
35
- }),
36
- extension: 'txt'
37
- };
38
- } else if (isBlobContent(content)) {
39
- return {
40
- blob: content.blob,
41
- extension: content.extension
42
- };
43
- } else {
44
- return {
45
- blob: await getBlobFromUrl(content.url),
46
- extension: content.extension
47
- };
48
- }
49
- })();
50
- const path = buildPath({
51
- bucket,
52
- pathAttrs: {
53
- ctx,
54
- input
55
- },
56
- fileInfo: {
57
- type: blob.type,
58
- size: blob.size,
59
- fileName: params.options?.manualFileName,
60
- replaceTargetUrl: params.options?.replaceTargetUrl
61
- }
62
- });
63
- const metadata = await bucket._def.metadata({
64
- ctx,
65
- input
66
- });
67
- const requestUploadRes = await sdk.requestUpload({
68
- bucketName,
69
- bucketType: bucket._def.type,
70
- fileInfo: {
71
- fileName: params.options?.manualFileName,
72
- replaceTargetUrl: params.options?.replaceTargetUrl,
73
- type: blob.type,
74
- size: blob.size,
75
- extension,
76
- isPublic: bucket._def.accessControl === undefined,
77
- temporary: params.options?.temporary ?? false,
78
- path,
79
- metadata
80
- }
81
- });
82
- const { signedUrl, multipart } = requestUploadRes;
83
- if (multipart) {
84
- // TODO
85
- throw new Error('Multipart upload not implemented');
86
- } else if (signedUrl) {
87
- const uploadResponse = await fetch(signedUrl, {
88
- method: 'PUT',
89
- body: blob
90
- });
91
- if (!uploadResponse.ok) {
92
- throw new Error(`Upload failed with status ${uploadResponse.status}: ${uploadResponse.statusText}`);
93
- }
94
- } else {
95
- throw new Error('Missing signedUrl');
96
- }
97
- const { parsedPath, pathOrder } = parsePath(path);
98
- return {
99
- url: requestUploadRes.accessUrl,
100
- ...{
101
- thumbnailUrl: requestUploadRes.thumbnailUrl
102
- },
103
- size: blob.size,
104
- metadata,
105
- path: parsedPath,
106
- pathOrder
107
- };
108
- },
109
- async getFile (params) {
110
- const res = await sdk.getFile(params);
111
- return {
112
- url: getUrl(res.url, config.baseUrl),
113
- size: res.size,
114
- uploadedAt: new Date(res.uploadedAt),
115
- metadata: res.metadata,
116
- path: res.path
117
- };
118
- },
119
- async confirmUpload (params) {
120
- return await sdk.confirmUpload(params);
121
- },
122
- async deleteFile (params) {
123
- return await sdk.deleteFile(params);
124
- },
125
- async listFiles (params) {
126
- const res = await sdk.listFiles({
127
- bucketName,
128
- ...params
129
- });
130
- const files = res.data.map((file)=>{
131
- return {
132
- url: getUrl(file.url, config.baseUrl),
133
- thumbnailUrl: file.thumbnailUrl,
134
- size: file.size,
135
- uploadedAt: new Date(file.uploadedAt),
136
- metadata: file.metadata,
137
- path: file.path
138
- };
139
- });
140
- return {
141
- data: files,
142
- pagination: res.pagination
143
- };
144
- }
145
- };
146
- return client;
147
- }
148
- });
149
- }
150
- /**
151
- * Protected files need third-party cookies to work.
152
- * Since third party cookies don't work on localhost,
153
- * we need to proxy the file through the server.
154
- */ function getUrl(url, baseUrl) {
155
- if (isDev() && !url.includes('/_public/')) {
156
- if (!baseUrl) {
157
- throw new Error('Missing baseUrl. You need to pass the baseUrl to `initEdgeStoreClient` to get protected files in development.');
158
- }
159
- const proxyUrl = new URL(baseUrl);
160
- proxyUrl.pathname = `${proxyUrl.pathname}/proxy-file`;
161
- proxyUrl.search = new URLSearchParams({
162
- url
163
- }).toString();
164
- return proxyUrl.toString();
165
- }
166
- return url;
167
- }
168
- async function getBlobFromUrl(url) {
169
- const res = await fetch(url);
170
- return await res.blob();
171
- }
172
-
173
- export { initEdgeStoreClient };
@@ -1,2 +0,0 @@
1
- export { initEdgeStoreClient } from './client/index.mjs';
2
- export { edgeStoreRawSdk, initEdgeStoreSdk } from './sdk/index.mjs';
@@ -1,223 +0,0 @@
1
- import { EdgeStoreError } from '@edgestore/shared';
2
- import { getEnv } from '../../adapters/shared.mjs';
3
- import EdgeStoreCredentialsError from '../../libs/errors/EdgeStoreCredentialsError.mjs';
4
-
5
- const API_ENDPOINT = getEnv('EDGE_STORE_API_ENDPOINT') ?? 'https://api.edgestore.dev';
6
- async function makeRequest(params) {
7
- const { body, accessKey, secretKey, path } = params;
8
- const res = await fetch(`${API_ENDPOINT}${path}`, {
9
- method: 'POST',
10
- body: JSON.stringify(body),
11
- headers: {
12
- 'Content-Type': 'application/json',
13
- Authorization: `Basic ${Buffer.from(`${accessKey}:${secretKey}`).toString('base64')}`
14
- }
15
- });
16
- if (!res.ok) {
17
- throw new Error(`Failed to make request to ${path}: ${await res.text()}`);
18
- }
19
- return await res.json();
20
- }
21
- const edgeStoreRawSdk = {
22
- async getToken (params) {
23
- const reqBuckets = Object.entries(params.router.buckets).reduce((acc, [bucketName, bucket])=>{
24
- acc[bucketName] = {
25
- path: bucket._def.path.map((p)=>{
26
- const paramEntries = Object.entries(p);
27
- if (paramEntries[0] === undefined) {
28
- throw new EdgeStoreError({
29
- message: `Empty path param found in: ${JSON.stringify(bucket._def.path)}`,
30
- code: 'SERVER_ERROR'
31
- });
32
- }
33
- const [key, value] = paramEntries[0];
34
- return {
35
- key,
36
- value: value()
37
- };
38
- }),
39
- accessControl: bucket._def.accessControl
40
- };
41
- return acc;
42
- }, {});
43
- const { token } = await makeRequest({
44
- body: {
45
- ctx: params.ctx,
46
- buckets: reqBuckets
47
- },
48
- accessKey: params.accessKey,
49
- secretKey: params.secretKey,
50
- path: '/get-token'
51
- });
52
- return token;
53
- },
54
- async getFile ({ accessKey, secretKey, url }) {
55
- return await makeRequest({
56
- path: '/get-file',
57
- accessKey,
58
- secretKey,
59
- body: {
60
- url
61
- }
62
- });
63
- },
64
- async requestUpload ({ accessKey, secretKey, bucketName, bucketType, fileInfo, multipart }) {
65
- const res = await makeRequest({
66
- path: '/request-upload',
67
- accessKey,
68
- secretKey,
69
- body: {
70
- multipart,
71
- bucketName,
72
- bucketType,
73
- isPublic: fileInfo.isPublic,
74
- path: fileInfo.path,
75
- extension: fileInfo.extension,
76
- size: fileInfo.size,
77
- mimeType: fileInfo.type,
78
- metadata: fileInfo.metadata,
79
- fileName: fileInfo.fileName,
80
- replaceTargetUrl: fileInfo.replaceTargetUrl,
81
- isTemporary: fileInfo.temporary
82
- }
83
- });
84
- return {
85
- multipart: res.multipart,
86
- signedUrl: res.signedUrl,
87
- accessUrl: res.url,
88
- path: res.path,
89
- thumbnailUrl: res.thumbnailUrl
90
- };
91
- },
92
- async requestUploadParts ({ accessKey, secretKey, key, multipart }) {
93
- const res = await makeRequest({
94
- path: '/request-upload-parts',
95
- accessKey,
96
- secretKey,
97
- body: {
98
- multipart,
99
- key
100
- }
101
- });
102
- return {
103
- multipart: res.multipart
104
- };
105
- },
106
- async completeMultipartUpload ({ accessKey, secretKey, uploadId, key, parts }) {
107
- return await makeRequest({
108
- path: '/complete-multipart-upload',
109
- accessKey,
110
- secretKey,
111
- body: {
112
- uploadId,
113
- key,
114
- parts
115
- }
116
- });
117
- },
118
- async confirmUpload ({ accessKey, secretKey, url }) {
119
- return await makeRequest({
120
- path: '/confirm-upload',
121
- accessKey,
122
- secretKey,
123
- body: {
124
- url
125
- }
126
- });
127
- },
128
- async deleteFile ({ accessKey, secretKey, url }) {
129
- return await makeRequest({
130
- path: '/delete-file',
131
- accessKey,
132
- secretKey,
133
- body: {
134
- url
135
- }
136
- });
137
- },
138
- async listFiles ({ accessKey, secretKey, bucketName, filter, pagination }) {
139
- return await makeRequest({
140
- path: '/list-files',
141
- accessKey,
142
- secretKey,
143
- body: {
144
- bucketName,
145
- filter,
146
- pagination
147
- }
148
- });
149
- }
150
- };
151
- function initEdgeStoreSdk(params) {
152
- const { accessKey = getEnv('EDGE_STORE_ACCESS_KEY'), secretKey = getEnv('EDGE_STORE_SECRET_KEY') } = params ?? {};
153
- if (!accessKey || !secretKey) {
154
- throw new EdgeStoreCredentialsError();
155
- }
156
- return {
157
- async getToken (params) {
158
- return await edgeStoreRawSdk.getToken({
159
- accessKey,
160
- secretKey,
161
- ctx: params.ctx,
162
- router: params.router
163
- });
164
- },
165
- async getFile ({ url }) {
166
- return await edgeStoreRawSdk.getFile({
167
- accessKey,
168
- secretKey,
169
- url
170
- });
171
- },
172
- async requestUpload ({ bucketName, bucketType, fileInfo, multipart }) {
173
- return await edgeStoreRawSdk.requestUpload({
174
- accessKey,
175
- secretKey,
176
- bucketName,
177
- bucketType,
178
- fileInfo,
179
- multipart
180
- });
181
- },
182
- async requestUploadParts ({ key, multipart }) {
183
- return await edgeStoreRawSdk.requestUploadParts({
184
- accessKey,
185
- secretKey,
186
- key,
187
- multipart
188
- });
189
- },
190
- async completeMultipartUpload ({ uploadId, key, parts }) {
191
- return await edgeStoreRawSdk.completeMultipartUpload({
192
- accessKey,
193
- secretKey,
194
- uploadId,
195
- key,
196
- parts
197
- });
198
- },
199
- async confirmUpload ({ url }) {
200
- return await edgeStoreRawSdk.confirmUpload({
201
- accessKey,
202
- secretKey,
203
- url
204
- });
205
- },
206
- async deleteFile ({ url }) {
207
- return await edgeStoreRawSdk.deleteFile({
208
- accessKey,
209
- secretKey,
210
- url
211
- });
212
- },
213
- async listFiles (params) {
214
- return await edgeStoreRawSdk.listFiles({
215
- accessKey,
216
- secretKey,
217
- ...params
218
- });
219
- }
220
- };
221
- }
222
-
223
- export { edgeStoreRawSdk, initEdgeStoreSdk };
package/dist/index.mjs DELETED
@@ -1 +0,0 @@
1
- export { initEdgeStore } from '@edgestore/shared';
@@ -1,10 +0,0 @@
1
- const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
2
- This can happen if you are trying to import something related to the backend of EdgeStore in a client component.`;
3
- class EdgeStoreCredentialsError extends Error {
4
- constructor(message = DEFAULT_MESSAGE){
5
- super(message);
6
- this.name = 'EdgeStoreCredentialsError';
7
- }
8
- }
9
-
10
- export { EdgeStoreCredentialsError as default };
@@ -1,53 +0,0 @@
1
- import { isDev } from '../adapters/shared.mjs';
2
-
3
- /* eslint-disable no-console */ function _define_property(obj, key, value) {
4
- if (key in obj) {
5
- Object.defineProperty(obj, key, {
6
- value: value,
7
- enumerable: true,
8
- configurable: true,
9
- writable: true
10
- });
11
- } else {
12
- obj[key] = value;
13
- }
14
- return obj;
15
- }
16
- const logLevel = [
17
- 'debug',
18
- 'info',
19
- 'warn',
20
- 'error',
21
- 'none'
22
- ];
23
- class Logger {
24
- shouldLog(level) {
25
- return logLevel.indexOf(level) >= logLevel.indexOf(this.logLevel);
26
- }
27
- debug(message, ...optionalParams) {
28
- if (this.shouldLog('debug')) {
29
- console.debug('[EdgeStoreDebug]', message, ...optionalParams);
30
- }
31
- }
32
- info(message, ...optionalParams) {
33
- if (this.shouldLog('info')) {
34
- console.info('[EdgeStoreInfo]', message, ...optionalParams);
35
- }
36
- }
37
- warn(message, ...optionalParams) {
38
- if (this.shouldLog('warn')) {
39
- console.warn('[EdgeStoreWarn]', message, ...optionalParams);
40
- }
41
- }
42
- error(message, ...optionalParams) {
43
- if (this.shouldLog('error')) {
44
- console.error('[EdgeStoreError]', message, ...optionalParams);
45
- }
46
- }
47
- constructor(logLevel){
48
- _define_property(this, "logLevel", void 0);
49
- this.logLevel = logLevel ?? (isDev() ? 'info' : 'error');
50
- }
51
- }
52
-
53
- export { Logger as default };
@@ -1,10 +0,0 @@
1
- /**
2
- * Check if a route matches the current path.
3
- */ function matchPath(pathname, route) {
4
- // Allow trailing slash
5
- // Allow query string
6
- const regex = new RegExp(`${route}/?(\\?.*)?$`);
7
- return regex.test(pathname);
8
- }
9
-
10
- export { matchPath };