@edgestore/server 0.1.5-alpha.13 → 0.1.5-alpha.15

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 (80) hide show
  1. package/dist/adapters/express/index.d.ts +1 -3
  2. package/dist/adapters/express/index.d.ts.map +1 -1
  3. package/dist/adapters/express/index.js +13 -12
  4. package/dist/adapters/express/index.mjs +3 -2
  5. package/dist/adapters/next/app/index.d.ts +1 -3
  6. package/dist/adapters/next/app/index.d.ts.map +1 -1
  7. package/dist/adapters/next/app/index.js +14 -13
  8. package/dist/adapters/next/app/index.mjs +3 -2
  9. package/dist/adapters/next/pages/index.d.ts +1 -3
  10. package/dist/adapters/next/pages/index.d.ts.map +1 -1
  11. package/dist/adapters/next/pages/index.js +14 -13
  12. package/dist/adapters/next/pages/index.mjs +3 -2
  13. package/dist/adapters/shared.d.ts +7 -43
  14. package/dist/adapters/shared.d.ts.map +1 -1
  15. package/dist/core/client/index.d.ts +2 -3
  16. package/dist/core/client/index.d.ts.map +1 -1
  17. package/dist/core/index.d.ts +0 -5
  18. package/dist/core/index.d.ts.map +1 -1
  19. package/dist/core/index.js +3 -13
  20. package/dist/core/index.mjs +5 -14
  21. package/dist/core/sdk/index.d.ts +1 -2
  22. package/dist/core/sdk/index.d.ts.map +1 -1
  23. package/dist/{index-23d1ede9.mjs → index-28efdacf.mjs} +2 -37
  24. package/dist/{index-a2e7ca9e.js → index-4491caf0.js} +2 -39
  25. package/dist/{index-0c401ce1.js → index-beed799d.js} +2 -32
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +5 -215
  29. package/dist/index.mjs +1 -218
  30. package/dist/providers/aws/index.d.ts +1 -1
  31. package/dist/providers/aws/index.d.ts.map +1 -1
  32. package/dist/providers/azure/index.d.ts +1 -1
  33. package/dist/providers/azure/index.d.ts.map +1 -1
  34. package/dist/providers/edgestore/index.d.ts +1 -1
  35. package/dist/providers/edgestore/index.d.ts.map +1 -1
  36. package/dist/providers/edgestore/index.js +4 -4
  37. package/dist/providers/edgestore/index.mjs +2 -2
  38. package/dist/{shared-d7ea66fb.mjs → shared-039276af.mjs} +1 -1
  39. package/dist/{shared-06cb0d86.js → shared-7c700083.js} +20 -20
  40. package/dist/{shared-d474acc6.js → shared-83f288f6.js} +1 -1
  41. package/package.json +5 -13
  42. package/src/adapters/express/index.ts +7 -6
  43. package/src/adapters/next/app/index.ts +7 -6
  44. package/src/adapters/next/pages/index.ts +7 -6
  45. package/src/adapters/shared.ts +14 -17
  46. package/src/core/client/index.ts +7 -5
  47. package/src/core/index.ts +0 -15
  48. package/src/core/sdk/index.ts +6 -3
  49. package/src/index.ts +1 -1
  50. package/src/providers/aws/index.ts +1 -1
  51. package/src/providers/azure/index.ts +1 -1
  52. package/src/providers/edgestore/index.ts +5 -2
  53. package/dist/adapters/index.d.ts +0 -2
  54. package/dist/adapters/index.d.ts.map +0 -1
  55. package/dist/adapters/index.js +0 -2
  56. package/dist/adapters/index.mjs +0 -1
  57. package/dist/core/internals/bucketBuilder.d.ts +0 -269
  58. package/dist/core/internals/bucketBuilder.d.ts.map +0 -1
  59. package/dist/core/internals/createPathParamProxy.d.ts +0 -21
  60. package/dist/core/internals/createPathParamProxy.d.ts.map +0 -1
  61. package/dist/libs/errors/EdgeStoreApiClientError.d.ts +0 -8
  62. package/dist/libs/errors/EdgeStoreApiClientError.d.ts.map +0 -1
  63. package/dist/libs/errors/EdgeStoreError.d.ts +0 -48
  64. package/dist/libs/errors/EdgeStoreError.d.ts.map +0 -1
  65. package/dist/providers/index.d.ts +0 -2
  66. package/dist/providers/index.d.ts.map +0 -1
  67. package/dist/providers/index.js +0 -2
  68. package/dist/providers/index.mjs +0 -1
  69. package/dist/providers/types.d.ts +0 -114
  70. package/dist/providers/types.d.ts.map +0 -1
  71. package/dist/types.d.ts +0 -94
  72. package/dist/types.d.ts.map +0 -1
  73. package/src/adapters/index.ts +0 -6
  74. package/src/core/internals/bucketBuilder.ts +0 -555
  75. package/src/core/internals/createPathParamProxy.ts +0 -40
  76. package/src/libs/errors/EdgeStoreApiClientError.ts +0 -14
  77. package/src/libs/errors/EdgeStoreError.ts +0 -92
  78. package/src/providers/index.ts +0 -1
  79. package/src/providers/types.ts +0 -140
  80. package/src/types.ts +0 -148
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,IAAI,CAAC;AAGpC,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAK/E,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE;QACJ,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,QAAQ,EAAE,WAAW,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,cAAc,GACtB,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,KAAK,GACL,YAAY,GACZ,UAAU,CAAC;AAEf,MAAM,MAAM,UAAU,CAAC,KAAK,GAAG,MAAM,IACjC,KAAK,GACL,OAAO,CACL;KACG,CAAC,IAAI,cAAc,GAAG,KAAK;CAC7B,GAAG;IACF,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CACzB,CACF,CAAC;AAEN,KAAK,eAAe,GAAG;IACrB,GAAG,CAAC,EAAE,eAAe,EAAE,CAAC;IACxB,EAAE,CAAC,EAAE,eAAe,EAA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{ _ } from '@swc/helpers/_/_define_property';
2
-
3
- /* eslint-disable @typescript-eslint/no-non-null-assertion */ const EDGE_STORE_ERROR_CODES = {
4
- BAD_REQUEST: 400,
5
- FILE_TOO_LARGE: 400,
6
- MIME_TYPE_NOT_ALLOWED: 400,
7
- UNAUTHORIZED: 401,
8
- UPLOAD_NOT_ALLOWED: 403,
9
- DELETE_NOT_ALLOWED: 403,
10
- CREATE_CONTEXT_ERROR: 500,
11
- SERVER_ERROR: 500
12
- };
13
- class EdgeStoreError extends Error {
14
- formattedMessage() {
15
- return `${this.message}${this.details ? `\n Details: ${JSON.stringify(this.details)}` : ''}${this.cause ? `\n Caused by: ${this.cause.message}` : ''}`;
16
- }
17
- formattedJson() {
18
- return {
19
- message: this.code === 'SERVER_ERROR' ? 'Internal server error' : this.message,
20
- code: this.code,
21
- details: this.details
22
- };
23
- }
24
- constructor(opts){
25
- super(opts.message);
26
- _(this, "cause", void 0);
27
- _(this, "code", void 0);
28
- _(this, "level", void 0);
29
- _(this, "details", void 0);
30
- this.name = 'EdgeStoreError';
31
- this.code = opts.code;
32
- this.cause = opts.cause;
33
- this.level = EDGE_STORE_ERROR_CODES[opts.code] >= 500 ? 'error' : 'warn';
34
- this.details = 'details' in opts ? opts.details : undefined;
35
- }
36
- }
1
+ import { EdgeStoreError } from '@edgestore/shared';
37
2
 
38
3
  const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
39
4
  This can happen if you are trying to import something related to the backend of Edge Store in a client component.`;
@@ -262,4 +227,4 @@ function initEdgeStoreSdk(params) {
262
227
  };
263
228
  }
264
229
 
265
- export { EdgeStoreError as E, EDGE_STORE_ERROR_CODES as a, EdgeStoreCredentialsError as b, edgeStoreRawSdk as e, initEdgeStoreSdk as i };
230
+ export { EdgeStoreCredentialsError as E, edgeStoreRawSdk as e, initEdgeStoreSdk as i };
@@ -1,41 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var _define_property = require('@swc/helpers/_/_define_property');
4
-
5
- /* eslint-disable @typescript-eslint/no-non-null-assertion */ const EDGE_STORE_ERROR_CODES = {
6
- BAD_REQUEST: 400,
7
- FILE_TOO_LARGE: 400,
8
- MIME_TYPE_NOT_ALLOWED: 400,
9
- UNAUTHORIZED: 401,
10
- UPLOAD_NOT_ALLOWED: 403,
11
- DELETE_NOT_ALLOWED: 403,
12
- CREATE_CONTEXT_ERROR: 500,
13
- SERVER_ERROR: 500
14
- };
15
- class EdgeStoreError extends Error {
16
- formattedMessage() {
17
- return `${this.message}${this.details ? `\n Details: ${JSON.stringify(this.details)}` : ''}${this.cause ? `\n Caused by: ${this.cause.message}` : ''}`;
18
- }
19
- formattedJson() {
20
- return {
21
- message: this.code === 'SERVER_ERROR' ? 'Internal server error' : this.message,
22
- code: this.code,
23
- details: this.details
24
- };
25
- }
26
- constructor(opts){
27
- super(opts.message);
28
- _define_property._(this, "cause", void 0);
29
- _define_property._(this, "code", void 0);
30
- _define_property._(this, "level", void 0);
31
- _define_property._(this, "details", void 0);
32
- this.name = 'EdgeStoreError';
33
- this.code = opts.code;
34
- this.cause = opts.cause;
35
- this.level = EDGE_STORE_ERROR_CODES[opts.code] >= 500 ? 'error' : 'warn';
36
- this.details = 'details' in opts ? opts.details : undefined;
37
- }
38
- }
3
+ var shared = require('@edgestore/shared');
39
4
 
40
5
  const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
41
6
  This can happen if you are trying to import something related to the backend of Edge Store in a client component.`;
@@ -69,7 +34,7 @@ const edgeStoreRawSdk = {
69
34
  path: bucket._def.path.map((p)=>{
70
35
  const paramEntries = Object.entries(p);
71
36
  if (paramEntries[0] === undefined) {
72
- throw new EdgeStoreError({
37
+ throw new shared.EdgeStoreError({
73
38
  message: `Empty path param found in: ${JSON.stringify(bucket._def.path)}`,
74
39
  code: 'SERVER_ERROR'
75
40
  });
@@ -264,8 +229,6 @@ function initEdgeStoreSdk(params) {
264
229
  };
265
230
  }
266
231
 
267
- exports.EDGE_STORE_ERROR_CODES = EDGE_STORE_ERROR_CODES;
268
232
  exports.EdgeStoreCredentialsError = EdgeStoreCredentialsError;
269
- exports.EdgeStoreError = EdgeStoreError;
270
233
  exports.edgeStoreRawSdk = edgeStoreRawSdk;
271
234
  exports.initEdgeStoreSdk = initEdgeStoreSdk;
@@ -1,34 +1,4 @@
1
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
- const EDGE_STORE_ERROR_CODES = {
3
- BAD_REQUEST: 400,
4
- FILE_TOO_LARGE: 400,
5
- MIME_TYPE_NOT_ALLOWED: 400,
6
- UNAUTHORIZED: 401,
7
- UPLOAD_NOT_ALLOWED: 403,
8
- DELETE_NOT_ALLOWED: 403,
9
- CREATE_CONTEXT_ERROR: 500,
10
- SERVER_ERROR: 500,
11
- };
12
- class EdgeStoreError extends Error {
13
- constructor(opts) {
14
- super(opts.message);
15
- this.name = 'EdgeStoreError';
16
- this.code = opts.code;
17
- this.cause = opts.cause;
18
- this.level = EDGE_STORE_ERROR_CODES[opts.code] >= 500 ? 'error' : 'warn';
19
- this.details = 'details' in opts ? opts.details : undefined;
20
- }
21
- formattedMessage() {
22
- return `${this.message}${this.details ? `\n Details: ${JSON.stringify(this.details)}` : ''}${this.cause ? `\n Caused by: ${this.cause.message}` : ''}`;
23
- }
24
- formattedJson() {
25
- return {
26
- message: this.code === 'SERVER_ERROR' ? 'Internal server error' : this.message,
27
- code: this.code,
28
- details: this.details,
29
- };
30
- }
31
- }
1
+ import { EdgeStoreError } from '@edgestore/shared';
32
2
 
33
3
  const DEFAULT_MESSAGE = `Missing EDGE_STORE_ACCESS_KEY or EDGE_STORE_SECRET_KEY.
34
4
  This can happen if you are trying to import something related to the backend of Edge Store in a client component.`;
@@ -257,4 +227,4 @@ function initEdgeStoreSdk(params) {
257
227
  };
258
228
  }
259
229
 
260
- export { EdgeStoreError as E, EDGE_STORE_ERROR_CODES as a, EdgeStoreCredentialsError as b, edgeStoreRawSdk as e, initEdgeStoreSdk as i };
230
+ export { EdgeStoreCredentialsError as E, edgeStoreRawSdk as e, initEdgeStoreSdk as i };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { initEdgeStore } from './core/internals/bucketBuilder';
1
+ export { initEdgeStore } from '@edgestore/shared';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -2,221 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var zod = require('zod');
5
+ var shared = require('@edgestore/shared');
6
6
 
7
- /**
8
- * Creates a Proxy that prints the path to the property when called.
9
- *
10
- * Example:
11
- *
12
- * ```ts
13
- * const pathParamProxy = createPathParamProxy();
14
- * console.log(pathParamProxy.ctx.user.id());
15
- * // Logs: "ctx.user.id"
16
- * console.log(pathParamProxy.input.type());
17
- * // Logs: "input.type"
18
- * ```
19
- */ function createPathParamProxy() {
20
- const getPath = (target, _prop)=>{
21
- const proxyFunction = ()=>target;
22
- return new Proxy(proxyFunction, {
23
- get: (_target, propChild)=>{
24
- return getPath(`${target}.${String(propChild)}`);
25
- }
26
- });
27
- };
28
- return new Proxy(()=>'', {
29
- get: (_target, prop)=>{
30
- return getPath(String(prop));
31
- }
32
- });
33
- }
34
7
 
35
- const createNewBuilder = (initDef, newDef)=>{
36
- const mergedDef = {
37
- ...initDef,
38
- ...newDef
39
- };
40
- return createBuilder({
41
- type: mergedDef.type
42
- }, mergedDef);
43
- };
44
- function createBuilder(opts, initDef) {
45
- const _def = {
46
- type: opts.type,
47
- input: zod.z.never(),
48
- path: [],
49
- metadata: ()=>({}),
50
- ...initDef
51
- };
52
- return {
53
- $config: {
54
- ctx: undefined
55
- },
56
- // @ts-expect-error - I think it would be too much work to make this type correct.
57
- _def,
58
- input (input) {
59
- return createNewBuilder(_def, {
60
- input
61
- });
62
- },
63
- path (pathResolver) {
64
- // TODO: Should throw a runtime error in the followin cases:
65
- // 1. in case of multiple keys in one object
66
- // 2. in case of duplicate keys
67
- const pathParamProxy = createPathParamProxy();
68
- const params = pathResolver(pathParamProxy);
69
- return createNewBuilder(_def, {
70
- path: params
71
- });
72
- },
73
- metadata (metadata) {
74
- return createNewBuilder(_def, {
75
- metadata
76
- });
77
- },
78
- accessControl (accessControl) {
79
- return createNewBuilder(_def, {
80
- accessControl: accessControl
81
- });
82
- },
83
- beforeUpload (beforeUpload) {
84
- return createNewBuilder(_def, {
85
- beforeUpload
86
- });
87
- },
88
- beforeDelete (beforeDelete) {
89
- return createNewBuilder(_def, {
90
- beforeDelete
91
- });
92
- }
93
- };
94
- }
95
- class EdgeStoreBuilder {
96
- context() {
97
- return new EdgeStoreBuilder();
98
- }
99
- create() {
100
- return createEdgeStoreInner()();
101
- }
102
- }
103
- function createRouterFactory() {
104
- return function createRouterInner(buckets) {
105
- return {
106
- $config: {
107
- ctx: undefined
108
- },
109
- buckets
110
- };
111
- };
112
- }
113
- function initBucket(type, config) {
114
- return createBuilder({
115
- type
116
- }, {
117
- bucketConfig: config
118
- });
119
- }
120
- function createEdgeStoreInner() {
121
- return function initEdgeStoreInner() {
122
- return {
123
- /**
124
- * Builder object for creating an image bucket
125
- */ imageBucket (config) {
126
- return initBucket('IMAGE', config);
127
- },
128
- /**
129
- * Builder object for creating a file bucket
130
- */ fileBucket (config) {
131
- return initBucket('FILE', config);
132
- },
133
- /**
134
- * Create a router
135
- */ router: createRouterFactory()
136
- };
137
- };
138
- }
139
- /**
140
- * Initialize EdgeStore - be done exactly once per backend
141
- */ const initEdgeStore = new EdgeStoreBuilder(); // ↓↓↓ TYPE TESTS ↓↓↓
142
- // type Context = {
143
- // userId: string;
144
- // userRole: 'admin' | 'visitor';
145
- // };
146
- // const es = initEdgeStore.context<Context>().create();
147
- // const imagesBucket = es.imageBucket()
148
- // .input(
149
- // z.object({
150
- // type: z.enum(['profile', 'post']),
151
- // extension: z.string().optional(),
152
- // }),
153
- // )
154
- // .path(({ ctx, input }) => [{ author: ctx.userId }, { type: input.type }])
155
- // .metadata(({ ctx, input }) => ({
156
- // extension: input.extension,
157
- // role: ctx.userRole,
158
- // }))
159
- // .beforeUpload(() => {
160
- // return true;
161
- // });
162
- // const a = es.imageBucket()
163
- // .input(z.object({ type: z.string(), someMeta: z.string().optional() }))
164
- // .path(({ ctx, input }) => [{ author: ctx.userId }, { type: input.type }])
165
- // .metadata(({ ctx, input }) => ({
166
- // role: ctx.userRole,
167
- // someMeta: input.someMeta,
168
- // }))
169
- // .accessControl({
170
- // OR: [
171
- // {
172
- // userId: { path: 'author' }, // this will check if the userId is the same as the author in the path parameter
173
- // },
174
- // {
175
- // userRole: 'admin', // this is the same as { userRole: { eq: "admin" } }
176
- // },
177
- // ],
178
- // })
179
- // .beforeUpload(({ ctx, input }) => {
180
- // return true;
181
- // })
182
- // .beforeDelete(({ ctx, file }) => {
183
- // return true;
184
- // });
185
- // const b = es.imageBucket().path(({ ctx }) => [{ author: ctx.userId }]);
186
- // const router = es.router({
187
- // original: imagesBucket,
188
- // imageBucket: a,
189
- // imageBucket2: b,
190
- // });
191
- // export { router };
192
- // type ListFilesResponse<TBucket extends AnyRouter['buckets'][string]> = {
193
- // data: {
194
- // // url: string;
195
- // // size: number;
196
- // // uploadedAt: Date;
197
- // // metadata: InferMetadataObject<TBucket>;
198
- // path: InferBucketPathKeys<TBucket> extends string ? {
199
- // [key: string]: string;
200
- // } :{
201
- // [TKey in InferBucketPathKeys<TBucket>]: string;
202
- // };
203
- // }[];
204
- // pagination: {
205
- // currentPage: number;
206
- // totalPages: number;
207
- // totalCount: number;
208
- // };
209
- // };
210
- // type TPathKeys = 'author' | 'type';
211
- // type TPathKeys2 = InferBucketPathKeys<AnyBuilder>;
212
- // type ObjectWithKeys<TKeys extends string> = {
213
- // [TKey in TKeys]: string;
214
- // };
215
- // type Test1 = ObjectWithKeys<TPathKeys>;
216
- // type Test2 = ObjectWithKeys<TPathKeys2>;
217
- // type PathKeys = InferBucketPathKeys<typeof router.buckets.imageBucket>;
218
- // type MetadataKeys = InferMetadataObject<typeof router.buckets.imageBucket>;
219
- // type MyEdgeStoreRouter = typeof router;
220
- // type MyAccessControl = AccessControlSchema<Context, AnyDef>;
221
8
 
222
- exports.initEdgeStore = initEdgeStore;
9
+ Object.defineProperty(exports, 'initEdgeStore', {
10
+ enumerable: true,
11
+ get: function () { return shared.initEdgeStore; }
12
+ });
package/dist/index.mjs CHANGED
@@ -1,218 +1 @@
1
- import { z } from 'zod';
2
-
3
- /**
4
- * Creates a Proxy that prints the path to the property when called.
5
- *
6
- * Example:
7
- *
8
- * ```ts
9
- * const pathParamProxy = createPathParamProxy();
10
- * console.log(pathParamProxy.ctx.user.id());
11
- * // Logs: "ctx.user.id"
12
- * console.log(pathParamProxy.input.type());
13
- * // Logs: "input.type"
14
- * ```
15
- */ function createPathParamProxy() {
16
- const getPath = (target, _prop)=>{
17
- const proxyFunction = ()=>target;
18
- return new Proxy(proxyFunction, {
19
- get: (_target, propChild)=>{
20
- return getPath(`${target}.${String(propChild)}`);
21
- }
22
- });
23
- };
24
- return new Proxy(()=>'', {
25
- get: (_target, prop)=>{
26
- return getPath(String(prop));
27
- }
28
- });
29
- }
30
-
31
- const createNewBuilder = (initDef, newDef)=>{
32
- const mergedDef = {
33
- ...initDef,
34
- ...newDef
35
- };
36
- return createBuilder({
37
- type: mergedDef.type
38
- }, mergedDef);
39
- };
40
- function createBuilder(opts, initDef) {
41
- const _def = {
42
- type: opts.type,
43
- input: z.never(),
44
- path: [],
45
- metadata: ()=>({}),
46
- ...initDef
47
- };
48
- return {
49
- $config: {
50
- ctx: undefined
51
- },
52
- // @ts-expect-error - I think it would be too much work to make this type correct.
53
- _def,
54
- input (input) {
55
- return createNewBuilder(_def, {
56
- input
57
- });
58
- },
59
- path (pathResolver) {
60
- // TODO: Should throw a runtime error in the followin cases:
61
- // 1. in case of multiple keys in one object
62
- // 2. in case of duplicate keys
63
- const pathParamProxy = createPathParamProxy();
64
- const params = pathResolver(pathParamProxy);
65
- return createNewBuilder(_def, {
66
- path: params
67
- });
68
- },
69
- metadata (metadata) {
70
- return createNewBuilder(_def, {
71
- metadata
72
- });
73
- },
74
- accessControl (accessControl) {
75
- return createNewBuilder(_def, {
76
- accessControl: accessControl
77
- });
78
- },
79
- beforeUpload (beforeUpload) {
80
- return createNewBuilder(_def, {
81
- beforeUpload
82
- });
83
- },
84
- beforeDelete (beforeDelete) {
85
- return createNewBuilder(_def, {
86
- beforeDelete
87
- });
88
- }
89
- };
90
- }
91
- class EdgeStoreBuilder {
92
- context() {
93
- return new EdgeStoreBuilder();
94
- }
95
- create() {
96
- return createEdgeStoreInner()();
97
- }
98
- }
99
- function createRouterFactory() {
100
- return function createRouterInner(buckets) {
101
- return {
102
- $config: {
103
- ctx: undefined
104
- },
105
- buckets
106
- };
107
- };
108
- }
109
- function initBucket(type, config) {
110
- return createBuilder({
111
- type
112
- }, {
113
- bucketConfig: config
114
- });
115
- }
116
- function createEdgeStoreInner() {
117
- return function initEdgeStoreInner() {
118
- return {
119
- /**
120
- * Builder object for creating an image bucket
121
- */ imageBucket (config) {
122
- return initBucket('IMAGE', config);
123
- },
124
- /**
125
- * Builder object for creating a file bucket
126
- */ fileBucket (config) {
127
- return initBucket('FILE', config);
128
- },
129
- /**
130
- * Create a router
131
- */ router: createRouterFactory()
132
- };
133
- };
134
- }
135
- /**
136
- * Initialize EdgeStore - be done exactly once per backend
137
- */ const initEdgeStore = new EdgeStoreBuilder(); // ↓↓↓ TYPE TESTS ↓↓↓
138
- // type Context = {
139
- // userId: string;
140
- // userRole: 'admin' | 'visitor';
141
- // };
142
- // const es = initEdgeStore.context<Context>().create();
143
- // const imagesBucket = es.imageBucket()
144
- // .input(
145
- // z.object({
146
- // type: z.enum(['profile', 'post']),
147
- // extension: z.string().optional(),
148
- // }),
149
- // )
150
- // .path(({ ctx, input }) => [{ author: ctx.userId }, { type: input.type }])
151
- // .metadata(({ ctx, input }) => ({
152
- // extension: input.extension,
153
- // role: ctx.userRole,
154
- // }))
155
- // .beforeUpload(() => {
156
- // return true;
157
- // });
158
- // const a = es.imageBucket()
159
- // .input(z.object({ type: z.string(), someMeta: z.string().optional() }))
160
- // .path(({ ctx, input }) => [{ author: ctx.userId }, { type: input.type }])
161
- // .metadata(({ ctx, input }) => ({
162
- // role: ctx.userRole,
163
- // someMeta: input.someMeta,
164
- // }))
165
- // .accessControl({
166
- // OR: [
167
- // {
168
- // userId: { path: 'author' }, // this will check if the userId is the same as the author in the path parameter
169
- // },
170
- // {
171
- // userRole: 'admin', // this is the same as { userRole: { eq: "admin" } }
172
- // },
173
- // ],
174
- // })
175
- // .beforeUpload(({ ctx, input }) => {
176
- // return true;
177
- // })
178
- // .beforeDelete(({ ctx, file }) => {
179
- // return true;
180
- // });
181
- // const b = es.imageBucket().path(({ ctx }) => [{ author: ctx.userId }]);
182
- // const router = es.router({
183
- // original: imagesBucket,
184
- // imageBucket: a,
185
- // imageBucket2: b,
186
- // });
187
- // export { router };
188
- // type ListFilesResponse<TBucket extends AnyRouter['buckets'][string]> = {
189
- // data: {
190
- // // url: string;
191
- // // size: number;
192
- // // uploadedAt: Date;
193
- // // metadata: InferMetadataObject<TBucket>;
194
- // path: InferBucketPathKeys<TBucket> extends string ? {
195
- // [key: string]: string;
196
- // } :{
197
- // [TKey in InferBucketPathKeys<TBucket>]: string;
198
- // };
199
- // }[];
200
- // pagination: {
201
- // currentPage: number;
202
- // totalPages: number;
203
- // totalCount: number;
204
- // };
205
- // };
206
- // type TPathKeys = 'author' | 'type';
207
- // type TPathKeys2 = InferBucketPathKeys<AnyBuilder>;
208
- // type ObjectWithKeys<TKeys extends string> = {
209
- // [TKey in TKeys]: string;
210
- // };
211
- // type Test1 = ObjectWithKeys<TPathKeys>;
212
- // type Test2 = ObjectWithKeys<TPathKeys2>;
213
- // type PathKeys = InferBucketPathKeys<typeof router.buckets.imageBucket>;
214
- // type MetadataKeys = InferMetadataObject<typeof router.buckets.imageBucket>;
215
- // type MyEdgeStoreRouter = typeof router;
216
- // type MyAccessControl = AccessControlSchema<Context, AnyDef>;
217
-
218
- export { initEdgeStore };
1
+ export { initEdgeStore } from '@edgestore/shared';
@@ -1,4 +1,4 @@
1
- import { type Provider } from '../types';
1
+ import { type Provider } from '@edgestore/shared';
2
2
  export type AWSProviderOptions = {
3
3
  /**
4
4
  * Access key for AWS credentials.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/aws/index.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,QAAQ,CAqGlE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/aws/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,QAAQ,CAqGlE"}
@@ -1,4 +1,4 @@
1
- import { type Provider } from '../types';
1
+ import { type Provider } from '@edgestore/shared';
2
2
  export type AzureProviderOptions = {
3
3
  /**
4
4
  * The storage account name for Azure Blob Storage
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/azure/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,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;CACxB,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,QAAQ,CAkEtE"}
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;AAGlD,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;CACxB,CAAC;AAEF,wBAAgB,aAAa,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,QAAQ,CAkEtE"}
@@ -1,4 +1,4 @@
1
- import { type Provider } from '../types';
1
+ import { type Provider } from '@edgestore/shared';
2
2
  export type EdgeStoreProviderOptions = {
3
3
  /**
4
4
  * Access key for your EdgeStore project.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/edgestore/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,QAAQ,EAAyB,MAAM,UAAU,CAAC;AAIhE,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,CAgJV"}
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;AAM3B,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,CAgJV"}