"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const queries_1 = __importDefault(require("../../controllers/public/queries"));
const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
const validators_1 = require("../utils/validators");
const read = [], write = [];
/**
 * @openapi
 * /queries/{queryId}:
 *   post:
 *     summary: Execute a query
 *     description: Queries which have been created within a Budibase app can be executed using this,
 *     tags:
 *       - queries
 *     parameters:
 *       - $ref: '#/components/parameters/queryId'
 *       - $ref: '#/components/parameters/appId'
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/executeQuery'
 *     responses:
 *       200:
 *         description: Returns the result of the query execution.
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/executeQueryOutput'
 *             examples:
 *               REST:
 *                 $ref: '#/components/examples/restResponse'
 *               SQL:
 *                 $ref: '#/components/examples/sqlResponse'
 *
 */
write.push(new Endpoint_1.default("post", "/queries/:queryId", queries_1.default.execute));
/**
 * @openapi
 * /queries/search:
 *   post:
 *     summary: Search for queries
 *     description: Based on query properties (currently only name) search for queries.
 *     tags:
 *       - queries
 *     parameters:
 *       - $ref: '#/components/parameters/appId'
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/nameSearch'
 *     responses:
 *       200:
 *         description: Returns the queries found based on the search parameters.
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/querySearch'
 *             examples:
 *               queries:
 *                 $ref: '#/components/examples/queries'
 */
read.push(new Endpoint_1.default("post", "/queries/search", queries_1.default.search).addMiddleware((0, validators_1.nameValidator)()));
exports.default = { read, write };
