"use strict";

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

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

module.exports = function (operations) {
	const isCompositeIndexType = require("../../validators/operations/schema/is-composite-index-type")(operations);

	return function indexes(_indexes) {
		let [ indexes ] = validateArguments(arguments, {
			indexes: [ required, arrayOf(isCompositeIndexType) ]
		});

		return node({
			type: "schemaIndexes",
			indexes: indexes
		});
	};
};
