UNPKG

@jupiterone/jupiterone-mcp

Version:

Model Context Protocol server for JupiterOne account rules and rule details

127 lines 4.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DashboardService = void 0; const queries_js_1 = require("../graphql/queries.js"); const mutations_js_1 = require("../graphql/mutations.js"); const appUrl_js_1 = require("../../utils/appUrl.js"); // The `updateWidget` mutation requires a `boardType` argument that the backend does not consume; // the web app passes this same placeholder. const BOARD_TYPE_PLACEHOLDER = 'not-consumed-on-backend'; class DashboardService { client; constructor(client) { this.client = client; } /** * Construct dashboard URL based on subdomain */ constructDashboardUrl(dashboardId, subdomain) { return (0, appUrl_js_1.constructAppUrl)(`insights/dashboards/${dashboardId}`, subdomain); } /** * Get all dashboards */ async getDashboards() { try { const response = await this.client.request(queries_js_1.GET_DASHBOARDS); return response.getDashboards; } catch (error) { console.error('Error getting dashboards:', error); throw error; } } /** * Create a new dashboard */ async createDashboard(input) { try { const response = await this.client.request(mutations_js_1.CREATE_DASHBOARD, { input, }); return response.createDashboard; } catch (error) { console.error('Error creating dashboard:', error); throw error; } } /** * Get dashboard details by ID */ async getDashboard(dashboardId) { try { const response = await this.client.request(queries_js_1.GET_DASHBOARD_DETAILS, { dashboardId, }); return response.getDashboard; } catch (error) { console.error('Error getting dashboard details:', error); throw error; } } /** * Create a new dashboard widget */ async createDashboardWidget(dashboardId, input) { try { const response = await this.client.request(mutations_js_1.CREATE_DASHBOARD_WIDGET, { dashboardId, input, }); return response.createWidget; } catch (error) { console.error('Error creating dashboard widget:', error); throw error; } } /** * Delete a widget from a dashboard. */ async deleteDashboardWidget(dashboardId, widgetId) { try { const response = await this.client.request(mutations_js_1.DELETE_DASHBOARD_WIDGET, { dashboardId, widgetId }); return response.deleteWidget; } catch (error) { console.error('Error deleting dashboard widget:', error); throw error; } } /** * Update (replace) a widget's definition. `newWidget` must be the full widget, including its `id`. */ async updateDashboardWidget(dashboardId, newWidget) { try { const response = await this.client.request(mutations_js_1.UPDATE_DASHBOARD_WIDGET, { boardId: dashboardId, boardType: BOARD_TYPE_PLACEHOLDER, newWidget }); return response.updateWidget; } catch (error) { console.error('Error updating dashboard widget:', error); throw error; } } /** * Delete a dashboard. */ async deleteDashboard(dashboardId) { try { const response = await this.client.request(mutations_js_1.DELETE_DASHBOARD, { dashboardId }); return response.deleteDashboard; } catch (error) { console.error('Error deleting dashboard:', error); throw error; } } async updateDashboard(input) { return this.patchDashboard(input); } async patchDashboard(input) { return this.client.request(mutations_js_1.PATCH_DASHBOARD, { input }); } } exports.DashboardService = DashboardService; //# sourceMappingURL=dashboard-service.js.map