import { DocumentNode, GraphQLSchema, type ExecutionArgs } from 'graphql';
import type { AbortAction, ClientInfo, CollectUsage, GraphQLResult, HiveInternalPluginOptions } from './types.cjs';
interface UsageCollector {
    collect(): CollectUsage;
    /** collect a short lived GraphQL request (mutation/query operation) */
    collectRequest(args: {
        args: ExecutionArgs;
        result: GraphQLResult | AbortAction;
        /** duration in milliseconds */
        duration: number;
        experimental__persistedDocumentHash?: string;
        /** Optionally send subgraph request information. This provides a deeper level of usage metrics */
        fetches?: CollectedOperationSubRequest[] | null;
    }): void;
    /** collect a long-lived GraphQL request/subscription (subscription operation) */
    collectSubscription(args: {
        args: ExecutionArgs;
        experimental__persistedDocumentHash?: string;
    }): void;
    dispose(): Promise<void>;
}
export declare function createUsage(pluginOptions: HiveInternalPluginOptions): UsageCollector;
interface CacheResult {
    document: string;
    fields: string[];
}
export declare function createCollector({ schema, max, ttl, processVariables, }: {
    schema: GraphQLSchema;
    max?: number;
    ttl?: number;
    processVariables?: boolean;
}): (arg: DocumentNode, arg2: {
    [key: string]: unknown;
} | null) => Promise<{
    key: any;
    value: CacheResult;
    cacheHit: boolean;
}>;
export interface Report {
    size: number;
    map: OperationMap;
    operations?: RequestOperation[];
    subscriptionOperations?: SubscriptionOperation[];
}
type OperationSubRequest = {
    /** Delta start time from "timestamp" */
    start: number;
    /** How long the request took */
    duration: number;
    /** HTTP Status Code. Optional if resolved locally. */
    status?: number | undefined;
    /** Number of times the field has been requested. Regardless of success or failure */
    fields: {
        [coordinate: string]: number;
    };
    /** Error code for a coordinate, with a code returned from the graphql extensions */
    errors?: {
        coordinate: string;
        code?: string;
    }[];
    /** Which subgraph resolved this path */
    subgraph: string;
    /**
     * If this is an entity request, then this is the coordinate in the original operation that is being resolved.
     * If undefined, then the path is assumed to be 'Query'.
     */
    paths: string[] | string;
    /**
     * What type of request this is. Root is if resolving a root query/mutation field. Entity is
     * if resolving an entity type in federation.
     * */
    type: 'ROOT' | 'ENTITY';
};
type CollectedOperationSubRequest = {
    /** Delta start time from "timestamp" */
    start: number;
    /** How long the request took */
    duration: number;
    /** HTTP Status Code. Optional for if resolved locally */
    status?: number | undefined;
    /** The graphql execution result. Used to calculate error code for a coordinate, with a code returned from the graphql extensions */
    result?: GraphQLResult;
    /** The GraphQL schema being accessed. Used to calculate coordinate from error path and the coordinate for field counts */
    subgraphSchema: GraphQLSchema;
    /** GraphQL operation document. Used to calculate field counts. */
    document: DocumentNode;
    /** Which subgraph resolved this path */
    subgraph: string;
    /**
     * If this is an entity request, then this is the coordinate in the original operation that is being resolved.
     * If undefined, then the path is assumed to be 'Query'.
     */
    paths?: string[] | string;
    /**
     * What type of request this is. Root is if resolving a root query/mutation field. Entity is
     * if resolving an entity type in federation.
     * */
    type: 'ROOT' | 'ENTITY';
};
interface RequestOperation {
    operationMapKey: string;
    timestamp: number;
    execution: {
        ok: boolean;
        duration: number;
        errorsTotal: number;
        fetches?: OperationSubRequest[] | null;
    };
    persistedDocumentHash?: string;
    metadata?: {
        client?: ClientInfo;
    };
}
interface SubscriptionOperation {
    operationMapKey: string;
    timestamp: number;
    persistedDocumentHash?: string;
    metadata?: {
        client?: ClientInfo;
    };
}
interface OperationMapRecord {
    operation: string;
    operationName?: string | null;
    fields: string[];
}
interface OperationMap {
    [key: string]: OperationMapRecord;
}
export {};
//# sourceMappingURL=usage.d.ts.map