Skip to main content
Version: v1

Constraint Interface

A set of constraints on the validity of an Edit. A Constraint is used to detect when an Edit, due to other concurrent edits, may have unintended effects or merge in non-semantic ways. It is processed in order like any other Change in an Edit. It can cause an edit to fail if the various constraints are not met at the time of evaluation (ex: the parentNode has changed due to concurrent editing). Does not modify the document.

Signature

export interface Constraint

Properties

Property Modifiers Type Description
contentHash optional UuidString

Require that the contents of all of the nodes in toConstrain hash to this value. Hash is an order dependant deep hash, which includes all subtree content recursively. TODO: implement and specify exact hash function.

This is an efficient (O(1) space) way to constrain a sequence of nodes have exact values (transitively).

effect ConstraintEffect What to do if a constraint is not met.
identityHash optional UuidString

Require that the identities of all the nodes in toConstrain hash to this value. Hash is order dependent. TODO: implement and specify exact hash function.

This is an efficient (O(1) space) way to constrain a sequence of nodes to have specific identities.

label optional TraitLabel Require that the trait under which toConstrain is located has this label.
length optional number Require that the number of nodes in toConstrain is this value.
parentNode optional NodeId Require that parent under which toConstrain is located has this identifier.
toConstrain StableRange

Selects a sequence of nodes which will be checked against the constraints specified by the optional fields. If toConstrain is invalid, it will be treated like a constraint being unmet. Depending on effect this may or may not make the Edit invalid.

When a constraint is not met, the effects is specified by effect.

type typeof ChangeType.Constraint Marker for which kind of Change this is.

Property Details

contentHash

Require that the contents of all of the nodes in toConstrain hash to this value. Hash is an order dependant deep hash, which includes all subtree content recursively. TODO: implement and specify exact hash function.

This is an efficient (O(1) space) way to constrain a sequence of nodes have exact values (transitively).

Signature

readonly contentHash?: UuidString;

Type: UuidString

effect

What to do if a constraint is not met.

Signature

readonly effect: ConstraintEffect;

Type: ConstraintEffect

identityHash

Require that the identities of all the nodes in toConstrain hash to this value. Hash is order dependent. TODO: implement and specify exact hash function.

This is an efficient (O(1) space) way to constrain a sequence of nodes to have specific identities.

Signature

readonly identityHash?: UuidString;

Type: UuidString

label

Require that the trait under which toConstrain is located has this label.

Signature

readonly label?: TraitLabel;

Type: TraitLabel

length

Require that the number of nodes in toConstrain is this value.

Signature

readonly length?: number;

Type: number

parentNode

Require that parent under which toConstrain is located has this identifier.

Signature

readonly parentNode?: NodeId;

Type: NodeId

toConstrain

Selects a sequence of nodes which will be checked against the constraints specified by the optional fields. If toConstrain is invalid, it will be treated like a constraint being unmet. Depending on effect this may or may not make the Edit invalid.

When a constraint is not met, the effects is specified by effect.

Signature

readonly toConstrain: StableRange;

Type: StableRange

type

Marker for which kind of Change this is.

Signature

readonly type: typeof ChangeType.Constraint;

Type: typeof ChangeType.Constraint