/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import type { ValueSchema } from "../core/index.js";
import type { JsonCompatibleReadOnlyObject } from "../util/index.js";
import type { NodeKind, SchemaUpgrade, SimpleNodeSchemaBase } from "./core/index.js";
import type { FieldKind, FieldSchemaMetadata } from "./fieldSchema.js";
/**
 * A {@link SimpleNodeSchema} containing fields for alpha features.
 *
 * @system
 * @alpha
 * @sealed
 */
export interface SimpleNodeSchemaBaseAlpha<out TNodeKind extends NodeKind, out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<TNodeKind, TCustomMetadata> {
    /**
     * Persisted metadata for this node schema.
     * @remarks
     * While this can be stored in the document, not all versions / configurations will do so.
     * Additionally, this is not part of {@link TreeView.compatibility|schema compatibility}, so different clients
     * (even within the same collaborative session) may see different `persistedMetadata` for the same node.
     * Specified using {@link NodeSchemaOptionsAlpha.persistedMetadata}.
     * @privateRemarks
     * How/when this gets updated in documents,
     * and how to read it from documents should be documented here when this feature is more mature and these questions have good answers.
     * If this does end up getting reflected in some compatibility value, that should also be documented.
     */
    readonly persistedMetadata: JsonCompatibleReadOnlyObject | undefined;
}
/**
 * {@link AllowedTypes} for a location in the tree, expressed for use in the Simple Schema layer of abstraction.
 *
 * @remarks
 * Refers to the types by identifier.
 * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
 */
export type SimpleAllowedTypes = ReadonlyMap<string, SimpleAllowedTypeAttributes>;
/**
 * A {@link SimpleNodeSchema} for an object node.
 *
 * @alpha
 * @sealed
 */
export interface SimpleObjectNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBaseAlpha<NodeKind.Object, TCustomMetadata> {
    /**
     * Schemas for each of the object's fields, keyed off of schema's keys.
     * @remarks
     * The keys are the property keys if known, otherwise they are the stored keys.
     * Use {@link SimpleObjectFieldSchema.storedKey} to get the stored key.
     * @privateRemarks
     * TODO: Provide and link a way to translate from stored keys to the property keys.
     * TODO: Consider adding `storedKeysToFields` or something similar to reduce confusion,
     * especially if/when TreeNodeSchema for objects provide more maps.
     */
    readonly fields: ReadonlyMap<string, SimpleObjectFieldSchema>;
    /**
     * Whether the object node allows unknown optional fields.
     *
     * @see {@link ObjectSchemaOptions.allowUnknownOptionalFields} for the API where this field is set as part of authoring a schema.
     *
     * @remarks Only populated for view schemas, undefined otherwise. Relevant for compatibility checking scenarios.
     */
    readonly allowUnknownOptionalFields: boolean | undefined;
}
/**
 * A {@link SimpleFieldSchema} for an {@link SimpleObjectNodeSchema} field.
 * @remarks
 * The only other case fields are uses in the root schema.
 *
 * @alpha
 * @sealed
 */
export interface SimpleObjectFieldSchema extends SimpleFieldSchema {
    /**
     * The stored key of the field.
     * @remarks
     * See {@link FieldProps.key} for more information.
     */
    readonly storedKey: string;
}
/**
 * A {@link SimpleNodeSchema} for an array node.
 *
 * @alpha
 * @sealed
 */
export interface SimpleArrayNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBaseAlpha<NodeKind.Array, TCustomMetadata> {
    /**
     * The types allowed in the array.
     *
     * @remarks Refers to the types by identifier.
     * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
     */
    readonly simpleAllowedTypes: ReadonlyMap<string, SimpleAllowedTypeAttributes>;
}
/**
 * A {@link SimpleNodeSchema} for a map node.
 *
 * @alpha
 * @sealed
 */
export interface SimpleMapNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBaseAlpha<NodeKind.Map, TCustomMetadata> {
    /**
     * The types allowed as values in the map.
     *
     * @remarks Refers to the types by identifier.
     * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
     */
    readonly simpleAllowedTypes: ReadonlyMap<string, SimpleAllowedTypeAttributes>;
}
/**
 * A {@link SimpleNodeSchema} for a map node.
 *
 * @alpha
 * @sealed
 */
export interface SimpleRecordNodeSchema<out TCustomMetadata = unknown> extends SimpleNodeSchemaBaseAlpha<NodeKind.Record, TCustomMetadata> {
    /**
     * The types allowed as values in the record.
     *
     * @remarks Refers to the types by identifier.
     * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
     */
    readonly simpleAllowedTypes: ReadonlyMap<string, SimpleAllowedTypeAttributes>;
}
/**
 * A {@link SimpleNodeSchema} for a leaf node.
 *
 * @alpha
 * @sealed
 */
export interface SimpleLeafNodeSchema extends SimpleNodeSchemaBaseAlpha<NodeKind.Leaf> {
    /**
     * The kind of leaf node.
     */
    readonly leafKind: ValueSchema;
}
/**
 * A simple, shallow representation of a schema for a node.
 *
 * @remarks This definition is incomplete, and references child types by identifiers.
 * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which
 * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.
 *
 * Note that, as documented on {@link NodeKind}, more kinds of nodes may be added,
 * and therefore code should not assume that switching over all these cases can be done exhaustively.
 * @privateRemarks
 * Because of the above mentioned extensibility of node kinds, does it make sense to stabilize this?
 *
 * @alpha
 */
export type SimpleNodeSchema = SimpleLeafNodeSchema | SimpleMapNodeSchema | SimpleArrayNodeSchema | SimpleObjectNodeSchema | SimpleRecordNodeSchema;
/**
 * Information about allowed types under a field.
 *
 * @alpha
 * @sealed
 */
export interface SimpleAllowedTypeAttributes {
    /**
     * {@link SchemaUpgrade} if this schema is included as a {@link SchemaStaticsBeta.staged | staged} schema upgrade,
     * allowing the view schema be compatible with stored schema with (post upgrade) or without it (pre-upgrade).
     * New documents and schema upgrades will omit any staged schema.
     *
     * Undefined if derived from a stored schema.
     *
     * @privateRemarks
     * The false and undefined cases here are a bit odd.
     * This API should be reevaluated before stabilizing.
     */
    readonly isStaged: false | SchemaUpgrade | undefined;
}
/**
 * A simple, shallow representation of a schema for a field.
 *
 * @remarks This definition is incomplete, and references child types by identifiers.
 * To be useful, this generally needs to be used as a part of a complete {@link SimpleTreeSchema}, which
 * contains backing {@link SimpleTreeSchema.definitions} for each referenced identifier.
 *
 * @alpha
 * @sealed
 */
export interface SimpleFieldSchema {
    /**
     * The kind of tree field.
     */
    readonly kind: FieldKind;
    /**
     * Information about the allowed types under this field.
     *
     * @remarks Refers to the types by identifier.
     * A {@link SimpleTreeSchema} is needed to resolve these identifiers to their schema {@link SimpleTreeSchema.definitions}.
     */
    readonly simpleAllowedTypes: ReadonlyMap<string, SimpleAllowedTypeAttributes>;
    /**
     * {@inheritDoc FieldSchemaMetadata}
     */
    readonly metadata: FieldSchemaMetadata;
    /**
     * Persisted metadata for this field schema.
     * @remarks
     * Like {@link SimpleNodeSchemaBaseAlpha.persistedMetadata} but for fields.
     * Set via {@link FieldPropsAlpha.persistedMetadata}.
     */
    readonly persistedMetadata?: JsonCompatibleReadOnlyObject | undefined;
}
/**
 * A simplified representation of a schema for a tree.
 *
 * @remarks Contains the complete set of schema {@link SimpleTreeSchema.definitions} required to resolve references,
 * which are represented inline with identifiers.
 *
 * @alpha
 * @sealed
 */
export interface SimpleTreeSchema {
    /**
     * The tree field representing the root of the tree.
     */
    readonly root: SimpleFieldSchema;
    /**
     * The complete set of node schema definitions recursively referenced by the tree's {@link SimpleTreeSchema.root}.
     *
     * @remarks
     * The keys are the schemas' {@link TreeNodeSchemaCore.identifier | identifiers}.
     *
     * Information about if a schema is {@link SchemaStaticsBeta.staged | staged} or not is not available as the "Simple Schema" layer of abstraction: they are included unconditionally.
     * Options for filtering out staged schemas from view schema are available in {@link extractPersistedSchema}.
     */
    readonly definitions: ReadonlyMap<string, SimpleNodeSchema>;
}
//# sourceMappingURL=simpleSchema.d.ts.map