2022-02-25 04:13:14 +13:00
|
|
|
import controller from "../../controllers/public/tables"
|
|
|
|
import Endpoint from "./utils/Endpoint"
|
|
|
|
import { tableValidator, nameValidator } from "../utils/validators"
|
2022-02-18 07:58:09 +13:00
|
|
|
|
2022-02-23 07:40:09 +13:00
|
|
|
const read = [],
|
|
|
|
write = []
|
2022-02-19 06:44:08 +13:00
|
|
|
|
2022-02-19 04:47:15 +13:00
|
|
|
/**
|
|
|
|
* @openapi
|
2022-02-19 06:44:08 +13:00
|
|
|
* /tables:
|
|
|
|
* post:
|
2022-09-22 06:11:47 +12:00
|
|
|
* operationId: create
|
2022-03-02 03:37:35 +13:00
|
|
|
* summary: Create a table
|
|
|
|
* description: Create a table, this could be internal or external.
|
2022-02-19 04:47:15 +13:00
|
|
|
* tags:
|
|
|
|
* - tables
|
2022-02-19 07:06:58 +13:00
|
|
|
* parameters:
|
|
|
|
* - $ref: '#/components/parameters/appId'
|
|
|
|
* requestBody:
|
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
|
|
|
* $ref: '#/components/schemas/table'
|
|
|
|
* examples:
|
|
|
|
* table:
|
|
|
|
* $ref: '#/components/examples/table'
|
2022-02-19 04:47:15 +13:00
|
|
|
* responses:
|
|
|
|
* 200:
|
2022-02-19 06:44:08 +13:00
|
|
|
* description: Returns the created table, including the ID which has been generated for it. This can be
|
2022-09-14 23:11:20 +12:00
|
|
|
* internal or external datasources.
|
2022-02-19 04:47:15 +13:00
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
2022-02-23 03:10:01 +13:00
|
|
|
* $ref: '#/components/schemas/tableOutput'
|
2022-02-19 04:47:15 +13:00
|
|
|
* examples:
|
2022-02-19 06:44:08 +13:00
|
|
|
* table:
|
|
|
|
* $ref: '#/components/examples/table'
|
2022-02-19 04:47:15 +13:00
|
|
|
*/
|
2022-02-25 00:39:38 +13:00
|
|
|
write.push(
|
|
|
|
new Endpoint("post", "/tables", controller.create).addMiddleware(
|
|
|
|
tableValidator()
|
|
|
|
)
|
|
|
|
)
|
2022-02-19 04:47:15 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @openapi
|
2022-02-23 03:28:57 +13:00
|
|
|
* /tables/{tableId}:
|
2022-02-19 06:44:08 +13:00
|
|
|
* put:
|
2022-09-22 06:11:47 +12:00
|
|
|
* operationId: update
|
2022-03-02 03:37:35 +13:00
|
|
|
* summary: Update a table
|
|
|
|
* description: Update a table, this could be internal or external.
|
2022-02-19 04:47:15 +13:00
|
|
|
* tags:
|
|
|
|
* - tables
|
|
|
|
* parameters:
|
|
|
|
* - $ref: '#/components/parameters/tableId'
|
2022-02-19 06:44:08 +13:00
|
|
|
* - $ref: '#/components/parameters/appId'
|
2022-02-19 07:06:58 +13:00
|
|
|
* requestBody:
|
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
|
|
|
* $ref: '#/components/schemas/table'
|
|
|
|
* examples:
|
|
|
|
* table:
|
|
|
|
* $ref: '#/components/examples/table'
|
2022-02-19 04:47:15 +13:00
|
|
|
* responses:
|
|
|
|
* 200:
|
2022-02-19 06:44:08 +13:00
|
|
|
* description: Returns the updated table.
|
2022-02-19 04:47:15 +13:00
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
2022-02-23 03:10:01 +13:00
|
|
|
* $ref: '#/components/schemas/tableOutput'
|
2022-02-19 04:47:15 +13:00
|
|
|
* examples:
|
2022-02-19 06:44:08 +13:00
|
|
|
* table:
|
2022-02-23 03:10:01 +13:00
|
|
|
* $ref: '#/components/examples/table'
|
2022-02-19 04:47:15 +13:00
|
|
|
*/
|
2022-02-25 00:39:38 +13:00
|
|
|
write.push(
|
|
|
|
new Endpoint("put", "/tables/:tableId", controller.update).addMiddleware(
|
|
|
|
tableValidator()
|
|
|
|
)
|
|
|
|
)
|
2022-02-19 04:47:15 +13:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @openapi
|
2022-02-19 06:44:08 +13:00
|
|
|
* /tables/{tableId}:
|
|
|
|
* delete:
|
2022-09-27 02:18:31 +13:00
|
|
|
* operationId: destroy
|
2022-03-02 03:37:35 +13:00
|
|
|
* summary: Delete a table
|
|
|
|
* description: Delete a table, this could be internal or external.
|
2022-02-19 04:47:15 +13:00
|
|
|
* tags:
|
2022-02-19 06:44:08 +13:00
|
|
|
* - tables
|
2022-02-19 04:47:15 +13:00
|
|
|
* parameters:
|
|
|
|
* - $ref: '#/components/parameters/tableId'
|
2022-02-19 06:44:08 +13:00
|
|
|
* - $ref: '#/components/parameters/appId'
|
2022-02-19 04:47:15 +13:00
|
|
|
* responses:
|
|
|
|
* 200:
|
2022-02-19 06:44:08 +13:00
|
|
|
* description: Returns the deleted table.
|
2022-02-19 04:47:15 +13:00
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
2022-02-23 03:10:01 +13:00
|
|
|
* $ref: '#/components/schemas/tableOutput'
|
2022-02-19 04:47:15 +13:00
|
|
|
* examples:
|
2022-02-19 06:44:08 +13:00
|
|
|
* table:
|
|
|
|
* $ref: '#/components/examples/table'
|
2022-02-19 04:47:15 +13:00
|
|
|
*/
|
2022-02-25 04:13:14 +13:00
|
|
|
write.push(new Endpoint("delete", "/tables/:tableId", controller.destroy))
|
2022-02-18 07:58:09 +13:00
|
|
|
|
2022-02-23 03:10:01 +13:00
|
|
|
/**
|
|
|
|
* @openapi
|
|
|
|
* /tables/{tableId}:
|
|
|
|
* get:
|
2022-09-22 06:11:47 +12:00
|
|
|
* operationId: getById
|
2022-03-02 03:37:35 +13:00
|
|
|
* summary: Retrieve a table
|
|
|
|
* description: Lookup a table, this could be internal or external.
|
2022-02-23 03:10:01 +13:00
|
|
|
* 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'
|
|
|
|
*/
|
2022-02-23 07:40:09 +13:00
|
|
|
read.push(new Endpoint("get", "/tables/:tableId", controller.read))
|
2022-02-23 03:10:01 +13:00
|
|
|
|
2022-02-25 12:21:10 +13:00
|
|
|
/**
|
|
|
|
* @openapi
|
|
|
|
* /tables/search:
|
|
|
|
* post:
|
2022-09-22 06:11:47 +12:00
|
|
|
* operationId: search
|
2022-03-02 03:37:35 +13:00
|
|
|
* summary: Search for tables
|
|
|
|
* description: Based on table properties (currently only name) search for tables. This could be
|
|
|
|
* an internal or an external table.
|
2022-02-25 12:21:10 +13:00
|
|
|
* 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:
|
2022-03-09 06:42:26 +13:00
|
|
|
* $ref: '#/components/schemas/tableSearch'
|
2022-02-25 12:21:10 +13:00
|
|
|
* examples:
|
|
|
|
* tables:
|
|
|
|
* $ref: '#/components/examples/tables'
|
|
|
|
*/
|
|
|
|
read.push(
|
|
|
|
new Endpoint("post", "/tables/search", controller.search).addMiddleware(
|
|
|
|
nameValidator()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2022-02-25 04:13:14 +13:00
|
|
|
export default { read, write }
|