/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { SummaryObject } from "@fluidframework/driver-definitions";
import { ISnapshotTree } from "@fluidframework/driver-definitions/internal";
import { ITelemetryLoggerExt, TelemetryDataTag } from "@fluidframework/telemetry-utils/internal";
export interface IRefreshSummaryResult {
    /** Tells whether this summary is tracked by this client. */
    isSummaryTracked: boolean;
    /** Tells whether this summary is newer than the latest one tracked by this client. */
    isSummaryNewer: boolean;
}
export interface IStartSummaryResult {
    /** The number of summarizerNodes at the start of the summary. */
    nodes: number;
    /** The number of summarizerNodes in the wrong state. */
    invalidNodes: number;
    /** The invalid sequence numbers and their values. It should be in the format of validateSequenceNumber-nodeSequenceNumber */
    mismatchNumbers: Set<string>;
}
/**
 * Return type of validateSummary function. In case of success, the object returned should have success: true.
 * In case of failure, the object returned should have success: false and additional properties to indicate what
 * the failure was, where it was, can it be retried, etc.
 */
export type ValidateSummaryResult = {
    success: true;
} | {
    success: false;
    /** The failure reason */
    reason: string;
    /** id of the node that failed during validation */
    id: {
        tag: TelemetryDataTag.CodeArtifact;
        value: string | undefined;
    };
    /** If the error can be retried, time to wait before retrying */
    retryAfterSeconds?: number;
};
export interface ISummarizerNodeRootContract {
    startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLoggerExt, latestSummaryRefSeqNum: number): IStartSummaryResult;
    validateSummary(): ValidateSummaryResult;
    completeSummary(proposalHandle: string): void;
    clearSummary(): void;
    refreshLatestSummary(proposalHandle: string, summaryRefSeq: number): Promise<IRefreshSummaryResult>;
}
/** Path for nodes in a tree with escaped special characters */
export declare class EscapedPath {
    readonly path: string;
    private constructor();
    static create(path: string): EscapedPath;
    static createAndConcat(pathParts: string[]): EscapedPath;
    toString(): string;
    concat(path: EscapedPath): EscapedPath;
}
/** Information about a summary relevant to a specific node in the tree */
export declare class SummaryNode {
    private readonly summary;
    /** Creates an instance that is valid for the root with specific basePath and localPath */
    static createForRoot(referenceSequenceNumber: number): SummaryNode;
    /** Summary reference sequence number, i.e. last sequence number seen when it was created */
    get referenceSequenceNumber(): number;
    /** Full path to parent node, or undefined if this is the root */
    get basePath(): EscapedPath | undefined;
    /** Relative path to this node from its parent node */
    get localPath(): EscapedPath;
    /** Relative path from this node to its node innermost base summary */
    get additionalPath(): EscapedPath | undefined;
    set additionalPath(additionalPath: EscapedPath | undefined);
    constructor(summary: {
        readonly referenceSequenceNumber: number;
        readonly basePath: EscapedPath | undefined;
        readonly localPath: EscapedPath;
        additionalPath?: EscapedPath;
    });
    /** Gets the full path to this node, to be used when sending a handle */
    get fullPath(): EscapedPath;
    /**
     * Gets the full path to this node's innermost base summary.
     * The children nodes can use this as their basePath to determine their path.
     */
    get fullPathForChildren(): EscapedPath;
    /**
     * Creates a new node within the same summary for a child of this node.
     * @param id - id of the child node
     */
    createForChild(id: string): SummaryNode;
}
/**
 * Represents the details needed to create a child summarizer node.
 */
export interface ICreateChildDetails {
    /** Latest summary from server node data */
    latestSummary: SummaryNode | undefined;
    /** Sequence number of latest known change to the node */
    changeSequenceNumber: number;
    /** A unique id of this child to be logged when sending telemetry. */
    telemetryNodeId: string;
}
export interface ISubtreeInfo<T extends ISnapshotTree | SummaryObject> {
    /** Tree to use to find children subtrees */
    childrenTree: T;
    /** Additional path part where children are isolated */
    childrenPathPart: string | undefined;
}
/**
 * Checks if the summary contains .channels subtree where the children subtrees
 * would be located if exists.
 * @param baseSummary - summary to check
 */
export declare function parseSummaryForSubtrees(baseSummary: ISnapshotTree): ISubtreeInfo<ISnapshotTree>;
//# sourceMappingURL=summarizerNodeUtils.d.ts.map