import { GroqBuilderSubquery } from "../../groq-builder"; import { ExtractProjectionResult, ProjectionMap } from "../../types/projection-types"; import { QueryConfig } from "../../types/query-config"; import { RequireAFakeParameterIfThereAreTypeMismatchErrors } from "../../types/type-mismatch-error"; import { ExtractDocumentTypes } from "../../types/document-types"; import { Fragment } from "../../types/fragment-types"; declare module "../../groq-builder" { interface GroqBuilderRoot { /** * Creates a fragment for any type you specify. * This is useful for inline types that do not have a top-level document type. * * @example * const keyValueFragment = q.fragment<{ key: string, value: number }>().project({ * key: z.string(), * value: z.number(), * }) */ fragment(): FragmentUtil; /** * Creates a fragment for a Document, based on the document type. * * @example * const productFragment = q.fragmentForType<"product">().project(sub => ({ * name: z.string(), * price: z.number(), * images: sub.field("images[]").field("asset").deref().project({ * url: z.string(), * altText: z.string(), * }), * })) */ fragmentForType>(): FragmentUtil>; } } /** * When creating a Fragment, we return this utility object * that exposes a `project` method that has almost the same API * as the normal `project` method. */ export type FragmentUtil = { /** * Performs an "object projection", returning an object with the fields specified. * * @param projectionMap - The projection map is an object, mapping field names to projection values * @param __projectionMapTypeMismatchErrors - (internal: this is only used for reporting errors from the projection) */ project, _TProjectionResult = ExtractProjectionResult>(projectionMap: TProjectionMap | ((sub: GroqBuilderSubquery) => TProjectionMap), ...__projectionMapTypeMismatchErrors: RequireAFakeParameterIfThereAreTypeMismatchErrors<_TProjectionResult>): Fragment; };