mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-06 21:54:01 -05:00
fix(jsm): combined jira providers for jsm (#2644)
This commit is contained in:
@@ -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',
|
||||
@@ -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',
|
||||
|
||||
@@ -1184,6 +1184,35 @@ export const auth = betterAuth({
|
||||
'delete:issue-worklog:jira',
|
||||
'write:issue-link:jira',
|
||||
'delete:issue-link:jira',
|
||||
// Jira Service Management scopes
|
||||
'read:servicedesk:jira-service-management',
|
||||
'read:requesttype:jira-service-management',
|
||||
'read:request:jira-service-management',
|
||||
'write:request:jira-service-management',
|
||||
'read:request.comment:jira-service-management',
|
||||
'write:request.comment:jira-service-management',
|
||||
'read:customer:jira-service-management',
|
||||
'write:customer:jira-service-management',
|
||||
'read:servicedesk.customer:jira-service-management',
|
||||
'write:servicedesk.customer:jira-service-management',
|
||||
'read:organization:jira-service-management',
|
||||
'write:organization:jira-service-management',
|
||||
'read:servicedesk.organization:jira-service-management',
|
||||
'write:servicedesk.organization:jira-service-management',
|
||||
'read:organization.user:jira-service-management',
|
||||
'write:organization.user:jira-service-management',
|
||||
'read:organization.property:jira-service-management',
|
||||
'write:organization.property:jira-service-management',
|
||||
'read:organization.profile:jira-service-management',
|
||||
'write:organization.profile:jira-service-management',
|
||||
'read:queue:jira-service-management',
|
||||
'read:request.sla:jira-service-management',
|
||||
'read:request.status:jira-service-management',
|
||||
'write:request.status:jira-service-management',
|
||||
'read:request.participant:jira-service-management',
|
||||
'write:request.participant:jira-service-management',
|
||||
'read:request.approval:jira-service-management',
|
||||
'write:request.approval:jira-service-management',
|
||||
],
|
||||
responseType: 'code',
|
||||
pkce: true,
|
||||
@@ -1227,98 +1256,6 @@ export const auth = betterAuth({
|
||||
},
|
||||
},
|
||||
|
||||
// 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',
|
||||
'read:servicedesk:jira-service-management',
|
||||
'read:requesttype:jira-service-management',
|
||||
'read:request:jira-service-management',
|
||||
'write:request:jira-service-management',
|
||||
'read:request.comment:jira-service-management',
|
||||
'write:request.comment:jira-service-management',
|
||||
'read:customer:jira-service-management',
|
||||
'write:customer:jira-service-management',
|
||||
'read:servicedesk.customer:jira-service-management',
|
||||
'write:servicedesk.customer:jira-service-management',
|
||||
'read:organization:jira-service-management',
|
||||
'write:organization:jira-service-management',
|
||||
'read:servicedesk.organization:jira-service-management',
|
||||
'write:servicedesk.organization:jira-service-management',
|
||||
'read:organization.user:jira-service-management',
|
||||
'write:organization.user:jira-service-management',
|
||||
'read:organization.property:jira-service-management',
|
||||
'write:organization.property:jira-service-management',
|
||||
'read:organization.profile:jira-service-management',
|
||||
'write:organization.profile:jira-service-management',
|
||||
'read:queue:jira-service-management',
|
||||
'read:request.sla:jira-service-management',
|
||||
'read:request.status:jira-service-management',
|
||||
'write:request.status:jira-service-management',
|
||||
'read:request.participant:jira-service-management',
|
||||
'write:request.participant:jira-service-management',
|
||||
'read:request.approval:jira-service-management',
|
||||
'write:request.approval:jira-service-management',
|
||||
],
|
||||
responseType: 'code',
|
||||
pkce: true,
|
||||
accessType: 'offline',
|
||||
authentication: 'basic',
|
||||
prompt: 'consent',
|
||||
redirectURI: `${getBaseUrl()}/api/auth/oauth2/callback/jira-service-management`,
|
||||
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 Service Management 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 || 'JSM 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 })
|
||||
return null
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
// Airtable provider
|
||||
{
|
||||
providerId: 'airtable',
|
||||
|
||||
@@ -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,
|
||||
@@ -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',
|
||||
|
||||
@@ -18,7 +18,6 @@ export type OAuthProvider =
|
||||
| 'airtable'
|
||||
| 'notion'
|
||||
| 'jira'
|
||||
| 'jira-service-management'
|
||||
| 'dropbox'
|
||||
| 'microsoft'
|
||||
| 'microsoft-excel'
|
||||
@@ -60,7 +59,6 @@ export type OAuthService =
|
||||
| 'airtable'
|
||||
| 'notion'
|
||||
| 'jira'
|
||||
| 'jira-service-management'
|
||||
| 'dropbox'
|
||||
| 'microsoft-excel'
|
||||
| 'microsoft-teams'
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmAddCommentTool: ToolConfig<JsmAddCommentParams, JsmAddCommentRes
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmAddCustomerTool: ToolConfig<JsmAddCustomerParams, JsmAddCustomer
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -15,7 +15,7 @@ export const jsmAddOrganizationToServiceDeskTool: ToolConfig<
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const jsmAddParticipantsTool: ToolConfig<
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -10,7 +10,7 @@ export const jsmAnswerApprovalTool: ToolConfig<JsmAnswerApprovalParams, JsmAnswe
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const jsmCreateOrganizationTool: ToolConfig<
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmCreateRequestTool: ToolConfig<JsmCreateRequestParams, JsmCreateR
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmGetApprovalsTool: ToolConfig<JsmGetApprovalsParams, JsmGetApprov
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmGetCommentsTool: ToolConfig<JsmGetCommentsParams, JsmGetComments
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmGetCustomersTool: ToolConfig<JsmGetCustomersParams, JsmGetCustom
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const jsmGetOrganizationsTool: ToolConfig<
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const jsmGetParticipantsTool: ToolConfig<
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmGetQueuesTool: ToolConfig<JsmGetQueuesParams, JsmGetQueuesRespon
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmGetRequestTool: ToolConfig<JsmGetRequestParams, JsmGetRequestRes
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const jsmGetRequestTypesTool: ToolConfig<
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmGetRequestsTool: ToolConfig<JsmGetRequestsParams, JsmGetRequests
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const jsmGetServiceDesksTool: ToolConfig<
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -9,7 +9,7 @@ export const jsmGetSlaTool: ToolConfig<JsmGetSlaParams, JsmGetSlaResponse> = {
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -10,7 +10,7 @@ export const jsmGetTransitionsTool: ToolConfig<JsmGetTransitionsParams, JsmGetTr
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
@@ -12,7 +12,7 @@ export const jsmTransitionRequestTool: ToolConfig<
|
||||
|
||||
oauth: {
|
||||
required: true,
|
||||
provider: 'jira-service-management',
|
||||
provider: 'jira',
|
||||
},
|
||||
|
||||
params: {
|
||||
|
||||
Reference in New Issue
Block a user