Module: crdt-recipes

A module for CRDT recipes: For each CRDT object metadata is needed and this module takes care of how to generate the recipes for them. As well as supplying some checking functions.

Source:

Methods

(static) clearCrdtRuntimeSets()

The runtime collections need to be cleared when the instance is closed

Source:

(static) getCrdtMetaRecipeName(crdtObjectName) → {OneCrdtMetaObjectTypeNames}

Parameters:
Name Type Description
crdtObjectName T

Get the metadata recipe name based on the data crdt recipe name.

Source:
Returns:

Type: OneCrdtMetaObjectTypeNames

(static) isCrdtObject(arg) → {boolean}

Parameters:
Name Type Description
arg OneObjectTypes

Check if the passed versioned object is a crdt type.

Source:
Returns:

Type: boolean

(static) isCrdtObjectRecipe(arg) → {boolean}

Parameters:
Name Type Description
arg Recipe

Check if the passed versioned object is a crdt type.

Source:
Returns:

Type: boolean

(static) isCrdtTypeName(arg) → {boolean}

Parameters:
Name Type Description
arg OneObjectTypeNames

Checks if the passed object type name is a crdt object type name.

Source:
Returns:

Type: boolean

(static) isCrdtMetaTypeName(arg) → {boolean}

Parameters:
Name Type Description
arg OneObjectTypeNames

Check if the object type name is a crdt meta-object type name

Source:
Returns:

Type: boolean

(static) isCrdtMetaObjectForCrdtObjectTypeName(arg, baseType) → {boolean}

Parameters:
Name Type Description
arg OneObjectTypes
baseType T

Check if the passed object is a meta-object for the passed crdt type.

Source:
Returns:

Type: boolean

(static) isCrdtMetaObjectTypeNameForCrdtObjectTypeName(arg, baseType) → {boolean}

Parameters:
Name Type Description
arg OneObjectTypeNames
baseType OneCrdtObjectTypeNames

Check if the passed meta type is the base type for a crdt type.

Source:
Returns:

Type: boolean

(static) registerCrdtRecipeName(crdtTypeName) → {undefined}

Parameters:
Name Type Description
crdtTypeName OneCrdtObjectTypeNames

When loading already installed recipes from the instance on instance startup the names of CRDT recipes need to be registered in two module-internal sets for teh CRDT and the CRDT-meta recipe type name.

Source:
Returns:

Type: undefined

(static) generateCrdtMetaRecipe(recipe) → {Recipe}

Parameters:
Name Type Description
recipe RecipeT

Function for generating the meta recipe for a crdt based recipe.

This also registers the passed recipe as CRDT recipe, so that the is* functions in this module return true.

Silently returns the existing meta recipe if it was already added.

Source:
Returns:

Type: Recipe

(static) addRecipesToRuntimeAndStorage(recipes) → {Promise.<Array.<VersionedObjectResult.<Recipe>>>}

Parameters:
Name Type Description
recipes Readonly.<Array.<Recipe>>

This function is called by instance-creator and updater and adds recipes to runtime and storage.

Since CRDT object recipes we implicitly want to generate and add CRDT meta recipes as well as the base recipe. This function takes care supplied recipes are in the right order before adding them to the runtime and storage.

If recipes already exist at runtime they aren't added again.

Source:
Returns:

Type: Promise.<Array.<VersionedObjectResult.<Recipe>>>

(static) adjustCrdtConfig(rule, crdtConfig) → {undefined|Map.<string, CRDTImplementationNames>}

Parameters:
Name Type Description
rule RecipeRule
crdtConfig Recipe.crdtConfig

When a crdt has reference to object children which are not CRDTs themselves. The crdtConfig still allows to configure the algorithm to use on these children.

This is done via '.' notation when the path to the child is specified. e.g.

crdtConfig: new Map([
['unversionedLvl1.unversionedLvl2.listStrOne', CRDT_IMPLEMENTATION_NAMES.LWWSet]
]),

in the example a parent object hast a property called 'unversionedLvl1' which references an unversionedLevel1 object, 'unversionedLvl1' in turn has a property 'unversionedLvl2' property which references an unversionedL2 object. The 'unversionedLvl2' then has a property 'listStrOne' where we want to use the LWWSet as merge-algorithm. In the generateMetaRecipeForRule we need to strip one level from the crdtConfig when the current rule.itemprop is the top-most of the "pathToChildren" ('unversionedLvl1.unversionedLvl2.listStrOne') except if we only have one level left.

Source:
Returns:

Type: undefined | Map.<string, CRDTImplementationNames>

(static) generateMetaRecipeForRule(rule, path, crdtConfig) → {Array.<RecipeRule>}

Parameters:
Name Type Description
rule RecipeRule
path string
crdtConfig Recipe.crdtConfig

Generate the CRDT meta recipe rules for the given rule.

Source:
Returns:

Type: Array.<RecipeRule>

(inner) generateMetaRecipeRuleFromListRule(rule, currPath, crdtConfig) → {Array.<RecipeRule>}

Parameters:
Name Type Description
rule RecipeRule

The rule to be processed for the meta recipe generation.

currPath string
crdtConfig Recipe.crdtConfig

Generate meta recipe rule for a list rule using the CRDT-Set algorithm.

Source:
Returns:

Type: Array.<RecipeRule>

(inner) generateMetaRecipeRuleFromRuleWithReferenceToObj(rule, currPath, crdtConfig) → {Array.<RecipeRule>}

Parameters:
Name Type Description
rule RecipeRule

The rule to be processed for the meta recipe generation.

currPath string
crdtConfig Recipe.crdtConfig

Generate the meta recipe rule for a rule with a 'referenceToObj' property. The reference to an unversioned child object is handled recursively if it has only one concrete type ('*' is not handled recursively).

Source:
Returns:

Type: Array.<RecipeRule>