From bbd9a1e529e3a226725b245ba6e428c905b3175d Mon Sep 17 00:00:00 2001 From: yond1994 Date: Thu, 6 Jun 2024 22:11:35 +0200 Subject: [PATCH 1/2] fix: "remove document system api" --- server/endpoints/api/system/index.js | 63 ++++++++++++++++++++++ server/swagger/openapi.json | 78 ++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) diff --git a/server/endpoints/api/system/index.js b/server/endpoints/api/system/index.js index c8e5e06cc76..8c68552f6cc 100644 --- a/server/endpoints/api/system/index.js +++ b/server/endpoints/api/system/index.js @@ -206,6 +206,69 @@ function apiSystemEndpoints(app) { } } ); + app.delete( + "/v1/system/remove-documents", + [validApiKey], + async (request, response) => { + /* + #swagger.tags = ['System'] + #swagger.description = 'Permanently remove documents from the system.' + #swagger.requestBody = { + description: 'Array of document names to be removed permanently.', + required: true, + content: { + "application/json": { + schema: { + type: 'object', + properties: { + names: { + type: 'array', + items: { + type: 'string' + }, + example: [ + "custom-documents/file.txt-fc4beeeb-e436-454d-8bb4-e5b8979cb48f.json" + ] + } + } + } + } + } + } + #swagger.responses[200] = { + description: 'Documents removed successfully.', + content: { + "application/json": { + schema: { + type: 'object', + example: { + success: true, + message: 'Documents removed successfully' + } + } + } + } + } + #swagger.responses[403] = { + description: 'Forbidden', + schema: { + "$ref": "#/definitions/InvalidAPIKey" + } + } + #swagger.responses[500] = { + description: 'Internal Server Error' + } + */ + try { + const { names } = reqBody(request); + for await (const name of names) await purgeDocument(name); + response.status(200).json({ success: true, message: 'Documents removed successfully' }).end(); + } catch (e) { + console.log(e.message, e); + response.sendStatus(500).end(); + } + } + ); } module.exports = { apiSystemEndpoints }; diff --git a/server/swagger/openapi.json b/server/swagger/openapi.json index ed6f153374c..adc843f38c6 100644 --- a/server/swagger/openapi.json +++ b/server/swagger/openapi.json @@ -2241,6 +2241,84 @@ } } } + }, + "/v1/system/remove-documents": { + "delete": { + "tags": [ + "System Settings" + ], + "description": "Permanently remove documents from the system.", + "parameters": [], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "example": { + "success": true, + "message": "Documents removed successfully" + } + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InvalidAPIKey" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/InvalidAPIKey" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + }, + "requestBody": { + "description": "Array of document names to be removed permanently.", + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string" + }, + "example": [ + "custom-documents/file.txt-fc4beeeb-e436-454d-8bb4-e5b8979cb48f.json" + ] + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "InvalidAPIKey": { + "type": "object", + "properties": { + "error": { + "type": "string", + "example": "Invalid API Key" + } + } + } + } } }, "components": { From 81b6838cfeb41e3ee8e03c8ecd23504860dfcea2 Mon Sep 17 00:00:00 2001 From: yond1994 Date: Fri, 7 Jun 2024 01:26:10 +0200 Subject: [PATCH 2/2] fix: "update text system system " --- server/endpoints/api/system/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/endpoints/api/system/index.js b/server/endpoints/api/system/index.js index 8c68552f6cc..da941bd8d89 100644 --- a/server/endpoints/api/system/index.js +++ b/server/endpoints/api/system/index.js @@ -211,7 +211,7 @@ function apiSystemEndpoints(app) { [validApiKey], async (request, response) => { /* - #swagger.tags = ['System'] + #swagger.tags = ['System Settings'] #swagger.description = 'Permanently remove documents from the system.' #swagger.requestBody = { description: 'Array of document names to be removed permanently.',