"use strict";

const either = require("@validatem/either");

const tagAsType = require("../tag-as-type");

module.exports = function (operations) {
	const isObjectType = require("./is-object-type")(operations);
	const isExpressionList = require("./is-expression-list")(operations);
	const isConditionList = require("./is-condition-list")(operations);
	const isWhereObjectList = require("./is-where-object-list")(operations);
	
	return either([
		// Boolean AND/OR
		[ isExpressionList, tagAsType("expressions") ],
		// Combine (JOIN)
		// FIXME
		// ...
		// Multiple-choice conditions
		[ isWhereObjectList, tagAsType("expressions") ],
		[ either([
			[ isObjectType("sqlExpression") ],
			[ isObjectType("placeholder") ], // for dynamically specified array of values
			[ isConditionList ],
		]), tagAsType("conditions") ],
	]);
};
