import { Serializable } from '@fluidframework/datastore-definitions' ; import { Definition , DetachedSequenceId , EditId , NodeId , TraitLabel } from '../Identifiers' ; /**
 * Types for Edits in Fluid Ops and Fluid summaries.
 *
 * Types describing locations in the tree are stable in the presence of other concurrent edits.
 *
 * All types are compatible with Fluid Serializable.
 *
 * These types can only be modified in ways that are both backwards and forwards compatible since they
 * are used in edits, and thus are persisted (using Fluid serialization).
 *
 * This means these types cannot be changed in any way that impacts their Fluid serialization
 * except through a very careful process:
 *
 * 1. The planned change must support all old data, and maintain the exact semantics of it.
 * This means that the change is pretty much limited to adding optional fields,
 * or making required fields optional.
 * 2. Support for the new format must be deployed to all users (This means all applications using SharedTree must do this),
 * and this deployment must be confirmed to be stable and will not be rolled back.
 * 3. Usage of the new format may start.
 *
 * Support for the old format can NEVER be removed: it must be maintained indefinably or old documents will break.
 * Because this process puts requirements on applications using shared tree,
 * step 3 should only ever be done in a Major version update,
 * and must be explicitly called out in the release notes
 * stating which versions of SharedTree are supported for documents modified by the new version.
 */ public export interface Edit < TChange > extends EditBase < TChange > { /**
     * Unique identifier for this edit. Must never be reused.
     * Used for referencing and de-duplicating edits.
     */ readonly id : EditId ; } public export interface EditWithoutId < TChange > extends EditBase < TChange > { /**
     * Used to explicitly state that EditWithoutId cannot contain an id and prevents type Edit from being assigned to type EditWithoutId.
     */ readonly id ? : never ; } public export interface EditBase < TChange > { /**
     * Actual changes to apply.
     * Applied in order as part of a single transaction.
     */ readonly changes : readonly TChange [ ] ; } public export interface TraitMap < TChild > { readonly [ key ] : TreeNodeSequence < TChild > ; } public export type TreeNodeSequence < TChild > = readonly TChild [ ] ; /**
 * Json compatible representation of a payload storing arbitrary Serializable data.
 *
 * Keys starting with "IFluid" are reserved for special use such as the JavaScript feature detection pattern and should not be used.
 *
 * See  comparePayloads for equality semantics and related details (like what is allowed to be lost when serializing)
 *
 * TODO:#51984: Allow opting into heuristic blobbing in snapshots with a special IFluid key.
 *
 *  public export type Payload = Serializable ; public export interface NodeData { readonly payload ? : Payload ; /**
     * The meaning of this node.
     * Provides contexts/semantics for this node and its content.
     * Typically use to associate a node with metadata (including a schema) and source code (types, behaviors, etc).
     */ readonly definition : Definition ; /**
     * Identifier which can be used to refer to this Node.
     */ readonly identifier : NodeId ; } public export interface TreeNode < TChild > extends NodeData { readonly traits : TraitMap < TChild > ; } public export interface TraitLocation { readonly parent : NodeId ; readonly label : TraitLabel ; } public export type ChangeNode = TreeNode < ChangeNode > ; public export type BuildNode = TreeNode < BuildNode > | DetachedSequenceId ; public export enum EditStatus { /**
     * The edit contained one or more malformed changes (e.g. was missing required fields such as `id`),
     * or contained a sequence of changes that could not possibly be applied sequentially without error
     * (e.g. an edit which tries to insert the same detached node twice).
     */ Malformed , /**
     * The edit contained a well-formed sequence of changes that couldn't be applied to the current view,
     * generally because concurrent changes caused one or more merge conflicts.
     */ Invalid , /**
     * The edit was applied to the current view successfully.
     */ Applied } /**
 * Types of ops handled by SharedTree.
 */ export enum SharedTreeOpType { /** An op that includes edit information. */ Edit , /** Includes a Fluid handle that corresponds to an edit chunk. */ Handle , /** An op that does not affect the tree's state. */ NoOp } /**
 * Requirements for SharedTree ops.
 */ export interface SharedTreeOp { type : SharedTreeOpType ; } /**
 * A SharedTree op that includes edit information.
 */ export interface SharedTreeEditOp < TChange > extends SharedTreeOp { edit : Edit < TChange > ; } /**
 * A SharedTree op that includes edit handle information.
 * The handle corresponds to an edit chunk in the edit log.
 */ export interface SharedTreeHandleOp extends SharedTreeOp { /** The serialized handle to an uploaded edit chunk. */ editHandle : string ; /** The index of the first edit in the chunk that corresponds to the handle. */ startRevision : number ; }