Enhance ApiStatusIndicator to conditionally render for aws-admin accounts only. Improve error handling in API response management across various components, ensuring expected 400 responses are logged appropriately. Update Credits and ApiMonitor components to handle null values gracefully and implement CRUD operations for planner and writer endpoints.

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-15 21:44:10 +00:00
parent a75ebf2584
commit 5a3706d997
4 changed files with 208 additions and 25 deletions

View File

@@ -105,7 +105,7 @@ const endpointGroups: EndpointGroup[] = [
{ path: "/v1/system/prompts/save/", method: "POST", description: "Save prompt" },
{ path: "/v1/system/author-profiles/", method: "GET", description: "List author profiles" },
{ path: "/v1/system/strategies/", method: "GET", description: "List strategies" },
{ path: "/v1/system/settings/integrations/1/test/", method: "POST", description: "Test integration" },
{ path: "/v1/system/settings/integrations/openai/test/", method: "POST", description: "Test integration (OpenAI)" },
{ path: "/v1/system/settings/account/", method: "GET", description: "Account settings" },
{ path: "/v1/billing/credits/balance/balance/", method: "GET", description: "Credit balance" },
{ path: "/v1/billing/credits/usage/", method: "GET", description: "Usage logs" },
@@ -126,6 +126,46 @@ const endpointGroups: EndpointGroup[] = [
{ path: "/v1/billing/credits/transactions/", method: "GET", description: "Transactions" },
],
},
{
name: "CRUD Operations - Planner",
endpoints: [
{ path: "/v1/planner/keywords/", method: "GET", description: "List keywords (READ)" },
{ path: "/v1/planner/keywords/", method: "POST", description: "Create keyword (CREATE)" },
{ path: "/v1/planner/keywords/1/", method: "GET", description: "Get keyword (READ)" },
{ path: "/v1/planner/keywords/1/", method: "PUT", description: "Update keyword (UPDATE)" },
{ path: "/v1/planner/keywords/1/", method: "DELETE", description: "Delete keyword (DELETE)" },
{ path: "/v1/planner/clusters/", method: "GET", description: "List clusters (READ)" },
{ path: "/v1/planner/clusters/", method: "POST", description: "Create cluster (CREATE)" },
{ path: "/v1/planner/clusters/1/", method: "GET", description: "Get cluster (READ)" },
{ path: "/v1/planner/clusters/1/", method: "PUT", description: "Update cluster (UPDATE)" },
{ path: "/v1/planner/clusters/1/", method: "DELETE", description: "Delete cluster (DELETE)" },
{ path: "/v1/planner/ideas/", method: "GET", description: "List ideas (READ)" },
{ path: "/v1/planner/ideas/", method: "POST", description: "Create idea (CREATE)" },
{ path: "/v1/planner/ideas/1/", method: "GET", description: "Get idea (READ)" },
{ path: "/v1/planner/ideas/1/", method: "PUT", description: "Update idea (UPDATE)" },
{ path: "/v1/planner/ideas/1/", method: "DELETE", description: "Delete idea (DELETE)" },
],
},
{
name: "CRUD Operations - Writer",
endpoints: [
{ path: "/v1/writer/tasks/", method: "GET", description: "List tasks (READ)" },
{ path: "/v1/writer/tasks/", method: "POST", description: "Create task (CREATE)" },
{ path: "/v1/writer/tasks/1/", method: "GET", description: "Get task (READ)" },
{ path: "/v1/writer/tasks/1/", method: "PUT", description: "Update task (UPDATE)" },
{ path: "/v1/writer/tasks/1/", method: "DELETE", description: "Delete task (DELETE)" },
{ path: "/v1/writer/content/", method: "GET", description: "List content (READ)" },
{ path: "/v1/writer/content/", method: "POST", description: "Create content (CREATE)" },
{ path: "/v1/writer/content/1/", method: "GET", description: "Get content (READ)" },
{ path: "/v1/writer/content/1/", method: "PUT", description: "Update content (UPDATE)" },
{ path: "/v1/writer/content/1/", method: "DELETE", description: "Delete content (DELETE)" },
{ path: "/v1/writer/images/", method: "GET", description: "List images (READ)" },
{ path: "/v1/writer/images/", method: "POST", description: "Create image (CREATE)" },
{ path: "/v1/writer/images/1/", method: "GET", description: "Get image (READ)" },
{ path: "/v1/writer/images/1/", method: "PUT", description: "Update image (UPDATE)" },
{ path: "/v1/writer/images/1/", method: "DELETE", description: "Delete image (DELETE)" },
],
},
];
const getStatusColor = (status: string) => {
@@ -245,9 +285,18 @@ export default function ApiMonitor() {
body = { username: 'test', password: 'test' }; // Will fail validation but endpoint exists
} else if (path.includes('/register/')) {
body = { username: 'test', email: 'test@test.com', password: 'test' }; // Will fail validation but endpoint exists
} else if (path.includes('/bulk_')) {
// Bulk operations need ids array
body = { ids: [] };
} else {
// CRUD CREATE operations - minimal valid body
body = {};
}
fetchOptions.body = JSON.stringify(body);
} else if (method === 'PUT') {
// CRUD UPDATE operations - minimal valid body
fetchOptions.body = JSON.stringify({});
}
const response = await fetch(`${API_BASE_URL}${path}`, fetchOptions);
@@ -380,6 +429,39 @@ export default function ApiMonitor() {
} else {
status = 'warning';
}
} else if (method === 'PUT') {
// UPDATE operations
if (response.status === 400 || response.status === 404) {
// 400/404 expected for test requests (validation/not found) - endpoint is working
status = 'healthy';
} else if (response.status >= 200 && response.status < 300) {
status = 'healthy';
} else if (response.status === 429) {
status = 'warning'; // Rate limited
} else if (response.status === 401 || response.status === 403) {
status = 'warning'; // Needs authentication
} else if (response.status >= 500) {
status = 'error';
} else {
status = 'warning';
}
} else if (method === 'DELETE') {
// DELETE operations
if (response.status === 204 || response.status === 200) {
// 204 No Content or 200 OK - successful delete
status = 'healthy';
} else if (response.status === 404) {
// 404 expected for test requests (resource not found) - endpoint is working
status = 'healthy';
} else if (response.status === 429) {
status = 'warning'; // Rate limited
} else if (response.status === 401 || response.status === 403) {
status = 'warning'; // Needs authentication
} else if (response.status >= 500) {
status = 'error';
} else {
status = 'warning';
}
}
// Store API status