@depup/uploadthing 7.7.4-depup.0
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/LICENSE +21 -0
- package/README.md +33 -0
- package/changes.json +18 -0
- package/client/index.cjs +331 -0
- package/client/index.d.cts +36 -0
- package/client/index.d.cts.map +1 -0
- package/client/index.d.ts +36 -0
- package/client/index.d.ts.map +1 -0
- package/client/index.js +286 -0
- package/client/index.js.map +1 -0
- package/client-future/index.cjs +426 -0
- package/client-future/index.d.cts +373 -0
- package/client-future/index.d.cts.map +1 -0
- package/client-future/index.d.ts +373 -0
- package/client-future/index.d.ts.map +1 -0
- package/client-future/index.js +383 -0
- package/client-future/index.js.map +1 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/deprecations-DPGpmqha.cjs +13 -0
- package/dist/deprecations-pLmw6Ytd.js +8 -0
- package/dist/deprecations-pLmw6Ytd.js.map +1 -0
- package/dist/package-BQ_k22T9.cjs +11 -0
- package/dist/package-DpScpvTA.js +6 -0
- package/dist/package-DpScpvTA.js.map +1 -0
- package/dist/shared-schemas-BmG5ARoX.js +82 -0
- package/dist/shared-schemas-BmG5ARoX.js.map +1 -0
- package/dist/shared-schemas-CG9VaBtT.cjs +129 -0
- package/dist/to-web-request-BQtxSXgE.cjs +98 -0
- package/dist/to-web-request-DhP0wXG-.js +87 -0
- package/dist/to-web-request-DhP0wXG-.js.map +1 -0
- package/dist/types-Bs3w2d_3.d.ts +627 -0
- package/dist/types-Bs3w2d_3.d.ts.map +1 -0
- package/dist/types-DiVC1t2V.d.cts +625 -0
- package/dist/types-DiVC1t2V.d.cts.map +1 -0
- package/dist/upload-builder-BUa7tovh.d.cts +32 -0
- package/dist/upload-builder-BUa7tovh.d.cts.map +1 -0
- package/dist/upload-builder-BcFawEj0.d.ts +32 -0
- package/dist/upload-builder-BcFawEj0.d.ts.map +1 -0
- package/dist/upload-builder-BlFOAnsv.js +699 -0
- package/dist/upload-builder-BlFOAnsv.js.map +1 -0
- package/dist/upload-builder-D6Ken9H0.cjs +794 -0
- package/dist/ut-reporter-BHoyNnzW.cjs +120 -0
- package/dist/ut-reporter-Dlppchbx.js +103 -0
- package/dist/ut-reporter-Dlppchbx.js.map +1 -0
- package/effect-platform/index.cjs +22 -0
- package/effect-platform/index.d.cts +54 -0
- package/effect-platform/index.d.cts.map +1 -0
- package/effect-platform/index.d.ts +54 -0
- package/effect-platform/index.d.ts.map +1 -0
- package/effect-platform/index.js +19 -0
- package/effect-platform/index.js.map +1 -0
- package/express/index.cjs +30 -0
- package/express/index.d.cts +28 -0
- package/express/index.d.cts.map +1 -0
- package/express/index.d.ts +28 -0
- package/express/index.d.ts.map +1 -0
- package/express/index.js +27 -0
- package/express/index.js.map +1 -0
- package/fastify/index.cjs +27 -0
- package/fastify/index.d.cts +28 -0
- package/fastify/index.d.cts.map +1 -0
- package/fastify/index.d.ts +28 -0
- package/fastify/index.d.ts.map +1 -0
- package/fastify/index.js +24 -0
- package/fastify/index.js.map +1 -0
- package/h3/index.cjs +20 -0
- package/h3/index.d.cts +28 -0
- package/h3/index.d.cts.map +1 -0
- package/h3/index.d.ts +28 -0
- package/h3/index.d.ts.map +1 -0
- package/h3/index.js +17 -0
- package/h3/index.js.map +1 -0
- package/next/index.cjs +22 -0
- package/next/index.d.cts +30 -0
- package/next/index.d.cts.map +1 -0
- package/next/index.d.ts +30 -0
- package/next/index.d.ts.map +1 -0
- package/next/index.js +19 -0
- package/next/index.js.map +1 -0
- package/next-legacy/index.cjs +28 -0
- package/next-legacy/index.d.cts +28 -0
- package/next-legacy/index.d.cts.map +1 -0
- package/next-legacy/index.d.ts +28 -0
- package/next-legacy/index.d.ts.map +1 -0
- package/next-legacy/index.js +25 -0
- package/next-legacy/index.js.map +1 -0
- package/package.json +210 -0
- package/remix/index.cjs +22 -0
- package/remix/index.d.cts +30 -0
- package/remix/index.d.cts.map +1 -0
- package/remix/index.d.ts +30 -0
- package/remix/index.d.ts.map +1 -0
- package/remix/index.js +19 -0
- package/remix/index.js.map +1 -0
- package/server/index.cjs +414 -0
- package/server/index.d.cts +211 -0
- package/server/index.d.cts.map +1 -0
- package/server/index.d.ts +213 -0
- package/server/index.d.ts.map +1 -0
- package/server/index.js +405 -0
- package/server/index.js.map +1 -0
- package/tw/index.cjs +70 -0
- package/tw/index.d.cts +29 -0
- package/tw/index.d.cts.map +1 -0
- package/tw/index.d.ts +29 -0
- package/tw/index.d.ts.map +1 -0
- package/tw/index.js +74 -0
- package/tw/index.js.map +1 -0
- package/tw/v4.css +11 -0
- package/types/index.cjs +3 -0
- package/types/index.d.cts +2 -0
- package/types/index.d.ts +2 -0
- package/types/index.js +3 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { ACLUpdateOptions, DeleteFilesOptions, FileEsque, FileRouter, GetFileUrlsOptions, GetSignedURLOptions, ListFilesOptions, RenameFileUpdate, RouteHandlerOptions, UTApiOptions, UTFiles, UTRegion, UnsetMarker, UploadBuilder, UploadFileResult, UploadFilesOptions$1 as UploadFilesOptions, UrlWithOverrides } from "../dist/types-DiVC1t2V.cjs";
|
|
2
|
+
import { CreateBuilderOptions, createBuilder } from "../dist/upload-builder-BUa7tovh.cjs";
|
|
3
|
+
import * as _uploadthing_shared0 from "@uploadthing/shared";
|
|
4
|
+
import { ACL, Json, MaybeUrl, UploadThingError, UploadThingError as UploadThingError$1 } from "@uploadthing/shared";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
|
|
7
|
+
//#region src/_internal/handler.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Create a request handler adapter for any framework or server library.
|
|
11
|
+
* Refer to the existing adapters for examples on how to use this function.
|
|
12
|
+
* @public
|
|
13
|
+
*
|
|
14
|
+
* @param makeAdapterArgs - Function that takes the args from your framework and returns an Effect that resolves to the adapter args.
|
|
15
|
+
* These args are passed to the `.middleware`, `.onUploadComplete`, and `.onUploadError` hooks.
|
|
16
|
+
* @param toRequest - Function that takes the args from your framework and returns an Effect that resolves to a web Request object.
|
|
17
|
+
* @param opts - The router config and other options that are normally passed to `createRequestHandler` of official adapters
|
|
18
|
+
* @param beAdapter - [Optional] The adapter name of the adapter, used for telemetry purposes
|
|
19
|
+
* @returns A function that takes the args from your framework and returns a promise that resolves to a Response object.
|
|
20
|
+
*/
|
|
21
|
+
declare const makeAdapterHandler: <Args extends any[], AdapterArgs extends Record<string, unknown>>(makeAdapterArgs: (...args: Args) => Effect.Effect<AdapterArgs>, toRequest: (...args: Args) => Effect.Effect<Request>, opts: RouteHandlerOptions<FileRouter>, beAdapter?: string) => ((...args: Args) => Promise<Response>);
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/sdk/ut-file.d.ts
|
|
24
|
+
interface UTFilePropertyBag extends BlobPropertyBag {
|
|
25
|
+
lastModified?: number | undefined;
|
|
26
|
+
customId?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Extension of the Blob class that simplifies setting the `name` and `customId` properties,
|
|
30
|
+
* similar to the built-in File class from Node > 20.
|
|
31
|
+
*/
|
|
32
|
+
declare class UTFile extends Blob {
|
|
33
|
+
name: string;
|
|
34
|
+
lastModified: number;
|
|
35
|
+
customId: string | undefined;
|
|
36
|
+
constructor(parts: BlobPart[], name: string, options?: UTFilePropertyBag);
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/sdk/index.d.ts
|
|
40
|
+
declare class UTApi {
|
|
41
|
+
private fetch;
|
|
42
|
+
private defaultKeyType;
|
|
43
|
+
private runtime;
|
|
44
|
+
private opts;
|
|
45
|
+
constructor(options?: UTApiOptions);
|
|
46
|
+
private requestUploadThing;
|
|
47
|
+
private executeAsync;
|
|
48
|
+
/**
|
|
49
|
+
* Upload files to UploadThing storage.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* await uploadFiles(new File(["foo"], "foo.txt"));
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* await uploadFiles([
|
|
56
|
+
* new File(["foo"], "foo.txt"),
|
|
57
|
+
* new File(["bar"], "bar.txt"),
|
|
58
|
+
* ]);
|
|
59
|
+
*/
|
|
60
|
+
uploadFiles(files: FileEsque, opts?: UploadFilesOptions): Promise<UploadFileResult>;
|
|
61
|
+
uploadFiles(files: FileEsque[], opts?: UploadFilesOptions): Promise<UploadFileResult[]>;
|
|
62
|
+
/**
|
|
63
|
+
* @param {string} url The URL of the file to upload
|
|
64
|
+
* @param {Json} metadata JSON-parseable metadata to attach to the uploaded file(s)
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* await uploadFileFromUrl("https://uploadthing.com/f/2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg");
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* await uploadFileFromUrl([
|
|
71
|
+
* "https://uploadthing.com/f/2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg",
|
|
72
|
+
* "https://uploadthing.com/f/1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg"
|
|
73
|
+
* ])
|
|
74
|
+
*/
|
|
75
|
+
uploadFilesFromUrl(urls: MaybeUrl | UrlWithOverrides, opts?: UploadFilesOptions): Promise<UploadFileResult>;
|
|
76
|
+
uploadFilesFromUrl(urls: (MaybeUrl | UrlWithOverrides)[], opts?: UploadFilesOptions): Promise<UploadFileResult[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Request to delete files from UploadThing storage.
|
|
79
|
+
* @param {string | string[]} fileKeys
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* await deleteFiles("2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg");
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* await deleteFiles(["2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg","1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg"])
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* await deleteFiles("myCustomIdentifier", { keyType: "customId" })
|
|
89
|
+
*/
|
|
90
|
+
deleteFiles: (keys: string[] | string, opts?: DeleteFilesOptions) => Promise<{
|
|
91
|
+
readonly success: boolean;
|
|
92
|
+
readonly deletedCount: number;
|
|
93
|
+
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Request file URLs from UploadThing storage.
|
|
96
|
+
* @param {string | string[]} fileKeys
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* const data = await getFileUrls("2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg");
|
|
100
|
+
* console.log(data); // [{key: "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg", url: "https://uploadthing.com/f/2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg"}]
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* const data = await getFileUrls(["2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg","1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg"])
|
|
104
|
+
* console.log(data) // [{key: "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg", url: "https://uploadthing.com/f/2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg" },{key: "1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg", url: "https://uploadthing.com/f/1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg"}]
|
|
105
|
+
*
|
|
106
|
+
* @deprecated - See https://docs.uploadthing.com/working-with-files#accessing-files for info how to access files
|
|
107
|
+
*/
|
|
108
|
+
getFileUrls: (keys: string[] | string, opts?: GetFileUrlsOptions) => Promise<{
|
|
109
|
+
readonly data: readonly {
|
|
110
|
+
readonly url: string;
|
|
111
|
+
readonly key: string;
|
|
112
|
+
}[];
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Request file list from UploadThing storage.
|
|
116
|
+
* @param {object} opts
|
|
117
|
+
* @param {number} opts.limit The maximum number of files to return
|
|
118
|
+
* @param {number} opts.offset The number of files to skip
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* const data = await listFiles({ limit: 1 });
|
|
122
|
+
* console.log(data); // { key: "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg", id: "2e0fdb64-9957-4262-8e45-f372ba903ac8" }
|
|
123
|
+
*/
|
|
124
|
+
listFiles: (opts?: ListFilesOptions) => Promise<{
|
|
125
|
+
readonly files: readonly {
|
|
126
|
+
readonly name: string;
|
|
127
|
+
readonly size: number;
|
|
128
|
+
readonly customId: string | null;
|
|
129
|
+
readonly key: string;
|
|
130
|
+
readonly id: string;
|
|
131
|
+
readonly status: "Deletion Pending" | "Failed" | "Uploaded" | "Uploading";
|
|
132
|
+
readonly uploadedAt: number;
|
|
133
|
+
}[];
|
|
134
|
+
readonly hasMore: boolean;
|
|
135
|
+
}>;
|
|
136
|
+
renameFiles: (updates: RenameFileUpdate | RenameFileUpdate[]) => Promise<{
|
|
137
|
+
readonly success: boolean;
|
|
138
|
+
}>;
|
|
139
|
+
getUsageInfo: () => Promise<{
|
|
140
|
+
readonly totalBytes: number;
|
|
141
|
+
readonly appTotalBytes: number;
|
|
142
|
+
readonly filesUploaded: number;
|
|
143
|
+
readonly limitBytes: number;
|
|
144
|
+
}>;
|
|
145
|
+
/**
|
|
146
|
+
* Generate a presigned url for a private file
|
|
147
|
+
* Unlike {@link getSignedURL}, this method does not make a fetch request to the UploadThing API
|
|
148
|
+
* and is the recommended way to generate a presigned url for a private file.
|
|
149
|
+
**/
|
|
150
|
+
generateSignedURL: (key: string, opts?: GetSignedURLOptions) => Promise<{
|
|
151
|
+
ufsUrl: string;
|
|
152
|
+
}>;
|
|
153
|
+
/**
|
|
154
|
+
* Request a presigned url for a private file(s)
|
|
155
|
+
* @remarks This method is no longer recommended as it makes a fetch
|
|
156
|
+
* request to the UploadThing API which incurs redundant latency. It
|
|
157
|
+
* will be deprecated in UploadThing v8 and removed in UploadThing v9.
|
|
158
|
+
*
|
|
159
|
+
* @see {@link generateSignedURL} for a more efficient way to generate a presigned url
|
|
160
|
+
**/
|
|
161
|
+
getSignedURL: (key: string, opts?: GetSignedURLOptions) => Promise<{
|
|
162
|
+
readonly url: string;
|
|
163
|
+
readonly ufsUrl: string;
|
|
164
|
+
}>;
|
|
165
|
+
/**
|
|
166
|
+
* Update the ACL of a file or set of files.
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* // Make a single file public
|
|
170
|
+
* await utapi.updateACL("2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg", "public-read");
|
|
171
|
+
*
|
|
172
|
+
* // Make multiple files private
|
|
173
|
+
* await utapi.updateACL(
|
|
174
|
+
* [
|
|
175
|
+
* "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg",
|
|
176
|
+
* "1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg",
|
|
177
|
+
* ],
|
|
178
|
+
* "private",
|
|
179
|
+
* );
|
|
180
|
+
*/
|
|
181
|
+
updateACL: (keys: string | string[], acl: ACL, opts?: ACLUpdateOptions) => Promise<{
|
|
182
|
+
readonly success: boolean;
|
|
183
|
+
}>;
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/server.d.ts
|
|
187
|
+
type AdapterArgs$1 = {
|
|
188
|
+
req: Request;
|
|
189
|
+
};
|
|
190
|
+
declare const createUploadthing: <TErrorShape extends Json>(opts?: CreateBuilderOptions<TErrorShape>) => <TRouteOptions extends _uploadthing_shared0.RouteOptions>(input: _uploadthing_shared0.FileRouterInputConfig, config?: TRouteOptions | undefined) => UploadBuilder<{
|
|
191
|
+
_routeOptions: TRouteOptions;
|
|
192
|
+
_input: {
|
|
193
|
+
in: UnsetMarker;
|
|
194
|
+
out: UnsetMarker;
|
|
195
|
+
};
|
|
196
|
+
_metadata: UnsetMarker;
|
|
197
|
+
_adapterFnArgs: AdapterArgs$1;
|
|
198
|
+
_errorShape: TErrorShape;
|
|
199
|
+
_errorFn: UnsetMarker;
|
|
200
|
+
_output: UnsetMarker;
|
|
201
|
+
}>;
|
|
202
|
+
declare const createRouteHandler: <TRouter extends FileRouter>(opts: RouteHandlerOptions<TRouter>) => (args_0: Request | {
|
|
203
|
+
request: Request;
|
|
204
|
+
}) => Promise<Response>;
|
|
205
|
+
declare const extractRouterConfig: (router: FileRouter) => {
|
|
206
|
+
slug: string;
|
|
207
|
+
config: _uploadthing_shared0.ExpandedRouteConfig;
|
|
208
|
+
}[];
|
|
209
|
+
//#endregion
|
|
210
|
+
export { type FileRouter, UTApi, UTFile, UTFiles, UploadThingError, createBuilder, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion, extractRouterConfig, makeAdapterHandler };
|
|
211
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/_internal/handler.ts","../src/sdk/ut-file.ts","../src/sdk/index.ts","../src/server.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;AAyE8B;cARjB,6DAES,oDAEO,SAAS,MAAA,CAAO,OAAO,mCAC7B,SAAS,MAAA,CAAO,OAAO,gBACtC,oBAAoB,+CAEd,SAAS,QAAQ;;;UCvErB,iBAAA,SAA0B;;;;;;;AD+DpC;AAmCC,cCzFY,MAAA,SAAe,IAAA,CDyF3B;EAAA,IAjCqB,EAAA,MAAA;EAAM,YAEC,EAAA,MAAA;EAAI,QAAmB,EAAA,MAAA,GAAA,SAAA;EAAW,WAAlB,CAAA,KAAA,ECrDxB,QDqDwB,EAAA,EAAA,IAAA,EAAA,MAAA,EAAA,OAAA,CAAA,ECrDY,iBDqDZ;;;;cEtBhC,KAAA;;;EFkBA,QAAA,OAAA;EAmCZ,QAAA,IAAA;EAAA,WAjCqB,CAAA,OAAA,CAAA,EEZE,YFYF;EAAM,QAEC,kBAAA;EAAI,QAAmB,YAAA;EAAW;;;;;;;;;AAIjC;;;qBEkEnB,kBACA,qBACN,QAAQ;ED3IH,WAAA,CAAA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AA;EAEqB,YAAA,EAAA,GAAA,GDoW3C,OCpW2C,CAAA;;;IAW5C,SAAA,aAC0B,EAAA,MAAA;IAAA,SAAA,UAAA,EAAA,MAAA;EAAA,CAAA,CAAA;EADe;;;;;0CDmXL,wBAAmB;;;;;;;;;;;qCAiExB,wBAAmB;;;;;;;;;;;;;;;;;;;;4CA0DtD,YACE,qBAAgB;;;;;;KCrgBtB,aAAA,GH+CkC;EAAM,GACjB,EG/CrB,OH+CqB;CAAU;AAExB,cG9CD,iBH8CC,EAAA,CAAA,oBG9CwC,IH8CxC,CAAA,CAAA,IAAA,CAAA,EG7CL,oBH6CK,CG7CgB,WH6ChB,CAAA,EAAA,GAAA,CAAA,sBG7Ce,oBAAA,CAAa,YH6C5B,CAAA,CAAA,KAAA,EG7C4B,oBAAA,CAAA,qBH6C5B,EAAA,MAAA,CAAA,EG7C4B,aH6C5B,GAAA,SAAA,EAAA,gBAAA,CAAA;EAAI,aAAa,EG7CW,aH6CX;EAAQ,MAAhB,EAAA;IAAO,EAAA,aAAA;;;;ECvEpB,cAAA,eAAkB;EASf,WAAO,aAAA;EAAA,QAAA,aAAA;EAAA,OAKC,aAAA;CAAQ,CAAA;AALD,cEoBf,kBFpBe,EAAA,CAAA,gBEoBuB,UFpBvB,CAAA,CAAA,IAAA,EEqBpB,mBFrBoB,CEqBA,OFrBA,CAAA,EAAA,GAAA,CAAA,MAAA,EEqBQ,OFrBR,GAAA;EAAI,OAAA,EEuBkB,OFvBlB;cEuByB;cAW5C,8BAA+B;;EDE/B,MAAA,ECFyC,oBAAA,CAAA,mBDEpC;CAAA,EAAA"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { ACLUpdateOptions, DeleteFilesOptions, FileEsque, FileRouter, GetFileUrlsOptions, GetSignedURLOptions, ListFilesOptions, RenameFileUpdate, RouteHandlerOptions, UTApiOptions, UTFiles, UTRegion, UnsetMarker, UploadBuilder, UploadFileResult, UploadFilesOptions$1 as UploadFilesOptions, UrlWithOverrides } from "../dist/types-Bs3w2d_3.js";
|
|
2
|
+
import { CreateBuilderOptions, createBuilder } from "../dist/upload-builder-BcFawEj0.js";
|
|
3
|
+
import * as _uploadthing_shared0 from "@uploadthing/shared";
|
|
4
|
+
import { ACL, Json, MaybeUrl, UploadThingError, UploadThingError as UploadThingError$1 } from "@uploadthing/shared";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import "@effect/platform/HttpRouter";
|
|
7
|
+
import "effect/Context";
|
|
8
|
+
|
|
9
|
+
//#region src/_internal/handler.d.ts
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Create a request handler adapter for any framework or server library.
|
|
13
|
+
* Refer to the existing adapters for examples on how to use this function.
|
|
14
|
+
* @public
|
|
15
|
+
*
|
|
16
|
+
* @param makeAdapterArgs - Function that takes the args from your framework and returns an Effect that resolves to the adapter args.
|
|
17
|
+
* These args are passed to the `.middleware`, `.onUploadComplete`, and `.onUploadError` hooks.
|
|
18
|
+
* @param toRequest - Function that takes the args from your framework and returns an Effect that resolves to a web Request object.
|
|
19
|
+
* @param opts - The router config and other options that are normally passed to `createRequestHandler` of official adapters
|
|
20
|
+
* @param beAdapter - [Optional] The adapter name of the adapter, used for telemetry purposes
|
|
21
|
+
* @returns A function that takes the args from your framework and returns a promise that resolves to a Response object.
|
|
22
|
+
*/
|
|
23
|
+
declare const makeAdapterHandler: <Args extends any[], AdapterArgs extends Record<string, unknown>>(makeAdapterArgs: (...args: Args) => Effect.Effect<AdapterArgs>, toRequest: (...args: Args) => Effect.Effect<Request>, opts: RouteHandlerOptions<FileRouter>, beAdapter?: string) => ((...args: Args) => Promise<Response>);
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/sdk/ut-file.d.ts
|
|
26
|
+
interface UTFilePropertyBag extends BlobPropertyBag {
|
|
27
|
+
lastModified?: number | undefined;
|
|
28
|
+
customId?: string | undefined;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Extension of the Blob class that simplifies setting the `name` and `customId` properties,
|
|
32
|
+
* similar to the built-in File class from Node > 20.
|
|
33
|
+
*/
|
|
34
|
+
declare class UTFile extends Blob {
|
|
35
|
+
name: string;
|
|
36
|
+
lastModified: number;
|
|
37
|
+
customId: string | undefined;
|
|
38
|
+
constructor(parts: BlobPart[], name: string, options?: UTFilePropertyBag);
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/sdk/index.d.ts
|
|
42
|
+
declare class UTApi {
|
|
43
|
+
private fetch;
|
|
44
|
+
private defaultKeyType;
|
|
45
|
+
private runtime;
|
|
46
|
+
private opts;
|
|
47
|
+
constructor(options?: UTApiOptions);
|
|
48
|
+
private requestUploadThing;
|
|
49
|
+
private executeAsync;
|
|
50
|
+
/**
|
|
51
|
+
* Upload files to UploadThing storage.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* await uploadFiles(new File(["foo"], "foo.txt"));
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* await uploadFiles([
|
|
58
|
+
* new File(["foo"], "foo.txt"),
|
|
59
|
+
* new File(["bar"], "bar.txt"),
|
|
60
|
+
* ]);
|
|
61
|
+
*/
|
|
62
|
+
uploadFiles(files: FileEsque, opts?: UploadFilesOptions): Promise<UploadFileResult>;
|
|
63
|
+
uploadFiles(files: FileEsque[], opts?: UploadFilesOptions): Promise<UploadFileResult[]>;
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} url The URL of the file to upload
|
|
66
|
+
* @param {Json} metadata JSON-parseable metadata to attach to the uploaded file(s)
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* await uploadFileFromUrl("https://uploadthing.com/f/2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg");
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* await uploadFileFromUrl([
|
|
73
|
+
* "https://uploadthing.com/f/2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg",
|
|
74
|
+
* "https://uploadthing.com/f/1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg"
|
|
75
|
+
* ])
|
|
76
|
+
*/
|
|
77
|
+
uploadFilesFromUrl(urls: MaybeUrl | UrlWithOverrides, opts?: UploadFilesOptions): Promise<UploadFileResult>;
|
|
78
|
+
uploadFilesFromUrl(urls: (MaybeUrl | UrlWithOverrides)[], opts?: UploadFilesOptions): Promise<UploadFileResult[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Request to delete files from UploadThing storage.
|
|
81
|
+
* @param {string | string[]} fileKeys
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* await deleteFiles("2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg");
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* await deleteFiles(["2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg","1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg"])
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* await deleteFiles("myCustomIdentifier", { keyType: "customId" })
|
|
91
|
+
*/
|
|
92
|
+
deleteFiles: (keys: string[] | string, opts?: DeleteFilesOptions) => Promise<{
|
|
93
|
+
readonly success: boolean;
|
|
94
|
+
readonly deletedCount: number;
|
|
95
|
+
}>;
|
|
96
|
+
/**
|
|
97
|
+
* Request file URLs from UploadThing storage.
|
|
98
|
+
* @param {string | string[]} fileKeys
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* const data = await getFileUrls("2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg");
|
|
102
|
+
* console.log(data); // [{key: "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg", url: "https://uploadthing.com/f/2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg"}]
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* const data = await getFileUrls(["2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg","1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg"])
|
|
106
|
+
* console.log(data) // [{key: "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg", url: "https://uploadthing.com/f/2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg" },{key: "1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg", url: "https://uploadthing.com/f/1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg"}]
|
|
107
|
+
*
|
|
108
|
+
* @deprecated - See https://docs.uploadthing.com/working-with-files#accessing-files for info how to access files
|
|
109
|
+
*/
|
|
110
|
+
getFileUrls: (keys: string[] | string, opts?: GetFileUrlsOptions) => Promise<{
|
|
111
|
+
readonly data: readonly {
|
|
112
|
+
readonly url: string;
|
|
113
|
+
readonly key: string;
|
|
114
|
+
}[];
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Request file list from UploadThing storage.
|
|
118
|
+
* @param {object} opts
|
|
119
|
+
* @param {number} opts.limit The maximum number of files to return
|
|
120
|
+
* @param {number} opts.offset The number of files to skip
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* const data = await listFiles({ limit: 1 });
|
|
124
|
+
* console.log(data); // { key: "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg", id: "2e0fdb64-9957-4262-8e45-f372ba903ac8" }
|
|
125
|
+
*/
|
|
126
|
+
listFiles: (opts?: ListFilesOptions) => Promise<{
|
|
127
|
+
readonly files: readonly {
|
|
128
|
+
readonly name: string;
|
|
129
|
+
readonly size: number;
|
|
130
|
+
readonly customId: string | null;
|
|
131
|
+
readonly key: string;
|
|
132
|
+
readonly id: string;
|
|
133
|
+
readonly status: "Deletion Pending" | "Failed" | "Uploaded" | "Uploading";
|
|
134
|
+
readonly uploadedAt: number;
|
|
135
|
+
}[];
|
|
136
|
+
readonly hasMore: boolean;
|
|
137
|
+
}>;
|
|
138
|
+
renameFiles: (updates: RenameFileUpdate | RenameFileUpdate[]) => Promise<{
|
|
139
|
+
readonly success: boolean;
|
|
140
|
+
}>;
|
|
141
|
+
getUsageInfo: () => Promise<{
|
|
142
|
+
readonly totalBytes: number;
|
|
143
|
+
readonly appTotalBytes: number;
|
|
144
|
+
readonly filesUploaded: number;
|
|
145
|
+
readonly limitBytes: number;
|
|
146
|
+
}>;
|
|
147
|
+
/**
|
|
148
|
+
* Generate a presigned url for a private file
|
|
149
|
+
* Unlike {@link getSignedURL}, this method does not make a fetch request to the UploadThing API
|
|
150
|
+
* and is the recommended way to generate a presigned url for a private file.
|
|
151
|
+
**/
|
|
152
|
+
generateSignedURL: (key: string, opts?: GetSignedURLOptions) => Promise<{
|
|
153
|
+
ufsUrl: string;
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* Request a presigned url for a private file(s)
|
|
157
|
+
* @remarks This method is no longer recommended as it makes a fetch
|
|
158
|
+
* request to the UploadThing API which incurs redundant latency. It
|
|
159
|
+
* will be deprecated in UploadThing v8 and removed in UploadThing v9.
|
|
160
|
+
*
|
|
161
|
+
* @see {@link generateSignedURL} for a more efficient way to generate a presigned url
|
|
162
|
+
**/
|
|
163
|
+
getSignedURL: (key: string, opts?: GetSignedURLOptions) => Promise<{
|
|
164
|
+
readonly url: string;
|
|
165
|
+
readonly ufsUrl: string;
|
|
166
|
+
}>;
|
|
167
|
+
/**
|
|
168
|
+
* Update the ACL of a file or set of files.
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* // Make a single file public
|
|
172
|
+
* await utapi.updateACL("2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg", "public-read");
|
|
173
|
+
*
|
|
174
|
+
* // Make multiple files private
|
|
175
|
+
* await utapi.updateACL(
|
|
176
|
+
* [
|
|
177
|
+
* "2e0fdb64-9957-4262-8e45-f372ba903ac8_image.jpg",
|
|
178
|
+
* "1649353b-04ea-48a2-9db7-31de7f562c8d_image2.jpg",
|
|
179
|
+
* ],
|
|
180
|
+
* "private",
|
|
181
|
+
* );
|
|
182
|
+
*/
|
|
183
|
+
updateACL: (keys: string | string[], acl: ACL, opts?: ACLUpdateOptions) => Promise<{
|
|
184
|
+
readonly success: boolean;
|
|
185
|
+
}>;
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/server.d.ts
|
|
189
|
+
type AdapterArgs$1 = {
|
|
190
|
+
req: Request;
|
|
191
|
+
};
|
|
192
|
+
declare const createUploadthing: <TErrorShape extends Json>(opts?: CreateBuilderOptions<TErrorShape>) => <TRouteOptions extends _uploadthing_shared0.RouteOptions>(input: _uploadthing_shared0.FileRouterInputConfig, config?: TRouteOptions | undefined) => UploadBuilder<{
|
|
193
|
+
_routeOptions: TRouteOptions;
|
|
194
|
+
_input: {
|
|
195
|
+
in: UnsetMarker;
|
|
196
|
+
out: UnsetMarker;
|
|
197
|
+
};
|
|
198
|
+
_metadata: UnsetMarker;
|
|
199
|
+
_adapterFnArgs: AdapterArgs$1;
|
|
200
|
+
_errorShape: TErrorShape;
|
|
201
|
+
_errorFn: UnsetMarker;
|
|
202
|
+
_output: UnsetMarker;
|
|
203
|
+
}>;
|
|
204
|
+
declare const createRouteHandler: <TRouter extends FileRouter>(opts: RouteHandlerOptions<TRouter>) => (args_0: Request | {
|
|
205
|
+
request: Request;
|
|
206
|
+
}) => Promise<Response>;
|
|
207
|
+
declare const extractRouterConfig: (router: FileRouter) => {
|
|
208
|
+
slug: string;
|
|
209
|
+
config: _uploadthing_shared0.ExpandedRouteConfig;
|
|
210
|
+
}[];
|
|
211
|
+
//#endregion
|
|
212
|
+
export { type FileRouter, UTApi, UTFile, UTFiles, UploadThingError, createBuilder, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion, extractRouterConfig, makeAdapterHandler };
|
|
213
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/_internal/handler.ts","../src/sdk/ut-file.ts","../src/sdk/index.ts","../src/server.ts"],"sourcesContent":[],"mappings":";;;;;;;;;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