@gitkraken/core-gitlens 0.28.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/dist/git/cache.d.ts +39 -1
  3. package/dist/git/cache.js +108 -7
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/providers/branches.d.ts +17 -12
  6. package/dist/git/providers/revision.d.ts +4 -0
  7. package/dist/git/watching/worktreeSummary.d.ts +16 -7
  8. package/dist/git/watching/worktreeSummary.js +44 -14
  9. package/dist/git/watching/worktreeSummary.js.map +1 -1
  10. package/dist/git-cli/cliGitProvider.js +3 -3
  11. package/dist/git-cli/cliGitProvider.js.map +1 -1
  12. package/dist/git-cli/exec/exec.d.ts +2 -2
  13. package/dist/git-cli/exec/exec.js +2 -2
  14. package/dist/git-cli/exec/gitDirResolver.d.ts +6 -1
  15. package/dist/git-cli/exec/gitDirResolver.js +9 -4
  16. package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
  17. package/dist/git-cli/providers/branches.d.ts +91 -13
  18. package/dist/git-cli/providers/branches.js +673 -176
  19. package/dist/git-cli/providers/branches.js.map +1 -1
  20. package/dist/git-cli/providers/config.js +1 -1
  21. package/dist/git-cli/providers/config.js.map +1 -1
  22. package/dist/git-cli/providers/revision.d.ts +4 -0
  23. package/dist/git-cli/providers/revision.js +64 -3
  24. package/dist/git-cli/providers/revision.js.map +1 -1
  25. package/dist/ipc/ipcServer.d.ts +6 -1
  26. package/dist/ipc/ipcServer.js +15 -6
  27. package/dist/ipc/ipcServer.js.map +1 -1
  28. package/dist/plus/ai/errors.js +4 -4
  29. package/dist/plus/ai/errors.js.map +1 -1
  30. package/dist/plus/ai/models/model.d.ts +1 -1
  31. package/dist/plus/ai/models/model.js.map +1 -1
  32. package/dist/plus/ai/models/promptTemplates.d.ts +45 -2
  33. package/dist/plus/ai/models/results.d.ts +41 -0
  34. package/dist/plus/ai/models/results.js +14 -0
  35. package/dist/plus/ai/models/results.js.map +1 -0
  36. package/dist/plus/ai/prompts.d.ts +6 -0
  37. package/dist/plus/ai/prompts.js +255 -5
  38. package/dist/plus/ai/prompts.js.map +1 -1
  39. package/dist/plus/ai/providers/gitkrakenProvider.js +2 -2
  40. package/dist/plus/ai/providers/gitkrakenProvider.js.map +1 -1
  41. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -0
  42. package/dist/plus/ai/providers/openAICompatibleProviderBase.js.map +1 -1
  43. package/dist/plus/ai/utils/ai.utils.d.ts +4 -0
  44. package/dist/plus/ai/utils/ai.utils.js +8 -1
  45. package/dist/plus/ai/utils/ai.utils.js.map +1 -1
  46. package/dist/plus/ai/utils/results.utils.d.ts +15 -1
  47. package/dist/plus/ai/utils/results.utils.js +80 -4
  48. package/dist/plus/ai/utils/results.utils.js.map +1 -1
  49. package/dist/plus/integrations/authentication/integrationAuthenticationService.js +2 -0
  50. package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
  51. package/dist/plus/integrations/authentication/models.d.ts +1 -1
  52. package/dist/plus/integrations/authentication/models.js +2 -0
  53. package/dist/plus/integrations/authentication/models.js.map +1 -1
  54. package/dist/plus/integrations/constants.d.ts +2 -1
  55. package/dist/plus/integrations/constants.js +12 -2
  56. package/dist/plus/integrations/constants.js.map +1 -1
  57. package/dist/plus/integrations/fieldPresence.js +17 -1
  58. package/dist/plus/integrations/fieldPresence.js.map +1 -1
  59. package/dist/plus/integrations/integrationService.d.ts +1 -1
  60. package/dist/plus/integrations/integrationService.js +8 -2
  61. package/dist/plus/integrations/integrationService.js.map +1 -1
  62. package/dist/plus/integrations/lite.js +5 -6
  63. package/dist/plus/integrations/lite.js.map +1 -1
  64. package/dist/plus/integrations/models/gitHostIntegration.d.ts +11 -1
  65. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  66. package/dist/plus/integrations/providers/asana.d.ts +91 -0
  67. package/dist/plus/integrations/providers/asana.js +344 -0
  68. package/dist/plus/integrations/providers/asana.js.map +1 -0
  69. package/dist/plus/integrations/providers/azure/azure.js +3 -2
  70. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  71. package/dist/plus/integrations/providers/azure/models.js +3 -2
  72. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  73. package/dist/plus/integrations/providers/azureDevOps.d.ts +7 -1
  74. package/dist/plus/integrations/providers/azureDevOps.js +9 -1
  75. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  76. package/dist/plus/integrations/providers/bitbucket-server/discovery.js +2 -1
  77. package/dist/plus/integrations/providers/bitbucket-server/discovery.js.map +1 -1
  78. package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
  79. package/dist/plus/integrations/providers/github.d.ts +2 -2
  80. package/dist/plus/integrations/providers/github.js +2 -2
  81. package/dist/plus/integrations/providers/github.js.map +1 -1
  82. package/dist/plus/integrations/providers/issueSorts.d.ts +5 -0
  83. package/dist/plus/integrations/providers/issueSorts.js +6 -1
  84. package/dist/plus/integrations/providers/issueSorts.js.map +1 -1
  85. package/dist/plus/integrations/providers/jiraIssueByKey.js +2 -1
  86. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  87. package/dist/plus/integrations/providers/models.d.ts +19 -3
  88. package/dist/plus/integrations/providers/models.js +12 -1
  89. package/dist/plus/integrations/providers/models.js.map +1 -1
  90. package/dist/plus/integrations/providers/providerApiClient.d.ts +0 -3
  91. package/dist/plus/integrations/providers/providerApiClient.js +1 -3
  92. package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
  93. package/dist/plus/integrations/providers/providersApi.d.ts +22 -1
  94. package/dist/plus/integrations/providers/providersApi.js +63 -12
  95. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  96. package/dist/plus/integrations/providers/utils.d.ts +1 -0
  97. package/dist/plus/integrations/providers/utils.js +8 -2
  98. package/dist/plus/integrations/providers/utils.js.map +1 -1
  99. package/dist/plus/integrations/reads/hierarchy.utils.d.ts +3 -3
  100. package/dist/plus/integrations/reads/hierarchy.utils.js +4 -4
  101. package/dist/plus/integrations/reads/hierarchy.utils.js.map +1 -1
  102. package/dist/plus/integrations/reads/resolveRepository.js +29 -21
  103. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  104. package/dist/plus/integrations/results.d.ts +18 -10
  105. package/dist/plus/integrations/results.js.map +1 -1
  106. package/dist/plus/integrations/utils/domain.utils.js +2 -1
  107. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  108. package/dist/plus/integrations/utils/integration.utils.js +5 -13
  109. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  110. package/dist/utils/diff.d.ts +19 -0
  111. package/dist/utils/diff.js +121 -3
  112. package/dist/utils/diff.js.map +1 -1
  113. package/dist/utils/env/node/exec.d.ts +0 -1
  114. package/dist/utils/env/node/exec.js +2 -14
  115. package/dist/utils/env/node/exec.js.map +1 -1
  116. package/dist/utils/path.d.ts +2 -0
  117. package/dist/utils/path.js +7 -1
  118. package/dist/utils/path.js.map +1 -1
  119. package/docs/integrations.md +72 -43
  120. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"results.utils.js","names":[],"sources":["../../../../../plus/ai/src/utils/results.utils.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type {\n\tAIReviewDetailResult,\n\tAIReviewFinding,\n\tAIReviewFocusArea,\n\tAIReviewResult,\n\tAIReviewSeverity,\n} from '../models/results.js';\n\nconst summaryTagRegex = /<summary>([\\s\\S]*?)(?:<\\/summary>|$)/;\nconst bodyTagRegex = /<body>([\\s\\S]*?)(?:<\\/body>|$)/;\nconst codeBlockRegex = /```([\\s\\S]*?)```/;\n\nexport function parseSummarizeResult(result: string): { readonly summary: string; readonly body: string } {\n\tresult = result.trim();\n\tconst summary = result.match(summaryTagRegex)?.[1]?.trim() ?? undefined;\n\tif (summary != null) {\n\t\tresult = result.replace(summaryTagRegex, '').trim();\n\t}\n\n\tlet body = result.match(bodyTagRegex)?.[1]?.trim() ?? undefined;\n\tif (body != null) {\n\t\tresult = result.replace(bodyTagRegex, '').trim();\n\t}\n\n\t// Check for self-closing body tag\n\tif (body == null && result.includes('<body/>')) {\n\t\tbody = '';\n\t}\n\n\t// If both tags are present, return them\n\tif (summary != null && body != null) return { summary: summary, body: body };\n\n\t// If both tags are missing, split the result\n\tif (summary == null && body == null) return splitMessageIntoSummaryAndBody(result);\n\n\t// If only summary tag is present, use any remaining text as the body\n\tif (summary && body == null) {\n\t\treturn result ? { summary: summary, body: result } : splitMessageIntoSummaryAndBody(summary);\n\t}\n\n\t// If only body tag is present, use the remaining text as the summary\n\tif (summary == null && body) {\n\t\treturn result ? { summary: result, body: body } : splitMessageIntoSummaryAndBody(body);\n\t}\n\n\treturn { summary: summary ?? '', body: body ?? '' };\n}\n\nexport function splitMessageIntoSummaryAndBody(message: string): { readonly summary: string; readonly body: string } {\n\tmessage = message.replace(codeBlockRegex, '$1').trim();\n\tconst index = message.indexOf('\\n');\n\tif (index === -1) return { summary: message, body: '' };\n\n\treturn {\n\t\tsummary: message.substring(0, index).trim(),\n\t\tbody: message.substring(index + 1).trim(),\n\t};\n}\n\nconst overviewTagRegex = /<overview>([\\s\\S]*?)(?:<\\/overview>|$)/;\nconst areaTagRegex = /<area\\s+([^>]*)>([\\s\\S]*?)(?:<\\/area>|$)/g;\nconst findingTagRegex = /<finding\\s+([^>]*)>([\\s\\S]*?)(?:<\\/finding>|$)/g;\nconst labelTagRegex = /<label>([\\s\\S]*?)(?:<\\/label>|$)/;\nconst rationaleTagRegex = /<rationale>([\\s\\S]*?)(?:<\\/rationale>|$)/;\nconst titleTagRegex = /<title>([\\s\\S]*?)(?:<\\/title>|$)/;\nconst descriptionTagRegex = /<description>([\\s\\S]*?)(?:<\\/description>|$)/;\nconst findingsBlockRegex = /<findings>([\\s\\S]*?)(?:<\\/findings>|$)/;\n\nfunction parseAttr(attrs: string, name: string): string | undefined {\n\tconst match = new RegExp(`${name}=\"([^\"]*)\"`, 'i').exec(attrs);\n\treturn match?.[1]?.trim() || undefined;\n}\n\nfunction parseSeverity(value: string | undefined): AIReviewSeverity {\n\tif (value === 'critical' || value === 'warning' || value === 'suggestion') return value;\n\treturn 'suggestion';\n}\n\n/** Shared range policy for the XML and JSON parse routes: no usable start → no range; a missing\n * or unusable end collapses to start */\nfunction normalizeLineRange(\n\tstart: number | undefined,\n\tend: number | undefined,\n): { start: number; end: number } | undefined {\n\tif (start == null || !Number.isFinite(start)) return undefined;\n\n\t// Truncate and clamp — prompt-only providers can emit fractional or reversed bounds\n\tstart = Math.trunc(start);\n\tconst resolved = end != null && Number.isFinite(end) ? Math.trunc(end) : start;\n\treturn { start: start, end: Math.max(start, resolved) };\n}\n\nfunction parseLineRange(value: string | undefined): { start: number; end: number } | undefined {\n\tif (!value) return undefined;\n\n\tconst parts = value.split('-');\n\treturn normalizeLineRange(parseInt(parts[0], 10), parts.length > 1 ? parseInt(parts[1], 10) : undefined);\n}\n\nfunction parseFindings(content: string, idPrefix: string): AIReviewFinding[] {\n\tconst findings: AIReviewFinding[] = [];\n\tlet findingIndex = 0;\n\n\tfor (const match of content.matchAll(findingTagRegex)) {\n\t\tconst attrs = match[1];\n\t\tconst inner = match[2];\n\t\tfindingIndex++;\n\t\tconst title = inner.match(titleTagRegex)?.[1]?.trim();\n\n\t\tfindings.push({\n\t\t\tid: `${idPrefix}-f${findingIndex}`,\n\t\t\tseverity: parseSeverity(parseAttr(attrs, 'severity')),\n\t\t\ttitle: title ?? 'Untitled finding',\n\t\t\t...(title == null ? { titleIsFallback: true } : {}),\n\t\t\tdescription: inner.match(descriptionTagRegex)?.[1]?.trim() ?? '',\n\t\t\tfilePath: parseAttr(attrs, 'file'),\n\t\t\tlineRange: parseLineRange(parseAttr(attrs, 'lines')),\n\t\t});\n\t}\n\n\treturn findings;\n}\n\nexport function parseReviewResult(result: string, mode: 'single-pass' | 'two-pass'): AIReviewResult {\n\tresult = result.trim();\n\n\tconst overview = result.match(overviewTagRegex)?.[1]?.trim() ?? '';\n\n\tconst focusAreas: AIReviewFocusArea[] = [];\n\tlet areaIndex = 0;\n\n\tfor (const match of result.matchAll(areaTagRegex)) {\n\t\tconst attrs = match[1];\n\t\tconst inner = match[2];\n\t\tareaIndex++;\n\n\t\tconst id = `area-${areaIndex}`;\n\t\tconst filesAttr = parseAttr(attrs, 'files');\n\t\tconst label = inner.match(labelTagRegex)?.[1]?.trim();\n\n\t\tconst findingsBlock = inner.match(findingsBlockRegex)?.[1];\n\t\tconst findings = findingsBlock ? parseFindings(findingsBlock, id) : undefined;\n\n\t\tfocusAreas.push({\n\t\t\tid: id,\n\t\t\tlabel: label ?? 'Untitled area',\n\t\t\t...(label == null ? { labelIsFallback: true } : {}),\n\t\t\trationale: inner.match(rationaleTagRegex)?.[1]?.trim() ?? '',\n\t\t\tseverity: parseSeverity(parseAttr(attrs, 'severity')),\n\t\t\tfiles: filesAttr?.split(',').map(f => f.trim()) ?? [],\n\t\t\tfindings: findings,\n\t\t});\n\t}\n\n\treturn { overview: overview, focusAreas: focusAreas, mode: mode };\n}\n\nfunction serializeFindingJson(finding: AIReviewFinding): ReviewFindingJson {\n\treturn {\n\t\tseverity: finding.severity,\n\t\ttitle: finding.title,\n\t\tdescription: finding.description,\n\t\tfile: finding.filePath ?? null,\n\t\tlines: finding.lineRange != null ? { start: finding.lineRange.start, end: finding.lineRange.end } : null,\n\t};\n}\n\n/** Inverse of {@link parseReviewResultJson} — emits the same JSON shape the review prompt templates\n * instruct (and the schemas enforce), so a prior result can be replayed as an assistant turn in a\n * follow-up conversation without contradicting the format the model is being asked to produce. */\nexport function serializeReviewResult(result: AIReviewResult): string {\n\tconst json: ReviewResultJson = {\n\t\toverview: result.overview,\n\t\tfocusAreas: result.focusAreas.map(area => ({\n\t\t\tlabel: area.label,\n\t\t\trationale: area.rationale,\n\t\t\tseverity: area.severity,\n\t\t\tfiles: [...area.files],\n\t\t\tfindings: area.findings?.map(serializeFindingJson) ?? null,\n\t\t})),\n\t};\n\n\treturn JSON.stringify(json, undefined, 2);\n}\n\nexport function parseReviewDetailResult(result: string, focusAreaId: string): AIReviewDetailResult {\n\tresult = result.trim();\n\n\tconst findingsBlock = result.match(findingsBlockRegex)?.[1] ?? result;\n\tconst findings = parseFindings(findingsBlock, focusAreaId);\n\n\treturn { findings: findings };\n}\n\ninterface ReviewFindingJson {\n\tseverity?: string;\n\ttitle?: string;\n\tdescription?: string;\n\tfile?: string | null;\n\tlines?: { start?: number; end?: number } | null;\n}\n\ninterface ReviewResultJson {\n\toverview?: string;\n\tfocusAreas?:\n\t\t| {\n\t\t\t\tlabel?: string;\n\t\t\t\trationale?: string;\n\t\t\t\tseverity?: string;\n\t\t\t\tfiles?: (string | null)[] | null;\n\t\t\t\tfindings?: ReviewFindingJson[] | null;\n\t\t }[]\n\t\t| null;\n}\n\nconst fencedJsonBlockRegex = /```(?:json)?\\s*([\\s\\S]*?)\\s*```/;\n\n/** Returns the contents of the first fenced code block, or the trimmed input when unfenced */\nexport function stripJsonCodeFence(text: string): string {\n\tconst fenced = fencedJsonBlockRegex.exec(text);\n\treturn (fenced?.[1] ?? text).trim();\n}\n\n/**\n * Extracts the first JSON object from the text — tolerating code fences and surrounding prose,\n * since providers without native schema enforcement often wrap the object in explanatory text.\n * Pass `isExpectedShape` so prose braces and stray JSON fragments (including complete nested\n * objects inside truncated output) can't be mistaken for the payload.\n */\nexport function extractJsonObject(\n\ttext: string,\n\tisExpectedShape?: (parsed: Record<string, unknown>) => boolean,\n): Record<string, unknown> | undefined {\n\ttext = text.trim();\n\n\tlet parsed = tryParseObject(text, isExpectedShape);\n\tif (parsed != null) return parsed;\n\n\tparsed = tryParseObject(stripJsonCodeFence(text), isExpectedShape);\n\tif (parsed != null) return parsed;\n\n\t// Fall back to balanced objects embedded in surrounding prose, trying each candidate start —\n\t// prose braces may be unbalanced (`render() {`) or parse to a different shape than expected\n\tlet index = text.indexOf('{');\n\twhile (index !== -1) {\n\t\tconst balanced = extractBalancedObject(text, index);\n\t\tif (balanced != null) {\n\t\t\tparsed = tryParseObject(balanced, isExpectedShape);\n\t\t\tif (parsed != null) return parsed;\n\t\t}\n\n\t\tindex = text.indexOf('{', index + 1);\n\t}\n\n\treturn undefined;\n}\n\nfunction tryParseObject(\n\ttext: string,\n\tisExpectedShape?: (parsed: Record<string, unknown>) => boolean,\n): Record<string, unknown> | undefined {\n\tif (!text.startsWith('{')) return undefined;\n\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(text);\n\t\tif (typeof parsed !== 'object' || parsed == null || Array.isArray(parsed)) return undefined;\n\n\t\tconst obj = parsed as Record<string, unknown>;\n\t\treturn isExpectedShape == null || isExpectedShape(obj) ? obj : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction extractBalancedObject(text: string, start: number): string | undefined {\n\tlet depth = 0;\n\tlet inString = false;\n\tlet escaped = false;\n\n\tfor (let i = start; i < text.length; i++) {\n\t\tconst ch = text[i];\n\t\tif (escaped) {\n\t\t\tescaped = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (ch === '\\\\') {\n\t\t\t\tescaped = true;\n\t\t\t} else if (ch === '\"') {\n\t\t\t\tinString = false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (ch === '\"') {\n\t\t\tinString = true;\n\t\t} else if (ch === '{') {\n\t\t\tdepth++;\n\t\t} else if (ch === '}') {\n\t\t\tdepth--;\n\t\t\tif (depth === 0) return text.substring(start, i + 1);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/** Guards schema-typed string fields against non-string values from prompt-only providers */\nfunction trimmedString(value: unknown): string | undefined {\n\treturn typeof value === 'string' ? value.trim() : undefined;\n}\n\n/** Line numbers are integers per the schema, but prompt-only providers can emit numeric strings */\nfunction coerceLineNumber(value: unknown): number | undefined {\n\tif (typeof value === 'number') return value;\n\tif (typeof value === 'string') return parseInt(value, 10);\n\treturn undefined;\n}\n\n// Normalizes schema null-unions (null → undefined) and synthesizes the same 1-based positional ids\n// as the XML parsers, so ids stay stable regardless of which parse route handled the response\nfunction normalizeFindingJson(finding: ReviewFindingJson, id: string): AIReviewFinding {\n\tconst title = trimmedString(finding.title);\n\treturn {\n\t\tid: id,\n\t\tseverity: parseSeverity(trimmedString(finding.severity)),\n\t\ttitle: title || 'Untitled finding',\n\t\t...(!title ? { titleIsFallback: true } : {}),\n\t\tdescription: trimmedString(finding.description) ?? '',\n\t\tfilePath: trimmedString(finding.file) || undefined,\n\t\tlineRange: normalizeLineRange(coerceLineNumber(finding.lines?.start), coerceLineNumber(finding.lines?.end)),\n\t};\n}\n\n/** Parses a review result, preferring the JSON shape and falling back to the legacy XML format */\nexport function parseReviewResultJson(result: string, mode: 'single-pass' | 'two-pass'): AIReviewResult {\n\t// An empty response is never a valid review — don't render it as a clean \"no issues\" result\n\tif (!result.trim()) throw new Error(l10n.t('The AI model returned an empty response'));\n\n\tconst parsed = extractJsonObject(result, o => typeof o.overview === 'string' || Array.isArray(o.focusAreas)) as\n\t\t| ReviewResultJson\n\t\t| undefined;\n\tconst overview = typeof parsed?.overview === 'string' ? parsed.overview.trim() : undefined;\n\tconst areas = Array.isArray(parsed?.focusAreas) ? parsed.focusAreas : undefined;\n\n\tif (overview == null && areas == null) {\n\t\tconst fallback = parseReviewResult(result, mode);\n\t\t// A non-empty response matching neither shape is malformed (e.g. truncated JSON) — surface\n\t\t// that rather than rendering it as a clean \"no issues\" review\n\t\tif (!fallback.overview && fallback.focusAreas.length === 0 && !result.includes('<overview')) {\n\t\t\tthrow new Error(l10n.t('Unable to parse the review response from the AI model'));\n\t\t}\n\t\treturn fallback;\n\t}\n\n\tconst focusAreas: AIReviewFocusArea[] = [];\n\tlet areaIndex = 0;\n\n\tfor (const area of areas ?? []) {\n\t\tif (area == null || typeof area !== 'object') continue;\n\n\t\tareaIndex++;\n\t\tconst label = trimmedString(area.label);\n\t\t// Finding ids MUST stay namespaced by area id — dismissed findings are tracked in one flat\n\t\t// set spanning all areas, so bare per-area indices would collide across areas\n\t\tconst id = `area-${areaIndex}`;\n\n\t\tconst findings = Array.isArray(area.findings)\n\t\t\t? area.findings.filter((f): f is ReviewFindingJson => f != null && typeof f === 'object')\n\t\t\t: undefined;\n\n\t\tfocusAreas.push({\n\t\t\tid: id,\n\t\t\tlabel: label || 'Untitled area',\n\t\t\t...(!label ? { labelIsFallback: true } : {}),\n\t\t\trationale: trimmedString(area.rationale) ?? '',\n\t\t\tseverity: parseSeverity(trimmedString(area.severity)),\n\t\t\tfiles: Array.isArray(area.files)\n\t\t\t\t? area.files.map(f => trimmedString(f)).filter((f): f is string => Boolean(f))\n\t\t\t\t: [],\n\t\t\tfindings: findings?.map((f, i) => normalizeFindingJson(f, `${id}-f${i + 1}`)),\n\t\t});\n\t}\n\n\treturn { overview: overview ?? '', focusAreas: focusAreas, mode: mode };\n}\n\n/** Parses a review detail result, preferring the JSON shape and falling back to the legacy XML format */\nexport function parseReviewDetailResultJson(result: string, focusAreaId: string): AIReviewDetailResult {\n\t// An empty response is never a valid result — don't render it as \"no findings\"\n\tif (!result.trim()) throw new Error(l10n.t('The AI model returned an empty response'));\n\n\tconst parsed = extractJsonObject(result, o => o.findings === null || Array.isArray(o.findings)) as\n\t\t| { findings?: ReviewFindingJson[] | null }\n\t\t| undefined;\n\t// Tolerate the sibling result schema's null-union — a null `findings` means \"no findings\"\n\tif (parsed?.findings === null) return { findings: [] };\n\n\tif (parsed == null || !Array.isArray(parsed.findings)) {\n\t\tconst fallback = parseReviewDetailResult(result, focusAreaId);\n\t\t// Same malformed-response guard as parseReviewResultJson above; an empty legacy\n\t\t// `<findings>` block is a legitimate \"no findings\" response, not a parse failure\n\t\tif (fallback.findings.length === 0 && !result.includes('<findings')) {\n\t\t\tthrow new Error(l10n.t('Unable to parse the review response from the AI model'));\n\t\t}\n\t\treturn fallback;\n\t}\n\n\treturn {\n\t\tfindings: parsed.findings\n\t\t\t.filter((f): f is ReviewFindingJson => f != null && typeof f === 'object')\n\t\t\t.map((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K,IAC5B,KAAK,MAAM,KAAI,MAAK,cAAc,CAAC,CAAC,CAAC,CAAC,QAAQ,MAAmB,QAAQ,CAAC,CAAC,IAC3E,CAAC;GACJ,UAAU,UAAU,KAAK,GAAG,MAAM,qBAAqB,GAAG,GAAG,GAAG,IAAI,IAAI,GAAG,CAAC;EAC7E,CAAC;CACF;CAEA,OAAO;EAAE,UAAU,YAAY;EAAgB;EAAkB;CAAK;AACvE;;AAGA,SAAgB,4BAA4B,QAAgB,aAA2C;CAEtG,IAAI,CAAC,OAAO,KAAK,GAAG,MAAM,IAAI,MAAM,KAAK,EAAE,yCAAyC,CAAC;CAErF,MAAM,SAAS,kBAAkB,SAAQ,MAAK,EAAE,aAAa,QAAQ,MAAM,QAAQ,EAAE,QAAQ,CAAC;CAI9F,IAAI,QAAQ,aAAa,MAAM,OAAO,EAAE,UAAU,CAAC,EAAE;CAErD,IAAI,UAAU,QAAQ,CAAC,MAAM,QAAQ,OAAO,QAAQ,GAAG;EACtD,MAAM,WAAW,wBAAwB,QAAQ,WAAW;EAG5D,IAAI,SAAS,SAAS,WAAW,KAAK,CAAC,OAAO,SAAS,WAAW,GACjE,MAAM,IAAI,MAAM,KAAK,EAAE,uDAAuD,CAAC;EAEhF,OAAO;CACR;CAEA,OAAO,EACN,UAAU,OAAO,SACf,QAAQ,MAA8B,KAAK,QAAQ,OAAO,MAAM,QAAQ,CAAC,CACzE,KAAK,GAAG,MAAM,qBAAqB,GAAG,GAAG,YAAY,IAAI,IAAI,GAAG,CAAC,EACpE;AACD"}
1
+ {"version":3,"file":"results.utils.js","names":[],"sources":["../../../../../plus/ai/src/utils/results.utils.ts"],"sourcesContent":["import * as l10n from '@vscode/l10n';\nimport type {\n\tAIReviewDetailResult,\n\tAIReviewFinding,\n\tAIReviewFindingLocation,\n\tAIReviewFocusArea,\n\tAIReviewOrientFile,\n\tAIReviewOrientGroup,\n\tAIReviewOrientGroupKind,\n\tAIReviewOrientResult,\n\tAIReviewResult,\n\tAIReviewSeverity,\n} from '../models/results.js';\n\nconst summaryTagRegex = /<summary>([\\s\\S]*?)(?:<\\/summary>|$)/;\nconst bodyTagRegex = /<body>([\\s\\S]*?)(?:<\\/body>|$)/;\nconst codeBlockRegex = /```([\\s\\S]*?)```/;\n\nexport function parseSummarizeResult(result: string): { readonly summary: string; readonly body: string } {\n\tresult = result.trim();\n\tconst summary = result.match(summaryTagRegex)?.[1]?.trim() ?? undefined;\n\tif (summary != null) {\n\t\tresult = result.replace(summaryTagRegex, '').trim();\n\t}\n\n\tlet body = result.match(bodyTagRegex)?.[1]?.trim() ?? undefined;\n\tif (body != null) {\n\t\tresult = result.replace(bodyTagRegex, '').trim();\n\t}\n\n\t// Check for self-closing body tag\n\tif (body == null && result.includes('<body/>')) {\n\t\tbody = '';\n\t}\n\n\t// If both tags are present, return them\n\tif (summary != null && body != null) return { summary: summary, body: body };\n\n\t// If both tags are missing, split the result\n\tif (summary == null && body == null) return splitMessageIntoSummaryAndBody(result);\n\n\t// If only summary tag is present, use any remaining text as the body\n\tif (summary && body == null) {\n\t\treturn result ? { summary: summary, body: result } : splitMessageIntoSummaryAndBody(summary);\n\t}\n\n\t// If only body tag is present, use the remaining text as the summary\n\tif (summary == null && body) {\n\t\treturn result ? { summary: result, body: body } : splitMessageIntoSummaryAndBody(body);\n\t}\n\n\treturn { summary: summary ?? '', body: body ?? '' };\n}\n\nexport function splitMessageIntoSummaryAndBody(message: string): { readonly summary: string; readonly body: string } {\n\tmessage = message.replace(codeBlockRegex, '$1').trim();\n\tconst index = message.indexOf('\\n');\n\tif (index === -1) return { summary: message, body: '' };\n\n\treturn {\n\t\tsummary: message.substring(0, index).trim(),\n\t\tbody: message.substring(index + 1).trim(),\n\t};\n}\n\nconst overviewTagRegex = /<overview>([\\s\\S]*?)(?:<\\/overview>|$)/;\nconst areaTagRegex = /<area\\s+([^>]*)>([\\s\\S]*?)(?:<\\/area>|$)/g;\nconst findingTagRegex = /<finding\\s+([^>]*)>([\\s\\S]*?)(?:<\\/finding>|$)/g;\nconst labelTagRegex = /<label>([\\s\\S]*?)(?:<\\/label>|$)/;\nconst rationaleTagRegex = /<rationale>([\\s\\S]*?)(?:<\\/rationale>|$)/;\nconst titleTagRegex = /<title>([\\s\\S]*?)(?:<\\/title>|$)/;\nconst descriptionTagRegex = /<description>([\\s\\S]*?)(?:<\\/description>|$)/;\nconst findingsBlockRegex = /<findings>([\\s\\S]*?)(?:<\\/findings>|$)/;\n\nfunction parseAttr(attrs: string, name: string): string | undefined {\n\tconst match = new RegExp(`${name}=\"([^\"]*)\"`, 'i').exec(attrs);\n\treturn match?.[1]?.trim() || undefined;\n}\n\nfunction parseSeverity(value: string | undefined): AIReviewSeverity {\n\tif (value === 'critical' || value === 'warning' || value === 'suggestion') return value;\n\treturn 'suggestion';\n}\n\n/** Shared range policy for the XML and JSON parse routes: no usable start → no range; a missing\n * or unusable end collapses to start */\nfunction normalizeLineRange(\n\tstart: number | undefined,\n\tend: number | undefined,\n): { start: number; end: number } | undefined {\n\tif (start == null || !Number.isFinite(start)) return undefined;\n\n\t// Truncate and clamp — prompt-only providers can emit fractional or reversed bounds\n\tstart = Math.trunc(start);\n\tconst resolved = end != null && Number.isFinite(end) ? Math.trunc(end) : start;\n\treturn { start: start, end: Math.max(start, resolved) };\n}\n\nfunction parseLineRange(value: string | undefined): { start: number; end: number } | undefined {\n\tif (!value) return undefined;\n\n\tconst parts = value.split('-');\n\treturn normalizeLineRange(parseInt(parts[0], 10), parts.length > 1 ? parseInt(parts[1], 10) : undefined);\n}\n\nfunction parseFindings(content: string, idPrefix: string): AIReviewFinding[] {\n\tconst findings: AIReviewFinding[] = [];\n\tlet findingIndex = 0;\n\n\tfor (const match of content.matchAll(findingTagRegex)) {\n\t\tconst attrs = match[1];\n\t\tconst inner = match[2];\n\t\tfindingIndex++;\n\t\tconst title = inner.match(titleTagRegex)?.[1]?.trim();\n\n\t\tfindings.push({\n\t\t\tid: `${idPrefix}-f${findingIndex}`,\n\t\t\tseverity: parseSeverity(parseAttr(attrs, 'severity')),\n\t\t\ttitle: title ?? 'Untitled finding',\n\t\t\t...(title == null ? { titleIsFallback: true } : {}),\n\t\t\tdescription: inner.match(descriptionTagRegex)?.[1]?.trim() ?? '',\n\t\t\tfilePath: parseAttr(attrs, 'file'),\n\t\t\tlineRange: parseLineRange(parseAttr(attrs, 'lines')),\n\t\t});\n\t}\n\n\treturn findings;\n}\n\nexport function parseReviewResult(result: string, mode: 'single-pass' | 'two-pass'): AIReviewResult {\n\tresult = result.trim();\n\n\tconst overview = result.match(overviewTagRegex)?.[1]?.trim() ?? '';\n\n\tconst focusAreas: AIReviewFocusArea[] = [];\n\tlet areaIndex = 0;\n\n\tfor (const match of result.matchAll(areaTagRegex)) {\n\t\tconst attrs = match[1];\n\t\tconst inner = match[2];\n\t\tareaIndex++;\n\n\t\tconst id = `area-${areaIndex}`;\n\t\tconst filesAttr = parseAttr(attrs, 'files');\n\t\tconst label = inner.match(labelTagRegex)?.[1]?.trim();\n\n\t\tconst findingsBlock = inner.match(findingsBlockRegex)?.[1];\n\t\tconst findings = findingsBlock ? parseFindings(findingsBlock, id) : undefined;\n\n\t\tfocusAreas.push({\n\t\t\tid: id,\n\t\t\tlabel: label ?? 'Untitled area',\n\t\t\t...(label == null ? { labelIsFallback: true } : {}),\n\t\t\trationale: inner.match(rationaleTagRegex)?.[1]?.trim() ?? '',\n\t\t\tseverity: parseSeverity(parseAttr(attrs, 'severity')),\n\t\t\tfiles: filesAttr?.split(',').map(f => f.trim()) ?? [],\n\t\t\tfindings: findings,\n\t\t});\n\t}\n\n\treturn { overview: overview, focusAreas: focusAreas, mode: mode };\n}\n\nfunction serializeFindingJson(finding: AIReviewFinding): ReviewFindingJson {\n\treturn {\n\t\tseverity: finding.severity,\n\t\ttitle: finding.title,\n\t\tdescription: finding.description,\n\t\tfile: finding.filePath ?? null,\n\t\tlines: finding.lineRange != null ? { start: finding.lineRange.start, end: finding.lineRange.end } : null,\n\t\tlocations:\n\t\t\tfinding.locations != null\n\t\t\t\t? finding.locations.map(l => ({\n\t\t\t\t\t\tfile: l.filePath,\n\t\t\t\t\t\tlines: l.lineRange != null ? { start: l.lineRange.start, end: l.lineRange.end } : null,\n\t\t\t\t\t}))\n\t\t\t\t: null,\n\t};\n}\n\n/** Inverse of {@link parseReviewResultJson} — emits the same JSON shape the review prompt templates\n * instruct (and the schemas enforce), so a prior result can be replayed as an assistant turn in a\n * follow-up conversation without contradicting the format the model is being asked to produce. */\nexport function serializeReviewResult(result: AIReviewResult): string {\n\tconst json: ReviewResultJson = {\n\t\toverview: result.overview,\n\t\tfocusAreas: result.focusAreas.map(area => ({\n\t\t\tlabel: area.label,\n\t\t\trationale: area.rationale,\n\t\t\tseverity: area.severity,\n\t\t\tfiles: [...area.files],\n\t\t\tfindings: area.findings?.map(serializeFindingJson) ?? null,\n\t\t})),\n\t};\n\n\treturn JSON.stringify(json, undefined, 2);\n}\n\nexport function parseReviewDetailResult(result: string, focusAreaId: string): AIReviewDetailResult {\n\tresult = result.trim();\n\n\tconst findingsBlock = result.match(findingsBlockRegex)?.[1] ?? result;\n\tconst findings = parseFindings(findingsBlock, focusAreaId);\n\n\treturn { findings: findings };\n}\n\ninterface ReviewFindingLocationJson {\n\tfile?: string | null;\n\tlines?: { start?: number; end?: number } | null;\n}\n\ninterface ReviewFindingJson extends ReviewFindingLocationJson {\n\tseverity?: string;\n\ttitle?: string;\n\tdescription?: string;\n\tlocations?: readonly ReviewFindingLocationJson[] | null;\n}\n\ninterface ReviewResultJson {\n\toverview?: string;\n\tfocusAreas?:\n\t\t| {\n\t\t\t\tlabel?: string;\n\t\t\t\trationale?: string;\n\t\t\t\tseverity?: string;\n\t\t\t\tfiles?: (string | null)[] | null;\n\t\t\t\tfindings?: ReviewFindingJson[] | null;\n\t\t }[]\n\t\t| null;\n}\n\nconst fencedJsonBlockRegex = /```(?:json)?\\s*([\\s\\S]*?)\\s*```/;\n\n/** Returns the contents of the first fenced code block, or the trimmed input when unfenced */\nexport function stripJsonCodeFence(text: string): string {\n\tconst fenced = fencedJsonBlockRegex.exec(text);\n\treturn (fenced?.[1] ?? text).trim();\n}\n\n/**\n * Extracts the first JSON object from the text — tolerating code fences and surrounding prose,\n * since providers without native schema enforcement often wrap the object in explanatory text.\n * Pass `isExpectedShape` so prose braces and stray JSON fragments (including complete nested\n * objects inside truncated output) can't be mistaken for the payload.\n */\nexport function extractJsonObject(\n\ttext: string,\n\tisExpectedShape?: (parsed: Record<string, unknown>) => boolean,\n): Record<string, unknown> | undefined {\n\ttext = text.trim();\n\n\tlet parsed = tryParseObject(text, isExpectedShape);\n\tif (parsed != null) return parsed;\n\n\tparsed = tryParseObject(stripJsonCodeFence(text), isExpectedShape);\n\tif (parsed != null) return parsed;\n\n\t// Fall back to balanced objects embedded in surrounding prose, trying each candidate start —\n\t// prose braces may be unbalanced (`render() {`) or parse to a different shape than expected\n\tlet index = text.indexOf('{');\n\twhile (index !== -1) {\n\t\tconst balanced = extractBalancedObject(text, index);\n\t\tif (balanced != null) {\n\t\t\tparsed = tryParseObject(balanced, isExpectedShape);\n\t\t\tif (parsed != null) return parsed;\n\t\t}\n\n\t\tindex = text.indexOf('{', index + 1);\n\t}\n\n\treturn undefined;\n}\n\nfunction tryParseObject(\n\ttext: string,\n\tisExpectedShape?: (parsed: Record<string, unknown>) => boolean,\n): Record<string, unknown> | undefined {\n\tif (!text.startsWith('{')) return undefined;\n\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(text);\n\t\tif (typeof parsed !== 'object' || parsed == null || Array.isArray(parsed)) return undefined;\n\n\t\tconst obj = parsed as Record<string, unknown>;\n\t\treturn isExpectedShape == null || isExpectedShape(obj) ? obj : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction extractBalancedObject(text: string, start: number): string | undefined {\n\tlet depth = 0;\n\tlet inString = false;\n\tlet escaped = false;\n\n\tfor (let i = start; i < text.length; i++) {\n\t\tconst ch = text[i];\n\t\tif (escaped) {\n\t\t\tescaped = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inString) {\n\t\t\tif (ch === '\\\\') {\n\t\t\t\tescaped = true;\n\t\t\t} else if (ch === '\"') {\n\t\t\t\tinString = false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (ch === '\"') {\n\t\t\tinString = true;\n\t\t} else if (ch === '{') {\n\t\t\tdepth++;\n\t\t} else if (ch === '}') {\n\t\t\tdepth--;\n\t\t\tif (depth === 0) return text.substring(start, i + 1);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/** Guards schema-typed string fields against non-string values from prompt-only providers */\nfunction trimmedString(value: unknown): string | undefined {\n\treturn typeof value === 'string' ? value.trim() : undefined;\n}\n\n/** Line numbers are integers per the schema, but prompt-only providers can emit numeric strings */\nfunction coerceLineNumber(value: unknown): number | undefined {\n\tif (typeof value === 'number') return value;\n\tif (typeof value === 'string') return parseInt(value, 10);\n\treturn undefined;\n}\n\n// Normalizes schema null-unions (null → undefined) and synthesizes the same 1-based positional ids\n// as the XML parsers, so ids stay stable regardless of which parse route handled the response\nfunction normalizeLocationJson(\n\tlocation: ReviewFindingLocationJson | null | undefined,\n): AIReviewFindingLocation | undefined {\n\tconst filePath = trimmedString(location?.file) || undefined;\n\tif (filePath == null) return undefined;\n\n\tconst lineRange = normalizeLineRange(\n\t\tcoerceLineNumber(location?.lines?.start),\n\t\tcoerceLineNumber(location?.lines?.end),\n\t);\n\treturn lineRange != null ? { filePath: filePath, lineRange: lineRange } : { filePath: filePath };\n}\n\n/** The finding's places, first place first: `file`/`lines` lead, then `locations` in order, each place once.\n * A model that puts the first place only in `locations` still gets it as the finding's `filePath`. */\nexport function normalizeFindingLocations(\n\tfinding: ReviewFindingLocationJson & { locations?: readonly ReviewFindingLocationJson[] | null },\n): AIReviewFindingLocation[] {\n\tconst out: AIReviewFindingLocation[] = [];\n\tconst seen = new Set<string>();\n\tconst add = (location: AIReviewFindingLocation | undefined) => {\n\t\tif (location == null) return;\n\n\t\tconst key = `${location.filePath}:${location.lineRange?.start ?? ''}-${location.lineRange?.end ?? ''}`;\n\t\tif (seen.has(key)) return;\n\n\t\tseen.add(key);\n\t\tout.push(location);\n\t};\n\tadd(normalizeLocationJson(finding));\n\tfor (const location of Array.isArray(finding.locations) ? finding.locations : []) {\n\t\tadd(normalizeLocationJson(location));\n\t}\n\treturn out;\n}\n\nfunction normalizeFindingJson(finding: ReviewFindingJson, id: string): AIReviewFinding {\n\tconst title = trimmedString(finding.title);\n\tconst locations = normalizeFindingLocations(finding);\n\tconst [first] = locations;\n\treturn {\n\t\tid: id,\n\t\tseverity: parseSeverity(trimmedString(finding.severity)),\n\t\ttitle: title || 'Untitled finding',\n\t\t...(!title ? { titleIsFallback: true } : {}),\n\t\tdescription: trimmedString(finding.description) ?? '',\n\t\tfilePath: first?.filePath,\n\t\tlineRange: first?.lineRange,\n\t\t...(locations.length > 1 ? { locations: locations } : {}),\n\t};\n}\n\ninterface ReviewOrientJson {\n\toverview?: unknown;\n\tgroups?: readonly { label?: unknown; kind?: unknown; files?: unknown }[] | null;\n}\n\nfunction parseOrientGroupKind(value: string | undefined): AIReviewOrientGroupKind {\n\treturn value === 'core' || value === 'supporting' || value === 'mechanical' ? value : 'supporting';\n}\n\n/** Parses an orient pass: a reading order, not findings. A file that appears twice keeps its first stop. */\nexport function parseReviewOrientJson(result: string): AIReviewOrientResult {\n\tif (!result.trim()) throw new Error(l10n.t('The AI model returned an empty response'));\n\n\tconst parsed = extractJsonObject(result, o => Array.isArray(o.groups)) as ReviewOrientJson | undefined;\n\tif (parsed == null) throw new Error(l10n.t('Unable to parse the review response from the AI model'));\n\n\tconst seen = new Set<string>();\n\tconst groups: AIReviewOrientGroup[] = [];\n\tlet index = 0;\n\tfor (const group of parsed.groups ?? []) {\n\t\tif (group == null || typeof group !== 'object') continue;\n\n\t\tconst files: AIReviewOrientFile[] = [];\n\t\tfor (const file of Array.isArray(group.files) ? group.files : []) {\n\t\t\tif (file == null || typeof file !== 'object') continue;\n\n\t\t\tconst path = trimmedString((file as { path?: unknown }).path);\n\t\t\tif (!path || seen.has(path)) continue;\n\n\t\t\tseen.add(path);\n\t\t\tfiles.push({ path: path, note: trimmedString((file as { note?: unknown }).note) ?? '' });\n\t\t}\n\t\tif (files.length === 0) continue;\n\n\t\tindex++;\n\t\tconst label = trimmedString(group.label);\n\t\tgroups.push({\n\t\t\tid: `group-${index}`,\n\t\t\tlabel: label || 'Untitled group',\n\t\t\t...(!label ? { labelIsFallback: true } : {}),\n\t\t\tkind: parseOrientGroupKind(trimmedString(group.kind)),\n\t\t\tsummary: trimmedString((group as { summary?: unknown }).summary) ?? '',\n\t\t\tfiles: files,\n\t\t});\n\t}\n\n\treturn { overview: typeof parsed.overview === 'string' ? parsed.overview.trim() : '', groups: groups };\n}\n\n/** Parses a review result, preferring the JSON shape and falling back to the legacy XML format */\nexport function parseReviewResultJson(result: string, mode: 'single-pass' | 'two-pass'): AIReviewResult {\n\t// An empty response is never a valid review — don't render it as a clean \"no issues\" result\n\tif (!result.trim()) throw new Error(l10n.t('The AI model returned an empty response'));\n\n\tconst parsed = extractJsonObject(result, o => typeof o.overview === 'string' || Array.isArray(o.focusAreas)) as\n\t\t| ReviewResultJson\n\t\t| undefined;\n\tconst overview = typeof parsed?.overview === 'string' ? parsed.overview.trim() : undefined;\n\tconst areas = Array.isArray(parsed?.focusAreas) ? parsed.focusAreas : undefined;\n\n\tif (overview == null && areas == null) {\n\t\tconst fallback = parseReviewResult(result, mode);\n\t\t// A non-empty response matching neither shape is malformed (e.g. truncated JSON) — surface\n\t\t// that rather than rendering it as a clean \"no issues\" review\n\t\tif (!fallback.overview && fallback.focusAreas.length === 0 && !result.includes('<overview')) {\n\t\t\tthrow new Error(l10n.t('Unable to parse the review response from the AI model'));\n\t\t}\n\t\treturn fallback;\n\t}\n\n\tconst focusAreas: AIReviewFocusArea[] = [];\n\tlet areaIndex = 0;\n\n\tfor (const area of areas ?? []) {\n\t\tif (area == null || typeof area !== 'object') continue;\n\n\t\tareaIndex++;\n\t\tconst label = trimmedString(area.label);\n\t\t// Finding ids MUST stay namespaced by area id — dismissed findings are tracked in one flat\n\t\t// set spanning all areas, so bare per-area indices would collide across areas\n\t\tconst id = `area-${areaIndex}`;\n\n\t\tconst findings = Array.isArray(area.findings)\n\t\t\t? area.findings.filter((f): f is ReviewFindingJson => f != null && typeof f === 'object')\n\t\t\t: undefined;\n\n\t\tfocusAreas.push({\n\t\t\tid: id,\n\t\t\tlabel: label || 'Untitled area',\n\t\t\t...(!label ? { labelIsFallback: true } : {}),\n\t\t\trationale: trimmedString(area.rationale) ?? '',\n\t\t\tseverity: parseSeverity(trimmedString(area.severity)),\n\t\t\tfiles: Array.isArray(area.files)\n\t\t\t\t? area.files.map(f => trimmedString(f)).filter((f): f is string => Boolean(f))\n\t\t\t\t: [],\n\t\t\tfindings: findings?.map((f, i) => normalizeFindingJson(f, `${id}-f${i + 1}`)),\n\t\t});\n\t}\n\n\treturn { overview: overview ?? '', focusAreas: focusAreas, mode: mode };\n}\n\n/** Parses a review detail result, preferring the JSON shape and falling back to the legacy XML format */\nexport function parseReviewDetailResultJson(result: string, focusAreaId: string): AIReviewDetailResult {\n\t// An empty response is never a valid result — don't render it as \"no findings\"\n\tif (!result.trim()) throw new Error(l10n.t('The AI model returned an empty response'));\n\n\tconst parsed = extractJsonObject(result, o => o.findings === null || Array.isArray(o.findings)) as\n\t\t| { findings?: ReviewFindingJson[] | null }\n\t\t| undefined;\n\t// Tolerate the sibling result schema's null-union — a null `findings` means \"no findings\"\n\tif (parsed?.findings === null) return { findings: [] };\n\n\tif (parsed == null || !Array.isArray(parsed.findings)) {\n\t\tconst fallback = parseReviewDetailResult(result, focusAreaId);\n\t\t// Same malformed-response guard as parseReviewResultJson above; an empty legacy\n\t\t// `<findings>` block is a legitimate \"no findings\" response, not a parse failure\n\t\tif (fallback.findings.length === 0 && !result.includes('<findings')) {\n\t\t\tthrow new Error(l10n.t('Unable to parse the review response from the AI model'));\n\t\t}\n\t\treturn fallback;\n\t}\n\n\treturn {\n\t\tfindings: parsed.findings\n\t\t\t.filter((f): f is ReviewFindingJson => f != null && typeof f === 'object')\n\t\t\t.map((f, i) => normalizeFindingJson(f, `${focusAreaId}-f${i + 1}`)),\n\t};\n}\n"],"mappings":";;AAcA,MAAM,kBAAkB;AACxB,MAAM,eAAe;AACrB,MAAM,iBAAiB;AAEvB,SAAgB,qBAAqB,QAAqE;CACzG,SAAS,OAAO,KAAK;CACrB,MAAM,UAAU,OAAO,MAAM,eAAe,CAAC,GAAG,EAAE,EAAE,KAAK,KAAK,KAAA;CAC9D,IAAI,WAAW,MACd,SAAS,OAAO,QAAQ,iBAAiB,EAAE,CAAC,CAAC,KAAK;CAGnD,IAAI,OAAO,OAAO,MAAM,YAAY,CAAC,GAAG,EAAE,EAAE,KAAK,KAAK,KAAA;CACtD,IAAI,QAAQ,MACX,SAAS,OAAO,QAAQ,cAAc,EAAE,CAAC,CAAC,KAAK;CAIhD,IAAI,QAAQ,QAAQ,OAAO,SAAS,SAAS,GAC5C,OAAO;CAIR,IAAI,WAAW,QAAQ,QAAQ,MAAM,OAAO;EAAW;EAAe;CAAK;CAG3E,IAAI,WAAW,QAAQ,QAAQ,MAAM,OAAO,+BAA+B,MAAM;CAGjF,IAAI,WAAW,QAAQ,MACtB,OAAO,SAAS;EAAW;EAAS,MAAM;CAAO,IAAI,+BAA+B,OAAO;CAI5F,IAAI,WAAW,QAAQ,MACtB,OAAO,SAAS;EAAE,SAAS;EAAc;CAAK,IAAI,+BAA+B,IAAI;CAGtF,OAAO;EAAE,SAAS,WAAW;EAAI,MAAM,QAAQ;CAAG;AACnD;AAEA,SAAgB,+BAA+B,SAAsE;CACpH,UAAU,QAAQ,QAAQ,gBAAgB,IAAI,CAAC,CAAC,KAAK;CACrD,MAAM,QAAQ,QAAQ,QAAQ,IAAI;CAClC,IAAI,UAAU,IAAI,OAAO;EAAE,SAAS;EAAS,MAAM;CAAG;CAEtD,OAAO;EACN,SAAS,QAAQ,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AI,GAAG,CAAC;EAC7E,CAAC;CACF;CAEA,OAAO;EAAE,UAAU,YAAY;EAAgB;EAAkB;CAAK;AACvE;;AAGA,SAAgB,4BAA4B,QAAgB,aAA2C;CAEtG,IAAI,CAAC,OAAO,KAAK,GAAG,MAAM,IAAI,MAAM,KAAK,EAAE,yCAAyC,CAAC;CAErF,MAAM,SAAS,kBAAkB,SAAQ,MAAK,EAAE,aAAa,QAAQ,MAAM,QAAQ,EAAE,QAAQ,CAAC;CAI9F,IAAI,QAAQ,aAAa,MAAM,OAAO,EAAE,UAAU,CAAC,EAAE;CAErD,IAAI,UAAU,QAAQ,CAAC,MAAM,QAAQ,OAAO,QAAQ,GAAG;EACtD,MAAM,WAAW,wBAAwB,QAAQ,WAAW;EAG5D,IAAI,SAAS,SAAS,WAAW,KAAK,CAAC,OAAO,SAAS,WAAW,GACjE,MAAM,IAAI,MAAM,KAAK,EAAE,uDAAuD,CAAC;EAEhF,OAAO;CACR;CAEA,OAAO,EACN,UAAU,OAAO,SACf,QAAQ,MAA8B,KAAK,QAAQ,OAAO,MAAM,QAAQ,CAAC,CACzE,KAAK,GAAG,MAAM,qBAAqB,GAAG,GAAG,YAAY,IAAI,IAAI,GAAG,CAAC,EACpE;AACD"}
@@ -66,6 +66,7 @@ var IntegrationAuthenticationService = class {
66
66
  case "jira-server":
67
67
  case "linear":
68
68
  case "trello":
69
+ case "asana":
69
70
  case "github": return true;
70
71
  default: return false;
71
72
  }
@@ -92,6 +93,7 @@ var IntegrationAuthenticationService = class {
92
93
  case "jira-server":
93
94
  case "linear":
94
95
  case "trello":
96
+ case "asana":
95
97
  provider = new CloudIntegrationAuthenticationProvider(this, this.configuredIntegrationService, providerId);
96
98
  break;
97
99
  default: throw new Error(`No authentication provider registered for integration '${String(providerId)}'`);
@@ -1 +1 @@
1
- {"version":3,"file":"integrationAuthenticationService.js","names":[],"sources":["../../../../../plus/integrations/src/authentication/integrationAuthenticationService.ts"],"sourcesContent":["import type { GitRemote } from '@gitlens/git/models/remote.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport type { IntegrationIds, SupportedCloudIntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { IntegrationService } from '../integrationService.js';\nimport type { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { ApiClients } from '../providers/apiClients.js';\nimport type { Source } from '../telemetry.js';\nimport { isSelfManagedHostIntegrationId, supportedIntegrationIds } from '../utils/integration.utils.js';\nimport type { CloudIntegrationService } from './cloudIntegrationService.js';\nimport type { ConfiguredIntegrationService } from './configuredIntegrationService.js';\nimport type {\n\tIntegrationAuthenticationProvider,\n\tIntegrationAuthenticationSessionDescriptor,\n} from './integrationAuthenticationProvider.js';\nimport { CloudIntegrationAuthenticationProvider } from './integrationAuthenticationProvider.js';\nimport { ObservedAuthenticationProvider } from './observedAuthenticationProvider.js';\n\nexport class IntegrationAuthenticationService implements Disposable {\n\tprivate readonly providers = new Map<IntegrationIds, IntegrationAuthenticationProvider>();\n\n\tconstructor(\n\t\tprivate readonly configuredIntegrationService: ConfiguredIntegrationService,\n\t\treadonly ctx: IntegrationServiceContext,\n\t\t/**\n\t\t * Lazy accessor for the owning {@link IntegrationService}. Injected by the composition root\n\t\t * ({@link createIntegrationManager}) to break the auth↔service construction cycle without a\n\t\t * mutable setter or a host round-trip; only resolved at runtime (long after construction).\n\t\t */\n\t\tprivate readonly getIntegrationService: () => IntegrationService,\n\t\t/** The package's cloud token-exchange client, constructed by the composition root. */\n\t\treadonly cloudIntegrations: CloudIntegrationService,\n\t) {}\n\n\tdispose(): void {\n\t\tthis.providers.forEach(p => p.dispose());\n\t\tthis.providers.clear();\n\t}\n\n\t/**\n\t * Initiates the cloud-integration connect flow on the owning service. Cloud auth providers call\n\t * this when they need a session that doesn't exist yet (see\n\t * {@link CloudIntegrationAuthenticationProvider}).\n\t */\n\tconnectCloudIntegrations(\n\t\tconnect: { integrationIds: SupportedCloudIntegrationIds[]; skipIfConnected?: boolean; skipPreSync?: boolean },\n\t\tsource?: Source,\n\t): Promise<boolean> {\n\t\treturn this.getIntegrationService().connectCloudIntegrations(connect, source);\n\t}\n\n\t/**\n\t * Resolves the connected git-host integration for a `GitRemote`, via the owning service. Lets\n\t * package-internal callers (e.g. the Bitbucket provider) resolve a remote's integration without a\n\t * host round-trip.\n\t */\n\tgetByRemote(remote: GitRemote): Promise<GitHostIntegration | undefined> {\n\t\treturn this.getIntegrationService().getByRemote(remote);\n\t}\n\n\t/** Resolves the per-integration `ignoreSSLErrors` flag via the owning service (host-config-backed). */\n\tignoreSSLErrors(integration: GitHostIntegration | { id: IntegrationIds; domain?: string }): boolean | 'force' {\n\t\treturn this.getIntegrationService().ignoreSSLErrors(integration);\n\t}\n\n\t/** The package-built per-provider API clients, via the owning service (built once + memoized there). */\n\tget apis(): ApiClients {\n\t\treturn this.getIntegrationService().apis;\n\t}\n\n\tasync get(providerId: IntegrationIds): Promise<IntegrationAuthenticationProvider> {\n\t\treturn this.ensureProvider(providerId);\n\t}\n\n\t/** The id of the connection a descriptor naming none reads: the primary configured for its host. */\n\tgetPrimaryConnectionId(providerId: IntegrationIds, descriptor: IntegrationAuthenticationSessionDescriptor): string {\n\t\treturn this.configuredIntegrationService.resolveConnectionId(providerId, descriptor);\n\t}\n\n\t@debug()\n\tasync reset(): Promise<void> {\n\t\t// TODO: This really isn't ideal, since it will only work for \"cloud\" providers as we won't have any more specific descriptors\n\t\tawait Promise.allSettled(\n\t\t\tsupportedIntegrationIds.map(async providerId =>\n\t\t\t\t(await this.ensureProvider(providerId)).deleteAllSessions(),\n\t\t\t),\n\t\t);\n\t}\n\n\tsupports(providerId: string): boolean {\n\t\t// Linear and Trello are cloud-backed issue integrations (same as Jira): `ensureProvider` registers a\n\t\t// cloud auth provider for them, so a disconnect must offer to sign out of the cloud token too —\n\t\t// otherwise the backend token and configured connection survive the disable.\n\t\tswitch (providerId) {\n\t\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\t\tcase IssuesCloudHostIntegrationId.Jira:\n\t\t\tcase IssuesSelfManagedHostIntegrationId.JiraServer:\n\t\t\tcase IssuesCloudHostIntegrationId.Linear:\n\t\t\tcase IssuesCloudHostIntegrationId.Trello:\n\t\t\tcase GitCloudHostIntegrationId.GitHub:\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\t@gate()\n\tprivate async ensureProvider(providerId: IntegrationIds): Promise<IntegrationAuthenticationProvider> {\n\t\tlet provider = this.providers.get(providerId);\n\t\tif (provider != null) return provider;\n\n\t\t// Optional consumer override for custom auth (e.g. a manual-token provider). GitLens omits it —\n\t\t// the package constructs its own cloud providers below (so GitLens's cloud auth needs no host hook).\n\t\tconst hostProvider = await this.ctx.hooks?.createAuthenticationProvider?.({\n\t\t\tid: providerId,\n\t\t});\n\t\tif (hostProvider != null) {\n\t\t\tprovider = new ObservedAuthenticationProvider(\n\t\t\t\thostProvider,\n\t\t\t\tisSelfManagedHostIntegrationId(providerId),\n\t\t\t\t(publication, domains) =>\n\t\t\t\t\tthis.getIntegrationService().onSessionPublishing(providerId, publication, domains),\n\t\t\t);\n\t\t\tthis.providers.set(providerId, provider);\n\t\t\treturn provider;\n\t\t}\n\n\t\t// Every cloud integration shares one provider, parameterized by id (cloud-only).\n\t\tswitch (providerId) {\n\t\t\tcase GitCloudHostIntegrationId.GitHub:\n\t\t\tcase GitSelfManagedHostIntegrationId.CloudGitHubEnterprise:\n\t\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\t\tcase GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:\n\t\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\t\tcase GitSelfManagedHostIntegrationId.BitbucketServer:\n\t\t\tcase IssuesCloudHostIntegrationId.Jira:\n\t\t\tcase IssuesSelfManagedHostIntegrationId.JiraServer:\n\t\t\tcase IssuesCloudHostIntegrationId.Linear:\n\t\t\tcase IssuesCloudHostIntegrationId.Trello:\n\t\t\t\tprovider = new CloudIntegrationAuthenticationProvider(\n\t\t\t\t\tthis,\n\t\t\t\t\tthis.configuredIntegrationService,\n\t\t\t\t\tproviderId,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`No authentication provider registered for integration '${String(providerId)}'`);\n\t\t}\n\n\t\tthis.providers.set(providerId, provider);\n\t\treturn provider;\n\t}\n}\n"],"mappings":";;;;;;;;AA0BA,IAAa,mCAAb,MAAoE;CAIjD;CACR;CAMQ;CAER;CAZV,4BAA6B,IAAI,IAAuD;CAExF,YACC,8BACA,KAMA,uBAEA,mBACC;EAVgB,KAAA,+BAAA;EACR,KAAA,MAAA;EAMQ,KAAA,wBAAA;EAER,KAAA,oBAAA;CACP;CAEH,UAAgB;EACf,KAAK,UAAU,SAAQ,MAAK,EAAE,QAAQ,CAAC;EACvC,KAAK,UAAU,MAAM;CACtB;;;;;;CAOA,yBACC,SACA,QACmB;EACnB,OAAO,KAAK,sBAAsB,CAAC,CAAC,yBAAyB,SAAS,MAAM;CAC7E;;;;;;CAOA,YAAY,QAA4D;EACvE,OAAO,KAAK,sBAAsB,CAAC,CAAC,YAAY,MAAM;CACvD;;CAGA,gBAAgB,aAA8F;EAC7G,OAAO,KAAK,sBAAsB,CAAC,CAAC,gBAAgB,WAAW;CAChE;;CAGA,IAAI,OAAmB;EACtB,OAAO,K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AAA;AA8BN,WAAA,CAAA,KAAK,CAAA,GAAA,iCAAA,WAAA,kBAAA,IAAA"}
1
+ {"version":3,"file":"integrationAuthenticationService.js","names":[],"sources":["../../../../../plus/integrations/src/authentication/integrationAuthenticationService.ts"],"sourcesContent":["import type { GitRemote } from '@gitlens/git/models/remote.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport type { Disposable } from '@gitlens/utils/disposable.js';\nimport type { IntegrationIds, SupportedCloudIntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from '../constants.js';\nimport type { IntegrationServiceContext } from '../context.js';\nimport type { IntegrationService } from '../integrationService.js';\nimport type { GitHostIntegration } from '../models/gitHostIntegration.js';\nimport type { ApiClients } from '../providers/apiClients.js';\nimport type { Source } from '../telemetry.js';\nimport { isSelfManagedHostIntegrationId, supportedIntegrationIds } from '../utils/integration.utils.js';\nimport type { CloudIntegrationService } from './cloudIntegrationService.js';\nimport type { ConfiguredIntegrationService } from './configuredIntegrationService.js';\nimport type {\n\tIntegrationAuthenticationProvider,\n\tIntegrationAuthenticationSessionDescriptor,\n} from './integrationAuthenticationProvider.js';\nimport { CloudIntegrationAuthenticationProvider } from './integrationAuthenticationProvider.js';\nimport { ObservedAuthenticationProvider } from './observedAuthenticationProvider.js';\n\nexport class IntegrationAuthenticationService implements Disposable {\n\tprivate readonly providers = new Map<IntegrationIds, IntegrationAuthenticationProvider>();\n\n\tconstructor(\n\t\tprivate readonly configuredIntegrationService: ConfiguredIntegrationService,\n\t\treadonly ctx: IntegrationServiceContext,\n\t\t/**\n\t\t * Lazy accessor for the owning {@link IntegrationService}. Injected by the composition root\n\t\t * ({@link createIntegrationManager}) to break the auth↔service construction cycle without a\n\t\t * mutable setter or a host round-trip; only resolved at runtime (long after construction).\n\t\t */\n\t\tprivate readonly getIntegrationService: () => IntegrationService,\n\t\t/** The package's cloud token-exchange client, constructed by the composition root. */\n\t\treadonly cloudIntegrations: CloudIntegrationService,\n\t) {}\n\n\tdispose(): void {\n\t\tthis.providers.forEach(p => p.dispose());\n\t\tthis.providers.clear();\n\t}\n\n\t/**\n\t * Initiates the cloud-integration connect flow on the owning service. Cloud auth providers call\n\t * this when they need a session that doesn't exist yet (see\n\t * {@link CloudIntegrationAuthenticationProvider}).\n\t */\n\tconnectCloudIntegrations(\n\t\tconnect: { integrationIds: SupportedCloudIntegrationIds[]; skipIfConnected?: boolean; skipPreSync?: boolean },\n\t\tsource?: Source,\n\t): Promise<boolean> {\n\t\treturn this.getIntegrationService().connectCloudIntegrations(connect, source);\n\t}\n\n\t/**\n\t * Resolves the connected git-host integration for a `GitRemote`, via the owning service. Lets\n\t * package-internal callers (e.g. the Bitbucket provider) resolve a remote's integration without a\n\t * host round-trip.\n\t */\n\tgetByRemote(remote: GitRemote): Promise<GitHostIntegration | undefined> {\n\t\treturn this.getIntegrationService().getByRemote(remote);\n\t}\n\n\t/** Resolves the per-integration `ignoreSSLErrors` flag via the owning service (host-config-backed). */\n\tignoreSSLErrors(integration: GitHostIntegration | { id: IntegrationIds; domain?: string }): boolean | 'force' {\n\t\treturn this.getIntegrationService().ignoreSSLErrors(integration);\n\t}\n\n\t/** The package-built per-provider API clients, via the owning service (built once + memoized there). */\n\tget apis(): ApiClients {\n\t\treturn this.getIntegrationService().apis;\n\t}\n\n\tasync get(providerId: IntegrationIds): Promise<IntegrationAuthenticationProvider> {\n\t\treturn this.ensureProvider(providerId);\n\t}\n\n\t/** The id of the connection a descriptor naming none reads: the primary configured for its host. */\n\tgetPrimaryConnectionId(providerId: IntegrationIds, descriptor: IntegrationAuthenticationSessionDescriptor): string {\n\t\treturn this.configuredIntegrationService.resolveConnectionId(providerId, descriptor);\n\t}\n\n\t@debug()\n\tasync reset(): Promise<void> {\n\t\t// TODO: This really isn't ideal, since it will only work for \"cloud\" providers as we won't have any more specific descriptors\n\t\tawait Promise.allSettled(\n\t\t\tsupportedIntegrationIds.map(async providerId =>\n\t\t\t\t(await this.ensureProvider(providerId)).deleteAllSessions(),\n\t\t\t),\n\t\t);\n\t}\n\n\tsupports(providerId: string): boolean {\n\t\t// Linear, Trello and Asana are cloud-backed issue integrations (same as Jira): `ensureProvider` registers a\n\t\t// cloud auth provider for them, so a disconnect must offer to sign out of the cloud token too —\n\t\t// otherwise the backend token and configured connection survive the disable.\n\t\tswitch (providerId) {\n\t\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\t\tcase IssuesCloudHostIntegrationId.Jira:\n\t\t\tcase IssuesSelfManagedHostIntegrationId.JiraServer:\n\t\t\tcase IssuesCloudHostIntegrationId.Linear:\n\t\t\tcase IssuesCloudHostIntegrationId.Trello:\n\t\t\tcase IssuesCloudHostIntegrationId.Asana:\n\t\t\tcase GitCloudHostIntegrationId.GitHub:\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\t@gate()\n\tprivate async ensureProvider(providerId: IntegrationIds): Promise<IntegrationAuthenticationProvider> {\n\t\tlet provider = this.providers.get(providerId);\n\t\tif (provider != null) return provider;\n\n\t\t// Optional consumer override for custom auth (e.g. a manual-token provider). GitLens omits it —\n\t\t// the package constructs its own cloud providers below (so GitLens's cloud auth needs no host hook).\n\t\tconst hostProvider = await this.ctx.hooks?.createAuthenticationProvider?.({\n\t\t\tid: providerId,\n\t\t});\n\t\tif (hostProvider != null) {\n\t\t\tprovider = new ObservedAuthenticationProvider(\n\t\t\t\thostProvider,\n\t\t\t\tisSelfManagedHostIntegrationId(providerId),\n\t\t\t\t(publication, domains) =>\n\t\t\t\t\tthis.getIntegrationService().onSessionPublishing(providerId, publication, domains),\n\t\t\t);\n\t\t\tthis.providers.set(providerId, provider);\n\t\t\treturn provider;\n\t\t}\n\n\t\t// Every cloud integration shares one provider, parameterized by id (cloud-only).\n\t\tswitch (providerId) {\n\t\t\tcase GitCloudHostIntegrationId.GitHub:\n\t\t\tcase GitSelfManagedHostIntegrationId.CloudGitHubEnterprise:\n\t\t\tcase GitCloudHostIntegrationId.GitLab:\n\t\t\tcase GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted:\n\t\t\tcase GitCloudHostIntegrationId.AzureDevOps:\n\t\t\tcase GitSelfManagedHostIntegrationId.AzureDevOpsServer:\n\t\t\tcase GitCloudHostIntegrationId.Bitbucket:\n\t\t\tcase GitSelfManagedHostIntegrationId.BitbucketServer:\n\t\t\tcase IssuesCloudHostIntegrationId.Jira:\n\t\t\tcase IssuesSelfManagedHostIntegrationId.JiraServer:\n\t\t\tcase IssuesCloudHostIntegrationId.Linear:\n\t\t\tcase IssuesCloudHostIntegrationId.Trello:\n\t\t\tcase IssuesCloudHostIntegrationId.Asana:\n\t\t\t\tprovider = new CloudIntegrationAuthenticationProvider(\n\t\t\t\t\tthis,\n\t\t\t\t\tthis.configuredIntegrationService,\n\t\t\t\t\tproviderId,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`No authentication provider registered for integration '${String(providerId)}'`);\n\t\t}\n\n\t\tthis.providers.set(providerId, provider);\n\t\treturn provider;\n\t}\n}\n"],"mappings":";;;;;;;;AA0BA,IAAa,mCAAb,MAAoE;CAIjD;CACR;CAMQ;CAER;CAZV,4BAA6B,IAAI,IAAuD;CAExF,YACC,8BACA,KAMA,uBAEA,mBACC;EAVgB,KAAA,+BAAA;EACR,KAAA,MAAA;EAMQ,KAAA,wBAAA;EAER,KAAA,oBAAA;CACP;CAEH,UAAgB;EACf,KAAK,UAAU,SAAQ,MAAK,EAAE,QAAQ,CAAC;EACvC,KAAK,UAAU,MAAM;CACtB;;;;;;CAOA,yBACC,SACA,QACmB;EACnB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KAAA;GACA,KAAA;GACA,KAAA;GACA,KAAA;GACA,KAAA;IACC,WAAW,IAAI,uCACd,MACA,KAAK,8BACL,UACD;IACA;GACD,SACC,MAAM,IAAI,MAAM,0DAA0D,OAAO,UAAU,EAAE,EAAE;EACjG;EAEA,KAAK,UAAU,IAAI,YAAY,QAAQ;EACvC,OAAO;CACR;AACD;AAhFE,WAAA,CAAA,MAAM,CAAA,GAAA,iCAAA,WAAA,SAAA,IAAA;AA+BN,WAAA,CAAA,KAAK,CAAA,GAAA,iCAAA,WAAA,kBAAA,IAAA"}
@@ -145,7 +145,7 @@ export interface CloudIntegrationConnection {
145
145
  /** Human-readable account handle, when the backend provides it on the connection (may be absent). */
146
146
  accountName?: string;
147
147
  }
148
- export type CloudIntegrationType = 'jira' | 'jiraServer' | 'linear' | 'trello' | 'gitlab' | 'github' | 'bitbucket' | 'bitbucketServer' | 'azure' | 'azureDevopsServer' | 'githubEnterprise' | 'gitlabSelfHosted';
148
+ export type CloudIntegrationType = 'jira' | 'jiraServer' | 'linear' | 'trello' | 'asana' | 'gitlab' | 'github' | 'bitbucket' | 'bitbucketServer' | 'azure' | 'azureDevopsServer' | 'githubEnterprise' | 'gitlabSelfHosted';
149
149
  export type CloudIntegrationAuthType = 'oauth' | 'pat';
150
150
  export declare const CloudIntegrationAuthenticationUriPathPrefix = "did-authenticate-cloud-integration";
151
151
  /** Returns all supported cloud integration ids. */
@@ -49,6 +49,7 @@ const toIntegrationId = {
49
49
  jiraServer: "jira-server",
50
50
  linear: "linear",
51
51
  trello: "trello",
52
+ asana: "asana",
52
53
  gitlab: "gitlab",
53
54
  github: "github",
54
55
  githubEnterprise: "cloud-github-enterprise",
@@ -63,6 +64,7 @@ const toCloudIntegrationType = {
63
64
  ["jira-server"]: "jiraServer",
64
65
  ["linear"]: "linear",
65
66
  ["trello"]: "trello",
67
+ ["asana"]: "asana",
66
68
  ["gitlab"]: "gitlab",
67
69
  ["github"]: "github",
68
70
  ["bitbucket"]: "bitbucket",
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","names":[],"sources":["../../../../../plus/integrations/src/authentication/models.ts"],"sourcesContent":["import { microhash } from '@gitlens/utils/hash.js';\nimport type { IntegrationIds, SupportedCloudIntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n\tsupportedOrderedCloudIntegrationIds,\n} from '../constants.js';\n\n/**\n * Mirrors the shape of `vscode.AuthenticationSession` so the integrations\n * package can stay vscode-free. Host adapters bridge VS Code sessions to\n * this shape via {@link AuthenticationProvider}.\n */\nexport interface AuthenticationSessionLike {\n\treadonly id: string;\n\treadonly accessToken: string;\n\treadonly account: { readonly id: string; readonly label: string };\n\treadonly scopes: readonly string[];\n}\n\nexport interface ProviderAuthenticationSession extends AuthenticationSessionLike {\n\treadonly cloud: boolean;\n\treadonly type: CloudIntegrationAuthType | undefined;\n\treadonly expiresAt?: Date;\n\treadonly domain: string;\n\t/**\n\t * The connection's address exactly as it was configured, path and all, when that differs from\n\t * {@link domain}.\n\t *\n\t * `domain` is the IDENTITY a self-managed connection is keyed by, so it is normalized to a bare host\n\t * (`hostFromDomain`) and one host cannot key two connections. An instance mounted below a context path —\n\t * Jira Data Center's `/jira`, a reverse-proxied GitLab or Bitbucket — still has to be ADDRESSED at that\n\t * path, and normalizing it away is what made every request go to the root. Absent when the backend\n\t * reported nothing beyond the host, which is the common case.\n\t */\n\treadonly baseUrl?: string;\n\treadonly protocol?: string;\n\t/** The provider app key paired with the token for providers whose client needs one (e.g. Trello). */\n\treadonly appKey?: string;\n}\n\nexport type SessionPublication = {\n\treadonly session?: ProviderAuthenticationSession;\n\treadonly previousSessionId?: string;\n\treadonly connectionId?: string;\n\t/** A removal has no session from which to recover the affected storage variant. */\n\treadonly cloud?: boolean;\n\treadonly replacePrimary?: boolean;\n};\n\nexport function getSessionIdentity(\n\tsession:\n\t\t| Partial<\n\t\t\t\tPick<\n\t\t\t\t\tProviderAuthenticationSession,\n\t\t\t\t\t'id' | 'accessToken' | 'domain' | 'baseUrl' | 'protocol' | 'appKey' | 'type' | 'cloud'\n\t\t\t\t>\n\t\t >\n\t\t| null\n\t\t| undefined,\n): string | undefined {\n\treturn session == null\n\t\t? undefined\n\t\t: JSON.stringify([\n\t\t\t\tsession.id,\n\t\t\t\tsession.accessToken,\n\t\t\t\tsession.domain,\n\t\t\t\tsession.baseUrl,\n\t\t\t\tsession.protocol,\n\t\t\t\tsession.appKey,\n\t\t\t\tsession.type,\n\t\t\t\tsession.cloud,\n\t\t\t]);\n}\n\nexport interface TokenInfo<T extends IntegrationIds | 'gitkraken' = IntegrationIds | 'gitkraken'> {\n\treadonly providerId: T;\n\t/**\n\t * The first 3 characters of the md5 hash of the token.\n\t * It's a very obfuscated representation of the token that we can use in logs\n\t * to see whether the token survives refreshing or gets updated.\n\t */\n\treadonly microHash: string | undefined;\n\treadonly cloud: boolean;\n\treadonly type: CloudIntegrationAuthType | undefined;\n\treadonly scopes: readonly string[] | undefined;\n\treadonly expiresAt?: Date;\n}\n\nexport interface TokenWithInfo<T extends IntegrationIds = IntegrationIds> extends TokenInfo<T> {\n\treadonly accessToken: string;\n\t/** The token's connection (its session's id), which a failed request's strike counts against. */\n\treadonly connectionId?: string;\n}\n\nexport function toTokenInfo<T extends IntegrationIds | 'gitkraken'>(\n\tproviderId: T,\n\taccessToken: string | undefined,\n\tinfo: { cloud: boolean; type: CloudIntegrationAuthType | undefined; scopes?: readonly string[]; expiresAt?: Date },\n): TokenInfo<T> {\n\treturn {\n\t\tproviderId: providerId,\n\t\tmicroHash: microhash(accessToken, 3),\n\t\tcloud: info.cloud,\n\t\ttype: info.type,\n\t\tscopes: info.scopes,\n\t\texpiresAt: info.expiresAt,\n\t};\n}\n\nexport function toTokenWithInfo<T extends IntegrationIds>(\n\tproviderId: T,\n\tsession: ProviderAuthenticationSession,\n\taltToken?: string,\n): TokenWithInfo<T> {\n\tconst { accessToken: sessionToken, ...sessionInfo } = session;\n\tconst accessToken = altToken ?? session.accessToken;\n\treturn {\n\t\t// pass original token info to form the correlated microhash\n\t\t...toTokenInfo(providerId, sessionToken, sessionInfo),\n\t\t// use the actual token used for the request\n\t\taccessToken: accessToken,\n\t\tconnectionId: session.id,\n\t};\n}\n\nexport type TokenOptInfo<T extends IntegrationIds = IntegrationIds> =\n\t| TokenWithInfo<T>\n\t// `connectionId` targets a specific connection (multi-account) when the token still has to be resolved.\n\t// Omitted resolves the provider's primary connection, preserving the pre-multi-account behavior.\n\t| { providerId: T; accessToken?: undefined; connectionId?: string };\n\nexport interface ConfiguredIntegrationDescriptor {\n\t/**\n\t * Stable per-connection identifier, distinct from the domain, so multiple accounts can be\n\t * connected to the same provider+domain simultaneously. For legacy/migrated single connections\n\t * this is the domain (self-managed) or the provider's canonical domain (cloud), which keeps the\n\t * existing secret key (`integration.auth[.cloud]:{id}|{domain}`) valid with zero migration.\n\t */\n\treadonly id: string;\n\t/**\n\t * Whether this is the connection used by default for the provider. Optional: when no descriptor\n\t * for a provider+domain carries an explicit flag, the first one is treated as primary. Only\n\t * {@link ConfiguredIntegrationService.setPrimaryConnection} sets the flag (and clears it on siblings).\n\t */\n\treadonly primary?: boolean;\n\t/** The connection's auth type (`oauth`/`pat`), when known. */\n\treadonly type?: CloudIntegrationAuthType;\n\t/**\n\t * Human-readable account handle for this connection (e.g. the GitHub login). Resolved from the\n\t * provider API (the token backend doesn't expose it); absent until resolved or if the lookup fails.\n\t */\n\treadonly accountName?: string;\n\t/**\n\t * Workspace the connection's token was granted for (Linear), separate from the person. Resolved with the\n\t * connection's own token and kept by connection id; both are set together, or neither is.\n\t */\n\treadonly resourceName?: string;\n\treadonly resourceId?: string;\n\treadonly cloud: boolean;\n\treadonly integrationId: IntegrationIds;\n\treadonly scopes: string;\n\treadonly domain?: string;\n\t/**\n\t * The address this connection was configured with, path included — see\n\t * {@link ProviderAuthenticationSession.baseUrl}.\n\t *\n\t * Mirrored onto the descriptor so reconciliation can tell a re-pointed connection from an unchanged one\n\t * without reading its secret: {@link domain} is normalized to a bare host, so a backend connection moved\n\t * from one context path to another on the SAME host looks identical by domain alone.\n\t */\n\treadonly baseUrl?: string;\n\treadonly expiresAt?: string | Date;\n}\n\nexport interface CloudIntegrationAuthenticationSession {\n\ttype: CloudIntegrationAuthType;\n\taccessToken: string;\n\tdomain: string;\n\texpiresIn: number;\n\tscopes: string;\n\t/** Backend per-connection token identifier, when the provider-tokens backend supports multi-account. */\n\tid?: string;\n\t/** Provider app key paired with the token (e.g. Trello app key), when the backend supplies one. */\n\tappKey?: string;\n}\n\nexport interface CloudIntegrationAuthorization {\n\turl: string;\n}\n\n/** Workspace a connection's token was granted for; only ever a complete pair. */\nexport interface ConnectionResource {\n\treadonly id: string;\n\treadonly name: string;\n}\n\nexport interface CloudIntegrationConnection {\n\ttype: CloudIntegrationAuthType;\n\tprovider: CloudIntegrationType;\n\tdomain: string;\n\t/** Backend per-connection token identifier, when the provider-tokens backend supports multi-account. */\n\tid?: string;\n\t/** Whether the backend marks this connection as the primary/default for the provider. */\n\tprimary?: boolean;\n\t/** Human-readable account handle, when the backend provides it on the connection (may be absent). */\n\taccountName?: string;\n}\n\nexport type CloudIntegrationType =\n\t| 'jira'\n\t| 'jiraServer'\n\t| 'linear'\n\t| 'trello'\n\t| 'gitlab'\n\t| 'github'\n\t| 'bitbucket'\n\t| 'bitbucketServer'\n\t| 'azure'\n\t| 'azureDevopsServer'\n\t| 'githubEnterprise'\n\t| 'gitlabSelfHosted';\n\nexport type CloudIntegrationAuthType = 'oauth' | 'pat';\n\nexport const CloudIntegrationAuthenticationUriPathPrefix = 'did-authenticate-cloud-integration';\n\n/** Returns all supported cloud integration ids. */\nexport function getSupportedCloudIntegrationIds(): readonly SupportedCloudIntegrationIds[] {\n\t// Return the shared const directly (readonly so callers can't mutate it) — this runs on hot,\n\t// per-integration membership paths, so avoid allocating a fresh array per call.\n\treturn supportedOrderedCloudIntegrationIds;\n}\n\n/** Whether `id` is a supported cloud integration id. */\nexport function isSupportedCloudIntegrationId(id: string): id is SupportedCloudIntegrationIds {\n\treturn getSupportedCloudIntegrationIds().includes(id as SupportedCloudIntegrationIds);\n}\n\nexport function isIssueCloudIntegrationId(id: string): id is IssuesCloudHostIntegrationId {\n\tconst issueIds: string[] = Object.values(IssuesCloudHostIntegrationId);\n\treturn issueIds.includes(id);\n}\n\nexport const toIntegrationId: { [key in CloudIntegrationType]: IntegrationIds } = {\n\tjira: IssuesCloudHostIntegrationId.Jira,\n\tjiraServer: IssuesSelfManagedHostIntegrationId.JiraServer,\n\tlinear: IssuesCloudHostIntegrationId.Linear,\n\ttrello: IssuesCloudHostIntegrationId.Trello,\n\tgitlab: GitCloudHostIntegrationId.GitLab,\n\tgithub: GitCloudHostIntegrationId.GitHub,\n\tgithubEnterprise: GitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\tgitlabSelfHosted: GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\tbitbucket: GitCloudHostIntegrationId.Bitbucket,\n\tbitbucketServer: GitSelfManagedHostIntegrationId.BitbucketServer,\n\tazure: GitCloudHostIntegrationId.AzureDevOps,\n\tazureDevopsServer: GitSelfManagedHostIntegrationId.AzureDevOpsServer,\n};\n\nexport const toCloudIntegrationType: { [key in IntegrationIds]: CloudIntegrationType | undefined } = {\n\t[IssuesCloudHostIntegrationId.Jira]: 'jira',\n\t[IssuesSelfManagedHostIntegrationId.JiraServer]: 'jiraServer',\n\t[IssuesCloudHostIntegrationId.Linear]: 'linear',\n\t[IssuesCloudHostIntegrationId.Trello]: 'trello',\n\t[GitCloudHostIntegrationId.GitLab]: 'gitlab',\n\t[GitCloudHostIntegrationId.GitHub]: 'github',\n\t[GitCloudHostIntegrationId.Bitbucket]: 'bitbucket',\n\t[GitCloudHostIntegrationId.AzureDevOps]: 'azure',\n\t[GitSelfManagedHostIntegrationId.AzureDevOpsServer]: 'azureDevopsServer',\n\t[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise]: 'githubEnterprise',\n\t[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted]: 'gitlabSelfHosted',\n\t[GitSelfManagedHostIntegrationId.BitbucketServer]: 'bitbucketServer',\n};\n"],"mappings":";;;AAoDA,SAAgB,mBACf,SASqB;CACrB,OAAO,WAAW,OACf,KAAA,IACA,KAAK,UAAU;EACf,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;CACT,CAAC;AACJ;AAsBA,SAAgB,YACf,YACA,aACA,MACe;CACf,OAAO;EACM;EACZ,WAAW,UAAU,aAAa,CAAC;EACnC,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,WAAW,KAAK;CACjB;AACD;AAEA,SAAgB,gBACf,YACA,SACA,UACmB;CACnB,MAAM,EAAE,aAAa,cAAc,GAAG,gBAAgB;CACtD,MAAM,cAAc,YAAY,QAAQ;CACxC,OAAO;EAEN,GAAG,YAAY,YAAY,cAAc,WAAW;EAEvC;EACb,cAAc,QAAQ;CACvB;AACD;AAqGA,MAAa,8CAA8C;;AAG3D,SAAgB,kCAA2E;CAG1F,OAAO;AACR;;AAGA,SAAgB,8BAA8B,IAAgD;CAC7F,OAAO,gCAAgC,CAAC,CAAC,SAAS,EAAkC;AACrF;AAEA,SAAgB,0BAA0B,IAAgD;CAEzF,OAD2B,OAAO,OAAO,4BAC3B,CAAC,CAAC,SAAS,EAAE;AAC5B;AAEA,MAAa,kBAAqE;CACjF,MAAA;CACA,YAAA;CACA,QAAA;CACA,QAAA;CACA,QAAA;CACA,QAAA;CACA,kBAAA;CACA,kBAAA;CACA,WAAA;CACA,iBAAA;CACA,OAAA;CACA,mBAAA;AACD;AAEA,MAAa,yBAAwF;EAC/D,SAAA;EACY,gBAAA;EACV,WAAA;EACA,WAAA;EACH,WAAA;EACA,WAAA;EACG,cAAA;EACE,gBAAA;EACY,wBAAA;EACI,4BAAA;EACA,6BAAA;EACN,qBAAA;AACpD"}
1
+ {"version":3,"file":"models.js","names":[],"sources":["../../../../../plus/integrations/src/authentication/models.ts"],"sourcesContent":["import { microhash } from '@gitlens/utils/hash.js';\nimport type { IntegrationIds, SupportedCloudIntegrationIds } from '../constants.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n\tsupportedOrderedCloudIntegrationIds,\n} from '../constants.js';\n\n/**\n * Mirrors the shape of `vscode.AuthenticationSession` so the integrations\n * package can stay vscode-free. Host adapters bridge VS Code sessions to\n * this shape via {@link AuthenticationProvider}.\n */\nexport interface AuthenticationSessionLike {\n\treadonly id: string;\n\treadonly accessToken: string;\n\treadonly account: { readonly id: string; readonly label: string };\n\treadonly scopes: readonly string[];\n}\n\nexport interface ProviderAuthenticationSession extends AuthenticationSessionLike {\n\treadonly cloud: boolean;\n\treadonly type: CloudIntegrationAuthType | undefined;\n\treadonly expiresAt?: Date;\n\treadonly domain: string;\n\t/**\n\t * The connection's address exactly as it was configured, path and all, when that differs from\n\t * {@link domain}.\n\t *\n\t * `domain` is the IDENTITY a self-managed connection is keyed by, so it is normalized to a bare host\n\t * (`hostFromDomain`) and one host cannot key two connections. An instance mounted below a context path —\n\t * Jira Data Center's `/jira`, a reverse-proxied GitLab or Bitbucket — still has to be ADDRESSED at that\n\t * path, and normalizing it away is what made every request go to the root. Absent when the backend\n\t * reported nothing beyond the host, which is the common case.\n\t */\n\treadonly baseUrl?: string;\n\treadonly protocol?: string;\n\t/** The provider app key paired with the token for providers whose client needs one (e.g. Trello). */\n\treadonly appKey?: string;\n}\n\nexport type SessionPublication = {\n\treadonly session?: ProviderAuthenticationSession;\n\treadonly previousSessionId?: string;\n\treadonly connectionId?: string;\n\t/** A removal has no session from which to recover the affected storage variant. */\n\treadonly cloud?: boolean;\n\treadonly replacePrimary?: boolean;\n};\n\nexport function getSessionIdentity(\n\tsession:\n\t\t| Partial<\n\t\t\t\tPick<\n\t\t\t\t\tProviderAuthenticationSession,\n\t\t\t\t\t'id' | 'accessToken' | 'domain' | 'baseUrl' | 'protocol' | 'appKey' | 'type' | 'cloud'\n\t\t\t\t>\n\t\t >\n\t\t| null\n\t\t| undefined,\n): string | undefined {\n\treturn session == null\n\t\t? undefined\n\t\t: JSON.stringify([\n\t\t\t\tsession.id,\n\t\t\t\tsession.accessToken,\n\t\t\t\tsession.domain,\n\t\t\t\tsession.baseUrl,\n\t\t\t\tsession.protocol,\n\t\t\t\tsession.appKey,\n\t\t\t\tsession.type,\n\t\t\t\tsession.cloud,\n\t\t\t]);\n}\n\nexport interface TokenInfo<T extends IntegrationIds | 'gitkraken' = IntegrationIds | 'gitkraken'> {\n\treadonly providerId: T;\n\t/**\n\t * The first 3 characters of the md5 hash of the token.\n\t * It's a very obfuscated representation of the token that we can use in logs\n\t * to see whether the token survives refreshing or gets updated.\n\t */\n\treadonly microHash: string | undefined;\n\treadonly cloud: boolean;\n\treadonly type: CloudIntegrationAuthType | undefined;\n\treadonly scopes: readonly string[] | undefined;\n\treadonly expiresAt?: Date;\n}\n\nexport interface TokenWithInfo<T extends IntegrationIds = IntegrationIds> extends TokenInfo<T> {\n\treadonly accessToken: string;\n\t/** The token's connection (its session's id), which a failed request's strike counts against. */\n\treadonly connectionId?: string;\n}\n\nexport function toTokenInfo<T extends IntegrationIds | 'gitkraken'>(\n\tproviderId: T,\n\taccessToken: string | undefined,\n\tinfo: { cloud: boolean; type: CloudIntegrationAuthType | undefined; scopes?: readonly string[]; expiresAt?: Date },\n): TokenInfo<T> {\n\treturn {\n\t\tproviderId: providerId,\n\t\tmicroHash: microhash(accessToken, 3),\n\t\tcloud: info.cloud,\n\t\ttype: info.type,\n\t\tscopes: info.scopes,\n\t\texpiresAt: info.expiresAt,\n\t};\n}\n\nexport function toTokenWithInfo<T extends IntegrationIds>(\n\tproviderId: T,\n\tsession: ProviderAuthenticationSession,\n\taltToken?: string,\n): TokenWithInfo<T> {\n\tconst { accessToken: sessionToken, ...sessionInfo } = session;\n\tconst accessToken = altToken ?? session.accessToken;\n\treturn {\n\t\t// pass original token info to form the correlated microhash\n\t\t...toTokenInfo(providerId, sessionToken, sessionInfo),\n\t\t// use the actual token used for the request\n\t\taccessToken: accessToken,\n\t\tconnectionId: session.id,\n\t};\n}\n\nexport type TokenOptInfo<T extends IntegrationIds = IntegrationIds> =\n\t| TokenWithInfo<T>\n\t// `connectionId` targets a specific connection (multi-account) when the token still has to be resolved.\n\t// Omitted resolves the provider's primary connection, preserving the pre-multi-account behavior.\n\t| { providerId: T; accessToken?: undefined; connectionId?: string };\n\nexport interface ConfiguredIntegrationDescriptor {\n\t/**\n\t * Stable per-connection identifier, distinct from the domain, so multiple accounts can be\n\t * connected to the same provider+domain simultaneously. For legacy/migrated single connections\n\t * this is the domain (self-managed) or the provider's canonical domain (cloud), which keeps the\n\t * existing secret key (`integration.auth[.cloud]:{id}|{domain}`) valid with zero migration.\n\t */\n\treadonly id: string;\n\t/**\n\t * Whether this is the connection used by default for the provider. Optional: when no descriptor\n\t * for a provider+domain carries an explicit flag, the first one is treated as primary. Only\n\t * {@link ConfiguredIntegrationService.setPrimaryConnection} sets the flag (and clears it on siblings).\n\t */\n\treadonly primary?: boolean;\n\t/** The connection's auth type (`oauth`/`pat`), when known. */\n\treadonly type?: CloudIntegrationAuthType;\n\t/**\n\t * Human-readable account handle for this connection (e.g. the GitHub login). Resolved from the\n\t * provider API (the token backend doesn't expose it); absent until resolved or if the lookup fails.\n\t */\n\treadonly accountName?: string;\n\t/**\n\t * Workspace the connection's token was granted for (Linear), separate from the person. Resolved with the\n\t * connection's own token and kept by connection id; both are set together, or neither is.\n\t */\n\treadonly resourceName?: string;\n\treadonly resourceId?: string;\n\treadonly cloud: boolean;\n\treadonly integrationId: IntegrationIds;\n\treadonly scopes: string;\n\treadonly domain?: string;\n\t/**\n\t * The address this connection was configured with, path included — see\n\t * {@link ProviderAuthenticationSession.baseUrl}.\n\t *\n\t * Mirrored onto the descriptor so reconciliation can tell a re-pointed connection from an unchanged one\n\t * without reading its secret: {@link domain} is normalized to a bare host, so a backend connection moved\n\t * from one context path to another on the SAME host looks identical by domain alone.\n\t */\n\treadonly baseUrl?: string;\n\treadonly expiresAt?: string | Date;\n}\n\nexport interface CloudIntegrationAuthenticationSession {\n\ttype: CloudIntegrationAuthType;\n\taccessToken: string;\n\tdomain: string;\n\texpiresIn: number;\n\tscopes: string;\n\t/** Backend per-connection token identifier, when the provider-tokens backend supports multi-account. */\n\tid?: string;\n\t/** Provider app key paired with the token (e.g. Trello app key), when the backend supplies one. */\n\tappKey?: string;\n}\n\nexport interface CloudIntegrationAuthorization {\n\turl: string;\n}\n\n/** Workspace a connection's token was granted for; only ever a complete pair. */\nexport interface ConnectionResource {\n\treadonly id: string;\n\treadonly name: string;\n}\n\nexport interface CloudIntegrationConnection {\n\ttype: CloudIntegrationAuthType;\n\tprovider: CloudIntegrationType;\n\tdomain: string;\n\t/** Backend per-connection token identifier, when the provider-tokens backend supports multi-account. */\n\tid?: string;\n\t/** Whether the backend marks this connection as the primary/default for the provider. */\n\tprimary?: boolean;\n\t/** Human-readable account handle, when the backend provides it on the connection (may be absent). */\n\taccountName?: string;\n}\n\nexport type CloudIntegrationType =\n\t| 'jira'\n\t| 'jiraServer'\n\t| 'linear'\n\t| 'trello'\n\t| 'asana'\n\t| 'gitlab'\n\t| 'github'\n\t| 'bitbucket'\n\t| 'bitbucketServer'\n\t| 'azure'\n\t| 'azureDevopsServer'\n\t| 'githubEnterprise'\n\t| 'gitlabSelfHosted';\n\nexport type CloudIntegrationAuthType = 'oauth' | 'pat';\n\nexport const CloudIntegrationAuthenticationUriPathPrefix = 'did-authenticate-cloud-integration';\n\n/** Returns all supported cloud integration ids. */\nexport function getSupportedCloudIntegrationIds(): readonly SupportedCloudIntegrationIds[] {\n\t// Return the shared const directly (readonly so callers can't mutate it) — this runs on hot,\n\t// per-integration membership paths, so avoid allocating a fresh array per call.\n\treturn supportedOrderedCloudIntegrationIds;\n}\n\n/** Whether `id` is a supported cloud integration id. */\nexport function isSupportedCloudIntegrationId(id: string): id is SupportedCloudIntegrationIds {\n\treturn getSupportedCloudIntegrationIds().includes(id as SupportedCloudIntegrationIds);\n}\n\nexport function isIssueCloudIntegrationId(id: string): id is IssuesCloudHostIntegrationId {\n\tconst issueIds: string[] = Object.values(IssuesCloudHostIntegrationId);\n\treturn issueIds.includes(id);\n}\n\nexport const toIntegrationId: { [key in CloudIntegrationType]: IntegrationIds } = {\n\tjira: IssuesCloudHostIntegrationId.Jira,\n\tjiraServer: IssuesSelfManagedHostIntegrationId.JiraServer,\n\tlinear: IssuesCloudHostIntegrationId.Linear,\n\ttrello: IssuesCloudHostIntegrationId.Trello,\n\tasana: IssuesCloudHostIntegrationId.Asana,\n\tgitlab: GitCloudHostIntegrationId.GitLab,\n\tgithub: GitCloudHostIntegrationId.GitHub,\n\tgithubEnterprise: GitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\tgitlabSelfHosted: GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\tbitbucket: GitCloudHostIntegrationId.Bitbucket,\n\tbitbucketServer: GitSelfManagedHostIntegrationId.BitbucketServer,\n\tazure: GitCloudHostIntegrationId.AzureDevOps,\n\tazureDevopsServer: GitSelfManagedHostIntegrationId.AzureDevOpsServer,\n};\n\nexport const toCloudIntegrationType: { [key in IntegrationIds]: CloudIntegrationType | undefined } = {\n\t[IssuesCloudHostIntegrationId.Jira]: 'jira',\n\t[IssuesSelfManagedHostIntegrationId.JiraServer]: 'jiraServer',\n\t[IssuesCloudHostIntegrationId.Linear]: 'linear',\n\t[IssuesCloudHostIntegrationId.Trello]: 'trello',\n\t[IssuesCloudHostIntegrationId.Asana]: 'asana',\n\t[GitCloudHostIntegrationId.GitLab]: 'gitlab',\n\t[GitCloudHostIntegrationId.GitHub]: 'github',\n\t[GitCloudHostIntegrationId.Bitbucket]: 'bitbucket',\n\t[GitCloudHostIntegrationId.AzureDevOps]: 'azure',\n\t[GitSelfManagedHostIntegrationId.AzureDevOpsServer]: 'azureDevopsServer',\n\t[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise]: 'githubEnterprise',\n\t[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted]: 'gitlabSelfHosted',\n\t[GitSelfManagedHostIntegrationId.BitbucketServer]: 'bitbucketServer',\n};\n"],"mappings":";;;AAoDA,SAAgB,mBACf,SASqB;CACrB,OAAO,WAAW,OACf,KAAA,IACA,KAAK,UAAU;EACf,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;CACT,CAAC;AACJ;AAsBA,SAAgB,YACf,YACA,aACA,MACe;CACf,OAAO;EACM;EACZ,WAAW,UAAU,aAAa,CAAC;EACnC,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,WAAW,KAAK;CACjB;AACD;AAEA,SAAgB,gBACf,YACA,SACA,UACmB;CACnB,MAAM,EAAE,aAAa,cAAc,GAAG,gBAAgB;CACtD,MAAM,cAAc,YAAY,QAAQ;CACxC,OAAO;EAEN,GAAG,YAAY,YAAY,cAAc,WAAW;EAEvC;EACb,cAAc,QAAQ;CACvB;AACD;AAsGA,MAAa,8CAA8C;;AAG3D,SAAgB,kCAA2E;CAG1F,OAAO;AACR;;AAGA,SAAgB,8BAA8B,IAAgD;CAC7F,OAAO,gCAAgC,CAAC,CAAC,SAAS,EAAkC;AACrF;AAEA,SAAgB,0BAA0B,IAAgD;CAEzF,OAD2B,OAAO,OAAO,4BAC3B,CAAC,CAAC,SAAS,EAAE;AAC5B;AAEA,MAAa,kBAAqE;CACjF,MAAA;CACA,YAAA;CACA,QAAA;CACA,QAAA;CACA,OAAA;CACA,QAAA;CACA,QAAA;CACA,kBAAA;CACA,kBAAA;CACA,WAAA;CACA,iBAAA;CACA,OAAA;CACA,mBAAA;AACD;AAEA,MAAa,yBAAwF;EAC/D,SAAA;EACY,gBAAA;EACV,WAAA;EACA,WAAA;EACD,UAAA;EACF,WAAA;EACA,WAAA;EACG,cAAA;EACE,gBAAA;EACY,wBAAA;EACI,4BAAA;EACA,6BAAA;EACN,qBAAA;AACpD"}
@@ -16,7 +16,8 @@ export declare enum GitSelfManagedHostIntegrationId {
16
16
  export declare enum IssuesCloudHostIntegrationId {
17
17
  Jira = "jira",
18
18
  Linear = "linear",
19
- Trello = "trello"
19
+ Trello = "trello",
20
+ Asana = "asana"
20
21
  }
21
22
  /**
22
23
  * Issue trackers that live on a customer-run host rather than a single cloud endpoint, so every read must be
@@ -18,6 +18,7 @@ let IssuesCloudHostIntegrationId = /* @__PURE__ */ function(IssuesCloudHostInteg
18
18
  IssuesCloudHostIntegrationId["Jira"] = "jira";
19
19
  IssuesCloudHostIntegrationId["Linear"] = "linear";
20
20
  IssuesCloudHostIntegrationId["Trello"] = "trello";
21
+ IssuesCloudHostIntegrationId["Asana"] = "asana";
21
22
  return IssuesCloudHostIntegrationId;
22
23
  }({});
23
24
  /**
@@ -43,7 +44,8 @@ const supportedOrderedCloudIntegrationIds = [
43
44
  "jira",
44
45
  "jira-server",
45
46
  "linear",
46
- "trello"
47
+ "trello",
48
+ "asana"
47
49
  ];
48
50
  /**
49
51
  * The issue trackers of {@link supportedOrderedCloudIntegrationIds}, in the same order. Derived rather than
@@ -63,7 +65,8 @@ const integrationIds = [
63
65
  "jira",
64
66
  "jira-server",
65
67
  "linear",
66
- "trello"
68
+ "trello",
69
+ "asana"
67
70
  ];
68
71
  function isSupportedCloudIntegrationId(id) {
69
72
  return supportedOrderedCloudIntegrationIds.includes(id);
@@ -155,6 +158,13 @@ const supportedCloudIntegrationDescriptors = [
155
158
  icon: "gl-provider-trello",
156
159
  supports: ["issues"],
157
160
  requiresPro: true
161
+ },
162
+ {
163
+ id: "asana",
164
+ name: "Asana",
165
+ icon: "gl-provider-asana",
166
+ supports: ["issues"],
167
+ requiresPro: true
158
168
  }
159
169
  ];
160
170
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":[],"sources":["../../../../plus/integrations/src/constants.ts"],"sourcesContent":["import type { CloudIntegrationAuthType } from './authentication/models.js';\n\nexport const providerFanOutConcurrency = 6;\n\nexport enum GitCloudHostIntegrationId {\n\tGitHub = 'github',\n\tGitLab = 'gitlab',\n\tBitbucket = 'bitbucket',\n\tAzureDevOps = 'azureDevOps',\n}\n\nexport enum GitSelfManagedHostIntegrationId {\n\tBitbucketServer = 'bitbucket-server',\n\tCloudGitHubEnterprise = 'cloud-github-enterprise',\n\tCloudGitLabSelfHosted = 'cloud-gitlab-self-hosted',\n\tAzureDevOpsServer = 'azure-devops-server',\n}\n\nexport enum IssuesCloudHostIntegrationId {\n\tJira = 'jira',\n\tLinear = 'linear',\n\tTrello = 'trello',\n}\n\n/**\n * Issue trackers that live on a customer-run host rather than a single cloud endpoint, so every read must be\n * routed by the connection's own domain. Separate from {@link GitSelfManagedHostIntegrationId} because a\n * tracker has no repositories or pull requests: the two enums differ in what the id can be ASKED for, while\n * what they share — being keyed by host — is expressed by {@link SelfManagedHostIntegrationIds} and the\n * `isSelfManagedHostIntegrationId` predicate.\n */\nexport enum IssuesSelfManagedHostIntegrationId {\n\tJiraServer = 'jira-server',\n}\n\nexport type CloudGitSelfManagedHostIntegrationIds =\n\t| GitSelfManagedHostIntegrationId.CloudGitHubEnterprise\n\t| GitSelfManagedHostIntegrationId.BitbucketServer\n\t| GitSelfManagedHostIntegrationId.AzureDevOpsServer\n\t| GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\n/** The self-managed ids whose tokens are issued by the GK cloud backend, whatever they host. */\nexport type CloudSelfManagedHostIntegrationIds =\n\t| CloudGitSelfManagedHostIntegrationIds\n\t| IssuesSelfManagedHostIntegrationId.JiraServer;\n\nexport type GitHostIntegrationIds = GitCloudHostIntegrationId | GitSelfManagedHostIntegrationId;\nexport type IssuesHostIntegrationIds = IssuesCloudHostIntegrationId | IssuesSelfManagedHostIntegrationId;\n\n/** Every id addressed by host, across both families — what the domain-keyed machinery keys off. */\nexport type SelfManagedHostIntegrationIds = GitSelfManagedHostIntegrationId | IssuesSelfManagedHostIntegrationId;\n\nexport type IntegrationIds = GitHostIntegrationIds | IssuesHostIntegrationIds;\n\nexport const supportedOrderedCloudIntegrationIds = [\n\tGitCloudHostIntegrationId.GitHub,\n\tGitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\tGitCloudHostIntegrationId.GitLab,\n\tGitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n\tGitCloudHostIntegrationId.Bitbucket,\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tIssuesCloudHostIntegrationId.Jira,\n\tIssuesSelfManagedHostIntegrationId.JiraServer,\n\tIssuesCloudHostIntegrationId.Linear,\n\tIssuesCloudHostIntegrationId.Trello,\n];\n\n/**\n * The issue trackers of {@link supportedOrderedCloudIntegrationIds}, in the same order. Derived rather than\n * listed again: the two were parallel literals, and an id added to one and forgotten in the other drops that\n * tracker out of default project discovery and the Graph's issue-integration check with no other symptom.\n */\nexport const supportedOrderedCloudIssuesIntegrationIds = supportedOrderedCloudIntegrationIds.filter(\n\t(id): id is IssuesHostIntegrationIds =>\n\t\t// `Object.values`, not `in`: these are string enums, so the object is keyed by member name and `in`\n\t\t// would test the id against `Jira`/`Linear` rather than against `jira`/`linear`.\n\t\t(Object.values(IssuesCloudHostIntegrationId) as IntegrationIds[]).includes(id) ||\n\t\t(Object.values(IssuesSelfManagedHostIntegrationId) as IntegrationIds[]).includes(id),\n);\n\nexport const integrationIds = [\n\tGitCloudHostIntegrationId.GitHub,\n\tGitCloudHostIntegrationId.GitLab,\n\tGitCloudHostIntegrationId.Bitbucket,\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tGitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\tGitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\tIssuesCloudHostIntegrationId.Jira,\n\tIssuesSelfManagedHostIntegrationId.JiraServer,\n\tIssuesCloudHostIntegrationId.Linear,\n\tIssuesCloudHostIntegrationId.Trello,\n];\n\nexport type SupportedCloudIntegrationIds = (typeof supportedOrderedCloudIntegrationIds)[number];\n\nexport function isSupportedCloudIntegrationId(id: IntegrationIds): id is SupportedCloudIntegrationIds {\n\treturn supportedOrderedCloudIntegrationIds.includes(id);\n}\n\nexport function isIntegrationId(id: string): id is IntegrationIds {\n\treturn integrationIds.includes(id as IntegrationIds);\n}\n\nexport type IntegrationFeatures = 'prs' | 'issues';\n\nexport interface IntegrationDescriptor {\n\tid: SupportedCloudIntegrationIds;\n\tname: string;\n\ticon: string;\n\tsupports: IntegrationFeatures[];\n\trequiresPro: boolean;\n}\n\n/** Stored shape of a configured-integration descriptor in workspace state. */\nexport interface StoredConfiguredIntegrationDescriptor {\n\t/** Stable per-connection identifier. Backfilled from the domain for pre-multi-account stored data. */\n\tid?: string;\n\t/** Whether this is the primary/default connection for the provider. */\n\tprimary?: boolean;\n\t/** The connection's auth type (`oauth`/`pat`), when known. */\n\ttype?: CloudIntegrationAuthType;\n\t/** Human-readable account handle for this connection (e.g. the GitHub login), when resolved. */\n\taccountName?: string;\n\t/** Workspace the token was granted for (Linear), separate from the person; set with {@link resourceId}. */\n\tresourceName?: string;\n\t/** Id of that workspace; set with {@link resourceName}, or neither is. */\n\tresourceId?: string;\n\tcloud: boolean;\n\tintegrationId: IntegrationIds;\n\tdomain?: string;\n\t/**\n\t * The address a self-managed connection was configured with, path included, when it differs from the\n\t * host-normalized {@link domain} — see `ProviderAuthenticationSession.baseUrl`.\n\t */\n\tbaseUrl?: string;\n\texpiresAt?: string;\n\tscopes: string;\n}\n\n/** Stored shape of the `integrations:configured` storage key. */\nexport type StoredIntegrationConfigurations = Record<\n\tIntegrationIds,\n\tStoredConfiguredIntegrationDescriptor[] | undefined\n>;\n\nexport const supportedCloudIntegrationDescriptors: IntegrationDescriptor[] = [\n\t{\n\t\tid: GitCloudHostIntegrationId.GitHub,\n\t\tname: 'GitHub',\n\t\ticon: 'gl-provider-github',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: false,\n\t},\n\t{\n\t\tid: GitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\t\tname: 'GitHub Enterprise',\n\t\ticon: 'gl-provider-github',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: GitCloudHostIntegrationId.GitLab,\n\t\tname: 'GitLab',\n\t\ticon: 'gl-provider-gitlab',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: false,\n\t},\n\t{\n\t\tid: GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\t\tname: 'GitLab Self-Hosted',\n\t\ticon: 'gl-provider-gitlab',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: GitCloudHostIntegrationId.AzureDevOps,\n\t\tname: 'Azure DevOps',\n\t\ticon: 'gl-provider-azdo',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: GitSelfManagedHostIntegrationId.AzureDevOpsServer,\n\t\tname: 'Azure DevOps Server',\n\t\ticon: 'gl-provider-azdo',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: GitCloudHostIntegrationId.Bitbucket,\n\t\tname: 'Bitbucket',\n\t\ticon: 'gl-provider-bitbucket',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: false,\n\t},\n\t{\n\t\tid: GitSelfManagedHostIntegrationId.BitbucketServer,\n\t\tname: 'Bitbucket Data Center',\n\t\ticon: 'gl-provider-bitbucket',\n\t\tsupports: ['prs'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: IssuesCloudHostIntegrationId.Jira,\n\t\tname: 'Jira',\n\t\ticon: 'gl-provider-jira',\n\t\tsupports: ['issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: IssuesSelfManagedHostIntegrationId.JiraServer,\n\t\tname: 'Jira Data Center',\n\t\ticon: 'gl-provider-jira',\n\t\tsupports: ['issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: IssuesCloudHostIntegrationId.Linear,\n\t\tname: 'Linear',\n\t\ticon: 'gl-provider-linear',\n\t\tsupports: ['issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: IssuesCloudHostIntegrationId.Trello,\n\t\tname: 'Trello',\n\t\ticon: 'gl-provider-trello',\n\t\tsupports: ['issues'],\n\t\trequiresPro: true,\n\t},\n];\n"],"mappings":";AAEA,MAAa,4BAA4B;AAEzC,IAAY,4BAAL,yBAAA,2BAAA;CACN,0BAAA,YAAA;CACA,0BAAA,YAAA;CACA,0BAAA,eAAA;CACA,0BAAA,iBAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAY,kCAAL,yBAAA,iCAAA;CACN,gCAAA,qBAAA;CACA,gCAAA,2BAAA;CACA,gCAAA,2BAAA;CACA,gCAAA,uBAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAY,+BAAL,yBAAA,8BAAA;CACN,6BAAA,UAAA;CACA,6BAAA,YAAA;CACA,6BAAA,YAAA;;AACD,EAAA,CAAA,CAAA;;;;;;;;AASA,IAAY,qCAAL,yBAAA,oCAAA;CACN,mCAAA,gBAAA;;AACD,EAAA,CAAA,CAAA;AAqBA,MAAa,sCAAsC;;;;;;;;;;;;;AAanD;;;;;;AAOA,MAAa,4CAA4C,oCAAoC,QAC3F,OAGC,OAAO,OAAO,4BAA4B,CAAC,CAAsB,SAAS,EAAE,KAC5E,OAAO,OAAO,kCAAkC,CAAC,CAAsB,SAAS,EAAE,CACrF;AAEA,MAAa,iBAAiB;;;;;;;;;;;;;AAa9B;AAIA,SAAgB,8BAA8B,IAAwD;CACrG,OAAO,oCAAoC,SAAS,EAAE;AACvD;AAEA,SAAgB,gBAAgB,IAAkC;CACjE,OAAO,eAAe,SAAS,EAAoB;AACpD;AA4CA,MAAa,uCAAgE;CAC5E;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,OAAO,QAAQ;EAC1B,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,OAAO,QAAQ;EAC1B,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,OAAO,QAAQ;EAC1B,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,OAAO,QAAQ;EAC1B,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,OAAO,QAAQ;EAC1B,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,OAAO,QAAQ;EAC1B,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,OAAO,QAAQ;EAC1B,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,KAAK;EAChB,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,QAAQ;EACnB,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,QAAQ;EACnB,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,QAAQ;EACnB,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,QAAQ;EACnB,aAAa;CACd;AACD"}
1
+ {"version":3,"file":"constants.js","names":[],"sources":["../../../../plus/integrations/src/constants.ts"],"sourcesContent":["import type { CloudIntegrationAuthType } from './authentication/models.js';\n\nexport const providerFanOutConcurrency = 6;\n\nexport enum GitCloudHostIntegrationId {\n\tGitHub = 'github',\n\tGitLab = 'gitlab',\n\tBitbucket = 'bitbucket',\n\tAzureDevOps = 'azureDevOps',\n}\n\nexport enum GitSelfManagedHostIntegrationId {\n\tBitbucketServer = 'bitbucket-server',\n\tCloudGitHubEnterprise = 'cloud-github-enterprise',\n\tCloudGitLabSelfHosted = 'cloud-gitlab-self-hosted',\n\tAzureDevOpsServer = 'azure-devops-server',\n}\n\nexport enum IssuesCloudHostIntegrationId {\n\tJira = 'jira',\n\tLinear = 'linear',\n\tTrello = 'trello',\n\tAsana = 'asana',\n}\n\n/**\n * Issue trackers that live on a customer-run host rather than a single cloud endpoint, so every read must be\n * routed by the connection's own domain. Separate from {@link GitSelfManagedHostIntegrationId} because a\n * tracker has no repositories or pull requests: the two enums differ in what the id can be ASKED for, while\n * what they share — being keyed by host — is expressed by {@link SelfManagedHostIntegrationIds} and the\n * `isSelfManagedHostIntegrationId` predicate.\n */\nexport enum IssuesSelfManagedHostIntegrationId {\n\tJiraServer = 'jira-server',\n}\n\nexport type CloudGitSelfManagedHostIntegrationIds =\n\t| GitSelfManagedHostIntegrationId.CloudGitHubEnterprise\n\t| GitSelfManagedHostIntegrationId.BitbucketServer\n\t| GitSelfManagedHostIntegrationId.AzureDevOpsServer\n\t| GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted;\n\n/** The self-managed ids whose tokens are issued by the GK cloud backend, whatever they host. */\nexport type CloudSelfManagedHostIntegrationIds =\n\t| CloudGitSelfManagedHostIntegrationIds\n\t| IssuesSelfManagedHostIntegrationId.JiraServer;\n\nexport type GitHostIntegrationIds = GitCloudHostIntegrationId | GitSelfManagedHostIntegrationId;\nexport type IssuesHostIntegrationIds = IssuesCloudHostIntegrationId | IssuesSelfManagedHostIntegrationId;\n\n/** Every id addressed by host, across both families — what the domain-keyed machinery keys off. */\nexport type SelfManagedHostIntegrationIds = GitSelfManagedHostIntegrationId | IssuesSelfManagedHostIntegrationId;\n\nexport type IntegrationIds = GitHostIntegrationIds | IssuesHostIntegrationIds;\n\nexport const supportedOrderedCloudIntegrationIds = [\n\tGitCloudHostIntegrationId.GitHub,\n\tGitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\tGitCloudHostIntegrationId.GitLab,\n\tGitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n\tGitCloudHostIntegrationId.Bitbucket,\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tIssuesCloudHostIntegrationId.Jira,\n\tIssuesSelfManagedHostIntegrationId.JiraServer,\n\tIssuesCloudHostIntegrationId.Linear,\n\tIssuesCloudHostIntegrationId.Trello,\n\tIssuesCloudHostIntegrationId.Asana,\n];\n\n/**\n * The issue trackers of {@link supportedOrderedCloudIntegrationIds}, in the same order. Derived rather than\n * listed again: the two were parallel literals, and an id added to one and forgotten in the other drops that\n * tracker out of default project discovery and the Graph's issue-integration check with no other symptom.\n */\nexport const supportedOrderedCloudIssuesIntegrationIds = supportedOrderedCloudIntegrationIds.filter(\n\t(id): id is IssuesHostIntegrationIds =>\n\t\t// `Object.values`, not `in`: these are string enums, so the object is keyed by member name and `in`\n\t\t// would test the id against `Jira`/`Linear` rather than against `jira`/`linear`.\n\t\t(Object.values(IssuesCloudHostIntegrationId) as IntegrationIds[]).includes(id) ||\n\t\t(Object.values(IssuesSelfManagedHostIntegrationId) as IntegrationIds[]).includes(id),\n);\n\nexport const integrationIds = [\n\tGitCloudHostIntegrationId.GitHub,\n\tGitCloudHostIntegrationId.GitLab,\n\tGitCloudHostIntegrationId.Bitbucket,\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n\tGitSelfManagedHostIntegrationId.BitbucketServer,\n\tGitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\tGitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\tIssuesCloudHostIntegrationId.Jira,\n\tIssuesSelfManagedHostIntegrationId.JiraServer,\n\tIssuesCloudHostIntegrationId.Linear,\n\tIssuesCloudHostIntegrationId.Trello,\n\tIssuesCloudHostIntegrationId.Asana,\n];\n\nexport type SupportedCloudIntegrationIds = (typeof supportedOrderedCloudIntegrationIds)[number];\n\nexport function isSupportedCloudIntegrationId(id: IntegrationIds): id is SupportedCloudIntegrationIds {\n\treturn supportedOrderedCloudIntegrationIds.includes(id);\n}\n\nexport function isIntegrationId(id: string): id is IntegrationIds {\n\treturn integrationIds.includes(id as IntegrationIds);\n}\n\nexport type IntegrationFeatures = 'prs' | 'issues';\n\nexport interface IntegrationDescriptor {\n\tid: SupportedCloudIntegrationIds;\n\tname: string;\n\ticon: string;\n\tsupports: IntegrationFeatures[];\n\trequiresPro: boolean;\n}\n\n/** Stored shape of a configured-integration descriptor in workspace state. */\nexport interface StoredConfiguredIntegrationDescriptor {\n\t/** Stable per-connection identifier. Backfilled from the domain for pre-multi-account stored data. */\n\tid?: string;\n\t/** Whether this is the primary/default connection for the provider. */\n\tprimary?: boolean;\n\t/** The connection's auth type (`oauth`/`pat`), when known. */\n\ttype?: CloudIntegrationAuthType;\n\t/** Human-readable account handle for this connection (e.g. the GitHub login), when resolved. */\n\taccountName?: string;\n\t/** Workspace the token was granted for (Linear), separate from the person; set with {@link resourceId}. */\n\tresourceName?: string;\n\t/** Id of that workspace; set with {@link resourceName}, or neither is. */\n\tresourceId?: string;\n\tcloud: boolean;\n\tintegrationId: IntegrationIds;\n\tdomain?: string;\n\t/**\n\t * The address a self-managed connection was configured with, path included, when it differs from the\n\t * host-normalized {@link domain} — see `ProviderAuthenticationSession.baseUrl`.\n\t */\n\tbaseUrl?: string;\n\texpiresAt?: string;\n\tscopes: string;\n}\n\n/** Stored shape of the `integrations:configured` storage key. */\nexport type StoredIntegrationConfigurations = Record<\n\tIntegrationIds,\n\tStoredConfiguredIntegrationDescriptor[] | undefined\n>;\n\nexport const supportedCloudIntegrationDescriptors: IntegrationDescriptor[] = [\n\t{\n\t\tid: GitCloudHostIntegrationId.GitHub,\n\t\tname: 'GitHub',\n\t\ticon: 'gl-provider-github',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: false,\n\t},\n\t{\n\t\tid: GitSelfManagedHostIntegrationId.CloudGitHubEnterprise,\n\t\tname: 'GitHub Enterprise',\n\t\ticon: 'gl-provider-github',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: GitCloudHostIntegrationId.GitLab,\n\t\tname: 'GitLab',\n\t\ticon: 'gl-provider-gitlab',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: false,\n\t},\n\t{\n\t\tid: GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted,\n\t\tname: 'GitLab Self-Hosted',\n\t\ticon: 'gl-provider-gitlab',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: GitCloudHostIntegrationId.AzureDevOps,\n\t\tname: 'Azure DevOps',\n\t\ticon: 'gl-provider-azdo',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: GitSelfManagedHostIntegrationId.AzureDevOpsServer,\n\t\tname: 'Azure DevOps Server',\n\t\ticon: 'gl-provider-azdo',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: GitCloudHostIntegrationId.Bitbucket,\n\t\tname: 'Bitbucket',\n\t\ticon: 'gl-provider-bitbucket',\n\t\tsupports: ['prs', 'issues'],\n\t\trequiresPro: false,\n\t},\n\t{\n\t\tid: GitSelfManagedHostIntegrationId.BitbucketServer,\n\t\tname: 'Bitbucket Data Center',\n\t\ticon: 'gl-provider-bitbucket',\n\t\tsupports: ['prs'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: IssuesCloudHostIntegrationId.Jira,\n\t\tname: 'Jira',\n\t\ticon: 'gl-provider-jira',\n\t\tsupports: ['issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: IssuesSelfManagedHostIntegrationId.JiraServer,\n\t\tname: 'Jira Data Center',\n\t\ticon: 'gl-provider-jira',\n\t\tsupports: ['issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: IssuesCloudHostIntegrationId.Linear,\n\t\tname: 'Linear',\n\t\ticon: 'gl-provider-linear',\n\t\tsupports: ['issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: IssuesCloudHostIntegrationId.Trello,\n\t\tname: 'Trello',\n\t\ticon: 'gl-provider-trello',\n\t\tsupports: ['issues'],\n\t\trequiresPro: true,\n\t},\n\t{\n\t\tid: IssuesCloudHostIntegrationId.Asana,\n\t\tname: 'Asana',\n\t\ticon: 'gl-provider-asana',\n\t\tsupports: ['issues'],\n\t\trequiresPro: true,\n\t},\n];\n"],"mappings":";AAEA,MAAa,4BAA4B;AAEzC,IAAY,4BAAL,yBAAA,2BAAA;CACN,0BAAA,YAAA;CACA,0BAAA,YAAA;CACA,0BAAA,eAAA;CACA,0BAAA,iBAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAY,kCAAL,yBAAA,iCAAA;CACN,gCAAA,qBAAA;CACA,gCAAA,2BAAA;CACA,gCAAA,2BAAA;CACA,gCAAA,uBAAA;;AACD,EAAA,CAAA,CAAA;AAEA,IAAY,+BAAL,yBAAA,8BAAA;CACN,6BAAA,UAAA;CACA,6BAAA,YAAA;CACA,6BAAA,YAAA;CACA,6BAAA,WAAA;;AACD,EAAA,CAAA,CAAA;;;;;;;;AASA,IAAY,qCAAL,yBAAA,oCAAA;CACN,mCAAA,gBAAA;;AACD,EAAA,CAAA,CAAA;AAqBA,MAAa,sCAAsC;;;;;;;;;;;;;;AAcnD;;;;;;AAOA,MAAa,4CAA4C,oCAAoC,QAC3F,OAGC,OAAO,OAAO,4B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MAAM;EACN,UAAU,CAAC,QAAQ;EACnB,aAAa;CACd;CACA;EACC,IAAA;EACA,MAAM;EACN,MAAM;EACN,UAAU,CAAC,QAAQ;EACnB,aAAa;CACd;AACD"}
@@ -333,6 +333,21 @@ const trelloIssues = {
333
333
  point: trelloCard,
334
334
  project: trelloCard
335
335
  };
336
+ /**
337
+ * provider-apis' Asana task fields: its notes, its single assignee, its tags as labels and its likes as reactions.
338
+ * Comments are stories, which a task doesn't count, so reading them would cost a request per task.
339
+ */
340
+ const asanaTask = issuePresenceOf([
341
+ "description",
342
+ "assignees",
343
+ "labels",
344
+ "reactions"
345
+ ], ["access"]);
346
+ const asanaIssues = {
347
+ point: asanaTask,
348
+ account: asanaTask,
349
+ project: asanaTask
350
+ };
336
351
  const pullRequestPresence = /* @__PURE__ */ new Map([
337
352
  ["github", gitHubPullRequests],
338
353
  ["cloud-github-enterprise", gitHubEnterprisePullRequests],
@@ -354,7 +369,8 @@ const issuePresence = /* @__PURE__ */ new Map([
354
369
  ["jira", jiraIssues],
355
370
  ["jira-server", jiraServerIssues],
356
371
  ["linear", linearIssues],
357
- ["trello", trelloIssues]
372
+ ["trello", trelloIssues],
373
+ ["asana", asanaIssues]
358
374
  ]);
359
375
  function lookup(tables, providerId, projection) {
360
376
  if (projection == null) return void 0;
@@ -1 +1 @@
1
- {"version":3,"file":"fieldPresence.js","names":[],"sources":["../../../../plus/integrations/src/fieldPresence.ts"],"sourcesContent":["import type { IssueProjection, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { PullRequestProjection, PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from './constants.js';\n\n/**\n * Whether a row's read fetched a field group.\n *\n * - `fetched`: the read asked for it and surfaces it, so an empty value means \"none\".\n * - `not-requested`: this read didn't ask for it, or asked but doesn't surface it faithfully. Ignore the value even\n * when one is present (some reads fill placeholders); another read may supply it.\n * - `unavailable`: this provider or host can't supply it on this read.\n */\nexport type FieldPresence = 'fetched' | 'not-requested' | 'unavailable';\n\n/** A group is `fetched` only when every field in it is. */\nexport type PullRequestFieldGroup =\n\t/** `body`. */\n\t| 'description'\n\t/** `latestReviews`. */\n\t| 'reviews'\n\t/**\n\t * `reviewRequests`: who is requested. Not each request's `isCodeOwner`, which only GitLens' own GitHub reads\n\t * report; every other row leaves it undefined.\n\t */\n\t| 'reviewRequests'\n\t/**\n\t * `reviewDecision`. Only GitHub reports one; elsewhere it is derived from the reviewers' states on the row, which\n\t * ignores the host's own approval rules, so it is never `fetched` there — derive it from `reviews` and\n\t * `reviewRequests` instead.\n\t */\n\t| 'reviewDecision'\n\t/** `assignees`. */\n\t| 'assignees'\n\t/** `statusCheckRollupState`, on the `PullRequest` class. */\n\t| 'checks'\n\t/** `mergeableState`. */\n\t| 'mergeable'\n\t/** `additions`, `deletions` and `filesChanged`. */\n\t| 'diffStats'\n\t/** `commitCount`, on the `PullRequest` class. */\n\t| 'commitCount'\n\t/** `commentsCount`. */\n\t| 'comments'\n\t/** `thumbsUpCount`. */\n\t| 'reactions'\n\t/** `viewerCanUpdate`, on the `PullRequest` class, and `repository.accessLevel`. */\n\t| 'access'\n\t/** `authoredByMe`, and the `viewer` it was matched against. */\n\t| 'authoredByMe'\n\t/** `stack`. */\n\t| 'stack';\n\n/** A group is `fetched` only when every field in it is. */\nexport type IssueFieldGroup =\n\t/** `body`, and `bodyField` where the provider sets it. */\n\t| 'description'\n\t/** `assignees`. */\n\t| 'assignees'\n\t/** `labels`. */\n\t| 'labels'\n\t/** `commentsCount`. */\n\t| 'comments'\n\t/** `thumbsUpCount`. */\n\t| 'reactions'\n\t/** `repository.accessLevel`. */\n\t| 'access';\n\ntype Presence<G extends string> = Readonly<Record<G, FieldPresence>>;\ntype PresenceTable<P extends string, G extends string> = Readonly<Partial<Record<P, Presence<G>>>>;\n\nconst pullRequestFieldGroups: readonly PullRequestFieldGroup[] = [\n\t'description',\n\t'reviews',\n\t'reviewRequests',\n\t'reviewDecision',\n\t'assignees',\n\t'checks',\n\t'mergeable',\n\t'diffStats',\n\t'commitCount',\n\t'comments',\n\t'reactions',\n\t'access',\n\t'authoredByMe',\n\t'stack',\n];\n\nconst issueFieldGroups: readonly IssueFieldGroup[] = [\n\t'description',\n\t'assignees',\n\t'labels',\n\t'comments',\n\t'reactions',\n\t'access',\n];\n\n/** Every group in `groups` listed as neither `fetched` nor `unavailable` is `not-requested`. */\nfunction presenceOf<G extends string>(\n\tgroups: readonly G[],\n\tfetched: readonly G[],\n\tunavailable: readonly G[] = [],\n): Presence<G> {\n\treturn Object.freeze(\n\t\tObject.fromEntries(\n\t\t\tgroups.map(\n\t\t\t\tgroup =>\n\t\t\t\t\t[\n\t\t\t\t\t\tgroup,\n\t\t\t\t\t\tfetched.includes(group)\n\t\t\t\t\t\t\t? 'fetched'\n\t\t\t\t\t\t\t: unavailable.includes(group)\n\t\t\t\t\t\t\t\t? 'unavailable'\n\t\t\t\t\t\t\t\t: 'not-requested',\n\t\t\t\t\t] as const,\n\t\t\t),\n\t\t) as Record<G, FieldPresence>,\n\t);\n}\n\nfunction pullRequestPresenceOf(\n\tfetched: readonly PullRequestFieldGroup[],\n\tunavailable?: readonly PullRequestFieldGroup[],\n): Presence<PullRequestFieldGroup> {\n\treturn presenceOf(pullRequestFieldGroups, fetched, unavailable);\n}\n\nfunction issuePresenceOf(\n\tfetched: readonly IssueFieldGroup[],\n\tunavailable?: readonly IssueFieldGroup[],\n): Presence<IssueFieldGroup> {\n\treturn presenceOf(issueFieldGroups, fetched, unavailable);\n}\n\n/** GitLens' own lite fragment (`fromGitHubPullRequestLite`). `stack` is only selected against github.com. */\nconst gitHubLite = pullRequestPresenceOf(['description', 'stack']);\n\n/**\n * GitLens' own full fragment, which selects no reactions. The account-wide and batch reads return its rows as they\n * are, GitHub's own review decision included: none stays none, even while a review is requested.\n * `authoredByMe` needs the current account, which a read may fail to resolve, and the other reads never set it.\n */\nconst gitHubFull = pullRequestPresenceOf([\n\t'description',\n\t'reviews',\n\t'reviewRequests',\n\t'reviewDecision',\n\t'assignees',\n\t'checks',\n\t'mergeable',\n\t'diffStats',\n\t'commitCount',\n\t'comments',\n\t'access',\n\t'stack',\n]);\n\nconst gitHubPullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\tpoint: gitHubLite,\n\tsearch: gitHubFull,\n\t'search-summary': gitHubLite,\n\t'text-search': gitHubFull,\n\taccount: gitHubFull,\n\t// The lite fragment's own rows.\n\t'account-summary': gitHubLite,\n\t// provider-apis' own fragment and normalizer. Its review-state map has no DISMISSED, so a dismissed review is\n\t// dropped (and none carries a `commitOid`); it removes code-owner requests; it derives the review decision from\n\t// that list rather than reading GitHub's; and it doesn't read `repository.accessLevel`.\n\trepos: pullRequestPresenceOf([\n\t\t'description',\n\t\t'assignees',\n\t\t'checks',\n\t\t'mergeable',\n\t\t'diffStats',\n\t\t'commitCount',\n\t\t'comments',\n\t\t'reactions',\n\t]),\n\t// `summary` drops the `commits` subtree that carries both the check rollup and the commit count.\n\t'repos-summary': pullRequestPresenceOf([\n\t\t'description',\n\t\t'assignees',\n\t\t'mergeable',\n\t\t'diffStats',\n\t\t'comments',\n\t\t'reactions',\n\t]),\n\tbatch: gitHubFull,\n};\n\n/**\n * GitHub Enterprise Server rejects the stack selection, so a read that carries `stack` on github.com can't here.\n * provider-apis also gates check runs on the server version, which this table can't see, so its rollup on the\n * repository-scoped read may come from commit statuses alone.\n */\nconst gitHubEnterprisePullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = Object.fromEntries(\n\tObject.entries(gitHubPullRequests).map(([projection, presence]) => {\n\t\tconst enterprise: Record<PullRequestFieldGroup, FieldPresence> = { ...presence };\n\t\tif (enterprise.stack === 'fetched') {\n\t\t\tenterprise.stack = 'unavailable';\n\t\t}\n\t\tif (projection === 'repos') {\n\t\t\tenterprise.checks = 'not-requested';\n\t\t}\n\t\treturn [projection, Object.freeze(enterprise)];\n\t}),\n);\n\n/** GitLens' own issue fragment, which every native read selects with the body. */\nconst gitHubNativeIssue = presenceOf(issueFieldGroups, issueFieldGroups);\n\nconst gitHubIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: gitHubNativeIssue,\n\tsearch: gitHubNativeIssue,\n\taccount: gitHubNativeIssue,\n\t// provider-apis' own fragment selects neither the body nor the repository's `viewerPermission`.\n\trepos: presenceOf(issueFieldGroups, ['assignees', 'labels', 'comments', 'reactions']),\n\tbatch: gitHubNativeIssue,\n};\n\n/*\n * Every other provider. None of them reads the viewer's access (`repository.accessLevel` is absent on every row),\n * resolves `authoredByMe` reliably, or has stacks. provider-apis honors neither `summary` nor\n * `includeReviews` for them, so each `-summary` tag reads like its full one.\n */\n\n/**\n * GitLens' own GitLab reads: the point reads, and the free-text search. They select the description but leave it,\n * and everything else beyond the merge request's identity and refs, off the row.\n */\nconst gitLabOwn = pullRequestPresenceOf([], ['stack']);\n\n/**\n * provider-apis' merge request fragment and normalizer, which every other GitLab read goes through. It turns a null\n * count into 0: GitLab's schema makes `diffStatsSummary`, `commitCount` and `userNotesCount` nullable, so none is\n * promised — except that GitLab.com's comment count resolver answers 0 rather than null, which a self-managed\n * version may not.\n */\nfunction gitLabProviderApis(comments: boolean): Presence<PullRequestFieldGroup> {\n\treturn pullRequestPresenceOf(\n\t\t[\n\t\t\t'description',\n\t\t\t'reviews',\n\t\t\t'reviewRequests',\n\t\t\t'assignees',\n\t\t\t'checks',\n\t\t\t'mergeable',\n\t\t\t'reactions',\n\t\t\t...(comments ? (['comments'] as const) : []),\n\t\t],\n\t\t['stack'],\n\t);\n}\n\nfunction gitLabPullRequestsFor(\n\tproviderApis: Presence<PullRequestFieldGroup>,\n): PresenceTable<PullRequestProjection, PullRequestFieldGroup> {\n\treturn {\n\t\tpoint: gitLabOwn,\n\t\tsearch: providerApis,\n\t\t'text-search': gitLabOwn,\n\t\taccount: providerApis,\n\t\t'account-summary': providerApis,\n\t\trepos: providerApis,\n\t\t'repos-summary': providerApis,\n\t\tbatch: providerApis,\n\t};\n}\n\n/**\n * Azure DevOps pull requests have no assignees (both converters fill `assignees` with the reviewers, which `reviews` and\n * `reviewRequests` already hold) and no reactions. Neither converter reads checks or counts.\n */\nconst azureUnavailable: readonly PullRequestFieldGroup[] = ['assignees', 'reactions', 'stack'];\n/** Every list read: Azure truncates a listed pull request's description (to 400 characters). */\nconst azureListed = pullRequestPresenceOf(['reviews', 'reviewRequests', 'mergeable'], azureUnavailable);\n/** The batch reads fetch each pull request by id, which returns the whole description. */\nconst azureById = pullRequestPresenceOf(['description', 'reviews', 'reviewRequests', 'mergeable'], azureUnavailable);\n\nconst azurePullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\t// GitLens' own converter, which leaves the description off the row.\n\tpoint: azureListed,\n\tsearch: azureListed,\n\t'text-search': azureListed,\n\taccount: azureListed,\n\t'account-summary': azureListed,\n\trepos: azureListed,\n\t'repos-summary': azureListed,\n\tbatch: azureById,\n};\n\nconst azureServerPullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\t...azurePullRequests,\n\t'search-summary': azureListed,\n};\n\n/**\n * Bitbucket pull requests have no assignees or reactions. Neither provider-apis nor GitLens reads their build\n * statuses or mergeability: provider-apis fills a literal Mergeable, and GitLens' own converters leave it unset.\n */\nconst bitbucketUnavailable: readonly PullRequestFieldGroup[] = ['assignees', 'reactions', 'stack'];\nconst bitbucketProviderApis = pullRequestPresenceOf(\n\t['description', 'reviews', 'reviewRequests', 'comments'],\n\tbitbucketUnavailable,\n);\n\nconst bitbucketPullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\t// GitLens' own converter, which drops the comment count. The commit read selects `+values.*`, which isn't\n\t// known to bring the participants the reviews come from, as the other two point reads do.\n\tpoint: pullRequestPresenceOf(['description'], bitbucketUnavailable),\n\tsearch: bitbucketProviderApis,\n\t'text-search': bitbucketProviderApis,\n\taccount: bitbucketProviderApis,\n\t'account-summary': bitbucketProviderApis,\n\trepos: bitbucketProviderApis,\n\t'repos-summary': bitbucketProviderApis,\n\t// GitLens' own converter over reads that do select the participants.\n\tbatch: pullRequestPresenceOf(['description', 'reviews', 'reviewRequests'], bitbucketUnavailable),\n};\n\n/** provider-apis' and GitLens' own Data Center converters read the same fields. */\nconst bitbucketServerAll = pullRequestPresenceOf(\n\t['description', 'reviews', 'reviewRequests', 'comments'],\n\tbitbucketUnavailable,\n);\nconst bitbucketServerPullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\tpoint: bitbucketServerAll,\n\tsearch: bitbucketServerAll,\n\t'search-summary': bitbucketServerAll,\n\t'text-search': bitbucketServerAll,\n\taccount: bitbucketServerAll,\n\t'account-summary': bitbucketServerAll,\n\trepos: bitbucketServerAll,\n\t'repos-summary': bitbucketServerAll,\n\tbatch: bitbucketServerAll,\n};\n\n/**\n * provider-apis' GitLab issue reads (GraphQL, and REST for the account-wide one). The repository's access isn't read.\n * The GraphQL comment count is nullable like the merge request's, and passed through, so only GitLab.com's is\n * promised; the REST one is always a number.\n */\nfunction gitLabIssuesFor(comments: boolean): PresenceTable<IssueProjection, IssueFieldGroup> {\n\tconst graphQL = issuePresenceOf([\n\t\t'description',\n\t\t'assignees',\n\t\t'labels',\n\t\t'reactions',\n\t\t...(comments ? (['comments'] as const) : []),\n\t]);\n\treturn {\n\t\tpoint: graphQL,\n\t\taccount: issuePresenceOf(['description', 'assignees', 'labels', 'comments', 'reactions']),\n\t\trepos: graphQL,\n\t\tbatch: graphQL,\n\t};\n}\n\n/**\n * Azure DevOps work items have no reactions (provider-apis' converter fills 0; GitLens' leaves it unset) and belong to\n * a project, not a repository.\n */\nconst azureWorkItemUnavailable: readonly IssueFieldGroup[] = ['reactions', 'access'];\n/** provider-apis' work item converter, and GitLens' copy of it for the batch read. */\nconst azureWorkItem = issuePresenceOf(['description', 'assignees', 'labels', 'comments'], azureWorkItemUnavailable);\n/** GitLens' own work item converter, which drops the tags. */\nconst azureOwnWorkItem = issuePresenceOf(['description', 'assignees', 'comments'], azureWorkItemUnavailable);\n\nconst azureIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: azureOwnWorkItem,\n\taccount: azureWorkItem,\n\trepos: azureWorkItem,\n\tbatch: azureWorkItem,\n};\n\nconst azureServerIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\t...azureIssues,\n\tsearch: azureOwnWorkItem,\n};\n\n/**\n * Bitbucket Cloud's legacy issues, which only the host's own `getIssue` and `searchMyIssues` read. They have no\n * labels, their votes aren't reactions, and neither a comment count nor the repository's access is read.\n */\nconst bitbucketIssue = issuePresenceOf(['description', 'assignees'], ['labels', 'reactions']);\nconst bitbucketIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: bitbucketIssue,\n\taccount: bitbucketIssue,\n};\n\n/**\n * Tracker issues belong to no repository, and a tracker's votes aren't reactions (and read 0 where voting is off), so\n * neither group can be supplied.\n */\nconst trackerUnavailable: readonly IssueFieldGroup[] = ['reactions', 'access'];\n/**\n * provider-apis' Jira converter counts the comments embedded in the issue, which Jira may cap, rather than reading\n * their total.\n */\nconst jiraProviderApis = issuePresenceOf(['description', 'assignees', 'labels'], trackerUnavailable);\n\nconst jiraIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: jiraProviderApis,\n\taccount: jiraProviderApis,\n\tproject: jiraProviderApis,\n\t// GitLens' own by-key read, which reads the comment total.\n\tbatch: issuePresenceOf(['description', 'assignees', 'labels', 'comments'], trackerUnavailable),\n};\n\nconst jiraServerIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\t...jiraIssues,\n\tbatch: jiraProviderApis,\n};\n\n/** provider-apis' Linear fragment selects no labels (it fills an empty list), comments or reactions. */\nconst linearIssue = issuePresenceOf(['description', 'assignees'], ['access']);\nconst linearIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: linearIssue,\n\taccount: linearIssue,\n\tproject: linearIssue,\n\tbatch: linearIssue,\n};\n\n/** A Trello card's description is never read; its members are its assignees. */\nconst trelloCard = issuePresenceOf(['assignees', 'labels', 'comments'], trackerUnavailable);\nconst trelloIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: trelloCard,\n\tproject: trelloCard,\n};\n\nconst pullRequestPresence = new Map<string, PresenceTable<PullRequestProjection, PullRequestFieldGroup>>([\n\t[GitCloudHostIntegrationId.GitHub, gitHubPullRequests],\n\t[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise, gitHubEnterprisePullRequests],\n\t[GitCloudHostIntegrationId.GitLab, gitLabPullRequestsFor(gitLabProviderApis(true))],\n\t[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted, gitLabPullRequestsFor(gitLabProviderApis(false))],\n\t[GitCloudHostIntegrationId.AzureDevOps, azurePullRequests],\n\t[GitSelfManagedHostIntegrationId.AzureDevOpsServer, azureServerPullRequests],\n\t[GitCloudHostIntegrationId.Bitbucket, bitbucketPullRequests],\n\t[GitSelfManagedHostIntegrationId.BitbucketServer, bitbucketServerPullRequests],\n]);\n\nconst issuePresence = new Map<string, PresenceTable<IssueProjection, IssueFieldGroup>>([\n\t[GitCloudHostIntegrationId.GitHub, gitHubIssues],\n\t[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise, gitHubIssues],\n\t[GitCloudHostIntegrationId.GitLab, gitLabIssuesFor(true)],\n\t[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted, gitLabIssuesFor(false)],\n\t[GitCloudHostIntegrationId.AzureDevOps, azureIssues],\n\t[GitSelfManagedHostIntegrationId.AzureDevOpsServer, azureServerIssues],\n\t[GitCloudHostIntegrationId.Bitbucket, bitbucketIssues],\n\t[IssuesCloudHostIntegrationId.Jira, jiraIssues],\n\t[IssuesSelfManagedHostIntegrationId.JiraServer, jiraServerIssues],\n\t[IssuesCloudHostIntegrationId.Linear, linearIssues],\n\t[IssuesCloudHostIntegrationId.Trello, trelloIssues],\n]);\n\nfunction lookup<P extends string, G extends string>(\n\ttables: ReadonlyMap<string, PresenceTable<P, G>>,\n\tproviderId: string,\n\tprojection: P | undefined,\n): Presence<G> | undefined {\n\tif (projection == null) return undefined;\n\n\tconst table = tables.get(providerId);\n\t// `hasOwn` so a projection read off an untrusted row can't resolve to an `Object.prototype` member.\n\treturn table != null && Object.hasOwn(table, projection) ? table[projection] : undefined;\n}\n\n/**\n * Which field groups the read that produced `pr` fetched, keyed by its provider and {@link PullRequestShape.projection}.\n * `undefined` when either is unknown or the provider has no table yet — then nothing can be said about any field.\n */\nexport function getPullRequestFieldPresence(\n\tpr: PullRequestShape,\n): Readonly<Record<PullRequestFieldGroup, FieldPresence>> | undefined {\n\treturn lookup(pullRequestPresence, pr.provider.id, pr.projection);\n}\n\n/**\n * Which field groups the read that produced `issue` fetched, keyed by its provider and {@link IssueShape.projection}.\n * `undefined` when either is unknown or the provider has no table yet — then nothing can be said about any field.\n */\nexport function getIssueFieldPresence(issue: IssueShape): Readonly<Record<IssueFieldGroup, FieldPresence>> | undefined {\n\treturn lookup(issuePresence, issue.provider.id, issue.projection);\n}\n"],"mappings":";;AA2EA,MAAM,yBAA2D;CAChE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAEA,MAAM,mBAA+C;CACpD;CACA;CACA;CACA;CACA;CACA;AACD;;AAGA,SAAS,WACR,QACA,SACA,cAA4B,CAAC,GACf;CACd,OAAO,OAAO,OACb,OAAO,YACN,OAAO,KACN,UACC,CACC,OACA,QAAQ,SAAS,KAAK,IACnB,YACA,YAAY,SAAS,KAAK,IACzB,gBACA,eACL,CACF,CACD,CACD;AACD;AAEA,SAAS,sBACR,SACA,aACkC;CAClC,OAAO,WAAW,wBAAwB,SAAS,WAAW;AAC/D;AAEA,SAAS,gBACR,SACA,aAC4B;CAC5B,OAAO,WAAW,kBAAkB,SAAS,WAAW;AACzD;;AAGA,MAAM,aAA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6D;CACtF,CAAA,UAAmC,YAAY;CAC/C,CAAA,2BAAwD,YAAY;CACpE,CAAA,UAAmC,gBAAgB,IAAI,CAAC;CACxD,CAAA,4BAAwD,gBAAgB,KAAK,CAAC;CAC9E,CAAA,eAAwC,WAAW;CACnD,CAAA,uBAAoD,iBAAiB;CACrE,CAAA,aAAsC,eAAe;CACrD,CAAA,QAAoC,UAAU;CAC9C,CAAA,eAAgD,gBAAgB;CAChE,CAAA,UAAsC,YAAY;CAClD,CAAA,UAAsC,YAAY;AACnD,CAAC;AAED,SAAS,OACR,QACA,YACA,YAC0B;CAC1B,IAAI,cAAc,MAAM,OAAO,KAAA;CAE/B,MAAM,QAAQ,OAAO,IAAI,UAAU;CAEnC,OAAO,SAAS,QAAQ,OAAO,OAAO,OAAO,UAAU,IAAI,MAAM,cAAc,KAAA;AAChF;;;;;AAMA,SAAgB,4BACf,IACqE;CACrE,OAAO,OAAO,qBAAqB,GAAG,SAAS,IAAI,GAAG,UAAU;AACjE;;;;;AAMA,SAAgB,sBAAsB,OAAiF;CACtH,OAAO,OAAO,eAAe,MAAM,SAAS,IAAI,MAAM,UAAU;AACjE"}
1
+ {"version":3,"file":"fieldPresence.js","names":[],"sources":["../../../../plus/integrations/src/fieldPresence.ts"],"sourcesContent":["import type { IssueProjection, IssueShape } from '@gitlens/git/models/issue.js';\nimport type { PullRequestProjection, PullRequestShape } from '@gitlens/git/models/pullRequest.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n\tIssuesSelfManagedHostIntegrationId,\n} from './constants.js';\n\n/**\n * Whether a row's read fetched a field group.\n *\n * - `fetched`: the read asked for it and surfaces it, so an empty value means \"none\".\n * - `not-requested`: this read didn't ask for it, or asked but doesn't surface it faithfully. Ignore the value even\n * when one is present (some reads fill placeholders); another read may supply it.\n * - `unavailable`: this provider or host can't supply it on this read.\n */\nexport type FieldPresence = 'fetched' | 'not-requested' | 'unavailable';\n\n/** A group is `fetched` only when every field in it is. */\nexport type PullRequestFieldGroup =\n\t/** `body`. */\n\t| 'description'\n\t/** `latestReviews`. */\n\t| 'reviews'\n\t/**\n\t * `reviewRequests`: who is requested. Not each request's `isCodeOwner`, which only GitLens' own GitHub reads\n\t * report; every other row leaves it undefined.\n\t */\n\t| 'reviewRequests'\n\t/**\n\t * `reviewDecision`. Only GitHub reports one; elsewhere it is derived from the reviewers' states on the row, which\n\t * ignores the host's own approval rules, so it is never `fetched` there — derive it from `reviews` and\n\t * `reviewRequests` instead.\n\t */\n\t| 'reviewDecision'\n\t/** `assignees`. */\n\t| 'assignees'\n\t/** `statusCheckRollupState`, on the `PullRequest` class. */\n\t| 'checks'\n\t/** `mergeableState`. */\n\t| 'mergeable'\n\t/** `additions`, `deletions` and `filesChanged`. */\n\t| 'diffStats'\n\t/** `commitCount`, on the `PullRequest` class. */\n\t| 'commitCount'\n\t/** `commentsCount`. */\n\t| 'comments'\n\t/** `thumbsUpCount`. */\n\t| 'reactions'\n\t/** `viewerCanUpdate`, on the `PullRequest` class, and `repository.accessLevel`. */\n\t| 'access'\n\t/** `authoredByMe`, and the `viewer` it was matched against. */\n\t| 'authoredByMe'\n\t/** `stack`. */\n\t| 'stack';\n\n/** A group is `fetched` only when every field in it is. */\nexport type IssueFieldGroup =\n\t/** `body`, and `bodyField` where the provider sets it. */\n\t| 'description'\n\t/** `assignees`. */\n\t| 'assignees'\n\t/** `labels`. */\n\t| 'labels'\n\t/** `commentsCount`. */\n\t| 'comments'\n\t/** `thumbsUpCount`. */\n\t| 'reactions'\n\t/** `repository.accessLevel`. */\n\t| 'access';\n\ntype Presence<G extends string> = Readonly<Record<G, FieldPresence>>;\ntype PresenceTable<P extends string, G extends string> = Readonly<Partial<Record<P, Presence<G>>>>;\n\nconst pullRequestFieldGroups: readonly PullRequestFieldGroup[] = [\n\t'description',\n\t'reviews',\n\t'reviewRequests',\n\t'reviewDecision',\n\t'assignees',\n\t'checks',\n\t'mergeable',\n\t'diffStats',\n\t'commitCount',\n\t'comments',\n\t'reactions',\n\t'access',\n\t'authoredByMe',\n\t'stack',\n];\n\nconst issueFieldGroups: readonly IssueFieldGroup[] = [\n\t'description',\n\t'assignees',\n\t'labels',\n\t'comments',\n\t'reactions',\n\t'access',\n];\n\n/** Every group in `groups` listed as neither `fetched` nor `unavailable` is `not-requested`. */\nfunction presenceOf<G extends string>(\n\tgroups: readonly G[],\n\tfetched: readonly G[],\n\tunavailable: readonly G[] = [],\n): Presence<G> {\n\treturn Object.freeze(\n\t\tObject.fromEntries(\n\t\t\tgroups.map(\n\t\t\t\tgroup =>\n\t\t\t\t\t[\n\t\t\t\t\t\tgroup,\n\t\t\t\t\t\tfetched.includes(group)\n\t\t\t\t\t\t\t? 'fetched'\n\t\t\t\t\t\t\t: unavailable.includes(group)\n\t\t\t\t\t\t\t\t? 'unavailable'\n\t\t\t\t\t\t\t\t: 'not-requested',\n\t\t\t\t\t] as const,\n\t\t\t),\n\t\t) as Record<G, FieldPresence>,\n\t);\n}\n\nfunction pullRequestPresenceOf(\n\tfetched: readonly PullRequestFieldGroup[],\n\tunavailable?: readonly PullRequestFieldGroup[],\n): Presence<PullRequestFieldGroup> {\n\treturn presenceOf(pullRequestFieldGroups, fetched, unavailable);\n}\n\nfunction issuePresenceOf(\n\tfetched: readonly IssueFieldGroup[],\n\tunavailable?: readonly IssueFieldGroup[],\n): Presence<IssueFieldGroup> {\n\treturn presenceOf(issueFieldGroups, fetched, unavailable);\n}\n\n/** GitLens' own lite fragment (`fromGitHubPullRequestLite`). `stack` is only selected against github.com. */\nconst gitHubLite = pullRequestPresenceOf(['description', 'stack']);\n\n/**\n * GitLens' own full fragment, which selects no reactions. The account-wide and batch reads return its rows as they\n * are, GitHub's own review decision included: none stays none, even while a review is requested.\n * `authoredByMe` needs the current account, which a read may fail to resolve, and the other reads never set it.\n */\nconst gitHubFull = pullRequestPresenceOf([\n\t'description',\n\t'reviews',\n\t'reviewRequests',\n\t'reviewDecision',\n\t'assignees',\n\t'checks',\n\t'mergeable',\n\t'diffStats',\n\t'commitCount',\n\t'comments',\n\t'access',\n\t'stack',\n]);\n\nconst gitHubPullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\tpoint: gitHubLite,\n\tsearch: gitHubFull,\n\t'search-summary': gitHubLite,\n\t'text-search': gitHubFull,\n\taccount: gitHubFull,\n\t// The lite fragment's own rows.\n\t'account-summary': gitHubLite,\n\t// provider-apis' own fragment and normalizer. Its review-state map has no DISMISSED, so a dismissed review is\n\t// dropped (and none carries a `commitOid`); it removes code-owner requests; it derives the review decision from\n\t// that list rather than reading GitHub's; and it doesn't read `repository.accessLevel`.\n\trepos: pullRequestPresenceOf([\n\t\t'description',\n\t\t'assignees',\n\t\t'checks',\n\t\t'mergeable',\n\t\t'diffStats',\n\t\t'commitCount',\n\t\t'comments',\n\t\t'reactions',\n\t]),\n\t// `summary` drops the `commits` subtree that carries both the check rollup and the commit count.\n\t'repos-summary': pullRequestPresenceOf([\n\t\t'description',\n\t\t'assignees',\n\t\t'mergeable',\n\t\t'diffStats',\n\t\t'comments',\n\t\t'reactions',\n\t]),\n\tbatch: gitHubFull,\n};\n\n/**\n * GitHub Enterprise Server rejects the stack selection, so a read that carries `stack` on github.com can't here.\n * provider-apis also gates check runs on the server version, which this table can't see, so its rollup on the\n * repository-scoped read may come from commit statuses alone.\n */\nconst gitHubEnterprisePullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = Object.fromEntries(\n\tObject.entries(gitHubPullRequests).map(([projection, presence]) => {\n\t\tconst enterprise: Record<PullRequestFieldGroup, FieldPresence> = { ...presence };\n\t\tif (enterprise.stack === 'fetched') {\n\t\t\tenterprise.stack = 'unavailable';\n\t\t}\n\t\tif (projection === 'repos') {\n\t\t\tenterprise.checks = 'not-requested';\n\t\t}\n\t\treturn [projection, Object.freeze(enterprise)];\n\t}),\n);\n\n/** GitLens' own issue fragment, which every native read selects with the body. */\nconst gitHubNativeIssue = presenceOf(issueFieldGroups, issueFieldGroups);\n\nconst gitHubIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: gitHubNativeIssue,\n\tsearch: gitHubNativeIssue,\n\taccount: gitHubNativeIssue,\n\t// provider-apis' own fragment selects neither the body nor the repository's `viewerPermission`.\n\trepos: presenceOf(issueFieldGroups, ['assignees', 'labels', 'comments', 'reactions']),\n\tbatch: gitHubNativeIssue,\n};\n\n/*\n * Every other provider. None of them reads the viewer's access (`repository.accessLevel` is absent on every row),\n * resolves `authoredByMe` reliably, or has stacks. provider-apis honors neither `summary` nor\n * `includeReviews` for them, so each `-summary` tag reads like its full one.\n */\n\n/**\n * GitLens' own GitLab reads: the point reads, and the free-text search. They select the description but leave it,\n * and everything else beyond the merge request's identity and refs, off the row.\n */\nconst gitLabOwn = pullRequestPresenceOf([], ['stack']);\n\n/**\n * provider-apis' merge request fragment and normalizer, which every other GitLab read goes through. It turns a null\n * count into 0: GitLab's schema makes `diffStatsSummary`, `commitCount` and `userNotesCount` nullable, so none is\n * promised — except that GitLab.com's comment count resolver answers 0 rather than null, which a self-managed\n * version may not.\n */\nfunction gitLabProviderApis(comments: boolean): Presence<PullRequestFieldGroup> {\n\treturn pullRequestPresenceOf(\n\t\t[\n\t\t\t'description',\n\t\t\t'reviews',\n\t\t\t'reviewRequests',\n\t\t\t'assignees',\n\t\t\t'checks',\n\t\t\t'mergeable',\n\t\t\t'reactions',\n\t\t\t...(comments ? (['comments'] as const) : []),\n\t\t],\n\t\t['stack'],\n\t);\n}\n\nfunction gitLabPullRequestsFor(\n\tproviderApis: Presence<PullRequestFieldGroup>,\n): PresenceTable<PullRequestProjection, PullRequestFieldGroup> {\n\treturn {\n\t\tpoint: gitLabOwn,\n\t\tsearch: providerApis,\n\t\t'text-search': gitLabOwn,\n\t\taccount: providerApis,\n\t\t'account-summary': providerApis,\n\t\trepos: providerApis,\n\t\t'repos-summary': providerApis,\n\t\tbatch: providerApis,\n\t};\n}\n\n/**\n * Azure DevOps pull requests have no assignees (both converters fill `assignees` with the reviewers, which `reviews` and\n * `reviewRequests` already hold) and no reactions. Neither converter reads checks or counts.\n */\nconst azureUnavailable: readonly PullRequestFieldGroup[] = ['assignees', 'reactions', 'stack'];\n/** Every list read: Azure truncates a listed pull request's description (to 400 characters). */\nconst azureListed = pullRequestPresenceOf(['reviews', 'reviewRequests', 'mergeable'], azureUnavailable);\n/** The batch reads fetch each pull request by id, which returns the whole description. */\nconst azureById = pullRequestPresenceOf(['description', 'reviews', 'reviewRequests', 'mergeable'], azureUnavailable);\n\nconst azurePullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\t// GitLens' own converter, which leaves the description off the row.\n\tpoint: azureListed,\n\tsearch: azureListed,\n\t'text-search': azureListed,\n\taccount: azureListed,\n\t'account-summary': azureListed,\n\trepos: azureListed,\n\t'repos-summary': azureListed,\n\tbatch: azureById,\n};\n\nconst azureServerPullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\t...azurePullRequests,\n\t'search-summary': azureListed,\n};\n\n/**\n * Bitbucket pull requests have no assignees or reactions. Neither provider-apis nor GitLens reads their build\n * statuses or mergeability: provider-apis fills a literal Mergeable, and GitLens' own converters leave it unset.\n */\nconst bitbucketUnavailable: readonly PullRequestFieldGroup[] = ['assignees', 'reactions', 'stack'];\nconst bitbucketProviderApis = pullRequestPresenceOf(\n\t['description', 'reviews', 'reviewRequests', 'comments'],\n\tbitbucketUnavailable,\n);\n\nconst bitbucketPullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\t// GitLens' own converter, which drops the comment count. The commit read selects `+values.*`, which isn't\n\t// known to bring the participants the reviews come from, as the other two point reads do.\n\tpoint: pullRequestPresenceOf(['description'], bitbucketUnavailable),\n\tsearch: bitbucketProviderApis,\n\t'text-search': bitbucketProviderApis,\n\taccount: bitbucketProviderApis,\n\t'account-summary': bitbucketProviderApis,\n\trepos: bitbucketProviderApis,\n\t'repos-summary': bitbucketProviderApis,\n\t// GitLens' own converter over reads that do select the participants.\n\tbatch: pullRequestPresenceOf(['description', 'reviews', 'reviewRequests'], bitbucketUnavailable),\n};\n\n/** provider-apis' and GitLens' own Data Center converters read the same fields. */\nconst bitbucketServerAll = pullRequestPresenceOf(\n\t['description', 'reviews', 'reviewRequests', 'comments'],\n\tbitbucketUnavailable,\n);\nconst bitbucketServerPullRequests: PresenceTable<PullRequestProjection, PullRequestFieldGroup> = {\n\tpoint: bitbucketServerAll,\n\tsearch: bitbucketServerAll,\n\t'search-summary': bitbucketServerAll,\n\t'text-search': bitbucketServerAll,\n\taccount: bitbucketServerAll,\n\t'account-summary': bitbucketServerAll,\n\trepos: bitbucketServerAll,\n\t'repos-summary': bitbucketServerAll,\n\tbatch: bitbucketServerAll,\n};\n\n/**\n * provider-apis' GitLab issue reads (GraphQL, and REST for the account-wide one). The repository's access isn't read.\n * The GraphQL comment count is nullable like the merge request's, and passed through, so only GitLab.com's is\n * promised; the REST one is always a number.\n */\nfunction gitLabIssuesFor(comments: boolean): PresenceTable<IssueProjection, IssueFieldGroup> {\n\tconst graphQL = issuePresenceOf([\n\t\t'description',\n\t\t'assignees',\n\t\t'labels',\n\t\t'reactions',\n\t\t...(comments ? (['comments'] as const) : []),\n\t]);\n\treturn {\n\t\tpoint: graphQL,\n\t\taccount: issuePresenceOf(['description', 'assignees', 'labels', 'comments', 'reactions']),\n\t\trepos: graphQL,\n\t\tbatch: graphQL,\n\t};\n}\n\n/**\n * Azure DevOps work items have no reactions (provider-apis' converter fills 0; GitLens' leaves it unset) and belong to\n * a project, not a repository.\n */\nconst azureWorkItemUnavailable: readonly IssueFieldGroup[] = ['reactions', 'access'];\n/** provider-apis' work item converter, and GitLens' copy of it for the batch read. */\nconst azureWorkItem = issuePresenceOf(['description', 'assignees', 'labels', 'comments'], azureWorkItemUnavailable);\n/** GitLens' own work item converter, which drops the tags. */\nconst azureOwnWorkItem = issuePresenceOf(['description', 'assignees', 'comments'], azureWorkItemUnavailable);\n\nconst azureIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: azureOwnWorkItem,\n\taccount: azureWorkItem,\n\trepos: azureWorkItem,\n\tbatch: azureWorkItem,\n};\n\nconst azureServerIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\t...azureIssues,\n\tsearch: azureOwnWorkItem,\n};\n\n/**\n * Bitbucket Cloud's legacy issues, which only the host's own `getIssue` and `searchMyIssues` read. They have no\n * labels, their votes aren't reactions, and neither a comment count nor the repository's access is read.\n */\nconst bitbucketIssue = issuePresenceOf(['description', 'assignees'], ['labels', 'reactions']);\nconst bitbucketIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: bitbucketIssue,\n\taccount: bitbucketIssue,\n};\n\n/**\n * Tracker issues belong to no repository, and a tracker's votes aren't reactions (and read 0 where voting is off), so\n * neither group can be supplied.\n */\nconst trackerUnavailable: readonly IssueFieldGroup[] = ['reactions', 'access'];\n/**\n * provider-apis' Jira converter counts the comments embedded in the issue, which Jira may cap, rather than reading\n * their total.\n */\nconst jiraProviderApis = issuePresenceOf(['description', 'assignees', 'labels'], trackerUnavailable);\n\nconst jiraIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: jiraProviderApis,\n\taccount: jiraProviderApis,\n\tproject: jiraProviderApis,\n\t// GitLens' own by-key read, which reads the comment total.\n\tbatch: issuePresenceOf(['description', 'assignees', 'labels', 'comments'], trackerUnavailable),\n};\n\nconst jiraServerIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\t...jiraIssues,\n\tbatch: jiraProviderApis,\n};\n\n/** provider-apis' Linear fragment selects no labels (it fills an empty list), comments or reactions. */\nconst linearIssue = issuePresenceOf(['description', 'assignees'], ['access']);\nconst linearIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: linearIssue,\n\taccount: linearIssue,\n\tproject: linearIssue,\n\tbatch: linearIssue,\n};\n\n/** A Trello card's description is never read; its members are its assignees. */\nconst trelloCard = issuePresenceOf(['assignees', 'labels', 'comments'], trackerUnavailable);\nconst trelloIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: trelloCard,\n\tproject: trelloCard,\n};\n\n/**\n * provider-apis' Asana task fields: its notes, its single assignee, its tags as labels and its likes as reactions.\n * Comments are stories, which a task doesn't count, so reading them would cost a request per task.\n */\nconst asanaTask = issuePresenceOf(['description', 'assignees', 'labels', 'reactions'], ['access']);\nconst asanaIssues: PresenceTable<IssueProjection, IssueFieldGroup> = {\n\tpoint: asanaTask,\n\taccount: asanaTask,\n\tproject: asanaTask,\n};\n\nconst pullRequestPresence = new Map<string, PresenceTable<PullRequestProjection, PullRequestFieldGroup>>([\n\t[GitCloudHostIntegrationId.GitHub, gitHubPullRequests],\n\t[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise, gitHubEnterprisePullRequests],\n\t[GitCloudHostIntegrationId.GitLab, gitLabPullRequestsFor(gitLabProviderApis(true))],\n\t[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted, gitLabPullRequestsFor(gitLabProviderApis(false))],\n\t[GitCloudHostIntegrationId.AzureDevOps, azurePullRequests],\n\t[GitSelfManagedHostIntegrationId.AzureDevOpsServer, azureServerPullRequests],\n\t[GitCloudHostIntegrationId.Bitbucket, bitbucketPullRequests],\n\t[GitSelfManagedHostIntegrationId.BitbucketServer, bitbucketServerPullRequests],\n]);\n\nconst issuePresence = new Map<string, PresenceTable<IssueProjection, IssueFieldGroup>>([\n\t[GitCloudHostIntegrationId.GitHub, gitHubIssues],\n\t[GitSelfManagedHostIntegrationId.CloudGitHubEnterprise, gitHubIssues],\n\t[GitCloudHostIntegrationId.GitLab, gitLabIssuesFor(true)],\n\t[GitSelfManagedHostIntegrationId.CloudGitLabSelfHosted, gitLabIssuesFor(false)],\n\t[GitCloudHostIntegrationId.AzureDevOps, azureIssues],\n\t[GitSelfManagedHostIntegrationId.AzureDevOpsServer, azureServerIssues],\n\t[GitCloudHostIntegrationId.Bitbucket, bitbucketIssues],\n\t[IssuesCloudHostIntegrationId.Jira, jiraIssues],\n\t[IssuesSelfManagedHostIntegrationId.JiraServer, jiraServerIssues],\n\t[IssuesCloudHostIntegrationId.Linear, linearIssues],\n\t[IssuesCloudHostIntegrationId.Trello, trelloIssues],\n\t[IssuesCloudHostIntegrationId.Asana, asanaIssues],\n]);\n\nfunction lookup<P extends string, G extends string>(\n\ttables: ReadonlyMap<string, PresenceTable<P, G>>,\n\tproviderId: string,\n\tprojection: P | undefined,\n): Presence<G> | undefined {\n\tif (projection == null) return undefined;\n\n\tconst table = tables.get(providerId);\n\t// `hasOwn` so a projection read off an untrusted row can't resolve to an `Object.prototype` member.\n\treturn table != null && Object.hasOwn(table, projection) ? table[projection] : undefined;\n}\n\n/**\n * Which field groups the read that produced `pr` fetched, keyed by its provider and {@link PullRequestShape.projection}.\n * `undefined` when either is unknown or the provider has no table yet — then nothing can be said about any field.\n */\nexport function getPullRequestFieldPresence(\n\tpr: PullRequestShape,\n): Readonly<Record<PullRequestFieldGroup, FieldPresence>> | undefined {\n\treturn lookup(pullRequestPresence, pr.provider.id, pr.projection);\n}\n\n/**\n * Which field groups the read that produced `issue` fetched, keyed by its provider and {@link IssueShape.projection}.\n * `undefined` when either is unknown or the provider has no table yet — then nothing can be said about any field.\n */\nexport function getIssueFieldPresence(issue: IssueShape): Readonly<Record<IssueFieldGroup, FieldPresence>> | undefined {\n\treturn lookup(issuePresence, issue.provider.id, issue.projection);\n}\n"],"mappings":";;AA2EA,MAAM,yBAA2D;CAChE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAEA,MAAM,mBAA+C;CACpD;CACA;CACA;CACA;CACA;CACA;AACD;;AAGA,SAAS,WACR,QACA,SACA,cAA4B,CAAC,GACf;CACd,OAAO,OAAO,OACb,OAAO,YACN,OAAO,KACN,UACC,CACC,OACA,QAAQ,SAAS,KAAK,IACnB,YACA,YAAY,SAAS,KAAK,IACzB,gBACA,eACL,CACF,CAC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CACxG,CAAA,UAAmC,kBAAkB;CACrD,CAAA,2BAAwD,4BAA4B;CACpF,CAAA,UAAmC,sBAAsB,mBAAmB,IAAI,CAAC,CAAC;CAClF,CAAA,4BAAwD,sBAAsB,mBAAmB,KAAK,CAAC,CAAC;CACxG,CAAA,eAAwC,iBAAiB;CACzD,CAAA,uBAAoD,uBAAuB;CAC3E,CAAA,aAAsC,qBAAqB;CAC3D,CAAA,oBAAkD,2BAA2B;AAC9E,CAAC;AAED,MAAM,gCAAgB,IAAI,IAA6D;CACtF,CAAA,UAAmC,YAAY;CAC/C,CAAA,2BAAwD,YAAY;CACpE,CAAA,UAAmC,gBAAgB,IAAI,CAAC;CACxD,CAAA,4BAAwD,gBAAgB,KAAK,CAAC;CAC9E,CAAA,eAAwC,WAAW;CACnD,CAAA,uBAAoD,iBAAiB;CACrE,CAAA,aAAsC,eAAe;CACrD,CAAA,QAAoC,UAAU;CAC9C,CAAA,eAAgD,gBAAgB;CAChE,CAAA,UAAsC,YAAY;CAClD,CAAA,UAAsC,YAAY;CAClD,CAAA,SAAqC,WAAW;AACjD,CAAC;AAED,SAAS,OACR,QACA,YACA,YAC0B;CAC1B,IAAI,cAAc,MAAM,OAAO,KAAA;CAE/B,MAAM,QAAQ,OAAO,IAAI,UAAU;CAEnC,OAAO,SAAS,QAAQ,OAAO,OAAO,OAAO,UAAU,IAAI,MAAM,cAAc,KAAA;AAChF;;;;;AAMA,SAAgB,4BACf,IACqE;CACrE,OAAO,OAAO,qBAAqB,GAAG,SAAS,IAAI,GAAG,UAAU;AACjE;;;;;AAMA,SAAgB,sBAAsB,OAAiF;CACtH,OAAO,OAAO,eAAe,MAAM,SAAS,IAAI,MAAM,UAAU;AACjE"}
@@ -386,7 +386,7 @@ export declare class IntegrationService implements Disposable, RepositoryResolut
386
386
  domain?: string;
387
387
  }): Promise<ProviderResult<PullRequestCountResult>>;
388
388
  /**
389
- * Reads the user's issues from an issue-tracker provider (Jira/Linear/Trello), whose issues live under
389
+ * Reads the user's issues from an issue-tracker provider (Jira/Linear/Trello/Asana), whose issues live under
390
390
  * resource → project (not repos), so they can't go through {@link listIssuesPage} (git-host, repo-scoped).
391
391
  * Returns the normalized {@link IssueShape} these providers produce, aggregated across the projects of the
392
392
  * given `org` (or every visible resource/project when omitted). `includeAllAssignees` drops the
@@ -292,7 +292,13 @@ var IntegrationService = class {
292
292
  "./providers/trello.js"
293
293
  ))).TrelloIntegration(this.ctx, this.authenticationService, this.getProvidersApi.bind(this), this._onDidChangeIntegrationConnection);
294
294
  break;
295
- default: throw new Error(`Integration with '${id}' is not supported`);
295
+ case "asana":
296
+ integration = new (await (import(
297
+ /* webpackChunkName: "integrations" */
298
+ "./providers/asana.js"
299
+ ))).AsanaIntegration(this.ctx, this.authenticationService, this.getProvidersApi.bind(this), this._onDidChangeIntegrationConnection);
300
+ break;
301
+ default: throw new Error(`Integration with '${String(id)}' is not supported`);
296
302
  }
297
303
  this._integrations.set(this.getCacheKey(id, domain), integration);
298
304
  }
@@ -668,7 +674,7 @@ var IntegrationService = class {
668
674
  return countPullRequests(this, options);
669
675
  }
670
676
  /**
671
- * Reads the user's issues from an issue-tracker provider (Jira/Linear/Trello), whose issues live under
677
+ * Reads the user's issues from an issue-tracker provider (Jira/Linear/Trello/Asana), whose issues live under
672
678
  * resource → project (not repos), so they can't go through {@link listIssuesPage} (git-host, repo-scoped).
673
679
  * Returns the normalized {@link IssueShape} these providers produce, aggregated across the projects of the
674
680
  * given `org` (or every visible resource/project when omitted). `includeAllAssignees` drops the