/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { BTree } from "@tylerbu/sorted-btree-es6";
import type { Listenable } from "@fluidframework/core-interfaces/internal";
import type { TreeNodeSchemaIdentifier } from "./format.js";
import { type TreeFieldStoredSchema, type TreeNodeStoredSchema, type TreeStoredSchema } from "./schema.js";
/**
 * Events for {@link TreeStoredSchemaSubscription}.
 *
 * TODO: consider having before and after events per subtree instead while applying anchor (and this just shows what happens at the root).
 */
export interface SchemaEvents {
    /**
     * Schema change is about to be applied.
     */
    beforeSchemaChange(newSchema: TreeStoredSchema): void;
    /**
     * Schema change was just applied.
     */
    afterSchemaChange(newSchema: TreeStoredSchema): void;
}
/**
 * A collection of stored schema that fires events in response to changes.
 */
export interface TreeStoredSchemaSubscription extends TreeStoredSchema {
    /**
     * Events for this schema subscription.
     */
    readonly events: Listenable<SchemaEvents>;
}
/**
 * Mutable collection of stored schema.
 */
export interface MutableTreeStoredSchema extends TreeStoredSchemaSubscription {
    /**
     * Mutates the stored schema.
     * Replaces all schema with the provided schema.
     * Can over-write preexisting schema, and removes unmentioned schema.
     */
    apply(newSchema: TreeStoredSchema): void;
}
/**
 * Mutable TreeStoredSchema repository.
 */
export declare class TreeStoredSchemaRepository implements MutableTreeStoredSchema {
    protected nodeSchemaData: BTree<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;
    protected rootFieldSchemaData: TreeFieldStoredSchema;
    protected readonly _events: Listenable<SchemaEvents> & import("@fluidframework/core-interfaces/internal").IEmitter<SchemaEvents> & import("@fluidframework/core-interfaces/internal").HasListeners<SchemaEvents>;
    readonly events: Listenable<SchemaEvents>;
    /**
     * Copies in the provided schema. If `data` is an TreeStoredSchemaRepository, it will be cheap-cloned.
     * Otherwise, it will be deep-cloned.
     *
     * We might not want to store schema in maps long term, as we might want a way to reserve a
     * large space of schema IDs within a schema.
     * The way mapFields has been structured mitigates the need for this, but it still might be useful.
     *
     * (ex: someone using data as field identifiers might want to
     * reserve all fields identifiers starting with "foo." to have a specific schema).
     * Combined with support for such namespaces in the allowed sets in the schema objects,
     * that might provide a decent alternative to mapFields (which is a bit odd).
     */
    constructor(data?: TreeStoredSchema);
    get nodeSchema(): ReadonlyMap<TreeNodeSchemaIdentifier, TreeNodeStoredSchema>;
    get rootFieldSchema(): TreeFieldStoredSchema;
    apply(newSchema: TreeStoredSchema): void;
    clone(): TreeStoredSchemaRepository;
}
export declare function schemaDataIsEmpty(data: TreeStoredSchema): boolean;
//# sourceMappingURL=storedSchemaRepository.d.ts.map