import { AuthenticationStrategy, BoundAuthenticationStrategy, BuildDescriptors, Descriptors, Host, HostModule, RESTFunctionDescriptor } from '@wix/sdk-types'; import { EmptyObject } from 'type-fest/source/empty-object.js'; import type { GraphQLFormattedError } from 'graphql'; import { EventHandlersClient } from './event-handlers-modules.js'; import { ServicePluginsClient } from './service-plugin-modules.js'; export type ContextType = 'global' | 'module'; type Headers = Record; /** * This type is used in `createClient` to ensure that the given host matches the host of the given descriptors. * If the host does not match, the descriptor is replaced with a host module that will throw an error when used. */ export type AssertHostMatches> = T extends HostModule ? H extends undefined ? never : H extends U ? T : `The host of this module does not match host provided to createClient.` : T extends RESTFunctionDescriptor ? T : { [Key in keyof T]: T[Key] extends Descriptors ? AssertHostMatches : T[Key]; }; type TypedQueryInput = { /** * Type to support `@graphql-typed-document-node/core` * @internal */ __apiType?: (variables: Variables) => Result; /** * Type to support `TypedQueryDocumentNode` from `graphql` * @internal */ __ensureTypesOfVariablesAndResultMatching?: (variables: Variables) => Result; }; export type WixClient | undefined = undefined, Z extends AuthenticationStrategy = AuthenticationStrategy, T extends Descriptors = {}> = { setHeaders(headers: Headers): void; auth: Omit & BoundAuthenticationStrategy; /** * @deprecated Use `fetchWithAuth` instead */ fetch(relativeUrl: string, options: RequestInit): Promise; fetchWithAuth: typeof fetch; use(modules: H extends Host ? AssertHostMatches : R): BuildDescriptors; enableContext(contextType: ContextType, opts?: { elevated: boolean; }): void; graphql(query: string | ((string | String) & TypedQueryInput), variables?: Variables): Promise<{ data: Result; errors?: GraphQLFormattedError[]; }>; webhooks: EventHandlersClient; servicePlugins: ServicePluginsClient; } & BuildDescriptors; export declare function createClient | undefined = undefined, Z extends AuthenticationStrategy = AuthenticationStrategy, T extends Descriptors = EmptyObject>(config: { modules?: H extends Host ? AssertHostMatches : T; auth?: Z; headers?: Headers; host?: H; }): WixClient; export {};