@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,120 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const require_package = require('./package-BQ_k22T9.cjs');
|
|
3
|
+
const effect_Micro = require_chunk.__toESM(require("effect/Micro"));
|
|
4
|
+
const __uploadthing_shared = require_chunk.__toESM(require("@uploadthing/shared"));
|
|
5
|
+
const effect_Function = require_chunk.__toESM(require("effect/Function"));
|
|
6
|
+
|
|
7
|
+
//#region src/_internal/deferred.ts
|
|
8
|
+
const createDeferred = () => {
|
|
9
|
+
let resolve;
|
|
10
|
+
let reject;
|
|
11
|
+
const ac = new AbortController();
|
|
12
|
+
const promise = new Promise((res, rej) => {
|
|
13
|
+
resolve = res;
|
|
14
|
+
reject = rej;
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
promise,
|
|
18
|
+
ac,
|
|
19
|
+
resolve,
|
|
20
|
+
reject
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/_internal/random-hex.ts
|
|
26
|
+
const randomHexString = (function() {
|
|
27
|
+
const characters = "abcdef0123456789";
|
|
28
|
+
const charactersLength = 16;
|
|
29
|
+
return function(length) {
|
|
30
|
+
let result = "";
|
|
31
|
+
for (let i = 0; i < length; i++) result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
const generateTraceHeaders = () => {
|
|
36
|
+
const traceId = randomHexString(32);
|
|
37
|
+
const spanId = randomHexString(16);
|
|
38
|
+
const sampled = "01";
|
|
39
|
+
return {
|
|
40
|
+
b3: `${traceId}-${spanId}-${sampled}`,
|
|
41
|
+
traceparent: `00-${traceId}-${spanId}-${sampled}`
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/_internal/ut-reporter.ts
|
|
47
|
+
const createAPIRequestUrl = (config) => {
|
|
48
|
+
const url = new URL(config.url);
|
|
49
|
+
const queryParams = new URLSearchParams(url.search);
|
|
50
|
+
queryParams.set("actionType", config.actionType);
|
|
51
|
+
queryParams.set("slug", config.slug);
|
|
52
|
+
url.search = queryParams.toString();
|
|
53
|
+
return url;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Creates a "client" for reporting events to the UploadThing server via the user's API endpoint.
|
|
57
|
+
* Events are handled in "./handler.ts starting at L112"
|
|
58
|
+
*/
|
|
59
|
+
const createUTReporter = (cfg) => (type, payload) => effect_Micro.gen(function* () {
|
|
60
|
+
const url = createAPIRequestUrl({
|
|
61
|
+
url: cfg.url,
|
|
62
|
+
slug: cfg.endpoint,
|
|
63
|
+
actionType: type
|
|
64
|
+
});
|
|
65
|
+
const headers = new Headers(yield* effect_Micro.promise(async () => typeof cfg.headers === "function" ? await cfg.headers() : cfg.headers));
|
|
66
|
+
if (cfg.package) headers.set("x-uploadthing-package", cfg.package);
|
|
67
|
+
headers.set("x-uploadthing-version", require_package.version);
|
|
68
|
+
headers.set("Content-Type", "application/json");
|
|
69
|
+
headers.set("b3", cfg.traceHeaders.b3);
|
|
70
|
+
headers.set("traceparent", cfg.traceHeaders.traceparent);
|
|
71
|
+
const response = yield* (0, __uploadthing_shared.fetchEff)(url, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
body: JSON.stringify(payload),
|
|
74
|
+
headers
|
|
75
|
+
}).pipe(
|
|
76
|
+
effect_Micro.andThen(__uploadthing_shared.parseResponseJson),
|
|
77
|
+
/**
|
|
78
|
+
* We don't _need_ to validate the response here, just cast it for now.
|
|
79
|
+
* As of now, @effect/schema includes quite a few bytes we cut out by this...
|
|
80
|
+
* We have "strong typing" on the backend that ensures the shape should match.
|
|
81
|
+
*/
|
|
82
|
+
effect_Micro.map(effect_Function.unsafeCoerce),
|
|
83
|
+
effect_Micro.catchTag("FetchError", (e) => effect_Micro.fail(new __uploadthing_shared.UploadThingError({
|
|
84
|
+
code: "INTERNAL_CLIENT_ERROR",
|
|
85
|
+
message: `Failed to report event "${type}" to UploadThing server`,
|
|
86
|
+
cause: e
|
|
87
|
+
}))),
|
|
88
|
+
effect_Micro.catchTag("BadRequestError", (e) => effect_Micro.fail(new __uploadthing_shared.UploadThingError({
|
|
89
|
+
code: (0, __uploadthing_shared.getErrorTypeFromStatusCode)(e.status),
|
|
90
|
+
message: e.getMessage(),
|
|
91
|
+
cause: e.json
|
|
92
|
+
}))),
|
|
93
|
+
effect_Micro.catchTag("InvalidJson", (e) => effect_Micro.fail(new __uploadthing_shared.UploadThingError({
|
|
94
|
+
code: "INTERNAL_CLIENT_ERROR",
|
|
95
|
+
message: "Failed to parse response from UploadThing server",
|
|
96
|
+
cause: e
|
|
97
|
+
})))
|
|
98
|
+
);
|
|
99
|
+
return response;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
Object.defineProperty(exports, 'createDeferred', {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () {
|
|
106
|
+
return createDeferred;
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(exports, 'createUTReporter', {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return createUTReporter;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(exports, 'generateTraceHeaders', {
|
|
116
|
+
enumerable: true,
|
|
117
|
+
get: function () {
|
|
118
|
+
return generateTraceHeaders;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { version } from "./package-DpScpvTA.js";
|
|
2
|
+
import * as Micro from "effect/Micro";
|
|
3
|
+
import { UploadThingError, fetchEff, getErrorTypeFromStatusCode, parseResponseJson } from "@uploadthing/shared";
|
|
4
|
+
import { unsafeCoerce } from "effect/Function";
|
|
5
|
+
|
|
6
|
+
//#region src/_internal/deferred.ts
|
|
7
|
+
const createDeferred = () => {
|
|
8
|
+
let resolve;
|
|
9
|
+
let reject;
|
|
10
|
+
const ac = new AbortController();
|
|
11
|
+
const promise = new Promise((res, rej) => {
|
|
12
|
+
resolve = res;
|
|
13
|
+
reject = rej;
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
promise,
|
|
17
|
+
ac,
|
|
18
|
+
resolve,
|
|
19
|
+
reject
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/_internal/random-hex.ts
|
|
25
|
+
const randomHexString = (function() {
|
|
26
|
+
const characters = "abcdef0123456789";
|
|
27
|
+
const charactersLength = 16;
|
|
28
|
+
return function(length) {
|
|
29
|
+
let result = "";
|
|
30
|
+
for (let i = 0; i < length; i++) result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
const generateTraceHeaders = () => {
|
|
35
|
+
const traceId = randomHexString(32);
|
|
36
|
+
const spanId = randomHexString(16);
|
|
37
|
+
const sampled = "01";
|
|
38
|
+
return {
|
|
39
|
+
b3: `${traceId}-${spanId}-${sampled}`,
|
|
40
|
+
traceparent: `00-${traceId}-${spanId}-${sampled}`
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region src/_internal/ut-reporter.ts
|
|
46
|
+
const createAPIRequestUrl = (config) => {
|
|
47
|
+
const url = new URL(config.url);
|
|
48
|
+
const queryParams = new URLSearchParams(url.search);
|
|
49
|
+
queryParams.set("actionType", config.actionType);
|
|
50
|
+
queryParams.set("slug", config.slug);
|
|
51
|
+
url.search = queryParams.toString();
|
|
52
|
+
return url;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Creates a "client" for reporting events to the UploadThing server via the user's API endpoint.
|
|
56
|
+
* Events are handled in "./handler.ts starting at L112"
|
|
57
|
+
*/
|
|
58
|
+
const createUTReporter = (cfg) => (type, payload) => Micro.gen(function* () {
|
|
59
|
+
const url = createAPIRequestUrl({
|
|
60
|
+
url: cfg.url,
|
|
61
|
+
slug: cfg.endpoint,
|
|
62
|
+
actionType: type
|
|
63
|
+
});
|
|
64
|
+
const headers = new Headers(yield* Micro.promise(async () => typeof cfg.headers === "function" ? await cfg.headers() : cfg.headers));
|
|
65
|
+
if (cfg.package) headers.set("x-uploadthing-package", cfg.package);
|
|
66
|
+
headers.set("x-uploadthing-version", version);
|
|
67
|
+
headers.set("Content-Type", "application/json");
|
|
68
|
+
headers.set("b3", cfg.traceHeaders.b3);
|
|
69
|
+
headers.set("traceparent", cfg.traceHeaders.traceparent);
|
|
70
|
+
const response = yield* fetchEff(url, {
|
|
71
|
+
method: "POST",
|
|
72
|
+
body: JSON.stringify(payload),
|
|
73
|
+
headers
|
|
74
|
+
}).pipe(
|
|
75
|
+
Micro.andThen(parseResponseJson),
|
|
76
|
+
/**
|
|
77
|
+
* We don't _need_ to validate the response here, just cast it for now.
|
|
78
|
+
* As of now, @effect/schema includes quite a few bytes we cut out by this...
|
|
79
|
+
* We have "strong typing" on the backend that ensures the shape should match.
|
|
80
|
+
*/
|
|
81
|
+
Micro.map(unsafeCoerce),
|
|
82
|
+
Micro.catchTag("FetchError", (e) => Micro.fail(new UploadThingError({
|
|
83
|
+
code: "INTERNAL_CLIENT_ERROR",
|
|
84
|
+
message: `Failed to report event "${type}" to UploadThing server`,
|
|
85
|
+
cause: e
|
|
86
|
+
}))),
|
|
87
|
+
Micro.catchTag("BadRequestError", (e) => Micro.fail(new UploadThingError({
|
|
88
|
+
code: getErrorTypeFromStatusCode(e.status),
|
|
89
|
+
message: e.getMessage(),
|
|
90
|
+
cause: e.json
|
|
91
|
+
}))),
|
|
92
|
+
Micro.catchTag("InvalidJson", (e) => Micro.fail(new UploadThingError({
|
|
93
|
+
code: "INTERNAL_CLIENT_ERROR",
|
|
94
|
+
message: "Failed to parse response from UploadThing server",
|
|
95
|
+
cause: e
|
|
96
|
+
})))
|
|
97
|
+
);
|
|
98
|
+
return response;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
//#endregion
|
|
102
|
+
export { createDeferred, createUTReporter, generateTraceHeaders };
|
|
103
|
+
//# sourceMappingURL=ut-reporter-Dlppchbx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ut-reporter-Dlppchbx.js","names":["resolve!: (value: T) => void","reject!: (reason?: any) => void","length: number","config: {\n /**\n * URL to the UploadThing API endpoint\n * @example URL { /api/uploadthing }\n * @example URL { https://www.example.com/api/uploadthing }\n */\n url: URL;\n slug: string;\n actionType: typeof ActionType.Type;\n}","cfg: {\n url: URL;\n endpoint: string;\n package?: string | undefined;\n headers: HeadersInit | (() => MaybePromise<HeadersInit>) | undefined;\n traceHeaders: TraceHeaders;\n }"],"sources":["../src/_internal/deferred.ts","../src/_internal/random-hex.ts","../src/_internal/ut-reporter.ts"],"sourcesContent":["export type Deferred<T> = {\n resolve: (value: T) => void;\n reject: (reason?: any) => void;\n ac: AbortController;\n promise: Promise<T>;\n};\n\nexport const createDeferred = <T>(): Deferred<T> => {\n let resolve!: (value: T) => void;\n let reject!: (reason?: any) => void;\n const ac = new AbortController();\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, ac, resolve, reject };\n};\n","export const randomHexString = (function () {\n const characters = \"abcdef0123456789\";\n const charactersLength = characters.length;\n return function (length: number) {\n let result = \"\";\n for (let i = 0; i < length; i++) {\n result += characters.charAt(Math.floor(Math.random() * charactersLength));\n }\n return result;\n };\n})();\n\nexport type TraceHeaders = {\n b3: string;\n traceparent: string;\n};\n\nexport const generateTraceHeaders = (): TraceHeaders => {\n const traceId = randomHexString(32);\n const spanId = randomHexString(16);\n const sampled = \"01\";\n\n return {\n b3: `${traceId}-${spanId}-${sampled}`,\n traceparent: `00-${traceId}-${spanId}-${sampled}`,\n };\n};\n","import { unsafeCoerce } from \"effect/Function\";\nimport * as Micro from \"effect/Micro\";\n\nimport type { FetchContext, MaybePromise } from \"@uploadthing/shared\";\nimport {\n fetchEff,\n getErrorTypeFromStatusCode,\n parseResponseJson,\n UploadThingError,\n} from \"@uploadthing/shared\";\n\nimport * as pkgJson from \"../../package.json\";\nimport type { TraceHeaders } from \"./random-hex\";\nimport type { ActionType } from \"./shared-schemas\";\nimport type { UTEvents } from \"./types\";\n\nconst createAPIRequestUrl = (config: {\n /**\n * URL to the UploadThing API endpoint\n * @example URL { /api/uploadthing }\n * @example URL { https://www.example.com/api/uploadthing }\n */\n url: URL;\n slug: string;\n actionType: typeof ActionType.Type;\n}) => {\n const url = new URL(config.url);\n\n const queryParams = new URLSearchParams(url.search);\n queryParams.set(\"actionType\", config.actionType);\n queryParams.set(\"slug\", config.slug);\n\n url.search = queryParams.toString();\n return url;\n};\n\nexport type UTReporter = <TEvent extends keyof UTEvents>(\n type: TEvent,\n payload: UTEvents[TEvent][\"in\"],\n) => Micro.Micro<UTEvents[TEvent][\"out\"], UploadThingError, FetchContext>;\n\n/**\n * Creates a \"client\" for reporting events to the UploadThing server via the user's API endpoint.\n * Events are handled in \"./handler.ts starting at L112\"\n */\nexport const createUTReporter =\n (cfg: {\n url: URL;\n endpoint: string;\n package?: string | undefined;\n headers: HeadersInit | (() => MaybePromise<HeadersInit>) | undefined;\n traceHeaders: TraceHeaders;\n }): UTReporter =>\n (type, payload) =>\n Micro.gen(function* () {\n const url = createAPIRequestUrl({\n url: cfg.url,\n slug: cfg.endpoint,\n actionType: type,\n });\n const headers = new Headers(\n yield* Micro.promise(async () =>\n typeof cfg.headers === \"function\" ? await cfg.headers() : cfg.headers,\n ),\n );\n if (cfg.package) {\n headers.set(\"x-uploadthing-package\", cfg.package);\n }\n headers.set(\"x-uploadthing-version\", pkgJson.version);\n headers.set(\"Content-Type\", \"application/json\");\n headers.set(\"b3\", cfg.traceHeaders.b3);\n headers.set(\"traceparent\", cfg.traceHeaders.traceparent);\n\n const response = yield* fetchEff(url, {\n method: \"POST\",\n body: JSON.stringify(payload),\n headers,\n }).pipe(\n Micro.andThen(parseResponseJson),\n /**\n * We don't _need_ to validate the response here, just cast it for now.\n * As of now, @effect/schema includes quite a few bytes we cut out by this...\n * We have \"strong typing\" on the backend that ensures the shape should match.\n */\n Micro.map(unsafeCoerce<unknown, UTEvents[typeof type][\"out\"]>),\n Micro.catchTag(\"FetchError\", (e) =>\n Micro.fail(\n new UploadThingError({\n code: \"INTERNAL_CLIENT_ERROR\",\n message: `Failed to report event \"${type}\" to UploadThing server`,\n cause: e,\n }),\n ),\n ),\n Micro.catchTag(\"BadRequestError\", (e) =>\n Micro.fail(\n new UploadThingError({\n code: getErrorTypeFromStatusCode(e.status),\n message: e.getMessage(),\n cause: e.json,\n }),\n ),\n ),\n Micro.catchTag(\"InvalidJson\", (e) =>\n Micro.fail(\n new UploadThingError({\n code: \"INTERNAL_CLIENT_ERROR\",\n message: \"Failed to parse response from UploadThing server\",\n cause: e,\n }),\n ),\n ),\n );\n\n return response;\n });\n"],"mappings":";;;;;;AAOA,MAAa,iBAAiB,MAAsB;CAClD,IAAIA;CACJ,IAAIC;CACJ,MAAM,KAAK,IAAI;CACf,MAAM,UAAU,IAAI,QAAW,CAAC,KAAK,QAAQ;EAC3C,UAAU;EACV,SAAS;CACV;AACD,QAAO;EAAE;EAAS;EAAI;EAAS;CAAQ;AACxC;;;;AChBD,MAAa,mBAAmB,WAAY;CAC1C,MAAM,aAAa;CACnB,MAAM,mBAAmB;AACzB,QAAO,SAAUC,QAAgB;EAC/B,IAAI,SAAS;AACb,OAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,KAC1B,UAAU,WAAW,OAAO,KAAK,MAAM,KAAK,QAAQ,GAAG,iBAAiB,CAAC;AAE3E,SAAO;CACR;AACF,IAAG;AAOJ,MAAa,uBAAuB,MAAoB;CACtD,MAAM,UAAU,gBAAgB,GAAG;CACnC,MAAM,SAAS,gBAAgB,GAAG;CAClC,MAAM,UAAU;AAEhB,QAAO;EACL,IAAI,GAAG,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS;EACrC,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,SAAS;CAClD;AACF;;;;ACVD,MAAM,sBAAsB,CAACC,WASvB;CACJ,MAAM,MAAM,IAAI,IAAI,OAAO;CAE3B,MAAM,cAAc,IAAI,gBAAgB,IAAI;CAC5C,YAAY,IAAI,cAAc,OAAO,WAAW;CAChD,YAAY,IAAI,QAAQ,OAAO,KAAK;CAEpC,IAAI,SAAS,YAAY,UAAU;AACnC,QAAO;AACR;;;;;AAWD,MAAa,mBACX,CAACC,QAOD,CAAC,MAAM,YACL,MAAM,IAAI,aAAa;CACrB,MAAM,MAAM,oBAAoB;EAC9B,KAAK,IAAI;EACT,MAAM,IAAI;EACV,YAAY;CACb,EAAC;CACF,MAAM,UAAU,IAAI,QAClB,OAAO,MAAM,QAAQ,YACnB,OAAO,IAAI,YAAY,aAAa,MAAM,IAAI,SAAS,GAAG,IAAI,QAC/D;AAEH,KAAI,IAAI,SACN,QAAQ,IAAI,yBAAyB,IAAI,QAAQ;CAEnD,QAAQ,IAAI,iCAAyC;CACrD,QAAQ,IAAI,gBAAgB,mBAAmB;CAC/C,QAAQ,IAAI,MAAM,IAAI,aAAa,GAAG;CACtC,QAAQ,IAAI,eAAe,IAAI,aAAa,YAAY;CAExD,MAAM,WAAW,OAAO,SAAS,KAAK;EACpC,QAAQ;EACR,MAAM,KAAK,UAAU,QAAQ;EAC7B;CACD,EAAC,CAAC;EACD,MAAM,QAAQ,kBAAkB;;;;;;EAMhC,MAAM,IAAI,aAAoD;EAC9D,MAAM,SAAS,cAAc,CAAC,MAC5B,MAAM,KACJ,IAAI,iBAAiB;GACnB,MAAM;GACN,SAAS,CAAC,wBAAwB,EAAE,KAAK,uBAAuB,CAAC;GACjE,OAAO;EACR,GACF,CACF;EACD,MAAM,SAAS,mBAAmB,CAAC,MACjC,MAAM,KACJ,IAAI,iBAAiB;GACnB,MAAM,2BAA2B,EAAE,OAAO;GAC1C,SAAS,EAAE,YAAY;GACvB,OAAO,EAAE;EACV,GACF,CACF;EACD,MAAM,SAAS,eAAe,CAAC,MAC7B,MAAM,KACJ,IAAI,iBAAiB;GACnB,MAAM;GACN,SAAS;GACT,OAAO;EACR,GACF,CACF;EACF;AAED,QAAO;AACR,EAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const require_chunk = require('../dist/chunk-CUT6urMc.cjs');
|
|
2
|
+
require('../dist/package-BQ_k22T9.cjs');
|
|
3
|
+
require('../dist/deprecations-DPGpmqha.cjs');
|
|
4
|
+
require('../dist/shared-schemas-CG9VaBtT.cjs');
|
|
5
|
+
const require_upload_builder = require('../dist/upload-builder-D6Ken9H0.cjs');
|
|
6
|
+
const effect_Effect = require_chunk.__toESM(require("effect/Effect"));
|
|
7
|
+
const __effect_platform_HttpRouter = require_chunk.__toESM(require("@effect/platform/HttpRouter"));
|
|
8
|
+
const __effect_platform_HttpServerRequest = require_chunk.__toESM(require("@effect/platform/HttpServerRequest"));
|
|
9
|
+
const effect_Layer = require_chunk.__toESM(require("effect/Layer"));
|
|
10
|
+
|
|
11
|
+
//#region src/effect-platform.ts
|
|
12
|
+
const createUploadthing = (opts) => require_upload_builder.createBuilder(opts);
|
|
13
|
+
const createRouteHandler = (opts) => {
|
|
14
|
+
const router = effect_Effect.runSync(require_upload_builder.createRequestHandler(opts, "effect-platform"));
|
|
15
|
+
return __effect_platform_HttpRouter.provideServiceEffect(router, require_upload_builder.AdapterArguments, effect_Effect.map(__effect_platform_HttpServerRequest.HttpServerRequest, (serverRequest) => ({ req: serverRequest }))).pipe(effect_Effect.provide(effect_Layer.setConfigProvider(require_upload_builder.configProvider(opts.config))));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.UTFiles = require_upload_builder.UTFiles;
|
|
20
|
+
exports.createRouteHandler = createRouteHandler;
|
|
21
|
+
exports.createUploadthing = createUploadthing;
|
|
22
|
+
exports.experimental_UTRegion = require_upload_builder.UTRegion;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FileRouter, RouteHandlerConfig, UTFiles, UTRegion, UnsetMarker, UploadBuilder } from "../dist/types-DiVC1t2V.cjs";
|
|
2
|
+
import { CreateBuilderOptions } from "../dist/upload-builder-BUa7tovh.cjs";
|
|
3
|
+
import * as _uploadthing_shared6 from "@uploadthing/shared";
|
|
4
|
+
import { Json } from "@uploadthing/shared";
|
|
5
|
+
import * as _effect_platform_HttpBody0 from "@effect/platform/HttpBody";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as effect_Cause0 from "effect/Cause";
|
|
8
|
+
import * as _effect_platform_HttpServerResponse0 from "@effect/platform/HttpServerResponse";
|
|
9
|
+
import * as _effect_platform_HttpServerError0 from "@effect/platform/HttpServerError";
|
|
10
|
+
import * as effect_ConfigError0 from "effect/ConfigError";
|
|
11
|
+
import * as _effect_platform_HttpClient0 from "@effect/platform/HttpClient";
|
|
12
|
+
import * as HttpServerRequest from "@effect/platform/HttpServerRequest";
|
|
13
|
+
|
|
14
|
+
//#region src/effect-platform.d.ts
|
|
15
|
+
type AdapterArgs = {
|
|
16
|
+
req: HttpServerRequest.HttpServerRequest;
|
|
17
|
+
};
|
|
18
|
+
declare const createUploadthing: <TErrorShape extends Json>(opts?: CreateBuilderOptions<TErrorShape>) => <TRouteOptions extends _uploadthing_shared6.RouteOptions>(input: _uploadthing_shared6.FileRouterInputConfig, config?: TRouteOptions | undefined) => UploadBuilder<{
|
|
19
|
+
_routeOptions: TRouteOptions;
|
|
20
|
+
_input: {
|
|
21
|
+
in: UnsetMarker;
|
|
22
|
+
out: UnsetMarker;
|
|
23
|
+
};
|
|
24
|
+
_metadata: UnsetMarker;
|
|
25
|
+
_adapterFnArgs: AdapterArgs;
|
|
26
|
+
_errorShape: TErrorShape;
|
|
27
|
+
_errorFn: UnsetMarker;
|
|
28
|
+
_output: UnsetMarker;
|
|
29
|
+
}>;
|
|
30
|
+
declare const createRouteHandler: <TRouter extends FileRouter>(opts: {
|
|
31
|
+
router: TRouter;
|
|
32
|
+
/**
|
|
33
|
+
* @remarks In order to obey by Effect conventions, we have omitted the `config.fetch` and `config.logLevel` options.
|
|
34
|
+
* You can provide these layers on your own if you need to.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { Effect, Layer, Logger, LogLevel } from "effect";
|
|
39
|
+
* import { HttpClient } from "@effect/platform";
|
|
40
|
+
* // Set logLevel
|
|
41
|
+
* Logger.withMinimumLogLevel(LogLevel.Debug)
|
|
42
|
+
*
|
|
43
|
+
* // Override fetch implementation
|
|
44
|
+
* Layer.succeed(
|
|
45
|
+
* HttpClient.Fetch,
|
|
46
|
+
* myFetchImplementation,
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
config?: Omit<RouteHandlerConfig, "fetch" | "logLevel">;
|
|
51
|
+
}) => Effect.Effect<_effect_platform_HttpServerResponse0.HttpServerResponse, _effect_platform_HttpServerError0.RequestError | _effect_platform_HttpServerError0.RouteNotFound | _effect_platform_HttpBody0.HttpBodyError | effect_ConfigError0.ConfigError | effect_Cause0.NoSuchElementException, HttpServerRequest.HttpServerRequest | _effect_platform_HttpClient0.HttpClient>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { type FileRouter, UTFiles, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion };
|
|
54
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/effect-platform.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;KAuBK,WAAA;OACE,iBAAA,CAAkB;AAHE,CAAA;AAMd,cAAA,iBAEqC,EAAA,CAAA,oBAFI,IAEJ,CAAA,CAAA,IAAA,CAAA,EADzC,oBACyC,CADpB,WACoB,CAAA,EAAA,GAAA,CAAA,sBADrB,oBAAA,CAAa,YACQ,CAAA,CAAA,KAAA,EADR,oBAAA,CAAA,qBACQ,EAAA,MAAA,CAAA,EADR,aACQ,GAAA,SAAA,EAAA,gBAAA,CAAA;EAAA,aAAA,EADR,aACQ;EAAA,MAFI,EAAA;IACxB,EAAA,aAAA;IAArB,GAAA,aAAA;EAAoB,CAAA;EAAa,SAAA,aAAA;EAAA,cAAA,aAAA;EAAA,WAAA,aAAA;;;;cAG7B,qCAAsC;UACzC;;;;AAJgC;AAG1C;;;;;;;;;;;;;;EAsBC,MAAA,CAAA,EADU,IACV,CADe,kBACf,EAAA,OAAA,GAAA,UAAA,CAAA;MAAA,MAAA,CAAA,OADc,oCAAA,CACd,kBAAA,EAAA,iCAAA,CAAA,YAAA,GAAA,iCAAA,CAAA,aAAA,GAAA,0BAAA,CAAA,aAAA,GAAA,mBAAA,CAAA,WAAA,GAAA,aAAA,CAAA,wBAAA,iBAAA,CAAA,oBAAA,4BAAA,CAAA"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FileRouter, RouteHandlerConfig, UTFiles, UTRegion, UnsetMarker, UploadBuilder } from "../dist/types-Bs3w2d_3.js";
|
|
2
|
+
import { CreateBuilderOptions } from "../dist/upload-builder-BcFawEj0.js";
|
|
3
|
+
import * as _uploadthing_shared6 from "@uploadthing/shared";
|
|
4
|
+
import { Json } from "@uploadthing/shared";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as _effect_platform_HttpBody0 from "@effect/platform/HttpBody";
|
|
7
|
+
import * as _effect_platform_HttpClient0 from "@effect/platform/HttpClient";
|
|
8
|
+
import * as HttpServerRequest from "@effect/platform/HttpServerRequest";
|
|
9
|
+
import * as _effect_platform_HttpServerResponse0 from "@effect/platform/HttpServerResponse";
|
|
10
|
+
import * as effect_ConfigError0 from "effect/ConfigError";
|
|
11
|
+
import * as effect_Cause0 from "effect/Cause";
|
|
12
|
+
import * as _effect_platform_HttpServerError0 from "@effect/platform/HttpServerError";
|
|
13
|
+
|
|
14
|
+
//#region src/effect-platform.d.ts
|
|
15
|
+
type AdapterArgs = {
|
|
16
|
+
req: HttpServerRequest.HttpServerRequest;
|
|
17
|
+
};
|
|
18
|
+
declare const createUploadthing: <TErrorShape extends Json>(opts?: CreateBuilderOptions<TErrorShape>) => <TRouteOptions extends _uploadthing_shared6.RouteOptions>(input: _uploadthing_shared6.FileRouterInputConfig, config?: TRouteOptions | undefined) => UploadBuilder<{
|
|
19
|
+
_routeOptions: TRouteOptions;
|
|
20
|
+
_input: {
|
|
21
|
+
in: UnsetMarker;
|
|
22
|
+
out: UnsetMarker;
|
|
23
|
+
};
|
|
24
|
+
_metadata: UnsetMarker;
|
|
25
|
+
_adapterFnArgs: AdapterArgs;
|
|
26
|
+
_errorShape: TErrorShape;
|
|
27
|
+
_errorFn: UnsetMarker;
|
|
28
|
+
_output: UnsetMarker;
|
|
29
|
+
}>;
|
|
30
|
+
declare const createRouteHandler: <TRouter extends FileRouter>(opts: {
|
|
31
|
+
router: TRouter;
|
|
32
|
+
/**
|
|
33
|
+
* @remarks In order to obey by Effect conventions, we have omitted the `config.fetch` and `config.logLevel` options.
|
|
34
|
+
* You can provide these layers on your own if you need to.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { Effect, Layer, Logger, LogLevel } from "effect";
|
|
39
|
+
* import { HttpClient } from "@effect/platform";
|
|
40
|
+
* // Set logLevel
|
|
41
|
+
* Logger.withMinimumLogLevel(LogLevel.Debug)
|
|
42
|
+
*
|
|
43
|
+
* // Override fetch implementation
|
|
44
|
+
* Layer.succeed(
|
|
45
|
+
* HttpClient.Fetch,
|
|
46
|
+
* myFetchImplementation,
|
|
47
|
+
* );
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
config?: Omit<RouteHandlerConfig, "fetch" | "logLevel">;
|
|
51
|
+
}) => Effect.Effect<_effect_platform_HttpServerResponse0.HttpServerResponse, _effect_platform_HttpServerError0.RequestError | _effect_platform_HttpServerError0.RouteNotFound | _effect_platform_HttpBody0.HttpBodyError | effect_ConfigError0.ConfigError | effect_Cause0.NoSuchElementException, HttpServerRequest.HttpServerRequest | _effect_platform_HttpClient0.HttpClient>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { type FileRouter, UTFiles, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion };
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/effect-platform.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;KAuBK,WAAA;OACE,iBAAA,CAAkB;AAHE,CAAA;AAMd,cAAA,iBAEqC,EAAA,CAAA,oBAFI,IAEJ,CAAA,CAAA,IAAA,CAAA,EADzC,oBACyC,CADpB,WACoB,CAAA,EAAA,GAAA,CAAA,sBADrB,oBAAA,CAAa,YACQ,CAAA,CAAA,KAAA,EADR,oBAAA,CAAA,qBACQ,EAAA,MAAA,CAAA,EADR,aACQ,GAAA,SAAA,EAAA,gBAAA,CAAA;EAAA,aAAA,EADR,aACQ;EAAA,MAFI,EAAA;IACxB,EAAA,aAAA;IAArB,GAAA,aAAA;EAAoB,CAAA;EAAa,SAAA,aAAA;EAAA,cAAA,aAAA;EAAA,WAAA,aAAA;;;;cAG7B,qCAAsC;UACzC;;;;AAJgC;AAG1C;;;;;;;;;;;;;;EAsBC,MAAA,CAAA,EADU,IACV,CADe,kBACf,EAAA,OAAA,GAAA,UAAA,CAAA;MAAA,MAAA,CAAA,OADc,oCAAA,CACd,kBAAA,EAAA,iCAAA,CAAA,YAAA,GAAA,iCAAA,CAAA,aAAA,GAAA,0BAAA,CAAA,aAAA,GAAA,mBAAA,CAAA,WAAA,GAAA,aAAA,CAAA,wBAAA,iBAAA,CAAA,oBAAA,4BAAA,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "../dist/package-DpScpvTA.js";
|
|
2
|
+
import "../dist/deprecations-pLmw6Ytd.js";
|
|
3
|
+
import "../dist/shared-schemas-BmG5ARoX.js";
|
|
4
|
+
import { AdapterArguments, UTFiles, UTRegion, configProvider, createBuilder, createRequestHandler } from "../dist/upload-builder-BlFOAnsv.js";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as HttpRouter from "@effect/platform/HttpRouter";
|
|
7
|
+
import * as HttpServerRequest from "@effect/platform/HttpServerRequest";
|
|
8
|
+
import * as Layer from "effect/Layer";
|
|
9
|
+
|
|
10
|
+
//#region src/effect-platform.ts
|
|
11
|
+
const createUploadthing = (opts) => createBuilder(opts);
|
|
12
|
+
const createRouteHandler = (opts) => {
|
|
13
|
+
const router = Effect.runSync(createRequestHandler(opts, "effect-platform"));
|
|
14
|
+
return HttpRouter.provideServiceEffect(router, AdapterArguments, Effect.map(HttpServerRequest.HttpServerRequest, (serverRequest) => ({ req: serverRequest }))).pipe(Effect.provide(Layer.setConfigProvider(configProvider(opts.config))));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { UTFiles, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion };
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["opts?: CreateBuilderOptions<TErrorShape>","opts: {\n router: TRouter;\n /**\n * @remarks In order to obey by Effect conventions, we have omitted the `config.fetch` and `config.logLevel` options.\n * You can provide these layers on your own if you need to.\n *\n * @example\n * ```ts\n * import { Effect, Layer, Logger, LogLevel } from \"effect\";\n * import { HttpClient } from \"@effect/platform\";\n\n * // Set logLevel\n * Logger.withMinimumLogLevel(LogLevel.Debug)\n * \n * // Override fetch implementation\n * Layer.succeed(\n * HttpClient.Fetch,\n * myFetchImplementation,\n * );\n * ```\n */\n config?: Omit<RouteHandlerConfig, \"fetch\" | \"logLevel\">;\n}"],"sources":["../src/effect-platform.ts"],"sourcesContent":["import * as HttpRouter from \"@effect/platform/HttpRouter\";\nimport * as HttpServerRequest from \"@effect/platform/HttpServerRequest\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\n\nimport type { Json } from \"@uploadthing/shared\";\n\nimport { configProvider } from \"./_internal/config\";\nimport { AdapterArguments, createRequestHandler } from \"./_internal/handler\";\nimport type { CreateBuilderOptions } from \"./_internal/upload-builder\";\nimport { createBuilder } from \"./_internal/upload-builder\";\nimport type { FileRouter, RouteHandlerConfig } from \"./types\";\n\nexport {\n UTFiles,\n /**\n * This is an experimental feature.\n * You need to be feature flagged on our backend to use this\n */\n UTRegion as experimental_UTRegion,\n} from \"./_internal/types\";\nexport type { FileRouter };\n\ntype AdapterArgs = {\n req: HttpServerRequest.HttpServerRequest;\n};\n\nexport const createUploadthing = <TErrorShape extends Json>(\n opts?: CreateBuilderOptions<TErrorShape>,\n) => createBuilder<AdapterArgs, TErrorShape>(opts);\n\nexport const createRouteHandler = <TRouter extends FileRouter>(opts: {\n router: TRouter;\n /**\n * @remarks In order to obey by Effect conventions, we have omitted the `config.fetch` and `config.logLevel` options.\n * You can provide these layers on your own if you need to.\n *\n * @example\n * ```ts\n * import { Effect, Layer, Logger, LogLevel } from \"effect\";\n * import { HttpClient } from \"@effect/platform\";\n\n * // Set logLevel\n * Logger.withMinimumLogLevel(LogLevel.Debug)\n * \n * // Override fetch implementation\n * Layer.succeed(\n * HttpClient.Fetch,\n * myFetchImplementation,\n * );\n * ```\n */\n config?: Omit<RouteHandlerConfig, \"fetch\" | \"logLevel\">;\n}) => {\n const router = Effect.runSync(\n createRequestHandler<TRouter>(opts, \"effect-platform\"),\n );\n\n return HttpRouter.provideServiceEffect(\n router,\n AdapterArguments,\n Effect.map(\n HttpServerRequest.HttpServerRequest,\n (serverRequest) =>\n ({\n req: serverRequest,\n }) satisfies AdapterArgs,\n ),\n ).pipe(Effect.provide(Layer.setConfigProvider(configProvider(opts.config))));\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAa,oBAAoB,CAC/BA,SACG,cAAwC,KAAK;AAElD,MAAa,qBAAqB,CAA6BC,SAsBzD;CACJ,MAAM,SAAS,OAAO,QACpB,qBAA8B,MAAM,kBAAkB,CACvD;AAED,QAAO,WAAW,qBAChB,QACA,kBACA,OAAO,IACL,kBAAkB,mBAClB,CAAC,mBACE,EACC,KAAK,cACN,GACJ,CACF,CAAC,KAAK,OAAO,QAAQ,MAAM,kBAAkB,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC;AAC7E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const require_chunk = require('../dist/chunk-CUT6urMc.cjs');
|
|
2
|
+
require('../dist/package-BQ_k22T9.cjs');
|
|
3
|
+
require('../dist/deprecations-DPGpmqha.cjs');
|
|
4
|
+
require('../dist/shared-schemas-CG9VaBtT.cjs');
|
|
5
|
+
const require_upload_builder = require('../dist/upload-builder-D6Ken9H0.cjs');
|
|
6
|
+
const require_to_web_request = require('../dist/to-web-request-BQtxSXgE.cjs');
|
|
7
|
+
const effect_Effect = require_chunk.__toESM(require("effect/Effect"));
|
|
8
|
+
const node_stream = require_chunk.__toESM(require("node:stream"));
|
|
9
|
+
const express = require_chunk.__toESM(require("express"));
|
|
10
|
+
|
|
11
|
+
//#region src/express.ts
|
|
12
|
+
const createUploadthing = (opts) => require_upload_builder.createBuilder(opts);
|
|
13
|
+
const createRouteHandler = (opts) => {
|
|
14
|
+
const handler = require_upload_builder.makeAdapterHandler((req, res) => effect_Effect.succeed({
|
|
15
|
+
req,
|
|
16
|
+
res
|
|
17
|
+
}), (req) => effect_Effect.flatMap(require_to_web_request.getPostBody({ req }), (body) => require_to_web_request.toWebRequest(req, body)).pipe(effect_Effect.orDie), opts, "express");
|
|
18
|
+
return (0, express.Router)().all("/", async (req, res) => {
|
|
19
|
+
const response = await handler(req, res);
|
|
20
|
+
res.writeHead(response.status, Object.fromEntries(response.headers));
|
|
21
|
+
if (response.body) node_stream.Readable.fromWeb(response.body).pipe(res);
|
|
22
|
+
else res.end();
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.UTFiles = require_upload_builder.UTFiles;
|
|
28
|
+
exports.createRouteHandler = createRouteHandler;
|
|
29
|
+
exports.createUploadthing = createUploadthing;
|
|
30
|
+
exports.experimental_UTRegion = require_upload_builder.UTRegion;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FileRouter, RouteHandlerOptions, UTFiles, UTRegion, UnsetMarker, UploadBuilder } from "../dist/types-DiVC1t2V.cjs";
|
|
2
|
+
import { CreateBuilderOptions } from "../dist/upload-builder-BUa7tovh.cjs";
|
|
3
|
+
import * as _uploadthing_shared10 from "@uploadthing/shared";
|
|
4
|
+
import { Json } from "@uploadthing/shared";
|
|
5
|
+
import { Request, Response, Router } from "express";
|
|
6
|
+
|
|
7
|
+
//#region src/express.d.ts
|
|
8
|
+
|
|
9
|
+
type AdapterArgs = {
|
|
10
|
+
req: Request;
|
|
11
|
+
res: Response;
|
|
12
|
+
};
|
|
13
|
+
declare const createUploadthing: <TErrorShape extends Json>(opts?: CreateBuilderOptions<TErrorShape>) => <TRouteOptions extends _uploadthing_shared10.RouteOptions>(input: _uploadthing_shared10.FileRouterInputConfig, config?: TRouteOptions | undefined) => UploadBuilder<{
|
|
14
|
+
_routeOptions: TRouteOptions;
|
|
15
|
+
_input: {
|
|
16
|
+
in: UnsetMarker;
|
|
17
|
+
out: UnsetMarker;
|
|
18
|
+
};
|
|
19
|
+
_metadata: UnsetMarker;
|
|
20
|
+
_adapterFnArgs: AdapterArgs;
|
|
21
|
+
_errorShape: TErrorShape;
|
|
22
|
+
_errorFn: UnsetMarker;
|
|
23
|
+
_output: UnsetMarker;
|
|
24
|
+
}>;
|
|
25
|
+
declare const createRouteHandler: <TRouter extends FileRouter>(opts: RouteHandlerOptions<TRouter>) => Router;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { type FileRouter, UTFiles, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion };
|
|
28
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/express.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+BA,KALK,WAAA,GAKQ;EAEqC,GAAA,EAN3C,OAM2C;EAAA,GAFI,EAH/C,QAG+C;CAAI;AACjD,cADI,iBACJ,EAAA,CAAA,oBAD6C,IAC7C,CAAA,CAAA,IAAA,CAAA,EAAA,oBAAA,CAAqB,WAArB,CAAA,EAAA,GAAA,CAAA,sBAAoB,qBAAA,CAAa,YAAjC,CAAA,CAAA,KAAA,EAAiC,qBAAA,CAAA,qBAAjC,EAAA,MAAA,CAAA,EAAiC,aAAjC,GAAA,SAAA,EAAA,gBAAA,CAAA;EAAoB,aAAA,EAAa,aAAA;EAAA,MAAA,EAAA;IAAA,EAAA,aAAA;IAAA,GAAA,aAAA;;;;;;;;cAG7B,qCAAsC,kBAC3C,oBAAoB,aACzB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FileRouter, RouteHandlerOptions, UTFiles, UTRegion, UnsetMarker, UploadBuilder } from "../dist/types-Bs3w2d_3.js";
|
|
2
|
+
import { CreateBuilderOptions } from "../dist/upload-builder-BcFawEj0.js";
|
|
3
|
+
import * as _uploadthing_shared10 from "@uploadthing/shared";
|
|
4
|
+
import { Json } from "@uploadthing/shared";
|
|
5
|
+
import { Request, Response, Router } from "express";
|
|
6
|
+
|
|
7
|
+
//#region src/express.d.ts
|
|
8
|
+
|
|
9
|
+
type AdapterArgs = {
|
|
10
|
+
req: Request;
|
|
11
|
+
res: Response;
|
|
12
|
+
};
|
|
13
|
+
declare const createUploadthing: <TErrorShape extends Json>(opts?: CreateBuilderOptions<TErrorShape>) => <TRouteOptions extends _uploadthing_shared10.RouteOptions>(input: _uploadthing_shared10.FileRouterInputConfig, config?: TRouteOptions | undefined) => UploadBuilder<{
|
|
14
|
+
_routeOptions: TRouteOptions;
|
|
15
|
+
_input: {
|
|
16
|
+
in: UnsetMarker;
|
|
17
|
+
out: UnsetMarker;
|
|
18
|
+
};
|
|
19
|
+
_metadata: UnsetMarker;
|
|
20
|
+
_adapterFnArgs: AdapterArgs;
|
|
21
|
+
_errorShape: TErrorShape;
|
|
22
|
+
_errorFn: UnsetMarker;
|
|
23
|
+
_output: UnsetMarker;
|
|
24
|
+
}>;
|
|
25
|
+
declare const createRouteHandler: <TRouter extends FileRouter>(opts: RouteHandlerOptions<TRouter>) => Router;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { type FileRouter, UTFiles, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion };
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/express.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA+BA,KALK,WAAA,GAKQ;EAEqC,GAAA,EAN3C,OAM2C;EAAA,GAFI,EAH/C,QAG+C;CAAI;AACjD,cADI,iBACJ,EAAA,CAAA,oBAD6C,IAC7C,CAAA,CAAA,IAAA,CAAA,EAAA,oBAAA,CAAqB,WAArB,CAAA,EAAA,GAAA,CAAA,sBAAoB,qBAAA,CAAa,YAAjC,CAAA,CAAA,KAAA,EAAiC,qBAAA,CAAA,qBAAjC,EAAA,MAAA,CAAA,EAAiC,aAAjC,GAAA,SAAA,EAAA,gBAAA,CAAA;EAAoB,aAAA,EAAa,aAAA;EAAA,MAAA,EAAA;IAAA,EAAA,aAAA;IAAA,GAAA,aAAA;;;;;;;;cAG7B,qCAAsC,kBAC3C,oBAAoB,aACzB"}
|
package/express/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "../dist/package-DpScpvTA.js";
|
|
2
|
+
import "../dist/deprecations-pLmw6Ytd.js";
|
|
3
|
+
import "../dist/shared-schemas-BmG5ARoX.js";
|
|
4
|
+
import { UTFiles, UTRegion, createBuilder, makeAdapterHandler } from "../dist/upload-builder-BlFOAnsv.js";
|
|
5
|
+
import { getPostBody, toWebRequest } from "../dist/to-web-request-DhP0wXG-.js";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import { Readable } from "node:stream";
|
|
8
|
+
import { Router } from "express";
|
|
9
|
+
|
|
10
|
+
//#region src/express.ts
|
|
11
|
+
const createUploadthing = (opts) => createBuilder(opts);
|
|
12
|
+
const createRouteHandler = (opts) => {
|
|
13
|
+
const handler = makeAdapterHandler((req, res) => Effect.succeed({
|
|
14
|
+
req,
|
|
15
|
+
res
|
|
16
|
+
}), (req) => Effect.flatMap(getPostBody({ req }), (body) => toWebRequest(req, body)).pipe(Effect.orDie), opts, "express");
|
|
17
|
+
return Router().all("/", async (req, res) => {
|
|
18
|
+
const response = await handler(req, res);
|
|
19
|
+
res.writeHead(response.status, Object.fromEntries(response.headers));
|
|
20
|
+
if (response.body) Readable.fromWeb(response.body).pipe(res);
|
|
21
|
+
else res.end();
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { UTFiles, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion };
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["opts?: CreateBuilderOptions<TErrorShape>","opts: RouteHandlerOptions<TRouter>","ExpressRouter"],"sources":["../src/express.ts"],"sourcesContent":["import { Readable } from \"node:stream\";\nimport * as Effect from \"effect/Effect\";\nimport type {\n Request as ExpressRequest,\n Response as ExpressResponse,\n} from \"express\";\nimport { Router as ExpressRouter } from \"express\";\n\nimport type { Json } from \"@uploadthing/shared\";\n\nimport { makeAdapterHandler } from \"./_internal/handler\";\nimport { getPostBody, toWebRequest } from \"./_internal/to-web-request\";\nimport type { CreateBuilderOptions } from \"./_internal/upload-builder\";\nimport { createBuilder } from \"./_internal/upload-builder\";\nimport type { FileRouter, RouteHandlerOptions } from \"./types\";\n\nexport {\n UTFiles,\n /**\n * This is an experimental feature.\n * You need to be feature flagged on our backend to use this\n */\n UTRegion as experimental_UTRegion,\n} from \"./_internal/types\";\nexport type { FileRouter };\n\ntype AdapterArgs = {\n req: ExpressRequest;\n res: ExpressResponse;\n};\n\nexport const createUploadthing = <TErrorShape extends Json>(\n opts?: CreateBuilderOptions<TErrorShape>,\n) => createBuilder<AdapterArgs, TErrorShape>(opts);\n\nexport const createRouteHandler = <TRouter extends FileRouter>(\n opts: RouteHandlerOptions<TRouter>,\n): ExpressRouter => {\n const handler = makeAdapterHandler<\n [ExpressRequest, ExpressResponse],\n AdapterArgs\n >(\n (req, res) => Effect.succeed({ req, res }),\n (req) =>\n Effect.flatMap(getPostBody({ req }), (body) =>\n toWebRequest(req, body),\n ).pipe(Effect.orDie),\n opts,\n \"express\",\n );\n\n return ExpressRouter().all(\"/\", async (req, res) => {\n const response = await handler(req, res);\n res.writeHead(response.status, Object.fromEntries(response.headers));\n if (response.body) {\n // Slight type mismatch in `node:stream.ReadableStream` and Fetch's `ReadableStream`.\n Readable.fromWeb(response.body as never).pipe(res);\n } else {\n res.end();\n }\n });\n};\n"],"mappings":";;;;;;;;;;AA+BA,MAAa,oBAAoB,CAC/BA,SACG,cAAwC,KAAK;AAElD,MAAa,qBAAqB,CAChCC,SACkB;CAClB,MAAM,UAAU,mBAId,CAAC,KAAK,QAAQ,OAAO,QAAQ;EAAE;EAAK;CAAK,EAAC,EAC1C,CAAC,QACC,OAAO,QAAQ,YAAY,EAAE,IAAK,EAAC,EAAE,CAAC,SACpC,aAAa,KAAK,KAAK,CACxB,CAAC,KAAK,OAAO,MAAM,EACtB,MACA,UACD;AAED,QAAOC,QAAe,CAAC,IAAI,KAAK,OAAO,KAAK,QAAQ;EAClD,MAAM,WAAW,MAAM,QAAQ,KAAK,IAAI;EACxC,IAAI,UAAU,SAAS,QAAQ,OAAO,YAAY,SAAS,QAAQ,CAAC;AACpE,MAAI,SAAS,MAEX,SAAS,QAAQ,SAAS,KAAc,CAAC,KAAK,IAAI;OAElD,IAAI,KAAK;CAEZ,EAAC;AACH"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const require_chunk = require('../dist/chunk-CUT6urMc.cjs');
|
|
2
|
+
require('../dist/package-BQ_k22T9.cjs');
|
|
3
|
+
require('../dist/deprecations-DPGpmqha.cjs');
|
|
4
|
+
require('../dist/shared-schemas-CG9VaBtT.cjs');
|
|
5
|
+
const require_upload_builder = require('../dist/upload-builder-D6Ken9H0.cjs');
|
|
6
|
+
const require_to_web_request = require('../dist/to-web-request-BQtxSXgE.cjs');
|
|
7
|
+
const effect_Effect = require_chunk.__toESM(require("effect/Effect"));
|
|
8
|
+
|
|
9
|
+
//#region src/fastify.ts
|
|
10
|
+
const createUploadthing = (opts) => require_upload_builder.createBuilder(opts);
|
|
11
|
+
const createRouteHandler = (fastify, opts, done) => {
|
|
12
|
+
const handler = require_upload_builder.makeAdapterHandler((req, res) => effect_Effect.succeed({
|
|
13
|
+
req,
|
|
14
|
+
res
|
|
15
|
+
}), (req) => require_to_web_request.toWebRequest(req), opts, "fastify");
|
|
16
|
+
fastify.all("/api/uploadthing", async (req, res) => {
|
|
17
|
+
const response = await handler(req, res);
|
|
18
|
+
return res.status(response.status).headers(Object.fromEntries(response.headers)).send(response.body);
|
|
19
|
+
});
|
|
20
|
+
done();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.UTFiles = require_upload_builder.UTFiles;
|
|
25
|
+
exports.createRouteHandler = createRouteHandler;
|
|
26
|
+
exports.createUploadthing = createUploadthing;
|
|
27
|
+
exports.experimental_UTRegion = require_upload_builder.UTRegion;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FileRouter, RouteHandlerOptions, UTFiles, UTRegion, UnsetMarker, UploadBuilder } from "../dist/types-DiVC1t2V.cjs";
|
|
2
|
+
import { CreateBuilderOptions } from "../dist/upload-builder-BUa7tovh.cjs";
|
|
3
|
+
import * as _uploadthing_shared8 from "@uploadthing/shared";
|
|
4
|
+
import { Json } from "@uploadthing/shared";
|
|
5
|
+
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
6
|
+
|
|
7
|
+
//#region src/fastify.d.ts
|
|
8
|
+
|
|
9
|
+
type AdapterArgs = {
|
|
10
|
+
req: FastifyRequest;
|
|
11
|
+
res: FastifyReply;
|
|
12
|
+
};
|
|
13
|
+
declare const createUploadthing: <TErrorShape extends Json>(opts?: CreateBuilderOptions<TErrorShape>) => <TRouteOptions extends _uploadthing_shared8.RouteOptions>(input: _uploadthing_shared8.FileRouterInputConfig, config?: TRouteOptions | undefined) => UploadBuilder<{
|
|
14
|
+
_routeOptions: TRouteOptions;
|
|
15
|
+
_input: {
|
|
16
|
+
in: UnsetMarker;
|
|
17
|
+
out: UnsetMarker;
|
|
18
|
+
};
|
|
19
|
+
_metadata: UnsetMarker;
|
|
20
|
+
_adapterFnArgs: AdapterArgs;
|
|
21
|
+
_errorShape: TErrorShape;
|
|
22
|
+
_errorFn: UnsetMarker;
|
|
23
|
+
_output: UnsetMarker;
|
|
24
|
+
}>;
|
|
25
|
+
declare const createRouteHandler: <TRouter extends FileRouter>(fastify: FastifyInstance, opts: RouteHandlerOptions<TRouter>, done: (err?: Error) => void) => void;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { type FileRouter, UTFiles, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion };
|
|
28
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/fastify.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAuBmB,KAFd,WAAA,GAEc;EAGN,GAAA,EAJN,cAIM;EAEqC,GAAA,EAL3C,YAK2C;CAAA;AADpB,cADjB,iBACiB,EAAA,CAAA,oBADwB,IACxB,CAAA,CAAA,IAAA,CAAA,EAArB,oBAAqB,CAAA,WAAA,CAAA,EAAA,GAAA,CAAA,sBAAD,oBAAA,CAAa,YAAZ,CAAA,CAAA,KAAA,EAAY,oBAAA,CAAA,qBAAZ,EAAA,MAAA,CAAA,EAAY,aAAZ,GAAA,SAAA,EAAA,gBAAA,CAAA;EAAW,aAAhC,EAAiC,aAAjC;EAAoB,MAAA,EAAA;IAAa,EAAA,aAAA;IAAA,GAAA,aAAA;EAAA,CAAA;;;;;;;cAG7B,qCAAsC,qBACxC,uBACH,oBAAoB,uBACb"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FileRouter, RouteHandlerOptions, UTFiles, UTRegion, UnsetMarker, UploadBuilder } from "../dist/types-Bs3w2d_3.js";
|
|
2
|
+
import { CreateBuilderOptions } from "../dist/upload-builder-BcFawEj0.js";
|
|
3
|
+
import * as _uploadthing_shared8 from "@uploadthing/shared";
|
|
4
|
+
import { Json } from "@uploadthing/shared";
|
|
5
|
+
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
|
6
|
+
|
|
7
|
+
//#region src/fastify.d.ts
|
|
8
|
+
|
|
9
|
+
type AdapterArgs = {
|
|
10
|
+
req: FastifyRequest;
|
|
11
|
+
res: FastifyReply;
|
|
12
|
+
};
|
|
13
|
+
declare const createUploadthing: <TErrorShape extends Json>(opts?: CreateBuilderOptions<TErrorShape>) => <TRouteOptions extends _uploadthing_shared8.RouteOptions>(input: _uploadthing_shared8.FileRouterInputConfig, config?: TRouteOptions | undefined) => UploadBuilder<{
|
|
14
|
+
_routeOptions: TRouteOptions;
|
|
15
|
+
_input: {
|
|
16
|
+
in: UnsetMarker;
|
|
17
|
+
out: UnsetMarker;
|
|
18
|
+
};
|
|
19
|
+
_metadata: UnsetMarker;
|
|
20
|
+
_adapterFnArgs: AdapterArgs;
|
|
21
|
+
_errorShape: TErrorShape;
|
|
22
|
+
_errorFn: UnsetMarker;
|
|
23
|
+
_output: UnsetMarker;
|
|
24
|
+
}>;
|
|
25
|
+
declare const createRouteHandler: <TRouter extends FileRouter>(fastify: FastifyInstance, opts: RouteHandlerOptions<TRouter>, done: (err?: Error) => void) => void;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { type FileRouter, UTFiles, createRouteHandler, createUploadthing, UTRegion as experimental_UTRegion };
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/fastify.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAuBmB,KAFd,WAAA,GAEc;EAGN,GAAA,EAJN,cAIM;EAEqC,GAAA,EAL3C,YAK2C;CAAA;AADpB,cADjB,iBACiB,EAAA,CAAA,oBADwB,IACxB,CAAA,CAAA,IAAA,CAAA,EAArB,oBAAqB,CAAA,WAAA,CAAA,EAAA,GAAA,CAAA,sBAAD,oBAAA,CAAa,YAAZ,CAAA,CAAA,KAAA,EAAY,oBAAA,CAAA,qBAAZ,EAAA,MAAA,CAAA,EAAY,aAAZ,GAAA,SAAA,EAAA,gBAAA,CAAA;EAAW,aAAhC,EAAiC,aAAjC;EAAoB,MAAA,EAAA;IAAa,EAAA,aAAA;IAAA,GAAA,aAAA;EAAA,CAAA;;;;;;;cAG7B,qCAAsC,qBACxC,uBACH,oBAAoB,uBACb"}
|