Skip to content

Commit bda9ace

Browse files
committed
updated jsm and jira customers route and docs
1 parent f46ec3f commit bda9ace

File tree

4 files changed

+33
-21
lines changed

4 files changed

+33
-21
lines changed

apps/docs/content/docs/en/tools/jira_service_management.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ Get multiple service requests from Jira Service Management
244244
| `domain` | string | Yes | Your Jira domain \(e.g., yourcompany.atlassian.net\) |
245245
| `cloudId` | string | No | Jira Cloud ID for the instance |
246246
| `serviceDeskId` | string | No | Filter by service desk ID \(e.g., "1", "2"\) |
247-
| `requestOwnership` | string | No | Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, APPROVER, ALL_REQUESTS |
247+
| `requestOwnership` | string | No | Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, ORGANIZATION, ALL_ORGANIZATIONS, APPROVER, ALL_REQUESTS |
248248
| `requestStatus` | string | No | Filter by status: OPEN_REQUESTS, CLOSED_REQUESTS, ALL_REQUESTS |
249249
| `requestTypeId` | string | No | Filter by request type ID |
250250
| `searchTerm` | string | No | Search term to filter requests \(e.g., "password reset", "laptop"\) |

apps/sim/app/api/tools/jsm/customers/route.ts

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,26 @@ export async function POST(request: NextRequest) {
5959

6060
const { action: customerAction } = body
6161

62-
const rawIds = accountIds || emails
63-
const parsedAccountIds = rawIds
64-
? typeof rawIds === 'string'
65-
? rawIds
66-
.split(',')
67-
.map((id: string) => id.trim())
68-
.filter((id: string) => id)
69-
: Array.isArray(rawIds)
70-
? rawIds
71-
: []
72-
: []
62+
const parseList = (raw: unknown): string[] => {
63+
if (!raw) return []
64+
if (typeof raw === 'string') {
65+
return raw
66+
.split(',')
67+
.map((id: string) => id.trim())
68+
.filter((id: string) => id)
69+
}
70+
return Array.isArray(raw) ? raw : []
71+
}
72+
73+
const parsedAccountIds = parseList(accountIds)
74+
const parsedEmails = parseList(emails)
7375

7476
const isRemoveOperation = customerAction === 'remove'
75-
const isAddOperation = !isRemoveOperation && parsedAccountIds.length > 0
77+
const isAddOperation =
78+
!isRemoveOperation && (parsedAccountIds.length > 0 || parsedEmails.length > 0)
7679

7780
if (isRemoveOperation) {
78-
if (parsedAccountIds.length === 0) {
81+
if (parsedAccountIds.length === 0 && parsedEmails.length === 0) {
7982
return NextResponse.json(
8083
{ error: 'Account IDs or emails are required for removal' },
8184
{ status: 400 }
@@ -84,12 +87,16 @@ export async function POST(request: NextRequest) {
8487

8588
const url = `${baseUrl}/servicedesk/${serviceDeskId}/customer`
8689

87-
logger.info('Removing customers from:', url, { accountIds: parsedAccountIds })
90+
const removeBody: Record<string, string[]> = {}
91+
if (parsedAccountIds.length > 0) removeBody.accountIds = parsedAccountIds
92+
if (parsedEmails.length > 0) removeBody.usernames = parsedEmails
93+
94+
logger.info('Removing customers from:', url, removeBody)
8895

8996
const response = await fetch(url, {
9097
method: 'DELETE',
9198
headers: getJsmHeaders(accessToken),
92-
body: JSON.stringify({ accountIds: parsedAccountIds }),
99+
body: JSON.stringify(removeBody),
93100
})
94101

95102
if (response.status === 204 || response.ok) {
@@ -119,11 +126,14 @@ export async function POST(request: NextRequest) {
119126
if (isAddOperation) {
120127
const url = `${baseUrl}/servicedesk/${serviceDeskId}/customer`
121128

122-
logger.info('Adding customers to:', url, { accountIds: parsedAccountIds })
123-
124-
const requestBody: Record<string, unknown> = {
129+
logger.info('Adding customers to:', url, {
125130
accountIds: parsedAccountIds,
126-
}
131+
usernames: parsedEmails,
132+
})
133+
134+
const requestBody: Record<string, unknown> = {}
135+
if (parsedAccountIds.length > 0) requestBody.accountIds = parsedAccountIds
136+
if (parsedEmails.length > 0) requestBody.usernames = parsedEmails
127137

128138
const response = await fetch(url, {
129139
method: 'POST',

apps/sim/blocks/blocks/jira_service_management.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ Return ONLY the comment text - no explanations.`,
373373
{ label: 'All Requests', id: 'ALL_REQUESTS' },
374374
{ label: 'My Requests', id: 'OWNED_REQUESTS' },
375375
{ label: 'Participated', id: 'PARTICIPATED_REQUESTS' },
376+
{ label: 'Organization', id: 'ORGANIZATION' },
377+
{ label: 'All Organizations', id: 'ALL_ORGANIZATIONS' },
376378
{ label: 'Approver', id: 'APPROVER' },
377379
],
378380
value: () => 'ALL_REQUESTS',

apps/sim/tools/jsm/get_requests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const jsmGetRequestsTool: ToolConfig<JsmGetRequestsParams, JsmGetRequests
4343
required: false,
4444
visibility: 'user-or-llm',
4545
description:
46-
'Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, APPROVER, ALL_REQUESTS',
46+
'Filter by ownership: OWNED_REQUESTS, PARTICIPATED_REQUESTS, ORGANIZATION, ALL_ORGANIZATIONS, APPROVER, ALL_REQUESTS',
4747
},
4848
requestStatus: {
4949
type: 'string',

0 commit comments

Comments
 (0)