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

Function getConfluenceCloudId

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

Source from the content-addressed store, hash-verified

13}
14
15export async function getConfluenceCloudId(
16 domain: string,
17 accessToken: string,
18 retryOptions?: RetryOptions
19): Promise<string> {
20 const response = await fetchWithRetry(
21 'https://api.atlassian.com/oauth/token/accessible-resources',
22 {
23 method: 'GET',
24 headers: {
25 Authorization: `Bearer ${accessToken}`,
26 Accept: 'application/json',
27 },
28 },
29 retryOptions
30 )
31
32 const resources = await response.json()
33
34 if (!Array.isArray(resources) || resources.length === 0) {
35 throw new Error('No Confluence resources found')
36 }
37
38 const normalized = `https://${normalizeConfluenceDomainHost(domain)}`.toLowerCase()
39 const match = resources.find(
40 (r: { url: string }) => r.url.toLowerCase().replace(/\/+$/, '') === normalized
41 )
42
43 if (match) {
44 return match.id
45 }
46
47 if (resources.length === 1) {
48 return resources[0].id
49 }
50
51 throw new Error(
52 `Could not match Confluence domain "${domain}" to any accessible resource. ` +
53 `Available sites: ${resources.map((r: { url: string }) => r.url).join(', ')}`
54 )
55}
56
57function decodeHtmlEntities(text: string): string {
58 let decoded = text

Callers 15

route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90
route.tsFile · 0.90

Calls 4

fetchWithRetryFunction · 0.90
joinMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected