import { IccAuthApi, IccDocumentApi } from '../icc-api';
import { IccCryptoXApi } from './icc-crypto-x-api';
import { XHR } from '../icc-api/api/XHR';
import * as models 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 { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi';
import AccessLevelEnum = SecureDelegation.AccessLevelEnum;
import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
import { SecretIdUseOption } from './crypto/SecretIdUseOption';
import { ListOfIds, PaginatedListDocument } from '../icc-api/model/models';
export declare class IccDocumentXApi extends IccDocumentApi implements EncryptedEntityXApi<models.Document> {
    private crypto;
    private authApi;
    private readonly autofillAuthor;
    fetchImpl: (input: RequestInfo, init?: RequestInit) => Promise<Response>;
    /** maps invalid UTI values to corresponding MIME type for backward-compatibility (pre-v1.0.117) */
    compatUtiRevDefs: {
        [key: string]: string;
    };
    utiRevDefs: {
        [key: string]: string;
    };
    utiExts: {
        [key: string]: string;
    };
    utiDefs: {
        [key: string]: string;
    };
    dataOwnerApi: IccDataOwnerXApi;
    authenticationProvider: AuthenticationProvider;
    private readonly encryptedFields;
    constructor(host: string, headers: {
        [key: string]: string;
    }, crypto: IccCryptoXApi, authApi: IccAuthApi, dataOwnerApi: IccDataOwnerXApi, autofillAuthor: boolean, authenticationProvider?: AuthenticationProvider, encryptedKeys?: Array<string>, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
    get headers(): Promise<Array<XHR.Header>>;
    /**
     * Creates a new instance of document with initialised encryption metadata (not in the database).
     * @param user the current user.
     * @param message the message this document refers to.
     * @param c initialised data for the document. 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.
     * - sfkOption: specifies which sfk of the owning entity to use.
     * - ignoreAutoDelegations: if true the data won't be shared with the autodelegations of the user, but only with additional delegates
     * - 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 document.
     */
    newInstance(user: models.User, message?: models.Message, c?: any, options?: {
        additionalDelegates?: {
            [dataOwnerId: string]: AccessLevelEnum;
        };
        sfkOption?: SecretIdUseOption;
        ignoreAutoDelegations?: boolean;
        alternateRootDelegation?: string;
    }): Promise<models.Document>;
    /**
     * Same as {@link findByMessage} but it will only return the ids of the documents. It can also filter the documents where Document.created is between
     * startDate and endDate in ascending or descending order by that field. (default: ascending).
     */
    findIdsByMessage(hcpartyId: string, message: models.Message, startDate?: number, endDate?: number, descending?: boolean): Promise<string[]>;
    /**
     * Decrypts an array of documents.
     * @param documents the documents to decrypt.
     * @return an array of objects containing the document and a flag indicating if it was successfully decrypted.
     */
    decrypt(documents: Array<models.Document>): Promise<{
        entity: models.Document;
        decrypted: boolean;
    }[]>;
    /**
     * Encrypts an array of documents.
     * @param documents the documents to encrypt.
     * @return the encrypted documents.
     */
    encrypt(documents: Array<models.Document>): Promise<Array<models.Document>>;
    getAttachmentAs(documentId: string, attachmentId: string, returnType: "application/octet-stream", enckeys?: string, fileName?: string): Promise<ArrayBuffer>;
    getAttachmentAs(documentId: string, attachmentId: string, returnType: "text/plain", enckeys?: string, fileName?: string): Promise<string>;
    getAttachmentAs(documentId: string, attachmentId: string, returnType: "application/json", enckeys?: string, fileName?: string): Promise<any>;
    getMainAttachmentAs(documentId: string, returnType: "application/octet-stream"): Promise<ArrayBuffer>;
    getMainAttachmentAs(documentId: string, returnType: "text/plain"): Promise<string>;
    getMainAttachmentAs(documentId: string, returnType: "application/json", tryHardToParseJson?: boolean): Promise<any>;
    getMainAttachmentAs(documentId: string, returnType: 'application/octet-stream' | 'text/plain' | 'application/json', tryHardToParseJson?: boolean): Promise<any>;
    getAndTryDecryptMainAttachmentAs(document: models.Document, returnType: "application/octet-stream"): Promise<ArrayBuffer | undefined>;
    getAndTryDecryptMainAttachmentAs(document: models.Document, returnType: "text/plain"): Promise<string | undefined>;
    getAndTryDecryptMainAttachmentAs(document: models.Document, returnType: "application/json"): Promise<any | undefined>;
    getAndTryDecryptMainAttachmentAs(document: models.Document, returnType: 'application/octet-stream' | 'text/plain' | 'application/json'): Promise<any | undefined>;
    private parserFor;
    /**
     * Converts a MIME type and file extension to a UTI (Uniform Type Identifier).
     * @param mimeType the MIME type.
     * @param extension the file extension.
     * @return the corresponding UTI.
     */
    uti(mimeType: string, extension: string): string;
    /**
     * Converts a UTI (Uniform Type Identifier) to a MIME type.
     * @param uti the UTI.
     * @return the corresponding MIME type.
     */
    mimeType(uti: string): string;
    /**
     * Adds an attachment to a document, encrypting it on client side using the encryption keys of the provided document.
     * @param document a document.
     * @param attachment a new main attachment for the document.
     * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
     * overrides existing values.
     * @param deflate if true, compress the attachment before uploading. Reliable decompression of compressed data requires version 26.5 of the API and all users to be using at least version 8.7.0 of the SDK    * @return the updated document.
     */
    encryptAndSetDocumentAttachment(document: models.Document, attachment: ArrayBuffer | Uint8Array, utis?: string[], deflate?: boolean): Promise<models.Document>;
    /**
     * Adds an unencrypted attachment to a document.
     * @param document a document.
     * @param attachment a new main attachment for the document.
     * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
     * overrides existing values.
     * @param deflate if true, compress the attachment before uploading. Reliable decompression of compressed data requires version 26.5 of the API and all users to be using at least version 8.7.0 of the SDK    * @return the updated document.
     */
    setClearDocumentAttachment(document: models.Document, attachment: ArrayBuffer | Uint8Array, utis?: string[], deflate?: boolean): Promise<models.Document>;
    /**
     * Adds a secondary attachment to a document, encrypting it on client side using the encryption keys of the provided document.
     * @param document a document.
     * @param secondaryAttachmentKey key for the secondary attachment.
     * @param attachment a new secondary attachment for the document.
     * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
     * overrides existing values.
     * @param deflate if true, compress the attachment before uploading. Reliable decompression of compressed data requires version 26.5 of the API and all users to be using at least version 8.7.0 of the SDK    * @return the updated document.
     */
    encryptAndSetSecondaryDocumentAttachment(document: models.Document, secondaryAttachmentKey: string, attachment: ArrayBuffer | Uint8Array, utis?: string[], deflate?: boolean): Promise<models.Document>;
    /**
     * Adds an unencrypted secondary attachment to a document.
     * @param document a document.
     * @param secondaryAttachmentKey key for the secondary attachment.
     * @param attachment a new secondary attachment for the document.
     * @param utis an array of UTIs for the attachment. The first element will be considered as the main UTI for the document. If provided and non-empty
     * overrides existing values.
     * @param deflate if true, compress the attachment before uploading. Reliable decompression of compressed data requires version 26.5 of the API and all users to be using at least version 8.7.0 of the SDK
     * @return the updated document.
     */
    setClearSecondaryDocumentAttachment(document: models.Document, secondaryAttachmentKey: string, attachment: ArrayBuffer | Uint8Array, utis?: string[], deflate?: boolean): Promise<models.Document>;
    /**
     * Gets the main attachment of a document and tries to decrypt it using the encryption keys of the document, throwing an error if the operation fails.
     * @param document a document.
     * @param validator optionally a validator function which checks if the decryption was successful. In cases where the document has many encryption
     * keys and it is unclear which one should be used this function can help to detect bad decryptions.
     * @return the decrypted attachment, if it could be decrypted, else the encrypted attachment.
     */
    getAndDecryptDocumentAttachment(document: models.Document, validator?: (decrypted: ArrayBuffer) => Promise<boolean>): Promise<ArrayBuffer>;
    /**
     * Gets the main attachment of a document and tries to decrypt it using the encryption keys of the document.
     * @param document a document.
     * @param validator optionally a validator function which checks if the decryption was successful. In cases where the document has many encryption
     * keys and it is unclear which one should be used this function can help to detect bad decryptions.
     * @return an object containing:
     * - data: the decrypted attachment, if it could be decrypted, else the encrypted attachment.
     * - wasDecrypted: if the data was successfully decrypted or not
     */
    getAndTryDecryptDocumentAttachment(document: models.Document, validator?: (decrypted: ArrayBuffer) => Promise<boolean>): Promise<{
        data: ArrayBuffer;
        wasDecrypted: boolean;
    }>;
    /**
     * Gets the secondary attachment of a document and tries to decrypt it using the encryption keys of the document, throwing an error if the operation fails.
     * @param document a document.
     * @param secondaryAttachmentKey key of the secondary attachment.
     * @param validator optionally a validator function which checks if the decryption was successful. In cases where the document has many encryption
     * keys and it is unclear which one should be used this function can help to detect bad decryptions.
     * @return the decrypted attachment.
     */
    getAndDecryptSecondaryDocumentAttachment(document: models.Document, secondaryAttachmentKey: string, validator?: (decrypted: ArrayBuffer) => Promise<boolean>): Promise<ArrayBuffer>;
    /**
     * Gets the secondary attachment of a document and tries to decrypt it using the encryption keys of the document.
     * @param document a document.
     * @param secondaryAttachmentKey key of the secondary attachment.
     * @param validator optionally a validator function which checks if the decryption was successful. In cases where the document has many encryption
     * keys and it is unclear which one should be used this function can help to detect bad decryptions.
     * @return an object containing:
     * - data: the decrypted attachment, if it could be decrypted, else the encrypted attachment.
     * - wasDecrypted: if the data was successfully decrypted or not
     */
    getAndTryDecryptSecondaryDocumentAttachment(document: models.Document, secondaryAttachmentKey: string, validator?: (decrypted: ArrayBuffer) => Promise<boolean>): Promise<{
        data: ArrayBuffer;
        wasDecrypted: boolean;
    }>;
    /**
     * @param document a document
     * @return the id of the message that the document 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.
     */
    decryptMessageIdOf(document: models.Document): Promise<string[]>;
    /**
     * @return if the logged data owner has write access to the content of the given document
     */
    hasWriteAccess(document: models.Document): Promise<boolean>;
    /**
     * Share an existing document with other data owners, allowing them to access the non-encrypted data of the document 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 document.
     * @param document the document to share.
     * @param options optional parameters to customize the sharing behaviour:
     * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared
     * - 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}).
     * - shareMessageId: specifies if the id of the message that this document 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, document: models.Document, options?: {
        shareSecretIds?: string[];
        requestedPermissions?: RequestedPermissionEnum;
        shareEncryptionKey?: ShareMetadataBehaviour;
        shareMessageId?: ShareMetadataBehaviour;
    }): Promise<models.Document>;
    /**
     * Share an existing document with other data owners, allowing them to access the non-encrypted data of the document and optionally also
     * the encrypted content, with read-only or read-write permissions.
     * @param document the document to share.
     * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
     * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared
     * - 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}).
     * - shareMessageId: specifies if the id of the message that this document 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(document: models.Document, delegates: {
        [delegateId: string]: {
            shareSecretIds?: string[];
            requestedPermissions?: RequestedPermissionEnum;
            shareEncryptionKey?: ShareMetadataBehaviour;
            shareMessageId?: ShareMetadataBehaviour;
        };
    }): Promise<models.Document>;
    /**
     * Share an existing document with other data owners, allowing them to access the non-encrypted data of the document and optionally also
     * the encrypted content, with read-only or read-write permissions.
     * @param document the document to share.
     * @param delegates associates the id of data owners which will be granted access to the entity, to the following sharing options:
     * - shareSecretIds: specifies which secret ids of the entity should be shared. If not provided all secret ids available to the current user will be shared
     * - 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}).
     * - shareMessageId: specifies if the id of the message that this document 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(document: models.Document, delegates: {
        [delegateId: string]: {
            shareSecretIds?: string[];
            requestedPermissions?: RequestedPermissionEnum;
            shareEncryptionKey?: ShareMetadataBehaviour;
            shareMessageId?: ShareMetadataBehaviour;
        };
    }): Promise<ShareResult<models.Document>>;
    /**
     * Gets the data owners that have access to a document.
     * @param entity the document.
     * @return an object containing the permissions by data owner id and a flag indicating if there are unknown anonymous data owners.
     */
    getDataOwnersWithAccessTo(entity: models.Document): Promise<{
        permissionsByDataOwnerId: {
            [p: string]: AccessLevelEnum;
        };
        hasUnknownAnonymousDataOwners: boolean;
    }>;
    /**
     * Gets the encryption keys of a document.
     * @param entity the document.
     * @return an array of encryption keys.
     */
    getEncryptionKeysOf(entity: models.Document): Promise<string[]>;
    /**
     * Creates delegation de-anonymization metadata for a document.
     * @param entity the document.
     * @param delegates the data owner ids of the delegates.
     */
    createDelegationDeAnonymizationMetadata(entity: models.Document, delegates: string[]): Promise<void>;
    private decryptPage;
    /**
     * Creates a new document.
     * @param user the user (not used).
     * @param body the document to create.
     * @return the created document.
     */
    createDocumentWithUser(user: models.User | undefined, body: models.Document): Promise<models.Document>;
    /**
     * Deletes the main attachment of a document.
     * @param user the user (not used).
     * @param documentId the id of the document.
     * @return the updated document.
     */
    deleteAttachmentWithUser(user: models.User | undefined, documentId: string): Promise<models.Document>;
    /**
     * @deprecated
     */
    findByTypeHCPartyMessageSecretFKeysWithUser(user: models.User | undefined, documentTypeCode: string, hcPartyId: string, secretFKeys: string[]): Promise<Array<models.Document>>;
    /**
     * @deprecated
     */
    findDocumentsByHCPartyPatientForeignKeysWithUser(user: models.User | undefined, hcPartyId: string, secretFKeys: string[]): Promise<Array<models.Document>>;
    /**
     * @deprecated
     */
    findDocumentsByHCPartyPatientForeignKeyWithUser(user: models.User | undefined, hcPartyId: string, secretFKey: string, startKey?: string, startDocumentId?: string, limit?: number): Promise<PaginatedListDocument>;
    findWithoutDelegationWithUser(user: models.User | undefined, limit?: number): Promise<Array<models.Document>>;
    /**
     * Gets a document by id.
     * @param user the user (not used).
     * @param documentId the id of the document.
     * @return the document.
     */
    getDocumentWithUser(user: models.User | undefined, documentId: string): Promise<models.Document>;
    /**
     * Gets a document by external UUID.
     * @param user the user (not used).
     * @param externalUuid the external UUID of the document.
     * @return the document.
     */
    getDocumentByExternalUuidWithUser(user: models.User | undefined, externalUuid: string): Promise<models.Document>;
    /**
     * Gets multiple documents by their ids.
     * @param user the user (not used).
     * @param body a list of document ids.
     * @return the documents.
     */
    getDocumentsWithUser(user: models.User | undefined, body?: ListOfIds): Promise<Array<models.Document>>;
    /**
     * Gets all documents with a specific external UUID.
     * @param user the user (not used).
     * @param externalUuid the external UUID.
     * @return the documents.
     */
    getDocumentsByExternalUuidWithUser(user: models.User | undefined, externalUuid: string): Promise<Array<models.Document>>;
    /**
     * Updates a document.
     * @param user the user (not used).
     * @param body the document to update.
     * @return the updated document.
     */
    modifyDocumentWithUser(user: models.User | undefined, body: models.Document): Promise<models.Document>;
    /**
     * Updates multiple documents.
     * @param user the user (not used).
     * @param body the documents to update.
     * @return the updated documents.
     */
    modifyDocumentsWithUser(user: models.User | undefined, body: Array<models.Document>): Promise<Array<models.Document>>;
    /**
     * Sets the main attachment of a document.
     * @param user the user (not used).
     * @param documentId the id of the document.
     * @param documentRev the revision of the document.
     * @param body the attachment data.
     * @param utis an array of UTIs for the attachment.
     * @param dataIsEncrypted whether the data is already encrypted.
     * @return the updated document.
     */
    setMainDocumentAttachmentWithUser(user: models.User | undefined, documentId: string, documentRev: string, body: Object, utis?: Array<string>, dataIsEncrypted?: boolean): Promise<models.Document>;
    /**
     * Sets a secondary attachment on a document.
     * @param user the user (not used).
     * @param documentId the id of the document.
     * @param key the key for the secondary attachment.
     * @param rev the revision of the document.
     * @param attachment the attachment data.
     * @param utis an array of UTIs for the attachment.
     * @param dataIsEncrypted whether the data is already encrypted.
     * @return the updated document.
     */
    setSecondaryAttachmentWithUser(user: models.User | undefined, documentId: string, key: string, rev: string, attachment: Object, utis?: Array<string>, dataIsEncrypted?: boolean): Promise<models.Document>;
    /**
     * Deletes a secondary attachment from a document.
     * @param user the user (not used).
     * @param documentId the id of the document.
     * @param key the key of the secondary attachment.
     * @param rev the revision of the document.
     * @return the updated document.
     */
    deleteSecondaryAttachmentWithUser(user: models.User | undefined, documentId: string, key: string, rev: string): Promise<models.Document>;
    createDocument(body?: models.Document): never;
    deleteAttachment(documentId: string): never;
    findByTypeHCPartyMessageSecretFKeys(documentTypeCode: string, hcPartyId: string, secretFKeys: string[]): never;
    findDocumentsByHCPartyPatientForeignKeys(hcPartyId: string, secretFKeys: string[]): never;
    findDocumentsByHCPartyPatientForeignKey(hcPartyId: string, secretFKey: string, startKey?: string, startDocumentId?: string, limit?: number): never;
    findWithoutDelegation(limit?: number): never;
    getDocument(documentId: string): never;
    getDocumentByExternalUuid(externalUuid: string): never;
    getDocuments(body?: ListOfIds): never;
    getDocumentsByExternalUuid(externalUuid: string): never;
    modifyDocument(body?: models.Document): never;
    modifyDocuments(body?: Array<models.Document>): never;
    setMainDocumentAttachment(documentId: string, documentRev: string, body: Object, utis?: Array<string>, dataIsEncrypted?: boolean): never;
    setDocumentAttachmentBody(documentId: string, documentRev: string, enckeys?: null, body?: Object, utis?: string[]): never;
    setDocumentAttachment(documentId: string, documentRev: string, enckeys?: null, body?: Object, utis?: string[]): never;
    setDocumentAttachmentMulti(attachment: ArrayBuffer, documentRev: string, documentId: string, enckeys?: null): never;
    setSecondaryAttachment(documentId: string, key: string, rev: string, attachment: Object, utis?: Array<string>, dataIsEncrypted?: boolean): never;
    deleteSecondaryAttachment(documentId: string, key: string, rev: string): never;
}
