import { ClientError } from 'graphql-request'; import { QueryVariables } from '../constants/index'; import { Sdk } from '../generated/sdk'; import { GraphQLClientResponse, RequestConfig } from 'graphql-request/build/esm/types'; import z from 'zod'; export { ClientError }; export interface ApiClientConfig { token: string; apiVersion?: string; endpoint?: string; requestConfig?: RequestConfig; } declare const requestOptionsSchema: z.ZodObject<{ versionOverride: z.ZodEffects, string | undefined, string | undefined>; timeoutMs: z.ZodOptional; }, "strip", z.ZodTypeAny, { versionOverride?: string | undefined; timeoutMs?: number | undefined; }, { versionOverride?: string | undefined; timeoutMs?: number | undefined; }>; export type RequestOptions = z.infer; /** * The `ApiClient` class provides a structured way to interact with the Monday.com API, * handling GraphQL requests with configurable API versioning. * * This class is designed to be initialized with an authentication token and an optional * API version, setting up the necessary headers for all subsequent API requests. */ export declare class ApiClient { private readonly token; private readonly defaultApiVersion; private readonly defaultEndpoint?; private readonly requestConfig?; readonly operations: Sdk; /** * Constructs a new `ApiClient` instance, storing configuration for dynamic client creation. * * @param {ApiClientConfig} config - Configuration for the API client. * Requires `token`, and optionally includes `apiVersion` and `requestConfig`. */ constructor(config: ApiClientConfig); /** * Creates a GraphQL client with the specified options * * @param {RequestOptions} [options] - Optional request configuration * @returns {GraphQLClient} - Configured GraphQL client */ private createClient; /** * Executes a GraphQL request with common setup and cleanup logic. * * @param {RequestOptions} [options] - Optional request configuration. * @param {Function} executor - Function that performs the actual request. * @returns {Promise} A promise that resolves with the result. * @template T The expected type of the result. */ private executeRequest; /** * Performs a GraphQL query or mutation to the Monday.com API using a dynamically created * GraphQL client. This method is asynchronous and returns a promise that resolves * with the query result. * * @param {string} query - The GraphQL query or mutation string. * @param {QueryVariables} [variables] - An optional object containing variables for the query. * `QueryVariables` is a type alias for `Record`, allowing specification * of key-value pairs where the value can be any type. This parameter is used to provide * dynamic values in the query or mutation. * @param {RequestOptions} [options] - Optional request configuration including version override and timeout. * @returns {Promise} A promise that resolves with the result of the query or mutation. * @template T The expected type of the query or mutation result. * @throws {Error} Throws an error if the request times out before receiving a response. */ request: (query: string, variables?: QueryVariables, options?: RequestOptions) => Promise; /** * Performs a raw GraphQL query or mutation to the Monday.com API using a dynamically created * GraphQL client. This method is asynchronous and returns a promise that resolves * with the query result. * * The result will be in the raw format: data, errors, extensions. * * @param {string} query - The GraphQL query or mutation string. * @param {QueryVariables} [variables] - An optional object containing variables for the query. * `QueryVariables` is a type alias for `Record`, allowing specification * of key-value pairs where the value can be any type. This parameter is used to provide * dynamic values in the query or mutation. * @param {RequestOptions} [options] - Optional request configuration including version override and timeout. * @returns {Promise} A promise that resolves with the result of the query or mutation. * @template T The expected type of the query or mutation result. * @throws {Error} Throws an error if the request times out before receiving a response. */ rawRequest: (query: string, variables?: QueryVariables, options?: RequestOptions) => Promise>; /** * Creates an AbortController with a timeout and a cleanup function. * * @param {number} timeout - The timeout duration in milliseconds. * @returns {{ abortController: AbortController | null, clear: () => void }} - The AbortController and cleanup function. */ private createAbortController; }