@edgestore/shared 1.0.0-next.0 → 1.0.0-next.2
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/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/internals/bucketBuilder.d.ts +46 -23
- package/dist/internals/bucketBuilder.d.ts.map +1 -1
- package/dist/internals/bucketBuilder.js +4 -3
- package/dist/internals/providerCapabilities.d.ts +44 -0
- package/dist/internals/providerCapabilities.d.ts.map +1 -0
- package/dist/internals/providerTypes.d.ts +178 -56
- package/dist/internals/providerTypes.d.ts.map +1 -1
- package/dist/internals/schema.d.ts +11 -0
- package/dist/internals/schema.d.ts.map +1 -0
- package/dist/internals/schema.js +36 -0
- package/dist/internals/sharedFuncTypes.d.ts +14 -4
- package/dist/internals/sharedFuncTypes.d.ts.map +1 -1
- package/dist/internals/types.d.ts +1 -1
- package/package.json +7 -8
- package/src/index.ts +7 -0
- package/src/internals/bucketBuilder.ts +85 -28
- package/src/internals/providerCapabilities.ts +126 -0
- package/src/internals/providerTypes.ts +290 -83
- package/src/internals/schema.ts +88 -0
- package/src/internals/sharedFuncTypes.ts +16 -4
- package/src/internals/types.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providerTypes.d.ts","sourceRoot":"","sources":["../../src/internals/providerTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACrB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG;
|
|
1
|
+
{"version":3,"file":"providerTypes.d.ts","sourceRoot":"","sources":["../../src/internals/providerTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,KAAK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MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAI,EAAE,CAAC,IAAI,SAAS,UAAU,EAC5B,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,KACrB,YAAY,CAAC,OAAO,CAAC,CAAC;IAC3B,SAAS,EAAE,2BAA2B,CAAC,gBAAgB,CAAC,CAAC;IACzD,OAAO,EAAE,QAAQ,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAClD,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,EAC1B,GAAG,EACH,eAAe,EACf,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CACxB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CACtD,gBAAgB,CAAC,OAAO,EAAE,aAAa,CAAC,EACxC,MAAM,CACP,GAAG;IACF,OAAO,EAAE,eAAe,CAAC,sBAAsB,CAAC,GAAG;QACjD,MAAM,EAAE,sBAAsB,CAAC;KAChC,CAAC;IACF,KAAK,EAAE,aAAa,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG;QAC5C,GAAG,EAAE,uBAAuB,CAAC;QAC7B,IAAI,EAAE,yBAAyB,CAAC;QAChC,OAAO,EAAE,4BAA4B,CAAC;QACtC,MAAM,EAAE,4BAA4B,CAAC;QACrC,OAAO,EAAE,4BAA4B,CAAC;QACtC,aAAa,EAAE,6BAA6B,CAAC;KAC9C,CAAC;CACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
export type AnySchema = StandardSchemaV1<any, Record<string, unknown>>;
|
|
3
|
+
/** @internal */
|
|
4
|
+
export type AnyInput = AnySchema | undefined;
|
|
5
|
+
export type InferSchemaInput<TSchema extends AnyInput> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TSchema> : never;
|
|
6
|
+
export type InferSchemaOutput<TSchema extends AnyInput> = TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : never;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare function assertStandardSchema(schema: unknown): asserts schema is AnySchema;
|
|
9
|
+
/** @internal */
|
|
10
|
+
export declare function parseBucketInput<TSchema extends AnyInput>(schema: TSchema, input: unknown): Promise<TSchema extends undefined ? Record<string, never> : InferSchemaOutput<TSchema>>;
|
|
11
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/internals/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,MAAM,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAEvE,gBAAgB;AAChB,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAE7C,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,QAAQ,IACnD,OAAO,SAAS,gBAAgB,GAC5B,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,GACpC,KAAK,CAAC;AAEZ,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,QAAQ,IACpD,OAAO,SAAS,gBAAgB,GAC5B,gBAAgB,CAAC,WAAW,CAAC,OAAO,CAAC,GACrC,KAAK,CAAC;AAYZ,gBAAgB;AAChB,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,GACd,OAAO,CAAC,MAAM,IAAI,SAAS,CAmB7B;AAED,gBAAgB;AAChB,wBAAsB,gBAAgB,CAAC,OAAO,SAAS,QAAQ,EAC7D,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,OAAO,GACb,OAAO,CACR,OAAO,SAAS,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAC/E,CA6BA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { EdgeStoreError } from '../errors/EdgeStoreError.js';
|
|
2
|
+
|
|
3
|
+
function formatIssue(issue) {
|
|
4
|
+
const path = issue.path?.map((segment)=>typeof segment === 'object' ? String(segment.key) : String(segment)).join('.');
|
|
5
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
6
|
+
}
|
|
7
|
+
/** @internal */ function assertStandardSchema(schema) {
|
|
8
|
+
const protocol = typeof schema === 'object' && schema !== null && '~standard' in schema ? schema['~standard'] : undefined;
|
|
9
|
+
if (typeof protocol !== 'object' || protocol === null || !('version' in protocol) || protocol.version !== 1 || !('validate' in protocol) || typeof protocol.validate !== 'function') {
|
|
10
|
+
throw new EdgeStoreError({
|
|
11
|
+
code: 'SERVER_ERROR',
|
|
12
|
+
message: 'Bucket input schemas must implement Standard Schema V1'
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** @internal */ async function parseBucketInput(schema, input) {
|
|
17
|
+
if (schema === undefined) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
const result = await schema['~standard'].validate(input);
|
|
21
|
+
if (result.issues !== undefined) {
|
|
22
|
+
throw new EdgeStoreError({
|
|
23
|
+
code: 'BAD_REQUEST',
|
|
24
|
+
message: `Invalid input: ${result.issues.map(formatIssue).join('; ')}`
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (typeof result.value !== 'object' || result.value === null || Array.isArray(result.value)) {
|
|
28
|
+
throw new EdgeStoreError({
|
|
29
|
+
code: 'SERVER_ERROR',
|
|
30
|
+
message: 'Bucket input schemas must return an object'
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return result.value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { assertStandardSchema, parseBucketInput };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { type Simplify } from '../types.js';
|
|
2
2
|
import { type AnyMetadata } from './bucketBuilder.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type ClientInit, type RequestUploadPartsRes, type RequestUploadRes } from './providerTypes.js';
|
|
4
4
|
export type SharedInitRes = {
|
|
5
5
|
newCookies: string[];
|
|
6
|
-
token: string | undefined;
|
|
7
6
|
baseUrl: string;
|
|
8
7
|
providerName: string;
|
|
9
|
-
|
|
8
|
+
clientInit?: ClientInit;
|
|
10
9
|
};
|
|
11
10
|
export type SharedRequestUploadRes = Simplify<RequestUploadRes & {
|
|
12
11
|
size: number;
|
|
@@ -16,5 +15,16 @@ export type SharedRequestUploadRes = Simplify<RequestUploadRes & {
|
|
|
16
15
|
metadata: AnyMetadata;
|
|
17
16
|
}>;
|
|
18
17
|
export type SharedRequestUploadPartsRes = RequestUploadPartsRes;
|
|
19
|
-
export type
|
|
18
|
+
export type SharedFileMutationRes = {
|
|
19
|
+
succeeded: string[];
|
|
20
|
+
failed: {
|
|
21
|
+
url: string;
|
|
22
|
+
error: {
|
|
23
|
+
code: string;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
export type SharedConfirmUploadsRes = SharedFileMutationRes;
|
|
29
|
+
export type SharedDeleteFilesRes = SharedFileMutationRes;
|
|
20
30
|
//# sourceMappingURL=sharedFuncTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sharedFuncTypes.d.ts","sourceRoot":"","sources":["../../src/internals/sharedFuncTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"sharedFuncTypes.d.ts","sourceRoot":"","sources":["../../src/internals/sharedFuncTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAC3C,gBAAgB,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,EAAE,WAAW,CAAC;CACvB,CACF,CAAC;AACF,MAAM,MAAM,2BAA2B,GAAG,qBAAqB,CAAC;AAEhE,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE;YACL,IAAI,EAAE,MAAM,CAAC;YACb,OAAO,EAAE,MAAM,CAAC;SACjB,CAAC;KACH,EAAE,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,qBAAqB,CAAC;AAC5D,MAAM,MAAM,oBAAoB,GAAG,qBAAqB,CAAC"}
|
|
@@ -26,7 +26,7 @@ export type UploadOptions = {
|
|
|
26
26
|
*/
|
|
27
27
|
replaceTargetUrl?: string;
|
|
28
28
|
/**
|
|
29
|
-
* If true, the file needs to be confirmed by using the `
|
|
29
|
+
* If true, the file needs to be confirmed by using the `confirm` function.
|
|
30
30
|
* If the file is not confirmed within 24 hours, it will be deleted.
|
|
31
31
|
*
|
|
32
32
|
* This is useful for pages where the file is uploaded as soon as it is selected,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edgestore/shared",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.2",
|
|
4
4
|
"description": "Upload files with ease from React/Next.js",
|
|
5
5
|
"homepage": "https://edgestore.dev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,22 +48,21 @@
|
|
|
48
48
|
"!**/*.test.*",
|
|
49
49
|
"!**/__tests__"
|
|
50
50
|
],
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@standard-schema/spec": "^1.1.0"
|
|
53
|
+
},
|
|
51
54
|
"peerDependencies": {
|
|
52
55
|
"react": ">=16.8.0",
|
|
53
|
-
"react-dom": ">=16.8.0"
|
|
54
|
-
"zod": ">=3.0.0"
|
|
55
|
-
},
|
|
56
|
-
"peerDependenciesMeta": {
|
|
57
|
-
"zod": {
|
|
58
|
-
"optional": true
|
|
59
|
-
}
|
|
56
|
+
"react-dom": ">=16.8.0"
|
|
60
57
|
},
|
|
61
58
|
"devDependencies": {
|
|
62
59
|
"@types/node": "25.0.3",
|
|
60
|
+
"arktype": "2.2.3",
|
|
63
61
|
"react": "19.2.7",
|
|
64
62
|
"react-dom": "19.2.7",
|
|
65
63
|
"tsx": "4.23.1",
|
|
66
64
|
"typescript": "6.0.3",
|
|
65
|
+
"valibot": "1.4.2",
|
|
67
66
|
"zod": "3.25.76"
|
|
68
67
|
},
|
|
69
68
|
"gitHead": "a223c4cb8df50e6b64f9db5dc2daf93848748da9",
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export * from './errors';
|
|
2
2
|
export * from './types';
|
|
3
3
|
export * from './internals/bucketBuilder';
|
|
4
|
+
export {
|
|
5
|
+
type AnySchema,
|
|
6
|
+
type InferSchemaInput,
|
|
7
|
+
type InferSchemaOutput,
|
|
8
|
+
parseBucketInput,
|
|
9
|
+
} from './internals/schema';
|
|
4
10
|
export * from './internals/types';
|
|
5
11
|
export * from './internals/providerTypes';
|
|
12
|
+
export * from './internals/providerCapabilities';
|
|
6
13
|
export * from './internals/sharedFuncTypes';
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { EdgeStoreError } from '../errors';
|
|
3
2
|
import { type KeysOfUnion, type MaybePromise, type Simplify } from '../types';
|
|
4
3
|
import { createPathParamProxy } from './createPathParamProxy';
|
|
4
|
+
import {
|
|
5
|
+
assertStandardSchema,
|
|
6
|
+
type AnyInput,
|
|
7
|
+
type AnySchema,
|
|
8
|
+
type InferSchemaOutput,
|
|
9
|
+
} from './schema';
|
|
10
|
+
|
|
11
|
+
export type { AnyInput } from './schema';
|
|
5
12
|
|
|
6
13
|
type Merge<TType, TWith> = {
|
|
7
14
|
[TKey in keyof TType | keyof TWith]?: TKey extends keyof TType
|
|
@@ -23,21 +30,22 @@ type UnionToIntersection<TType> = (
|
|
|
23
30
|
? I
|
|
24
31
|
: never;
|
|
25
32
|
|
|
26
|
-
export type InferBucketPathKeys<TBucket extends
|
|
27
|
-
|
|
33
|
+
export type InferBucketPathKeys<TBucket extends AnyBuilder> = KeysOfUnion<
|
|
34
|
+
TBucket['_def']['path'][number]
|
|
35
|
+
>;
|
|
28
36
|
|
|
29
37
|
type InferBucketPathKeysFromDef<TDef extends AnyDef> = KeysOfUnion<
|
|
30
38
|
TDef['path'][number]
|
|
31
39
|
>;
|
|
32
40
|
|
|
33
|
-
export type InferBucketPathObject<TBucket extends
|
|
41
|
+
export type InferBucketPathObject<TBucket extends AnyBuilder> =
|
|
34
42
|
InferBucketPathKeys<TBucket> extends never
|
|
35
43
|
? Record<string, never>
|
|
36
44
|
: {
|
|
37
45
|
[TKey in InferBucketPathKeys<TBucket>]: string;
|
|
38
46
|
};
|
|
39
47
|
|
|
40
|
-
export type InferBucketPathOrder<TBucket extends
|
|
48
|
+
export type InferBucketPathOrder<TBucket extends AnyBuilder> =
|
|
41
49
|
InferBucketPathKeys<TBucket> extends never
|
|
42
50
|
? []
|
|
43
51
|
: InferBucketPathKeys<TBucket>[];
|
|
@@ -49,24 +57,57 @@ export type InferBucketPathObjectFromDef<TDef extends AnyDef> =
|
|
|
49
57
|
[TKey in InferBucketPathKeysFromDef<TDef>]: string;
|
|
50
58
|
};
|
|
51
59
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
type NormalizeMetadata<TMetadata> = string extends keyof TMetadata
|
|
61
|
+
? Record<string, Exclude<TMetadata[string], null | undefined>>
|
|
62
|
+
: Simplify<
|
|
63
|
+
{
|
|
64
|
+
[
|
|
65
|
+
TKey in keyof TMetadata as Extract<
|
|
66
|
+
TMetadata[TKey],
|
|
67
|
+
null | undefined
|
|
68
|
+
> extends never
|
|
69
|
+
? TKey
|
|
70
|
+
: never
|
|
71
|
+
]: Exclude<TMetadata[TKey], null | undefined>;
|
|
72
|
+
} & {
|
|
73
|
+
[
|
|
74
|
+
TKey in keyof TMetadata as Extract<
|
|
75
|
+
TMetadata[TKey],
|
|
76
|
+
null | undefined
|
|
77
|
+
> extends never
|
|
78
|
+
? never
|
|
79
|
+
: TKey
|
|
80
|
+
]?: Exclude<TMetadata[TKey], null | undefined>;
|
|
81
|
+
}
|
|
82
|
+
>;
|
|
83
|
+
|
|
84
|
+
type InferMetadataObjectFromFn<TMetadata> = [
|
|
85
|
+
Exclude<TMetadata, undefined>,
|
|
86
|
+
] extends [never]
|
|
87
|
+
? Record<string, never>
|
|
88
|
+
: Exclude<TMetadata, undefined> extends (...args: any) => any
|
|
89
|
+
? NormalizeMetadata<Awaited<ReturnType<Exclude<TMetadata, undefined>>>>
|
|
55
90
|
: Record<string, never>;
|
|
56
91
|
|
|
92
|
+
export type InferMetadataObject<TBucket extends AnyBuilder> =
|
|
93
|
+
InferMetadataObjectFromFn<TBucket['_def']['metadata']>;
|
|
94
|
+
|
|
57
95
|
type InferMetadataObjectFromDef<TDef extends AnyDef> =
|
|
58
|
-
TDef['metadata']
|
|
59
|
-
? Awaited<ReturnType<TDef['metadata']>>
|
|
60
|
-
: Record<string, never>;
|
|
96
|
+
InferMetadataObjectFromFn<TDef['metadata']>;
|
|
61
97
|
|
|
62
|
-
export type AnyContextValue = string | undefined
|
|
98
|
+
export type AnyContextValue = string | undefined;
|
|
63
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Context shared by router hooks, path and metadata builders, and providers.
|
|
102
|
+
*
|
|
103
|
+
* Values are limited to strings so every supported provider receives the same
|
|
104
|
+
* context shape. Optional properties may be `undefined`; providers omit them
|
|
105
|
+
* when serializing the context.
|
|
106
|
+
*/
|
|
64
107
|
export interface AnyContext {
|
|
65
108
|
[key: string]: AnyContextValue;
|
|
66
109
|
}
|
|
67
110
|
|
|
68
|
-
export type AnyInput = z.AnyZodObject | z.ZodNever;
|
|
69
|
-
|
|
70
111
|
export type AnyPath = Record<string, () => string>[];
|
|
71
112
|
|
|
72
113
|
type PathParam<TPath extends AnyPath> = {
|
|
@@ -125,7 +166,7 @@ type BucketConfig = {
|
|
|
125
166
|
|
|
126
167
|
type BeforeUploadFn<TCtx, TDef extends AnyDef> = (params: {
|
|
127
168
|
ctx: TCtx;
|
|
128
|
-
input:
|
|
169
|
+
input: InferSchemaOutput<TDef['input']>;
|
|
129
170
|
fileInfo: {
|
|
130
171
|
size: number;
|
|
131
172
|
type: string;
|
|
@@ -153,16 +194,22 @@ type MetadataFn<
|
|
|
153
194
|
TCtx,
|
|
154
195
|
TInput extends AnyInput,
|
|
155
196
|
TMetadata extends AnyMetadata,
|
|
156
|
-
> = (params: {
|
|
197
|
+
> = (params: {
|
|
198
|
+
ctx: TCtx;
|
|
199
|
+
input: InferSchemaOutput<TInput>;
|
|
200
|
+
}) => MaybePromise<TMetadata>;
|
|
157
201
|
|
|
158
|
-
export type AnyMetadataFn =
|
|
202
|
+
export type AnyMetadataFn = (params: {
|
|
203
|
+
ctx: any;
|
|
204
|
+
input: any;
|
|
205
|
+
}) => MaybePromise<AnyMetadata>;
|
|
159
206
|
|
|
160
207
|
type BucketType = 'IMAGE' | 'FILE';
|
|
161
208
|
|
|
162
209
|
type Def<
|
|
163
210
|
TInput extends AnyInput,
|
|
164
211
|
TPath extends AnyPath,
|
|
165
|
-
TMetadata extends AnyMetadataFn,
|
|
212
|
+
TMetadata extends AnyMetadataFn | undefined,
|
|
166
213
|
> = {
|
|
167
214
|
type: BucketType;
|
|
168
215
|
input: TInput;
|
|
@@ -175,7 +222,7 @@ type Def<
|
|
|
175
222
|
beforeDelete?: BeforeDeleteFn<any, any>;
|
|
176
223
|
};
|
|
177
224
|
|
|
178
|
-
type AnyDef = Def<AnyInput, AnyPath, AnyMetadataFn>;
|
|
225
|
+
type AnyDef = Def<AnyInput, AnyPath, AnyMetadataFn | undefined>;
|
|
179
226
|
|
|
180
227
|
type Builder<TCtx, TDef extends AnyDef> = {
|
|
181
228
|
/** only used for types */
|
|
@@ -191,7 +238,7 @@ type Builder<TCtx, TDef extends AnyDef> = {
|
|
|
191
238
|
*
|
|
192
239
|
* This can be used to add additional information to the file, like choose the file path or add metadata.
|
|
193
240
|
*/
|
|
194
|
-
input<TInput extends
|
|
241
|
+
input<TInput extends AnySchema>(
|
|
195
242
|
input: TInput,
|
|
196
243
|
): Builder<
|
|
197
244
|
TCtx,
|
|
@@ -222,7 +269,9 @@ type Builder<TCtx, TDef extends AnyDef> = {
|
|
|
222
269
|
path<TParams extends AnyPath>(
|
|
223
270
|
pathResolver: (params: {
|
|
224
271
|
ctx: Simplify<ConvertStringToFunction<TCtx>>;
|
|
225
|
-
input: Simplify<
|
|
272
|
+
input: Simplify<
|
|
273
|
+
ConvertStringToFunction<InferSchemaOutput<TDef['input']>>
|
|
274
|
+
>;
|
|
226
275
|
}) => [...TParams],
|
|
227
276
|
): Builder<
|
|
228
277
|
TCtx,
|
|
@@ -338,7 +387,14 @@ type Builder<TCtx, TDef extends AnyDef> = {
|
|
|
338
387
|
>;
|
|
339
388
|
};
|
|
340
389
|
|
|
341
|
-
|
|
390
|
+
type ErasedBuilder<TCtx> = {
|
|
391
|
+
$config: {
|
|
392
|
+
ctx: TCtx;
|
|
393
|
+
};
|
|
394
|
+
_def: AnyDef;
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
export type AnyBuilder = ErasedBuilder<any>;
|
|
342
398
|
|
|
343
399
|
const createNewBuilder = (initDef: AnyDef, newDef: Partial<AnyDef>) => {
|
|
344
400
|
const mergedDef = {
|
|
@@ -356,9 +412,9 @@ const createNewBuilder = (initDef: AnyDef, newDef: Partial<AnyDef>) => {
|
|
|
356
412
|
function createBuilder<
|
|
357
413
|
TCtx,
|
|
358
414
|
TType extends BucketType,
|
|
359
|
-
TInput extends AnyInput =
|
|
415
|
+
TInput extends AnyInput = undefined,
|
|
360
416
|
TPath extends AnyPath = [],
|
|
361
|
-
TMetadata extends AnyMetadataFn
|
|
417
|
+
TMetadata extends AnyMetadataFn | undefined = undefined,
|
|
362
418
|
>(
|
|
363
419
|
opts: { type: TType },
|
|
364
420
|
initDef?: Partial<AnyDef>,
|
|
@@ -378,9 +434,9 @@ function createBuilder<
|
|
|
378
434
|
> {
|
|
379
435
|
const _def: AnyDef = {
|
|
380
436
|
type: opts.type,
|
|
381
|
-
input:
|
|
437
|
+
input: undefined,
|
|
382
438
|
path: [],
|
|
383
|
-
metadata:
|
|
439
|
+
metadata: undefined,
|
|
384
440
|
...initDef,
|
|
385
441
|
};
|
|
386
442
|
|
|
@@ -391,6 +447,7 @@ function createBuilder<
|
|
|
391
447
|
// @ts-expect-error - I think it would be too much work to make this type correct.
|
|
392
448
|
_def,
|
|
393
449
|
input(input) {
|
|
450
|
+
assertStandardSchema(input);
|
|
394
451
|
return createNewBuilder(_def, {
|
|
395
452
|
input,
|
|
396
453
|
}) as any;
|
|
@@ -486,9 +543,9 @@ class EdgeStoreBuilder<TCtx = Record<string, never>> {
|
|
|
486
543
|
|
|
487
544
|
export type EdgeStoreRouter<
|
|
488
545
|
TCtx,
|
|
489
|
-
TBuckets extends Record<string,
|
|
546
|
+
TBuckets extends Record<string, ErasedBuilder<TCtx>> = Record<
|
|
490
547
|
string,
|
|
491
|
-
|
|
548
|
+
ErasedBuilder<TCtx>
|
|
492
549
|
>,
|
|
493
550
|
> = {
|
|
494
551
|
/**
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import type {
|
|
3
|
+
BackendFile,
|
|
4
|
+
GetSignedUrlRes,
|
|
5
|
+
ProviderFileMutationResult,
|
|
6
|
+
} from './providerTypes';
|
|
7
|
+
|
|
8
|
+
export type ProviderCapabilityName =
|
|
9
|
+
| 'upload'
|
|
10
|
+
| 'get'
|
|
11
|
+
| 'list'
|
|
12
|
+
| 'confirm'
|
|
13
|
+
| 'delete'
|
|
14
|
+
| 'restore'
|
|
15
|
+
| 'getSignedUrls';
|
|
16
|
+
|
|
17
|
+
export type ProviderCapability<
|
|
18
|
+
TProvider,
|
|
19
|
+
TName extends ProviderCapabilityName,
|
|
20
|
+
> = TName extends 'upload'
|
|
21
|
+
? TProvider extends { uploads: { upload: infer TOperation } }
|
|
22
|
+
? Extract<TOperation, (...args: never[]) => unknown>
|
|
23
|
+
: never
|
|
24
|
+
: TProvider extends {
|
|
25
|
+
files: infer TFiles;
|
|
26
|
+
}
|
|
27
|
+
? TName extends keyof TFiles
|
|
28
|
+
? Extract<TFiles[TName], (...args: never[]) => unknown>
|
|
29
|
+
: never
|
|
30
|
+
: never;
|
|
31
|
+
|
|
32
|
+
export type ProviderCapabilityInput<
|
|
33
|
+
TProvider,
|
|
34
|
+
TName extends ProviderCapabilityName,
|
|
35
|
+
> = Parameters<ProviderCapability<TProvider, TName>>[0];
|
|
36
|
+
|
|
37
|
+
export type ProviderCapabilityResult<
|
|
38
|
+
TProvider,
|
|
39
|
+
TName extends ProviderCapabilityName,
|
|
40
|
+
> = Awaited<ReturnType<ProviderCapability<TProvider, TName>>>;
|
|
41
|
+
|
|
42
|
+
type ProviderReferenceSchema<TProvider> = TProvider extends {
|
|
43
|
+
reference: {
|
|
44
|
+
schema: infer TSchema extends StandardSchemaV1;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
? TSchema
|
|
48
|
+
: never;
|
|
49
|
+
|
|
50
|
+
export type ProviderReferenceInput<TProvider> = StandardSchemaV1.InferInput<
|
|
51
|
+
ProviderReferenceSchema<TProvider>
|
|
52
|
+
>;
|
|
53
|
+
|
|
54
|
+
export type ProviderReference<TProvider> = StandardSchemaV1.InferOutput<
|
|
55
|
+
ProviderReferenceSchema<TProvider>
|
|
56
|
+
>;
|
|
57
|
+
|
|
58
|
+
export type ProviderCursor<TProvider> = TProvider extends {
|
|
59
|
+
files: {
|
|
60
|
+
cursorSchema: infer TSchema extends StandardSchemaV1;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
? StandardSchemaV1.InferOutput<TSchema>
|
|
64
|
+
: string;
|
|
65
|
+
|
|
66
|
+
export type ProviderCapabilityFile<
|
|
67
|
+
TProvider,
|
|
68
|
+
TName extends 'upload' | 'get' | 'list',
|
|
69
|
+
> = TName extends 'upload'
|
|
70
|
+
? ProviderCapabilityResult<TProvider, TName> extends {
|
|
71
|
+
file: infer TFile extends BackendFile;
|
|
72
|
+
}
|
|
73
|
+
? TFile
|
|
74
|
+
: never
|
|
75
|
+
: TName extends 'list'
|
|
76
|
+
? ProviderCapabilityResult<TProvider, TName> extends {
|
|
77
|
+
items: (infer TFile extends BackendFile)[];
|
|
78
|
+
}
|
|
79
|
+
? TFile
|
|
80
|
+
: never
|
|
81
|
+
: ProviderCapabilityResult<TProvider, TName> extends BackendFile
|
|
82
|
+
? ProviderCapabilityResult<TProvider, TName>
|
|
83
|
+
: never;
|
|
84
|
+
|
|
85
|
+
export type ProviderMutationItem<
|
|
86
|
+
TProvider,
|
|
87
|
+
TName extends 'confirm' | 'delete' | 'restore',
|
|
88
|
+
> =
|
|
89
|
+
ProviderCapabilityResult<TProvider, TName> extends {
|
|
90
|
+
results: (infer TItem)[];
|
|
91
|
+
}
|
|
92
|
+
? TItem
|
|
93
|
+
: never;
|
|
94
|
+
|
|
95
|
+
export type ProviderMutationError<
|
|
96
|
+
TProvider,
|
|
97
|
+
TName extends 'confirm' | 'delete' | 'restore',
|
|
98
|
+
> =
|
|
99
|
+
Extract<ProviderMutationItem<TProvider, TName>, { success: false }> extends {
|
|
100
|
+
error: infer TError;
|
|
101
|
+
}
|
|
102
|
+
? TError
|
|
103
|
+
: never;
|
|
104
|
+
|
|
105
|
+
type ProviderMutationErrorCode<
|
|
106
|
+
TProvider,
|
|
107
|
+
TName extends 'confirm' | 'delete' | 'restore',
|
|
108
|
+
> =
|
|
109
|
+
ProviderMutationError<TProvider, TName> extends {
|
|
110
|
+
code: infer TErrorCode extends string;
|
|
111
|
+
}
|
|
112
|
+
? TErrorCode
|
|
113
|
+
: never;
|
|
114
|
+
|
|
115
|
+
export type ProviderSignedUrlResult<TProvider> =
|
|
116
|
+
ProviderCapabilityResult<
|
|
117
|
+
TProvider,
|
|
118
|
+
'getSignedUrls'
|
|
119
|
+
> extends (infer TResult extends GetSignedUrlRes)[]
|
|
120
|
+
? TResult
|
|
121
|
+
: never;
|
|
122
|
+
|
|
123
|
+
export type ProviderMutationResult<
|
|
124
|
+
TProvider,
|
|
125
|
+
TName extends 'confirm' | 'delete' | 'restore',
|
|
126
|
+
> = ProviderFileMutationResult<ProviderMutationErrorCode<TProvider, TName>>;
|