"use strict";

const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");

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

module.exports = function (operations) {
	const isValueExpression = require("../../validators/operations/is-value-expression")(operations);

	return function restoreAs(_expression) {
		let [ expression ] = validateArguments(arguments, {
			expression: [ required, isValueExpression ]
		});

		return node({
			type: "restoreAs",
			expression: expression
		});
	};
};
