@muhgholy/next-drive 4.23.14 → 4.23.20
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/README.md +81 -0
- package/dist/client/components/drive/explorer.d.ts.map +1 -1
- package/dist/client/components/drive/file-grid.d.ts.map +1 -1
- package/dist/client/components/drive/upload.d.ts.map +1 -1
- package/dist/client/context.d.ts +9 -1
- package/dist/client/context.d.ts.map +1 -1
- package/dist/client/file-chooser.d.ts +1 -0
- package/dist/client/file-chooser.d.ts.map +1 -1
- package/dist/client/hooks/use-upload.d.ts +1 -1
- package/dist/client/hooks/use-upload.d.ts.map +1 -1
- package/dist/client/index.cjs +371 -175
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.css +1 -1
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +371 -177
- package/dist/client/index.js.map +1 -1
- package/dist/client/upload.d.ts +18 -0
- package/dist/client/upload.d.ts.map +1 -0
- package/dist/server/zod/schemas.d.ts +6 -6
- package/dist/types/client/index.d.ts +62 -0
- package/dist/types/client/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TDriveUploadOptions, TDriveUploadHandle, TDriveBatchOptions, TDriveBatchHandle } from '../types/client';
|
|
2
|
+
/**
|
|
3
|
+
* Upload a single file in chunks with byte-level progress, logging and cancellation.
|
|
4
|
+
*
|
|
5
|
+
* Returns a handle immediately; the upload starts right away. Use `handle.cancel()`
|
|
6
|
+
* to abort and `handle.promise` to await the final result. Omit `accountId` to upload
|
|
7
|
+
* anonymously (the server resolves anonymous uploads automatically when enabled).
|
|
8
|
+
*/
|
|
9
|
+
export declare const uploadFile: (options: TDriveUploadOptions) => TDriveUploadHandle;
|
|
10
|
+
/**
|
|
11
|
+
* Upload multiple files with a bounded concurrency pool.
|
|
12
|
+
*
|
|
13
|
+
* Returns immediately with one handle per file (each exposes its own `cancel` and
|
|
14
|
+
* `promise`), plus `cancelAll` and an aggregate `promise` that resolves once every
|
|
15
|
+
* file has settled.
|
|
16
|
+
*/
|
|
17
|
+
export declare const uploadFiles: (files: File[], options: TDriveBatchOptions) => TDriveBatchHandle;
|
|
18
|
+
//# sourceMappingURL=upload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/client/upload.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAER,mBAAmB,EACnB,kBAAkB,EAElB,kBAAkB,EAClB,iBAAiB,EACpB,MAAM,gBAAgB,CAAC;AA4BxB;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,SAAS,mBAAmB,KAAG,kBAiMzD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,IAAI,EAAE,EAAE,SAAS,kBAAkB,KAAG,iBAmFxE,CAAC"}
|
|
@@ -10,32 +10,32 @@ export declare const uploadChunkSchema: z.ZodEffects<z.ZodObject<{
|
|
|
10
10
|
fileType: z.ZodString;
|
|
11
11
|
folderId: z.ZodOptional<z.ZodString>;
|
|
12
12
|
}, "strip", z.ZodTypeAny, {
|
|
13
|
-
totalChunks: number;
|
|
14
13
|
chunkIndex: number;
|
|
14
|
+
totalChunks: number;
|
|
15
15
|
fileName: string;
|
|
16
16
|
fileSize: number;
|
|
17
17
|
fileType: string;
|
|
18
18
|
folderId?: string | undefined;
|
|
19
19
|
driveId?: string | undefined;
|
|
20
20
|
}, {
|
|
21
|
-
totalChunks: number;
|
|
22
21
|
chunkIndex: number;
|
|
22
|
+
totalChunks: number;
|
|
23
23
|
fileName: string;
|
|
24
24
|
fileSize: number;
|
|
25
25
|
fileType: string;
|
|
26
26
|
folderId?: string | undefined;
|
|
27
27
|
driveId?: string | undefined;
|
|
28
28
|
}>, {
|
|
29
|
-
totalChunks: number;
|
|
30
29
|
chunkIndex: number;
|
|
30
|
+
totalChunks: number;
|
|
31
31
|
fileName: string;
|
|
32
32
|
fileSize: number;
|
|
33
33
|
fileType: string;
|
|
34
34
|
folderId?: string | undefined;
|
|
35
35
|
driveId?: string | undefined;
|
|
36
36
|
}, {
|
|
37
|
-
totalChunks: number;
|
|
38
37
|
chunkIndex: number;
|
|
38
|
+
totalChunks: number;
|
|
39
39
|
fileName: string;
|
|
40
40
|
fileSize: number;
|
|
41
41
|
fileType: string;
|
|
@@ -51,8 +51,8 @@ export declare const listQuerySchema: z.ZodObject<{
|
|
|
51
51
|
folderId?: string | undefined;
|
|
52
52
|
afterId?: string | undefined;
|
|
53
53
|
}, {
|
|
54
|
-
limit?: string | undefined;
|
|
55
54
|
folderId?: string | undefined;
|
|
55
|
+
limit?: string | undefined;
|
|
56
56
|
afterId?: string | undefined;
|
|
57
57
|
}>;
|
|
58
58
|
export declare const serveQuerySchema: z.ZodObject<{
|
|
@@ -141,8 +141,8 @@ export declare const searchQuerySchema: z.ZodObject<{
|
|
|
141
141
|
folderId?: string | undefined;
|
|
142
142
|
}, {
|
|
143
143
|
q: string;
|
|
144
|
-
limit?: string | undefined;
|
|
145
144
|
folderId?: string | undefined;
|
|
145
|
+
limit?: string | undefined;
|
|
146
146
|
trashed?: string | undefined;
|
|
147
147
|
}>;
|
|
148
148
|
export declare const restoreQuerySchema: z.ZodObject<{
|
|
@@ -53,6 +53,7 @@ export type TDriveUploadState = {
|
|
|
53
53
|
status: 'pending' | 'queued' | 'uploading' | 'complete' | 'error' | 'cancelled';
|
|
54
54
|
currentChunk: number;
|
|
55
55
|
totalChunks: number;
|
|
56
|
+
percent?: number;
|
|
56
57
|
driveId?: string;
|
|
57
58
|
error?: string;
|
|
58
59
|
logs?: Array<{
|
|
@@ -61,4 +62,65 @@ export type TDriveUploadState = {
|
|
|
61
62
|
timestamp: number;
|
|
62
63
|
}>;
|
|
63
64
|
};
|
|
65
|
+
export type TDriveUploadLog = {
|
|
66
|
+
type: 'info' | 'warning' | 'error' | 'success';
|
|
67
|
+
message: string;
|
|
68
|
+
timestamp: number;
|
|
69
|
+
};
|
|
70
|
+
export type TDriveUploadProgress = {
|
|
71
|
+
id: string;
|
|
72
|
+
percent: number;
|
|
73
|
+
uploadedBytes: number;
|
|
74
|
+
totalBytes: number;
|
|
75
|
+
currentChunk: number;
|
|
76
|
+
totalChunks: number;
|
|
77
|
+
};
|
|
78
|
+
export type TDriveUploadResult = {
|
|
79
|
+
id: string;
|
|
80
|
+
status: 'complete';
|
|
81
|
+
driveId: string;
|
|
82
|
+
file: TDriveFile;
|
|
83
|
+
item: unknown;
|
|
84
|
+
} | {
|
|
85
|
+
id: string;
|
|
86
|
+
status: 'cancelled';
|
|
87
|
+
driveId: string | null;
|
|
88
|
+
} | {
|
|
89
|
+
id: string;
|
|
90
|
+
status: 'error';
|
|
91
|
+
driveId: string | null;
|
|
92
|
+
error: string;
|
|
93
|
+
};
|
|
94
|
+
export type TDriveUploadOptions = {
|
|
95
|
+
apiEndpoint: string;
|
|
96
|
+
file: File;
|
|
97
|
+
folderId?: string | null;
|
|
98
|
+
/** Account id forwarded as `x-drive-account`. Omit/null to upload anonymously. */
|
|
99
|
+
accountId?: string | null;
|
|
100
|
+
withCredentials?: boolean;
|
|
101
|
+
/** Caller-supplied id. Generated automatically when omitted. */
|
|
102
|
+
id?: string;
|
|
103
|
+
/** External abort signal; aborting it cancels the upload. */
|
|
104
|
+
signal?: AbortSignal;
|
|
105
|
+
onProgress?: (progress: TDriveUploadProgress) => void;
|
|
106
|
+
onLog?: (log: TDriveUploadLog & {
|
|
107
|
+
id: string;
|
|
108
|
+
}) => void;
|
|
109
|
+
onComplete?: (item: unknown) => void;
|
|
110
|
+
};
|
|
111
|
+
export type TDriveUploadHandle = {
|
|
112
|
+
id: string;
|
|
113
|
+
promise: Promise<TDriveUploadResult>;
|
|
114
|
+
cancel: () => void;
|
|
115
|
+
};
|
|
116
|
+
export type TDriveBatchOptions = Omit<TDriveUploadOptions, 'file' | 'id'> & {
|
|
117
|
+
/** Maximum number of concurrent uploads. Defaults to 2. */
|
|
118
|
+
concurrency?: number;
|
|
119
|
+
onFileComplete?: (result: TDriveUploadResult) => void;
|
|
120
|
+
};
|
|
121
|
+
export type TDriveBatchHandle = {
|
|
122
|
+
uploads: TDriveUploadHandle[];
|
|
123
|
+
cancelAll: () => void;
|
|
124
|
+
promise: Promise<TDriveUploadResult[]>;
|
|
125
|
+
};
|
|
64
126
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/client/index.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,UAAU,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CACtD,CAAC;AAGF,MAAM,MAAM,iBAAiB,GAAG;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,OAAO,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;IACxD,QAAQ,EAAE;QACN,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;QACzB,MAAM,CAAC,EAAE;YACL,EAAE,EAAE,MAAM,CAAC;YACX,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,aAAa,CAAC,EAAE,MAAM,CAAC;SA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