From 11c5ab317203c5e13253bd90c6d57075feaed06f Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Sun, 28 May 2023 02:34:51 -0700 Subject: [PATCH] =?UTF-8?q?chore(release):=20=F0=9F=93=A6=20=20version=20p?= =?UTF-8?q?ackages=20(#100)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(release): 📦 version packages * chore(release): 📦 sync lockfile * fixy * silence manypkg for nwo * json parse * silence --------- Co-authored-by: github-actions[bot] Co-authored-by: juliusmarminge --- .changeset/config.json | 2 +- .changeset/ninety-monkeys-notice.md | 5 --- .changeset/olive-donkeys-move.md | 6 ---- .changeset/swift-bottles-dream.md | 5 --- examples/appdir/package.json | 4 +-- examples/pagedir/package.json | 4 +-- .../solid/src/routes/api/uploadthing/core.ts | 34 ++++++++----------- examples/solid/src/routes/index.tsx | 2 +- package.json | 3 +- packages/react/CHANGELOG.md | 11 ++++++ packages/react/package.json | 6 ++-- packages/uploadthing/CHANGELOG.md | 14 ++++++++ packages/uploadthing/package.json | 2 +- packages/uploadthing/src/next/core/page.ts | 5 ++- pnpm-lock.yaml | 17 ++++++---- 15 files changed, 65 insertions(+), 55 deletions(-) delete mode 100644 .changeset/ninety-monkeys-notice.md delete mode 100644 .changeset/olive-donkeys-move.md delete mode 100644 .changeset/swift-bottles-dream.md diff --git a/.changeset/config.json b/.changeset/config.json index 2867245fa5..965a76a6a7 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -5,7 +5,7 @@ { "repo": "pingdotgg/uploadthing" } ], "commit": false, - "fixed": [["uploadthing", "@uploadthing/react", "@uploadthing/solid"]], + "fixed": [["uploadthing", "@uploadthing/react"]], "access": "public", "baseBranch": "main", "updateInternalDependencies": "patch", diff --git a/.changeset/ninety-monkeys-notice.md b/.changeset/ninety-monkeys-notice.md deleted file mode 100644 index 004d092acd..0000000000 --- a/.changeset/ninety-monkeys-notice.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"uploadthing": minor ---- - -[feat] API Helpers -- deleteFiles() and getFileUrls() diff --git a/.changeset/olive-donkeys-move.md b/.changeset/olive-donkeys-move.md deleted file mode 100644 index 0cb561254d..0000000000 --- a/.changeset/olive-donkeys-move.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"uploadthing": major -"@uploadthing/react": major ---- - -Overhauled file router syntax diff --git a/.changeset/swift-bottles-dream.md b/.changeset/swift-bottles-dream.md deleted file mode 100644 index e53a61c8bd..0000000000 --- a/.changeset/swift-bottles-dream.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"uploadthing": patch ---- - -[Fix] Update to buildRequestHandler secret diff --git a/examples/appdir/package.json b/examples/appdir/package.json index a07f2a7805..28fc81e227 100644 --- a/examples/appdir/package.json +++ b/examples/appdir/package.json @@ -12,14 +12,14 @@ }, "dependencies": { "@tanstack/react-query": "^4.28.0", - "@uploadthing/react": "3.0.5", + "@uploadthing/react": "4.0.0", "autoprefixer": "10.4.14", "next": "13.4.4", "postcss": "8.4.22", "react": "18.2.0", "react-dom": "18.2.0", "tailwindcss": "^3.3.2", - "uploadthing": "3.0.5", + "uploadthing": "4.0.0", "zod": "^3.21.4", "zod-validation-error": "^1.1.0" }, diff --git a/examples/pagedir/package.json b/examples/pagedir/package.json index f25669d4a8..1363438b56 100644 --- a/examples/pagedir/package.json +++ b/examples/pagedir/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@tanstack/react-query": "^4.28.0", - "@uploadthing/react": "3.0.5", + "@uploadthing/react": "4.0.0", "autoprefixer": "10.4.14", "next": "13.4.4", "next-auth": "^4.22.1", @@ -20,7 +20,7 @@ "react": "18.2.0", "react-dom": "18.2.0", "tailwindcss": "^3.3.2", - "uploadthing": "3.0.5", + "uploadthing": "4.0.0", "zod": "^3.21.4", "zod-validation-error": "^1.1.0" }, diff --git a/examples/solid/src/routes/api/uploadthing/core.ts b/examples/solid/src/routes/api/uploadthing/core.ts index 143114b412..c7dcc995d1 100644 --- a/examples/solid/src/routes/api/uploadthing/core.ts +++ b/examples/solid/src/routes/api/uploadthing/core.ts @@ -8,31 +8,25 @@ const auth = (req: Request) => Promise.resolve({ id: "fakeId" }); // Fake auth f // FileRouter for your app, can contain multiple FileRoutes export const ourFileRouter = { // Define as many FileRoutes as you like, each with a unique routeSlug - withMdwr: f({ - image: { - maxFileCount: 2, - maxFileSize: "1MB", - }, - }) + imageUploader: f + // Set permissions and file types for this FileRoute + .fileTypes(["image", "video"]) + .maxSize("1GB") .middleware(async (req) => { - const h = req.headers.get("someProperty"); - const authed = await auth(req); + // This code runs on your server before upload + const user = await auth(req); - return { - someProperty: h, - userId: authed.id, - }; + // If you throw, the user will not be able to upload + if (!user) throw new Error("Unauthorized"); + + // Whatever is returned here is accessible in onUploadComplete as `metadata` + return { userId: user.id }; }) .onUploadComplete(({ metadata, file }) => { - console.log("uploaded with the following metadata:", metadata); - metadata.someProperty; - // ^? - metadata.userId; - // ^? + // This code RUNS ON YOUR SERVER after upload + console.log("Upload complete for userId:", metadata.userId); - console.log("files successfully uploaded:", file); - file; - // ^? + console.log("file url", file.url); }), } satisfies FileRouter; diff --git a/examples/solid/src/routes/index.tsx b/examples/solid/src/routes/index.tsx index eafc64224a..7e14ad6aed 100644 --- a/examples/solid/src/routes/index.tsx +++ b/examples/solid/src/routes/index.tsx @@ -10,7 +10,7 @@ const Home: VoidComponent = () => { return (
- endpoint="withMdwr" + endpoint="imageUploader" // needed when server side rendering url="http://localhost:9898" onClientUploadComplete={(res) => { diff --git a/package.json b/package.json index 3255201377..11255751c5 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "build": "turbo run build", "clean": "turbo run clean && git clean -xdf node_modules", "dev": "turbo run dev", - "lint": "turbo run lint && manypkg check", + "lint": "turbo run lint", + "lint fixme after solid package is updated": "turbo run lint && manypkg check", "format": "prettier --write . --ignore-path .gitignore", "test": "turbo run test", "test:watch": "turbo run test:watch", diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index 5ef2f06d04..463aaeb15c 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,16 @@ # @uploadthing/react +## 4.0.0 + +### Major Changes + +- [#94](https://github.com/pingdotgg/uploadthing/pull/94) [`91fb166`](https://github.com/pingdotgg/uploadthing/commit/91fb1660ba9a3dd2eb92df16b5bb1d3373b77662) Thanks [@t3dotgg](https://github.com/t3dotgg)! - Overhauled file router syntax + +### Patch Changes + +- Updated dependencies [[`16157de`](https://github.com/pingdotgg/uploadthing/commit/16157de54198d0838007efb4f6a37a4cd8720bab), [`91fb166`](https://github.com/pingdotgg/uploadthing/commit/91fb1660ba9a3dd2eb92df16b5bb1d3373b77662), [`b073c96`](https://github.com/pingdotgg/uploadthing/commit/b073c96120edccf9c9dd8f6db78611f43b841d20)]: + - uploadthing@4.0.0 + ## 3.0.5 ### Patch Changes diff --git a/packages/react/package.json b/packages/react/package.json index 066e0b0d25..489e9d888c 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@uploadthing/react", - "version": "3.0.5", + "version": "4.0.0", "license": "MIT", "exports": { "./package.json": "./package.json", @@ -36,7 +36,7 @@ "peerDependencies": { "react": "^17.0.2 || ^18.0.0", "react-dropzone": "^14.2.3", - "uploadthing": "3.0.5" + "uploadthing": "4.0.0" }, "devDependencies": { "@tailwindcss/forms": "^0.5.3", @@ -54,7 +54,7 @@ "tailwindcss": "^3.3.2", "tsup": "6.7.0", "typescript": "5.1.0-beta", - "uploadthing": "3.0.5", + "uploadthing": "4.0.0", "vitest": "^0.30.1", "wait-on": "^7.0.1" }, diff --git a/packages/uploadthing/CHANGELOG.md b/packages/uploadthing/CHANGELOG.md index 6223f1ec56..37fe7a73cc 100644 --- a/packages/uploadthing/CHANGELOG.md +++ b/packages/uploadthing/CHANGELOG.md @@ -1,5 +1,19 @@ # uploadthing +## 4.0.0 + +### Major Changes + +- [#94](https://github.com/pingdotgg/uploadthing/pull/94) [`91fb166`](https://github.com/pingdotgg/uploadthing/commit/91fb1660ba9a3dd2eb92df16b5bb1d3373b77662) Thanks [@t3dotgg](https://github.com/t3dotgg)! - Overhauled file router syntax + +### Minor Changes + +- [#93](https://github.com/pingdotgg/uploadthing/pull/93) [`16157de`](https://github.com/pingdotgg/uploadthing/commit/16157de54198d0838007efb4f6a37a4cd8720bab) Thanks [@markflorkowski](https://github.com/markflorkowski)! - [feat] API Helpers -- deleteFiles() and getFileUrls() + +### Patch Changes + +- [#97](https://github.com/pingdotgg/uploadthing/pull/97) [`b073c96`](https://github.com/pingdotgg/uploadthing/commit/b073c96120edccf9c9dd8f6db78611f43b841d20) Thanks [@ayatofrench](https://github.com/ayatofrench)! - [Fix] Update to buildRequestHandler secret + ## 3.0.5 ### Patch Changes diff --git a/packages/uploadthing/package.json b/packages/uploadthing/package.json index 26e3813cdb..f0f81d9658 100644 --- a/packages/uploadthing/package.json +++ b/packages/uploadthing/package.json @@ -1,6 +1,6 @@ { "name": "uploadthing", - "version": "3.0.5", + "version": "4.0.0", "license": "MIT", "exports": { "./package.json": "./package.json", diff --git a/packages/uploadthing/src/next/core/page.ts b/packages/uploadthing/src/next/core/page.ts index 4a76f23b11..f9808d5e15 100644 --- a/packages/uploadthing/src/next/core/page.ts +++ b/packages/uploadthing/src/next/core/page.ts @@ -36,10 +36,13 @@ export const createNextPageApiHandler = ( return res.status(400).send("`actionType` must not be an array"); if (uploadthingHook && typeof uploadthingHook !== "string") return res.status(400).send("`uploadthingHook` must not be an array"); + if (typeof req.body !== "string") + return res.status(400).send("Request body must be a JSON string"); const standardRequest = { ...req, - json: () => Promise.resolve(req.body), + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + json: () => Promise.resolve(JSON.parse(req.body)), headers: { get: (key: string) => req.headers[key], } as Headers, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c0f1a309d5..b3e7dd15d6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,7 +62,7 @@ importers: specifier: ^4.28.0 version: 4.28.0(react-dom@18.2.0)(react@18.2.0) '@uploadthing/react': - specifier: 3.0.5 + specifier: 4.0.0 version: link:../../packages/react autoprefixer: specifier: 10.4.14 @@ -83,7 +83,7 @@ importers: specifier: ^3.3.2 version: 3.3.2 uploadthing: - specifier: 3.0.5 + specifier: 4.0.0 version: link:../../packages/uploadthing zod: specifier: ^3.21.4 @@ -123,7 +123,7 @@ importers: specifier: ^4.28.0 version: 4.28.0(react-dom@18.2.0)(react@18.2.0) '@uploadthing/react': - specifier: 3.0.5 + specifier: 4.0.0 version: link:../../packages/react autoprefixer: specifier: 10.4.14 @@ -147,7 +147,7 @@ importers: specifier: ^3.3.2 version: 3.3.2 uploadthing: - specifier: 3.0.5 + specifier: 4.0.0 version: link:../../packages/uploadthing zod: specifier: ^3.21.4 @@ -215,7 +215,7 @@ importers: version: 5.20.0 uploadthing: specifier: 3.0.5 - version: link:../../packages/uploadthing + version: 3.0.5 zod: specifier: ^3.21.4 version: 3.21.4 @@ -347,7 +347,7 @@ importers: specifier: 5.1.0-beta version: 5.1.0-beta uploadthing: - specifier: 3.0.5 + specifier: 4.0.0 version: link:../uploadthing vitest: specifier: ^0.30.1 @@ -387,7 +387,7 @@ importers: version: 5.1.0-beta uploadthing: specifier: 3.0.5 - version: link:../uploadthing + version: 3.0.5 packages/uploadthing: dependencies: @@ -9031,6 +9031,9 @@ packages: escalade: 3.1.1 picocolors: 1.0.0 + /uploadthing@3.0.5: + resolution: {integrity: sha512-/AHyRKp6nnI0DLbjBeKf/JYqQNW6qIYVVBiVyDQewlJk+NtP5R7ux8aPGNrgdZOonXWrM3pDYaY7+FtplQ7sPA==} + /uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: