<?php

	use vlw\MySQL\Order;
	use Reflect\{Response, Path};
	use Reflect\Rules\{Ruleset, Rules, Type};

	use VLW\Database\Database;
	use VLW\Database\Tables\Work\ActionsTable;

	require_once Path::root("src/Database/Database.php");
	require_once Path::root("src/Database/Tables/Work/Actions.php");

	class GET_WorkActions extends Database {
		protected Ruleset $ruleset;

		public function __construct() {
			$this->ruleset = new Ruleset(strict: true);

			$this->ruleset->GET([
				(new Rules(ActionsTable::REF_WORK_ID->value))
					->type(Type::STRING)
					->min(1)
					->max(parent::SIZE_VARCHAR)
			]);

			$this->ruleset->validate_or_exit();

			parent::__construct();
		}

		public function main(): Response {
			return $this->list(ActionsTable::NAME, ActionsTable::values(), [
				ActionsTable::ORDER_IDX->value => Order::DESC
			]);
		}
	}