Skip to content

Commit 2697da5

Browse files
authored
fix(jsm): combined jira providers for jsm (#2644)
1 parent eca9123 commit 2697da5

24 files changed

+30
-115
lines changed

apps/sim/blocks/blocks/jira_service_management.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ export const JiraServiceManagementBlock: BlockConfig<JsmResponse> = {
5252
},
5353
{
5454
id: 'credential',
55-
title: 'Jira Service Management Account',
55+
title: 'Jira Account',
5656
type: 'oauth-input',
5757
required: true,
58-
serviceId: 'jira-service-management',
58+
serviceId: 'jira',
5959
requiredScopes: [
6060
'read:jira-user',
6161
'read:jira-work',
@@ -92,7 +92,7 @@ export const JiraServiceManagementBlock: BlockConfig<JsmResponse> = {
9292
'read:request.approval:jira-service-management',
9393
'write:request.approval:jira-service-management',
9494
],
95-
placeholder: 'Select Jira Service Management account',
95+
placeholder: 'Select Jira account',
9696
},
9797
{
9898
id: 'serviceDeskId',

apps/sim/lib/auth/auth.ts

Lines changed: 5 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,70 +1184,7 @@ export const auth = betterAuth({
11841184
'delete:issue-worklog:jira',
11851185
'write:issue-link:jira',
11861186
'delete:issue-link:jira',
1187-
],
1188-
responseType: 'code',
1189-
pkce: true,
1190-
accessType: 'offline',
1191-
authentication: 'basic',
1192-
prompt: 'consent',
1193-
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/jira`,
1194-
getUserInfo: async (tokens) => {
1195-
try {
1196-
const response = await fetch('https://api.atlassian.com/me', {
1197-
headers: {
1198-
Authorization: `Bearer ${tokens.accessToken}`,
1199-
},
1200-
})
1201-
1202-
if (!response.ok) {
1203-
logger.error('Error fetching Jira user info:', {
1204-
status: response.status,
1205-
statusText: response.statusText,
1206-
})
1207-
return null
1208-
}
1209-
1210-
const profile = await response.json()
1211-
1212-
const now = new Date()
1213-
1214-
return {
1215-
id: profile.account_id,
1216-
name: profile.name || profile.display_name || 'Jira User',
1217-
email: profile.email || `${profile.account_id}@atlassian.com`,
1218-
image: profile.picture || undefined,
1219-
emailVerified: true,
1220-
createdAt: now,
1221-
updatedAt: now,
1222-
}
1223-
} catch (error) {
1224-
logger.error('Error in Jira getUserInfo:', { error })
1225-
return null
1226-
}
1227-
},
1228-
},
1229-
1230-
// Jira Service Management provider
1231-
{
1232-
providerId: 'jira-service-management',
1233-
clientId: env.JIRA_CLIENT_ID as string,
1234-
clientSecret: env.JIRA_CLIENT_SECRET as string,
1235-
authorizationUrl: 'https://auth.atlassian.com/authorize',
1236-
tokenUrl: 'https://auth.atlassian.com/oauth/token',
1237-
userInfoUrl: 'https://api.atlassian.com/me',
1238-
scopes: [
1239-
'read:jira-user',
1240-
'read:jira-work',
1241-
'write:jira-work',
1242-
'read:project:jira',
1243-
'read:me',
1244-
'offline_access',
1245-
'read:issue:jira',
1246-
'read:status:jira',
1247-
'read:user:jira',
1248-
'read:issue-details:jira',
1249-
'write:comment:jira',
1250-
'read:comment:jira',
1187+
// Jira Service Management scopes
12511188
'read:servicedesk:jira-service-management',
12521189
'read:requesttype:jira-service-management',
12531190
'read:request:jira-service-management',
@@ -1282,7 +1219,7 @@ export const auth = betterAuth({
12821219
accessType: 'offline',
12831220
authentication: 'basic',
12841221
prompt: 'consent',
1285-
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/jira-service-management`,
1222+
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/jira`,
12861223
getUserInfo: async (tokens) => {
12871224
try {
12881225
const response = await fetch('https://api.atlassian.com/me', {
@@ -1292,7 +1229,7 @@ export const auth = betterAuth({
12921229
})
12931230

12941231
if (!response.ok) {
1295-
logger.error('Error fetching Jira Service Management user info:', {
1232+
logger.error('Error fetching Jira user info:', {
12961233
status: response.status,
12971234
statusText: response.statusText,
12981235
})
@@ -1305,15 +1242,15 @@ export const auth = betterAuth({
13051242

13061243
return {
13071244
id: profile.account_id,
1308-
name: profile.name || profile.display_name || 'JSM User',
1245+
name: profile.name || profile.display_name || 'Jira User',
13091246
email: profile.email || `${profile.account_id}@atlassian.com`,
13101247
image: profile.picture || undefined,
13111248
emailVerified: true,
13121249
createdAt: now,
13131250
updatedAt: now,
13141251
}
13151252
} catch (error) {
1316-
logger.error('Error in Jira Service Management getUserInfo:', { error })
1253+
logger.error('Error in Jira getUserInfo:', { error })
13171254
return null
13181255
}
13191256
},

apps/sim/lib/oauth/oauth.ts

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
322322
services: {
323323
jira: {
324324
name: 'Jira',
325-
description: 'Access Jira projects and issues.',
325+
description: 'Access Jira projects, issues, and Service Management.',
326326
providerId: 'jira',
327327
icon: JiraIcon,
328328
baseProviderIcon: JiraIcon,
@@ -365,27 +365,7 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
365365
'read:comment.property:jira',
366366
'read:jql:jira',
367367
'read:field:jira',
368-
],
369-
},
370-
'jira-service-management': {
371-
name: 'Jira Service Management',
372-
description: 'Access Jira Service Management service desks, requests, and customers.',
373-
providerId: 'jira-service-management',
374-
icon: JiraIcon,
375-
baseProviderIcon: JiraIcon,
376-
scopes: [
377-
'read:jira-user',
378-
'read:jira-work',
379-
'write:jira-work',
380-
'read:project:jira',
381-
'read:me',
382-
'offline_access',
383-
'read:issue:jira',
384-
'read:status:jira',
385-
'read:user:jira',
386-
'read:issue-details:jira',
387-
'write:comment:jira',
388-
'read:comment:jira',
368+
// Jira Service Management scopes
389369
'read:servicedesk:jira-service-management',
390370
'read:requesttype:jira-service-management',
391371
'read:request:jira-service-management',

apps/sim/lib/oauth/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export type OAuthProvider =
1818
| 'airtable'
1919
| 'notion'
2020
| 'jira'
21-
| 'jira-service-management'
2221
| 'dropbox'
2322
| 'microsoft'
2423
| 'microsoft-excel'
@@ -60,7 +59,6 @@ export type OAuthService =
6059
| 'airtable'
6160
| 'notion'
6261
| 'jira'
63-
| 'jira-service-management'
6462
| 'dropbox'
6563
| 'microsoft-excel'
6664
| 'microsoft-teams'

apps/sim/tools/jsm/add_comment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const jsmAddCommentTool: ToolConfig<JsmAddCommentParams, JsmAddCommentRes
99

1010
oauth: {
1111
required: true,
12-
provider: 'jira-service-management',
12+
provider: 'jira',
1313
},
1414

1515
params: {

apps/sim/tools/jsm/add_customer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const jsmAddCustomerTool: ToolConfig<JsmAddCustomerParams, JsmAddCustomer
99

1010
oauth: {
1111
required: true,
12-
provider: 'jira-service-management',
12+
provider: 'jira',
1313
},
1414

1515
params: {

apps/sim/tools/jsm/add_organization_to_service_desk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const jsmAddOrganizationToServiceDeskTool: ToolConfig<
1515

1616
oauth: {
1717
required: true,
18-
provider: 'jira-service-management',
18+
provider: 'jira',
1919
},
2020

2121
params: {

apps/sim/tools/jsm/add_participants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const jsmAddParticipantsTool: ToolConfig<
1212

1313
oauth: {
1414
required: true,
15-
provider: 'jira-service-management',
15+
provider: 'jira',
1616
},
1717

1818
params: {

apps/sim/tools/jsm/answer_approval.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const jsmAnswerApprovalTool: ToolConfig<JsmAnswerApprovalParams, JsmAnswe
1010

1111
oauth: {
1212
required: true,
13-
provider: 'jira-service-management',
13+
provider: 'jira',
1414
},
1515

1616
params: {

apps/sim/tools/jsm/create_organization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const jsmCreateOrganizationTool: ToolConfig<
1212

1313
oauth: {
1414
required: true,
15-
provider: 'jira-service-management',
15+
provider: 'jira',
1616
},
1717

1818
params: {

0 commit comments

Comments
 (0)