diff --git a/packages/server/specs/openapi.json b/packages/server/specs/openapi.json index beb1eaeb6..12ac1f05b 100644 --- a/packages/server/specs/openapi.json +++ b/packages/server/specs/openapi.json @@ -43,6 +43,33 @@ "schema": { "type": "string" } + }, + "appIdUrl": { + "in": "path", + "name": "appId", + "required": true, + "description": "The ID of the app which this request is targeting.", + "schema": { + "type": "string" + } + }, + "queryId": { + "in": "path", + "name": "queryId", + "required": true, + "description": "The ID of the query which this request is targeting.", + "schema": { + "type": "string" + } + }, + "userId": { + "in": "path", + "name": "userId", + "required": true, + "description": "The ID of the user which this request is targeting.", + "schema": { + "type": "string" + } } }, "examples": { @@ -366,6 +393,18 @@ ] } } + }, + "query": { + "type": "object", + "properties": {} + }, + "user": { + "type": "object", + "properties": {} + }, + "application": { + "type": "object", + "properties": {} } } }, @@ -375,12 +414,133 @@ } ], "paths": { + "/applications/search": { + "post": { + "summary": "Search for an application based on its app name.", + "tags": [ + "applications" + ], + "parameters": [ + { + "$ref": "#/components/parameters/appId" + } + ], + "responses": { + "200": { + "description": "Returns the applications that were found based on the search parameters.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/application" + } + } + } + } + } + } + } + }, + "/applications": { + "post": { + "summary": "Create a new application.", + "tags": [ + "applications" + ], + "parameters": [ + { + "$ref": "#/components/parameters/appId" + } + ], + "responses": { + "200": { + "description": "Returns the created application.", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/applications/{appId}": { + "put": { + "summary": "Update an existing application by its ID.", + "tags": [ + "applications" + ], + "parameters": [ + { + "$ref": "#/components/parameters/appIdUrl" + } + ], + "responses": { + "200": { + "description": "Returns the updated application.", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "summary": "Delete an existing application by its ID.", + "tags": [ + "applications" + ], + "parameters": [ + { + "$ref": "#/components/parameters/appIdUrl" + } + ], + "responses": { + "200": { + "description": "Returns the deleted application.", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, "/queries/search": { "post": { "summary": "Search for a query based on its name.", "tags": [ "queries" - ] + ], + "parameters": [ + { + "$ref": "#/components/parameters/appId" + } + ], + "responses": { + "200": { + "description": "Returns the queries found based on the search parameters.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/query" + } + } + } + } + } + } } }, "/queries/{queryId}": { @@ -388,7 +548,30 @@ "summary": "Execute a query and retrieve its response.", "tags": [ "queries" - ] + ], + "parameters": [ + { + "$ref": "#/components/parameters/queryId" + }, + { + "$ref": "#/components/parameters/appId" + } + ], + "responses": { + "200": { + "description": "Returns the result of the query execution.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + } + } } }, "/tables/{tableId}/rows/search": { @@ -866,8 +1049,8 @@ } }, "/tables/{tableId}": { - "get": { - "summary": "Get a single table by its ID, internal and external within an app.", + "delete": { + "summary": "Delete a single table and all of its data.", "tags": [ "tables" ], @@ -881,7 +1064,7 @@ ], "responses": { "200": { - "description": "Returns the table that was found.", + "description": "Returns the deleted table.", "content": { "application/json": { "schema": { @@ -889,22 +1072,103 @@ }, "examples": { "table": { - "$ref": "#/components/examples/row" + "$ref": "#/components/examples/table" + } + } + } + } + } + } + } + }, + "/users/search": { + "post": { + "summary": "Search for a user based on their email/username.", + "tags": [ + "users" + ], + "parameters": [ + { + "$ref": "#/components/parameters/appId" + } + ], + "responses": { + "200": { + "description": "Returns the found users based on search parameters.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/user" } } } } } } + } + }, + "/users": { + "post": { + "summary": "Create a new user in the Budibase portal.", + "tags": [ + "users" + ], + "parameters": [ + { + "$ref": "#/components/parameters/appId" + } + ], + "responses": { + "200": { + "description": "Returns the created user.", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/users/{userId}": { + "put": { + "summary": "Update an existing user by their ID.", + "tags": [ + "users" + ], + "parameters": [ + { + "$ref": "#/components/parameters/userId" + }, + { + "$ref": "#/components/parameters/appId" + } + ], + "responses": { + "200": { + "description": "Returns the updated user.", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } }, "delete": { - "summary": "Delete a single table and all of its data.", + "summary": "Delete an existing user by their ID.", "tags": [ - "tables" + "users" ], "parameters": [ { - "$ref": "#/components/parameters/tableId" + "$ref": "#/components/parameters/userId" }, { "$ref": "#/components/parameters/appId" @@ -912,16 +1176,11 @@ ], "responses": { "200": { - "description": "Returns the deleted table.", + "description": "Returns the deleted user.", "content": { "application/json": { "schema": { "type": "object" - }, - "examples": { - "table": { - "$ref": "#/components/examples/table" - } } } } diff --git a/packages/server/specs/openapi.yaml b/packages/server/specs/openapi.yaml index 04b25647f..065624306 100644 --- a/packages/server/specs/openapi.yaml +++ b/packages/server/specs/openapi.yaml @@ -31,6 +31,27 @@ components: description: The ID of the app which this request is targeting. schema: type: string + appIdUrl: + in: path + name: appId + required: true + description: The ID of the app which this request is targeting. + schema: + type: string + queryId: + in: path + name: queryId + required: true + description: The ID of the query which this request is targeting. + schema: + type: string + userId: + in: path + name: userId + required: true + description: The ID of the user which this request is targeting. + schema: + type: string examples: table: value: @@ -267,19 +288,109 @@ components: autocolumn: type: boolean description: Defines whether the column is automatically generated. + query: + type: object + properties: {} + user: + type: object + properties: {} + application: + type: object + properties: {} security: - ApiKeyAuth: [] paths: + /applications/search: + post: + summary: Search for an application based on its app name. + tags: + - applications + parameters: + - $ref: "#/components/parameters/appId" + responses: + "200": + description: Returns the applications that were found based on the search + parameters. + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/application" + /applications: + post: + summary: Create a new application. + tags: + - applications + parameters: + - $ref: "#/components/parameters/appId" + responses: + "200": + description: Returns the created application. + content: + application/json: + schema: + type: object + "/applications/{appId}": + put: + summary: Update an existing application by its ID. + tags: + - applications + parameters: + - $ref: "#/components/parameters/appIdUrl" + responses: + "200": + description: Returns the updated application. + content: + application/json: + schema: + type: object + delete: + summary: Delete an existing application by its ID. + tags: + - applications + parameters: + - $ref: "#/components/parameters/appIdUrl" + responses: + "200": + description: Returns the deleted application. + content: + application/json: + schema: + type: object /queries/search: post: summary: Search for a query based on its name. tags: - queries + parameters: + - $ref: "#/components/parameters/appId" + responses: + "200": + description: Returns the queries found based on the search parameters. + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/query" "/queries/{queryId}": post: summary: Execute a query and retrieve its response. tags: - queries + parameters: + - $ref: "#/components/parameters/queryId" + - $ref: "#/components/parameters/appId" + responses: + "200": + description: Returns the result of the query execution. + content: + application/json: + schema: + type: array + items: + type: object "/tables/{tableId}/rows/search": post: summary: Used to search for rows within a table. @@ -580,8 +691,8 @@ paths: table: $ref: "#/components/examples/row" "/tables/{tableId}": - get: - summary: Get a single table by its ID, internal and external within an app. + delete: + summary: Delete a single table and all of its data. tags: - tables parameters: @@ -589,29 +700,71 @@ paths: - $ref: "#/components/parameters/appId" responses: "200": - description: Returns the table that was found. + description: Returns the deleted table. content: application/json: schema: type: object examples: table: - $ref: "#/components/examples/row" + $ref: "#/components/examples/table" + /users/search: + post: + summary: Search for a user based on their email/username. + tags: + - users + parameters: + - $ref: "#/components/parameters/appId" + responses: + "200": + description: Returns the found users based on search parameters. + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/user" + /users: + post: + summary: Create a new user in the Budibase portal. + tags: + - users + parameters: + - $ref: "#/components/parameters/appId" + responses: + "200": + description: Returns the created user. + content: + application/json: + schema: + type: object + "/users/{userId}": + put: + summary: Update an existing user by their ID. + tags: + - users + parameters: + - $ref: "#/components/parameters/userId" + - $ref: "#/components/parameters/appId" + responses: + "200": + description: Returns the updated user. + content: + application/json: + schema: + type: object delete: - summary: Delete a single table and all of its data. + summary: Delete an existing user by their ID. tags: - - tables + - users parameters: - - $ref: "#/components/parameters/tableId" + - $ref: "#/components/parameters/userId" - $ref: "#/components/parameters/appId" responses: "200": - description: Returns the deleted table. + description: Returns the deleted user. content: application/json: schema: type: object - examples: - table: - $ref: "#/components/examples/table" tags: [] diff --git a/packages/server/specs/parameters.js b/packages/server/specs/parameters.js index f1382ffe7..ca7a0a9a2 100644 --- a/packages/server/specs/parameters.js +++ b/packages/server/specs/parameters.js @@ -27,3 +27,33 @@ exports.appId = { type: "string", }, } + +exports.appIdUrl = { + in: "path", + name: "appId", + required: true, + description: "The ID of the app which this request is targeting.", + schema: { + type: "string", + }, +} + +exports.queryId = { + in: "path", + name: "queryId", + required: true, + description: "The ID of the query which this request is targeting.", + schema: { + type: "string", + }, +} + +exports.userId = { + in: "path", + name: "userId", + required: true, + description: "The ID of the user which this request is targeting.", + schema: { + type: "string", + }, +} diff --git a/packages/server/specs/schemas.js b/packages/server/specs/schemas.js index f9fedda89..0dd4e2512 100644 --- a/packages/server/specs/schemas.js +++ b/packages/server/specs/schemas.js @@ -143,3 +143,18 @@ exports.table = { }, }, } + +exports.query = { + type: "object", + properties: {}, +} + +exports.user = { + type: "object", + properties: {}, +} + +exports.application = { + type: "object", + properties: {}, +} diff --git a/packages/server/src/api/controllers/public/applications.js b/packages/server/src/api/controllers/public/applications.js new file mode 100644 index 000000000..8bd8d6d9d --- /dev/null +++ b/packages/server/src/api/controllers/public/applications.js @@ -0,0 +1,15 @@ +exports.search = () => { + +} + +exports.create = () => { + +} + +exports.update = () => { + +} + +exports.delete = () => { + +} \ No newline at end of file diff --git a/packages/server/src/api/controllers/public/tables.js b/packages/server/src/api/controllers/public/tables.js index 7c2fad410..8bd8d6d9d 100644 --- a/packages/server/src/api/controllers/public/tables.js +++ b/packages/server/src/api/controllers/public/tables.js @@ -6,10 +6,6 @@ exports.create = () => { } -exports.singleRead = () => { - -} - exports.update = () => { } diff --git a/packages/server/src/api/controllers/public/users.js b/packages/server/src/api/controllers/public/users.js new file mode 100644 index 000000000..8bd8d6d9d --- /dev/null +++ b/packages/server/src/api/controllers/public/users.js @@ -0,0 +1,15 @@ +exports.search = () => { + +} + +exports.create = () => { + +} + +exports.update = () => { + +} + +exports.delete = () => { + +} \ No newline at end of file diff --git a/packages/server/src/api/routes/public/applications.js b/packages/server/src/api/routes/public/applications.js index f9a77e6bc..193085b9a 100644 --- a/packages/server/src/api/routes/public/applications.js +++ b/packages/server/src/api/routes/public/applications.js @@ -1,5 +1,84 @@ const Router = require("@koa/router") +const controller = require("../../controllers/public/applications") const router = Router() +/** + * @openapi + * /applications/search: + * post: + * summary: Search for an application based on its app name. + * tags: + * - applications + * parameters: + * - $ref: '#/components/parameters/appId' + * responses: + * 200: + * description: Returns the applications that were found based on the search parameters. + * content: + * application/json: + * schema: + * type: array + * items: + * $ref: '#/components/schemas/application' + */ +router.post("/applications/search", controller.search) + +/** + * @openapi + * /applications: + * post: + * summary: Create a new application. + * tags: + * - applications + * parameters: + * - $ref: '#/components/parameters/appId' + * responses: + * 200: + * description: Returns the created application. + * content: + * application/json: + * schema: + * type: object + */ +router.post("/applications", controller.create) + +/** + * @openapi + * /applications/{appId}: + * put: + * summary: Update an existing application by its ID. + * tags: + * - applications + * parameters: + * - $ref: '#/components/parameters/appIdUrl' + * responses: + * 200: + * description: Returns the updated application. + * content: + * application/json: + * schema: + * type: object + */ +router.put("/applications/:appId", controller.update) + +/** + * @openapi + * /applications/{appId}: + * delete: + * summary: Delete an existing application by its ID. + * tags: + * - applications + * parameters: + * - $ref: '#/components/parameters/appIdUrl' + * responses: + * 200: + * description: Returns the deleted application. + * content: + * application/json: + * schema: + * type: object + */ +router.delete("/applications/:appId", controller.delete) + module.exports = router diff --git a/packages/server/src/api/routes/public/queries.js b/packages/server/src/api/routes/public/queries.js index 113767946..b1982562a 100644 --- a/packages/server/src/api/routes/public/queries.js +++ b/packages/server/src/api/routes/public/queries.js @@ -10,6 +10,17 @@ const router = Router() * summary: Search for a query based on its name. * tags: * - queries + * parameters: + * - $ref: '#/components/parameters/appId' + * responses: + * 200: + * description: Returns the queries found based on the search parameters. + * content: + * application/json: + * schema: + * type: array + * items: + * $ref: '#/components/schemas/query' */ router.post("/queries/search", controller.search) @@ -20,6 +31,18 @@ router.post("/queries/search", controller.search) * summary: Execute a query and retrieve its response. * tags: * - queries + * parameters: + * - $ref: '#/components/parameters/queryId' + * - $ref: '#/components/parameters/appId' + * responses: + * 200: + * description: Returns the result of the query execution. + * content: + * application/json: + * schema: + * type: array + * items: + * type: object */ router.post("/queries/:queryId", controller.execute) diff --git a/packages/server/src/api/routes/public/tables.js b/packages/server/src/api/routes/public/tables.js index 748a7ca70..a2c26af49 100644 --- a/packages/server/src/api/routes/public/tables.js +++ b/packages/server/src/api/routes/public/tables.js @@ -99,29 +99,6 @@ router.post("/tables", controller.create) */ router.put("/tables/:tableId", controller.update) -/** - * @openapi - * /tables/{tableId}: - * get: - * summary: Get a single table by its ID, internal and external within an app. - * tags: - * - tables - * parameters: - * - $ref: '#/components/parameters/tableId' - * - $ref: '#/components/parameters/appId' - * responses: - * 200: - * description: Returns the table that was found. - * content: - * application/json: - * schema: - * type: object - * examples: - * table: - * $ref: '#/components/examples/row' - */ -router.get("/tables/:tableId", controller.singleRead) - /** * @openapi * /tables/{tableId}: diff --git a/packages/server/src/api/routes/public/users.js b/packages/server/src/api/routes/public/users.js index f9a77e6bc..e76af6097 100644 --- a/packages/server/src/api/routes/public/users.js +++ b/packages/server/src/api/routes/public/users.js @@ -1,5 +1,86 @@ const Router = require("@koa/router") +const controller = require("../../controllers/public/users") const router = Router() +/** + * @openapi + * /users/search: + * post: + * summary: Search for a user based on their email/username. + * tags: + * - users + * parameters: + * - $ref: '#/components/parameters/appId' + * responses: + * 200: + * description: Returns the found users based on search parameters. + * content: + * application/json: + * schema: + * type: array + * items: + * $ref: '#/components/schemas/user' + */ +router.post("/users/search", controller.search) + +/** + * @openapi + * /users: + * post: + * summary: Create a new user in the Budibase portal. + * tags: + * - users + * parameters: + * - $ref: '#/components/parameters/appId' + * responses: + * 200: + * description: Returns the created user. + * content: + * application/json: + * schema: + * type: object + */ +router.post("/users", controller.create) + +/** + * @openapi + * /users/{userId}: + * put: + * summary: Update an existing user by their ID. + * tags: + * - users + * parameters: + * - $ref: '#/components/parameters/userId' + * - $ref: '#/components/parameters/appId' + * responses: + * 200: + * description: Returns the updated user. + * content: + * application/json: + * schema: + * type: object + */ +router.put("/users/:userId", controller.update) + +/** + * @openapi + * /users/{userId}: + * delete: + * summary: Delete an existing user by their ID. + * tags: + * - users + * parameters: + * - $ref: '#/components/parameters/userId' + * - $ref: '#/components/parameters/appId' + * responses: + * 200: + * description: Returns the deleted user. + * content: + * application/json: + * schema: + * type: object + */ +router.delete("/users/:userId", controller.delete) + module.exports = router