Skip to main content

fluid-framework Package

Bundles a collection of Fluid Framework client libraries for easy use when paired with a corresponding service client package (e.g. @fluidframework/azure-client, @fluidframework/tinylicious-client, or @fluidframework/odsp-client (BETA)).

Interfaces

InterfaceAlertsModifiersDescription
AllowedTypeMetadataBetaAnnotations that apply to an individual allowed type.
AllowedTypesMetadataBetaAnnotations that apply to a set of allowed types.
AnnotatedAllowedTypeBetasealedStores annotations for an individual allowed type.
AnnotatedAllowedTypesBetasealedStores annotations for a set of allowed types.
AnnotatedAllowedTypesUnsafeSystemsealedUnenforced version of AnnotatedAllowedTypes.
AnnotatedAllowedTypeUnsafeSystemsealedUnenforced version of AnnotatedAllowedType.
ArrayNodeCustomizableSchemaSystemsealedA schema for customizable TreeArrayNodes.
ArrayNodeCustomizableSchemaUnsafeSystemsealedUnenforced version of ArrayNodeCustomizableSchemas.
ArrayNodePojoEmulationSchemaSystemsealedA schema for POJO emulation mode TreeArrayNodes.
BranchableTreeAlphasealedA "version control"-style branch of a SharedTree.
CodecWriteOptionsAlphaOptions relating to encoding of persisted data.
CommitMetadatasealedInformation about a commit that has been applied.
ContainerSchemaDeclares the Fluid objects that will be available in the Container.
DirtyTreeMapAlphaA map-like interface for tracking the status of nodes that have been tracked for changes.
FieldPropsAdditional information to provide to a FieldSchema.
FieldPropsAlphaAlphaFieldProps extended with additional alpha options.
FieldSchemaAlphaUnsafeSystemsealedUnenforced version of FieldSchemaAlpha.
FieldSchemaMetadatasealedMetadata associated with a FieldSchema.
ForestOptionsBetaConfiguration options for SharedTree's internal tree storage.
ForestTypeBetasealedUsed to distinguish between different forest types.
FormatValidatorAlphasealedA kind of validator for SharedTree's internal data formats.
IBranchOriginLegacyBranch origin information.
ICodecOptionsAlphaOptions relating to handling of persisted data.
IConnectionBase interface for information for each connection made to the Fluid session.
IDirectoryLegacysealedInterface describing actions on a directory.
IDirectoryEventsLegacysealedEvents emitted in response to changes to the directory data.
IDirectoryValueChangedLegacysealedType of "valueChanged" event parameter for ISharedDirectory.
IDisposablesealedBase interface for objects that require lifetime management via explicit disposal.
IErrorBaseBase interface for all errors and warnings emitted the container.
IErrorEventBase interface for error event emitters.
IEventBase interface for event emitters.
IEventProvidersealedBase interface for event providers.
IFluidContainersealedProvides an entrypoint into the client side of collaborative Fluid data. Provides access to the data as well as status on the collaboration session.
IFluidContainerEventssealedEvents emitted from IFluidContainer.
IFluidHandlesealedHandle to a shared FluidObject.
IFluidHandleErasedsealedA type erased Fluid Handle. These can only be produced by the Fluid Framework and provide the implementation details needed to power IFluidHandle.
IFluidLoadablesealedA shared FluidObject with a handle that can be used to retrieve it.
IIntervalLegacyBasic interval abstraction
IMemberBase interface to be implemented to fetch each service's member.
InternalTreeNodesealedA node type internal to @fluidframework/tree.
IProvideFluidLoadable
ISequencedDocumentMessageLegacySequenced message for a distributed document.
ISequenceDeltaRangeLegacyA range that has changed corresponding to a segment modification.
ISequenceIntervalCollectionLegacyCollection of intervals that supports addition, modification, removal, and efficient spatial querying. Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).
ISequenceIntervalCollectionEventsLegacyChange events emitted by IntervalCollections
ISerializedIntervalLegacySerialized object representation of an interval. This representation is used for ops that create or change intervals.
IServiceAudienceBase interface to be implemented to fetch each service's audience.
IServiceAudienceEventsEvents that trigger when the roster of members in the Fluid session change.
ISharedDirectoryLegacysealedProvides a hierarchical organization of map-like data structures as SubDirectories. The values stored within can be accessed like a map, and the hierarchy can be navigated using path syntax. SubDirectories can be retrieved for use as working directories.
ISharedDirectoryEventsLegacysealedEvents emitted in response to changes to the directory data.
ISharedMapLegacysealedThe SharedMap distributed data structure can be used to store key-value pairs.
ISharedMapEventsLegacysealedEvents emitted in response to changes to the map data.
ISharedObjectLegacyBase interface for shared objects from which other interfaces extend.
ISharedObjectEventsLegacyEvents emitted by ISharedObject.
ISharedSegmentSequenceLegacy
ISharedSegmentSequenceEventsLegacyEvents emitted in response to changes to the sequence data.
ISharedStringLegacyFluid object interface describing access methods on a SharedString
ITelemetryBasePropertiesJSON-serializable properties, which will be logged with telemetry.
ITraceLegacyMessages to track latency trace.
ITreesealedChannel for a Fluid Tree DDS.
ITreeAlphaAlphasealedITree extended with some alpha APIs.
ITreeConfigurationOptionsOptions when constructing a tree view.
ITreeViewConfigurationProperty-bag configuration for TreeViewConfiguration construction.
IValueChangedLegacysealedType of "valueChanged" event parameter.
JsonArrayNodeSchemaAlphasealedJSON Schema for an array node.
JsonLeafNodeSchemaAlphasealedJSON Schema for a leaf node.
JsonMapNodeSchemaAlphasealedJSON Schema for a map node.
JsonNodeSchemaBaseAlphasealedBase interface for node schemas represented in JSON Schema format.
JsonObjectNodeSchemaAlphasealedJSON Schema for an object node.
JsonRecordNodeSchemaAlphasealedJSON Schema for a record node.
JsonSchemaRefAlphasealedType entry containing a reference to a definition in the schema.
JsonStringKeyPatternPropertiesAlphasealedTypes allowed in map / record nodes.
LeafSchemaSystemsealedA TreeNodeSchema for a TreeLeafValue.
ListenablesealedAn object which allows the registration of listeners so that subscribers can be notified when an event happens.
MakeNominalsealedUse this as the type of a protected field to cause a type to use nominal typing instead of structural.
MapNodeCustomizableSchemaSystemsealedA schema for customizable TreeMapNodes.
MapNodeCustomizableSchemaUnsafeSystemsealedUnenforced version of MapNodeCustomizableSchemas.
MapNodePojoEmulationSchemaSystemsealedA schema for POJO emulation mode TreeMapNodes.
NodeChangedDataBetasealedData included for nodeChanged.
NodeInDocumentConstraintA transaction constraint which requires that the given node exists in the tree.
NodeSchemaMetadatasealedMetadata associated with a Node Schema.
NodeSchemaOptionsAdditional information to provide to Node Schema creation.
NodeSchemaOptionsAlphaAlphaAdditional information to provide to Node Schema creation. Includes fields for alpha features.
ObjectNodeSchemaAlphasealedA schema for TreeObjectNodes.
ObjectSchemaOptionsBetaOptions when declaring an object node's schema.
ObjectSchemaOptionsAlphaAlphaOptions when declaring an object node's schema
ObservationResultsAlphasealedResults from an operation with tracked observations.
ReadonlyArrayNodeSystemsealed

A covariant base type for TreeArrayNode.

This provides the readonly subset of TreeArrayNode functionality, and is used as the source interface for moves since that needs to be covariant.

RecordNodeCustomizableSchemaSystemsealedA schema for customizable TreeMapNodes.
RecordNodePojoEmulationSchemaSystemsealedA schema for POJO emulation mode TreeMapNodes.
RevertiblesealedAllows reversion of a change made to SharedTree.
RevertibleAlphaAlphasealedA Revertible with features that are not yet stable.
RunTransactionsealedA function which runs a transaction in a SharedTree.
RunTransactionParamsAlphaThe parameters for the RunTransaction API.
SchemaCompatibilityStatussealed

Information about a view schema's compatibility with the document's stored schema.

See SharedTree's README for more information about choosing a compatibility policy.

SchemaStaticsSystemsealedStateless APIs exposed via SchemaFactory as both instance properties and as statics.
SchemaStaticsBetaSystemsealedStateless APIs exposed via SchemaFactoryBeta as both instance properties and as statics.
SequenceDeltaEventLegacy

The event object returned on sequenceDelta events.

The properties of this object and its sub-objects represent the state of the sequence at the point in time at which the operation was applied. They will not take into consideration any future modifications performed to the underlying sequence and merge tree.

For group ops, each op will get its own event, and the group op property will be set on the op args.

Ops may get multiple events. For instance, an insert-replace will get a remove then an insert event.

SequenceEventLegacy

Base class for SequenceDeltaEvent and SequenceMaintenanceEvent.

The properties of this object and its sub-objects represent the state of the sequence at the point in time at which the operation was applied. They will not take into any future modifications performed to the underlying sequence and merge tree.

SequenceIntervalLegacyInterval implementation whose ends are associated with positions in a mutatable sequence. As such, when content is inserted into the middle of the interval, the interval expands to include that content.
SequenceIntervalIndexLegacy

Collection of intervals.

Implementers of this interface will typically implement additional APIs to support efficiently querying a collection of intervals in some manner, for example: - "find all intervals with start endpoint between these two points" - "find all intervals which overlap this range" etc.

SequenceMaintenanceEventLegacy

The event object returned on maintenance events.

The properties of this object and its sub-objects represent the state of the sequence at the point in time at which the operation was applied. They will not take into consideration any future modifications performed to the underlying sequence and merge tree.

SharedObjectKindsealedDefines a kind of shared object.
SharedTreeFormatOptionsAlphaOptions for configuring the persisted format SharedTree uses.
SharedTreeOptionsAlphaConfiguration options for SharedTree.
SimpleAllowedTypeAttributesAlphasealedInformation about allowed types under a field.
SimpleArrayNodeSchemaAlphasealedA SimpleNodeSchema for an array node.
SimpleFieldSchemaAlphasealedA simple, shallow representation of a schema for a field.
SimpleLeafNodeSchemaAlphasealedA SimpleNodeSchema for a leaf node.
SimpleMapNodeSchemaAlphasealedA SimpleNodeSchema for a map node.
SimpleNodeSchemaBaseSystemsealedBase interface for TreeNodeSchema and SimpleNodeSchema types. Once simple schema is stable this doesn't have a reason to be kept @system, but it could be.
SimpleNodeSchemaBaseAlphaSystemsealedA SimpleNodeSchema containing fields for alpha features.
SimpleObjectFieldSchemaAlphasealedA SimpleFieldSchema for an SimpleObjectNodeSchema field.
SimpleObjectNodeSchemaAlphasealedA SimpleNodeSchema for an object node.
SimpleRecordNodeSchemaAlphasealedA SimpleNodeSchema for a map node.
SimpleTreeSchemaAlphasealedA simplified representation of a schema for a tree.
Tagged

A property to be logged to telemetry may require a tag indicating the value may contain sensitive data. This type wraps a value of the given type V in an object along with a string tag (type can be further specified as T).

This indicates that the value should be organized or handled differently by loggers in various first or third party scenarios. For example, tags are used to mark data that should not be stored in logs for privacy reasons.

TransactionResultFailedAlphaThe result of the RunTransaction API when it failed.
TransactionResultSuccessAlphaThe result of the RunTransaction API when it was successful.
TreeSystemsealedProvides various functions for interacting with TreeNodes.
TreeAlphaSystemsealedExtensions to Tree and TreeBeta which are not yet stable.
TreeArrayNodesealedA TreeNode which implements 'readonly T[]' and the array mutation APIs.
TreeBetaSystemsealedExtensions to Tree which are not yet stable.
TreeBranchBetasealedA collection of functionality associated with a (version-control-style) branch of a SharedTree.
TreeBranchAlphaAlphasealedTreeBranch with alpha-level APIs.
TreeBranchEventsAlphasealedEvents for TreeBranch.
TreeBranchForkAlphasealedA branch of a SharedTree that has merged from another branch.
TreeChangeEventssealedA collection of events that can be emitted by a TreeNode.
TreeChangeEventsBetaBetasealedExtensions to TreeChangeEvents which are not yet stable.
TreeEncodingOptionsBetaOptions for how to interpret or encode a tree when schema information is available.
TreeIdentifierUtilsAlphasealedA utility interface for retrieving or converting node identifiers.
TreeIndexAlphaA index where values are keyed on TreeIndexKeys.
TreeMapNodesealedA map of string keys to tree objects.
TreeNodeApisealedProvides various functions for analyzing TreeNodes.
TreeNodeSchemaCoresealedData common to all tree node schema.
TreeRecordNodeBetaA TreeNode which models a TypeScript record.
TreeRecordNodeUnsafeSystemsealedUnenforced version of TreeRecordNode.
TreeSchemaAlphasealedTreeViewConfigurationAlpha
TreeSchemaEncodingOptionsAlphaOptions for how to interpret or encode a tree when schema information is available.
TreeViewsealedAn editable view of a (version control style) branch of a shared tree based on some schema.
TreeViewAlphaAlphasealedTreeView with proposed changes to the schema aware typing to allow use with UnsafeUnknownSchema.
TreeViewBetaBetasealedTreeView with additional beta APIs.
TreeViewEventssealedEvents for TreeView.
VerboseTreeNodeAlphaVerbose encoding of a TreeNode.
ViewableTreeSystemsealedA tree from which a TreeView can be created.
ViewContentAlphaThe portion of SharedTree data typically persisted by the container. Usable with independentInitializedView(config, options, content) to create a TreeView without loading a container.
WithTypesealedAdds a type symbol to a type for stronger typing.

Classes

ClassAlertsModifiersDescription
ErasedBaseTypeSystemsealedUsed to mark a @sealed interface in a strongly typed way to prevent external implementations.
ErasedTypesealedErased type which can be used to expose a opaque/erased version of a type without referencing the actual type.
FieldSchemasealed

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. Use SchemaFactory to create the FieldSchema instances, for example optional.

FieldSchemaAlphaAlphasealedFieldSchema including alpha APIs (currently SimpleFieldSchema).
IterableTreeArrayContentsealedUsed to insert iterable content into a TreeArrayNode. Use (TreeArrayNode:variable).spread to create an instance of this type.
SchemaFactorysealedCreates various types of schema for TreeNodes.
SchemaFactoryAlphaAlphaSchemaFactory with additional alpha APIs.
SchemaFactoryBetaBetaSchemaFactory with additional beta APIs.
SchemaUpgradeBetasealedUnique token used to upgrade schemas and determine if a particular upgrade has been completed.
TreeNodesealedA non-leaf SharedTree node. Includes objects, arrays, and maps.
TreeViewConfigurationsealedConfiguration for viewWith(config).
TreeViewConfigurationAlphaAlphasealedTreeViewConfiguration extended with some alpha APIs.

Enumerations

EnumAlertsDescription
AttachStateThe attachment state of some Fluid data (e.g. a container or data store), denoting whether it is uploaded to the service. The transition from detached to attached state is a one-way transition.
CommitKindThe type of a commit. This is used to describe the context in which the commit was created.
ConnectionStateThe state of the Container's connection to the service.
FieldKindKind of a field on an TreeObjectNode.
IntervalTypeLegacy
KeyEncodingOptionsBetaOptions for how to encode keys in a tree.
NodeKindKind of tree node.
RevertibleStatusThe status of a Revertible.
TreeCompressionStrategyAlphaSelects which heuristics to use when encoding tree content. All encoding options here are compatible with the same decoder: the selection here does not impact compatibility.
TreeStatusStatus of the tree that a particular node belongs to.
ValueSchemaAlphaSchema for what TreeLeafValue is allowed on a Leaf node.

Types

TypeAliasAlertsModifiersDescription
AllowedTypesSystemSchema for types allowed in some location in a tree (like a field, map entry or array).
AllowedTypesFullBetasealedStores annotations for a set of allowed types.
AllowedTypesFullEvaluatedBetasealedAllowedTypesFull but with the lazy schema references eagerly evaluated.
AllowedTypesFullFromMixedSystemsealedCreates an AllowedTypesFull type from a mixed array of annotated and unannotated allowed types.
AllowedTypesFullFromMixedUnsafeSystemsealedUnenforced version of AllowedTypesFullFromMixed.
AllowedTypesFullUnsafeSystemsealedUnenforced version of AllowedTypesFull.
AnnotateAllowedTypesListSystemAdd annotations to a list of allowed types that may or may not contain annotations.
AnnotateAllowedTypesListUnsafeSystemsealedUnenforced version of AnnotateAllowedTypesList.
ArrayNodeSchemaAlphaA schema for TreeArrayNodes.
ConciseTreeBetaConcise encoding of a TreeNode or TreeLeafValue.
ConnectionStateTypeType defining the different states of connectivity a Container can be in.
ContainerAttachPropsRepresents properties that can be attached to a container.
DeserializeCallbackLegacy
DirtyTreeStatusAlphaThe status of a node in a that has been tracked for changes.
FactoryContentSystemContent which can be used to build a node.
FactoryContentObjectSystemRecord-like object which can be used to build some kinds of nodes.
FixRecursiveArraySchemaBetaWorkaround for fixing errors resulting from an issue with recursive ArrayNode schema exports.
FluidObject

This utility type take interface(s) that follow the FluidObject pattern, and produces a new type that can be used for inspection and discovery of those interfaces.

It is meant to be used with types that are known to implement the FluidObject pattern. A common way to specify a type implements the FluidObject pattern is to expose it as a FluidObject without a generic argument.

FluidObjectProviderKeysProduces a valid FluidObject key given a type and a property.
HandleConverterAlphaOptions for how to transcode handles.
ICriticalContainerErrorRepresents errors raised on container.
IdentifierIndexAlphaAn index that returns tree nodes given their associated identifiers.
IEventThisPlaceHolderThe placeholder type that should be used instead of this in events.
IEventTransformerThis type is a conditional type for transforming all the overloads provided in TEvent.
ImplicitAllowedTypesTypes of TreeNodes or TreeLeafValues allowed at a location in a tree.
ImplicitFieldSchemaSchema for a field of a tree node.
InitialObjectsExtract the type of 'initialObjects' from the given ContainerSchema type.
InputSystem

This type exists only to be linked from documentation to provide a single linkable place to document some details of "Input" types and how they handle schema.

When a schema is used to describe data which is an input into an API, the API is contravariant) over the schema. (See also TypeScript Variance Annotations).

Since these schema are expressed using TypeScript types, it is possible for the user of the API to provide non-exact values of these types which has implications that depended on the variance.

Consider a field with schema type of A

InsertableAlphaContent which could be inserted into a tree.
InsertableContentSystemContent which can be inserted into a tree.
InsertableFieldAlphaContent which could be inserted into a field within a tree.
InsertableTreeFieldFromImplicitFieldType of content that can be inserted into the tree for a field of the given schema.
InsertableTreeNodeFromAllowedTypesSystemType of content that can be inserted into the tree for a node of the given schema.
InsertableTreeNodeFromImplicitAllowedTypesType of content that can be inserted into the tree for a node of the given schema.
InsertableTypedNodeData which can be used as a node to be inserted. Either an unhydrated node, or content to build a new node.
IntervalStickinessLegacy

Determines how an interval should expand when segments are inserted adjacent to the range it spans

Note that interval stickiness is currently an experimental feature and must be explicitly enabled with the intervalStickinessEnabled flag

IsListenertrue iff the given type is an acceptable shape for a event listener
IsUnionSystemReturns true if T is a union and false if it is not.
JsonCompatibleBetaUse for Json compatible data.
JsonCompatibleObjectBetaUse for Json object compatible data.
JsonCompatibleReadOnlyAlphaUse for readonly view of Json compatible data.
JsonCompatibleReadOnlyObjectAlphaUse for readonly view of Json compatible data.
JsonFieldSchemaAlphasealedJSON Schema representation of a FieldSchema.
JsonLeafSchemaTypeAlphaJSON primitive types.
JsonNodeSchemaAlphaJSON Schema representation of a TreeNodeSchema.
JsonRefPathAlphaReference string pointing to a definition in the schema. Should be the fully-qualified identifier.
JsonSchemaIdAlphaThe fully-qualified identifier.
JsonSchemaTypeAlphaJSON entity type.
JsonTreeSchemaAlphasealedJSON Schema representation of a tree schema.
LazyItemAn "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.
ListenersUsed to specify the kinds of events emitted by a Listenable.
MapNodeInsertableDataSystemContent which can be used to construct a Map node, explicitly or implicitly.
MapNodeSchemaAlphaA schema for TreeMapNodes.
MemberChangedListenerSignature for IMember change events.
MyselfAn extended member object that includes currentConnection
NodeFromSchemaTakes in TreeNodeSchema[] and returns a TypedNode union.
NumberKeysSystemExtracts the keys of T which are numbers.
ObjectFromSchemaRecordSystemGenerates the properties for an ObjectNode from its field schema object.
OffA function that, when called, will deregister an event listener subscription that was previously registered.
PopUnionSystemGets the first item of a union type.
ReadableFieldSystemContent which could be read from a field within a tree.
ReadSchemaSystemAdapter to remove UnsafeUnknownSchema from a schema type so it can be used with types for generating APIs for reading data.
RecordNodeInsertableDataSystemContent which can be used to construct a Record node, explicitly or implicitly.
RecordNodeSchemaAlphaA schema for TreeRecordNodes.
ReplaceIEventThisPlaceHolderDoes the type replacement by changing types of IEventThisPlaceHolder to TThis
RestrictiveReadonlyRecordDeprecatedAlternative to the built in Record type which does not permit unexpected members, and is readonly.
RestrictiveStringRecordSystemAlternative to the built-in Record<string, T> type which is readonly and does not permit symbols.
RevertibleAlphaFactoryAlphasealedFactory for creating a RevertibleAlpha.
RevertibleFactorysealedFactory for creating a Revertible.
SharedDirectoryLegacyEntrypoint for ISharedDirectory creation.
SharedMapLegacyEntrypoint for ISharedMap creation.
SharedStringLegacyAlias for ISharedString for compatibility.
SharedStringSegmentLegacy
SharedTreeOptionsBetaBetaConfiguration options for SharedTree.
SimpleNodeSchemaAlphaA simple, shallow representation of a schema for a node.
SimpleTreeIndexAlphaA TreeIndex that returns tree nodes given their associated keys.
TelemetryBaseEventPropertyTypeProperty types that can be logged.
TransactionCallbackStatusAlphaThe status of the transaction callback in the RunTransaction API.
TransactionConstraintA requirement for a SharedTree transaction to succeed.
TransactionResultAlphaThe result of the RunTransaction API. This is the same as TransactionResultExt but with the value field omitted. This is useful when the transaction callback doesn't need to return a value.
TransactionResultExtAlphaThe result of the RunTransaction API.
TransformedEventTransforms the event overload by replacing IEventThisPlaceHolder with TThis in the event listener arguments and having the overload return TTHis as well
TreeFieldFromImplicitFieldConverts an ImplicitFieldSchema to a property type suitable for reading a field with this that schema.
TreeIndexKeyAlphaValue that may be used as keys in a TreeIndex.
TreeIndexNodesAlphaan array of nodes that is guaranteed to have at least one element
TreeLeafValueValue that may be stored as a leaf node.
TreeNodeFromImplicitAllowedTypesType of tree node for a field of the given schema.
TreeNodeSchemasealedSchema for a TreeNode or TreeLeafValue.
TreeNodeSchemaClasssealedTree node schema which is implemented using a class.
TreeNodeSchemaNonClassSystemsealedSchema which is not a class.
TreeObjectNodeA TreeNode which models a JavaScript object.
TreeParsingOptionsAlphaOptions for how to interpret a tree when schema information is available.
UnannotateAllowedTypesListSystemRemoves annotations from a list of allowed types that may contain annotations.
UnannotateAllowedTypesListUnsafeSystemsealedUnenforced version of UnannotateAllowedTypesList.
UnannotateAllowedTypeUnsafeSystemsealedUnenforced utility to remove AnnotatedAllowedTypeUnsafe wrappers.
Unenforced

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.

UnionToIntersectionSystemConvert a union of types to an intersection of those types. Useful for TransformEvents.
UnionToTupleSystemConverts a union type to a tuple type.
UnsafeUnknownSchemaAlphaA special type which can be provided to some APIs as the schema type parameter when schema cannot easily be provided at compile time and an unsafe (instead of disabled) editing API is desired.
ValidateRecursiveSchemaCompile time check for validity of a recursive schema. This type also serves as a central location for documenting the requirements and issues related to recursive schema.
ValidateRecursiveSchemaTemplateSystemValidation logic used by ValidateRecursiveSchema.
VerboseTreeAlphaVerbose encoding of a TreeNode or TreeLeafValue.
VoidTransactionCallbackStatusAlphaThe status of a the transaction callback in the RunTransaction API where the transaction doesn't need to return a value. This is the same as TransactionCallbackStatus but with the value field omitted. This

Functions

FunctionAlertsReturn TypeDescription
adaptEnum(factory, members)Beta(<TValue extends TEnum[keyof TEnum]>(value: TValue) => TValue extends unknown ? TreeNode & { readonly value: TValue; } : never) & { readonly [Property in keyof TEnum]: TreeNodeSchemaClass<ScopedSchemaName<TScope, TEnum[Property]>, NodeKind.Object, TreeNode & { readonly value: TEnum[Property]; }, Record<string, never>, true, Record<string, never>, undefined>; } & { readonly schema: UnionToTuple<{ readonly [Property in keyof TEnum]: TreeNodeSchemaClass<ScopedSchemaName<TScope, TEnum[Property]>, NodeKind.Object, TreeNode & { readonly value: TEnum[Property]; }, Record<string, never>, true, Record<string, never>, undefined>; }[keyof TEnum]>; }Converts an enum into a collection of schema which can be used in a union.
allowUnused(t)AlphavoidDoes nothing with the provided value, but appears to use it to make unused locals warnings and errors go away.
asAlpha(view)AlphaTreeViewAlpha<TSchema>Retrieve the alpha API for a TreeView.
asAlpha(view)AlphaTreeViewConfigurationAlpha<TSchema>Retrieve the alpha API for a TreeViewConfiguration.
asBeta(view)BetaTreeViewBeta<TSchema>Retrieve the beta API for a TreeView.
asTreeViewAlpha(view)Deprecated, AlphaTreeViewAlpha<TSchema>Retrieve the alpha API for a TreeView.
checkCompatibility(viewWhichCreatedStoredSchema, view)AlphaOmit<SchemaCompatibilityStatus, "canInitialize">Compute the compatibility of using view to view a tree who's stored schema could be derived from viewWhichCreatedStoredSchema via either initialize(content) or upgradeSchema().
cloneWithReplacements(root, rootKey, replacer)AlphaunknownLike JSON.stringify, but returns a clone instead of stringifying the result.
comparePersistedSchema(persisted, view, options)AlphaOmit<SchemaCompatibilityStatus, "canInitialize">Compares two schema extracted using extractPersistedSchema(schema, minVersionForCollab, includeStaged). Reports the same compatibility that compatibility would report if opening a document that used the persisted schema and provided view to viewWith(config).
configuredSharedTree(options)AlphaSharedObjectKind<ITree>SharedTree but allowing a non-default configuration.
configuredSharedTreeBeta(options)BetaSharedObjectKind<ITree>SharedTree but allowing a non-default configuration.
createIdentifierIndex(view)AlphaIdentifierIndexCreates an IdentifierIndex for a given TreeView.
createIndependentTreeAlpha(options)AlphaViewableTree & Pick<ITreeAlpha, "exportVerbose" | "exportSimpleSchema">Alpha extensions to createIndependentTreeBeta(options).
createIndependentTreeBeta(options)BetaViewableTreeCreate a ViewableTree that is not tied to any Fluid runtimes or services.
createSimpleTreeIndex(view, indexer, getValue, isKeyValid)AlphaSimpleTreeIndex<TKey, TValue>Creates a SimpleTreeIndex with a specified indexer.
createSimpleTreeIndex(view, indexer, getValue, isKeyValid, indexableSchema)AlphaSimpleTreeIndex<TKey, TValue>Creates a SimpleTreeIndex with a specified indexer.
createSimpleTreeIndex(view, indexer, getValue, isKeyValid)AlphaSimpleTreeIndex<TKey, TValue>Creates a SimpleTreeIndex with a specified indexer.
createSimpleTreeIndex(view, indexer, getValue, isKeyValid, indexableSchema)AlphaSimpleTreeIndex<TKey, TValue>Creates a SimpleTreeIndex with a specified indexer.
decodeSimpleSchema(encodedSchema, validator)AlphaSimpleTreeSchemaDecodes a JSON-compatible schema into a simple schema.
encodeSimpleSchema(simpleSchema)AlphaJsonCompatibleReadOnlyEncodes a simple schema (view or stored) into a serializable format.
enumFromStrings(factory, members)Beta(<TValue extends Members[number]>(value: TValue) => TValue extends unknown ? TreeNode & { readonly value: TValue; } : never) & { [Index in Extract<keyof Members, `${number}`> extends `${infer N extends number}` ? N : never as Members[Index]]: TreeNodeSchemaClass<ScopedSchemaName<TScope, Members[Index]>, NodeKind.Object, TreeNode & { readonly value: Members[Index]; }, Record<string, never>, true, Record<string, never>, undefined>; } & { readonly schema: UnionToTuple<Members[number] extends unknown ? { [Index in Extract<keyof Members, `${number}`> extends `${infer N extends number}` ? N : never as Members[Index]]: TreeNodeSchemaClass<ScopedSchemaName<TScope, Members[Index]>, NodeKind.Object, TreeNode & { readonly value: Members[Index]; }, Record<string, never>, true, Record<string, never>, undefined>; }[Members[number]] : never>; }Converts an array of distinct strings into a collection of schema which can be used like an enum style union.
evaluateLazySchema(value)AlphaTReturns the schema referenced by the LazyItem.
exportCompatibilitySchemaSnapshot(config)AlphaJsonCompatibleReadOnly

Returns a JSON compatible representation of the tree schema for snapshot compatibility checking.

Snapshots can be loaded by the same or newer package versions, but not necessarily older versions.

extractPersistedSchema(schema, minVersionForCollab, includeStaged)AlphaJsonCompatibleDumps the "persisted" schema subset of the provided schema into a deterministic JSON-compatible, semi-human-readable format.
generateSchemaFromSimpleSchema(simple)AlphaTreeSchemaCreate FieldSchema from a SimpleTreeSchema.
getBranch(tree)Deprecated, AlphaBranchableTreeGet a BranchableTree from a ITree.
getBranch(view)Deprecated, AlphaBranchableTreeGet a BranchableTree from a TreeView.
getJsonSchema(schema, options)AlphaJsonTreeSchemaCreates a JSON Schema representation of the provided TreeNodeSchema.
getSimpleSchema(schema)AlphaSimpleTreeSchemaCopies data from ImplicitFieldSchema to create a SimpleTreeSchema out of new plain JavaScript objects, Sets and Maps.
importCompatibilitySchemaSnapshot(config)AlphaTreeViewConfiguration

Parse the format exported by exportCompatibilitySchemaSnapshot(config) into a schema.

Can load snapshots created by the same or older package versions, but not necessarily newer versions.

independentInitializedView(config, options, content)AlphaTreeViewAlpha<TSchema>Create an initialized TreeView that is not tied to any ITree instance.
independentView(config, options)AlphaTreeViewAlpha<TSchema>Create an uninitialized TreeView that is not tied to any ITree instance.
isFluidHandle(value)value is IFluidHandleCheck if a value is an @fluidframework/core-interfaces#IFluidHandle.
normalizeAllowedTypes(types)AlphaAllowedTypesFullNormalizes an ImplicitAllowedTypes to an AllowedTypesFull.
onAssertionFailure(handler)Alpha() => voidAdd a callback which can be used to report an assertion before it is thrown.
persistedToSimpleSchema(persisted, options)AlphaSimpleTreeSchemaA way to parse schema in the persisted format from extractPersistedSchema(schema, minVersionForCollab, includeStaged).
replaceConciseTreeHandles(tree, replacer)AlphaConciseTree<T>Clones tree, replacing any handles.
replaceHandles(tree, replacer)AlphaunknownClones tree, replacing any handles.
replaceVerboseTreeHandles(tree, replacer)AlphaVerboseTree<T>Clones tree, replacing any handles.
singletonSchema(factory, name)BetaTreeNodeSchemaClass<ScopedSchemaName<TScope, TName>, NodeKind.Object, TreeNode & { readonly value: TName; }, Record<string, never>, true, Record<string, never>, undefined>Create a schema for a node with no state.
trackDirtyNodes(view, dirty)Alpha() => voidRegisters a visitor on the view's forest that tracks which nodes are dirty.

Variables

VariableAlertsModifiersTypeDescription
ArrayNodeSchemaAlphareadonly{ readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is ArrayNodeSchema; }
contentSchemaSymbolAlphareadonlyunique symbolThe intended type of insertable content that is to become a TreeNode.
FluidClientVersionAlphareadonly{ readonly v2_0: "2.0.0"; readonly v2_43: "2.43.0"; readonly v2_52: "2.52.0"; readonly v2_73: "2.73.0"; }Versions of Fluid Framework client packages.
ForestTypeExpensiveDebugBetareadonlyForestTypeSlow implementation of forest intended only for debugging.
ForestTypeOptimizedBetareadonlyForestTypeOptimized implementation of forest.
ForestTypeReferenceBetareadonlyForestTypeReference implementation of forest.
FormatValidatorBasicAlphareadonlyimport("../codec/codec.js").FormatValidatorA FormatValidator implementation which uses TypeBox's JSON schema validator.
FormatValidatorNoOpAlphareadonlyFormatValidatorA FormatValidator which does no validation.
IFluidHandlereadonly
IFluidLoadablereadonlykeyof IProvideFluidLoadable
IntervalStickinessLegacyreadonly{ readonly NONE: 0; readonly START: 1; readonly END: 2; readonly FULL: 3; }

Determines how an interval should expand when segments are inserted adjacent to the range it spans

Note that interval stickiness is currently an experimental feature and must be explicitly enabled with the intervalStickinessEnabled flag

MapNodeSchemaAlphareadonly{ readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is MapNodeSchema; }
ObjectNodeSchemaAlphareadonly{ readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is ObjectNodeSchema<string, RestrictiveStringRecord<ImplicitFieldSchema>, boolean, unknown>; }
RecordNodeSchemaAlphareadonly{ readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is RecordNodeSchema<string, ImplicitAllowedTypes, true, unknown>; }
rollbackreadonlyunique symbolA special object that signifies when a SharedTree transaction should "roll back".
SchemaFactory_baseSystemreadonlySchemaStatics & (new () => SchemaStatics)Base class for SchemaFactory, exposes SchemaStatics as both static properties and member properties.
SharedDirectoryLegacyreadonlyimport("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedDirectory> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedDirectory>Entrypoint for ISharedDirectory creation.
SharedMapLegacyreadonlyimport("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedMap> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedMap>Entrypoint for ISharedMap creation.
SharedStringLegacyreadonlyimport("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedString> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedString>Entrypoint for ISharedString creation.
SharedTreereadonlySharedObjectKind<ITree>A hierarchical data structure for collaboratively editing strongly typed JSON-like trees of objects, arrays, and other data types.
TreereadonlyTreeThe Tree singleton which holds various functions for interacting with TreeNodes.
TreeAlphaAlphareadonlyTreeAlphaExtensions to Tree and TreeBeta which are not yet stable.
TreeArrayNodereadonly{ readonly spread: <T>(content: Iterable<T>) => IterableTreeArrayContent<T>; }A TreeNode which implements 'readonly T[]' and the array mutation APIs.
TreeBetaBetareadonlyTreeBetaExtensions to Tree which are not yet stable.
typeSchemaSymbolSystemreadonlyunique symbolThe type of a TreeNode. For more information about the type, use Tree.schema(theNode) instead.
UnsafeUnknownSchemaAlphareadonlyunique symbolA special type which can be provided to some APIs as the schema type parameter when schema cannot easily be provided at compile time and an unsafe (instead of disabled) editing API is desired.

Namespaces

NamespaceAlertsDescription
ConnectionStateTypeNamespace for the different connection states a container can be in. PLEASE NOTE: The sequence of the numerical values does no correspond to the typical connection state progression.
FluidSerializableAsTreeBeta

Utilities for storing Fluid Serializable data in TreeNodes.

Same as JsonAsTree except allows IFluidHandles.

InternalTypes
JsonAsTreeAlphaUtilities for storing JSON data in TreeNodes.
System_TableSchemaSystemNot intended for use outside of this package.
System_UnsafeSystemA collection of Unenforced types that are used in the implementation of recursive schema. These are all @system types, and thus should not be used directly.
TableSchemaAlphaContains types and factories for creating schema to represent dynamic tabular data.

Function Details

adaptEnum

Converts an enum into a collection of schema which can be used in a union.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

export declare function adaptEnum<TScope extends string, const TEnum extends Record<string, string | number>>(factory: SchemaFactory<TScope>, members: TEnum): (<TValue extends TEnum[keyof TEnum]>(value: TValue) => TValue extends unknown ? TreeNode & {
readonly value: TValue;
} : never) & { readonly [Property in keyof TEnum]: TreeNodeSchemaClass<ScopedSchemaName<TScope, TEnum[Property]>, NodeKind.Object, TreeNode & {
readonly value: TEnum[Property];
}, Record<string, never>, true, Record<string, never>, undefined>; } & {
readonly schema: UnionToTuple<{ readonly [Property in keyof TEnum]: TreeNodeSchemaClass<ScopedSchemaName<TScope, TEnum[Property]>, NodeKind.Object, TreeNode & {
readonly value: TEnum[Property];
}, Record<string, never>, true, Record<string, never>, undefined>; }[keyof TEnum]>;
};
Type Parameters
ParameterConstraintDescription
TScopestringThe scope of the provided factory. There is a known issue where if a factory is provided that is typed as a SchemaFactoryAlpha, and its scope contains a "." character, the inferred type for the scope will end up as a union of the scope up to the first "." character and the scope as it should be. This can be mitigated by explicitly providing the TScope type parameter or by typing the provided factory as a SchemaFactory instead of a SchemaFactoryAlpha.
TEnumRecord<string, string | number>

Remarks

The string value of the enum is used as the name of the schema: callers must ensure that it is stable and unique. Numeric enums values have the value implicitly converted into a string. Consider making a dedicated schema factory with a nested scope (for example using scopedFactory(name)) to avoid the enum members colliding with other schema.

Example

const schemaFactory = new SchemaFactory("com.myApp");
// An enum for use in the tree. Must have string keys.
enum Mode {
a = "A",
b = "B",
}
// Define the schema for each member of the enum using a nested scope to group them together.
const ModeNodes = adaptEnum(new SchemaFactory(`${schemaFactory.scope}.Mode`), Mode);
// Defined the types of the nodes which correspond to this the schema.
type ModeNodes = TreeNodeFromImplicitAllowedTypes<(typeof ModeNodes.schema)>;
// An example schema which has an enum as a child.
class Parent extends schemaFactory.object("Parent", {
// adaptEnum's return value has a ".schema" property can be use as an `AllowedTypes` array allowing any of the members of the enum.
mode: ModeNodes.schema,
}) {}

// Example usage of enum based nodes, showing what type to use and that `.value` can be used to read out the enum value.
function getValue(node: ModeNodes): Mode {
return node.value;
}

// Example constructing a tree containing an enum node from an enum value.
// The syntax `new ModeNodes.a()` is also supported.
function setValue(node: Parent): void {
node.mode = ModeNodes(Mode.a);
}

Parameters

ParameterTypeDescription
factorySchemaFactory<TScope>
membersTEnum

Returns

Return type: (<TValue extends TEnum[keyof TEnum]>(value: TValue) => TValue extends unknown ? TreeNode & { readonly value: TValue; } : never) & { readonly [Property in keyof TEnum]: TreeNodeSchemaClass<ScopedSchemaName<TScope, TEnum[Property]>, NodeKind.Object, TreeNode & { readonly value: TEnum[Property]; }, Record<string, never>, true, Record<string, never>, undefined>; } & { readonly schema: UnionToTuple<{ readonly [Property in keyof TEnum]: TreeNodeSchemaClass<ScopedSchemaName<TScope, TEnum[Property]>, NodeKind.Object, TreeNode & { readonly value: TEnum[Property]; }, Record<string, never>, true, Record<string, never>, undefined>; }[keyof TEnum]>; }

See Also

enumFromStrings(factory, members) for a similar function that works on arrays of strings instead of an enum.

allowUnused

Does nothing with the provided value, but appears to use it to make unused locals warnings and errors go away.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function allowUnused<T>(t?: T): void;
Type Parameters
ParameterDescription
T

Remarks

When TypeScript is configured with "noUnusedLocals", it will produce an error if a local variable is declared but never used. When you want to have this check enabled, but not follow it for a specific variable, you can pass the type or value to this function.

Instead of using this, consider disabling "noUnusedLocals" in your tsconfig.json file, and enabling a similar check via a linter. This will allow you to still have the check, but have more control over it, for example being able to suppress it, or enable patterns like allowing unused locals with an "_" prefix.

Parameters

ParameterModifiersTypeDescription
toptionalT

asAlpha

Retrieve the alpha API for a TreeView.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function asAlpha<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewAlpha<TSchema>;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Parameters

ParameterTypeDescription
viewTreeView<TSchema>

Returns

Return type: TreeViewAlpha<TSchema>

asAlpha

Retrieve the alpha API for a TreeViewConfiguration.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function asAlpha<TSchema extends ImplicitFieldSchema>(view: TreeViewConfiguration<TSchema>): TreeViewConfigurationAlpha<TSchema>;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Parameters

ParameterTypeDescription
viewTreeViewConfiguration<TSchema>

Returns

Return type: TreeViewConfigurationAlpha<TSchema>

asBeta

Retrieve the beta API for a TreeView.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

export declare function asBeta<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewBeta<TSchema>;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Parameters

ParameterTypeDescription
viewTreeView<TSchema>

Returns

Return type: TreeViewBeta<TSchema>

asTreeViewAlpha

Retrieve the alpha API for a TreeView.

This API is deprecated and will be removed in a future release.

Use asAlpha(view) instead.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function asTreeViewAlpha<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): TreeViewAlpha<TSchema>;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Parameters

ParameterTypeDescription
viewTreeView<TSchema>

Returns

Return type: TreeViewAlpha<TSchema>

checkCompatibility

Compute the compatibility of using view to view a tree who's stored schema could be derived from viewWhichCreatedStoredSchema via either initialize(content) or upgradeSchema().

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function checkCompatibility(viewWhichCreatedStoredSchema: TreeViewConfiguration, view: TreeViewConfiguration): Omit<SchemaCompatibilityStatus, "canInitialize">;

Remarks

See SchemaCompatibilityStatus for details on the compatibility results.

Example

This example demonstrates checking the compatibility of a historical schema against a current schema. In this case, the historical schema is a Point2D object with x and y fields, while the current schema is a Point3D object that adds an optional z field.

// This snapshot is assumed to be the same as Point3D, except missing `z`.
const encodedSchema = JSON.parse(fs.readFileSync("PointSchema.json", "utf8"));
const oldViewSchema = importCompatibilitySchemaSnapshot(encodedSchema);

// Build the current view schema
class Point3D extends factory.object("Point", {
x: factory.number,
y: factory.number,

// The current schema has a new optional field that was not present on Point2D
z: factory.optional(factory.number),
}) {}
const currentViewSchema = new TreeViewConfiguration({ schema: Point3D });

// Check to see if the document created by the historical view schema can be opened with the current view schema
const backwardsCompatibilityStatus = checkCompatibility(oldViewSchema, currentViewSchema);

// z is not present in Point2D, so the schema must be upgraded
assert.equal(backwardsCompatibilityStatus.canView, false);

// The schema can be upgraded to add the new optional field
assert.equal(backwardsCompatibilityStatus.canUpgrade, true);

// Test what the old version of the application would do with a tree using the new schema:
const forwardsCompatibilityStatus = checkCompatibility(currentViewSchema, oldViewSchema);

// If the old schema set allowUnknownOptionalFields, this would be true, but since it did not,
// this assert will fail, detecting the forwards compatibility break:
// this means these two versions of the application cannot collaborate on content using these schema.
assert.equal(forwardsCompatibilityStatus.canView, true);

Parameters

ParameterTypeDescription
viewWhichCreatedStoredSchemaTreeViewConfigurationFrom which to derive the stored schema, as if it initialized or upgraded a tree via TreeView.
viewTreeViewConfigurationThe view being tested to see if it could view tree created or initialized using viewWhichCreatedStoredSchema.

Returns

The compatibility status.

Return type: Omit<SchemaCompatibilityStatus, "canInitialize">

cloneWithReplacements

Like JSON.stringify, but returns a clone instead of stringifying the result.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function cloneWithReplacements(root: unknown, rootKey: string, replacer: (key: string, value: unknown) => {
clone: boolean;
value: unknown;
}): unknown;

Remarks

Only considers enumerable own properties with string keys.

Parameters

ParameterTypeDescription
rootunknownData to clone.
rootKeystringThe key to pass to replacer for the root.
replacer(key: string, value: unknown) => { clone: boolean; value: unknown; }Like JSON.stringify's replacer: called for every value while walking data. Unlike JSON.stringify's replacer, this returns a wrapper around the value with a "clone" flag to indicate if the clone should recurse into that object (true) or use it as is (false).

Returns

A clone of root.

Return type: unknown

comparePersistedSchema

Compares two schema extracted using extractPersistedSchema(schema, minVersionForCollab, includeStaged). Reports the same compatibility that compatibility would report if opening a document that used the persisted schema and provided view to viewWith(config).

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function comparePersistedSchema(persisted: JsonCompatible, view: ImplicitFieldSchema, options: ICodecOptions): Omit<SchemaCompatibilityStatus, "canInitialize">;

Remarks

This uses the persisted formats for schema, meaning it only includes data which impacts compatibility. It also uses the persisted format so that this API can be used in tests to compare against saved schema from previous versions of the application.

Example

An application could use extractPersistedSchema(schema, minVersionForCollab, includeStaged) to generate a schema.json file for various versions of the app, then test that documents using those schema can be upgraded to work with the current schema using a test like:

assert(
comparePersistedSchema(
require("./schema.json"),
MySchema,
{ jsonValidator: typeboxValidator },
false,
).canUpgrade,
);

Parameters

ParameterTypeDescription
persistedJsonCompatibleSchema persisted for a document. Typically persisted alongside the data and assumed to describe that data.
viewImplicitFieldSchemaSchema which would be used to view persisted content.
optionsICodecOptionsICodecOptions used when parsing the provided schema.

Returns

The SchemaCompatibilityStatus a TreeView would report for this combination of schema.

Return type: Omit<SchemaCompatibilityStatus, "canInitialize">

configuredSharedTree

SharedTree but allowing a non-default configuration.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function configuredSharedTree(options: SharedTreeOptions): SharedObjectKind<ITree>;

Remarks

This is useful for debugging and testing. For example, it can be used to opt into extra validation or see if opting out of some optimizations fixes an issue.

With great care, and knowledge of the support and stability of the options exposed here, this can also be used to opt into some features early or for performance tuning.

Example

import {
TreeCompressionStrategy,
configuredSharedTree,
FormatValidatorBasic,
ForestTypeReference,
} from "fluid-framework/alpha";
const SharedTree = configuredSharedTree({
forest: ForestTypeReference,
jsonValidator: FormatValidatorBasic,
treeEncodeType: TreeCompressionStrategy.Uncompressed,
});

Parameters

ParameterTypeDescription
optionsSharedTreeOptions

Returns

Return type: SharedObjectKind<ITree>

configuredSharedTreeBeta

SharedTree but allowing a non-default configuration.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

export declare function configuredSharedTreeBeta(options: SharedTreeOptionsBeta): SharedObjectKind<ITree>;

Remarks

This is useful for debugging and testing. For example it can be used to opt into extra validation or see if opting out of some optimizations fixes an issue.

With great care, and knowledge of the support and stability of the options exposed here, this can also be used to opt into some features early or for performance tuning.

Example

import {
configuredSharedTreeBeta,
ForestTypeReference,
} from "fluid-framework/beta";
const SharedTree = configuredSharedTree({
forest: ForestTypeReference,
});

Parameters

ParameterTypeDescription
optionsSharedTreeOptionsBeta

Returns

Return type: SharedObjectKind<ITree>

createIdentifierIndex

Creates an IdentifierIndex for a given TreeView.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function createIdentifierIndex<TSchema extends ImplicitFieldSchema>(view: TreeView<TSchema>): IdentifierIndex;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Parameters

ParameterTypeDescription
viewTreeView<TSchema>

Returns

Return type: IdentifierIndex

createIndependentTreeAlpha

Alpha extensions to createIndependentTreeBeta(options).

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function createIndependentTreeAlpha<const TSchema extends ImplicitFieldSchema>(options?: ForestOptions & (({
idCompressor?: IIdCompressor | undefined;
} & {
content?: undefined;
}) | (ICodecOptions & {
content: ViewContent;
} & {
idCompressor?: undefined;
}))): ViewableTree & Pick<ITreeAlpha, "exportVerbose" | "exportSimpleSchema">;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Parameters

ParameterModifiersTypeDescription
optionsoptionalForestOptions & (({ idCompressor?: IIdCompressor | undefined; } & { content?: undefined; }) | (ICodecOptions & { content: ViewContent; } & { idCompressor?: undefined; }))Configuration options for the independent tree. This can be used to create an uninitialized tree, or content can be provided to create an initialized tree. If content is provided, the idCompressor is a required part of it: otherwise it is optional and provided at the top level.

Returns

Return type: ViewableTree & Pick<ITreeAlpha, "exportVerbose" | "exportSimpleSchema">

createIndependentTreeBeta

Create a ViewableTree that is not tied to any Fluid runtimes or services.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

export declare function createIndependentTreeBeta<const TSchema extends ImplicitFieldSchema>(options?: ForestOptions): ViewableTree;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Remarks

Such a tree can never experience collaboration or be persisted to to a Fluid Container.

This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.

Example

const tree = createIndependentTreeBeta();

const stagedConfig = new TreeViewConfiguration({
schema: SchemaFactoryAlpha.types([
SchemaFactory.number,
SchemaFactoryAlpha.staged(SchemaFactory.string),
]),
});
const afterConfig = new TreeViewConfigurationAlpha({
schema: [SchemaFactory.number, SchemaFactory.string],
});

// Initialize tree
{
const view = tree.viewWith(stagedConfig);
view.initialize(1);
view.dispose();
}

// Do schema upgrade
{
const view = tree.viewWith(afterConfig);
view.upgradeSchema();
view.root = "A";
view.dispose();
}

// Can still view tree with staged schema
{
const view = tree.viewWith(stagedConfig);
assert.equal(view.root, "A");
view.dispose();
}

Parameters

ParameterModifiersTypeDescription
optionsoptionalForestOptions

Returns

Return type: ViewableTree

createSimpleTreeIndex

Creates a SimpleTreeIndex with a specified indexer.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue>(view: TreeView<TFieldSchema>, indexer: (schema: TreeNodeSchema) => string | undefined, getValue: (nodes: TreeIndexNodes<TreeNode>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey): SimpleTreeIndex<TKey, TValue>;
Type Parameters
ParameterConstraintDescription
TFieldSchemaImplicitFieldSchema
TKeyTreeIndexKey
TValue

Parameters

ParameterTypeDescription
viewTreeView<TFieldSchema>the view for the tree being indexed
indexer(schema: TreeNodeSchema) => string | undefineda function that takes in a TreeNodeSchema and returns the field name that all nodes of the given schema should be keyed on, must be pure and functional
getValue(nodes: TreeIndexNodes<TreeNode>) => TValuegiven at least one TreeNode, returns an associated value
isKeyValid(key: TreeIndexKey) => key is TKeyfunction for verifying the validity of the key retrieved based on the information given by the indexer

Returns

Return type: SimpleTreeIndex<TKey, TValue>

createSimpleTreeIndex

Creates a SimpleTreeIndex with a specified indexer.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue, TSchema extends TreeNodeSchema>(view: TreeView<TFieldSchema>, indexer: (schema: TSchema) => string | undefined, getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey, indexableSchema: readonly TSchema[]): SimpleTreeIndex<TKey, TValue>;
Type Parameters
ParameterConstraintDescription
TFieldSchemaImplicitFieldSchema
TKeyTreeIndexKey
TValue
TSchemaTreeNodeSchema

Parameters

ParameterTypeDescription
viewTreeView<TFieldSchema>the view for the tree being indexed
indexer(schema: TSchema) => string | undefineda function that takes in a TreeNodeSchema and returns the field name that all nodes of the given schema should be keyed on, must be pure and functional
getValue(nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValuegiven at least one TreeNode, returns an associated value
isKeyValid(key: TreeIndexKey) => key is TKeyfunction for verifying the validity of the key retrieved based on the information given by the indexer
indexableSchemareadonly TSchema[]a list of all the schema types that can be indexed

Returns

Return type: SimpleTreeIndex<TKey, TValue>

createSimpleTreeIndex

Creates a SimpleTreeIndex with a specified indexer.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue>(view: TreeView<TFieldSchema>, indexer: Map<TreeNodeSchema, string>, getValue: (nodes: TreeIndexNodes<TreeNode>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey): SimpleTreeIndex<TKey, TValue>;
Type Parameters
ParameterConstraintDescription
TFieldSchemaImplicitFieldSchema
TKeyTreeIndexKey
TValue

Parameters

ParameterTypeDescription
viewTreeView<TFieldSchema>the view for the tree being indexed
indexerMap<TreeNodeSchema, string>a map from TreeNodeSchema to the field name that all nodes of the given schema should be keyed on
getValue(nodes: TreeIndexNodes<TreeNode>) => TValuegiven at least one TreeNode, returns an associated value
isKeyValid(key: TreeIndexKey) => key is TKeyfunction for verifying the validity of the key retrieved based on the information given by the indexer

Returns

Return type: SimpleTreeIndex<TKey, TValue>

createSimpleTreeIndex

Creates a SimpleTreeIndex with a specified indexer.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function createSimpleTreeIndex<TFieldSchema extends ImplicitFieldSchema, TKey extends TreeIndexKey, TValue, TSchema extends TreeNodeSchema>(view: TreeView<TFieldSchema>, indexer: Map<TreeNodeSchema, string>, getValue: (nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValue, isKeyValid: (key: TreeIndexKey) => key is TKey, indexableSchema: readonly TSchema[]): SimpleTreeIndex<TKey, TValue>;
Type Parameters
ParameterConstraintDescription
TFieldSchemaImplicitFieldSchema
TKeyTreeIndexKey
TValue
TSchemaTreeNodeSchema

Parameters

ParameterTypeDescription
viewTreeView<TFieldSchema>the view for the tree being indexed
indexerMap<TreeNodeSchema, string>a map from TreeNodeSchema to the field name that all nodes of the given schema should be keyed on
getValue(nodes: TreeIndexNodes<NodeFromSchema<TSchema>>) => TValuegiven at least one TreeNode, returns an associated value
isKeyValid(key: TreeIndexKey) => key is TKeyfunction for verifying the validity of the key retrieved based on the information given by the indexer
indexableSchemareadonly TSchema[]a list of all the schema types that can be indexed

Returns

Return type: SimpleTreeIndex<TKey, TValue>

decodeSimpleSchema

Decodes a JSON-compatible schema into a simple schema.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function decodeSimpleSchema(encodedSchema: JsonCompatibleReadOnly, validator?: FormatValidator): SimpleTreeSchema;

Parameters

ParameterModifiersTypeDescription
encodedSchemaJsonCompatibleReadOnlyThe encoded schema to decode.
validatoroptionalFormatValidatorThe format validator to use to validate the encoded schema.

Returns

A decoded simple schema.

Return type: SimpleTreeSchema

Error Handling

Will throw a usage error if the encoded schema is not in the expected format.

encodeSimpleSchema

Encodes a simple schema (view or stored) into a serializable format.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function encodeSimpleSchema(simpleSchema: SimpleTreeSchema): JsonCompatibleReadOnly;

Remarks

The JSON-compatible schema returned from this method is only intended for use in snapshots/comparisons of schemas. It is not possible to reconstruct a full schema (including metadata and persistedMetadata) from the encoded format.

Parameters

ParameterTypeDescription
simpleSchemaSimpleTreeSchema

Returns

A serializable representation of the schema.

Return type: JsonCompatibleReadOnly

enumFromStrings

Converts an array of distinct strings into a collection of schema which can be used like an enum style union.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

export declare function enumFromStrings<TScope extends string, const Members extends readonly string[]>(factory: SchemaFactory<TScope>, members: Members): (<TValue extends Members[number]>(value: TValue) => TValue extends unknown ? TreeNode & {
readonly value: TValue;
} : never) & { [Index in Extract<keyof Members, `${number}`> extends `${infer N extends number}` ? N : never as Members[Index]]: TreeNodeSchemaClass<ScopedSchemaName<TScope, Members[Index]>, NodeKind.Object, TreeNode & {
readonly value: Members[Index];
}, Record<string, never>, true, Record<string, never>, undefined>; } & {
readonly schema: UnionToTuple<Members[number] extends unknown ? { [Index in Extract<keyof Members, `${number}`> extends `${infer N extends number}` ? N : never as Members[Index]]: TreeNodeSchemaClass<ScopedSchemaName<TScope, Members[Index]>, NodeKind.Object, TreeNode & {
readonly value: Members[Index];
}, Record<string, never>, true, Record<string, never>, undefined>; }[Members[number]] : never>;
};
Type Parameters
ParameterConstraintDescription
TScopestring
Membersreadonly string[]

Remarks

The returned collection is also a function which can be used to convert strings into Unhydrated nodes in the union. Each node type has a .value getter which returns the associated string.

The produced nodes use the provided strings as their name, and don't store any data beyond that.

Example

const schemaFactory = new SchemaFactory("com.myApp");
const Mode = enumFromStrings(schemaFactory, ["Fun", "Cool"]);
type Mode = TreeNodeFromImplicitAllowedTypes<typeof Mode.schema>;
const nodeFromString: Mode = Mode("Fun");
const nodeFromSchema: Mode = new Mode.Fun();

// Schema nodes have a strongly typed `.value` property.
const nameFromNode: "Fun" | "Cool" = nodeFromSchema.value;

class Parent extends schemaFactory.object("Parent", { mode: Mode.schema }) {}

Parameters

ParameterTypeDescription
factorySchemaFactory<TScope>
membersMembers

Returns

Return type: (<TValue extends Members[number]>(value: TValue) => TValue extends unknown ? TreeNode & { readonly value: TValue; } : never) & { [Index in Extract<keyof Members, `${number}`> extends `${infer N extends number}` ? N : never as Members[Index]]: TreeNodeSchemaClass<ScopedSchemaName<TScope, Members[Index]>, NodeKind.Object, TreeNode & { readonly value: Members[Index]; }, Record<string, never>, true, Record<string, never>, undefined>; } & { readonly schema: UnionToTuple<Members[number] extends unknown ? { [Index in Extract<keyof Members, `${number}`> extends `${infer N extends number}` ? N : never as Members[Index]]: TreeNodeSchemaClass<ScopedSchemaName<TScope, Members[Index]>, NodeKind.Object, TreeNode & { readonly value: Members[Index]; }, Record<string, never>, true, Record<string, never>, undefined>; }[Members[number]] : never>; }

See Also

adaptEnum(factory, members) for a similar function that works on enums instead of arrays of strings.

evaluateLazySchema

Returns the schema referenced by the LazyItem.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function evaluateLazySchema<T extends TreeNodeSchema>(value: LazyItem<T>): T;
Type Parameters
ParameterConstraintDescription
TTreeNodeSchema

Remarks

Caches results to handle LazyItems which compute their resulting schema.

Parameters

ParameterTypeDescription
valueLazyItem<T>

Returns

Return type: T

exportCompatibilitySchemaSnapshot

Returns a JSON compatible representation of the tree schema for snapshot compatibility checking.

Snapshots can be loaded by the same or newer package versions, but not necessarily older versions.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function exportCompatibilitySchemaSnapshot(config: Pick<TreeViewConfiguration, "schema">): JsonCompatibleReadOnly;

Example

This example creates and persists a snapshot of a Point2D schema.

const schemaFactory = new SchemaFactory("test");
class Point2D extends schemaFactory.object("Point", {
x: factory.number,
y: factory.number,
}) {}
const viewSchema = new TreeViewConfiguration({ schema: Point2D });
const encodedSchema = JSON.stringify(exportCompatibilitySchemaSnapshot(viewSchema));
fs.writeFileSync("PointSchema.json", encodedSchema);

Parameters

ParameterTypeDescription
configPick<TreeViewConfiguration, "schema">The schema to snapshot. Only the schema field of the TreeViewConfiguration is used.

Returns

The JSON representation of the schema.

Return type: JsonCompatibleReadOnly

See Also

importCompatibilitySchemaSnapshot(config) which loads these snapshots.

extractPersistedSchema

Dumps the "persisted" schema subset of the provided schema into a deterministic JSON-compatible, semi-human-readable format.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function extractPersistedSchema(schema: ImplicitFieldSchema, minVersionForCollab: MinimumVersionForCollab, includeStaged: (upgrade: SchemaUpgrade) => boolean): JsonCompatible;

Remarks

This can be used to help inspect schema for debugging, and to save a snapshot of schema to help detect and review changes to an applications schema. This format is also compatible with schema, comparePersistedSchema(persisted, view, options) and persistedToSimpleSchema(persisted, options).

This only includes the "persisted" subset of schema information, which means the portion which gets included in documents. It thus uses "persisted" keys, see key.

If two schema have identical "persisted" schema, then they are considered equivalent.

See also comparePersistedSchema(persisted, view, options).

Example

An application could use this API to generate a schema.json file when it first releases, then test that the schema is sill compatible with documents from that version with a test like :

assert.deepEqual(extractPersistedSchema(MySchema, FluidClientVersion.v2_0), require("./schema.json"));

Parameters

ParameterTypeDescription
schemaImplicitFieldSchemaThe schema to dump.
minVersionForCollabMinimumVersionForCollabThe oldest client version which can read the schema: impacts the format used.
includeStaged(upgrade: SchemaUpgrade) => booleanfilter for selecting which staged allowed types to include in the output.

Returns

Return type: JsonCompatible

generateSchemaFromSimpleSchema

Create FieldSchema from a SimpleTreeSchema.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function generateSchemaFromSimpleSchema(simple: SimpleTreeSchema): TreeSchema;

Remarks

Only use this API if hand written schema (produced using SchemaFactory cannot be provided.

Using generated schema with schema aware APIs (designed to work with strongly typed schema) like TreeViewConfiguration will produce a poor TypeScript typing experience which is subject to change.

Editing through a view produced using this schema can easily violate invariants other users of the document might expect and must be done with great care.

This API bakes in some arbitrary policy choices for how to handle data that is not included in the SimpleTreeSchema API, for example the value of allowUnknownOptionalFields. If any particular choice is required for such cases, this API should not be used.

Parameters

ParameterTypeDescription
simpleSimpleTreeSchema

Returns

Return type: TreeSchema

getBranch

Get a BranchableTree from a ITree.

This API is deprecated and will be removed in a future release.

This API is superseded by TreeBranch, which should be used instead.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function getBranch(tree: ITree): BranchableTree;

Remarks

The branch can be used for "version control"-style coordination of edits on the tree.

Parameters

ParameterTypeDescription
treeITree

Returns

Return type: BranchableTree

getBranch

Get a BranchableTree from a TreeView.

This API is deprecated and will be removed in a future release.

This API is superseded by TreeBranch, which should be used instead.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function getBranch<T extends ImplicitFieldSchema | UnsafeUnknownSchema>(view: TreeViewAlpha<T>): BranchableTree;
Type Parameters
ParameterConstraintDescription
TImplicitFieldSchema | UnsafeUnknownSchema

Remarks

The branch can be used for "version control"-style coordination of edits on the tree. Branches are currently an unstable "alpha" API and are subject to change in the future.

Parameters

ParameterTypeDescription
viewTreeViewAlpha<T>

Returns

Return type: BranchableTree

getJsonSchema

Creates a JSON Schema representation of the provided TreeNodeSchema.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function getJsonSchema(schema: ImplicitAllowedTypes, options: Required<TreeSchemaEncodingOptions>): JsonTreeSchema;

Remarks

Useful when communicating the schema to external libraries or services. Caches the result for future calls.

Example

A Shared Tree schema like the following:

class MyObject extends schemaFactory.object("MyObject", {
foo: schemaFactory.number,
bar: schemaFactory.optional(schemaFactory.string),
});

Will yield JSON Schema like the following:

{
"$defs": {
"com.fluidframework.leaf.string": {
"type": "string",
},
"com.fluidframework.leaf.number": {
"type": "number",
},
"com.myapp.MyObject": {
"type": "object",
"properties": {
"foo": { "$ref": "com.fluidframework.leaf.number" },
"bar": { "$ref": "com.fluidframework.leaf.string" },
},
"required": ["foo"],
},
},
"$ref": "#/$defs/com.myapp.MyObject",
}

Parameters

ParameterTypeDescription
schemaImplicitAllowedTypes
optionsRequired<TreeSchemaEncodingOptions>

Returns

Return type: JsonTreeSchema

getSimpleSchema

Copies data from ImplicitFieldSchema to create a SimpleTreeSchema out of new plain JavaScript objects, Sets and Maps.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function getSimpleSchema(schema: ImplicitFieldSchema): SimpleTreeSchema;

Remarks

See also TreeViewConfigurationAlpha which implements SimpleTreeSchema as a way to get a SimpleTreeSchema without copying the node and field schema and without losing as much type information.

Parameters

ParameterTypeDescription
schemaImplicitFieldSchema

Returns

Return type: SimpleTreeSchema

importCompatibilitySchemaSnapshot

Parse the format exported by exportCompatibilitySchemaSnapshot(config) into a schema.

Can load snapshots created by the same or older package versions, but not necessarily newer versions.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function importCompatibilitySchemaSnapshot(config: JsonCompatibleReadOnly): TreeViewConfiguration;

Example

This example loads and parses a snapshot of a Point2D schema.

const oldViewSchema = importCompatibilitySchemaSnapshot(fs.readFileSync("PointSchema.json", "utf8"));

Parameters

ParameterTypeDescription
configJsonCompatibleReadOnlyThe JSON representation of the schema.

Returns

The schema. Only the schema field of the TreeViewConfiguration is populated.

Return type: TreeViewConfiguration

Error Handling

Will throw a usage error if the encoded schema is not in the expected format.

See Also

exportCompatibilitySchemaSnapshot(config) which creates these snapshots.

independentInitializedView

Create an initialized TreeView that is not tied to any ITree instance.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function independentInitializedView<const TSchema extends ImplicitFieldSchema>(config: TreeViewConfiguration<TSchema>, options: ForestOptions & ICodecOptions, content: ViewContent): TreeViewAlpha<TSchema>;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Remarks

Such a view can never experience collaboration or be persisted to to a Fluid Container.

This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.

Parameters

ParameterTypeDescription
configTreeViewConfiguration<TSchema>
optionsForestOptions & ICodecOptions
contentViewContent

Returns

Return type: TreeViewAlpha<TSchema>

independentView

Create an uninitialized TreeView that is not tied to any ITree instance.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function independentView<const TSchema extends ImplicitFieldSchema>(config: TreeViewConfiguration<TSchema>, options: ForestOptions & {
idCompressor?: IIdCompressor | undefined;
}): TreeViewAlpha<TSchema>;
Type Parameters
ParameterConstraintDescription
TSchemaImplicitFieldSchema

Remarks

Such a view can never experience collaboration or be persisted to to a Fluid Container.

This can be useful for testing, as well as use-cases like working on local files instead of documents stored in some Fluid service.

Parameters

ParameterTypeDescription
configTreeViewConfiguration<TSchema>
optionsForestOptions & { idCompressor?: IIdCompressor | undefined; }

Returns

Return type: TreeViewAlpha<TSchema>

isFluidHandle

Check if a value is an @fluidframework/core-interfaces#IFluidHandle.

Signature

export declare function isFluidHandle(value: unknown): value is IFluidHandle;

Remarks

Objects which have a field named IFluidHandle can in some cases produce a false positive.

Parameters

ParameterTypeDescription
valueunknown

Returns

Return type: value is IFluidHandle

normalizeAllowedTypes

Normalizes an ImplicitAllowedTypes to an AllowedTypesFull.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function normalizeAllowedTypes(types: ImplicitAllowedTypes): AllowedTypesFull;

Parameters

ParameterTypeDescription
typesImplicitAllowedTypes

Returns

Return type: AllowedTypesFull

onAssertionFailure

Add a callback which can be used to report an assertion before it is thrown.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function onAssertionFailure(handler: (error: Error) => void): () => void;

Remarks

The callback runs just before the exception is thrown, which makes it a better place to report telemetry for Fluid Framework bugs than a catch block or an event like window.onerror. Using this API to report telemetry is preferred over those approaches since it eliminates the risk of the exception being swallowed or obfuscated by an intermediate stack frame's catch block or missed due to not having the right catch block or event handler.

This does not replace the need for error handling elsewhere since errors (even bugs in Fluid) can cause other kinds of exceptions which this cannot run the callback for.

Example

import { onAssertionFailure } from "fluid-framework/alpha";

let firstAssertion: Error | undefined;

onAssertionFailure((error: Error) => {
const priorErrorNote =
firstAssertion === undefined
? "Please report this bug."
: `Might be caused due to prior error ${JSON.stringify(firstAssertion.message)} which should be investigated first.`;
const message = `Encountered Bug in Fluid Framework: ${error.message}\n${priorErrorNote}\n${error.stack}`;
console.error(message);

debugger;
firstAssertion ??= error;
});

Parameters

ParameterTypeDescription
handler(error: Error) => voidCalled when an assertion occurs before the exception is thrown.

Returns

a function to remove the handler.

Return type: () => void

persistedToSimpleSchema

A way to parse schema in the persisted format from extractPersistedSchema(schema, minVersionForCollab, includeStaged).

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function persistedToSimpleSchema(persisted: JsonCompatible, options: ICodecOptions): SimpleTreeSchema;

Remarks

This behaves identically to exportSimpleSchema(), except that it gets the schema from the caller instead of from an existing tree.

This can be useful for inspecting the contents of persisted schema, such as those generated by extractPersistedSchema(schema, minVersionForCollab, includeStaged) for use in testing. Since that data format is otherwise unspecified, this provides a way to inspect its contents with documented semantics.

Parameters

ParameterTypeDescription
persistedJsonCompatible
optionsICodecOptions

Returns

Return type: SimpleTreeSchema

replaceConciseTreeHandles

Clones tree, replacing any handles.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function replaceConciseTreeHandles<T>(tree: ConciseTree, replacer: HandleConverter<T>): ConciseTree<T>;
Type Parameters
ParameterDescription
T

Remarks

A strongly typed version of replaceHandles(tree, replacer).

Parameters

ParameterTypeDescription
treeConciseTree
replacerHandleConverter<T>

Returns

Return type: ConciseTree<T>

replaceHandles

Clones tree, replacing any handles.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function replaceHandles<T>(tree: unknown, replacer: HandleConverter<T>): unknown;
Type Parameters
ParameterDescription
T

Remarks

This can be useful converting data containing handles to JSON compatible formats, or just asserting that data does not contain handles.

Reversing this replacement depends on how the replacer encodes handles, and can often be impossible if the replacer does not have all the necessary context to restore the handles (e.g. if the handles are something insufficiently descriptive, if data referenced by the handle got garbage collected, if the encoded form of the handle can't be differentiated from other data, or the replacer doesn't have access to the correct Fluid container to to restore them from).

Code attempting to reverse this replacement may want to use cloneWithReplacements(root, rootKey, replacer).

Parameters

ParameterTypeDescription
treeunknown
replacerHandleConverter<T>

Returns

Return type: unknown

replaceVerboseTreeHandles

Clones tree, replacing any handles.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function replaceVerboseTreeHandles<T>(tree: VerboseTree, replacer: HandleConverter<T>): VerboseTree<T>;
Type Parameters
ParameterDescription
T

Remarks

A strongly types version of replaceHandles(tree, replacer).

Parameters

ParameterTypeDescription
treeVerboseTree
replacerHandleConverter<T>

Returns

Return type: VerboseTree<T>

singletonSchema

Create a schema for a node with no state.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

export declare function singletonSchema<TScope extends string, TName extends string | number>(factory: SchemaFactory<TScope, TName>, name: TName): TreeNodeSchemaClass<ScopedSchemaName<TScope, TName>, NodeKind.Object, TreeNode & {
readonly value: TName;
}, Record<string, never>, true, Record<string, never>, undefined>;
Type Parameters
ParameterConstraintDescription
TScopestring
TNamestring | number

Remarks

This is commonly used in unions when the only information needed is which kind of node the value is. Enums are a common example of this pattern.

Parameters

ParameterTypeDescription
factorySchemaFactory<TScope, TName>
nameTName

Returns

Return type: TreeNodeSchemaClass<ScopedSchemaName<TScope, TName>, NodeKind.Object, TreeNode & { readonly value: TName; }, Record<string, never>, true, Record<string, never>, undefined>

See Also

adaptEnum(factory, members)

trackDirtyNodes

Registers a visitor on the view's forest that tracks which nodes are dirty.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

export declare function trackDirtyNodes(view: TreeViewAlpha<ImplicitFieldSchema>, dirty: DirtyTreeMap): () => void;

Example

const dirty = new Map<TreeNode, DirtyTreeStatus>();
const stopTracking = trackDirtyNodes(view, dirty);
// ... make changes to the view ...
console.log(`The root of the tree is ${dirty.get(view.root) ?? "unchanged"}`);
stopTracking();

Parameters

ParameterTypeDescription
viewTreeViewAlpha<ImplicitFieldSchema>The view to track dirty nodes on
dirtyDirtyTreeMapA map that will be updated over time to reflect the status of nodes as they change. Nodes that have not changed will not be inserted/updated in the map.

Returns

a cleanup function that should be called when the tracking is no longer needed.

Return type: () => void

Variable Details

ArrayNodeSchema

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

ArrayNodeSchema: {
readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is ArrayNodeSchema;
}

Type: { readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is ArrayNodeSchema; }

contentSchemaSymbol

The intended type of insertable content that is to become a TreeNode.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

contentSchemaSymbol: unique symbol

Type: unique symbol

Remarks

Use the type-safe tagContentSchema(schema, content) function to tag insertable content with this symbol.

If a property with this symbol key is present on an object that is inserted into the tree, the tree will use the schema identifier specified by the value of this property when creating the node. This is particularly useful for specifying the intended schema of untyped content when it would otherwise be ambiguous.

Example

const sf = new SchemaFactory("example");
class Dog extends sf.object("Dog", { name: sf.string() }) {}
class Cat extends sf.object("Cat", { name: sf.string() }) {}
class Root extends sf.object("Root", { pet: [Dog, Cat] }) {}
// ...
view.root.pet = { name: "Max" }; // Error: ambiguous schema - is it a Dog or a Cat?
view.root.pet = { name: "Max", [contentSchemaSymbol]: "example.Dog" }; // No error - it's a Dog.

FluidClientVersion

Versions of Fluid Framework client packages.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

FluidClientVersion: {
readonly v2_0: "2.0.0";
readonly v2_43: "2.43.0";
readonly v2_52: "2.52.0";
readonly v2_73: "2.73.0";
}

Type: { readonly v2_0: "2.0.0"; readonly v2_43: "2.43.0"; readonly v2_52: "2.52.0"; readonly v2_73: "2.73.0"; }

Remarks

Used to express compatibility requirements by indicating the oldest version with which compatibility must be maintained.

When no compatibility-impacting change is made in a given version, the value associated with its enum entry may point to the older version which it's fully compatible with. Note that this can change if a future version of the framework introduces an option to use something which is only supported at a particular version. In which case, the values of the enum may shift, but the semantics of keys in this enum will not change.

Do not depend on the value of this enums's entries: only depend on the keys (enum members) themselves.

Some release may also be omitted if there is currently no need to express that specific version. If the need arises, they might be added in the future.

ForestTypeExpensiveDebug

Slow implementation of forest intended only for debugging.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

ForestTypeExpensiveDebug: ForestType

Type: ForestType

Remarks

Includes validation with scales poorly. May be asymptotically slower than ForestTypeReference, and may perform very badly with larger data sizes.

ForestTypeOptimized

Optimized implementation of forest.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

ForestTypeOptimized: ForestType

Type: ForestType

Remarks

A complex optimized forest implementation, which has minimal validation and debuggability to optimize for performance. Uses an internal representation optimized for size designed to scale to larger datasets with reduced overhead.

ForestTypeReference

Reference implementation of forest.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

ForestTypeReference: ForestType

Type: ForestType

Remarks

A simple implementation with minimal complexity and moderate debuggability, validation and performance.

FormatValidatorBasic

A FormatValidator implementation which uses TypeBox's JSON schema validator.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

FormatValidatorBasic: import("../codec/codec.js").FormatValidator

Type: import("../codec/codec.js").FormatValidator

FormatValidatorNoOp

A FormatValidator which does no validation.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

FormatValidatorNoOp: FormatValidator

Type: FormatValidator

IFluidHandle

Signature

IFluidHandle = "IFluidHandle"

IFluidLoadable

Signature

IFluidLoadable: keyof IProvideFluidLoadable

Type: keyof IProvideFluidLoadable

IntervalStickiness

Determines how an interval should expand when segments are inserted adjacent to the range it spans

Note that interval stickiness is currently an experimental feature and must be explicitly enabled with the intervalStickinessEnabled flag \

This API is provided for existing users, but is not recommended for new users.

To use, import via fluid-framework/legacy.

For more information about our API support guarantees, see here.

Signature

IntervalStickiness: {
readonly NONE: 0;
readonly START: 1;
readonly END: 2;
readonly FULL: 3;
}

Type: { readonly NONE: 0; readonly START: 1; readonly END: 2; readonly FULL: 3; }

MapNodeSchema

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

MapNodeSchema: {
readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is MapNodeSchema;
}

Type: { readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is MapNodeSchema; }

ObjectNodeSchema

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

ObjectNodeSchema: {
readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is ObjectNodeSchema<string, RestrictiveStringRecord<ImplicitFieldSchema>, boolean, unknown>;
}

Type: { readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is ObjectNodeSchema<string, RestrictiveStringRecord<ImplicitFieldSchema>, boolean, unknown>; }

RecordNodeSchema

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

RecordNodeSchema: {
readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is RecordNodeSchema<string, ImplicitAllowedTypes, true, unknown>;
}

Type: { readonly [Symbol.hasInstance]: (value: TreeNodeSchema) => value is RecordNodeSchema<string, ImplicitAllowedTypes, true, unknown>; }

rollback

A special object that signifies when a SharedTree transaction should "roll back".

Signature

rollback: unique symbol

Type: unique symbol

SchemaFactory_base

Base class for SchemaFactory, exposes SchemaStatics as both static properties and member properties.

This API is reserved for internal system use and should not be imported directly. It may change at any time without notice.

For more information about our API support guarantees, see here.

Signature

SchemaFactory_base: SchemaStatics & (new () => SchemaStatics)

Type: SchemaStatics & (new () => SchemaStatics)

Remarks

Do not use this directly, use SchemaFactory instead. \

SharedDirectory

Entrypoint for ISharedDirectory creation. \

This API is provided for existing users, but is not recommended for new users.

To use, import via fluid-framework/legacy.

For more information about our API support guarantees, see here.

Signature

SharedDirectory: import("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedDirectory> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedDirectory>

Type: import("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedDirectory> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedDirectory>

SharedMap

Entrypoint for ISharedMap creation. \

This API is provided for existing users, but is not recommended for new users.

To use, import via fluid-framework/legacy.

For more information about our API support guarantees, see here.

Signature

SharedMap: import("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedMap> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedMap>

Type: import("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedMap> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedMap>

SharedString

Entrypoint for ISharedString creation. \

This API is provided for existing users, but is not recommended for new users.

To use, import via fluid-framework/legacy.

For more information about our API support guarantees, see here.

Signature

SharedString: import("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedString> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedString>

Type: import("@fluidframework/shared-object-base/internal").ISharedObjectKind<ISharedString> & import("@fluidframework/shared-object-base/internal").SharedObjectKind<ISharedString>

SharedTree

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

Signature

SharedTree: SharedObjectKind<ITree>

Type: SharedObjectKind<ITree>

Tree

The Tree singleton which holds various functions for interacting with TreeNodes.

Signature

Tree: Tree

Type: Tree

TreeAlpha

Extensions to Tree and TreeBeta which are not yet stable.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

TreeAlpha: TreeAlpha

Type: TreeAlpha

See Also

TreeAlpha.

TreeArrayNode

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

Signature

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

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

TreeBeta

Extensions to Tree which are not yet stable.

This API is provided as a beta preview and may change without notice.

To use, import via fluid-framework/beta.

For more information about our API support guarantees, see here.

Signature

TreeBeta: TreeBeta

Type: TreeBeta

See Also

TreeBeta.

typeSchemaSymbol

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

This API is reserved for internal system use and should not be imported directly. It may change at any time without notice.

For more information about our API support guarantees, see here.

Signature

typeSchemaSymbol: unique symbol

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 specific nodes are expected. Instead construct a real node of the desired type using its constructor.

This symbol should not be used directly for type narrowing. Instead use WithType. \

UnsafeUnknownSchema

A special type which can be provided to some APIs as the schema type parameter when schema cannot easily be provided at compile time and an unsafe (instead of disabled) editing API is desired.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Signature

UnsafeUnknownSchema: unique symbol

Type: unique symbol

Remarks

When used, this means the TypeScript typing should err on the side of completeness (allow all inputs that could be valid). This introduces the risk that out-of-schema data could be allowed at compile time, and only error at runtime.