Class: LibraryConstructionContext

x2node-records~ LibraryConstructionContext

Context used during the building of a record types library by the factory. The context is used by the library extensions to perform work on completion of various descriptors.

new LibraryConstructionContext()

Note: The constructor is not accessible from the client code. Instances of the context are provided to the extensions by the factory.
Parameters:
Name Type Description
Extensions. Iterable.<module:x2node-records.Extension>

Methods


addHiddenProperty()

Add hidden property to the current context properties container. The property descriptor will be available via the container's getPropertyDesc() method but will be not listed in the container's allPropertyNames list.

This method can only be called from a handler added to the context via the onContainerComplete() method.


addRecordType(recordTypeName, recordTypeDef)

Add record type to the record types library.

This method can only be called from a handler added to the context via the onLibraryComplete() method.

Parameters:
Name Type Description
recordTypeName string | Symbol Record type name.
recordTypeDef Object Record type definition.
Throws:
If record type with the same name already exists of if called from a wrong place in the extension.
Type
module:x2node-common.X2UsageError

createPropertiesContainer(containerPropDesc, containerDef)

Create nested properties container.
Parameters:
Name Type Description
containerPropDesc module:x2node-records~PropertyDescriptor Descriptor of the container property in the parent container.
containerDef Object Container definition.
Returns:
The new container.
Type
module:x2node-records~PropertiesContainer

onContainerComplete(handler)

Perform work upon properties container (either nested object or record type descriptor) completion. The handlers are called right after all properties are added to the container. If called from the extension's extendPropertyDescriptor() or extendPropertiesContainer() function, the handler is called only when the currently being built container is complete. If called from the extension's extendRecordTypesLibrary() function, an error is thrown.
Parameters:
Name Type Description
handler function The handler function that receives the properties container as its only argument.

onLibraryComplete(handler)

Perform work upon record types library completion. The handlers are called right after all record types are added to the library but before the registered library validators are called.
Parameters:
Name Type Description
handler function The handler function that receives the record type library as its only argument.

onLibraryValidation(validator)

Register validator invoked after the library completion.
Parameters:
Name Type Description
validator function The validator function that receives the complete record types library as its only argument.