Packages > @fluidframework/tree

@fluidframework/tree Package

Interfaces

Interface Alerts Description
CommitMetadata Information about a commit that has been applied.
FieldSchemaUnsafe BETA Unenforced version of FieldSchema.
IDisposable An object with an explicit lifetime that can be ended.
ISubscribable

An object which allows the registration of listeners so that subscribers can be notified when an event happens.

EventEmitter can be used as a base class to implement this via extension.

ITree Channel for a Fluid Tree DDS.
MakeNominal Use this as the type of a protected field to cause a type to use nominal typing instead of structural.
Revertible Allows reversion of a change made to SharedTree.
SchemaIncompatible Information about how a view schema was incompatible.
TreeApi Provides various functions for interacting with TreeNodes.
TreeArrayNode A TreeNode which implements 'readonly T[]' and the array mutation APIs.
TreeArrayNodeBase A generic array type, used to defined types like TreeArrayNode.
TreeArrayNodeUnsafe BETA Unenforced version of TreeArrayNode.
TreeMapNode A map of string keys to tree objects.
TreeMapNodeUnsafe BETA Unenforced version of TreeMapNode.
TreeNodeApi Provides various functions for analyzing TreeNodes.
TreeNodeEvents A collection of events that can be raised by a TreeNode.
TreeNodeSchemaClass Tree node schema which is implemented using a class.
TreeNodeSchemaCore Data common to all tree node schema.
TreeNodeSchemaNonClass Schema which is not a class.
TreeView

An editable view of a (version control style) branch of a shared tree.

This view is always in one of two states: 1. In schema: the stored schema is compatible with the provided view schema. There is no error, and root can be used. 2. Out of schema: the stored schema is incompatible with the provided view schema. There is an error, and root cannot be used.

TreeViewEvents Events for TreeView.
WithType Adds a type field.

Classes

Class Alerts Modifiers Description
FieldSchema sealed

All policy for a specific field, including functionality that does not have to be kept consistent across versions or deterministic.

This can include policy for how to use this schema for "view" purposes, and well as how to expose editing APIs.

IterableTreeArrayContent Used to insert iterable content into a TreeArrayNode. Use (TreeArrayNode:variable).spread to create an instance of this type.
SchemaFactory sealed Creates various types of schema for TreeNodes.
SchemaFactoryRecursive BETA sealed Extends SchemaFactory with utilities for recursive schema.
TreeConfiguration Configuration for how to schematize a tree.
TreeNode A non-leaf SharedTree node. Includes objects, arrays, and maps.

Enumerations

Enum Description
CommitKind The type of a commit. This is used to describe the context in which the commit was created.
FieldKind Kind of a field on a node.
NodeKind Kind of tree node.
RevertibleStatus The status of a Revertible.
TreeStatus Status of the tree that a particular node belongs to.

Types

TypeAlias Alerts Description
AllowedTypes Types for use in fields.
ApplyKind Suitable for output. For input must error on side of excluding undefined instead.
ArrayToUnion Convert a Array type into a union of its value types.
Events Used to specify the kinds of events emitted by an ISubscribable.
ExtractItemType Get the Item type from a LazyItem<Item>.
FlexList A flexible way to list values. Each item in the list can either be an "eager" **value** or a "lazy" **function that returns a value** (the latter allows cyclic references to work).
FlexListToUnion Normalize FlexList type to a union.
ImplicitAllowedTypes Types allowed in a field.
ImplicitFieldSchema Schema for a field of a tree node.
InsertableObjectFromSchemaRecord

Helper used to produce types for:

1. Insertable content which can be used to construct an object node.

2. Insertable content which is an unhydrated object node.

3. Union of 1 and 2.

InsertableObjectFromSchemaRecordUnsafe BETA Unenforced version of InsertableObjectFromSchemaRecord.
InsertableTreeFieldFromImplicitField Type of content that can be inserted into the tree for a field of the given schema.
InsertableTreeFieldFromImplicitFieldUnsafe BETA Unenforced version of InsertableTreeFieldFromImplicitField.
InsertableTreeNodeFromImplicitAllowedTypes Type of content that can be inserted into the tree for a node of the given schema.
InsertableTreeNodeFromImplicitAllowedTypesUnsafe BETA Unenforced version of InsertableTreeNodeFromImplicitAllowedTypes.
InsertableTypedNode Data which can be used as a node to be inserted. Either an unhydrated node, or content to build a new node.
InsertableTypedNodeUnsafe BETA Unenforced version of InsertableTypedNode.
IsEvent true iff the given type is an acceptable shape for an event
LazyItem An "eager" or "lazy" Item in a FlexList. Lazy items are wrapped in a function to allow referring to themselves before they are declared. This makes recursive and co-recursive items possible.
NodeBuilderData Given a node's schema, return the corresponding object from which the node could be built.
NodeBuilderDataUnsafe BETA Unenforced version of InsertableTreeNodeFromImplicitAllowedTypes.
NodeFromSchema Takes in TreeNodeSchema[] and returns a TypedNode union.
NodeFromSchemaUnsafe BETA Unenforced version of NodeFromSchema.
ObjectFromSchemaRecord Helper used to produce types for object nodes.
ObjectFromSchemaRecordUnsafe BETA Unenforced version of ObjectFromSchemaRecord.
RestrictiveReadonlyRecord Alternative to the built in Record type which does not permit unexpected members, and is readonly.
ScopedSchemaName The name of a schema produced by SchemaFactory, including its optional scope prefix.
TreeFieldFromImplicitField Converts ImplicitFieldSchema to the corresponding tree node's field type.
TreeFieldFromImplicitFieldUnsafe BETA Unenforced version of TreeFieldFromImplicitField.
TreeLeafValue Value that may be stored as a leaf node.
TreeNodeFromImplicitAllowedTypes Type of of tree node for a field of the given schema.
TreeNodeFromImplicitAllowedTypesUnsafe BETA Unenforced version of TreeNodeFromImplicitAllowedTypes.
TreeNodeSchema Schema for a tree node.
TreeObjectNode A TreeNode which modules a JavaScript object.
TreeObjectNodeUnsafe BETA Unenforced version of TreeObjectNode.
Unenforced BETA

A placeholder to use in extends constraints when using the real type breaks compilation of some recursive types due to a design limitation of TypeScript.

These extends constraints only serve as documentation: to avoid breaking compilation, this type has to not actually enforce anything, and thus is just unknown. Therefore the type safety is the responsibility of the user of the API.

Unhydrated

Type alias to document which values are un-hydrated.

Un-hydrated values are nodes produced from schema's create functions that haven't been inserted into a tree yet.

Since un-hydrated nodes become hydrated when inserted, strong typing can't be used to distinguish them. This no-op wrapper is used instead.

ValidateRecursiveSchema BETA Compile time check for validity of a recursive schema.

Variables

Variable Modifiers Description
disposeSymbol readonly

Placeholder for Symbol.dispose.

Replace this with Symbol.dispose when it is available.

SharedTree readonly SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees of objects, arrays, and other data types.
Tree readonly The Tree object holds various functions for interacting with TreeNodes.
TreeArrayNode readonly A TreeNode which implements 'readonly T[]' and the array mutation APIs.
type readonly The type of a TreeNode. For moore information about the type, use Tree.schema(theNode) instead.

Variable Details

disposeSymbol

Placeholder for Symbol.dispose.

Replace this with Symbol.dispose when it is available.

Signature

disposeSymbol: unique symbol

SharedTree

SharedTree is a hierarchical data structure for collaboratively editing strongly typed JSON-like trees of objects, arrays, and other data types.

Signature

SharedTree: ISharedObjectKind<ITree>

Tree

The Tree object holds various functions for interacting with TreeNode s.

Signature

treeApi: TreeApi

TreeArrayNode

A TreeNode which implements ‘readonly T[]’ and the array mutation APIs.

Signature

TreeArrayNode: {
    spread: <T>(content: Iterable<T>) => IterableTreeArrayContent<T>;
}

type

The type of a TreeNode . For moore information about the type, use Tree.schema(theNode) instead.

Signature

type: unique symbol

Remarks

This symbol mainly exists on nodes to allow TypeScript to provide more accurate type checking. Tree.is and Tree.schema provide a superset of this information in more friendly ways.

This symbol should not manually be added to objects as doing so allows the object to be invalidly used where nodes are expected. Instead construct a real node of the desired type using its constructor.