import { IccFormApi } from '../icc-api';
import { IccCryptoXApi } from './icc-crypto-x-api';
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 AccessLevelEnum = SecureDelegation.AccessLevelEnum;
import { ShareMetadataBehaviour } from './crypto/ShareMetadataBehaviour';
import { ShareResult } from './utils/ShareResult';
import { EntityShareRequest } from '../icc-api/model/requests/EntityShareRequest';
import RequestedPermissionEnum = EntityShareRequest.RequestedPermissionEnum;
import { XHR } from '../icc-api/api/XHR';
import { EncryptedEntityXApi } from './basexapi/EncryptedEntityXApi';
import { SecretIdUseOption } from './crypto/SecretIdUseOption';
export declare class IccFormXApi extends IccFormApi implements EncryptedEntityXApi<models.Form> {
    private readonly autofillAuthor;
    crypto: IccCryptoXApi;
    dataOwnerApi: IccDataOwnerXApi;
    get headers(): Promise<Array<XHR.Header>>;
    constructor(host: string, headers: {
        [key: string]: string;
    }, crypto: IccCryptoXApi, dataOwnerApi: IccDataOwnerXApi, autofillAuthor: boolean, authenticationProvider?: AuthenticationProvider, fetchImpl?: (input: RequestInfo, init?: RequestInit) => Promise<Response>);
    /**
     * Creates a new instance of form with initialised encryption metadata (not in the database).
     * @param user the current user.
     * @param patient the patient this form refers to.
     * @param c initialised data for the form. 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 form.
     */
    newInstance(user: models.User, patient: models.Patient, c?: any, options?: {
        additionalDelegates?: {
            [dataOwnerId: string]: AccessLevelEnum;
        };
        sfkOption?: SecretIdUseOption;
        ignoreAutoDelegations?: boolean;
        alternateRootDelegation?: string;
    }): Promise<models.Form>;
    /**
     * 1. Check whether there is a delegation with 'hcpartyId' or not.
     * 2. 'fetchHcParty[hcpartyId][1]': is encrypted AES exchange key by RSA public key of him.
     * 3. Obtain the AES exchange key, by decrypting the previous step value with hcparty private key
     *      3.1.  KeyPair should be fetch from cache (in jwk)
     *      3.2.  if it doesn't exist in the cache, it has to be loaded from Browser Local store, and then import it to WebCrypto
     * 4. Obtain the array of delegations which are delegated to his ID (hcpartyId) in this patient
     * 5. Decrypt and collect all keys (secretForeignKeys) within delegations of previous step (with obtained AES key of step 4)
     * 6. Do the REST call to get all forms with (allSecretForeignKeysDelimitedByComa, hcpartyId)
     *
     * After these painful steps, you have the forms of the patient.
     * @deprecated use {@link findIdsBy} instead.
     * @param hcpartyId
     * @param patient
     * @param usingPost (Promise)
     */
    findBy(hcpartyId: string, patient: models.Patient, usingPost?: boolean): Promise<models.Form[]>;
    /**
     * Same as {@link findBy} but it will only return the ids of the forms. It can also filter the forms by opening date
     * (the date when the form was opened/started) between startDate and endDate in ascending or descending order by that field (default: ascending).
     * @param hcpartyId the id of the data owner.
     * @param patient the patient whose forms to retrieve.
     * @param startDate optional start date filter (inclusive). Only forms with openingDate >= startDate will be returned.
     * @param endDate optional end date filter (inclusive). Only forms with openingDate <= endDate will be returned.
     * @param descending if true, results are sorted by openingDate in descending order; otherwise in ascending order (default).
     * @return an array of form ids.
     */
    findIdsBy(hcpartyId: string, patient: models.Patient, startDate?: number, endDate?: number, descending?: boolean): Promise<string[]>;
    /**
     * Decrypts the encrypted content of the provided forms.
     * @param hcpartyId the id of the data owner attempting to decrypt the forms.
     * @param forms the forms to decrypt.
     * @return an array of decrypted forms. Forms that could not be decrypted will be returned as-is.
     */
    decrypt(hcpartyId: string, forms: Array<models.Form>): Promise<models.Form[]>;
    /**
     * @param form a form
     * @return the id of the patient that the form 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(form: models.Form): Promise<string[]>;
    /**
     * @return if the logged data owner has write access to the content of the given form
     */
    hasWriteAccess(form: models.Form): Promise<boolean>;
    /**
     * Share an existing form with other data owners, allowing them to access the non-encrypted data of the form 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 form.
     * @param form the form 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}). Note that by default a
     * form does not have encrypted content.
     * - sharePatientId: specifies if the id of the patient that this form 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, form: models.Form, options?: {
        shareSecretIds?: string[];
        requestedPermissions?: RequestedPermissionEnum;
        shareEncryptionKey?: ShareMetadataBehaviour;
        sharePatientId?: ShareMetadataBehaviour;
    }): Promise<models.Form>;
    /**
     * Share an existing form with other data owners, allowing them to access the non-encrypted data of the form and optionally also
     * the encrypted content, with read-only or read-write permissions.
     * @param form the form 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}). Note that by default a
     * form does not have encrypted content.
     * - sharePatientId: specifies if the id of the patient that this form 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(form: models.Form, delegates: {
        [delegateId: string]: {
            shareSecretIds?: string[];
            requestedPermissions?: RequestedPermissionEnum;
            shareEncryptionKey?: ShareMetadataBehaviour;
            sharePatientId?: ShareMetadataBehaviour;
        };
    }): Promise<models.Form>;
    /**
     * Share an existing form with other data owners, allowing them to access the non-encrypted data of the form and optionally also
     * the encrypted content, with read-only or read-write permissions.
     * @param form the form 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}). Note that by default a
     * form does not have encrypted content.
     * - sharePatientId: specifies if the id of the patient that this form 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(form: models.Form, delegates: {
        [delegateId: string]: {
            shareSecretIds?: string[];
            requestedPermissions?: RequestedPermissionEnum;
            shareEncryptionKey?: ShareMetadataBehaviour;
            sharePatientId?: ShareMetadataBehaviour;
        };
    }): Promise<ShareResult<models.Form>>;
    /**
     * Gets all data owners that have access to the given form, along with their access levels.
     * @param entity the form to check.
     * @return an object containing:
     * - permissionsByDataOwnerId: a map of data owner id to their access level.
     * - hasUnknownAnonymousDataOwners: true if there are anonymous data owners with access that could not be identified.
     */
    getDataOwnersWithAccessTo(entity: models.Form): Promise<{
        permissionsByDataOwnerId: {
            [p: string]: AccessLevelEnum;
        };
        hasUnknownAnonymousDataOwners: boolean;
    }>;
    /**
     * Retrieves all encryption keys of the given form that are available to the current data owner.
     * @param entity the form whose encryption keys to retrieve.
     * @return an array of encryption keys in hexadecimal string format.
     */
    getEncryptionKeysOf(entity: models.Form): Promise<string[]>;
    /**
     * Creates or updates de-anonymization metadata for the given form, allowing the delegates to be identified
     * even if they were initially anonymous (e.g., in keyless mode).
     * @param entity the form for which to create de-anonymization metadata.
     * @param delegates the ids of the data owners for which to create de-anonymization information.
     */
    createDelegationDeAnonymizationMetadata(entity: models.Form, delegates: string[]): Promise<void>;
}
