nylas
Version:
A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.
59 lines (58 loc) • 2.26 kB
TypeScript
import APIClient from '../apiClient.js';
import { OverridableNylasConfig } from '../config.js';
import { ListQueryParams } from '../models/listQueryParams.js';
import { NylasResponse, NylasListResponse, ListResponseInnerType } from '../models/response.js';
interface ListParams<T> {
queryParams?: ListQueryParams;
path: string;
overrides?: OverridableNylasConfig;
useGenerator?: boolean;
}
interface FindParams<T> {
path: string;
queryParams?: Record<string, any>;
overrides?: OverridableNylasConfig;
}
interface PayloadParams<T> {
path: string;
queryParams?: Record<string, any>;
requestBody: Record<string, any>;
overrides?: OverridableNylasConfig;
}
interface DestroyParams {
path: string;
queryParams?: Record<string, any>;
requestBody?: Record<string, any>;
overrides?: OverridableNylasConfig;
}
type List<T> = NylasListResponse<ListResponseInnerType<T>>;
/**
* Base class for Nylas API resources
*
* @ignore No public constructor or functions
*/
export declare class Resource {
protected apiClient: APIClient;
/**
* @param apiClient client The configured Nylas API client
*/
constructor(apiClient: APIClient);
private fetchList;
private listIterator;
protected _list<T extends List<T>>(listParams: ListParams<T>): AsyncListResponse<T>;
protected _find<T>({ path, queryParams, overrides, }: FindParams<T>): Promise<NylasResponse<T>>;
private payloadRequest;
protected _create<T>(params: PayloadParams<T>): Promise<NylasResponse<T>>;
protected _update<T>(params: PayloadParams<T>): Promise<NylasResponse<T>>;
protected _updatePatch<T>(params: PayloadParams<T>): Promise<NylasResponse<T>>;
protected _destroy<T>({ path, queryParams, requestBody, overrides, }: DestroyParams): Promise<T>;
protected _getRaw({ path, queryParams, overrides, }: FindParams<void>): Promise<Buffer>;
protected _getStream({ path, queryParams, overrides, }: FindParams<void>): Promise<ReadableStream<Uint8Array>>;
}
type ListYieldReturn<T> = T & {
next: () => Promise<IteratorResult<T, undefined>>;
};
export interface AsyncListResponse<T> extends Promise<ListYieldReturn<T>> {
[Symbol.asyncIterator](): AsyncGenerator<T, undefined>;
}
export {};