MCPcopy Index your code
hub / github.com/simstudioai/sim / getJiraCloudId

Function getJiraCloudId

apps/sim/tools/jira/utils.ts:170–215  ·  view source on GitHub ↗
(
  domain: string,
  accessToken: string,
  retryOptions?: RetryOptions
)

Source from the content-addressed store, hash-verified

168}
169
170export async function getJiraCloudId(
171 domain: string,
172 accessToken: string,
173 retryOptions?: RetryOptions
174): Promise<string> {
175 const response = await fetchWithRetry(
176 'https://api.atlassian.com/oauth/token/accessible-resources',
177 {
178 method: 'GET',
179 headers: {
180 Authorization: `Bearer ${accessToken}`,
181 Accept: 'application/json',
182 },
183 },
184 retryOptions
185 )
186
187 if (!response.ok) {
188 const errorText = await response.text()
189 throw new Error(`Failed to fetch Jira accessible resources: ${response.status} - ${errorText}`)
190 }
191
192 const resources = await response.json()
193
194 if (!Array.isArray(resources) || resources.length === 0) {
195 throw new Error('No Jira resources found')
196 }
197
198 const normalized = normalizeDomain(domain)
199 const match = resources.find(
200 (r: { url: string }) => r.url.toLowerCase().replace(/\/+$/, '') === normalized
201 )
202
203 if (match) {
204 return match.id
205 }
206
207 if (resources.length === 1) {
208 return resources[0].id
209 }
210
211 throw new Error(
212 `Could not match Jira domain "${domain}" to any accessible resource. ` +
213 `Available sites: ${resources.map((r: { url: string }) => r.url).join(', ')}`
214 )
215}
216
217/**
218 * Parse error messages from Atlassian API responses (Jira, JSM, Confluence).

Callers 15

resolveAssetsContextFunction · 0.90
add_comment.tsFile · 0.90
get_users.tsFile · 0.90
get_transitions.tsFile · 0.90
update_comment.tsFile · 0.90
get_comments.tsFile · 0.90
assign_issue.tsFile · 0.90
update_worklog.tsFile · 0.90
retrieve.tsFile · 0.90

Calls 5

fetchWithRetryFunction · 0.90
textMethod · 0.80
joinMethod · 0.80
normalizeDomainFunction · 0.70
replaceMethod · 0.65

Tested by

no test coverage detected