From bda9acefe272e4b6a6664b2d8b1a4a9afded9f99 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Tue, 17 Feb 2026 13:37:58 -0800 Subject: [PATCH] updated jsm and jira customers route and docs --- .../docs/en/tools/jira_service_management.mdx | 2 +- apps/sim/app/api/tools/jsm/customers/route.ts | 48 +++++++++++-------- .../blocks/blocks/jira_service_management.ts | 2 + apps/sim/tools/jsm/get_requests.ts | 2 +- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/apps/docs/content/docs/en/tools/jira_service_management.mdx b/apps/docs/content/docs/en/tools/jira_service_management.mdx index 60598d5e8..bf8548ce5 100644 --- a/apps/docs/content/docs/en/tools/jira_service_management.mdx +++ b/apps/docs/content/docs/en/tools/jira_service_management.mdx @@ -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"\) | diff --git a/apps/sim/app/api/tools/jsm/customers/route.ts b/apps/sim/app/api/tools/jsm/customers/route.ts index d1a14d3b0..46b764afb 100644 --- a/apps/sim/app/api/tools/jsm/customers/route.ts +++ b/apps/sim/app/api/tools/jsm/customers/route.ts @@ -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 = {} + 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 = { + logger.info('Adding customers to:', url, { accountIds: parsedAccountIds, - } + usernames: parsedEmails, + }) + + const requestBody: Record = {} + if (parsedAccountIds.length > 0) requestBody.accountIds = parsedAccountIds + if (parsedEmails.length > 0) requestBody.usernames = parsedEmails const response = await fetch(url, { method: 'POST', diff --git a/apps/sim/blocks/blocks/jira_service_management.ts b/apps/sim/blocks/blocks/jira_service_management.ts index 68ccfbedc..de62d7d5d 100644 --- a/apps/sim/blocks/blocks/jira_service_management.ts +++ b/apps/sim/blocks/blocks/jira_service_management.ts @@ -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', diff --git a/apps/sim/tools/jsm/get_requests.ts b/apps/sim/tools/jsm/get_requests.ts index 5aca92bd0..8c0ace69d 100644 --- a/apps/sim/tools/jsm/get_requests.ts +++ b/apps/sim/tools/jsm/get_requests.ts @@ -43,7 +43,7 @@ export const jsmGetRequestsTool: ToolConfig