mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-18 10:22:00 -05:00
updated jsm and jira customers route and docs
This commit is contained in:
@@ -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"\) |
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user