"use strict";

const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");
const arrayOf = require("@validatem/array-of");

const node = require("../ast-node");

module.exports = function (operations) {
	const isPossiblyForeignColumn = require("../validators/operations/is-possibly-foreign-column")(operations);

	return function hierarchical(_columns) {
		let [ columns ] = validateArguments(arguments, {
			columns: [ required, arrayOf([ required, isPossiblyForeignColumn ]) ] // FIXME: Require minimum 2, probably
		});

		return node({
			type: "hierarchical",
			columns: columns
		});
	};
};
