Skip to main content

FieldSchema Class

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.

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 declare class FieldSchema<out Kind extends FieldKind = FieldKind, out Types extends ImplicitAllowedTypes = ImplicitAllowedTypes, out TCustomMetadata = unknown>

Type Parameters​

ParameterConstraintDefaultDescription
KindFieldKindFieldKind
TypesImplicitAllowedTypesImplicitAllowedTypes
TCustomMetadataunknownCustom metadata properties to associate with the field. See custom.

Remarks​

All implementations of this are actually FieldSchemaAlpha which exposes some additional alpha APIs.

Constructors​

ConstructorDescription
(constructor)(kind, allowedTypes, props)This class is @sealed: protected members like this constructor are for internal use only. Use SchemaFactory to create the FieldSchema instances.

Properties​

PropertyModifiersTypeDescription
_typeCheckMakeNominalThis class is used with instanceof, and therefore should have nominal typing. This field enforces that.
allowedTypesreadonlyTypesWhat types of tree nodes are allowed in this field.
allowedTypeSetreadonlyReadonlySet<TreeNodeSchema>What types of tree nodes are allowed in this field.
kindreadonlyKindThe kind of this field. Determines the multiplicity, viewing and editing APIs as well as the merge resolution policy.
metadatareadonlyFieldSchemaMetadata<TCustomMetadata>Optional metadata to associate with the field.
propsoptional, readonlyFieldProps<TCustomMetadata> | undefinedOptional properties associated with the field.
requiresValuereadonlybooleanTrue if and only if, when constructing a node with this field, a value must be provided for it.

Constructor Details​

(constructor)​

This class is @sealed: protected members like this constructor are for internal use only. Use SchemaFactory to create the FieldSchema instances.

Signature​

protected constructor(
kind: Kind,
allowedTypes: Types,
props?: FieldProps<TCustomMetadata> | undefined);

Parameters​

ParameterModifiersTypeDescription
kindKind
allowedTypesTypes
propsoptionalFieldProps<TCustomMetadata> | undefined

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>;

Type: FieldSchemaMetadata<TCustomMetadata>

Remarks​

Note: this metadata is not persisted nor made part of the collaborative state; it is strictly client-local. Different clients in the same collaborative session may see different metadata for the same field.

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