diff --git a/frontend/package.json b/frontend/package.json index d8954f6..56dc88c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -2,13 +2,14 @@ "name": "frontend", "private": true, "scripts": { - "predev": "npm run typegen", + "predev": "npm run schema:extract && npm run typegen", "dev": "next dev --turbopack", "prebuild": "npm run typegen", "build": "next build", "start": "next start", "lint": "next lint", - "typegen": "sanity typegen generate" + "typegen": "sanity typegen generate", + "schema:extract": "cd ../studio && npm run extract-types" }, "dependencies": { "@sanity/client": "^7.6.0", diff --git a/frontend/sanity.types.ts b/frontend/sanity.types.ts index 1949b81..df43d1c 100644 --- a/frontend/sanity.types.ts +++ b/frontend/sanity.types.ts @@ -176,14 +176,11 @@ export type Page = { slug: Slug; heading: string; subheading?: string; - pageBuilder?: Array< - | ({ - _key: string; - } & CallToAction) - | ({ - _key: string; - } & InfoSection) - >; + pageBuilder?: Array<{ + _key: string; + } & CallToAction | { + _key: string; + } & InfoSection>; }; export type Post = { @@ -252,21 +249,17 @@ export type SanityAssistInstructionTask = { export type SanityAssistTaskStatus = { _type: "sanity.assist.task.status"; - tasks?: Array< - { - _key: string; - } & SanityAssistInstructionTask - >; + tasks?: Array<{ + _key: string; + } & SanityAssistInstructionTask>; }; export type SanityAssistSchemaTypeAnnotations = { _type: "sanity.assist.schemaType.annotations"; title?: string; - fields?: Array< - { - _key: string; - } & SanityAssistSchemaTypeField - >; + fields?: Array<{ + _key: string; + } & SanityAssistSchemaTypeField>; }; export type SanityAssistOutputType = { @@ -319,23 +312,18 @@ export type SanityAssistInstructionUserInput = { }; export type SanityAssistInstructionPrompt = Array<{ - children?: Array< - | { - marks?: Array; - text?: string; - _type: "span"; - _key: string; - } - | ({ - _key: string; - } & SanityAssistInstructionFieldRef) - | ({ - _key: string; - } & SanityAssistInstructionContext) - | ({ - _key: string; - } & SanityAssistInstructionUserInput) - >; + children?: Array<{ + marks?: Array; + text?: string; + _type: "span"; + _key: string; + } | { + _key: string; + } & SanityAssistInstructionFieldRef | { + _key: string; + } & SanityAssistInstructionContext | { + _key: string; + } & SanityAssistInstructionUserInput>; style?: "normal"; listItem?: never; markDefs?: null; @@ -356,24 +344,19 @@ export type SanityAssistInstruction = { title?: string; userId?: string; createdById?: string; - output?: Array< - | ({ - _key: string; - } & SanityAssistOutputField) - | ({ - _key: string; - } & SanityAssistOutputType) - >; + output?: Array<{ + _key: string; + } & SanityAssistOutputField | { + _key: string; + } & SanityAssistOutputType>; }; export type SanityAssistSchemaTypeField = { _type: "sanity.assist.schemaType.field"; path?: string; - instructions?: Array< - { - _key: string; - } & SanityAssistInstruction - >; + instructions?: Array<{ + _key: string; + } & SanityAssistInstruction>; }; export type SanityImagePaletteSwatch = { @@ -494,38 +477,7 @@ export type SanityAssetSourceData = { url?: string; }; -export type AllSanitySchemaTypes = - | CallToAction - | Link - | InfoSection - | BlockContent - | Settings - | Page - | Post - | Person - | SanityAssistInstructionTask - | SanityAssistTaskStatus - | SanityAssistSchemaTypeAnnotations - | SanityAssistOutputType - | SanityAssistOutputField - | SanityAssistInstructionContext - | AssistInstructionContext - | SanityAssistInstructionUserInput - | SanityAssistInstructionPrompt - | SanityAssistInstructionFieldRef - | SanityAssistInstruction - | SanityAssistSchemaTypeField - | SanityImagePaletteSwatch - | SanityImagePalette - | SanityImageDimensions - | SanityImageHotspot - | SanityImageCrop - | SanityFileAsset - | SanityImageAsset - | SanityImageMetadata - | Geopoint - | Slug - | SanityAssetSourceData; +export type AllSanitySchemaTypes = CallToAction | Link | InfoSection | BlockContent | Settings | Page | Post | Person | SanityAssistInstructionTask | SanityAssistTaskStatus | SanityAssistSchemaTypeAnnotations | SanityAssistOutputType | SanityAssistOutputField | SanityAssistInstructionContext | AssistInstructionContext | SanityAssistInstructionUserInput | SanityAssistInstructionPrompt | SanityAssistInstructionFieldRef | SanityAssistInstruction | SanityAssistSchemaTypeField | SanityImagePaletteSwatch | SanityImagePalette | SanityImageDimensions | SanityImageHotspot | SanityImageCrop | SanityFileAsset | SanityImageAsset | SanityImageMetadata | Geopoint | Slug | SanityAssetSourceData; export declare const internalGroqTypeReferenceTo: unique symbol; // Source: ./sanity/lib/queries.ts // Variable: settingsQuery @@ -593,74 +545,60 @@ export type GetPageQueryResult = { slug: Slug; heading: string; subheading: string | null; - pageBuilder: Array< - | { - _key: string; - _type: "callToAction"; - heading: string; + pageBuilder: Array<{ + _key: string; + _type: "callToAction"; + heading: string; + text?: string; + buttonText?: string; + link: { + _type: "link"; + linkType?: "href" | "page" | "post"; + href?: string; + page: string | null; + post: string | null; + openInNewTab?: boolean; + } | null; + } | { + _key: string; + _type: "infoSection"; + heading?: string; + subheading?: string; + content: Array<{ + children?: Array<{ + marks?: Array; text?: string; - buttonText?: string; - link: { - _type: "link"; - linkType?: "href" | "page" | "post"; - href?: string; - page: string | null; - post: string | null; - openInNewTab?: boolean; - } | null; - } - | { + _type: "span"; _key: string; - _type: "infoSection"; - heading?: string; - subheading?: string; - content: Array<{ - children?: Array<{ - marks?: Array; - text?: string; - _type: "span"; - _key: string; - }>; - style?: - | "blockquote" - | "h1" - | "h2" - | "h3" - | "h4" - | "h5" - | "h6" - | "normal"; - listItem?: "bullet" | "number"; - markDefs: Array<{ - linkType?: "href" | "page" | "post"; - href?: string; - page: string | null; - post: string | null; - openInNewTab?: boolean; - _type: "link"; - _key: string; - }> | null; - level?: number; - _type: "block"; - _key: string; - }> | null; - } - > | null; + }>; + style?: "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "normal"; + listItem?: "bullet" | "number"; + markDefs: Array<{ + linkType?: "href" | "page" | "post"; + href?: string; + page: string | null; + post: string | null; + openInNewTab?: boolean; + _type: "link"; + _key: string; + }> | null; + level?: number; + _type: "block"; + _key: string; + }> | null; + }> | null; } | null; // Variable: sitemapData // Query: *[_type == "page" || _type == "post" && defined(slug.current)] | order(_type asc) { "slug": slug.current, _type, _updatedAt, } -export type SitemapDataResult = Array< - | { - slug: string; - _type: "page"; - _updatedAt: string; - } - | { - slug: string; - _type: "post"; - _updatedAt: string; - } ->; +export type SitemapDataResult = Array<{ + slug: string; + _type: "page"; + _updatedAt: string; +} | { + slug: string; + _type: "post"; + _updatedAt: string; +}>; // Variable: allPostsQuery // Query: *[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) { _id, "status": select(_originalId in path("drafts.**") => "draft", "published"), "title": coalesce(title, "Untitled"), "slug": slug.current, excerpt, coverImage, "date": coalesce(date, _updatedAt), "author": author->{firstName, lastName, picture}, } export type AllPostsQueryResult = Array<{ @@ -818,13 +756,13 @@ export type PagesSlugsResult = Array<{ import "@sanity/client"; declare module "@sanity/client" { interface SanityQueries { - '*[_type == "settings"][0]': SettingsQueryResult; - '\n *[_type == \'page\' && slug.current == $slug][0]{\n _id,\n _type,\n name,\n slug,\n heading,\n subheading,\n "pageBuilder": pageBuilder[]{\n ...,\n _type == "callToAction" => {\n \n link {\n ...,\n \n _type == "link" => {\n "page": page->slug.current,\n "post": post->slug.current\n }\n\n }\n,\n },\n _type == "infoSection" => {\n content[]{\n ...,\n markDefs[]{\n ...,\n \n _type == "link" => {\n "page": page->slug.current,\n "post": post->slug.current\n }\n\n }\n }\n },\n },\n }\n': GetPageQueryResult; - '\n *[_type == "page" || _type == "post" && defined(slug.current)] | order(_type asc) {\n "slug": slug.current,\n _type,\n _updatedAt,\n }\n': SitemapDataResult; - '\n *[_type == "post" && defined(slug.current)] | order(date desc, _updatedAt desc) {\n \n _id,\n "status": select(_originalId in path("drafts.**") => "draft", "published"),\n "title": coalesce(title, "Untitled"),\n "slug": slug.current,\n excerpt,\n coverImage,\n "date": coalesce(date, _updatedAt),\n "author": author->{firstName, lastName, picture},\n\n }\n': AllPostsQueryResult; - '\n *[_type == "post" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] {\n \n _id,\n "status": select(_originalId in path("drafts.**") => "draft", "published"),\n "title": coalesce(title, "Untitled"),\n "slug": slug.current,\n excerpt,\n coverImage,\n "date": coalesce(date, _updatedAt),\n "author": author->{firstName, lastName, picture},\n\n }\n': MorePostsQueryResult; - '\n *[_type == "post" && slug.current == $slug] [0] {\n content[]{\n ...,\n markDefs[]{\n ...,\n \n _type == "link" => {\n "page": page->slug.current,\n "post": post->slug.current\n }\n\n }\n },\n \n _id,\n "status": select(_originalId in path("drafts.**") => "draft", "published"),\n "title": coalesce(title, "Untitled"),\n "slug": slug.current,\n excerpt,\n coverImage,\n "date": coalesce(date, _updatedAt),\n "author": author->{firstName, lastName, picture},\n\n }\n': PostQueryResult; - '\n *[_type == "post" && defined(slug.current)]\n {"slug": slug.current}\n': PostPagesSlugsResult; - '\n *[_type == "page" && defined(slug.current)]\n {"slug": slug.current}\n': PagesSlugsResult; + "*[_type == \"settings\"][0]": SettingsQueryResult; + "\n *[_type == 'page' && slug.current == $slug][0]{\n _id,\n _type,\n name,\n slug,\n heading,\n subheading,\n \"pageBuilder\": pageBuilder[]{\n ...,\n _type == \"callToAction\" => {\n \n link {\n ...,\n \n _type == \"link\" => {\n \"page\": page->slug.current,\n \"post\": post->slug.current\n }\n\n }\n,\n },\n _type == \"infoSection\" => {\n content[]{\n ...,\n markDefs[]{\n ...,\n \n _type == \"link\" => {\n \"page\": page->slug.current,\n \"post\": post->slug.current\n }\n\n }\n }\n },\n },\n }\n": GetPageQueryResult; + "\n *[_type == \"page\" || _type == \"post\" && defined(slug.current)] | order(_type asc) {\n \"slug\": slug.current,\n _type,\n _updatedAt,\n }\n": SitemapDataResult; + "\n *[_type == \"post\" && defined(slug.current)] | order(date desc, _updatedAt desc) {\n \n _id,\n \"status\": select(_originalId in path(\"drafts.**\") => \"draft\", \"published\"),\n \"title\": coalesce(title, \"Untitled\"),\n \"slug\": slug.current,\n excerpt,\n coverImage,\n \"date\": coalesce(date, _updatedAt),\n \"author\": author->{firstName, lastName, picture},\n\n }\n": AllPostsQueryResult; + "\n *[_type == \"post\" && _id != $skip && defined(slug.current)] | order(date desc, _updatedAt desc) [0...$limit] {\n \n _id,\n \"status\": select(_originalId in path(\"drafts.**\") => \"draft\", \"published\"),\n \"title\": coalesce(title, \"Untitled\"),\n \"slug\": slug.current,\n excerpt,\n coverImage,\n \"date\": coalesce(date, _updatedAt),\n \"author\": author->{firstName, lastName, picture},\n\n }\n": MorePostsQueryResult; + "\n *[_type == \"post\" && slug.current == $slug] [0] {\n content[]{\n ...,\n markDefs[]{\n ...,\n \n _type == \"link\" => {\n \"page\": page->slug.current,\n \"post\": post->slug.current\n }\n\n }\n },\n \n _id,\n \"status\": select(_originalId in path(\"drafts.**\") => \"draft\", \"published\"),\n \"title\": coalesce(title, \"Untitled\"),\n \"slug\": slug.current,\n excerpt,\n coverImage,\n \"date\": coalesce(date, _updatedAt),\n \"author\": author->{firstName, lastName, picture},\n\n }\n": PostQueryResult; + "\n *[_type == \"post\" && defined(slug.current)]\n {\"slug\": slug.current}\n": PostPagesSlugsResult; + "\n *[_type == \"page\" && defined(slug.current)]\n {\"slug\": slug.current}\n": PagesSlugsResult; } }