"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 isNamedIndexType = require("../../validators/operations/schema/is-named-index-type")(operations);

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

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