From 1ac0f1bbd9be32bc58dbb1c58233b8592fd4188b Mon Sep 17 00:00:00 2001 From: Theo Browne Date: Mon, 19 Jun 2023 23:17:03 -0700 Subject: [PATCH] =?UTF-8?q?chore(release):=20=F0=9F=93=A6=20=20version=20p?= =?UTF-8?q?ackages=20(#164)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: github-actions[bot] --- .changeset/honest-seas-rush.md | 7 -- .changeset/new-cooks-visit.md | 114 -------------------------- examples/appdir/package.json | 4 +- examples/pagedir/package.json | 4 +- examples/solid/package.json | 4 +- packages/react/CHANGELOG.md | 130 ++++++++++++++++++++++++++++++ packages/react/package.json | 6 +- packages/solid/CHANGELOG.md | 130 ++++++++++++++++++++++++++++++ packages/solid/package.json | 6 +- packages/uploadthing/CHANGELOG.md | 116 ++++++++++++++++++++++++++ packages/uploadthing/package.json | 2 +- pnpm-lock.yaml | 23 +++--- 12 files changed, 403 insertions(+), 143 deletions(-) delete mode 100644 .changeset/honest-seas-rush.md delete mode 100644 .changeset/new-cooks-visit.md diff --git a/.changeset/honest-seas-rush.md b/.changeset/honest-seas-rush.md deleted file mode 100644 index 2cdae820b7..0000000000 --- a/.changeset/honest-seas-rush.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -"@uploadthing/react": minor -"@uploadthing/solid": minor ---- - -feat: `generateComponents` functions for solid and react allows to pass the -generic `FileRouter` once instead of for everytime the component is used diff --git a/.changeset/new-cooks-visit.md b/.changeset/new-cooks-visit.md deleted file mode 100644 index b2757530e9..0000000000 --- a/.changeset/new-cooks-visit.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -"@uploadthing/react": major -"@uploadthing/solid": major -"uploadthing": major ---- - -feat!: allow client side metadata to be passed along with the files - -## Summary - -You can now pass input along with the files when uploading. - -In your file route: - -```ts - withInput: f(["image"]) - .input( - z.object({ - foo: z.string(), - }), - ) - .middleware((opts) => { - console.log("input", opts.input); - // input is typed as { foo: string } - return {}; - }) - .onUploadComplete((data) => { - console.log("upload completed", data); - }), -``` - -Then, when uploading, attach the input to the component or the `startUpload` -function: - -```tsx -const { useUploadThing } = generateReactHelpers(); - -function MyComponent() { - // Vanilla way - const { startUpload } = useUploadthing("withInput"); - async function onSubmit(files: File[]) { - await startUpload(files, { foo: "bar" }); - } - - // Component way - return ( - - endpoint="withInput" - input={{ foo: "bar" }} // or use some state to be dynamic - /> - ); -} -``` - -The input is validated on **your** server and only leaves your server if you -pass it along from the `.middleware` to the `.onUploadComplete`. If you only use -the input in the middleware without returning it, the Uploadthing server won't -have any knowledge of it. - -## Breaking changes - -- Options passed in the `middleware` now comes as an object. - - ```ts - // before - route: f(["image"]) - // res only for Next.js pages - .middleware((req, res) => { - return {}; - }); - - // after - route: f(["image"]) - // res only for Next.js pages - .middleware((opts) => { - opts.req; // Request, NextRequest, NextApiRequest depending on runtime - opts.res; // NextApiResponse for Next.js pages - opts.input; // typesafe, validated input - return {}; - }); - ``` - -- The `endpoint` option in the `useUploadthing` hook has been moved out to a - separate positional argument. - - ```ts - // before - useUploadthing({ - endpoint: "withInput" - onUploadComplete: ... - }) - - // after - useUploadthing("withInput", { - onUploadComplete: ... - }) - ``` - -- The signature for `uploadFiles` has changed to object syntax. - - ```ts - // before - const { uploadFiles } = generateReactHelpers(); - uploadFiles(files, endpoint, { url: "" }) - - // after - const { uploadFiles } = generateReactHelpers(); - uploadFiles({ - files, - endpoint, - input, // <-- new option - url, - }) - ``` diff --git a/examples/appdir/package.json b/examples/appdir/package.json index 805be0394f..121f5e723e 100644 --- a/examples/appdir/package.json +++ b/examples/appdir/package.json @@ -12,14 +12,14 @@ }, "dependencies": { "@tanstack/react-query": "^4.29.12", - "@uploadthing/react": "4.1.3", + "@uploadthing/react": "5.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": "4.1.3", + "uploadthing": "5.0.0", "zod": "^3.21.4", "zod-validation-error": "^1.3.0" }, diff --git a/examples/pagedir/package.json b/examples/pagedir/package.json index 3cd95fb76c..db48768af7 100644 --- a/examples/pagedir/package.json +++ b/examples/pagedir/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@tanstack/react-query": "^4.29.12", - "@uploadthing/react": "4.1.3", + "@uploadthing/react": "5.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": "4.1.3", + "uploadthing": "5.0.0", "zod": "^3.21.4", "zod-validation-error": "^1.3.0" }, diff --git a/examples/solid/package.json b/examples/solid/package.json index 0b17baf05b..3c53162ce6 100644 --- a/examples/solid/package.json +++ b/examples/solid/package.json @@ -24,14 +24,14 @@ "dependencies": { "@solidjs/meta": "^0.28.5", "@solidjs/router": "^0.8.2", - "@uploadthing/solid": "4.1.3", + "@uploadthing/solid": "5.0.0", "attr-accept": "^2.2.2", "file-selector": "^0.6.0", "solid-js": "^1.7.6", "solid-start": "^0.2.26", "solidjs-dropzone": "^1.0.0", "undici": "5.20.0", - "uploadthing": "4.1.3", + "uploadthing": "5.0.0", "zod": "^3.21.4" }, "engines": { diff --git a/packages/react/CHANGELOG.md b/packages/react/CHANGELOG.md index b1f5f87837..e64458fc8b 100644 --- a/packages/react/CHANGELOG.md +++ b/packages/react/CHANGELOG.md @@ -1,5 +1,135 @@ # @uploadthing/react +## 5.0.0 + +### Major Changes + +- [#157](https://github.com/pingdotgg/uploadthing/pull/157) + [`5652869`](https://github.com/pingdotgg/uploadthing/commit/56528690adb7b1500c4db53b8f0fa10432d13139) + Thanks [@juliusmarminge](https://github.com/juliusmarminge)! - feat!: allow + client side metadata to be passed along with the files + + ## Summary + + You can now pass input along with the files when uploading. + + In your file route: + + ```ts + withInput: f(["image"]) + .input( + z.object({ + foo: z.string(), + }), + ) + .middleware((opts) => { + console.log("input", opts.input); + // input is typed as { foo: string } + return {}; + }) + .onUploadComplete((data) => { + console.log("upload completed", data); + }), + ``` + + Then, when uploading, attach the input to the component or the `startUpload` + function: + + ```tsx + const { useUploadThing } = generateReactHelpers(); + + function MyComponent() { + // Vanilla way + const { startUpload } = useUploadthing("withInput"); + async function onSubmit(files: File[]) { + await startUpload(files, { foo: "bar" }); + } + + // Component way + return ( + + endpoint="withInput" + input={{ foo: "bar" }} // or use some state to be dynamic + /> + ); + } + ``` + + The input is validated on **your** server and only leaves your server if you + pass it along from the `.middleware` to the `.onUploadComplete`. If you only + use the input in the middleware without returning it, the Uploadthing server + won't have any knowledge of it. + + ## Breaking changes + + - Options passed in the `middleware` now comes as an object. + + ```ts + // before + route: f(["image"]) + // res only for Next.js pages + .middleware((req, res) => { + return {}; + }); + + // after + route: f(["image"]) + // res only for Next.js pages + .middleware((opts) => { + opts.req; // Request, NextRequest, NextApiRequest depending on runtime + opts.res; // NextApiResponse for Next.js pages + opts.input; // typesafe, validated input + return {}; + }); + ``` + + - The `endpoint` option in the `useUploadthing` hook has been moved out to a + separate positional argument. + + ```ts + // before + useUploadthing({ + endpoint: "withInput" + onUploadComplete: ... + }) + + // after + useUploadthing("withInput", { + onUploadComplete: ... + }) + ``` + + - The signature for `uploadFiles` has changed to object syntax. + + ```ts + // before + const { uploadFiles } = generateReactHelpers(); + uploadFiles(files, endpoint, { url: "" }) + + // after + const { uploadFiles } = generateReactHelpers(); + uploadFiles({ + files, + endpoint, + input, // <-- new option + url, + }) + ``` + +### Minor Changes + +- [#61](https://github.com/pingdotgg/uploadthing/pull/61) + [`9162cce`](https://github.com/pingdotgg/uploadthing/commit/9162cce03245e500cae0d0c0564a388473c1ae13) + Thanks [@OrJDev](https://github.com/OrJDev)! - feat: `generateComponents` + functions for solid and react allows to pass the generic `FileRouter` once + instead of for everytime the component is used + +### Patch Changes + +- Updated dependencies + [[`5652869`](https://github.com/pingdotgg/uploadthing/commit/56528690adb7b1500c4db53b8f0fa10432d13139)]: + - uploadthing@5.0.0 + ## 4.1.3 ### Patch Changes diff --git a/packages/react/package.json b/packages/react/package.json index 2206dd12fc..8fe65d3654 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@uploadthing/react", - "version": "4.1.3", + "version": "5.0.0", "license": "MIT", "exports": { "./package.json": "./package.json", @@ -39,7 +39,7 @@ "peerDependencies": { "react": "^17.0.2 || ^18.0.0", "react-dropzone": "^14.2.3", - "uploadthing": "^4.0.0" + "uploadthing": "^5.0.0" }, "devDependencies": { "@tailwindcss/forms": "^0.5.3", @@ -57,7 +57,7 @@ "tailwindcss": "^3.3.2", "tsup": "6.7.0", "typescript": "5.1.3", - "uploadthing": "4.1.3", + "uploadthing": "5.0.0", "vitest": "^0.30.1", "wait-on": "^7.0.1", "zod": "^3.21.4" diff --git a/packages/solid/CHANGELOG.md b/packages/solid/CHANGELOG.md index f4c3157bd8..a91bf2b0d7 100644 --- a/packages/solid/CHANGELOG.md +++ b/packages/solid/CHANGELOG.md @@ -1,5 +1,135 @@ # @uploadthing/solid +## 5.0.0 + +### Major Changes + +- [#157](https://github.com/pingdotgg/uploadthing/pull/157) + [`5652869`](https://github.com/pingdotgg/uploadthing/commit/56528690adb7b1500c4db53b8f0fa10432d13139) + Thanks [@juliusmarminge](https://github.com/juliusmarminge)! - feat!: allow + client side metadata to be passed along with the files + + ## Summary + + You can now pass input along with the files when uploading. + + In your file route: + + ```ts + withInput: f(["image"]) + .input( + z.object({ + foo: z.string(), + }), + ) + .middleware((opts) => { + console.log("input", opts.input); + // input is typed as { foo: string } + return {}; + }) + .onUploadComplete((data) => { + console.log("upload completed", data); + }), + ``` + + Then, when uploading, attach the input to the component or the `startUpload` + function: + + ```tsx + const { useUploadThing } = generateReactHelpers(); + + function MyComponent() { + // Vanilla way + const { startUpload } = useUploadthing("withInput"); + async function onSubmit(files: File[]) { + await startUpload(files, { foo: "bar" }); + } + + // Component way + return ( + + endpoint="withInput" + input={{ foo: "bar" }} // or use some state to be dynamic + /> + ); + } + ``` + + The input is validated on **your** server and only leaves your server if you + pass it along from the `.middleware` to the `.onUploadComplete`. If you only + use the input in the middleware without returning it, the Uploadthing server + won't have any knowledge of it. + + ## Breaking changes + + - Options passed in the `middleware` now comes as an object. + + ```ts + // before + route: f(["image"]) + // res only for Next.js pages + .middleware((req, res) => { + return {}; + }); + + // after + route: f(["image"]) + // res only for Next.js pages + .middleware((opts) => { + opts.req; // Request, NextRequest, NextApiRequest depending on runtime + opts.res; // NextApiResponse for Next.js pages + opts.input; // typesafe, validated input + return {}; + }); + ``` + + - The `endpoint` option in the `useUploadthing` hook has been moved out to a + separate positional argument. + + ```ts + // before + useUploadthing({ + endpoint: "withInput" + onUploadComplete: ... + }) + + // after + useUploadthing("withInput", { + onUploadComplete: ... + }) + ``` + + - The signature for `uploadFiles` has changed to object syntax. + + ```ts + // before + const { uploadFiles } = generateReactHelpers(); + uploadFiles(files, endpoint, { url: "" }) + + // after + const { uploadFiles } = generateReactHelpers(); + uploadFiles({ + files, + endpoint, + input, // <-- new option + url, + }) + ``` + +### Minor Changes + +- [#61](https://github.com/pingdotgg/uploadthing/pull/61) + [`9162cce`](https://github.com/pingdotgg/uploadthing/commit/9162cce03245e500cae0d0c0564a388473c1ae13) + Thanks [@OrJDev](https://github.com/OrJDev)! - feat: `generateComponents` + functions for solid and react allows to pass the generic `FileRouter` once + instead of for everytime the component is used + +### Patch Changes + +- Updated dependencies + [[`5652869`](https://github.com/pingdotgg/uploadthing/commit/56528690adb7b1500c4db53b8f0fa10432d13139)]: + - uploadthing@5.0.0 + ## 4.1.3 ### Patch Changes diff --git a/packages/solid/package.json b/packages/solid/package.json index 0d3bcfa222..80961994b4 100644 --- a/packages/solid/package.json +++ b/packages/solid/package.json @@ -2,7 +2,7 @@ "name": "@uploadthing/solid", "author": "OrJDev", "license": "MIT", - "version": "4.1.3", + "version": "5.0.0", "type": "module", "exports": { ".": { @@ -96,12 +96,12 @@ "tsup": "6.7.0", "tsup-preset-solid": "0.1.8", "typescript": "5.1.3", - "uploadthing": "4.1.3" + "uploadthing": "5.0.0" }, "peerDependencies": { "solid-js": "^1.5.3", "solidjs-dropzone": "^1.0.0", - "uploadthing": "4.1.3" + "uploadthing": "5.0.0" }, "keywords": [ "SolidJS", diff --git a/packages/uploadthing/CHANGELOG.md b/packages/uploadthing/CHANGELOG.md index e1314a2a64..56b57a3bfb 100644 --- a/packages/uploadthing/CHANGELOG.md +++ b/packages/uploadthing/CHANGELOG.md @@ -1,5 +1,121 @@ # uploadthing +## 5.0.0 + +### Major Changes + +- [#157](https://github.com/pingdotgg/uploadthing/pull/157) + [`5652869`](https://github.com/pingdotgg/uploadthing/commit/56528690adb7b1500c4db53b8f0fa10432d13139) + Thanks [@juliusmarminge](https://github.com/juliusmarminge)! - feat!: allow + client side metadata to be passed along with the files + + ## Summary + + You can now pass input along with the files when uploading. + + In your file route: + + ```ts + withInput: f(["image"]) + .input( + z.object({ + foo: z.string(), + }), + ) + .middleware((opts) => { + console.log("input", opts.input); + // input is typed as { foo: string } + return {}; + }) + .onUploadComplete((data) => { + console.log("upload completed", data); + }), + ``` + + Then, when uploading, attach the input to the component or the `startUpload` + function: + + ```tsx + const { useUploadThing } = generateReactHelpers(); + + function MyComponent() { + // Vanilla way + const { startUpload } = useUploadthing("withInput"); + async function onSubmit(files: File[]) { + await startUpload(files, { foo: "bar" }); + } + + // Component way + return ( + + endpoint="withInput" + input={{ foo: "bar" }} // or use some state to be dynamic + /> + ); + } + ``` + + The input is validated on **your** server and only leaves your server if you + pass it along from the `.middleware` to the `.onUploadComplete`. If you only + use the input in the middleware without returning it, the Uploadthing server + won't have any knowledge of it. + + ## Breaking changes + + - Options passed in the `middleware` now comes as an object. + + ```ts + // before + route: f(["image"]) + // res only for Next.js pages + .middleware((req, res) => { + return {}; + }); + + // after + route: f(["image"]) + // res only for Next.js pages + .middleware((opts) => { + opts.req; // Request, NextRequest, NextApiRequest depending on runtime + opts.res; // NextApiResponse for Next.js pages + opts.input; // typesafe, validated input + return {}; + }); + ``` + + - The `endpoint` option in the `useUploadthing` hook has been moved out to a + separate positional argument. + + ```ts + // before + useUploadthing({ + endpoint: "withInput" + onUploadComplete: ... + }) + + // after + useUploadthing("withInput", { + onUploadComplete: ... + }) + ``` + + - The signature for `uploadFiles` has changed to object syntax. + + ```ts + // before + const { uploadFiles } = generateReactHelpers(); + uploadFiles(files, endpoint, { url: "" }) + + // after + const { uploadFiles } = generateReactHelpers(); + uploadFiles({ + files, + endpoint, + input, // <-- new option + url, + }) + ``` + ## 4.1.3 ### Patch Changes diff --git a/packages/uploadthing/package.json b/packages/uploadthing/package.json index da4ba8727c..b2d9df5a00 100644 --- a/packages/uploadthing/package.json +++ b/packages/uploadthing/package.json @@ -1,6 +1,6 @@ { "name": "uploadthing", - "version": "4.1.3", + "version": "5.0.0", "license": "MIT", "exports": { "./package.json": "./package.json", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b9c6ea23f4..3d9694390b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,7 +28,7 @@ importers: version: link:packages/config/eslint dotenv: specifier: latest - version: 16.1.4 + version: 16.3.1 prettier: specifier: ^2.8.8 version: 2.8.8 @@ -73,7 +73,7 @@ importers: specifier: ^4.29.12 version: 4.29.12(react-dom@18.2.0)(react@18.2.0) '@uploadthing/react': - specifier: 4.1.3 + specifier: 5.0.0 version: link:../../packages/react autoprefixer: specifier: 10.4.14 @@ -94,7 +94,7 @@ importers: specifier: ^3.3.2 version: 3.3.2 uploadthing: - specifier: 4.1.3 + specifier: 5.0.0 version: link:../../packages/uploadthing zod: specifier: ^3.21.4 @@ -134,7 +134,7 @@ importers: specifier: ^4.29.12 version: 4.29.12(react-dom@18.2.0)(react@18.2.0) '@uploadthing/react': - specifier: 4.1.3 + specifier: 5.0.0 version: link:../../packages/react autoprefixer: specifier: 10.4.14 @@ -158,7 +158,7 @@ importers: specifier: ^3.3.2 version: 3.3.2 uploadthing: - specifier: 4.1.3 + specifier: 5.0.0 version: link:../../packages/uploadthing zod: specifier: ^3.21.4 @@ -201,7 +201,7 @@ importers: specifier: ^0.8.2 version: 0.8.2(solid-js@1.7.6) '@uploadthing/solid': - specifier: 4.1.3 + specifier: 5.0.0 version: link:../../packages/solid attr-accept: specifier: ^2.2.2 @@ -222,7 +222,7 @@ importers: specifier: 5.20.0 version: 5.20.0 uploadthing: - specifier: 4.1.3 + specifier: 5.0.0 version: link:../../packages/uploadthing zod: specifier: ^3.21.4 @@ -380,7 +380,7 @@ importers: specifier: 5.1.3 version: 5.1.3 uploadthing: - specifier: 4.1.3 + specifier: 5.0.0 version: link:../uploadthing vitest: specifier: ^0.30.1 @@ -453,7 +453,7 @@ importers: specifier: 5.1.3 version: 5.1.3 uploadthing: - specifier: 4.1.3 + specifier: 5.0.0 version: link:../uploadthing packages/uploadthing: @@ -4281,6 +4281,11 @@ packages: resolution: {integrity: sha512-m55RtE8AsPeJBpOIFKihEmqUcoVncQIwo7x9U8ZwLEZw9ZpXboz2c+rvog+jUaJvVrZ5kBOeYQBX5+8Aa/OZQw==} engines: {node: '>=12'} + /dotenv@16.3.1: + resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} + engines: {node: '>=12'} + dev: false + /dotenv@8.6.0: resolution: {integrity: sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==} engines: {node: '>=10'}