/**
 * A protocol-scoped API returned by {@link Web5.using}.
 *
 * `TypedWeb5` is the **primary developer interface** for interacting with
 * protocol-backed records. It auto-injects the protocol URI, protocolPath,
 * and schema into every operation, and provides compile-time path
 * autocompletion plus typed data payloads via the schema map.
 *
 * All record-returning methods wrap the underlying `Record` instances in
 * {@link TypedRecord} so that type information flows through reads, queries,
 * updates, and subscriptions without manual casts.
 *
 * @example
 * ```ts
 * const social = web5.using(SocialProtocol);
 *
 * // Install the protocol
 * await social.configure();
 *
 * // Create — path and data type are checked at compile time
 * const { record } = await social.records.create('thread', {
 *   data: { title: 'Hello World', body: '...' },
 * });
 * // record is TypedRecord<ThreadData>
 *
 * const data = await record.data.json(); // ThreadData — no cast needed
 *
 * // Query — protocol and protocolPath are auto-injected
 * const { records } = await social.records.query('thread');
 * // records is TypedRecord<ThreadData>[]
 *
 * // Subscribe — real-time changes via TypedLiveQuery
 * const { liveQuery } = await social.records.subscribe('thread/reply');
 * liveQuery.on('create', (record) => {
 *   // record is TypedRecord<ReplyData>
 * });
 * ```
 */
import type { DwnApi } from './dwn-api.js';
import type { Protocol } from './protocol.js';
import type { DateSort, ProtocolDefinition, ProtocolType, RecordsFilter } from '@enbox/dwn-sdk-js';
import type { DwnPaginationCursor, DwnResponseStatus } from '@enbox/agent';
import type { ProtocolPaths, SchemaMap, TypedProtocol, TypeNameAtPath } from './protocol-types.js';
import { TypedLiveQuery } from './typed-live-query.js';
import { TypedRecord } from './typed-record.js';
/**
 * Resolves the TypeScript data type for a given protocol path.
 *
 * If the schema map contains a mapping for the type name at the given path,
 * that type is returned. Otherwise falls back to `unknown`.
 */
export type DataForPath<_D extends ProtocolDefinition, M extends SchemaMap, Path extends string> = TypeNameAtPath<Path> extends keyof M ? M[TypeNameAtPath<Path>] : unknown;
/**
 * Resolves the `ProtocolType` entry for a given protocol path.
 */
type ProtocolTypeForPath<D extends ProtocolDefinition, Path extends string> = TypeNameAtPath<Path> extends keyof D['types'] ? D['types'][TypeNameAtPath<Path>] extends ProtocolType ? D['types'][TypeNameAtPath<Path>] : undefined : undefined;
/**
 * Resolves a `dataFormat` string literal union for a path, or `string` if none.
 */
type DataFormatForPath<D extends ProtocolDefinition, Path extends string> = ProtocolTypeForPath<D, Path> extends {
    dataFormats: infer F;
} ? F extends readonly string[] ? F[number] : string : string;
/** Options for {@link TypedWeb5} `records.create()`. */
export type TypedCreateRequest<D extends ProtocolDefinition, M extends SchemaMap, Path extends string> = {
    /** The data payload. Type-checked against the schema map. */
    data: DataForPath<D, M, Path>;
    parentContextId?: string;
    published?: boolean;
    datePublished?: string;
    recipient?: string;
    protocolRole?: string;
    dataFormat?: DataFormatForPath<D, Path>;
    tags?: globalThis.Record<string, string | number | boolean | string[] | number[]>;
    /** Whether to persist immediately (defaults to `true`). */
    store?: boolean;
    /** Whether to auto-encrypt (follows protocol definition if omitted). */
    encryption?: boolean;
};
/** Response from {@link TypedWeb5} `records.create()`. */
export type TypedCreateResponse<T = unknown> = DwnResponseStatus & {
    record: TypedRecord<T>;
};
/** Filter options for {@link TypedWeb5} `records.query()`. */
export type TypedQueryFilter = Omit<RecordsFilter, 'protocol' | 'protocolPath' | 'schema'> & {
    tags?: globalThis.Record<string, string | number | boolean | (string | number)[]>;
};
/** Options for {@link TypedWeb5} `records.query()`. */
export type TypedQueryRequest = {
    /** Optional remote DWN DID to query from. */
    from?: string;
    /** Query filter (protocol, protocolPath, schema are injected). */
    filter?: TypedQueryFilter;
    dateSort?: DateSort;
    pagination?: {
        limit?: number;
        cursor?: DwnPaginationCursor;
    };
    protocolRole?: string;
    /** When true, automatically decrypts encrypted records. */
    encryption?: boolean;
};
/** Response from {@link TypedWeb5} `records.query()`. */
export type TypedQueryResponse<T = unknown> = DwnResponseStatus & {
    records: TypedRecord<T>[];
    cursor?: DwnPaginationCursor;
};
/** Options for {@link TypedWeb5} `records.read()`. */
export type TypedReadRequest = {
    /** Optional remote DWN DID to read from. */
    from?: string;
    /** Filter to identify the record (protocol and protocolPath are injected). */
    filter: Omit<RecordsFilter, 'protocol' | 'protocolPath' | 'schema'>;
    /** When true, automatically decrypts the record. */
    encryption?: boolean;
};
/** Response from {@link TypedWeb5} `records.read()`. */
export type TypedReadResponse<T = unknown> = DwnResponseStatus & {
    record: TypedRecord<T>;
};
/** Options for {@link TypedWeb5} `records.delete()`. */
export type TypedDeleteRequest = {
    /** Optional remote DWN DID to delete from. */
    from?: string;
    /** The `recordId` of the record to delete. */
    recordId: string;
};
/** Options for {@link TypedWeb5} `records.subscribe()`. */
export type TypedSubscribeRequest = {
    /** Optional remote DWN DID to subscribe to. */
    from?: string;
    /** Subscription filter (protocol, protocolPath, schema are injected). */
    filter?: TypedQueryFilter;
    protocolRole?: string;
};
/** Response from {@link TypedWeb5} `records.subscribe()`. */
export type TypedSubscribeResponse<T = unknown> = DwnResponseStatus & {
    /** The typed live query instance, or `undefined` if the request failed. */
    liveQuery?: TypedLiveQuery<T>;
};
/**
 * A protocol-scoped API that auto-injects `protocol`, `protocolPath`, and
 * `schema` into every DWN operation.
 *
 * All record-returning methods wrap results in {@link TypedRecord} so that
 * the data type `T` (resolved from the schema map) flows end-to-end — from
 * write through read, query, update, and subscribe — without manual casts.
 *
 * Obtain an instance via `web5.using(typedProtocol)`.
 *
 * @example
 * ```ts
 * const social = web5.using(SocialProtocol);
 *
 * await social.configure();
 *
 * const { record } = await social.records.create('friend', {
 *   data: { did: 'did:example:alice', alias: 'Alice' },
 * });
 * const data = await record.data.json(); // FriendData — no cast
 *
 * const { records } = await social.records.query('friend', {
 *   filter: { tags: { did: 'did:example:alice' } },
 * });
 * for (const r of records) {
 *   const d = await r.data.json(); // FriendData
 * }
 * ```
 */
export declare class TypedWeb5<D extends ProtocolDefinition = ProtocolDefinition, M extends SchemaMap = SchemaMap> {
    private _dwn;
    private _definition;
    private _configured;
    private _validPaths;
    private _records?;
    constructor(dwn: DwnApi, protocol: TypedProtocol<D, M>);
    /** The protocol URI. */
    get protocol(): string;
    /** The raw protocol definition. */
    get definition(): D;
    /**
     * Configures (installs) this protocol on the local DWN.
     *
     * If the protocol is already installed with an identical definition,
     * this is a no-op and returns the existing protocol. If the definition
     * has changed (e.g. new types, modified structure), the protocol is
     * re-configured with the updated definition.
     *
     * @param options - Optional overrides like `encryption`.
     */
    configure(options?: {
        encryption?: boolean;
    }): Promise<DwnResponseStatus & {
        protocol?: Protocol;
    }>;
    /** Whether the protocol has been configured (installed) on the local DWN. */
    get isConfigured(): boolean;
    /**
     * Validates that the protocol has been configured and that the path is
     * recognized. Throws a descriptive error if either check fails.
     */
    private _assertReady;
    /**
     * Protocol-scoped record operations.
     *
     * Every method auto-injects the protocol URI, protocolPath, and schema
     * from the protocol definition. Path parameters provide compile-time
     * autocompletion via `ProtocolPaths<D>`.
     *
     * All methods return {@link TypedRecord} or {@link TypedLiveQuery} instances
     * that carry the resolved data type from the schema map.
     */
    get records(): {
        create: <Path extends ProtocolPaths<D> & string>(path: Path, request: TypedCreateRequest<D, M, Path>) => Promise<TypedCreateResponse<DataForPath<D, M, Path>>>;
        query: <Path extends ProtocolPaths<D> & string>(path: Path, request?: TypedQueryRequest) => Promise<TypedQueryResponse<DataForPath<D, M, Path>>>;
        read: <Path extends ProtocolPaths<D> & string>(path: Path, request: TypedReadRequest) => Promise<TypedReadResponse<DataForPath<D, M, Path>>>;
        delete: <Path extends ProtocolPaths<D> & string>(path: Path, request: TypedDeleteRequest) => Promise<DwnResponseStatus>;
        subscribe: <Path extends ProtocolPaths<D> & string>(path: Path, request?: TypedSubscribeRequest) => Promise<TypedSubscribeResponse<DataForPath<D, M, Path>>>;
    };
}
export {};
//# sourceMappingURL=typed-web5.d.ts.map