import { QueryConfig } from "./schema-types"; import type { IsLiteral, LiteralUnion } from "type-fest"; import { StringKeys, UndefinedToNull, ValueOf } from "./utils"; import { Path, PathValue } from "./path-types"; export declare namespace Expressions { /** * This type allows any string, but provides * TypeScript suggestions for common expressions, * like '_type == "product"' or 'slug.current == $slug'. */ export type AnyConditional = LiteralUnion, string>; /** * A strongly-typed conditional Groq conditional expression. * Currently, this only supports simple "equality" expressions, * like '_type == "product"' or 'slug.current == $slug'. * */ export type Conditional = Equality; export type Equality> = ValueOf<{ [Key in SuggestedKeys]: `${Key} == ${SuggestedValues<_ParameterEntries, SuggestedKeysValue>}`; }>; type LiteralValue = TValue extends string ? `"${TValue}"` : TValue extends number | boolean | null ? TValue : never; type LiteralSuggestion = IsLiteral extends true ? never : TValue extends string ? "(string)" : TValue extends number ? "(number)" : never; type SuggestedKeys = Path; type SuggestedKeysValue> = UndefinedToNull>; type SuggestedValues = StringKeysWithType | LiteralSuggestion | LiteralValue; export type ParameterEntries = { [P in Path as `$${P}`]: PathValue; }; /** * Finds all (string) keys of TObject where the value matches the given TType */ export type StringKeysWithType = StringKeys>; export {}; }