diff --git a/.changeset/mighty-stingrays-press.md b/.changeset/mighty-stingrays-press.md deleted file mode 100644 index 12c353dcd928..000000000000 --- a/.changeset/mighty-stingrays-press.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -'astro': patch ---- - -Adds support for Zod discriminated unions on Action form inputs. This allows forms with different inputs to be submitted to the same action, using a given input to decide which object should be used for validation. - -This example accepts either a `create` or `update` form submission, and uses the `type` field to determine which object to validate against. - -```ts -import { defineAction } from 'astro:actions'; -import { z } from 'astro:schema'; - -export const server = { - changeUser: defineAction({ - accept: 'form', - input: z.discriminatedUnion('type', [ - z.object({ - type: z.literal('create'), - name: z.string(), - email: z.string().email(), - }), - z.object({ - type: z.literal('update'), - id: z.number(), - name: z.string(), - email: z.string().email(), - }), - ]), - async handler(input) { - if (input.type === 'create') { - // input is { type: 'create', name: string, email: string } - } else { - // input is { type: 'update', id: number, name: string, email: string } - } - }, - }), -} -``` - -The corresponding `create` and `update` forms may look like this: - -```astro ---- -import { actions } from 'astro:actions'; ---- - - -
- - - -``` diff --git a/examples/basics/package.json b/examples/basics/package.json index a6bbf72554da..20320658e4f7 100644 --- a/examples/basics/package.json +++ b/examples/basics/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/blog/package.json b/examples/blog/package.json index 2935f2ceed86..c8bebd190646 100644 --- a/examples/blog/package.json +++ b/examples/blog/package.json @@ -11,9 +11,9 @@ "astro": "astro" }, "dependencies": { - "@astrojs/mdx": "^3.1.5", + "@astrojs/mdx": "^3.1.6", "@astrojs/rss": "^4.0.7", "@astrojs/sitemap": "^3.1.6", - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/component/package.json b/examples/component/package.json index 3f44cb9385fe..1ca79c5fb1b6 100644 --- a/examples/component/package.json +++ b/examples/component/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.15.4" + "astro": "^4.15.5" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/container-with-vitest/package.json b/examples/container-with-vitest/package.json index 6d5aea4c37fc..45ca685d4a8b 100644 --- a/examples/container-with-vitest/package.json +++ b/examples/container-with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest run" }, "dependencies": { - "astro": "^4.15.4", + "astro": "^4.15.5", "@astrojs/react": "^3.6.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-alpine/package.json b/examples/framework-alpine/package.json index 1d0b64c2c346..a08659d18e6b 100644 --- a/examples/framework-alpine/package.json +++ b/examples/framework-alpine/package.json @@ -14,6 +14,6 @@ "@astrojs/alpinejs": "^0.4.0", "@types/alpinejs": "^3.13.10", "alpinejs": "^3.14.1", - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/framework-lit/package.json b/examples/framework-lit/package.json index 1aba743b6d54..2c2a88d0935c 100644 --- a/examples/framework-lit/package.json +++ b/examples/framework-lit/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/lit": "^4.3.0", "@webcomponents/template-shadowroot": "^0.2.1", - "astro": "^4.15.4", + "astro": "^4.15.5", "lit": "^3.2.0" } } diff --git a/examples/framework-multiple/package.json b/examples/framework-multiple/package.json index f459c4aeff2b..c99a3ba72e2f 100644 --- a/examples/framework-multiple/package.json +++ b/examples/framework-multiple/package.json @@ -18,7 +18,7 @@ "@astrojs/vue": "^4.5.0", "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", - "astro": "^4.15.4", + "astro": "^4.15.5", "preact": "^10.23.2", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/framework-preact/package.json b/examples/framework-preact/package.json index 2d2924649b4d..222c29ccfb25 100644 --- a/examples/framework-preact/package.json +++ b/examples/framework-preact/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@preact/signals": "^1.3.0", - "astro": "^4.15.4", + "astro": "^4.15.5", "preact": "^10.23.2" } } diff --git a/examples/framework-react/package.json b/examples/framework-react/package.json index 97cb985ef9cc..ac96d6c9da74 100644 --- a/examples/framework-react/package.json +++ b/examples/framework-react/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "^3.6.2", "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", - "astro": "^4.15.4", + "astro": "^4.15.5", "react": "^18.3.1", "react-dom": "^18.3.1" } diff --git a/examples/framework-solid/package.json b/examples/framework-solid/package.json index 8ccd47f5294f..351cd4d30225 100644 --- a/examples/framework-solid/package.json +++ b/examples/framework-solid/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/solid-js": "^4.4.1", - "astro": "^4.15.4", + "astro": "^4.15.5", "solid-js": "^1.8.22" } } diff --git a/examples/framework-svelte/package.json b/examples/framework-svelte/package.json index eb29897a7c45..1b983c3a1f05 100644 --- a/examples/framework-svelte/package.json +++ b/examples/framework-svelte/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/svelte": "^5.7.0", - "astro": "^4.15.4", + "astro": "^4.15.5", "svelte": "^4.2.19" } } diff --git a/examples/framework-vue/package.json b/examples/framework-vue/package.json index 004b6ebac2a5..7300890f9c83 100644 --- a/examples/framework-vue/package.json +++ b/examples/framework-vue/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/vue": "^4.5.0", - "astro": "^4.15.4", + "astro": "^4.15.5", "vue": "^3.5.3" } } diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 4115eb8014a7..932de940d9ea 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/integration/package.json b/examples/integration/package.json index 3377faa51ecf..57f58177241e 100644 --- a/examples/integration/package.json +++ b/examples/integration/package.json @@ -15,7 +15,7 @@ ], "scripts": {}, "devDependencies": { - "astro": "^4.15.4" + "astro": "^4.15.5" }, "peerDependencies": { "astro": "^4.0.0" diff --git a/examples/middleware/package.json b/examples/middleware/package.json index a35011515d9d..d3abf03155e5 100644 --- a/examples/middleware/package.json +++ b/examples/middleware/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@astrojs/node": "^8.3.3", - "astro": "^4.15.4", + "astro": "^4.15.5", "html-minifier": "^4.0.0" }, "devDependencies": { diff --git a/examples/minimal/package.json b/examples/minimal/package.json index 8a892c29f4d9..e354465171db 100644 --- a/examples/minimal/package.json +++ b/examples/minimal/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/non-html-pages/package.json b/examples/non-html-pages/package.json index 0106f522117f..8b1af1116e23 100644 --- a/examples/non-html-pages/package.json +++ b/examples/non-html-pages/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/portfolio/package.json b/examples/portfolio/package.json index fb6256b22275..490e0a3b22db 100644 --- a/examples/portfolio/package.json +++ b/examples/portfolio/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/server-islands/package.json b/examples/server-islands/package.json index 86f7acb1a216..d9ecb186a368 100644 --- a/examples/server-islands/package.json +++ b/examples/server-islands/package.json @@ -17,7 +17,7 @@ "@tailwindcss/forms": "^0.5.9", "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", - "astro": "^4.15.4", + "astro": "^4.15.5", "postcss": "^8.4.45", "react": "^18.3.1", "react-dom": "^18.3.1", diff --git a/examples/ssr/package.json b/examples/ssr/package.json index 652197543d6c..9b1c4cb800a6 100644 --- a/examples/ssr/package.json +++ b/examples/ssr/package.json @@ -14,7 +14,7 @@ "dependencies": { "@astrojs/node": "^8.3.3", "@astrojs/svelte": "^5.7.0", - "astro": "^4.15.4", + "astro": "^4.15.5", "svelte": "^4.2.19" } } diff --git a/examples/starlog/package.json b/examples/starlog/package.json index 2886d3cb5ec0..378426cfb3fd 100644 --- a/examples/starlog/package.json +++ b/examples/starlog/package.json @@ -10,7 +10,7 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.4", + "astro": "^4.15.5", "sass": "^1.78.0", "sharp": "^0.33.3" } diff --git a/examples/toolbar-app/package.json b/examples/toolbar-app/package.json index 6e452f1ada0a..beec943bbade 100644 --- a/examples/toolbar-app/package.json +++ b/examples/toolbar-app/package.json @@ -15,6 +15,6 @@ "./app": "./dist/app.js" }, "devDependencies": { - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/view-transitions/package.json b/examples/view-transitions/package.json index 1563b1cb9e23..13484ffe7a9f 100644 --- a/examples/view-transitions/package.json +++ b/examples/view-transitions/package.json @@ -12,6 +12,6 @@ "devDependencies": { "@astrojs/tailwind": "^5.1.0", "@astrojs/node": "^8.3.3", - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/with-markdoc/package.json b/examples/with-markdoc/package.json index 94241cc27289..26a5afadc8d4 100644 --- a/examples/with-markdoc/package.json +++ b/examples/with-markdoc/package.json @@ -12,6 +12,6 @@ }, "dependencies": { "@astrojs/markdoc": "^0.11.4", - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/with-markdown-plugins/package.json b/examples/with-markdown-plugins/package.json index fdc774ee1d26..bb472654ce94 100644 --- a/examples/with-markdown-plugins/package.json +++ b/examples/with-markdown-plugins/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@astrojs/markdown-remark": "^5.2.0", - "astro": "^4.15.4", + "astro": "^4.15.5", "hast-util-select": "^6.0.2", "rehype-autolink-headings": "^7.1.0", "rehype-slug": "^6.0.0", diff --git a/examples/with-markdown-shiki/package.json b/examples/with-markdown-shiki/package.json index 420c6270d116..5b7beef2a275 100644 --- a/examples/with-markdown-shiki/package.json +++ b/examples/with-markdown-shiki/package.json @@ -11,6 +11,6 @@ "astro": "astro" }, "dependencies": { - "astro": "^4.15.4" + "astro": "^4.15.5" } } diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 1b4e7cd4f745..290686f59c07 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -11,9 +11,9 @@ "astro": "astro" }, "dependencies": { - "@astrojs/mdx": "^3.1.5", + "@astrojs/mdx": "^3.1.6", "@astrojs/preact": "^3.5.3", - "astro": "^4.15.4", + "astro": "^4.15.5", "preact": "^10.23.2" } } diff --git a/examples/with-nanostores/package.json b/examples/with-nanostores/package.json index 8706fad193b6..ea17f24b3c94 100644 --- a/examples/with-nanostores/package.json +++ b/examples/with-nanostores/package.json @@ -13,7 +13,7 @@ "dependencies": { "@astrojs/preact": "^3.5.3", "@nanostores/preact": "^0.5.2", - "astro": "^4.15.4", + "astro": "^4.15.5", "nanostores": "^0.11.3", "preact": "^10.23.2" } diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 8f7995b45dbe..55a63847b455 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -11,10 +11,10 @@ "astro": "astro" }, "dependencies": { - "@astrojs/mdx": "^3.1.5", + "@astrojs/mdx": "^3.1.6", "@astrojs/tailwind": "^5.1.0", "@types/canvas-confetti": "^1.6.4", - "astro": "^4.15.4", + "astro": "^4.15.5", "autoprefixer": "^10.4.20", "canvas-confetti": "^1.9.3", "postcss": "^8.4.45", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 39f947259536..bd30c3df8b16 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "test": "vitest" }, "dependencies": { - "astro": "^4.15.4", + "astro": "^4.15.5", "vitest": "^2.0.5" } } diff --git a/packages/astro/CHANGELOG.md b/packages/astro/CHANGELOG.md index 7853efb1650e..cfe6474f0cb8 100644 --- a/packages/astro/CHANGELOG.md +++ b/packages/astro/CHANGELOG.md @@ -1,5 +1,73 @@ # astro +## 4.15.5 + +### Patch Changes + +- [#11939](https://github.com/withastro/astro/pull/11939) [`7b09c62`](https://github.com/withastro/astro/commit/7b09c62b565cd7b50c35fb68d390729f936a43fb) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Adds support for Zod discriminated unions on Action form inputs. This allows forms with different inputs to be submitted to the same action, using a given input to decide which object should be used for validation. + + This example accepts either a `create` or `update` form submission, and uses the `type` field to determine which object to validate against. + + ```ts + import { defineAction } from 'astro:actions'; + import { z } from 'astro:schema'; + + export const server = { + changeUser: defineAction({ + accept: 'form', + input: z.discriminatedUnion('type', [ + z.object({ + type: z.literal('create'), + name: z.string(), + email: z.string().email(), + }), + z.object({ + type: z.literal('update'), + id: z.number(), + name: z.string(), + email: z.string().email(), + }), + ]), + async handler(input) { + if (input.type === 'create') { + // input is { type: 'create', name: string, email: string } + } else { + // input is { type: 'update', id: number, name: string, email: string } + } + }, + }), + }; + ``` + + The corresponding `create` and `update` forms may look like this: + + ```astro + --- + import { actions } from 'astro:actions'; + --- + + + + + + + ``` + +- [#11968](https://github.com/withastro/astro/pull/11968) [`86ad1fd`](https://github.com/withastro/astro/commit/86ad1fd223e2d2c448372caa159090efbee69237) Thanks [@NikolaRHristov](https://github.com/NikolaRHristov)! - Fixes a typo in the server island JSDoc + +- [#11983](https://github.com/withastro/astro/pull/11983) [`633eeaa`](https://github.com/withastro/astro/commit/633eeaa9d8a8a35bba638fde06fd8f52cc1c2ce3) Thanks [@uwej711](https://github.com/uwej711)! - Remove dependency on path-to-regexp + ## 4.15.4 ### Patch Changes diff --git a/packages/astro/package.json b/packages/astro/package.json index 11ad27c58c34..f3a2b7d0bbd0 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -1,6 +1,6 @@ { "name": "astro", - "version": "4.15.4", + "version": "4.15.5", "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", "type": "module", "author": "withastro", @@ -168,7 +168,6 @@ "ora": "^8.1.0", "p-limit": "^6.1.0", "p-queue": "^8.0.1", - "path-to-regexp": "^6.2.2", "preferred-pm": "^4.0.0", "prompts": "^2.4.2", "rehype": "^13.0.1", diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 9087858f1115..41a874871941 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -2094,7 +2094,7 @@ export interface AstroUserConfig { * * The outer page will be rendered, either at build time (`hybrid`) or at runtime (`server`) with the island content omitted and a `