import { IccAuthApi, IccMessageApi } from '../icc-api';
import { IccCryptoXApi } from './icc-crypto-x-api';
import * as models from '../icc-api/model/models';
import { ListOfIds, Message, MessagesReadStatusUpdate, PaginatedListMessage, Patient, TimingInfo, User } from '../icc-api/model/models';
import { IccDataOwnerXApi } from './icc-data-owner-x-api';
import { AuthenticationProvider } from './auth/AuthenticationProvider';
import { SecureDelegation } from '../icc-api/model/SecureDelegation';
import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
import { ShareResult } from './utils/ShareResult';
import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest';
import { XHR } from '../icc-api/api/XHR';
import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi';
import { FilterChainMessage } from '../icc-api/model/FilterChainMessage';
import AccessLevelEnum = SecureDelegation.AccessLevelEnum;
import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
import { AbstractFilter } from './filters/filters';
import { SubscriptionOptions } from './utils';
import { Connection } from '../icc-api/model/Connection';
import { SecretIdUseOption } from './crypto/SecretIdUseOption';
export declare class IccMessageXApi extends IccMessageApi implements EncryptedEntityXApi<models.Message> {
    private readonly crypto;
    private readonly dataOwnerApi;
    private readonly authApi;
    private readonly autofillAuthor;
    private readonly encryptedFields;
    get headers(): Promise<Array<XHR.Header>>;
    constructor(host: string, headers: {
        [key: string]: string;
    }, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, authApi: IccAuthApi, autofillAuthor: boolean, authenticationProvider?: AuthenticationProvider, encryptedKeys?: Array<string>, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
    /**
     * Creates a new instance of message with initialised encryption metadata (not in the database).
     * @param user the current user.
     * @param m initialised data for the message. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
     * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
     * @return a new instance of message.
     */
    newInstance(user: User, m: any): Promise<models.Message>;
    /**
     * Creates a new instance of message with initialised encryption metadata (not in the database).
     * @param user the current user.
     * @param patient the patient this message refers to.
     * @param m initialised data for the message. Metadata such as id, creation data, etc. will be automatically initialised, but you can specify
     * other kinds of data or overwrite generated metadata with this. You can't specify encryption metadata.
     * @param options optional parameters:
     * - additionalDelegates: delegates which will have access to the entity in addition to the current data owner and delegates from the
     * auto-delegations. Must be an object which associates each data owner id with the access level to give to that data owner. May overlap with
     * auto-delegations, in such case the access level specified here will be used.
     * - preferredSfk: secret id of the patient to use as the secret foreign key to use for the message. The default value will be a
     * secret id of patient known by the topmost parent in the current data owner hierarchy.
     * - alternateRootDelegation: by default a new entity is created with a root delegation from self to self. In keyless mode this is not possible,
     * and instead the root delegation will be from self to another. You have to specify which delegate will be part of the root delegation.
     * @return a new instance of message.
     */
    newInstanceWithPatient(user: User, patient: Patient | null, m?: any, options?: {
        additionalDelegates?: {
            [dataOwnerId: string]: AccessLevelEnum;
        };
        sfkOption?: SecretIdUseOption;
        alternateRootDelegation?: string;
    }): Promise<models.Message>;
    /**
     * Decrypts the encrypted content of messages.
     * @param messages the messages to decrypt.
     * @return the decrypted messages with their encryption status.
     */
    decrypt(messages: Array<models.Message>): Promise<{
        entity: models.Message;
        decrypted: boolean;
    }[]>;
    /**
     * Encrypts the content of messages.
     * @param messages the messages to encrypt.
     * @return the encrypted messages.
     */
    encrypt(messages: Array<models.Message>): Promise<Array<models.Message>>;
    /**
     * @param message a message
     * @return the id of the patient that the message refers to, retrieved from the encrypted metadata. Normally there should only be one element
     * in the returned array, but in case of entity merges there could be multiple values.
     */
    decryptPatientIdOf(message: models.Message): Promise<string[]>;
    /**
     * @return if the logged data owner has write access to the content of the given message
     */
    hasWriteAccess(message: models.Message): Promise<boolean>;
    /**
     * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also
     * the encrypted content, with read-only or read-write permissions.
     * @param delegateId the id of the data owner which will be granted access to the message.
     * @param message the message to share.
     * @param shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the
     * shared Message is the owning entity id.
     * @param options optional parameters to customize the sharing behaviour:
     * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
     * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
     * message does not have encrypted content.
     * - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to
     * {@link ShareMetadataBehaviour.IF_AVAILABLE}).
     * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
     * @return the updated entity
     */
    shareWith(delegateId: string, message: models.Message, shareSecretIds: string[], options?: {
        requestedPermissions?: RequestedPermissionEnum;
        shareEncryptionKey?: ShareMetadataBehaviour;
        sharePatientId?: ShareMetadataBehaviour;
    }): Promise<models.Message>;
    /**
     * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also
     * the encrypted content, with read-only or read-write permissions.
     * @param message the message to share.
     * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
     * - shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the
     * shared Message is the owning entity id. Mandatory.
     * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
     * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
     * message does not have encrypted content.
     * - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to
     * {@link ShareMetadataBehaviour.IF_AVAILABLE}).
     * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
     * @return the updated entity
     */
    shareWithMany(message: models.Message, delegates: {
        [delegateId: string]: {
            shareSecretIds: string[];
            requestedPermissions?: RequestedPermissionEnum;
            shareEncryptionKey?: ShareMetadataBehaviour;
            sharePatientId?: ShareMetadataBehaviour;
        };
    }): Promise<models.Message>;
    /**
     * Share an existing message with other data owners, allowing them to access the non-encrypted data of the message and optionally also
     * the encrypted content, with read-only or read-write permissions.
     * @param message the message to share.
     * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
     * - shareSecretIds the secret ids of the Message that the delegate will be given access to. Allows the delegate to search for data where the
     * shared Message is the owning entity id. Mandatory.
     * - shareEncryptionKey: specifies if the encryption key of the access log should be shared with the delegate, giving access to all encrypted
     * content of the entity, excluding other encrypted metadata (defaults to {@link ShareMetadataBehaviour.IF_AVAILABLE}). Note that by default a
     * message does not have encrypted content.
     * - sharePatientId: specifies if the id of the patient that this message refers to should be shared with the delegate (defaults to
     * {@link ShareMetadataBehaviour.IF_AVAILABLE}).
     * - requestedPermissions: the requested permissions for the delegate, defaults to {@link RequestedPermissionEnum.MAX_WRITE}.
     * @return a promise which will contain the result of the operation: the updated entity if the operation was successful or details of the error if
     * the operation failed.
     */
    tryShareWithMany(message: models.Message, delegates: {
        [delegateId: string]: {
            shareSecretIds: string[];
            requestedPermissions?: RequestedPermissionEnum;
            shareEncryptionKey?: ShareMetadataBehaviour;
            sharePatientId?: ShareMetadataBehaviour;
        };
    }): Promise<ShareResult<models.Message>>;
    /**
     * @param message a message
     * @return the secret ids of the message, retrieved from the encrypted metadata. The result may be used to find entities where the message is
     * the 'owning entity', or in the {@link shareWith} method in order to share it with other data owners.
     */
    decryptSecretIdsOf(message: models.Message): Promise<string[]>;
    /**
     * Creates or updates de-anonymization metadata for the message, allowing resolution of anonymous delegations.
     * @param entity the message.
     * @param delegates the data owner ids of the delegates.
     */
    createDelegationDeAnonymizationMetadata(entity: Message, delegates: string[]): Promise<void>;
    /**
     * Retrieves the data owners that have access to the message.
     * @param entity the message.
     * @return the data owners with their access levels and a flag indicating if there are unknown anonymous data owners.
     */
    getDataOwnersWithAccessTo(entity: models.Message): Promise<{
        permissionsByDataOwnerId: {
            [p: string]: AccessLevelEnum;
        };
        hasUnknownAnonymousDataOwners: boolean;
    }>;
    /**
     * Retrieves the encryption keys of the message.
     * @param entity the message.
     * @return the encryption keys.
     */
    getEncryptionKeysOf(entity: models.Message): Promise<string[]>;
    /**
     * Subscribes to message events (create, update, delete).
     * @param eventTypes the types of events to subscribe to.
     * @param filter optional filter to apply to the events.
     * @param eventFired callback function to be called when an event is fired.
     * @param options optional subscription options.
     * @return a connection that can be used to close the subscription.
     */
    subscribeToMessageEvents(eventTypes: ('CREATE' | 'UPDATE' | 'DELETE')[], filter: AbstractFilter<Message> | undefined, eventFired: (message: Message) => Promise<void>, options?: SubscriptionOptions): Promise<Connection>;
    private decryptPage;
    /**
     * Creates a message.
     * @param user the current user (unused, for compatibility).
     * @param body the message to create.
     * @return the created message.
     */
    createMessageWithUser(user: models.User | undefined, body: Message): Promise<Message>;
    /**
     * Finds messages with pagination.
     * @param user the current user (unused, for compatibility).
     * @param startKey optional start key for pagination.
     * @param startDocumentId optional start document id for pagination.
     * @param limit optional maximum number of results to return.
     * @return a paginated list of messages.
     */
    findMessagesWithUser(user: models.User | undefined, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListMessage>;
    /**
     * Finds messages by sender address with pagination.
     * @param user the current user (unused, for compatibility).
     * @param fromAddress the sender address to filter by.
     * @param startKey optional start key for pagination.
     * @param startDocumentId optional start document id for pagination.
     * @param limit optional maximum number of results to return.
     * @param hcpId optional healthcare party id to filter by.
     * @return a paginated list of messages.
     */
    findMessagesByFromAddressWithUser(user: models.User | undefined, fromAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, hcpId?: string): Promise<PaginatedListMessage>;
    /**
     * @deprecated
     */
    findMessagesByHCPartyPatientForeignKeysUsingPostWithUser(user: models.User | undefined, body?: Array<string>): Promise<Array<Message>>;
    /**
     * @deprecated
     */
    findMessagesByHCPartyPatientForeignKeysWithUser(user: models.User | undefined, secretFKeys: string): Promise<Array<Message>>;
    /**
     * Finds messages by recipient address with pagination.
     * @param user the current user (unused, for compatibility).
     * @param toAddress the recipient address to filter by.
     * @param startKey optional start key for pagination.
     * @param startDocumentId optional start document id for pagination.
     * @param limit optional maximum number of results to return.
     * @param reverse optional flag to reverse the sort order.
     * @param hcpId optional healthcare party id to filter by.
     * @return a paginated list of messages.
     */
    findMessagesByToAddressWithUser(user: models.User | undefined, toAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, reverse?: boolean, hcpId?: string): Promise<PaginatedListMessage>;
    /**
     * Finds messages by transport GUID with pagination.
     * @param user the current user (unused, for compatibility).
     * @param transportGuid the transport GUID to filter by.
     * @param received optional flag to filter by received status.
     * @param startKey optional start key for pagination.
     * @param startDocumentId optional start document id for pagination.
     * @param limit optional maximum number of results to return.
     * @param hcpId optional healthcare party id to filter by.
     * @return a paginated list of messages.
     */
    findMessagesByTransportGuidWithUser(user: models.User | undefined, transportGuid?: string, received?: boolean, startKey?: string, startDocumentId?: string, limit?: number, hcpId?: string): Promise<PaginatedListMessage>;
    /**
     * Finds messages by transport GUID and sent date range with pagination.
     * @param user the current user (unused, for compatibility).
     * @param transportGuid the transport GUID to filter by.
     * @param from optional start timestamp for the date range.
     * @param to optional end timestamp for the date range.
     * @param startKey optional start key for pagination.
     * @param startDocumentId optional start document id for pagination.
     * @param limit optional maximum number of results to return.
     * @param hcpId optional healthcare party id to filter by.
     * @return a paginated list of messages.
     */
    findMessagesByTransportGuidSentDateWithUser(user: models.User | undefined, transportGuid?: string, from?: number, to?: number, startKey?: string, startDocumentId?: string, limit?: number, hcpId?: string): Promise<PaginatedListMessage>;
    /**
     * Retrieves the children messages of a message.
     * @param user the current user (unused, for compatibility).
     * @param messageId the id of the parent message.
     * @return the children messages.
     */
    getChildrenMessagesWithUser(user: models.User | undefined, messageId: string): Promise<Array<Message>>;
    /**
     * Retrieves the children messages of a list of parent messages.
     * @param user the current user (unused, for compatibility).
     * @param body the list of parent message ids.
     * @return the children messages.
     */
    getChildrenMessagesOfListWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<Message>>;
    /**
     * Retrieves a message by its id.
     * @param user the current user (unused, for compatibility).
     * @param messageId the id of the message.
     * @return the message.
     */
    getMessageWithUser(user: models.User | undefined, messageId: string): Promise<Message>;
    /**
     * Retrieves multiple messages by their ids.
     * @param user the current user (unused, for compatibility).
     * @param messageIds the list of message ids.
     * @return the messages.
     */
    getMessagesWithUser(user: models.User | undefined, messageIds: ListOfIds): Promise<Message[]>;
    /**
     * Lists messages by invoice ids.
     * @param user the current user (unused, for compatibility).
     * @param body the list of invoice ids.
     * @return the messages associated with the invoices.
     */
    listMessagesByInvoiceIdsWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<Message>>;
    /**
     * Lists messages by transport GUIDs.
     * @param user the current user (unused, for compatibility).
     * @param hcpId the healthcare party id.
     * @param body the list of transport GUIDs.
     * @return the messages associated with the transport GUIDs.
     */
    listMessagesByTransportGuidsWithUser(user: models.User | undefined, hcpId: string, body?: ListOfIds): Promise<Array<Message>>;
    /**
     * Modifies a message.
     * @param user the current user (unused, for compatibility).
     * @param body the message to modify.
     * @return the modified message.
     */
    modifyMessageWithUser(user: models.User | undefined, body: Message): Promise<Message>;
    /**
     * Sets the status bits of multiple messages.
     * @param user the current user (unused, for compatibility).
     * @param status the status bits to set.
     * @param body the list of message ids.
     * @return the updated messages.
     */
    setMessagesStatusBitsWithUser(user: models.User | undefined, status: number, body?: ListOfIds): Promise<Array<Message>>;
    /**
     * Filters messages using a filter chain with pagination.
     * @param user the current user (unused, for compatibility).
     * @param body the filter chain to apply.
     * @param startDocumentId optional start document id for pagination.
     * @param limit optional maximum number of results to return.
     * @param collectTiming add timing information to the response
     * @return a paginated list of filtered messages.
     */
    filterMessagesByWithUser(user: models.User | undefined, body: FilterChainMessage, startDocumentId?: string, limit?: number, collectTiming?: false): Promise<PaginatedListMessage>;
    filterMessagesByWithUser(user: models.User | undefined, body: FilterChainMessage, startDocumentId?: string, limit?: number, collectTiming?: true): Promise<PaginatedListMessage & TimingInfo>;
    /**
     * Sets the read status of multiple messages.
     * @param user the current user (unused, for compatibility).
     * @param body the read status update information.
     * @return the updated messages.
     */
    setMessagesReadStatusWithUser(user: models.User | undefined, body?: MessagesReadStatusUpdate): Promise<Array<Message>>;
    createMessage(body?: Message): never;
    findMessages(startKey?: string, startDocumentId?: string, limit?: number): never;
    findMessagesByFromAddress(fromAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, hcpId?: string): never;
    findMessagesByHCPartyPatientForeignKeysUsingPost(body?: Array<string>): never;
    findMessagesByHCPartyPatientForeignKeys(secretFKeys: string): never;
    findMessagesByToAddress(toAddress?: string, startKey?: string, startDocumentId?: string, limit?: number, reverse?: boolean, hcpId?: string): never;
    findMessagesByTransportGuid(transportGuid?: string, received?: boolean, startKey?: string, startDocumentId?: string, limit?: number, hcpId?: string): never;
    findMessagesByTransportGuidSentDate(transportGuid?: string, from?: number, to?: number, startKey?: string, startDocumentId?: string, limit?: number, hcpId?: string): never;
    getChildrenMessages(messageId: string): never;
    getChildrenMessagesOfList(body?: ListOfIds): never;
    getMessage(messageId: string): never;
    getMessages(messageIds: ListOfIds): never;
    listMessagesByInvoiceIds(body?: ListOfIds): never;
    listMessagesByTransportGuids(hcpId: string, body?: ListOfIds): never;
    modifyMessage(body?: Message): never;
    setMessagesStatusBits(status: number, body?: ListOfIds): never;
    filterMessagesBy(body: FilterChainMessage, startDocumentId?: string, limit?: number): never;
    setMessagesReadStatus(body?: MessagesReadStatusUpdate): never;
}
