mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-15 17:05:14 -05:00
* improvement(mcp): improved mcp sse events notifs, update jira to handle files, fix UI issues in settings modal, fix org and workspace invitations when bundled * added back useMcpToolsEvents for event-driven discovery * ack PR comments * updated placeholder * updated colors, error throwing in mcp modal * ack comments * updated error msg
120 lines
3.4 KiB
TypeScript
120 lines
3.4 KiB
TypeScript
import type { JiraDeleteIssueLinkParams, JiraDeleteIssueLinkResponse } from '@/tools/jira/types'
|
|
import { SUCCESS_OUTPUT, TIMESTAMP_OUTPUT } from '@/tools/jira/types'
|
|
import { getJiraCloudId } from '@/tools/jira/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const jiraDeleteIssueLinkTool: ToolConfig<
|
|
JiraDeleteIssueLinkParams,
|
|
JiraDeleteIssueLinkResponse
|
|
> = {
|
|
id: 'jira_delete_issue_link',
|
|
name: 'Jira Delete Issue Link',
|
|
description: 'Delete a link between two Jira issues',
|
|
version: '1.0.0',
|
|
|
|
oauth: {
|
|
required: true,
|
|
provider: 'jira',
|
|
},
|
|
|
|
params: {
|
|
accessToken: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'hidden',
|
|
description: 'OAuth access token for Jira',
|
|
},
|
|
domain: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-only',
|
|
description: 'Your Jira domain (e.g., yourcompany.atlassian.net)',
|
|
},
|
|
linkId: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'user-or-llm',
|
|
description: 'ID of the issue link to delete',
|
|
},
|
|
cloudId: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'hidden',
|
|
description:
|
|
'Jira Cloud ID for the instance. If not provided, it will be fetched using the domain.',
|
|
},
|
|
},
|
|
|
|
request: {
|
|
url: (params: JiraDeleteIssueLinkParams) => {
|
|
if (params.cloudId) {
|
|
return `https://api.atlassian.com/ex/jira/${params.cloudId}/rest/api/3/issueLink/${params.linkId}`
|
|
}
|
|
return 'https://api.atlassian.com/oauth/token/accessible-resources'
|
|
},
|
|
method: (params: JiraDeleteIssueLinkParams) => (params.cloudId ? 'DELETE' : 'GET'),
|
|
headers: (params: JiraDeleteIssueLinkParams) => {
|
|
return {
|
|
Accept: 'application/json',
|
|
Authorization: `Bearer ${params.accessToken}`,
|
|
}
|
|
},
|
|
},
|
|
|
|
transformResponse: async (response: Response, params?: JiraDeleteIssueLinkParams) => {
|
|
if (!params?.cloudId) {
|
|
const cloudId = await getJiraCloudId(params!.domain, params!.accessToken)
|
|
const issueLinkUrl = `https://api.atlassian.com/ex/jira/${cloudId}/rest/api/3/issueLink/${params!.linkId}`
|
|
const issueLinkResponse = await fetch(issueLinkUrl, {
|
|
method: 'DELETE',
|
|
headers: {
|
|
Accept: 'application/json',
|
|
Authorization: `Bearer ${params!.accessToken}`,
|
|
},
|
|
})
|
|
|
|
if (!issueLinkResponse.ok) {
|
|
let message = `Failed to delete issue link (${issueLinkResponse.status})`
|
|
try {
|
|
const err = await issueLinkResponse.json()
|
|
message = err?.errorMessages?.join(', ') || err?.message || message
|
|
} catch (_e) {}
|
|
throw new Error(message)
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
ts: new Date().toISOString(),
|
|
linkId: params!.linkId || 'unknown',
|
|
success: true,
|
|
},
|
|
}
|
|
}
|
|
|
|
if (!response.ok) {
|
|
let message = `Failed to delete issue link (${response.status})`
|
|
try {
|
|
const err = await response.json()
|
|
message = err?.errorMessages?.join(', ') || err?.message || message
|
|
} catch (_e) {}
|
|
throw new Error(message)
|
|
}
|
|
|
|
return {
|
|
success: true,
|
|
output: {
|
|
ts: new Date().toISOString(),
|
|
linkId: params!.linkId || 'unknown',
|
|
success: true,
|
|
},
|
|
}
|
|
},
|
|
|
|
outputs: {
|
|
ts: TIMESTAMP_OUTPUT,
|
|
success: SUCCESS_OUTPUT,
|
|
linkId: { type: 'string', description: 'Deleted link ID' },
|
|
},
|
|
}
|