mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-08 22:48:14 -05:00
fix(grafana): tool outputs (#2565)
* fix(grafana): list annotations outputs * fix more grafana tools
This commit is contained in:
committed by
GitHub
parent
dc4e5d3bdc
commit
169dd4a503
@@ -110,32 +110,27 @@ export const listAnnotationsTool: ToolConfig<
|
||||
transformResponse: async (response: Response) => {
|
||||
const data = await response.json()
|
||||
|
||||
// Handle potential nested array structure
|
||||
const rawAnnotations = Array.isArray(data) ? data.flat() : []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
annotations: Array.isArray(data)
|
||||
? data.map((a: any) => ({
|
||||
id: a.id,
|
||||
alertId: a.alertId,
|
||||
alertName: a.alertName,
|
||||
dashboardId: a.dashboardId,
|
||||
dashboardUID: a.dashboardUID,
|
||||
panelId: a.panelId,
|
||||
userId: a.userId,
|
||||
newState: a.newState,
|
||||
prevState: a.prevState,
|
||||
created: a.created,
|
||||
updated: a.updated,
|
||||
time: a.time,
|
||||
timeEnd: a.timeEnd,
|
||||
text: a.text,
|
||||
tags: a.tags || [],
|
||||
login: a.login,
|
||||
email: a.email,
|
||||
avatarUrl: a.avatarUrl,
|
||||
data: a.data,
|
||||
}))
|
||||
: [],
|
||||
annotations: rawAnnotations.map((a: any) => ({
|
||||
id: a.id,
|
||||
dashboardId: a.dashboardId,
|
||||
dashboardUID: a.dashboardUID,
|
||||
created: a.created,
|
||||
updated: a.updated,
|
||||
time: a.time,
|
||||
timeEnd: a.timeEnd,
|
||||
text: a.text,
|
||||
tags: a.tags || [],
|
||||
login: a.login,
|
||||
email: a.email,
|
||||
avatarUrl: a.avatarUrl,
|
||||
data: a.data || {},
|
||||
})),
|
||||
},
|
||||
}
|
||||
},
|
||||
@@ -148,12 +143,21 @@ export const listAnnotationsTool: ToolConfig<
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'number', description: 'Annotation ID' },
|
||||
text: { type: 'string', description: 'Annotation text' },
|
||||
tags: { type: 'array', description: 'Annotation tags' },
|
||||
dashboardId: { type: 'number', description: 'Dashboard ID' },
|
||||
dashboardUID: { type: 'string', description: 'Dashboard UID' },
|
||||
created: { type: 'number', description: 'Creation timestamp in epoch ms' },
|
||||
updated: { type: 'number', description: 'Last update timestamp in epoch ms' },
|
||||
time: { type: 'number', description: 'Start time in epoch ms' },
|
||||
timeEnd: { type: 'number', description: 'End time in epoch ms' },
|
||||
dashboardUID: { type: 'string', description: 'Dashboard UID' },
|
||||
panelId: { type: 'number', description: 'Panel ID' },
|
||||
text: { type: 'string', description: 'Annotation text' },
|
||||
tags: { type: 'array', items: { type: 'string' }, description: 'Annotation tags' },
|
||||
login: { type: 'string', description: 'Login of the user who created the annotation' },
|
||||
email: { type: 'string', description: 'Email of the user who created the annotation' },
|
||||
avatarUrl: { type: 'string', description: 'Avatar URL of the user' },
|
||||
data: {
|
||||
type: 'json',
|
||||
description: 'Additional annotation data object from Grafana',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -75,7 +75,6 @@ export const listFoldersTool: ToolConfig<GrafanaListFoldersParams, GrafanaListFo
|
||||
id: f.id,
|
||||
uid: f.uid,
|
||||
title: f.title,
|
||||
url: f.url,
|
||||
hasAcl: f.hasAcl || false,
|
||||
canSave: f.canSave || false,
|
||||
canEdit: f.canEdit || false,
|
||||
@@ -102,7 +101,6 @@ export const listFoldersTool: ToolConfig<GrafanaListFoldersParams, GrafanaListFo
|
||||
id: { type: 'number', description: 'Folder ID' },
|
||||
uid: { type: 'string', description: 'Folder UID' },
|
||||
title: { type: 'string', description: 'Folder title' },
|
||||
url: { type: 'string', description: 'Folder URL path' },
|
||||
hasAcl: { type: 'boolean', description: 'Whether the folder has custom ACL permissions' },
|
||||
canSave: { type: 'boolean', description: 'Whether the current user can save the folder' },
|
||||
canEdit: { type: 'boolean', description: 'Whether the current user can edit the folder' },
|
||||
|
||||
@@ -267,14 +267,8 @@ export interface GrafanaCreateAnnotationParams extends GrafanaBaseParams {
|
||||
|
||||
export interface GrafanaAnnotation {
|
||||
id: number
|
||||
alertId: number
|
||||
alertName: string
|
||||
dashboardId: number
|
||||
dashboardUID: string
|
||||
panelId: number
|
||||
userId: number
|
||||
newState: string
|
||||
prevState: string
|
||||
created: number
|
||||
updated: number
|
||||
time: number
|
||||
@@ -380,7 +374,6 @@ export interface GrafanaFolder {
|
||||
id: number
|
||||
uid: string
|
||||
title: string
|
||||
url: string
|
||||
hasAcl: boolean
|
||||
canSave: boolean
|
||||
canEdit: boolean
|
||||
|
||||
Reference in New Issue
Block a user