import { ClientPerspective, ContentSourceMap, QueryParams, ResponseQueryOptions } from "@sanity/client"; import { Path, StudioPathLike } from "@sanity/client/csm"; import { InitializedStegaConfig, StegaConfig } from "@sanity/client/stega"; import { ArrayOptions, InsertMenuOptions, PreviewValue } from "@sanity/types"; /** * The subset of `@sanity/client` configuration that loaders reconfigure clients with. * @public */ interface SanityClientLikeConfig { allowReconfigure?: boolean; apiVersion?: string; perspective?: ClientPerspective; resultSourceMap?: boolean | 'withKeyArraySelector'; stega?: StegaConfig | boolean; useCdn?: boolean; } /** * The subset of `@sanity/client` query options that loaders pass to `fetch`. * @public */ type SanityClientLikeQueryOptions = Pick; /** * A structural subset of `SanityClient` describing only what loaders need: reading the * configuration, cloning with a new configuration, and running queries. * * Prefer this over `SanityClient` in public options. `SanityClient` declares a `#private` * field, which makes it nominal rather than structural, so a client is only assignable to it * if it comes from the exact same copy of `@sanity/client`. Any duplicate install fails to * typecheck, even at the same version, and so does passing a client from a different major. * * Satisfied by clients from `@sanity/client`, `@sanity/client/stega`, * `@sanity/preview-kit/client` and `next-sanity`, across versions. * @public */ interface SanityClientLike { config(): { dataset?: string; perspective?: ClientPerspective; projectId?: string; stega: InitializedStegaConfig; token?: string; useCdn: boolean; }; withConfig(config: SanityClientLikeConfig): SanityClientLike; /** * `R` defaults to `any` to match `SanityClient['fetch']`, where the same default lets callers * pass the result straight into a generic position. Defaulting to `unknown` instead would be * stricter than the client it stands in for, and callers cannot always name the type. */ fetch(query: string, params?: QueryParams, options?: SanityClientLikeQueryOptions & { filterResponse?: true; }): Promise; fetch(query: string, params: QueryParams, options: SanityClientLikeQueryOptions & { filterResponse: false; }): Promise<{ result: R; resultSourceMap?: ContentSourceMap; }>; } /** * Data resolved from a Sanity node * @public */ type SanityNode = { baseUrl: string; id: string; path: string; perspective?: string; dataset?: string; projectId?: string; tool?: string; type?: string; workspace?: string; }; /** * Data resolved from a Sanity Stega node * @public */ type SanityStegaNode = { origin: string; href: string; data?: unknown; }; interface DocumentSchema { type: 'document'; name: string; title?: string; icon?: string; fields: Partial>; } interface TypeSchema { type: 'type'; name: string; title?: string; value: SchemaNode; } type SchemaType = DocumentSchema | TypeSchema; interface SchemaArrayNode { type: 'array'; of: SchemaArrayItem; } interface SchemaArrayItem { type: 'arrayItem'; name: string; title?: string; value: T; } interface SchemaBooleanNode { type: 'boolean'; value?: boolean; } interface SchemaInlineNode { type: 'inline'; /** the name of the referenced type */ name: string; } interface SchemaNullNode { type: 'null'; } interface SchemaNumberNode { type: 'number'; value?: number; } interface SchemaObjectNode { type: 'object'; fields: Partial>>; rest?: SchemaObjectNode | SchemaUnknownNode | SchemaInlineNode; dereferencesTo?: string; } interface SchemaObjectField { type: 'objectField'; name: string; title?: string; value: T; optional?: boolean; } interface SchemaStringNode { type: 'string'; value?: string; } type SchemaUnionNodeOptions = Omit & { insertMenu?: Omit & { views?: Array<{ name: 'list'; } | { name: 'grid'; previewImageUrls?: Record; }>; }; }; interface SchemaUnionNode { type: 'union'; of: SchemaUnionOption[] | SchemaStringNode[] | SchemaNumberNode[]; options?: SchemaUnionNodeOptions; } interface SchemaUnionOption { type: 'unionOption'; name: string; title?: string; icon?: string; value: T; } interface SchemaUnknownNode { type: 'unknown'; } type SchemaNode = SchemaArrayNode | SchemaBooleanNode | SchemaInlineNode | SchemaNullNode | SchemaNumberNode | SchemaObjectNode | SchemaStringNode | SchemaUnionNode | SchemaUnknownNode; type ResolvedSchemaTypeMap = Map>; interface UnresolvedPath { id: string; path: string; } /** * @public */ type PreviewSnapshot = { [K in keyof Omit]?: Omit[K]; } & { _id: string; }; export { DocumentSchema, type InsertMenuOptions, type Path, PreviewSnapshot, ResolvedSchemaTypeMap, SanityClientLike, SanityClientLikeConfig, SanityClientLikeQueryOptions, SanityNode, SanityStegaNode, SchemaArrayItem, SchemaArrayNode, SchemaBooleanNode, SchemaInlineNode, SchemaNode, SchemaNullNode, SchemaNumberNode, SchemaObjectField, SchemaObjectNode, SchemaStringNode, SchemaType, SchemaUnionNode, SchemaUnionNodeOptions, SchemaUnionOption, SchemaUnknownNode, TypeSchema, UnresolvedPath }; //# sourceMappingURL=index.d.ts.map