updated jsm and jira customers route and docs

This commit is contained in:
Waleed Latif
2026-02-17 13:37:58 -08:00
parent f46ec3fc1b
commit bda9acefe2
4 changed files with 33 additions and 21 deletions

View File

@@ -244,7 +244,7 @@ Get multiple service requests from Jira Service Management
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
| `cloudId` | string | No | Jira Cloud ID for the instance |
| `serviceDeskId` | string | No | Filter by service desk ID \(e.g., "1", "2"\) |
| `requestOwnership` | string | No | Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, APPROVER, ALL_REQUESTS |
| `requestOwnership` | string | No | Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, ORGANIZATION, ALL_ORGANIZATIONS, APPROVER, ALL_REQUESTS |
| `requestStatus` | string | No | Filter by status: OPEN_REQUESTS, CLOSED_REQUESTS, ALL_REQUESTS |
| `requestTypeId` | string | No | Filter by request type ID |
| `searchTerm` | string | No | Search term to filter requests \(e.g., "password reset", "laptop"\) |

View File

@@ -59,23 +59,26 @@ export async function POST(request: NextRequest) {
const { action: customerAction } = body
const rawIds = accountIds || emails
const parsedAccountIds = rawIds
? typeof rawIds === 'string'
? rawIds
.split(',')
.map((id: string) => id.trim())
.filter((id: string) => id)
: Array.isArray(rawIds)
? rawIds
: []
: []
const parseList = (raw: unknown): string[] => {
if (!raw) return []
if (typeof raw === 'string') {
return raw
.split(',')
.map((id: string) => id.trim())
.filter((id: string) => id)
}
return Array.isArray(raw) ? raw : []
}
const parsedAccountIds = parseList(accountIds)
const parsedEmails = parseList(emails)
const isRemoveOperation = customerAction === 'remove'
const isAddOperation = !isRemoveOperation && parsedAccountIds.length > 0
const isAddOperation =
!isRemoveOperation && (parsedAccountIds.length > 0 || parsedEmails.length > 0)
if (isRemoveOperation) {
if (parsedAccountIds.length === 0) {
if (parsedAccountIds.length === 0 && parsedEmails.length === 0) {
return NextResponse.json(
{ error: 'Account IDs or emails are required for removal' },
{ status: 400 }
@@ -84,12 +87,16 @@ export async function POST(request: NextRequest) {
const url = `${baseUrl}/servicedesk/${serviceDeskId}/customer`
logger.info('Removing customers from:', url, { accountIds: parsedAccountIds })
const removeBody: Record<string, string[]> = {}
if (parsedAccountIds.length > 0) removeBody.accountIds = parsedAccountIds
if (parsedEmails.length > 0) removeBody.usernames = parsedEmails
logger.info('Removing customers from:', url, removeBody)
const response = await fetch(url, {
method: 'DELETE',
headers: getJsmHeaders(accessToken),
body: JSON.stringify({ accountIds: parsedAccountIds }),
body: JSON.stringify(removeBody),
})
if (response.status === 204 || response.ok) {
@@ -119,11 +126,14 @@ export async function POST(request: NextRequest) {
if (isAddOperation) {
const url = `${baseUrl}/servicedesk/${serviceDeskId}/customer`
logger.info('Adding customers to:', url, { accountIds: parsedAccountIds })
const requestBody: Record<string, unknown> = {
logger.info('Adding customers to:', url, {
accountIds: parsedAccountIds,
}
usernames: parsedEmails,
})
const requestBody: Record<string, unknown> = {}
if (parsedAccountIds.length > 0) requestBody.accountIds = parsedAccountIds
if (parsedEmails.length > 0) requestBody.usernames = parsedEmails
const response = await fetch(url, {
method: 'POST',

View File

@@ -373,6 +373,8 @@ Return ONLY the comment text - no explanations.`,
{ label: 'All Requests', id: 'ALL_REQUESTS' },
{ label: 'My Requests', id: 'OWNED_REQUESTS' },
{ label: 'Participated', id: 'PARTICIPATED_REQUESTS' },
{ label: 'Organization', id: 'ORGANIZATION' },
{ label: 'All Organizations', id: 'ALL_ORGANIZATIONS' },
{ label: 'Approver', id: 'APPROVER' },
],
value: () => 'ALL_REQUESTS',

View File

@@ -43,7 +43,7 @@ export const jsmGetRequestsTool: ToolConfig<JsmGetRequestsParams, JsmGetRequests
required: false,
visibility: 'user-or-llm',
description:
'Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, APPROVER, ALL_REQUESTS',
'Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, ORGANIZATION, ALL_ORGANIZATIONS, APPROVER, ALL_REQUESTS',
},
requestStatus: {
type: 'string',