diff --git a/.changeset/social-maps-shine.md b/.changeset/social-maps-shine.md new file mode 100644 index 000000000000..17b0b5c00942 --- /dev/null +++ b/.changeset/social-maps-shine.md @@ -0,0 +1,5 @@ +--- +'astro': major +--- + +Deprecates `astro:schema` and `z` from `astro:content` in favor of `astro/zod` - ([v6 upgrade guidance](https://deploy-preview-12322--astro-docs-2.netlify.app/en/guides/upgrade-to/v6/#deprecated-astroschema-and-z-from-astrocontent)) diff --git a/benchmark/make-project/markdown-cc1.js b/benchmark/make-project/markdown-cc1.js index 97cd7f1712ab..1045a532bd92 100644 --- a/benchmark/make-project/markdown-cc1.js +++ b/benchmark/make-project/markdown-cc1.js @@ -55,7 +55,8 @@ const { Content } = await render(entry); await fs.writeFile( new URL(`./src/content.config.ts`, projectDir), `\ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/benchmark/make-project/markdown-cc2.js b/benchmark/make-project/markdown-cc2.js index ed0312397b3c..58c35120b518 100644 --- a/benchmark/make-project/markdown-cc2.js +++ b/benchmark/make-project/markdown-cc2.js @@ -30,7 +30,8 @@ ${loremIpsumMd} await fs.writeFile( new URL(`./src/content.config.ts`, projectDir), /*ts */ ` - import { defineCollection, z } from 'astro:content'; + import { defineCollection } from 'astro:content'; + import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/benchmark/make-project/mdx-cc1.js b/benchmark/make-project/mdx-cc1.js index 4d381d921908..c2b4453e956d 100644 --- a/benchmark/make-project/mdx-cc1.js +++ b/benchmark/make-project/mdx-cc1.js @@ -55,7 +55,8 @@ const { Content } = await render(entry); await fs.writeFile( new URL(`./src/content.config.ts`, projectDir), `\ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/benchmark/make-project/mdx-cc2.js b/benchmark/make-project/mdx-cc2.js index 666971050d27..d21c0f8f749d 100644 --- a/benchmark/make-project/mdx-cc2.js +++ b/benchmark/make-project/mdx-cc2.js @@ -30,8 +30,8 @@ ${loremIpsumMd} await fs.writeFile( new URL(`./src/content.config.ts`, projectDir), /*ts */ ` - import { defineCollection, z } from 'astro:content'; - import { glob } from 'astro/loaders'; + import { defineCollection } from 'astro:content'; + import { z } from 'astro/zod'; const blog = defineCollection({ loader: glob({ pattern: '*', base: './data/blog' }), diff --git a/benchmark/make-project/memory-default.js b/benchmark/make-project/memory-default.js index a4f09f8d49af..8154ebf9ea37 100644 --- a/benchmark/make-project/memory-default.js +++ b/benchmark/make-project/memory-default.js @@ -71,7 +71,8 @@ const { Content } = await render(entry); await fs.writeFile( new URL(`./src/content.config.ts`, projectDir), `\ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/examples/blog/src/content.config.ts b/examples/blog/src/content.config.ts index ce37c7f6ff34..7cd3662599d0 100644 --- a/examples/blog/src/content.config.ts +++ b/examples/blog/src/content.config.ts @@ -1,5 +1,6 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; import { glob } from 'astro/loaders'; +import { z } from 'astro/zod'; const blog = defineCollection({ // Load Markdown and MDX files in the `src/content/blog/` directory. diff --git a/examples/portfolio/src/content.config.ts b/examples/portfolio/src/content.config.ts index 2bcc3494efbf..e3747f89ad8b 100644 --- a/examples/portfolio/src/content.config.ts +++ b/examples/portfolio/src/content.config.ts @@ -1,5 +1,6 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; import { glob } from 'astro/loaders'; +import { z } from 'astro/zod'; export const collections = { work: defineCollection({ diff --git a/examples/starlog/src/content.config.ts b/examples/starlog/src/content.config.ts index d29e83364b29..8a812e9b301e 100644 --- a/examples/starlog/src/content.config.ts +++ b/examples/starlog/src/content.config.ts @@ -1,5 +1,6 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; import { glob } from 'astro/loaders'; +import { z } from 'astro/zod'; const releases = defineCollection({ // Load Markdown files in the src/content/releases directory. diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index 7e21a9e8e082..43c263f9f1fa 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -193,8 +193,22 @@ declare module 'astro:components' { export * from 'astro/components'; } +// TODO: remove in Astro 7 +/** + * @deprecated + * `import { z } from 'astro:schema'` is deprecated and will be removed + * in Astro 7. Use `import { z } from 'astro/zod'` instead. + */ declare module 'astro:schema' { export * from 'astro/zod'; + import zod from 'astro/zod'; + + /** + * @deprecated + * `import { z } from 'astro:schema'` is deprecated and will be removed + * in Astro 7. Use `import { z } from 'astro/zod'` instead. + */ + export const z = zod.z; } type MD = import('./dist/types/public/content.js').MarkdownInstance>; diff --git a/packages/astro/e2e/fixtures/actions-blog/src/actions/index.ts b/packages/astro/e2e/fixtures/actions-blog/src/actions/index.ts index 1d75c424a27d..b928330a4a0d 100644 --- a/packages/astro/e2e/fixtures/actions-blog/src/actions/index.ts +++ b/packages/astro/e2e/fixtures/actions-blog/src/actions/index.ts @@ -1,6 +1,6 @@ import { db, Comment, Likes, eq, sql } from 'astro:db'; import { ActionError, defineAction } from 'astro:actions'; -import { z } from 'astro:schema'; +import { z } from 'astro/zod'; import { getCollection } from 'astro:content'; export const server = { diff --git a/packages/astro/e2e/fixtures/actions-blog/src/content.config.ts b/packages/astro/e2e/fixtures/actions-blog/src/content.config.ts index 355d5f45e912..a55948cd80b4 100644 --- a/packages/astro/e2e/fixtures/actions-blog/src/content.config.ts +++ b/packages/astro/e2e/fixtures/actions-blog/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/e2e/fixtures/actions-react-19/src/actions/index.ts b/packages/astro/e2e/fixtures/actions-react-19/src/actions/index.ts index 0c8e90f74ff4..2e4ba89dae20 100644 --- a/packages/astro/e2e/fixtures/actions-react-19/src/actions/index.ts +++ b/packages/astro/e2e/fixtures/actions-react-19/src/actions/index.ts @@ -1,6 +1,6 @@ import { db, Likes, eq, sql } from 'astro:db'; import { defineAction, type SafeResult } from 'astro:actions'; -import { z } from 'astro:schema'; +import { z } from 'astro/zod'; import { getActionState } from '@astrojs/react/actions'; export const server = { diff --git a/packages/astro/e2e/fixtures/actions-react-19/src/content.config.ts b/packages/astro/e2e/fixtures/actions-react-19/src/content.config.ts index 355d5f45e912..a55948cd80b4 100644 --- a/packages/astro/e2e/fixtures/actions-react-19/src/content.config.ts +++ b/packages/astro/e2e/fixtures/actions-react-19/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index d79ae3e23a29..0dc25a512437 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -213,6 +213,7 @@ export async function createVite( find: 'astro:middleware', replacement: 'astro/virtual-modules/middleware.js', }, + // TODO: remove in Astro 7 { find: 'astro:schema', replacement: 'astro/zod', diff --git a/packages/astro/templates/content/module.mjs b/packages/astro/templates/content/module.mjs index 00e4496c8d9c..d3b317101e8f 100644 --- a/packages/astro/templates/content/module.mjs +++ b/packages/astro/templates/content/module.mjs @@ -14,6 +14,7 @@ export { defineLiveCollection, renderEntry as render, } from 'astro/content/runtime'; +// TODO: remove in Astro 7 export { z } from 'astro/zod'; /* @@LIVE_CONTENT_CONFIG@@ */ diff --git a/packages/astro/test/fixtures/actions/src/actions/index.ts b/packages/astro/test/fixtures/actions/src/actions/index.ts index d3cd1b1bba55..ae9272126448 100644 --- a/packages/astro/test/fixtures/actions/src/actions/index.ts +++ b/packages/astro/test/fixtures/actions/src/actions/index.ts @@ -1,5 +1,5 @@ import { defineAction, ActionError } from 'astro:actions'; -import { z } from 'astro:schema'; +import { z } from 'astro/zod'; const passwordSchema = z .string() diff --git a/packages/astro/test/fixtures/astro-assets-dir/src/content.config.ts b/packages/astro/test/fixtures/astro-assets-dir/src/content.config.ts index bbff615cf6e8..652c4943b103 100644 --- a/packages/astro/test/fixtures/astro-assets-dir/src/content.config.ts +++ b/packages/astro/test/fixtures/astro-assets-dir/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from "astro:content"; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from "astro/loaders"; const blogCollection = defineCollection({ diff --git a/packages/astro/test/fixtures/astro-assets-prefix/src/content.config.ts b/packages/astro/test/fixtures/astro-assets-prefix/src/content.config.ts index bbff615cf6e8..652c4943b103 100644 --- a/packages/astro/test/fixtures/astro-assets-prefix/src/content.config.ts +++ b/packages/astro/test/fixtures/astro-assets-prefix/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from "astro:content"; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from "astro/loaders"; const blogCollection = defineCollection({ diff --git a/packages/astro/test/fixtures/astro-env-content-collections/src/content.config.ts b/packages/astro/test/fixtures/astro-env-content-collections/src/content.config.ts index 3276a6789e71..6cce996efc12 100644 --- a/packages/astro/test/fixtures/astro-env-content-collections/src/content.config.ts +++ b/packages/astro/test/fixtures/astro-env-content-collections/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from "astro:content"; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { FOO } from "astro:env/client" console.log({ FOO, BAR: import.meta.env.BAR }) diff --git a/packages/astro/test/fixtures/content with spaces in folder name/src/content.config.ts b/packages/astro/test/fixtures/content with spaces in folder name/src/content.config.ts index a246646a0e7d..521f4c899024 100644 --- a/packages/astro/test/fixtures/content with spaces in folder name/src/content.config.ts +++ b/packages/astro/test/fixtures/content with spaces in folder name/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const withCustomSlugs = defineCollection({ diff --git a/packages/astro/test/fixtures/content-collection-references/src/content.config.ts b/packages/astro/test/fixtures/content-collection-references/src/content.config.ts index d383dd6401e0..786f730de319 100644 --- a/packages/astro/test/fixtures/content-collection-references/src/content.config.ts +++ b/packages/astro/test/fixtures/content-collection-references/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, reference, z } from 'astro:content'; +import { defineCollection, reference } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const banners = defineCollection({ diff --git a/packages/astro/test/fixtures/content-collections-base/src/content.config.ts b/packages/astro/test/fixtures/content-collections-base/src/content.config.ts index ec081aeb4893..fa8c74e5dff0 100644 --- a/packages/astro/test/fixtures/content-collections-base/src/content.config.ts +++ b/packages/astro/test/fixtures/content-collections-base/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; diff --git a/packages/astro/test/fixtures/content-collections-cache-invalidation/src/content.config.ts b/packages/astro/test/fixtures/content-collections-cache-invalidation/src/content.config.ts index 5a097a7cb67c..97afe1fb86c3 100644 --- a/packages/astro/test/fixtures/content-collections-cache-invalidation/src/content.config.ts +++ b/packages/astro/test/fixtures/content-collections-cache-invalidation/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/test/fixtures/content-collections-empty-dir/src/content.config.ts b/packages/astro/test/fixtures/content-collections-empty-dir/src/content.config.ts index 9ea94b911608..5f3d4d354bb3 100644 --- a/packages/astro/test/fixtures/content-collections-empty-dir/src/content.config.ts +++ b/packages/astro/test/fixtures/content-collections-empty-dir/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/test/fixtures/content-collections-empty-md-file/src/content.config.ts b/packages/astro/test/fixtures/content-collections-empty-md-file/src/content.config.ts index 17183a82621b..ab47bec4c286 100644 --- a/packages/astro/test/fixtures/content-collections-empty-md-file/src/content.config.ts +++ b/packages/astro/test/fixtures/content-collections-empty-md-file/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/test/fixtures/content-collections-mutation/src/content.config.ts b/packages/astro/test/fixtures/content-collections-mutation/src/content.config.ts index 29738d550bfb..bf67efe366fc 100644 --- a/packages/astro/test/fixtures/content-collections-mutation/src/content.config.ts +++ b/packages/astro/test/fixtures/content-collections-mutation/src/content.config.ts @@ -1,5 +1,6 @@ // 1. Import utilities from `astro:content` -import { z, defineCollection } from "astro:content"; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from "astro/loaders"; // 2. Define a `type` and `schema` for each collection diff --git a/packages/astro/test/fixtures/content-collections-number-id/src/content.config.ts b/packages/astro/test/fixtures/content-collections-number-id/src/content.config.ts index c2315eff6e0e..f117cf7731c8 100644 --- a/packages/astro/test/fixtures/content-collections-number-id/src/content.config.ts +++ b/packages/astro/test/fixtures/content-collections-number-id/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; const data = defineCollection({ loader: async () => ([ diff --git a/packages/astro/test/fixtures/content-collections-same-contents/src/content.config.ts b/packages/astro/test/fixtures/content-collections-same-contents/src/content.config.ts index ec081aeb4893..fa8c74e5dff0 100644 --- a/packages/astro/test/fixtures/content-collections-same-contents/src/content.config.ts +++ b/packages/astro/test/fixtures/content-collections-same-contents/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; diff --git a/packages/astro/test/fixtures/content-collections-with-config-mjs/src/content/config.mjs b/packages/astro/test/fixtures/content-collections-with-config-mjs/src/content/config.mjs index 8e9d2ee24e32..212a06017916 100644 --- a/packages/astro/test/fixtures/content-collections-with-config-mjs/src/content/config.mjs +++ b/packages/astro/test/fixtures/content-collections-with-config-mjs/src/content/config.mjs @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/test/fixtures/content-collections/src/content.config.ts b/packages/astro/test/fixtures/content-collections/src/content.config.ts index 07b5b3992ec8..b55acb91c92d 100644 --- a/packages/astro/test/fixtures/content-collections/src/content.config.ts +++ b/packages/astro/test/fixtures/content-collections/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const withData = defineCollection({ diff --git a/packages/astro/test/fixtures/content-intellisense/src/content.config.ts b/packages/astro/test/fixtures/content-intellisense/src/content.config.ts index 96b494303960..3442a209f9b4 100644 --- a/packages/astro/test/fixtures/content-intellisense/src/content.config.ts +++ b/packages/astro/test/fixtures/content-intellisense/src/content.config.ts @@ -1,5 +1,6 @@ import { glob, file } from 'astro/loaders'; -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; const blogCC = defineCollection({ loader: glob({ pattern: "**/*.{md,mdx,mdoc}", base: "./src/content/blog-cc" }), diff --git a/packages/astro/test/fixtures/content-layer-remark-plugins/src/content.config.ts b/packages/astro/test/fixtures/content-layer-remark-plugins/src/content.config.ts index 8fc30380482e..eef54f5d843e 100644 --- a/packages/astro/test/fixtures/content-layer-remark-plugins/src/content.config.ts +++ b/packages/astro/test/fixtures/content-layer-remark-plugins/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const docs = defineCollection({ diff --git a/packages/astro/test/fixtures/content-layer-rendering/src/content.config.ts b/packages/astro/test/fixtures/content-layer-rendering/src/content.config.ts index 2a8c005d5f21..00fd18cec784 100644 --- a/packages/astro/test/fixtures/content-layer-rendering/src/content.config.ts +++ b/packages/astro/test/fixtures/content-layer-rendering/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z, reference } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const reptiles = defineCollection({ diff --git a/packages/astro/test/fixtures/content-layer/src/content.config.ts b/packages/astro/test/fixtures/content-layer/src/content.config.ts index d3a173ff654d..8438901a6e2b 100644 --- a/packages/astro/test/fixtures/content-layer/src/content.config.ts +++ b/packages/astro/test/fixtures/content-layer/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z, reference } from 'astro:content'; +import { defineCollection, reference } from 'astro:content'; +import { z } from 'astro/zod'; import { file, glob } from 'astro/loaders'; import { loader } from './loaders/post-loader.js'; import { readFile } from 'fs/promises'; diff --git a/packages/astro/test/fixtures/content-layer/src/loaders/post-loader.ts b/packages/astro/test/fixtures/content-layer/src/loaders/post-loader.ts index b03c1442227e..232819ce2585 100644 --- a/packages/astro/test/fixtures/content-layer/src/loaders/post-loader.ts +++ b/packages/astro/test/fixtures/content-layer/src/loaders/post-loader.ts @@ -1,4 +1,4 @@ -import { z } from 'astro:content'; +import { z } from 'astro/zod'; import type { Loader } from "astro/loaders" export interface PostLoaderConfig { diff --git a/packages/astro/test/fixtures/content-ssr-integration/src/content.config.ts b/packages/astro/test/fixtures/content-ssr-integration/src/content.config.ts index eedbec2cc1f2..6df4d99e5c60 100644 --- a/packages/astro/test/fixtures/content-ssr-integration/src/content.config.ts +++ b/packages/astro/test/fixtures/content-ssr-integration/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/test/fixtures/content-static-paths-integration/src/content.config.ts b/packages/astro/test/fixtures/content-static-paths-integration/src/content.config.ts index 1806ae5abdfb..a880cc1053fd 100644 --- a/packages/astro/test/fixtures/content-static-paths-integration/src/content.config.ts +++ b/packages/astro/test/fixtures/content-static-paths-integration/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/test/fixtures/content/src/content.config.ts b/packages/astro/test/fixtures/content/src/content.config.ts index 850bec0ade94..24cbaa06b073 100644 --- a/packages/astro/test/fixtures/content/src/content.config.ts +++ b/packages/astro/test/fixtures/content/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/test/fixtures/core-image-base/src/content.config.ts b/packages/astro/test/fixtures/core-image-base/src/content.config.ts index 39428c387e24..466ced827049 100644 --- a/packages/astro/test/fixtures/core-image-base/src/content.config.ts +++ b/packages/astro/test/fixtures/core-image-base/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from "astro:content"; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from "astro/loaders"; const blogCollection = defineCollection({ diff --git a/packages/astro/test/fixtures/core-image-deletion/src/content.config.ts b/packages/astro/test/fixtures/core-image-deletion/src/content.config.ts index 89756e2d112c..386e51d7b944 100644 --- a/packages/astro/test/fixtures/core-image-deletion/src/content.config.ts +++ b/packages/astro/test/fixtures/core-image-deletion/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/test/fixtures/core-image-errors/src/content.config.ts b/packages/astro/test/fixtures/core-image-errors/src/content.config.ts index bb3d90b3e9e2..6de7e9cad397 100644 --- a/packages/astro/test/fixtures/core-image-errors/src/content.config.ts +++ b/packages/astro/test/fixtures/core-image-errors/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from "astro:content"; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from "astro/loaders"; const blogCollection = defineCollection({ diff --git a/packages/astro/test/fixtures/core-image-ssg/src/content.config.ts b/packages/astro/test/fixtures/core-image-ssg/src/content.config.ts index 39428c387e24..466ced827049 100644 --- a/packages/astro/test/fixtures/core-image-ssg/src/content.config.ts +++ b/packages/astro/test/fixtures/core-image-ssg/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from "astro:content"; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from "astro/loaders"; const blogCollection = defineCollection({ diff --git a/packages/astro/test/fixtures/core-image-svg/src/content.config.ts b/packages/astro/test/fixtures/core-image-svg/src/content.config.ts index 850bec0ade94..24cbaa06b073 100644 --- a/packages/astro/test/fixtures/core-image-svg/src/content.config.ts +++ b/packages/astro/test/fixtures/core-image-svg/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/astro/test/fixtures/core-image/src/content.config.ts b/packages/astro/test/fixtures/core-image/src/content.config.ts index 8852ace386c8..9525dd1364b7 100644 --- a/packages/astro/test/fixtures/core-image/src/content.config.ts +++ b/packages/astro/test/fixtures/core-image/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from "astro:content"; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from "astro/loaders"; const blogCollection = defineCollection({ diff --git a/packages/astro/test/fixtures/data-collections-schema/src/content.config.ts b/packages/astro/test/fixtures/data-collections-schema/src/content.config.ts index 8a34bfc0234a..67f67382888e 100644 --- a/packages/astro/test/fixtures/data-collections-schema/src/content.config.ts +++ b/packages/astro/test/fixtures/data-collections-schema/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const docs = defineCollection({ diff --git a/packages/astro/test/fixtures/data-collections/src/content.config.ts b/packages/astro/test/fixtures/data-collections/src/content.config.ts index 3694a022471f..46e4104ca3d7 100644 --- a/packages/astro/test/fixtures/data-collections/src/content.config.ts +++ b/packages/astro/test/fixtures/data-collections/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const docs = defineCollection({ diff --git a/packages/astro/test/fixtures/live-loaders/src/live.config.ts b/packages/astro/test/fixtures/live-loaders/src/live.config.ts index 49db510788bb..ec257f3279ed 100644 --- a/packages/astro/test/fixtures/live-loaders/src/live.config.ts +++ b/packages/astro/test/fixtures/live-loaders/src/live.config.ts @@ -1,4 +1,5 @@ -import { defineLiveCollection, z } from 'astro:content'; +import { defineLiveCollection } from 'astro:content'; +import { z } from 'astro/zod'; import type { LiveLoader } from 'astro/loaders'; type Entry = { diff --git a/packages/astro/test/fixtures/sessions/src/actions/index.ts b/packages/astro/test/fixtures/sessions/src/actions/index.ts index 5935e9ea0b6b..73ba32745d17 100644 --- a/packages/astro/test/fixtures/sessions/src/actions/index.ts +++ b/packages/astro/test/fixtures/sessions/src/actions/index.ts @@ -1,5 +1,5 @@ import { defineAction } from 'astro:actions'; -import { z } from 'astro:schema'; +import { z } from 'astro/zod'; export const server = { addToCart: defineAction({ diff --git a/packages/astro/test/units/content-collections/frontmatter.test.js b/packages/astro/test/units/content-collections/frontmatter.test.js index 30e32f867dd4..098f013c65e7 100644 --- a/packages/astro/test/units/content-collections/frontmatter.test.js +++ b/packages/astro/test/units/content-collections/frontmatter.test.js @@ -11,7 +11,8 @@ describe('frontmatter', () => { --- `, '/src/content.config.ts': `\ - import { defineCollection, z } from 'astro:content'; + import { defineCollection } from 'astro:content'; + import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const posts = defineCollection({ diff --git a/packages/astro/types/content.d.ts b/packages/astro/types/content.d.ts index cb5b6d7360b8..ec0f5596974c 100644 --- a/packages/astro/types/content.d.ts +++ b/packages/astro/types/content.d.ts @@ -1,5 +1,5 @@ declare module 'astro:content' { - export { z } from 'astro/zod'; + import zod from 'astro/zod'; export type { ImageFunction, DataEntry, @@ -9,6 +9,14 @@ declare module 'astro:content' { SchemaContext, } from 'astro/content/config'; + // TODO: remove in Astro 7 + /** + * @deprecated + * `import { z } from 'astro:content'` is deprecated and will be removed + * in Astro 7. Use `import { z } from 'astro/zod'` instead. + */ + export const z = zod.z; + export function defineLiveCollection< L extends import('astro/loaders').LiveLoader, S extends import('astro/content/config').BaseSchema | undefined = undefined, diff --git a/packages/integrations/cloudflare/test/fixtures/compile-image-service/src/content.config.ts b/packages/integrations/cloudflare/test/fixtures/compile-image-service/src/content.config.ts index 8692f75e2a18..d22561db62a3 100644 --- a/packages/integrations/cloudflare/test/fixtures/compile-image-service/src/content.config.ts +++ b/packages/integrations/cloudflare/test/fixtures/compile-image-service/src/content.config.ts @@ -1,5 +1,6 @@ import type { ImageMetadata } from 'astro'; -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/integrations/cloudflare/test/fixtures/sessions/src/actions/index.ts b/packages/integrations/cloudflare/test/fixtures/sessions/src/actions/index.ts index 856f68ba8fb1..755cc81ad985 100644 --- a/packages/integrations/cloudflare/test/fixtures/sessions/src/actions/index.ts +++ b/packages/integrations/cloudflare/test/fixtures/sessions/src/actions/index.ts @@ -1,5 +1,5 @@ import { defineAction } from 'astro:actions'; -import { z } from 'astro:schema'; +import { z } from 'astro/zod'; export const server = { addToCart: defineAction({ diff --git a/packages/integrations/markdoc/test/fixtures/content-collections/src/content.config.ts b/packages/integrations/markdoc/test/fixtures/content-collections/src/content.config.ts index bdc0b100eafd..cbdd80130834 100644 --- a/packages/integrations/markdoc/test/fixtures/content-collections/src/content.config.ts +++ b/packages/integrations/markdoc/test/fixtures/content-collections/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/integrations/markdoc/test/fixtures/variables/src/content.config.ts b/packages/integrations/markdoc/test/fixtures/variables/src/content.config.ts index 958e209bf450..0b43709bda97 100644 --- a/packages/integrations/markdoc/test/fixtures/variables/src/content.config.ts +++ b/packages/integrations/markdoc/test/fixtures/variables/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/integrations/mdx/test/fixtures/mdx-images/src/content.config.ts b/packages/integrations/mdx/test/fixtures/mdx-images/src/content.config.ts index 4621eee5fbaf..3397fdd66b83 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-images/src/content.config.ts +++ b/packages/integrations/mdx/test/fixtures/mdx-images/src/content.config.ts @@ -1,4 +1,5 @@ -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from 'astro/loaders'; const blog = defineCollection({ diff --git a/packages/integrations/mdx/test/fixtures/mdx-plus-react-errors/src/content.config.js b/packages/integrations/mdx/test/fixtures/mdx-plus-react-errors/src/content.config.js index 0f045f564881..497e6771d299 100644 --- a/packages/integrations/mdx/test/fixtures/mdx-plus-react-errors/src/content.config.js +++ b/packages/integrations/mdx/test/fixtures/mdx-plus-react-errors/src/content.config.js @@ -1,4 +1,5 @@ -import { z, defineCollection } from "astro:content"; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; import { glob } from "astro/loaders"; const filesSchema = () => { diff --git a/packages/integrations/netlify/test/functions/fixtures/sessions/src/actions/index.ts b/packages/integrations/netlify/test/functions/fixtures/sessions/src/actions/index.ts index 856f68ba8fb1..755cc81ad985 100644 --- a/packages/integrations/netlify/test/functions/fixtures/sessions/src/actions/index.ts +++ b/packages/integrations/netlify/test/functions/fixtures/sessions/src/actions/index.ts @@ -1,5 +1,5 @@ import { defineAction } from 'astro:actions'; -import { z } from 'astro:schema'; +import { z } from 'astro/zod'; export const server = { addToCart: defineAction({ diff --git a/packages/integrations/netlify/test/functions/fixtures/skew-protection/src/actions/index.ts b/packages/integrations/netlify/test/functions/fixtures/skew-protection/src/actions/index.ts index 024595cee9c1..005aba4d457a 100644 --- a/packages/integrations/netlify/test/functions/fixtures/skew-protection/src/actions/index.ts +++ b/packages/integrations/netlify/test/functions/fixtures/skew-protection/src/actions/index.ts @@ -1,5 +1,5 @@ import { defineAction } from 'astro:actions'; -import { z } from 'astro:schema'; +import { z } from 'astro/zod'; export const server = { test: defineAction({ diff --git a/packages/integrations/node/test/fixtures/sessions/src/actions/index.ts b/packages/integrations/node/test/fixtures/sessions/src/actions/index.ts index 856f68ba8fb1..755cc81ad985 100644 --- a/packages/integrations/node/test/fixtures/sessions/src/actions/index.ts +++ b/packages/integrations/node/test/fixtures/sessions/src/actions/index.ts @@ -1,5 +1,5 @@ import { defineAction } from 'astro:actions'; -import { z } from 'astro:schema'; +import { z } from 'astro/zod'; export const server = { addToCart: defineAction({ diff --git a/packages/language-tools/language-server/test/content-intellisense/definitions.test.ts b/packages/language-tools/language-server/test/content-intellisense/definitions.test.ts index f3184d69d011..9d31ffdf630e 100644 --- a/packages/language-tools/language-server/test/content-intellisense/definitions.test.ts +++ b/packages/language-tools/language-server/test/content-intellisense/definitions.test.ts @@ -36,13 +36,13 @@ describe( const { targetRange, targetSelectionRange, originSelectionRange } = definitions[0]; assert.deepStrictEqual(targetRange, { - start: { line: 6, character: 2 }, - end: { line: 6, character: 65 }, + start: { line: 7, character: 2 }, + end: { line: 7, character: 65 }, }); assert.deepStrictEqual(targetSelectionRange, { - start: { line: 6, character: 2 }, - end: { line: 6, character: 7 }, + start: { line: 7, character: 2 }, + end: { line: 7, character: 7 }, }); assert.deepStrictEqual(originSelectionRange, { diff --git a/packages/language-tools/language-server/test/fixture/src/content.config.ts b/packages/language-tools/language-server/test/fixture/src/content.config.ts index 62d6a0d62501..3f1504ef0da2 100644 --- a/packages/language-tools/language-server/test/fixture/src/content.config.ts +++ b/packages/language-tools/language-server/test/fixture/src/content.config.ts @@ -1,5 +1,6 @@ import { glob } from 'astro/loaders'; -import { defineCollection, z } from 'astro:content'; +import { defineCollection } from 'astro:content'; +import { z } from 'astro/zod'; const blog = defineCollection({ loader: glob({ base: './src/content/blog', pattern: '**/[^_]*.md' }),