import { IsNullable } from "../types/utils"; import { IGroqBuilderNotChainable } from "../groq-builder"; declare module "../groq-builder" { interface GroqBuilder { /** * Asserts that the results are NOT nullable. * Useful when you know there must be a value, * even though the query thinks it might be null. * * ⚠️ NOTE: This method can only be used at the end of a query chain, * because you cannot chain more commands after making an assertion. * See CHAINED_ASSERTION_ERROR for more details. * * @example * q.star * .filterBy("slug.current == $slug") * .slice(0) // <- this return type is nullable, even though we expect there will be a match * .project({ name: z.string() }) * .notNull() // <- this ensures that the results are not null * * @example * q.star.filterByType("product").project(sub => ({ * categories: sub.field("categories[]") // <- nullable array * .deref() * .field("name", z.string()) * .notNull() * })); * * @param redundant - If the type is already not-nullable, then you must explicitly pass `.notNull(true)` to allow this redundancy. (This has no impact at runtime) */ notNull(...redundant: IsNullable extends true ? [] : [true]): IGroqBuilderNotChainable, TQueryConfig>; } }