@edgestore/server 1.0.0-next.2 → 1.0.0-next.4
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/agent-docs/README.md +20 -0
- package/agent-docs/astro.md +153 -0
- package/agent-docs/backend-client.md +294 -0
- package/agent-docs/configuration.md +269 -0
- package/agent-docs/express.md +130 -0
- package/agent-docs/fastify.md +129 -0
- package/agent-docs/hono.md +137 -0
- package/agent-docs/next.md +94 -0
- package/agent-docs/provider-azure-blob.md +87 -0
- package/agent-docs/provider-custom.md +266 -0
- package/agent-docs/provider-edgestore.md +53 -0
- package/agent-docs/provider-s3.md +166 -0
- package/agent-docs/remix.md +123 -0
- package/agent-docs/tanstack-start.md +105 -0
- package/agent-docs/troubleshooting.md +83 -0
- package/dist/adapters/shared.js +1 -1
- package/dist/providers/edgestore/index.d.ts +4 -1
- package/dist/providers/edgestore/index.d.ts.map +1 -1
- package/dist/providers/edgestore/index.js +11 -2
- package/dist/version.d.ts +1 -1
- package/package.json +6 -4
- package/src/adapters/shared.ts +1 -1
- package/src/providers/edgestore/index.ts +9 -1
- package/src/version.ts +1 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Remix / React Router
|
|
2
|
+
|
|
3
|
+
Source: https://next.edgestore.dev/docs/adapters/remix
|
|
4
|
+
|
|
5
|
+
Use the Remix adapter with Remix or React Router framework mode. A client-only
|
|
6
|
+
React Router application needs a separate backend; this route runs on the server.
|
|
7
|
+
|
|
8
|
+
## Setup
|
|
9
|
+
|
|
10
|
+
### Install
|
|
11
|
+
|
|
12
|
+
Packages to install (use the application’s package manager):
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
@edgestore/server @edgestore/react
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Environment variables
|
|
19
|
+
|
|
20
|
+
Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/) to the backend env file:
|
|
21
|
+
|
|
22
|
+
Example: title=".env"
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
EDGE_STORE_ACCESS_KEY=your-access-key
|
|
26
|
+
EDGE_STORE_SECRET_KEY=your-secret-key
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> WARNING
|
|
30
|
+
>
|
|
31
|
+
> Add `.env` to `.gitignore`.
|
|
32
|
+
|
|
33
|
+
### Backend
|
|
34
|
+
|
|
35
|
+
Create the EdgeStore API route:
|
|
36
|
+
|
|
37
|
+
Example: title="app/routes/api/edgestore.ts"
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { createEdgeStore, initEdgeStore } from '@edgestore/server';
|
|
41
|
+
import { createEdgeStoreRemixHandler } from '@edgestore/server/adapters/remix';
|
|
42
|
+
import { edgestore } from '@edgestore/server/providers/edgestore';
|
|
43
|
+
|
|
44
|
+
const es = initEdgeStore.create();
|
|
45
|
+
|
|
46
|
+
const router = es.router({
|
|
47
|
+
publicFiles: es.fileBucket(),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export type EdgeStoreRouter = typeof router;
|
|
51
|
+
|
|
52
|
+
const configuredEdgeStore = createEdgeStore({
|
|
53
|
+
router,
|
|
54
|
+
provider: edgestore(),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const handler = createEdgeStoreRemixHandler({
|
|
58
|
+
edgestore: configuredEdgeStore,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export { handler as loader, handler as action };
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
For React Router framework mode, add the endpoint to your existing routes file:
|
|
65
|
+
|
|
66
|
+
Example: title="app/routes.ts"
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { index, route, type RouteConfig } from '@react-router/dev/routes';
|
|
70
|
+
|
|
71
|
+
export default [
|
|
72
|
+
index('routes/home.tsx'),
|
|
73
|
+
// [!code ++]
|
|
74
|
+
route('api/edgestore/*', 'routes/api/edgestore.ts'),
|
|
75
|
+
] satisfies RouteConfig;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
For Remix v2's default file-based routing, put the same handler in
|
|
79
|
+
`app/routes/api.edgestore.$.ts` instead. For custom routing, see
|
|
80
|
+
[Remix route conventions](https://v2.remix.run/docs/file-conventions/routes/)
|
|
81
|
+
and [React Router routing](https://reactrouter.com/start/framework/routing).
|
|
82
|
+
|
|
83
|
+
### Frontend
|
|
84
|
+
|
|
85
|
+
Create the React provider:
|
|
86
|
+
|
|
87
|
+
Example: title="app/lib/edgestore.ts"
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { createEdgeStoreProvider } from '@edgestore/react';
|
|
91
|
+
import type { EdgeStoreRouter } from '~/routes/api/edgestore';
|
|
92
|
+
|
|
93
|
+
const { EdgeStoreProvider, useEdgeStore } =
|
|
94
|
+
createEdgeStoreProvider<EdgeStoreRouter>();
|
|
95
|
+
|
|
96
|
+
export { EdgeStoreProvider, useEdgeStore };
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Point the type-only import at your actual route module; for the Remix filename
|
|
100
|
+
above, use `~/routes/api.edgestore.$`.
|
|
101
|
+
|
|
102
|
+
Wrap the root component with the provider:
|
|
103
|
+
|
|
104
|
+
Example: title="app/root.tsx"
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
// [!code ++]
|
|
108
|
+
import { EdgeStoreProvider } from '~/lib/edgestore';
|
|
109
|
+
|
|
110
|
+
// ...
|
|
111
|
+
|
|
112
|
+
export default function App() {
|
|
113
|
+
return (
|
|
114
|
+
<EdgeStoreProvider>
|
|
115
|
+
<Outlet />
|
|
116
|
+
</EdgeStoreProvider>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Usage
|
|
122
|
+
|
|
123
|
+
See [Quick start](https://next.edgestore.dev/docs/quick-start) for the upload UI.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# TanStack Start
|
|
2
|
+
|
|
3
|
+
Source: https://next.edgestore.dev/docs/adapters/tanstack-start
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
### Install
|
|
8
|
+
|
|
9
|
+
Packages to install (use the application’s package manager):
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
@edgestore/server @edgestore/react
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Environment variables
|
|
16
|
+
|
|
17
|
+
Copy your project's keys from the [dashboard](https://dashboard.edgestore.dev/) to the backend env file:
|
|
18
|
+
|
|
19
|
+
Example: title=".env.local"
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
EDGE_STORE_ACCESS_KEY=your-access-key
|
|
23
|
+
EDGE_STORE_SECRET_KEY=your-secret-key
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> WARNING
|
|
27
|
+
>
|
|
28
|
+
> Use the app's existing env file, or `.env.local` for a new app. Keep it gitignored.
|
|
29
|
+
|
|
30
|
+
### Backend
|
|
31
|
+
|
|
32
|
+
Create the EdgeStore API route:
|
|
33
|
+
|
|
34
|
+
Example: title="src/routes/api/edgestore.$.ts"
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
import { createEdgeStore, initEdgeStore } from '@edgestore/server';
|
|
38
|
+
import { createEdgeStoreStartHandler } from '@edgestore/server/adapters/start';
|
|
39
|
+
import { edgestore } from '@edgestore/server/providers/edgestore';
|
|
40
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
41
|
+
|
|
42
|
+
const es = initEdgeStore.create();
|
|
43
|
+
const router = es.router({
|
|
44
|
+
publicFiles: es.fileBucket(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export type EdgeStoreRouter = typeof router;
|
|
48
|
+
|
|
49
|
+
const configuredEdgeStore = createEdgeStore({
|
|
50
|
+
router,
|
|
51
|
+
provider: edgestore(),
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const handler = createEdgeStoreStartHandler({
|
|
55
|
+
edgestore: configuredEdgeStore,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const Route = createFileRoute('/api/edgestore/$')({
|
|
59
|
+
server: {
|
|
60
|
+
handlers: {
|
|
61
|
+
GET: handler,
|
|
62
|
+
POST: handler,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Frontend
|
|
69
|
+
|
|
70
|
+
Create the React provider:
|
|
71
|
+
|
|
72
|
+
Example: title="src/utils/edgestore.ts"
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
import { createEdgeStoreProvider } from '@edgestore/react';
|
|
76
|
+
import { type EdgeStoreRouter } from '../routes/api/edgestore.$';
|
|
77
|
+
|
|
78
|
+
const { EdgeStoreProvider, useEdgeStore } =
|
|
79
|
+
createEdgeStoreProvider<EdgeStoreRouter>();
|
|
80
|
+
|
|
81
|
+
export { EdgeStoreProvider, useEdgeStore };
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Wrap your app with the provider:
|
|
85
|
+
|
|
86
|
+
Example: title="src/routes/\_\_root.tsx"
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
// [!code ++]
|
|
90
|
+
import { EdgeStoreProvider } from '~/utils/edgestore';
|
|
91
|
+
|
|
92
|
+
// ...
|
|
93
|
+
|
|
94
|
+
function RootComponent() {
|
|
95
|
+
return (
|
|
96
|
+
<EdgeStoreProvider>
|
|
97
|
+
<Outlet />
|
|
98
|
+
</EdgeStoreProvider>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Usage
|
|
104
|
+
|
|
105
|
+
See [Quick start](https://next.edgestore.dev/docs/quick-start) for the upload UI.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
Source: https://next.edgestore.dev/docs/troubleshooting
|
|
4
|
+
|
|
5
|
+
## Ask your agent to debug it
|
|
6
|
+
|
|
7
|
+
Read <https://edgestore.dev/docs/troubleshooting.md> and inspect my existing
|
|
8
|
+
EdgeStore integration. Explain the cause before making changes.
|
|
9
|
+
|
|
10
|
+
Problem:
|
|
11
|
+
|
|
12
|
+
\[Describe the problem]
|
|
13
|
+
|
|
14
|
+
Include the error message and steps to reproduce it.
|
|
15
|
+
|
|
16
|
+
## Route not found or method not allowed
|
|
17
|
+
|
|
18
|
+
Open the handler's health endpoint. With the default Next.js route it is
|
|
19
|
+
<http://localhost:3000/api/edgestore/health>.
|
|
20
|
+
Use your backend origin and mounted path for other adapters.
|
|
21
|
+
|
|
22
|
+
For a 404 or 405, check the catch-all route and GET/POST exports. Match the React
|
|
23
|
+
provider's `basePath` to the mounted endpoint, including any proxy prefix.
|
|
24
|
+
|
|
25
|
+
## Credentials or access denied
|
|
26
|
+
|
|
27
|
+
Confirm the backend loads the expected env file before creating the storage
|
|
28
|
+
provider, and that the keys belong to the intended project.
|
|
29
|
+
|
|
30
|
+
For protected buckets, check the application's authentication context and access
|
|
31
|
+
rules.
|
|
32
|
+
|
|
33
|
+
## Browser upload failures
|
|
34
|
+
|
|
35
|
+
Check the browser console for errors and the failing request and response in the
|
|
36
|
+
Network panel, then use
|
|
37
|
+
[Error handling](https://next.edgestore.dev/docs/error-handling) to identify validation, size, or access
|
|
38
|
+
errors. Confirm that the React provider wraps the upload component.
|
|
39
|
+
|
|
40
|
+
For separate frontend and backend origins, allow the intended frontend origin in
|
|
41
|
+
CORS and check the adapter's cookie and deployment requirements.
|
|
42
|
+
|
|
43
|
+
## Enable server debug logging
|
|
44
|
+
|
|
45
|
+
Enable [debug logging](https://next.edgestore.dev/docs/logging) to inspect server-side failures. Debug output
|
|
46
|
+
includes application context and cookies. Remove those values before sharing logs.
|
|
47
|
+
|
|
48
|
+
## Inspect the application with the CLI
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
edgestore --cwd <app> agent context --json
|
|
52
|
+
edgestore --cwd <app> doctor --offline --json
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Use the backend directory for server checks in a split workspace. `agent context`
|
|
56
|
+
reports installed versions and local references. `doctor --offline` inspects
|
|
57
|
+
configuration without authenticating or running the application.
|
|
58
|
+
|
|
59
|
+
## Try an example app
|
|
60
|
+
|
|
61
|
+
Run an [example close to your framework](https://github.com/edgestorejs/edgestore/tree/main/examples)
|
|
62
|
+
to compare with your application.
|
|
63
|
+
|
|
64
|
+
For Next.js:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
npx degit edgestorejs/edgestore/examples/next-basic#main edgestore-example
|
|
68
|
+
cd edgestore-example
|
|
69
|
+
npm install
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Add your EdgeStore keys to `.env.local` as shown in
|
|
73
|
+
[Quick start](https://next.edgestore.dev/docs/quick-start#environment-variables), then run:
|
|
74
|
+
|
|
75
|
+
```sh
|
|
76
|
+
npm run dev
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Still blocked?
|
|
80
|
+
|
|
81
|
+
Ask in [Discord](https://discord.gg/HvrnhRTfgQ) or
|
|
82
|
+
[open an issue](https://github.com/edgestorejs/edgestore/issues) with your framework,
|
|
83
|
+
installed EdgeStore versions, and the error.
|
package/dist/adapters/shared.js
CHANGED
|
@@ -86,7 +86,7 @@ async function init(params) {
|
|
|
86
86
|
...resolvedCookieConfig.token.options
|
|
87
87
|
}));
|
|
88
88
|
}
|
|
89
|
-
const baseUrl = await getProviderBaseUrl(provider);
|
|
89
|
+
const baseUrl = initRes.baseUrl ?? await getProviderBaseUrl(provider);
|
|
90
90
|
logger.debug('Finished [init]', {
|
|
91
91
|
ctx,
|
|
92
92
|
newCookies,
|
|
@@ -72,14 +72,17 @@ export declare function edgestore(options?: EdgeStoreProviderOptions): {
|
|
|
72
72
|
};
|
|
73
73
|
readonly init: <TCtx extends import("@edgestore/shared").AnyContext>({ ctx, router }: import("@edgestore/shared").InitParams<TCtx>) => Promise<{
|
|
74
74
|
token?: undefined;
|
|
75
|
+
baseUrl?: undefined;
|
|
75
76
|
clientInit?: undefined;
|
|
76
77
|
} | {
|
|
77
78
|
token: string;
|
|
79
|
+
baseUrl: string;
|
|
78
80
|
clientInit: {
|
|
79
81
|
path: string;
|
|
80
82
|
headers: {
|
|
81
83
|
'x-edgestore-token': string;
|
|
82
84
|
};
|
|
85
|
+
urls?: string[] | undefined;
|
|
83
86
|
};
|
|
84
87
|
}>;
|
|
85
88
|
readonly uploads: {
|
|
@@ -96,7 +99,7 @@ export declare function edgestore(options?: EdgeStoreProviderOptions): {
|
|
|
96
99
|
}>;
|
|
97
100
|
readonly complete: ({ uploadId, parts }: import("@edgestore/shared").CompleteMultipartUploadParams) => Promise<void>;
|
|
98
101
|
};
|
|
99
|
-
readonly upload: ({ bucketName, fileInfo, autoSignedUrls, source, signal, onProgress, }: import("@edgestore/shared").BackendUploadParams) => Promise<{
|
|
102
|
+
readonly upload: ({ bucketName, bucketType, fileInfo, autoSignedUrls, source, signal, onProgress, }: import("@edgestore/shared").BackendUploadParams) => Promise<{
|
|
100
103
|
file: ProviderFile;
|
|
101
104
|
signedReadUrl: {
|
|
102
105
|
expiresAt: Date;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/edgestore/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB,KAAK,8BAA8B,GAAG;IACpC,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,+BAA+B,GAAG;IACrC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,GACnE,CAAC,+BAA+B,GAAG,8BAA8B,CAAC,CAAC;AAErE,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,wBAAwB
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/edgestore/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkBxB,KAAK,8BAA8B,GAAG;IACpC,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,+BAA+B,GAAG;IACrC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB,CAAC;AAEF,KAAK,8BAA8B,GAAG;IACpC,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,8BAA8B,GACnE,CAAC,+BAA+B,GAAG,8BAA8B,CAAC,CAAC;AAErE,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0GAgElD,OAAO,CAAC,gBAAgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4IlC;AAED,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC"}
|
|
@@ -35,7 +35,7 @@ function edgestore(options) {
|
|
|
35
35
|
init: async ({ ctx, router })=>{
|
|
36
36
|
const requiresFileAccessCookie = Object.values(router.buckets).some((bucket)=>bucket._def.accessControl !== undefined && bucket._def.accessControl !== 'private');
|
|
37
37
|
if (!requiresFileAccessCookie) return {};
|
|
38
|
-
const { token } = await runtime.accessTokens.create({
|
|
38
|
+
const { token, delivery } = await runtime.accessTokens.create({
|
|
39
39
|
context: Object.fromEntries(Object.entries(ctx).filter((entry)=>entry[1] !== undefined)),
|
|
40
40
|
buckets: Object.fromEntries(Object.entries(router.buckets).map(([bucketName, bucket])=>[
|
|
41
41
|
bucketName,
|
|
@@ -58,9 +58,14 @@ function edgestore(options) {
|
|
|
58
58
|
}
|
|
59
59
|
]))
|
|
60
60
|
});
|
|
61
|
+
const overrideBaseUrl = getEnv('EDGE_STORE_BASE_URL');
|
|
61
62
|
return {
|
|
62
63
|
token,
|
|
64
|
+
baseUrl: overrideBaseUrl ?? delivery?.baseUrl ?? baseUrl,
|
|
63
65
|
clientInit: {
|
|
66
|
+
...delivery && !overrideBaseUrl ? {
|
|
67
|
+
urls: delivery.initUrls
|
|
68
|
+
} : {},
|
|
64
69
|
path: '/_init',
|
|
65
70
|
headers: {
|
|
66
71
|
'x-edgestore-token': token
|
|
@@ -113,9 +118,13 @@ function edgestore(options) {
|
|
|
113
118
|
});
|
|
114
119
|
}
|
|
115
120
|
},
|
|
116
|
-
upload: async ({ bucketName, fileInfo, autoSignedUrls, source, signal, onProgress })=>{
|
|
121
|
+
upload: async ({ bucketName, bucketType, fileInfo, autoSignedUrls, source, signal, onProgress })=>{
|
|
117
122
|
const result = await runtime.uploads.upload({
|
|
118
123
|
bucket: bucketName,
|
|
124
|
+
bucketConfig: {
|
|
125
|
+
type: bucketType.toLowerCase(),
|
|
126
|
+
visibility: fileInfo.isPublic ? 'public' : 'protected'
|
|
127
|
+
},
|
|
119
128
|
source,
|
|
120
129
|
...mapHighLevelUploadOptions(fileInfo, autoSignedUrls),
|
|
121
130
|
signal,
|
package/dist/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgestore/server",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.4",
|
|
4
4
|
"description": "Upload files with ease from React/Next.js",
|
|
5
5
|
"homepage": "https://edgestore.dev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"src",
|
|
105
105
|
"README.md",
|
|
106
106
|
"LICENSE",
|
|
107
|
+
"agent-docs",
|
|
107
108
|
"package.json",
|
|
108
109
|
"adapters",
|
|
109
110
|
"core",
|
|
@@ -112,8 +113,8 @@
|
|
|
112
113
|
"!**/__tests__"
|
|
113
114
|
],
|
|
114
115
|
"dependencies": {
|
|
115
|
-
"@edgestore/sdk": "1.0.0-next.
|
|
116
|
-
"@edgestore/shared": "1.0.0-next.
|
|
116
|
+
"@edgestore/sdk": "1.0.0-next.4",
|
|
117
|
+
"@edgestore/shared": "1.0.0-next.4",
|
|
117
118
|
"@standard-schema/spec": "^1.1.0",
|
|
118
119
|
"@panva/hkdf": "^1.2.1",
|
|
119
120
|
"cookie": "^2.0.1",
|
|
@@ -155,7 +156,8 @@
|
|
|
155
156
|
},
|
|
156
157
|
"gitHead": "a223c4cb8df50e6b64f9db5dc2daf93848748da9",
|
|
157
158
|
"scripts": {
|
|
158
|
-
"build": "rollup --config rollup.config.ts --configPlugin rollup-plugin-swc3",
|
|
159
|
+
"build": "pnpm agent-docs:build && rollup --config rollup.config.ts --configPlugin rollup-plugin-swc3",
|
|
160
|
+
"agent-docs:build": "node --import tsx ../../scripts/agentDocs/build.ts server",
|
|
159
161
|
"dev": "pnpm build --watch",
|
|
160
162
|
"codegen:entrypoints": "tsx entrypoints.script.ts",
|
|
161
163
|
"test": "vitest run --config vitest.config.ts",
|
package/src/adapters/shared.ts
CHANGED
|
@@ -195,7 +195,7 @@ export async function init<TCtx extends AnyContext>(params: {
|
|
|
195
195
|
}),
|
|
196
196
|
);
|
|
197
197
|
}
|
|
198
|
-
const baseUrl = await getProviderBaseUrl(provider);
|
|
198
|
+
const baseUrl = initRes.baseUrl ?? (await getProviderBaseUrl(provider));
|
|
199
199
|
|
|
200
200
|
logger.debug('Finished [init]', {
|
|
201
201
|
ctx,
|
|
@@ -83,7 +83,7 @@ export function edgestore(options?: EdgeStoreProviderOptions) {
|
|
|
83
83
|
);
|
|
84
84
|
if (!requiresFileAccessCookie) return {};
|
|
85
85
|
|
|
86
|
-
const { token } = await runtime.accessTokens.create({
|
|
86
|
+
const { token, delivery } = await runtime.accessTokens.create({
|
|
87
87
|
context: Object.fromEntries(
|
|
88
88
|
Object.entries(ctx).filter(
|
|
89
89
|
(entry): entry is [string, string] => entry[1] !== undefined,
|
|
@@ -109,9 +109,12 @@ export function edgestore(options?: EdgeStoreProviderOptions) {
|
|
|
109
109
|
]),
|
|
110
110
|
),
|
|
111
111
|
});
|
|
112
|
+
const overrideBaseUrl = getEnv('EDGE_STORE_BASE_URL');
|
|
112
113
|
return {
|
|
113
114
|
token,
|
|
115
|
+
baseUrl: overrideBaseUrl ?? delivery?.baseUrl ?? baseUrl,
|
|
114
116
|
clientInit: {
|
|
117
|
+
...(delivery && !overrideBaseUrl ? { urls: delivery.initUrls } : {}),
|
|
115
118
|
path: '/_init',
|
|
116
119
|
headers: {
|
|
117
120
|
'x-edgestore-token': token,
|
|
@@ -176,6 +179,7 @@ export function edgestore(options?: EdgeStoreProviderOptions) {
|
|
|
176
179
|
},
|
|
177
180
|
upload: async ({
|
|
178
181
|
bucketName,
|
|
182
|
+
bucketType,
|
|
179
183
|
fileInfo,
|
|
180
184
|
autoSignedUrls,
|
|
181
185
|
source,
|
|
@@ -184,6 +188,10 @@ export function edgestore(options?: EdgeStoreProviderOptions) {
|
|
|
184
188
|
}) => {
|
|
185
189
|
const result = await runtime.uploads.upload({
|
|
186
190
|
bucket: bucketName,
|
|
191
|
+
bucketConfig: {
|
|
192
|
+
type: bucketType.toLowerCase() as 'file' | 'image',
|
|
193
|
+
visibility: fileInfo.isPublic ? 'public' : 'protected',
|
|
194
|
+
},
|
|
187
195
|
source,
|
|
188
196
|
...mapHighLevelUploadOptions(fileInfo, autoSignedUrls),
|
|
189
197
|
signal,
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const EDGE_STORE_PACKAGE_NAME = '@edgestore/server';
|
|
2
|
-
export const EDGE_STORE_PACKAGE_VERSION = '1.0.0-next.
|
|
2
|
+
export const EDGE_STORE_PACKAGE_VERSION = '1.0.0-next.4';
|