lib/props-tree-builder.js
function buildSuperPropsTreeBranches(
	recordTypes, recordTypeDesc, superPropNames) {

	// create the branching tree top node
	const topNode = PropertyTreeNode.createTopNode(
		recordTypes, {
			isScalar() { return true; },
			isCalculated() { return false; },
			refTarget: recordTypeDesc.superRecordTypeName
		},
		new ValueExpressionContext('', [
			recordTypes.getRecordTypeDesc(recordTypeDesc.superRecordTypeName)
		]),
		'select');

	// add super-properties to the tree
	const valuePropsTrees = new Map();
	for (let superPropName of superPropNames)
		addProperty(
			topNode, null, superPropName, 'select', null, valuePropsTrees);

	// de-branch the tree and merge in the value trees
	const valuePropsTreesArray = Array.from(valuePropsTrees.entries());
	return topNode.debranch().map(
		branch => valuePropsTreesArray.reduce((res, pair) => {
			const valuePropPath = pair[0];
			const valuePropsTree = pair[1];
			if (!res.includesProp(valuePropPath))
				return res;
			return res.combine(valuePropsTree);
		}, branch)
	);
}
function buildSuperPropsTreeBranches(
	recordTypes, recordTypeDesc, superPropNames) {

	// create the branching tree top node
	const topNode = PropertyTreeNode.createTopNode(
		recordTypes, {
			isScalar() { return true; },
			isCalculated() { return false; },
			refTarget: recordTypeDesc.superRecordTypeName
		},
		new ValueExpressionContext('', [
			recordTypes.getRecordTypeDesc(recordTypeDesc.superRecordTypeName)
		]),
		'select');

	// add super-properties to the tree
	const valuePropsTrees = new Map();
	for (let superPropName of superPropNames)
		addProperty(
			topNode, null, superPropName, 'select', null, valuePropsTrees);

	// de-branch the tree and merge in the value trees
	const valuePropsTreesArray = Array.from(valuePropsTrees.entries());
	return topNode.debranch().map(
		branch => valuePropsTreesArray.reduce((res, pair) => {
			const valuePropPath = pair[0];
			const valuePropsTree = pair[1];
			if (!res.includesProp(valuePropPath))
				return res;
			return res.combine(valuePropsTree);
		}, branch)
	);
}
function buildSuperPropsTreeBranches ( recordTypes , recordTypeDesc , superPropNames ) { // create the branching tree top node const topNode = PropertyTreeNode . createTopNode ( recordTypes , { isScalar ( ) { return true ; } , isCalculated ( ) { return false ; } , refTarget : recordTypeDesc . superRecordTypeName } , new ValueExpressionContext ( '' , [ recordTypes . getRecordTypeDesc ( recordTypeDesc . superRecordTypeName ) ] ) , 'select' ) ; // add super-properties to the tree const valuePropsTrees = new Map ( ) ; for ( let superPropName of superPropNames ) addProperty ( topNode , null , superPropName , 'select' , null , valuePropsTrees ) ; // de-branch the tree and merge in the value trees const valuePropsTreesArray = Array . from ( valuePropsTrees . entries ( ) ) ; return topNode . debranch ( ) . map ( branch => valuePropsTreesArray . reduce ( ( res , pair ) => { const valuePropPath = pair [ 0 ] ; const valuePropsTree = pair [ 1 ] ; if ( ! res . includesProp ( valuePropPath ) ) return res ; return res . combine ( valuePropsTree ) ; } , branch ) ) ; }
Build properties tree for a super-properties query and debranch it.

@protected
@param {module:x2node-records~RecordTypesLibrary} recordTypes Record types
library.
@param {module:x2node-records~RecordTypeDescriptor} recordTypeDesc Record type
descriptor.
@param {Iterable.<string>} superPropName Selected super-property names.
@returns {Array.<module:x2node-dbos~PropertyTreeNode>} The resulting
properties tree branches.
@throws {module:x2node-common.X2SyntaxError} If the provided specifications or
participating property definitions are invalid.
Build properties tree for a super - properties query and debranch it .