import { ConnectRestResponse as RestResponse, EndpointDefinition, Logger, ProgressEventsPromise, ProgressingOperationDefinition } from "@objectif-lune/core"; import { OLConnectRestClientContract } from "./interfaces"; export interface RetryHandler { (restResponse: RestResponse): Promise | false; } export declare const DefaultLogger: Logger; export interface OLConnectRestClientOptions { ignorecer?: boolean; logger?: Logger; disableProgress?: boolean; rateLimit?: number; concurrentRateLimit?: number; } export declare class OLConnectRestClient implements OLConnectRestClientContract { #private; private cachedVersion; private concurrentRateLimit; private rateLimiter; get ConcurrentRateLimit(): number; set ConcurrentRateLimit(v: number); constructor(url: string, userName: string | undefined, password: string | undefined, options?: OLConnectRestClientOptions); /** * @returns The version of the Connect Server the client is talking to */ version(logger?: Logger, msgId?: string): Promise; private loginPromise; /** * Performs a login with the credentials stored on this instance * and return the authentication token * * @param logger optional logger * @returns Promise * @throws ServerAuthenticationFailed<{ serverMessage: string }> */ login(logger?: Logger, msgId?: string): Promise; /** * Validate the authentication token and make sure it's not yet expired * * @returns true if the token exist and there is still more than 15 sec until expiration */ private isAuthenticationTokenValid; /** * Performs a handshake and return true when authenticated, * otherwise return false * * @param logger optional logger * @returns Promise */ handshake(logger?: Logger, msgId?: string): Promise; authenticate(forceNewToken?: boolean, logger?: Logger, msgId?: string): Promise; /** * Performs a handshake and when not authenticated perform a login * and wait for the authentication token. * * @param logger optional logger * @returns Promise * @throws ServerAuthenticationFailed<{ serverMessage: string }> */ ready(logger?: Logger, msgId?: string): Promise; /** * Request a REST endpoint, but check first if authentication is still valid. * If not, request a new login first. * Generally, you can send a request, as it will retry when the token has expired. * But in case of sending streams, or very large data objects, this might get too time * consuming or even impossible (streams) * * @param endpoint enpoint definition to request * @throws ServerAuthenticationFailed<{ serverMessage: string }> * @throws depends on endpoint definition */ requestWhenAuthorised(endpoint: EndpointDefinition, alternativeLogger?: Logger): Promise; /** * Request a REST endpoint, but do not include the Authorization token * Basically, you do not want to use this as the server won't accept the request * * @param endpoint enpoint definition to request * @throws ServerStatusCodeNotExpected<{statusCode: number, body: string} * @throws depends on endpoint definition */ requestWithoutToken(endpoint: EndpointDefinition, alternativeLogger?: Logger): Promise; /** * Request a REST endpoint * This method is applicable for most enpoints. * It will call the endpoint, but on a 401 or 403 error it will * re-login and send the request again * * @param endpoint endpoint definition to request * @throws ServerStatusCodeNotExpected<{statusCode: number, body: string} * @throws depends on endpoint definition */ requestWithToken(endpoint: EndpointDefinition, alternativeLogger?: Logger): Promise; /** * Send the request to the given endpoint. The result of this endpoint must be * an operationId. With this, it will poll for the progress and get the result. * * @param endpoint endpoint definition to request * @returns Promise a promise to the final result of the operation * @event START when the operation has started * @event FINISH when the operation has finished * @event PROGRESS when the operation has a new percentage */ requestOperation(endpoint: EndpointDefinition>, alternativeLogger?: Logger): ProgressEventsPromise; createOperationDefinition(restResponse: { operationId: string; }, baseUrl: string, resultCall: (operationId: string) => Promise, logger?: Logger): ProgressingOperationDefinition; filenameLabel(prefix: string, persistName?: string | number): string; logLabel(label: string): string; authenticationModel: { token: string; expiresOn: number; } | null; private retryTimeout; ignorecer: boolean; disableProgress: boolean; private getProgressOfOperation; private cancelOperation; protected call(endpoint: EndpointDefinition, logger: Logger, retryHandler?: RetryHandler, retryCount?: number): Promise; private handleResponse; private writeDebugLog; private mergeHeaders; private static reportServerError; private static reportServerAuthenticationFailed; }