@edgestore/server 0.0.0-alpha.12 → 0.0.0-alpha.14
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/next/app/index.d.ts +4 -1
- package/dist/adapters/next/app/index.d.ts.map +1 -1
- package/dist/adapters/next/app/index.js +24 -4
- package/dist/adapters/next/app/index.mjs +24 -4
- package/dist/adapters/next/pages/index.d.ts +4 -1
- package/dist/adapters/next/pages/index.d.ts.map +1 -1
- package/dist/adapters/next/pages/index.js +18 -4
- package/dist/adapters/next/pages/index.mjs +18 -4
- package/dist/adapters/shared.d.ts +4 -3
- package/dist/adapters/shared.d.ts.map +1 -1
- package/dist/core/client/index.d.ts +19 -9
- package/dist/core/client/index.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +21 -3
- package/dist/core/index.mjs +22 -4
- package/dist/core/internals/bucketBuilder.d.ts +98 -29
- package/dist/core/internals/bucketBuilder.d.ts.map +1 -1
- package/dist/core/sdk/index.d.ts +4 -4
- package/dist/core/sdk/index.d.ts.map +1 -1
- package/dist/{index-3cc4d530.js → index-0a168903.js} +4 -2
- package/dist/{index-ca41982b.mjs → index-579b8015.mjs} +4 -2
- package/dist/{index-3999aae6.js → index-62d969e5.js} +4 -2
- package/dist/index.js +18 -9
- package/dist/index.mjs +18 -9
- package/dist/providers/edgestore/index.d.ts +0 -1
- package/dist/providers/edgestore/index.d.ts.map +1 -1
- package/dist/providers/edgestore/index.js +4 -3
- package/dist/providers/edgestore/index.mjs +4 -3
- package/dist/providers/types.d.ts +2 -4
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/{shared-43667670.mjs → shared-2a9c8307.mjs} +34 -3
- package/dist/{shared-f7607e44.js → shared-ae739a04.js} +34 -3
- package/dist/{shared-6bef8919.js → shared-fac1b0a0.js} +35 -3
- package/package.json +7 -5
- package/src/adapters/next/app/index.ts +37 -6
- package/src/adapters/next/pages/index.ts +33 -6
- package/src/adapters/shared.ts +41 -9
- package/src/core/client/index.ts +50 -17
- package/src/core/index.ts +1 -0
- package/src/core/internals/bucketBuilder.ts +129 -41
- package/src/core/sdk/index.ts +8 -6
- package/src/providers/edgestore/index.ts +3 -4
- package/src/providers/types.ts +6 -4
|
@@ -3,23 +3,26 @@ import { KeysOfUnion, MaybePromise, Simplify } from '../../types';
|
|
|
3
3
|
type Merge<TType, TWith> = {
|
|
4
4
|
[TKey in keyof TType | keyof TWith]?: TKey extends keyof TType ? TKey extends keyof TWith ? TType[TKey] & TWith[TKey] : TType[TKey] : TWith[TKey & keyof TWith];
|
|
5
5
|
};
|
|
6
|
-
type OverwriteIfDefined<TType, TWith> = UnsetMarker extends TType ? TWith : Simplify<TType & TWith>;
|
|
7
6
|
type ConvertStringToFunction<TType> = {
|
|
8
7
|
[K in keyof TType]: TType[K] extends object ? Simplify<ConvertStringToFunction<TType[K]>> : () => string;
|
|
9
8
|
};
|
|
10
9
|
type UnionToIntersection<TType> = (TType extends any ? (k: TType) => void : never) extends (k: infer I) => void ? I : never;
|
|
11
10
|
export type InferBucketPathKeys<TBucket extends Builder<any, AnyDef>> = KeysOfUnion<TBucket['_def']['path'][number]>;
|
|
12
11
|
type InferBucketPathKeysFromDef<TDef extends AnyDef> = KeysOfUnion<TDef['path'][number]>;
|
|
13
|
-
export type
|
|
14
|
-
|
|
12
|
+
export type InferBucketPathObject<TBucket extends Builder<any, AnyDef>> = InferBucketPathKeys<TBucket> extends never ? Record<string, never> : {
|
|
13
|
+
[TKey in InferBucketPathKeys<TBucket>]: string;
|
|
14
|
+
};
|
|
15
|
+
export type InferBucketPathObjectFromDef<TDef extends AnyDef> = InferBucketPathKeysFromDef<TDef> extends never ? Record<string, never> : {
|
|
16
|
+
[TKey in InferBucketPathKeysFromDef<TDef>]: string;
|
|
17
|
+
};
|
|
18
|
+
export type InferMetadataObject<TBucket extends Builder<any, AnyDef>> = TBucket['_def']['metadata'] extends (...args: any) => any ? Awaited<ReturnType<TBucket['_def']['metadata']>> : Record<string, never>;
|
|
19
|
+
type InferMetadataObjectFromDef<TDef extends AnyDef> = TDef['metadata'] extends (...args: any) => any ? Awaited<ReturnType<TDef['metadata']>> : Record<string, never>;
|
|
15
20
|
export type AnyContext = Record<string, string | undefined | null>;
|
|
16
|
-
export type AnyInput = z.AnyZodObject;
|
|
21
|
+
export type AnyInput = z.AnyZodObject | z.ZodNever;
|
|
17
22
|
export type AnyPath = Record<string, () => string>[];
|
|
18
23
|
type PathParam<TPath extends AnyPath> = {
|
|
19
24
|
path: keyof UnionToIntersection<TPath[number]>;
|
|
20
25
|
};
|
|
21
|
-
declare const unsetMarker: unique symbol;
|
|
22
|
-
type UnsetMarker = typeof unsetMarker;
|
|
23
26
|
type Conditions<TPath extends AnyPath> = {
|
|
24
27
|
eq?: string | PathParam<TPath>;
|
|
25
28
|
lt?: string | PathParam<TPath>;
|
|
@@ -37,10 +40,29 @@ export type AccessControlSchema<TCtx, TDef extends AnyDef> = Merge<{
|
|
|
37
40
|
AND?: AccessControlSchema<TCtx, TDef>[];
|
|
38
41
|
NOT?: AccessControlSchema<TCtx, TDef>[];
|
|
39
42
|
}>;
|
|
43
|
+
type BucketConfig = {
|
|
44
|
+
/**
|
|
45
|
+
* Maximum size for a single file in bytes
|
|
46
|
+
*
|
|
47
|
+
* e.g. 1024 * 1024 * 10 = 10MB
|
|
48
|
+
*/
|
|
49
|
+
maxSize?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Accepted MIME types
|
|
52
|
+
*
|
|
53
|
+
* e.g. ['image/jpeg', 'image/png']
|
|
54
|
+
*
|
|
55
|
+
* You can also use wildcards after the slash:
|
|
56
|
+
*
|
|
57
|
+
* e.g. ['image/*']
|
|
58
|
+
*/
|
|
59
|
+
accept?: string[];
|
|
60
|
+
};
|
|
40
61
|
type FileInfo = {
|
|
41
62
|
size: number;
|
|
42
63
|
type: string;
|
|
43
64
|
extension: string;
|
|
65
|
+
fileName?: string;
|
|
44
66
|
replaceTargetUrl?: string;
|
|
45
67
|
};
|
|
46
68
|
type BeforeUploadFn<TCtx, TDef extends AnyDef> = (params: {
|
|
@@ -50,31 +72,32 @@ type BeforeUploadFn<TCtx, TDef extends AnyDef> = (params: {
|
|
|
50
72
|
}) => MaybePromise<boolean>;
|
|
51
73
|
type BeforeDeleteFn<TCtx, TDef extends AnyDef> = (params: {
|
|
52
74
|
ctx: TCtx;
|
|
53
|
-
|
|
75
|
+
fileInfo: {
|
|
54
76
|
url: string;
|
|
55
77
|
size: number;
|
|
56
78
|
uploadedAt: Date;
|
|
57
|
-
path:
|
|
58
|
-
[TKey in InferBucketPathKeysFromDef<TDef>]: string;
|
|
59
|
-
};
|
|
79
|
+
path: InferBucketPathObjectFromDef<TDef>;
|
|
60
80
|
metadata: InferMetadataObjectFromDef<TDef>;
|
|
61
81
|
};
|
|
62
82
|
}) => MaybePromise<boolean>;
|
|
63
|
-
type AnyMetadata = Record<string, string | undefined | null>;
|
|
64
|
-
type MetadataFn<TCtx,
|
|
83
|
+
export type AnyMetadata = Record<string, string | undefined | null>;
|
|
84
|
+
type MetadataFn<TCtx, TInput extends AnyInput, TMetadata extends AnyMetadata> = (params: {
|
|
65
85
|
ctx: TCtx;
|
|
66
|
-
input: z.infer<
|
|
86
|
+
input: z.infer<TInput>;
|
|
67
87
|
}) => MaybePromise<TMetadata>;
|
|
68
|
-
type
|
|
69
|
-
|
|
88
|
+
export type AnyMetadataFn = MetadataFn<any, AnyInput, AnyMetadata>;
|
|
89
|
+
type BucketType = 'IMAGE' | 'FILE';
|
|
90
|
+
type Def<TInput extends AnyInput, TPath extends AnyPath, TMetadata extends AnyMetadataFn> = {
|
|
91
|
+
type: BucketType;
|
|
70
92
|
input: TInput;
|
|
71
93
|
path: TPath;
|
|
72
|
-
metadata
|
|
94
|
+
metadata: TMetadata;
|
|
95
|
+
bucketConfig?: BucketConfig;
|
|
73
96
|
accessControl?: AccessControlSchema<any, any>;
|
|
74
97
|
beforeUpload?: BeforeUploadFn<any, any>;
|
|
75
98
|
beforeDelete?: BeforeDeleteFn<any, any>;
|
|
76
99
|
};
|
|
77
|
-
type AnyDef = Def<
|
|
100
|
+
type AnyDef = Def<AnyInput, AnyPath, AnyMetadataFn>;
|
|
78
101
|
type Builder<TCtx, TDef extends AnyDef> = {
|
|
79
102
|
/** only used for types */
|
|
80
103
|
$config: {
|
|
@@ -84,15 +107,33 @@ type Builder<TCtx, TDef extends AnyDef> = {
|
|
|
84
107
|
* @internal
|
|
85
108
|
*/
|
|
86
109
|
_def: TDef;
|
|
110
|
+
/**
|
|
111
|
+
* You can set an input that will be required in every upload from the client.
|
|
112
|
+
*
|
|
113
|
+
* This can be used to add additional information to the file, like choose the file path or add metadata.
|
|
114
|
+
*/
|
|
87
115
|
input<TInput extends AnyInput>(input: TInput): Builder<TCtx, {
|
|
88
116
|
type: TDef['type'];
|
|
89
|
-
input:
|
|
117
|
+
input: TInput;
|
|
90
118
|
path: TDef['path'];
|
|
91
119
|
metadata: TDef['metadata'];
|
|
120
|
+
bucketConfig: TDef['bucketConfig'];
|
|
92
121
|
accessControl: TDef['accessControl'];
|
|
93
122
|
beforeUpload: TDef['beforeUpload'];
|
|
94
123
|
beforeDelete: TDef['beforeDelete'];
|
|
95
124
|
}>;
|
|
125
|
+
/**
|
|
126
|
+
* The `path` is similar to folders in a file system.
|
|
127
|
+
* But in this case, every segment of the path must have a meaning.
|
|
128
|
+
*
|
|
129
|
+
* ```
|
|
130
|
+
* // e.g. 123/profile/file.jpg
|
|
131
|
+
* {
|
|
132
|
+
* author: '123',
|
|
133
|
+
* type: 'profile',
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
96
137
|
path<TParams extends AnyPath>(pathResolver: (params: {
|
|
97
138
|
ctx: Simplify<ConvertStringToFunction<TCtx>>;
|
|
98
139
|
input: Simplify<ConvertStringToFunction<z.infer<TDef['input']>>>;
|
|
@@ -101,59 +142,86 @@ type Builder<TCtx, TDef extends AnyDef> = {
|
|
|
101
142
|
input: TDef['input'];
|
|
102
143
|
path: TParams;
|
|
103
144
|
metadata: TDef['metadata'];
|
|
145
|
+
bucketConfig: TDef['bucketConfig'];
|
|
104
146
|
accessControl: TDef['accessControl'];
|
|
105
147
|
beforeUpload: TDef['beforeUpload'];
|
|
106
148
|
beforeDelete: TDef['beforeDelete'];
|
|
107
149
|
}>;
|
|
108
|
-
|
|
150
|
+
/**
|
|
151
|
+
* This metadata will be added to every file uploaded to this bucket.
|
|
152
|
+
*
|
|
153
|
+
* This can be used, for example, to filter files.
|
|
154
|
+
*/
|
|
155
|
+
metadata<TMetadata extends AnyMetadata>(metadata: MetadataFn<TCtx, TDef['input'], TMetadata>): Builder<TCtx, {
|
|
109
156
|
type: TDef['type'];
|
|
110
157
|
input: TDef['input'];
|
|
111
158
|
path: TDef['path'];
|
|
112
159
|
metadata: MetadataFn<any, any, TMetadata>;
|
|
160
|
+
bucketConfig: TDef['bucketConfig'];
|
|
113
161
|
accessControl: TDef['accessControl'];
|
|
114
162
|
beforeUpload: TDef['beforeUpload'];
|
|
115
163
|
beforeDelete: TDef['beforeDelete'];
|
|
116
164
|
}>;
|
|
165
|
+
/**
|
|
166
|
+
* If you set this, your bucket will automatically be configured as a protected bucket.
|
|
167
|
+
*
|
|
168
|
+
* This means that images will only be accessible from within your app.
|
|
169
|
+
* And only if it passes the check set in this function.
|
|
170
|
+
*/
|
|
117
171
|
accessControl(accessControl: AccessControlSchema<TCtx, TDef>): Builder<TCtx, {
|
|
118
172
|
type: TDef['type'];
|
|
119
173
|
input: TDef['input'];
|
|
120
174
|
path: TDef['path'];
|
|
121
175
|
metadata: TDef['metadata'];
|
|
176
|
+
bucketConfig: TDef['bucketConfig'];
|
|
122
177
|
accessControl: AccessControlSchema<any, any>;
|
|
123
178
|
beforeUpload: TDef['beforeUpload'];
|
|
124
179
|
beforeDelete: TDef['beforeDelete'];
|
|
125
180
|
}>;
|
|
181
|
+
/**
|
|
182
|
+
* return `true` to allow upload
|
|
183
|
+
*
|
|
184
|
+
* By default every upload from your app is allowed.
|
|
185
|
+
*/
|
|
126
186
|
beforeUpload(beforeUpload: BeforeUploadFn<TCtx, TDef>): Builder<TCtx, {
|
|
127
187
|
type: TDef['type'];
|
|
128
188
|
input: TDef['input'];
|
|
129
189
|
path: TDef['path'];
|
|
130
190
|
metadata: TDef['metadata'];
|
|
191
|
+
bucketConfig: TDef['bucketConfig'];
|
|
131
192
|
accessControl: TDef['accessControl'];
|
|
132
193
|
beforeUpload: BeforeUploadFn<any, any>;
|
|
133
194
|
beforeDelete: TDef['beforeDelete'];
|
|
134
195
|
}>;
|
|
196
|
+
/**
|
|
197
|
+
* return `true` to allow delete
|
|
198
|
+
*
|
|
199
|
+
* This function must be defined if you want to delete files directly from the client.
|
|
200
|
+
*/
|
|
135
201
|
beforeDelete(beforeDelete: BeforeDeleteFn<TCtx, TDef>): Builder<TCtx, {
|
|
136
202
|
type: TDef['type'];
|
|
137
203
|
input: TDef['input'];
|
|
138
204
|
path: TDef['path'];
|
|
139
205
|
metadata: TDef['metadata'];
|
|
206
|
+
bucketConfig: TDef['bucketConfig'];
|
|
140
207
|
accessControl: TDef['accessControl'];
|
|
141
208
|
beforeUpload: TDef['beforeUpload'];
|
|
142
209
|
beforeDelete: BeforeDeleteFn<any, any>;
|
|
143
210
|
}>;
|
|
144
211
|
};
|
|
145
212
|
export type AnyBuilder = Builder<any, AnyDef>;
|
|
146
|
-
declare class EdgeStoreBuilder<TCtx =
|
|
213
|
+
declare class EdgeStoreBuilder<TCtx = Record<string, never>> {
|
|
147
214
|
context<TNewContext extends AnyContext>(): EdgeStoreBuilder<TNewContext>;
|
|
148
215
|
create(): {
|
|
149
216
|
/**
|
|
150
217
|
* Builder object for creating an image bucket
|
|
151
218
|
*/
|
|
152
|
-
imageBucket: Builder<TCtx, {
|
|
219
|
+
imageBucket(config?: BucketConfig | undefined): Builder<TCtx, {
|
|
153
220
|
type: "IMAGE";
|
|
154
|
-
input:
|
|
155
|
-
path:
|
|
156
|
-
metadata
|
|
221
|
+
input: z.ZodNever;
|
|
222
|
+
path: [];
|
|
223
|
+
metadata: () => Record<string, never>;
|
|
224
|
+
bucketConfig?: BucketConfig | undefined;
|
|
157
225
|
accessControl?: AccessControlSchema<any, any> | undefined;
|
|
158
226
|
beforeUpload?: BeforeUploadFn<any, any> | undefined;
|
|
159
227
|
beforeDelete?: BeforeDeleteFn<any, any> | undefined;
|
|
@@ -161,11 +229,12 @@ declare class EdgeStoreBuilder<TCtx = object> {
|
|
|
161
229
|
/**
|
|
162
230
|
* Builder object for creating a file bucket
|
|
163
231
|
*/
|
|
164
|
-
fileBucket: Builder<TCtx, {
|
|
232
|
+
fileBucket(config?: BucketConfig | undefined): Builder<TCtx, {
|
|
165
233
|
type: "FILE";
|
|
166
|
-
input:
|
|
167
|
-
path:
|
|
168
|
-
metadata
|
|
234
|
+
input: z.ZodNever;
|
|
235
|
+
path: [];
|
|
236
|
+
metadata: () => Record<string, never>;
|
|
237
|
+
bucketConfig?: BucketConfig | undefined;
|
|
169
238
|
accessControl?: AccessControlSchema<any, any> | undefined;
|
|
170
239
|
beforeUpload?: BeforeUploadFn<any, any> | undefined;
|
|
171
240
|
beforeDelete?: BeforeDeleteFn<any, any> | undefined;
|
|
@@ -194,6 +263,6 @@ export type EdgeStoreRouter<TCtx> = {
|
|
|
194
263
|
/**
|
|
195
264
|
* Initialize EdgeStore - be done exactly once per backend
|
|
196
265
|
*/
|
|
197
|
-
export declare const initEdgeStore: EdgeStoreBuilder<
|
|
266
|
+
export declare const initEdgeStore: EdgeStoreBuilder<Record<string, never>>;
|
|
198
267
|
export {};
|
|
199
268
|
//# sourceMappingURL=bucketBuilder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bucketBuilder.d.ts","sourceRoot":"","sources":["../../../src/core/internals/bucketBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACx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AAC,CAAC;AAyF9C,cAAM,gBAAgB,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IACjD,OAAO,CAAC,WAAW,SAAS,UAAU;IAItC,MAAM;QAuCF;;WAEG;;;;;;;;;;;QAIH;;WAEG;;;;;;;;;;;QAIH;;WAEG;;;;;;;;CAlDR;AAED,MAAM,MAAM,eAAe,CAAC,IAAI,IAAI;IAClC;;;OAGG;IACH,OAAO,EAAE;QACP,GAAG,EAAE,IAAI,CAAC;KACX,CAAC;IACF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD,CAAC;AA6CF;;GAEG;AACH,eAAO,MAAM,aAAa,yCAAyB,CAAC"}
|
package/dist/core/sdk/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { AnyRouter } from '..';
|
|
2
|
-
import { AnyContext } from '../internals/bucketBuilder';
|
|
2
|
+
import { AnyContext, AnyMetadata } from '../internals/bucketBuilder';
|
|
3
3
|
type FileInfoForUpload = {
|
|
4
4
|
size: number;
|
|
5
5
|
extension: string;
|
|
6
|
+
type?: string;
|
|
6
7
|
isPublic: boolean;
|
|
7
8
|
path: {
|
|
8
9
|
key: string;
|
|
9
10
|
value: string;
|
|
10
11
|
}[];
|
|
11
|
-
metadata
|
|
12
|
-
|
|
13
|
-
};
|
|
12
|
+
metadata: AnyMetadata;
|
|
13
|
+
fileName?: string;
|
|
14
14
|
replaceTargetUrl?: string;
|
|
15
15
|
};
|
|
16
16
|
export type SimpleOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'startsWith' | 'endsWith';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAE/B,OAAO,EAAE,UAA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AAE;oBACS;YACV,WAAW,EAAE,MAAM,CAAC;YACpB,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE,MAAM,CAAC;YACnB,UAAU,EAAE,MAAM,CAAC;SACpB;;CAYN,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;qBAW0B;QAAE,GAAG,EAAE,UAAU,CAAC;QAAC,MAAM,EAAE,SAAS,CAAA;KAAE;;aAQ/B,MAAM;;;;;;;;;oBAatB,MAAM;oBACN,MAAM;kBACR,iBAAiB;;mBAElB,MAAM,EAAE;;;;;;;;;;;;;;aAgBZ,MAAM;mBACA;YACT,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,KAAK,EAAE,MAAM,EAAE,CAAC;SACjB;;;;;;;;;;;aAS8B,MAAM;;;;sBAOf;QACtB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,eAAe,CAAC;QACzB,UAAU,CAAC,EAAE,UAAU,CAAC;KACzB;;;;;;;;;;;;;;;;EAQJ;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -8,7 +8,7 @@ class EdgeStoreCredentialsError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const API_ENDPOINT = process.env.EDGE_STORE_API_ENDPOINT ?? 'https://api.
|
|
11
|
+
const API_ENDPOINT = process.env.EDGE_STORE_API_ENDPOINT ?? 'https://api.edgestore.dev';
|
|
12
12
|
async function makeRequest(params) {
|
|
13
13
|
const { body, accessKey, secretKey, path } = params;
|
|
14
14
|
const res = await fetch(`${API_ENDPOINT}${path}`, {
|
|
@@ -20,7 +20,7 @@ async function makeRequest(params) {
|
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
if (!res.ok) {
|
|
23
|
-
throw new Error(`Failed to make request to ${path}`);
|
|
23
|
+
throw new Error(`Failed to make request to ${path}: ${await res.text()}`);
|
|
24
24
|
}
|
|
25
25
|
return (await res.json());
|
|
26
26
|
}
|
|
@@ -77,7 +77,9 @@ const edgeStoreRawSdk = {
|
|
|
77
77
|
path: fileInfo.path,
|
|
78
78
|
extension: fileInfo.extension,
|
|
79
79
|
size: fileInfo.size,
|
|
80
|
+
mimeType: fileInfo.type,
|
|
80
81
|
metadata: fileInfo.metadata,
|
|
82
|
+
fileName: fileInfo.fileName,
|
|
81
83
|
replaceTargetUrl: fileInfo.replaceTargetUrl,
|
|
82
84
|
},
|
|
83
85
|
});
|
|
@@ -8,7 +8,7 @@ class EdgeStoreCredentialsError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const API_ENDPOINT = process.env.EDGE_STORE_API_ENDPOINT ?? 'https://api.
|
|
11
|
+
const API_ENDPOINT = process.env.EDGE_STORE_API_ENDPOINT ?? 'https://api.edgestore.dev';
|
|
12
12
|
async function makeRequest(params) {
|
|
13
13
|
const { body, accessKey, secretKey, path } = params;
|
|
14
14
|
const res = await fetch(`${API_ENDPOINT}${path}`, {
|
|
@@ -20,7 +20,7 @@ async function makeRequest(params) {
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
if (!res.ok) {
|
|
23
|
-
throw new Error(`Failed to make request to ${path}`);
|
|
23
|
+
throw new Error(`Failed to make request to ${path}: ${await res.text()}`);
|
|
24
24
|
}
|
|
25
25
|
return await res.json();
|
|
26
26
|
}
|
|
@@ -77,7 +77,9 @@ const edgeStoreRawSdk = {
|
|
|
77
77
|
path: fileInfo.path,
|
|
78
78
|
extension: fileInfo.extension,
|
|
79
79
|
size: fileInfo.size,
|
|
80
|
+
mimeType: fileInfo.type,
|
|
80
81
|
metadata: fileInfo.metadata,
|
|
82
|
+
fileName: fileInfo.fileName,
|
|
81
83
|
replaceTargetUrl: fileInfo.replaceTargetUrl
|
|
82
84
|
}
|
|
83
85
|
});
|
|
@@ -10,7 +10,7 @@ class EdgeStoreCredentialsError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const API_ENDPOINT = process.env.EDGE_STORE_API_ENDPOINT ?? 'https://api.
|
|
13
|
+
const API_ENDPOINT = process.env.EDGE_STORE_API_ENDPOINT ?? 'https://api.edgestore.dev';
|
|
14
14
|
async function makeRequest(params) {
|
|
15
15
|
const { body, accessKey, secretKey, path } = params;
|
|
16
16
|
const res = await fetch(`${API_ENDPOINT}${path}`, {
|
|
@@ -22,7 +22,7 @@ async function makeRequest(params) {
|
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
if (!res.ok) {
|
|
25
|
-
throw new Error(`Failed to make request to ${path}`);
|
|
25
|
+
throw new Error(`Failed to make request to ${path}: ${await res.text()}`);
|
|
26
26
|
}
|
|
27
27
|
return await res.json();
|
|
28
28
|
}
|
|
@@ -79,7 +79,9 @@ const edgeStoreRawSdk = {
|
|
|
79
79
|
path: fileInfo.path,
|
|
80
80
|
extension: fileInfo.extension,
|
|
81
81
|
size: fileInfo.size,
|
|
82
|
+
mimeType: fileInfo.type,
|
|
82
83
|
metadata: fileInfo.metadata,
|
|
84
|
+
fileName: fileInfo.fileName,
|
|
83
85
|
replaceTargetUrl: fileInfo.replaceTargetUrl
|
|
84
86
|
}
|
|
85
87
|
});
|
package/dist/index.js
CHANGED
|
@@ -46,12 +46,14 @@ function createBuilder(opts, initDef) {
|
|
|
46
46
|
type: opts.type,
|
|
47
47
|
input: zod.z.never(),
|
|
48
48
|
path: [],
|
|
49
|
+
metadata: ()=>({}),
|
|
49
50
|
...initDef
|
|
50
51
|
};
|
|
51
52
|
return {
|
|
52
53
|
$config: {
|
|
53
54
|
ctx: undefined
|
|
54
55
|
},
|
|
56
|
+
// @ts-expect-error - I think it would be too much work to make this type correct.
|
|
55
57
|
_def,
|
|
56
58
|
input (input) {
|
|
57
59
|
return createNewBuilder(_def, {
|
|
@@ -108,19 +110,26 @@ function createRouterFactory() {
|
|
|
108
110
|
};
|
|
109
111
|
};
|
|
110
112
|
}
|
|
113
|
+
function initBucket(type, config) {
|
|
114
|
+
return createBuilder({
|
|
115
|
+
type
|
|
116
|
+
}, {
|
|
117
|
+
bucketConfig: config
|
|
118
|
+
});
|
|
119
|
+
}
|
|
111
120
|
function createEdgeStoreInner() {
|
|
112
121
|
return function initEdgeStoreInner() {
|
|
113
122
|
return {
|
|
114
123
|
/**
|
|
115
124
|
* Builder object for creating an image bucket
|
|
116
|
-
*/ imageBucket
|
|
117
|
-
|
|
118
|
-
}
|
|
125
|
+
*/ imageBucket (config) {
|
|
126
|
+
return initBucket('IMAGE', config);
|
|
127
|
+
},
|
|
119
128
|
/**
|
|
120
129
|
* Builder object for creating a file bucket
|
|
121
|
-
*/ fileBucket
|
|
122
|
-
|
|
123
|
-
}
|
|
130
|
+
*/ fileBucket (config) {
|
|
131
|
+
return initBucket('FILE', config);
|
|
132
|
+
},
|
|
124
133
|
/**
|
|
125
134
|
* Create a router
|
|
126
135
|
*/ router: createRouterFactory()
|
|
@@ -135,7 +144,7 @@ function createEdgeStoreInner() {
|
|
|
135
144
|
// userRole: 'admin' | 'visitor';
|
|
136
145
|
// };
|
|
137
146
|
// const es = initEdgeStore.context<Context>().create();
|
|
138
|
-
// const imagesBucket = es.imageBucket
|
|
147
|
+
// const imagesBucket = es.imageBucket()
|
|
139
148
|
// .input(
|
|
140
149
|
// z.object({
|
|
141
150
|
// type: z.enum(['profile', 'post']),
|
|
@@ -150,7 +159,7 @@ function createEdgeStoreInner() {
|
|
|
150
159
|
// .beforeUpload(() => {
|
|
151
160
|
// return true;
|
|
152
161
|
// });
|
|
153
|
-
// const a = es.imageBucket
|
|
162
|
+
// const a = es.imageBucket()
|
|
154
163
|
// .input(z.object({ type: z.string(), someMeta: z.string().optional() }))
|
|
155
164
|
// .path(({ ctx, input }) => [{ author: ctx.userId }, { type: input.type }])
|
|
156
165
|
// .metadata(({ ctx, input }) => ({
|
|
@@ -173,7 +182,7 @@ function createEdgeStoreInner() {
|
|
|
173
182
|
// .beforeDelete(({ ctx, file }) => {
|
|
174
183
|
// return true;
|
|
175
184
|
// });
|
|
176
|
-
// const b = es.imageBucket.path(({ ctx }) => [{ author: ctx.userId }]);
|
|
185
|
+
// const b = es.imageBucket().path(({ ctx }) => [{ author: ctx.userId }]);
|
|
177
186
|
// const router = es.router({
|
|
178
187
|
// original: imagesBucket,
|
|
179
188
|
// imageBucket: a,
|
package/dist/index.mjs
CHANGED
|
@@ -42,12 +42,14 @@ function createBuilder(opts, initDef) {
|
|
|
42
42
|
type: opts.type,
|
|
43
43
|
input: z.never(),
|
|
44
44
|
path: [],
|
|
45
|
+
metadata: ()=>({}),
|
|
45
46
|
...initDef
|
|
46
47
|
};
|
|
47
48
|
return {
|
|
48
49
|
$config: {
|
|
49
50
|
ctx: undefined
|
|
50
51
|
},
|
|
52
|
+
// @ts-expect-error - I think it would be too much work to make this type correct.
|
|
51
53
|
_def,
|
|
52
54
|
input (input) {
|
|
53
55
|
return createNewBuilder(_def, {
|
|
@@ -104,19 +106,26 @@ function createRouterFactory() {
|
|
|
104
106
|
};
|
|
105
107
|
};
|
|
106
108
|
}
|
|
109
|
+
function initBucket(type, config) {
|
|
110
|
+
return createBuilder({
|
|
111
|
+
type
|
|
112
|
+
}, {
|
|
113
|
+
bucketConfig: config
|
|
114
|
+
});
|
|
115
|
+
}
|
|
107
116
|
function createEdgeStoreInner() {
|
|
108
117
|
return function initEdgeStoreInner() {
|
|
109
118
|
return {
|
|
110
119
|
/**
|
|
111
120
|
* Builder object for creating an image bucket
|
|
112
|
-
*/ imageBucket
|
|
113
|
-
|
|
114
|
-
}
|
|
121
|
+
*/ imageBucket (config) {
|
|
122
|
+
return initBucket('IMAGE', config);
|
|
123
|
+
},
|
|
115
124
|
/**
|
|
116
125
|
* Builder object for creating a file bucket
|
|
117
|
-
*/ fileBucket
|
|
118
|
-
|
|
119
|
-
}
|
|
126
|
+
*/ fileBucket (config) {
|
|
127
|
+
return initBucket('FILE', config);
|
|
128
|
+
},
|
|
120
129
|
/**
|
|
121
130
|
* Create a router
|
|
122
131
|
*/ router: createRouterFactory()
|
|
@@ -131,7 +140,7 @@ function createEdgeStoreInner() {
|
|
|
131
140
|
// userRole: 'admin' | 'visitor';
|
|
132
141
|
// };
|
|
133
142
|
// const es = initEdgeStore.context<Context>().create();
|
|
134
|
-
// const imagesBucket = es.imageBucket
|
|
143
|
+
// const imagesBucket = es.imageBucket()
|
|
135
144
|
// .input(
|
|
136
145
|
// z.object({
|
|
137
146
|
// type: z.enum(['profile', 'post']),
|
|
@@ -146,7 +155,7 @@ function createEdgeStoreInner() {
|
|
|
146
155
|
// .beforeUpload(() => {
|
|
147
156
|
// return true;
|
|
148
157
|
// });
|
|
149
|
-
// const a = es.imageBucket
|
|
158
|
+
// const a = es.imageBucket()
|
|
150
159
|
// .input(z.object({ type: z.string(), someMeta: z.string().optional() }))
|
|
151
160
|
// .path(({ ctx, input }) => [{ author: ctx.userId }, { type: input.type }])
|
|
152
161
|
// .metadata(({ ctx, input }) => ({
|
|
@@ -169,7 +178,7 @@ function createEdgeStoreInner() {
|
|
|
169
178
|
// .beforeDelete(({ ctx, file }) => {
|
|
170
179
|
// return true;
|
|
171
180
|
// });
|
|
172
|
-
// const b = es.imageBucket.path(({ ctx }) => [{ author: ctx.userId }]);
|
|
181
|
+
// const b = es.imageBucket().path(({ ctx }) => [{ author: ctx.userId }]);
|
|
173
182
|
// const router = es.router({
|
|
174
183
|
// original: imagesBucket,
|
|
175
184
|
// imageBucket: a,
|
|
@@ -2,7 +2,6 @@ import { Provider } from '../types';
|
|
|
2
2
|
export type EdgeStoreProviderOptions = {
|
|
3
3
|
accessKey?: string;
|
|
4
4
|
secretKey?: string;
|
|
5
|
-
baseUrl?: string;
|
|
6
5
|
};
|
|
7
6
|
export declare function EdgeStoreProvider(options?: EdgeStoreProviderOptions): Provider;
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/edgestore/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAoB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/edgestore/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAoB,MAAM,UAAU,CAAC;AAItD,MAAM,MAAM,wBAAwB,GAAG;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,iBAAiB,CAC/B,OAAO,CAAC,EAAE,wBAAwB,GACjC,QAAQ,CA6HV"}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('../../index-
|
|
5
|
+
var index = require('../../index-62d969e5.js');
|
|
6
6
|
|
|
7
|
-
const DEFAULT_BASE_URL =
|
|
7
|
+
const DEFAULT_BASE_URL = 'https://files.edgestore.dev';
|
|
8
8
|
function EdgeStoreProvider(options) {
|
|
9
|
-
const { accessKey = process.env.EDGE_STORE_ACCESS_KEY, secretKey = process.env.EDGE_STORE_SECRET_KEY
|
|
9
|
+
const { accessKey = process.env.EDGE_STORE_ACCESS_KEY, secretKey = process.env.EDGE_STORE_SECRET_KEY } = options ?? {};
|
|
10
|
+
const baseUrl = process.env.EDGE_STORE_BASE_URL ?? DEFAULT_BASE_URL;
|
|
10
11
|
if (!accessKey || !secretKey) {
|
|
11
12
|
throw new index.EdgeStoreCredentialsError();
|
|
12
13
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { E as EdgeStoreCredentialsError, i as initEdgeStoreSdk } from '../../index-
|
|
1
|
+
import { E as EdgeStoreCredentialsError, i as initEdgeStoreSdk } from '../../index-579b8015.mjs';
|
|
2
2
|
|
|
3
|
-
const DEFAULT_BASE_URL =
|
|
3
|
+
const DEFAULT_BASE_URL = 'https://files.edgestore.dev';
|
|
4
4
|
function EdgeStoreProvider(options) {
|
|
5
|
-
const { accessKey = process.env.EDGE_STORE_ACCESS_KEY, secretKey = process.env.EDGE_STORE_SECRET_KEY
|
|
5
|
+
const { accessKey = process.env.EDGE_STORE_ACCESS_KEY, secretKey = process.env.EDGE_STORE_SECRET_KEY } = options ?? {};
|
|
6
|
+
const baseUrl = process.env.EDGE_STORE_BASE_URL ?? DEFAULT_BASE_URL;
|
|
6
7
|
if (!accessKey || !secretKey) {
|
|
7
8
|
throw new EdgeStoreCredentialsError();
|
|
8
9
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyBuilder, EdgeStoreRouter } from '../core/internals/bucketBuilder';
|
|
1
|
+
import { AnyBuilder, AnyMetadata, EdgeStoreRouter } from '../core/internals/bucketBuilder';
|
|
2
2
|
import { MaybePromise } from '../types';
|
|
3
3
|
export type InitParams = {
|
|
4
4
|
ctx: any;
|
|
@@ -36,9 +36,7 @@ export type RequestUploadParams = {
|
|
|
36
36
|
key: string;
|
|
37
37
|
value: string;
|
|
38
38
|
}[];
|
|
39
|
-
metadata
|
|
40
|
-
[key: string]: string;
|
|
41
|
-
};
|
|
39
|
+
metadata: AnyMetadata;
|
|
42
40
|
replaceTargetUrl?: string;
|
|
43
41
|
};
|
|
44
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,WAAW,EACX,eAAe,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM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