* Extracts common metadata fields from a Jira issue into an ExternalDocument * stub with deferred content. The contentHash is metadata-based so it is * identical whether produced during listing or full fetch.
(issue: Record<string, unknown>, domain: string)
| 53 | * identical whether produced during listing or full fetch. |
| 54 | */ |
| 55 | function issueToStub(issue: Record<string, unknown>, domain: string): ExternalDocument { |
| 56 | const fields = (issue.fields || {}) as Record<string, unknown> |
| 57 | const key = issue.key as string |
| 58 | const issueType = fields.issuetype as Record<string, unknown> | undefined |
| 59 | const status = fields.status as Record<string, unknown> | undefined |
| 60 | const priority = fields.priority as Record<string, unknown> | undefined |
| 61 | const assignee = fields.assignee as Record<string, unknown> | undefined |
| 62 | const reporter = fields.reporter as Record<string, unknown> | undefined |
| 63 | const project = fields.project as Record<string, unknown> | undefined |
| 64 | const labels = Array.isArray(fields.labels) ? (fields.labels as string[]) : [] |
| 65 | const updated = (fields.updated as string) ?? '' |
| 66 | |
| 67 | return { |
| 68 | externalId: String(issue.id), |
| 69 | title: `${key}: ${(fields.summary as string) || 'Untitled'}`, |
| 70 | content: '', |
| 71 | contentDeferred: true, |
| 72 | mimeType: 'text/plain', |
| 73 | sourceUrl: `https://${domain}/browse/${key}`, |
| 74 | contentHash: `jira:${issue.id}:${updated}`, |
| 75 | metadata: { |
| 76 | key, |
| 77 | issueType: issueType?.name, |
| 78 | status: status?.name, |
| 79 | priority: priority?.name, |
| 80 | assignee: assignee?.displayName, |
| 81 | reporter: reporter?.displayName, |
| 82 | project: project?.key, |
| 83 | labels, |
| 84 | created: fields.created, |
| 85 | updated: fields.updated, |
| 86 | }, |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Converts a fully-fetched Jira issue (with description and comments) into an |
no outgoing calls
no test coverage detected