FieldSchema Class

Packages > @fluidframework/tree > FieldSchema

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(t, props) .

Signature

/** @sealed */
export declare class FieldSchema<out Kind extends FieldKind = FieldKind, out Types extends ImplicitAllowedTypes = ImplicitAllowedTypes, out TCustomMetadata = unknown>

Type Parameters

Parameter Constraint Default Description
Kind FieldKind FieldKind
Types ImplicitAllowedTypes ImplicitAllowedTypes
TCustomMetadata unknown Custom metadata properties to associate with the field. See custom.

Properties

Property Modifiers Type Description
_typeCheck MakeNominal This class is used with instanceof, and therefore should have nominal typing. This field enforces that.
allowedTypes readonly Types What types of tree nodes are allowed in this field.
allowedTypeSet readonly ReadonlySet<TreeNodeSchema> What types of tree nodes are allowed in this field.
kind readonly Kind The kind of this field. Determines the multiplicity, viewing and editing APIs as well as the merge resolution policy.
metadata readonly FieldSchemaMetadata<TCustomMetadata> | undefined Optional metadata to associate with the field.
props optional, readonly FieldProps<TCustomMetadata> | undefined Optional properties associated with the field.
requiresValue readonly boolean True if and only if, when constructing a node with this field, a value must be provided for it.

Property Details

_typeCheck

This class is used with instanceof, and therefore should have nominal typing. This field enforces that.

Signature

protected _typeCheck: MakeNominal;

Type: MakeNominal

allowedTypes

What types of tree nodes are allowed in this field.

Signature

readonly allowedTypes: Types;

Type: Types

allowedTypeSet

What types of tree nodes are allowed in this field.

Signature

get allowedTypeSet(): ReadonlySet<TreeNodeSchema>;

Type: ReadonlySet<TreeNodeSchema >

Remarks

Counterpart to allowedTypes , with any lazy definitions evaluated.

kind

The kind of this field. Determines the multiplicity, viewing and editing APIs as well as the merge resolution policy.

Signature

readonly kind: Kind;

Type: Kind

metadata

Optional metadata to associate with the field.

Signature

get metadata(): FieldSchemaMetadata<TCustomMetadata> | undefined;

Type: FieldSchemaMetadata <TCustomMetadata> | undefined

Remarks

Note: this metadata is not persisted in the document.

props

Optional properties associated with the field.

Signature

readonly props?: FieldProps<TCustomMetadata> | undefined;

Type: FieldProps <TCustomMetadata> | undefined

requiresValue

True if and only if, when constructing a node with this field, a value must be provided for it.

Signature

readonly requiresValue: boolean;

Type: boolean