import { fetch } from 'cross-fetch'; import { Observable } from 'rxjs'; type ThenArgRecursive = T extends PromiseLike ? ThenArgRecursive : T; export type FetchResponse = ThenArgRecursive>; export interface RESTAPIEndpoints { readonly accountMicroServiceBaseUrl: string; readonly agentPerfBaseUrl: string; readonly aiCfoMicroServiceBaseUrl: string; readonly approvalMicroServiceBaseUrl: string; readonly authMicroServiceBaseUrl: string; readonly bankingMicroServiceBaseUrl: string; readonly cardMicroServiceBaseUrl: string; readonly communicationAgentMicroServiceBaseUrl: string; readonly documentAIMicroServiceBaseUrl: string; readonly fileMicroServiceBaseUrl: string; readonly insightsMicroServiceBaseUrl: string; readonly invoicingMicroServiceBaseUrl: string; readonly noAuthMicroServiceBaseUrl: string; readonly notificationMicroServiceBaseUrl: string; readonly payMicroServiceBaseUrl: string; readonly reconciliationMicroServiceBaseUrl: string; readonly searchMicroServiceBaseUrl: string; readonly spendManagementMicroServiceBaseUrl: string; readonly taskMicroServiceBaseUrl: string; readonly tenantMicroServiceBaseUrl: string; } export interface ZeniAPI { readonly apiEndPoints: RESTAPIEndpoints; readonly sessionId?: string; readonly tenantId?: string; readonly userId?: string; deleteAndGetJSON(path: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; getFile(path: string, headers?: Record, signal?: AbortSignal): Observable; getJSON(path: string, headers?: Record, signal?: AbortSignal): Observable; patchAndGetJSON(restEndPoint: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; postAndGetJSON(restEndPoint: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; postFormData(restEndPoint: string, formData: FormData, signal?: AbortSignal): Observable; postJSON(restEndPoint: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; putAndGetJSON(restEndPoint: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; update(userId?: string, sessionId?: string, tenantId?: string): void; } export declare class ZeniAPIClient implements ZeniAPI { readonly apiEndPoints: RESTAPIEndpoints; userId?: string | undefined; sessionId?: string | undefined; tenantId?: string | undefined; private readonly onSessionInvalidated?; private sessionInvalidationTriggered; constructor(apiEndPoints: RESTAPIEndpoints, userId?: string | undefined, sessionId?: string | undefined, tenantId?: string | undefined, onSessionInvalidated?: (() => void) | undefined); update(userId?: string, sessionId?: string, tenantId?: string): void; /** * Check if the API response indicates an invalid session (401). * If so, trigger the session invalidation callback once. */ private checkSessionValidity; /** * Parse JSON response and check for session validity. * For 204 No Content, the response body is empty so we return a minimal status object. */ private processJsonResponse; /** * Runs a JSON request that is cancelled when its subscription is torn down. * * `from(promise)` cannot do this: unsubscribing detaches the subscriber but * the request keeps running, so a `switchMap` that drops an in-flight call * leaves a successful response with nobody left to reduce it. Binding an * `AbortController` to the subscription makes teardown actually cancel. * * A teardown-triggered abort is silent — the subscriber is already gone. An * abort through the caller's own `signal` still surfaces as an observable * error, which is what callers passing a signal already expect. */ private observeJSONRequest; getJSON(restEndPoint: string, headers?: Record, signal?: AbortSignal): Observable; postJSON(restEndPoint: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; postAndGetJSON(restEndPoint: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; postFormData(restEndPoint: string, formData: FormData, signal?: AbortSignal): Observable; deleteAndGetJSON(restEndPoint: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; putAndGetJSON(restEndPoint: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; patchAndGetJSON(restEndPoint: string, body?: Record, headers?: Record, signal?: AbortSignal): Observable; getFile(restEndPoint: string, headers?: Record, signal?: AbortSignal): Observable; private apiHeaders; } export {};