Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/sim/blocks/blocks/jira_service_management.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export const JiraServiceManagementBlock: BlockConfig<JsmResponse> = {
},
{
id: 'credential',
title: 'Jira Service Management Account',
title: 'Jira Account',
type: 'oauth-input',
required: true,
serviceId: 'jira-service-management',
serviceId: 'jira',
requiredScopes: [
'read:jira-user',
'read:jira-work',
Expand Down Expand Up @@ -92,7 +92,7 @@ export const JiraServiceManagementBlock: BlockConfig<JsmResponse> = {
'read:request.approval:jira-service-management',
'write:request.approval:jira-service-management',
],
placeholder: 'Select Jira Service Management account',
placeholder: 'Select Jira account',
},
{
id: 'serviceDeskId',
Expand Down
73 changes: 5 additions & 68 deletions apps/sim/lib/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1184,70 +1184,7 @@ export const auth = betterAuth({
'delete:issue-worklog:jira',
'write:issue-link:jira',
'delete:issue-link:jira',
],
responseType: 'code',
pkce: true,
accessType: 'offline',
authentication: 'basic',
prompt: 'consent',
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/jira`,
getUserInfo: async (tokens) => {
try {
const response = await fetch('https://api.atlassian.com/me', {
headers: {
Authorization: `Bearer ${tokens.accessToken}`,
},
})

if (!response.ok) {
logger.error('Error fetching Jira user info:', {
status: response.status,
statusText: response.statusText,
})
return null
}

const profile = await response.json()

const now = new Date()

return {
id: profile.account_id,
name: profile.name || profile.display_name || 'Jira User',
email: profile.email || `${profile.account_id}@atlassian.com`,
image: profile.picture || undefined,
emailVerified: true,
createdAt: now,
updatedAt: now,
}
} catch (error) {
logger.error('Error in Jira getUserInfo:', { error })
return null
}
},
},

// Jira Service Management provider
{
providerId: 'jira-service-management',
clientId: env.JIRA_CLIENT_ID as string,
clientSecret: env.JIRA_CLIENT_SECRET as string,
authorizationUrl: 'https://auth.atlassian.com/authorize',
tokenUrl: 'https://auth.atlassian.com/oauth/token',
userInfoUrl: 'https://api.atlassian.com/me',
scopes: [
'read:jira-user',
'read:jira-work',
'write:jira-work',
'read:project:jira',
'read:me',
'offline_access',
'read:issue:jira',
'read:status:jira',
'read:user:jira',
'read:issue-details:jira',
'write:comment:jira',
'read:comment:jira',
// Jira Service Management scopes
'read:servicedesk:jira-service-management',
'read:requesttype:jira-service-management',
'read:request:jira-service-management',
Expand Down Expand Up @@ -1282,7 +1219,7 @@ export const auth = betterAuth({
accessType: 'offline',
authentication: 'basic',
prompt: 'consent',
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/jira-service-management`,
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/jira`,
getUserInfo: async (tokens) => {
try {
const response = await fetch('https://api.atlassian.com/me', {
Expand All @@ -1292,7 +1229,7 @@ export const auth = betterAuth({
})

if (!response.ok) {
logger.error('Error fetching Jira Service Management user info:', {
logger.error('Error fetching Jira user info:', {
status: response.status,
statusText: response.statusText,
})
Expand All @@ -1305,15 +1242,15 @@ export const auth = betterAuth({

return {
id: profile.account_id,
name: profile.name || profile.display_name || 'JSM User',
name: profile.name || profile.display_name || 'Jira User',
email: profile.email || `${profile.account_id}@atlassian.com`,
image: profile.picture || undefined,
emailVerified: true,
createdAt: now,
updatedAt: now,
}
} catch (error) {
logger.error('Error in Jira Service Management getUserInfo:', { error })
logger.error('Error in Jira getUserInfo:', { error })
return null
}
},
Expand Down
24 changes: 2 additions & 22 deletions apps/sim/lib/oauth/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
services: {
jira: {
name: 'Jira',
description: 'Access Jira projects and issues.',
description: 'Access Jira projects, issues, and Service Management.',
providerId: 'jira',
icon: JiraIcon,
baseProviderIcon: JiraIcon,
Expand Down Expand Up @@ -365,27 +365,7 @@ export const OAUTH_PROVIDERS: Record<string, OAuthProviderConfig> = {
'read:comment.property:jira',
'read:jql:jira',
'read:field:jira',
],
},
'jira-service-management': {
name: 'Jira Service Management',
description: 'Access Jira Service Management service desks, requests, and customers.',
providerId: 'jira-service-management',
icon: JiraIcon,
baseProviderIcon: JiraIcon,
scopes: [
'read:jira-user',
'read:jira-work',
'write:jira-work',
'read:project:jira',
'read:me',
'offline_access',
'read:issue:jira',
'read:status:jira',
'read:user:jira',
'read:issue-details:jira',
'write:comment:jira',
'read:comment:jira',
// Jira Service Management scopes
'read:servicedesk:jira-service-management',
'read:requesttype:jira-service-management',
'read:request:jira-service-management',
Expand Down
2 changes: 0 additions & 2 deletions apps/sim/lib/oauth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export type OAuthProvider =
| 'airtable'
| 'notion'
| 'jira'
| 'jira-service-management'
| 'dropbox'
| 'microsoft'
| 'microsoft-excel'
Expand Down Expand Up @@ -60,7 +59,6 @@ export type OAuthService =
| 'airtable'
| 'notion'
| 'jira'
| 'jira-service-management'
| 'dropbox'
| 'microsoft-excel'
| 'microsoft-teams'
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/add_comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmAddCommentTool: ToolConfig<JsmAddCommentParams, JsmAddCommentRes

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/add_customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmAddCustomerTool: ToolConfig<JsmAddCustomerParams, JsmAddCustomer

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/add_organization_to_service_desk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const jsmAddOrganizationToServiceDeskTool: ToolConfig<

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/add_participants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const jsmAddParticipantsTool: ToolConfig<

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/answer_approval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const jsmAnswerApprovalTool: ToolConfig<JsmAnswerApprovalParams, JsmAnswe

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/create_organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const jsmCreateOrganizationTool: ToolConfig<

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/create_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmCreateRequestTool: ToolConfig<JsmCreateRequestParams, JsmCreateR

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_approvals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmGetApprovalsTool: ToolConfig<JsmGetApprovalsParams, JsmGetApprov

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmGetCommentsTool: ToolConfig<JsmGetCommentsParams, JsmGetComments

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_customers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmGetCustomersTool: ToolConfig<JsmGetCustomersParams, JsmGetCustom

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const jsmGetOrganizationsTool: ToolConfig<

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_participants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const jsmGetParticipantsTool: ToolConfig<

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmGetQueuesTool: ToolConfig<JsmGetQueuesParams, JsmGetQueuesRespon

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmGetRequestTool: ToolConfig<JsmGetRequestParams, JsmGetRequestRes

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_request_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const jsmGetRequestTypesTool: ToolConfig<

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmGetRequestsTool: ToolConfig<JsmGetRequestsParams, JsmGetRequests

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_service_desks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const jsmGetServiceDesksTool: ToolConfig<

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_sla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const jsmGetSlaTool: ToolConfig<JsmGetSlaParams, JsmGetSlaResponse> = {

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/get_transitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const jsmGetTransitionsTool: ToolConfig<JsmGetTransitionsParams, JsmGetTr

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/jsm/transition_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const jsmTransitionRequestTool: ToolConfig<

oauth: {
required: true,
provider: 'jira-service-management',
provider: 'jira',
},

params: {
Expand Down