/**
 * NOTE: Added reference types here to avoid a `pnpm` bug during build.
 * https://github.com/enboxorg/enbox/pull/507
 */
import type { CreateGrantParams, CreateRequestParams, DwnMessageParams, DwnPaginationCursor, DwnResponseStatus, EnboxAgent, FetchPermissionRequestParams, FetchPermissionsParams } from '@enbox/agent';
import { DwnInterface } from '@enbox/agent';
import { LiveQuery } from './live-query.js';
import { PermissionGrant } from './permission-grant.js';
import { PermissionRequest } from './permission-request.js';
import { Protocol } from './protocol.js';
import { Record } from './record.js';
/**
 * Represents the request payload for fetching permission requests from a Decentralized Web Node (DWN).
 *
 * Optionally, specify a remote DWN target in the `from` property to fetch requests from.
 */
export type FetchRequestsRequest = Omit<FetchPermissionRequestParams, 'author' | 'target' | 'remote'> & {
    /** Optional DID specifying the remote target DWN tenant to be queried. */
    from?: string;
};
/**
 * Represents the request payload for fetching permission grants from a Decentralized Web Node (DWN).
 *
 * Optionally, specify a remote DWN target in the `from` property to fetch requests from.
 * Set `checkRevoked: true` to perform explicit per-grant revocation checks.
 */
export type FetchGrantsRequest = Omit<FetchPermissionsParams, 'author' | 'target' | 'remote'> & {
    /** Optional DID specifying the remote target DWN tenant to be queried. */
    from?: string;
};
/**
 * Represents the request payload for configuring a protocol on a Decentralized Web Node (DWN).
 *
 * This request type is used to specify the configuration options for the protocol.
 */
export type ProtocolsConfigureRequest = Omit<DwnMessageParams[DwnInterface.ProtocolsConfigure], 'signer'> & {
    /** When true, derives and injects $encryption public keys into the protocol definition. */
    encryption?: boolean;
};
/**
 * Encapsulates the response from a protocol configuration request to a Decentralized Web Node (DWN).
 *
 * This response type combines the general operation status with the details of the protocol that
 * was configured, if the operation was successful.
 *
 * @beta
 */
export type ProtocolsConfigureResponse = DwnResponseStatus & {
    /** The configured protocol, if successful. */
    protocol?: Protocol;
};
/**
 * Defines the request structure for querying protocols from a Decentralized Web Node (DWN).
 *
 * This request type is used to specify the target DWN from which protocols should be queried and
 * any additional query filters or options. If the `from` property is not provided, the query will
 * target the local DWN. If the `from` property is provided, the query will target the specified
 * remote DWN.
 */
export type ProtocolsQueryRequest = Omit<DwnMessageParams[DwnInterface.ProtocolsQuery], 'signer'> & {
    /** Optional DID specifying the remote target DWN tenant to be queried. */
    from?: string;
};
/**
 * Wraps the response from a protocols query, including the operation status and the list of
 * protocols.
 */
export type ProtocolsQueryResponse = DwnResponseStatus & {
    /** Array of protocols matching the query. */
    protocols: Protocol[];
};
/**
 * Defines a request to delete a record from the Decentralized Web Node (DWN).
 *
 * This request type optionally specifies the target from which the record should be deleted and the
 * message parameters for the delete operation. If the `from` property is not provided, the record
 * will be deleted from the local DWN.
 */
export type RecordsDeleteRequest = Omit<DwnMessageParams[DwnInterface.RecordsDelete], 'signer'> & {
    /** Optional DID specifying the remote target DWN tenant the record will be deleted from. */
    from?: string;
    /** Protocol URI for permission grant resolution. */
    protocol?: string;
};
/**
 * Encapsulates a request to query records from a Decentralized Web Node (DWN).
 *
 * This request type is used to specify the criteria for querying records, including query
 * parameters, and optionally the target DWN to query from. If the `from` property is not provided,
 * the query will target the local DWN.
 */
export type RecordsQueryRequest = Omit<DwnMessageParams[DwnInterface.RecordsQuery], 'signer'> & {
    /** Optional DID specifying the remote target DWN tenant to query from and return results. */
    from?: string;
    /** When true, automatically decrypts encrypted records in the query results. */
    encryption?: boolean;
};
/**
 * Represents the response from a records query operation, including status, records, and an
 * optional pagination cursor.
 */
export type RecordsQueryResponse = DwnResponseStatus & {
    /** Array of records matching the query. */
    records: Record[];
    /** If there are additional results, the messageCid of the last record will be returned as a pagination cursor. */
    cursor?: DwnPaginationCursor;
};
/**
 * Represents a request to read a specific record from a Decentralized Web Node (DWN).
 *
 * This request type is used to specify the target DWN from which the record should be read and any
 * additional parameters for the read operation. It's useful for fetching the details of a single
 * record by its identifier or other criteria.
 */
export type RecordsReadRequest = Omit<DwnMessageParams[DwnInterface.RecordsRead], 'signer'> & {
    /** Optional DID specifying the remote target DWN tenant the record will be read from. */
    from?: string;
    /** Protocol URI for permission grant resolution. */
    protocol?: string;
    /** When true, automatically decrypts the encrypted record data. */
    encryption?: boolean;
};
/**
 * Encapsulates the response from a record read operation, combining the general operation status
 * with the specific record that was retrieved.
 *
 * When the status code is not in the 2xx range (e.g. 401, 404), `record` will be `undefined`.
 * Always check `status.code` before accessing the record.
 */
export type RecordsReadResponse = DwnResponseStatus & {
    /** The record retrieved by the read operation, or `undefined` if the request failed. */
    record?: Record;
};
/**
 * Represents a request to subscribe to records from a Decentralized Web Node (DWN).
 *
 * Returns a {@link LiveQuery} that atomically provides an initial snapshot of
 * matching records alongside a real-time stream of deduplicated, semantically-
 * typed change events (`create`, `update`, `delete`).
 */
export type RecordsSubscribeRequest = Omit<DwnMessageParams[DwnInterface.RecordsSubscribe], 'signer'> & {
    /** Optional DID specifying the remote target DWN tenant to subscribe from. */
    from?: string;
};
/** Encapsulates the response from a DWN RecordsSubscribeRequest. */
export type RecordsSubscribeResponse = DwnResponseStatus & {
    /** The live query instance, or `undefined` if the request failed. */
    liveQuery?: LiveQuery;
};
/**
 * Defines a request to write (create) a record to a Decentralized Web Node (DWN).
 *
 * This request type allows specifying the data for the new or updated record, along with any
 * additional message parameters required for the write operation, and an optional flag to indicate
 * whether the record should be immediately stored.
 */
export type RecordsWriteRequest = Omit<Partial<DwnMessageParams[DwnInterface.RecordsWrite]>, 'signer' | 'data' | 'protocol' | 'protocolPath'> & Pick<DwnMessageParams[DwnInterface.RecordsWrite], 'protocol' | 'protocolPath'> & {
    /** The data payload for the record, which can be of any type. */
    data: unknown;
    /**
     * Optional flag indicating whether the record should be immediately stored. If true, the record
     * is persisted in the DWN as part of the write operation. If false, the record is created,
     * signed, and returned but not persisted.
     */
    store?: boolean;
    /** When true, automatically encrypts the record data using the protocol's encryption keys. */
    encryption?: boolean;
};
/**
 * Encapsulates the response from a record write operation to a Decentralized Web Node (DWN).
 *
 * This request type combines the general operation status with the details of the record that was
 * written, if the operation was successful.
 *
 * The response includes a status object that contains the HTTP-like status code and detail message
 * indicating the success or failure of the write operation. If the operation was successful and a
 * record was created or updated, the `record` property will contain an instance of the `Record`
 * class representing the written record. This allows the caller to access the written record's
 * details and perform additional operations using the provided {@link Record} instance methods.
 */
export type RecordsWriteResponse = DwnResponseStatus & {
    /**
     * The `Record` instance representing the record that was successfully written to the
     * DWN as a result of the write operation, or `undefined` if the write failed.
     *
     * Always check `status.code` before accessing the record.
     */
    record?: Record;
};
/**
 * Interface to interact with DWN Records and Protocols
 */
export declare class DwnApi {
    /**
     * Holds the instance of a {@link EnboxAgent} that represents the current execution context for
     * the `DwnApi`. This agent is used to process DWN requests.
     */
    private readonly agent;
    /**
     * The DID of the DWN tenant under which operations are being performed.
     *
     * Exposed as a public getter so that `TypedEnbox` can read it during
     * delegate auto-configure (remote protocol fetch).
     */
    private _connectedDid;
    get connectedDid(): string;
    /** @internal — used by tests to reset state between runs. */
    set connectedDid(did: string);
    /** (optional) The DID of the signer when signing with permissions */
    private readonly delegateDid?;
    /** Holds the instance of {@link AgentPermissionsApi} that helps when dealing with permissions protocol records */
    private readonly permissionsApi;
    constructor(options: {
        agent: EnboxAgent;
        connectedDid: string;
        delegateDid?: string;
    });
    /** Whether this DWN API instance is operating as a delegate. */
    get isDelegate(): boolean;
    /**
     * API to interact with Grants
     *
     * NOTE: This is an EXPERIMENTAL API that will change behavior.
     *
     * Currently only supports issuing requests, grants, revokes and queries on behalf without permissions or impersonation.
     * If the agent is connected to a delegateDid, the delegateDid will be used to sign/author the underlying records.
     * If the agent is not connected to a delegateDid, the connectedDid will be used to sign/author the underlying records.
     *
     * @beta
     */
    get permissions(): {
        request: (request: Omit<CreateRequestParams, 'author'>) => Promise<PermissionRequest>;
        grant: (request: Omit<CreateGrantParams, 'author'>) => Promise<PermissionGrant>;
        queryRequests: (request?: FetchRequestsRequest) => Promise<PermissionRequest[]>;
        queryGrants: (request?: FetchGrantsRequest) => Promise<PermissionGrant[]>;
    };
    /**
     * API to interact with DWN protocols (e.g., `dwn.protocols.configure()`).
     */
    get protocols(): {
        configure: (request: ProtocolsConfigureRequest) => Promise<ProtocolsConfigureResponse>;
        query: (request: ProtocolsQueryRequest) => Promise<ProtocolsQueryResponse>;
    };
    /**
     * API to interact with DWN records (e.g., `dwn.records.write()`).
     */
    get records(): {
        delete: (request: RecordsDeleteRequest) => Promise<DwnResponseStatus>;
        query: (request: RecordsQueryRequest) => Promise<RecordsQueryResponse>;
        read: (request: RecordsReadRequest) => Promise<RecordsReadResponse>;
        subscribe: (request: RecordsSubscribeRequest) => Promise<RecordsSubscribeResponse>;
        write: (request: RecordsWriteRequest) => Promise<RecordsWriteResponse>;
    };
}
//# sourceMappingURL=dwn-api.d.ts.map