"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const tables_1 = __importDefault(require("../../controllers/public/tables"));
const Endpoint_1 = __importDefault(require("./utils/Endpoint"));
const validators_1 = require("../utils/validators");
const read = [], write = [];
/**
 * @openapi
 * /tables:
 *   post:
 *     summary: Create a table
 *     description: Create a table, this could be internal or external.
 *     tags:
 *       - tables
 *     parameters:
 *       - $ref: '#/components/parameters/appId'
 *     requestBody:
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/table'
 *           examples:
 *             table:
 *               $ref: '#/components/examples/table'
 *     responses:
 *       200:
 *         description: Returns the created table, including the ID which has been generated for it. This can be
 *           internal or external data sources.
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/tableOutput'
 *             examples:
 *               table:
 *                 $ref: '#/components/examples/table'
 */
write.push(new Endpoint_1.default("post", "/tables", tables_1.default.create).addMiddleware((0, validators_1.tableValidator)()));
/**
 * @openapi
 * /tables/{tableId}:
 *   put:
 *     summary: Update a table
 *     description: Update a table, this could be internal or external.
 *     tags:
 *       - tables
 *     parameters:
 *       - $ref: '#/components/parameters/tableId'
 *       - $ref: '#/components/parameters/appId'
 *     requestBody:
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/table'
 *           examples:
 *             table:
 *               $ref: '#/components/examples/table'
 *     responses:
 *       200:
 *         description: Returns the updated table.
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/tableOutput'
 *             examples:
 *               table:
 *                 $ref: '#/components/examples/table'
 */
write.push(new Endpoint_1.default("put", "/tables/:tableId", tables_1.default.update).addMiddleware((0, validators_1.tableValidator)()));
/**
 * @openapi
 * /tables/{tableId}:
 *   delete:
 *     summary: Delete a table
 *     description: Delete a table, this could be internal or external.
 *     tags:
 *       - tables
 *     parameters:
 *       - $ref: '#/components/parameters/tableId'
 *       - $ref: '#/components/parameters/appId'
 *     responses:
 *       200:
 *         description: Returns the deleted table.
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/tableOutput'
 *             examples:
 *               table:
 *                 $ref: '#/components/examples/table'
 */
write.push(new Endpoint_1.default("delete", "/tables/:tableId", tables_1.default.destroy));
/**
 * @openapi
 * /tables/{tableId}:
 *   get:
 *     summary: Retrieve a table
 *     description: Lookup a table, this could be internal or external.
 *     tags:
 *       - tables
 *     parameters:
 *       - $ref: '#/components/parameters/tableId'
 *       - $ref: '#/components/parameters/appId'
 *     responses:
 *       200:
 *         description: Returns the retrieved table.
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/tableOutput'
 *             examples:
 *               table:
 *                 $ref: '#/components/examples/table'
 */
read.push(new Endpoint_1.default("get", "/tables/:tableId", tables_1.default.read));
/**
 * @openapi
 * /tables/search:
 *   post:
 *     summary: Search for tables
 *     description: Based on table properties (currently only name) search for tables. This could be
 *       an internal or an external table.
 *     tags:
 *       - tables
 *     parameters:
 *       - $ref: '#/components/parameters/appId'
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             $ref: '#/components/schemas/nameSearch'
 *     responses:
 *       200:
 *         description: Returns the found tables, based on the search parameters.
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/tableSearch'
 *             examples:
 *               tables:
 *                 $ref: '#/components/examples/tables'
 */
read.push(new Endpoint_1.default("post", "/tables/search", tables_1.default.search).addMiddleware((0, validators_1.nameValidator)()));
exports.default = { read, write };
