@mondaydotcomorg/api
Version:
monday.com API client
45 lines (44 loc) • 2.96 kB
TypeScript
import { ApiVersionType, QueryVariables } from './constants';
import { SeamlessApiClientError } from './errors/seamless-api-client-error';
export { SeamlessApiClientError };
/**
* The `SeamlessApiClient` class provides functionality for making seamless API requests to Monday.com.
* It is specifically designed to be used within the client side of applications deployed on Monday.com,
* leveraging the platform's internal messaging system for communication with the API.
*
*/
export declare class SeamlessApiClient {
readonly apiVersion: ApiVersionType;
private listeners;
/**
* @param {ApiVersionType} [apiVersion=DEFAULT_VERSION] - Can be one of the predefined versions in `AvailableVersions` or a custom version string.
* Defaults to the version corresponding to the package version release (which will be the current),
*/
constructor(apiVersion?: ApiVersionType);
/**
* Performs a seamless query to the Monday API. This function is intended for use exclusively within
* client side of a app thats deployed in Monday.com. It leverages the platform's internal messaging system to
* communicate with the API.
*
* By specifying an `version` parameter, you can override the default API version set at the class level.
* This allows for flexible API version control on a per-query basis, enabling the use of different
* API versions for specific calls if necessary.
*
* @param {string} query - The GraphQL query or mutation string to be sent to the Monday API.
* @param {QueryVariables} [variables] - An optional object containing variables for the query.
* `QueryVariables` is a type alias for `Record<string, any>`, 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 {ApiVersionType} [version] - An optional API version string. If provided, this version overrides
* the class's default API version for this specific query.
* Can be one of the predefined versions in `AvailableVersions` or a custom version string.
* @param {number} [timeout=60000] - An optional timeout value in milliseconds for the request. The default is 60 seconds.
* @returns {Promise<T>} A promise that resolves with the query result.
* @template T The expected type of the query or mutation result.
* @throws {Error} Throws an error if called from within the monday.com platform and the request failed, or if the request timed out.
*/
request<T>(query: string, variables?: QueryVariables, version?: ApiVersionType, timeout?: number): Promise<T>;
private generateRequestId;
private addListener;
private receiveMessage;
}