Skip to main content

TreeNodeSchemaCore Interface

Data common to all tree node schema.

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature

/** @sealed */
export interface TreeNodeSchemaCore<out Name extends string, out Kind extends NodeKind, out ImplicitlyConstructable extends boolean, out Info = unknown, out TInsertable = never, out TCustomMetadata = unknown> extends SimpleNodeSchemaBase<Kind, TCustomMetadata>

Extends: SimpleNodeSchemaBase<Kind, TCustomMetadata>

Type Parameters

ParameterConstraintDefaultDescription
Namestring
KindNodeKind
ImplicitlyConstructableboolean
Infounknown
TInsertablenever
TCustomMetadataunknown

Remarks

Implementation detail of TreeNodeSchema which should be accessed instead of referring to this type directly. \

Properties

PropertyAlertsModifiersTypeDescription
childTypesSystemreadonlyReadonlySet<TreeNodeSchema>

All possible schema that a direct child of a node with this schema could have.

Equivalently, this is also all schema directly referenced when defining this schema's allowed child types, which is also the same as the set of schema referenced directly by the Info type parameter and the info property. This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.

identifierreadonlyNameUnique (within a document's schema) identifier used to associate nodes with their schema.
implicitlyConstructablereadonlyImplicitlyConstructableWhen constructing insertable content, data that could be passed to the node's constructor can be used instead of an Unhydrated node iff implicitlyConstructable is true.
inforeadonlyInfoData used to define this schema.

Methods

MethodAlertsModifiersReturn TypeDescription
createFromInsertable(data)SystemsealedUnhydrated<TreeNode | TreeLeafValue>Constructs an instance of this node type.

Property Details

childTypes

All possible schema that a direct child of a node with this schema could have.

Equivalently, this is also all schema directly referenced when defining this schema's allowed child types, which is also the same as the set of schema referenced directly by the Info type parameter and the info property. This property is simply re-exposing that information in an easier to traverse format consistent across all node kinds.

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

readonly childTypes: ReadonlySet<TreeNodeSchema>;

Type: ReadonlySet<TreeNodeSchema>

Remarks

Some kinds of nodes may have additional restrictions on children: this set simply enumerates all directly referenced schema, and can be use to walk over all referenced schema types.

This set cannot be used before the schema in it have been defined: more specifically, when using lazy schema references (for example to make foreword references to schema which have not yet been defined), users must wait until after the schema are defined to access this set.

identifier

Unique (within a document's schema) identifier used to associate nodes with their schema.

Signature

readonly identifier: Name;

Type: Name

Remarks

This is used when encoding nodes, and when decoding nodes to re-associate them with the schema. Since this decoding may happen in a different version of the application (or even a different application altogether), this identifier should generally correspond to some specific semantics for the data (how to interpret the node with this identifier). Any time the semantics change such that data would be misinterpreted if the old semantics were applied (for example the units of a value are changed), it is best practice to pick a new identifier.

implicitlyConstructable

When constructing insertable content, data that could be passed to the node's constructor can be used instead of an Unhydrated node iff implicitlyConstructable is true.

Signature

readonly implicitlyConstructable: ImplicitlyConstructable;

Type: ImplicitlyConstructable

info

Data used to define this schema.

Signature

readonly info: Info;

Type: Info

Remarks

The format depends on the kind of node it is for. For example, the "object" node kind could store the field schema here.

Method Details

createFromInsertable

Constructs an instance of this node type.

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.

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature

/** @sealed */
createFromInsertable(data: TInsertable): Unhydrated<TreeNode | TreeLeafValue>;

Remarks

Due to TypeScript limitations, the return type of this method can not be very specific. For TreeNodeSchemaClass prefer using the constructor directly for better typing. For TreeNodeSchemaNonClass use create. \

Parameters

ParameterTypeDescription
dataTInsertable

Returns

Return type: Unhydrated<TreeNode | TreeLeafValue>