import type { Logger } from 'generic-logger-typings'; import { StateMachine, ListenerRegistration } from 'typescript-state-machine'; import type { Filter, InstalledFilter, Request, Response } from 'typescript-http-client'; import { DeviceMessage, Item, Principal, User, UUID } from 'ozone-type'; import { ClientState } from './clientState'; import { ItemClient } from '../itemClient/itemClient'; import { BlobClient } from '../blobClient/blobClient'; import { RoleClient } from '../roleClient/roleClient'; import { PermissionClient } from '../permissionClient/permissionClient'; import { TypeClient } from '../typeClient/typeClient'; import { TaskClient } from '../taskClient/taskClient'; import { ImportExportClient } from '../importExportClient/importExportClient'; import { FileTypeClient } from '../filetypeClient/filetypeClient'; import { TypedDocumentNode } from '@apollo/client/core'; export declare enum DEFAULT_FILTERS { PRE_FILTERS = "pre-filters", SESSION_REFRESH = "session-refresh", SESSION_FILTER = "session-filter", DEFAULT_OPTIONS = "default-options", POST_FILTERS = "post-filters" } export interface AuthInfo { principalClass: string; principalId: string; sessionId: string; } export interface ClientConfiguration { ozoneURL: string; ozoneInstanceId?: string; ozoneCredentials?: OzoneCredentials; webSocketsURL?: string; defaultTimeout?: number; defaultFilters?: DEFAULT_FILTERS[]; } export interface OzoneCredentials { authenticate(ozoneURL: string): Promise; } export declare type AuthenticatedPrincipal = ((User & { tenantId: UUID; }) | (Principal & { tenant: UUID; })) & { id: UUID; }; export interface OzoneClient extends StateMachine { readonly config: ClientConfiguration; readonly authInfo?: AuthInfo; readonly lastFailedLogin?: Response; readonly isAuthenticated: boolean; readonly isConnected: boolean; start(): Promise; readonly preFilters: InstalledFilter[]; readonly postFilters: InstalledFilter[]; updateWSURL(url: string): void; updateCredentials(ozoneCredentials: OzoneCredentials): void; /** * Retrieve the principal this client has authenticated with * @throws if client is not authenticated */ currentPrincipal(): Promise; stop(): Promise; callForResponse(request: Request): Promise>; call(request: Request): Promise; onMessage(messageType: string, callBack: (message: M) => void): ListenerRegistration; onAnyMessage(callBack: (message: DeviceMessage) => void): ListenerRegistration; send(message: DeviceMessage): void; itemClient(typeIdentifier: string): ItemClient; blobClient(): BlobClient; roleClient(): RoleClient; /** * get client to work with type */ typeClient(): TypeClient; /** * get task client to wait manage task */ taskClient(): TaskClient; /** * get client to work with permission */ permissionClient(): PermissionClient; /** * get client to work with permission */ importExportClient(): ImportExportClient; /** * file file type client */ fileTypeClient(): FileTypeClient; insertSessionIdInURL(url: string): string; /** * Add a custom filter * @param filter to add */ addCustomFilter(filter: Filter, name: string): void; /** * Provide external logger to client * @param logger The logger to use */ setLogger(logger: Logger): void; graphQLSearch(query: TypedDocumentNode, variables?: TVariables): Promise; }