2022-02-25 04:13:14 +13:00
|
|
|
import controller from "../../controllers/public/queries"
|
|
|
|
import Endpoint from "./utils/Endpoint"
|
|
|
|
import { 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-18 07:58:09 +13:00
|
|
|
|
2022-02-22 05:37:02 +13:00
|
|
|
/**
|
|
|
|
* @openapi
|
|
|
|
* /queries/{queryId}:
|
|
|
|
* post:
|
2022-03-02 03:37:35 +13:00
|
|
|
* summary: Execute a query
|
|
|
|
* description: Queries which have been created within a Budibase app can be executed using this,
|
2022-02-22 05:37:02 +13:00
|
|
|
* - queries
|
2022-02-22 08:04:13 +13:00
|
|
|
* parameters:
|
|
|
|
* - $ref: '#/components/parameters/queryId'
|
|
|
|
* - $ref: '#/components/parameters/appId'
|
|
|
|
* responses:
|
|
|
|
* 200:
|
|
|
|
* description: Returns the result of the query execution.
|
|
|
|
* content:
|
|
|
|
* application/json:
|
|
|
|
* schema:
|
2022-02-24 07:31:32 +13:00
|
|
|
* type: object
|
|
|
|
* properties:
|
|
|
|
* data:
|
|
|
|
* type: array
|
|
|
|
* description: The data retrieved from the query.
|
|
|
|
* items:
|
|
|
|
* type: object
|
|
|
|
* description: The structure of the returned data will be an object,
|
|
|
|
* if it is just a string then this will be an object containing "value".
|
|
|
|
* pagination:
|
|
|
|
* type: object
|
|
|
|
* description: For supported query types this returns pagination information.
|
|
|
|
* properties:
|
|
|
|
* cursor:
|
|
|
|
* type: string
|
|
|
|
* description: The pagination cursor location.
|
|
|
|
* raw:
|
|
|
|
* type: string
|
|
|
|
* description: The raw query response.
|
|
|
|
* headers:
|
|
|
|
* type: object
|
|
|
|
* description: For REST queries the headers in the response will be returned here.
|
2022-02-23 03:10:01 +13:00
|
|
|
* examples:
|
2022-02-24 07:31:32 +13:00
|
|
|
* REST:
|
|
|
|
* $ref: '#/components/examples/restResponse'
|
|
|
|
* SQL:
|
|
|
|
* $ref: '#/components/examples/sqlResponse'
|
|
|
|
*
|
2022-02-22 05:37:02 +13:00
|
|
|
*/
|
2022-02-23 07:40:09 +13:00
|
|
|
write.push(new Endpoint("post", "/queries/:queryId", controller.execute))
|
2022-02-22 05:37:02 +13:00
|
|
|
|
2022-02-25 12:21:10 +13:00
|
|
|
/**
|
|
|
|
* @openapi
|
|
|
|
* /queries/search:
|
|
|
|
* post:
|
2022-03-02 03:37:35 +13:00
|
|
|
* summary: Search for queries
|
|
|
|
* description: Based on query properties (currently only name) search for queries.
|
2022-02-25 12:21:10 +13:00
|
|
|
* 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:
|
|
|
|
* type: object
|
|
|
|
* required:
|
2022-03-02 03:37:35 +13:00
|
|
|
* - data
|
2022-02-25 12:21:10 +13:00
|
|
|
* properties:
|
2022-03-02 03:37:35 +13:00
|
|
|
* data:
|
2022-02-25 12:21:10 +13:00
|
|
|
* type: array
|
|
|
|
* items:
|
|
|
|
* $ref: '#/components/schemas/query'
|
|
|
|
* examples:
|
|
|
|
* queries:
|
|
|
|
* $ref: '#/components/examples/queries'
|
|
|
|
*/
|
|
|
|
read.push(
|
|
|
|
new Endpoint("post", "/queries/search", controller.search).addMiddleware(
|
|
|
|
nameValidator()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2022-02-25 04:13:14 +13:00
|
|
|
export default { read, write }
|