@gitkraken/core-gitlens 0.41.0 → 0.43.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.
- package/CHANGELOG.md +12 -1
- package/dist/git/models/issue.d.ts +2 -0
- package/dist/git/models/issue.js.map +1 -1
- package/dist/git/models/issueOrPullRequest.d.ts +4 -0
- package/dist/git/models/pullRequest.d.ts +2 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +2 -4
- package/dist/plus/git-github/api/github.js +12 -2
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/api/issueWrites.d.ts +3 -2
- package/dist/plus/git-github/api/issueWrites.js +10 -5
- package/dist/plus/git-github/api/issueWrites.js.map +1 -1
- package/dist/plus/git-github/models.js +7 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/index.d.ts +2 -2
- package/dist/plus/integrations/index.js.map +1 -1
- package/dist/plus/integrations/integrationService.d.ts +2 -1
- package/dist/plus/integrations/integrationService.js +14 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/manager.d.ts +9 -1
- package/dist/plus/integrations/providers/azure/azure.js +20 -14
- package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
- package/dist/plus/integrations/providers/azure/models.js +7 -3
- package/dist/plus/integrations/providers/azure/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js +18 -13
- package/dist/plus/integrations/providers/bitbucket/bitbucket.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket/models.js +5 -2
- package/dist/plus/integrations/providers/bitbucket/models.js.map +1 -1
- package/dist/plus/integrations/providers/bitbucket-server/models.js +3 -1
- package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
- package/dist/plus/integrations/providers/github.d.ts +2 -4
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.js +12 -6
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/models.js +5 -2
- package/dist/plus/integrations/providers/gitlab/models.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +0 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js +3 -1
- package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
- package/dist/plus/integrations/providers/models.js +9 -4
- package/dist/plus/integrations/providers/models.js.map +1 -1
- package/dist/plus/integrations/providers/providerApiClient.js +10 -7
- package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
- package/dist/plus/integrations/providers/providersApi.js +3 -1
- package/dist/plus/integrations/providers/providersApi.js.map +1 -1
- package/dist/plus/integrations/reads/drains.d.ts +0 -1
- package/docs/integrations.md +15 -9
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jiraIssueByKey.js","names":[],"sources":["../../../../../plus/integrations/src/providers/jiraIssueByKey.ts"],"sourcesContent":["import { trimTrailingSlashes } from '@gitlens/utils/path.js';\nimport type { IssueEtagFields } from '../models/integration.js';\nimport type { ProviderAccount, ProviderIssue, ProviderRequestFunction } from './models.js';\n\nconst jiraCloudApiUrl = 'https://api.atlassian.com/ex/jira';\nconst jiraIssueByKeyFields = [\n\t'assignee',\n\t'comment',\n\t'created',\n\t'creator',\n\t'description',\n\t'issuetype',\n\t'labels',\n\t'project',\n\t'status',\n\t'summary',\n\t'updated',\n\t'votes',\n];\n\ntype JiraIssueMemberResponse = {\n\taccountId?: string;\n\tdisplayName?: string | null;\n\temailAddress?: string | null;\n\tavatarUrls?: Record<string, string | undefined>;\n};\n\ntype JiraIssueStatusResponse = {\n\tid: string;\n\tname: string;\n\tstatusCategory: {\n\t\tcolorName: string;\n\t\tkey: string;\n\t\tname: string;\n\t};\n};\n\ntype JiraIssueByKeyResponse = {\n\tid: string;\n\tkey: string;\n\tfields: {\n\t\tassignee?: JiraIssueMemberResponse | null;\n\t\tcomment?: { comments?: unknown[]; total?: number };\n\t\tcreated: string;\n\t\tcreator?: JiraIssueMemberResponse | null;\n\t\tdescription?: string | null;\n\t\tissuetype?: { name?: string | null };\n\t\tlabels?: string[];\n\t\tproject?: { id?: string | null; key?: string | null; name?: string | null };\n\t\tstatus: JiraIssueStatusResponse;\n\t\tsummary: string;\n\t\tupdated: string;\n\t\tvotes?: { votes?: number | null };\n\t};\n};\n\nfunction toAccount(member: JiraIssueMemberResponse | null | undefined): ProviderAccount | null {\n\tif (member == null) return null;\n\n\treturn {\n\t\tid: member.accountId ?? '',\n\t\tname: member.displayName ?? null,\n\t\tusername: member.displayName ?? null,\n\t\temail: member.emailAddress ?? null,\n\t\tavatarUrl: member.avatarUrls?.['48x48'] ?? null,\n\t\turl: null,\n\t};\n}\n\nfunction toStatusCategory(key: string): 'TO_DO' | 'IN_PROGRESS' | 'DONE' {\n\tswitch (key.toLowerCase()) {\n\t\tcase 'new':\n\t\t\treturn 'TO_DO';\n\t\tcase 'indeterminate':\n\t\t\treturn 'IN_PROGRESS';\n\t\tcase 'done':\n\t\t\treturn 'DONE';\n\t\tdefault:\n\t\t\treturn 'TO_DO';\n\t}\n}\n\nfunction toJiraIssueState(status: JiraIssueStatusResponse): NonNullable<ProviderIssue['state']> {\n\treturn {\n\t\tid: status.id,\n\t\tname: status.name,\n\t\tcolor: status.statusCategory.colorName,\n\t\tcategory: toStatusCategory(status.statusCategory.key),\n\t};\n}\n\nfunction toIssueWebUrl(resourceUrl: string, key: string): string {\n\tconst url = new URL(resourceUrl);\n\turl.pathname = `${trimTrailingSlashes(url.pathname)}/browse/${encodeURIComponent(key)}`;\n\turl.search = '';\n\turl.hash = '';\n\treturn url.toString();\n}\n\nfunction fromJiraIssueByKey(issue: JiraIssueByKeyResponse, resourceId: string, resourceUrl: string): ProviderIssue {\n\tconst assignee = toAccount(issue.fields.assignee);\n\tconst project = issue.fields.project;\n\tconst status = issue.fields.status;\n\n\treturn {\n\t\tid: issue.id,\n\t\tcommentCount: issue.fields.comment?.total ?? issue.fields.comment?.comments?.length ?? null,\n\t\tnumber: issue.key,\n\t\ttitle: issue.fields.summary,\n\t\turl: toIssueWebUrl(resourceUrl, issue.key),\n\t\tclosedDate: null,\n\t\tcreatedDate: new Date(issue.fields.created),\n\t\tauthor: toAccount(issue.fields.creator),\n\t\tupdatedDate: new Date(issue.fields.updated),\n\t\tassignees: assignee != null ? [assignee] : [],\n\t\tdescription: issue.fields.description ?? null,\n\t\trepository: null,\n\t\tproject:\n\t\t\tproject != null\n\t\t\t\t? {\n\t\t\t\t\t\tname: project.name ?? '',\n\t\t\t\t\t\tresourceId: resourceId,\n\t\t\t\t\t\tkey: project.key ?? null,\n\t\t\t\t\t\tnamespace: null,\n\t\t\t\t\t\tid: project.id ?? null,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\tstate: toJiraIssueState(status),\n\t\ttype: issue.fields.issuetype?.name ?? null,\n\t\tupvoteCount: issue.fields.votes?.votes ?? null,\n\t\tlabels: (issue.fields.labels ?? []).map(label => ({\n\t\t\tcolor: null,\n\t\t\tdescription: null,\n\t\t\tid: null,\n\t\t\tname: label,\n\t\t})),\n\t};\n}\n\n/**\n * The SDK's Jira point read performs resource and field discovery before the issue GET. This focused path uses\n * caller-supplied resource identity so a cold lookup remains one upstream request.\n */\nexport async function requestJiraIssueByKey(\n\trequest: ProviderRequestFunction,\n\taccessToken: string,\n\tresourceId: string,\n\tresourceUrl: string,\n\tkey: string,\n): Promise<ProviderIssue> {\n\tconst url = new URL(\n\t\t`${jiraCloudApiUrl}/${encodeURIComponent(resourceId)}/rest/api/2/issue/${encodeURIComponent(key)}`,\n\t);\n\turl.searchParams.set('fields', jiraIssueByKeyFields.join(','));\n\n\tconst response = await request<JiraIssueByKeyResponse>({\n\t\turl: url.toString(),\n\t\theaders: { Authorization: `Bearer ${accessToken}` },\n\t});\n\treturn fromJiraIssueByKey(response.body, resourceId, resourceUrl);\n}\n\n/**\n * The most keys one bulk fetch takes. Atlassian allows up to 1000 for a request that names its fields explicitly, but\n * documents 100 as the default limit.\n */\nexport const jiraBulkFetchMaxKeys = 100;\n\n/**\n * One issue of a bulk fetch that asks for `status` and `updated` only. The bulk fetch is API v3 while the full read is\n * v2, but these two fields have the same shape in both: the v2 and v3 OpenAPI specs define the same `StatusDetails`\n * and `StatusCategory`, and a live comparison found both fields byte-identical. v3 differs in rich-text fields, which\n * it returns as ADF, so this request must never widen to `description`. `self` differs too, and is never read.\n */\nexport type JiraIssueEtagResponse = {\n\tid: string;\n\tkey: string;\n\tfields: Partial<Pick<JiraIssueByKeyResponse['fields'], 'status' | 'updated'>>;\n};\n\ntype JiraBulkFetchResponse = {\n\tissues?: JiraIssueEtagResponse[];\n\t/**\n\t * Only issues Jira could not return for a retriable error or a payload constraint, by numeric issue id rather than\n\t * the key asked for. Issues that don't exist or aren't visible are NOT listed here, nor in `issues`: they are\n\t * silently omitted, so a bulk fetch never proves an absence.\n\t */\n\tissueErrors?: { id?: string; errorMessage?: string }[];\n};\n\n/**\n * The cheap check behind the batch issue read's etags: `status` and `updated` of up to {@link jiraBulkFetchMaxKeys}\n * issues of one site in ONE request, where {@link requestJiraIssueByKey} reads one issue per request. Jira returns the\n * issues in its own order, each under its CURRENT key (a lowercase or moved key resolves to the issue it names now), and\n * omits the ones it can't find, so a caller matches them to its keys by key, never by position.\n */\nexport async function requestJiraIssuesEtagFields(\n\trequest: ProviderRequestFunction,\n\taccessToken: string,\n\tresourceId: string,\n\tkeys: readonly string[],\n): Promise<{ issues: JiraIssueEtagResponse[]; errorCount: number }> {\n\tconst response = await request<JiraBulkFetchResponse | null>({\n\t\turl: `${jiraCloudApiUrl}/${encodeURIComponent(resourceId)}/rest/api/3/issue/bulkfetch`,\n\t\tmethod: 'POST',\n\t\theaders: { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' },\n\t\tbody: JSON.stringify({ issueIdsOrKeys: keys, fields: ['status', 'updated'] }),\n\t});\n\n\tconst issues = response.body?.issues;\n\tif (!Array.isArray(issues)) throw new Error('Jira bulk fetch returned no issues');\n\n\treturn { issues: issues, errorCount: response.body?.issueErrors?.length ?? 0 };\n}\n\n/**\n * A bulk-fetched issue's change state, as the fields the full row's etag reads. {@link fromJiraIssueByKey} maps the\n * status with the same {@link toJiraIssueState} and never sets `closedDate`, so `toIssueShape` closes exactly the\n * issues whose status category is done. Throws on a missing status or an unparseable `updated`, so the target falls\n * through to the full read rather than matching an etag that would ignore its update time.\n */\nexport function toJiraIssueEtagFields(issue: JiraIssueEtagResponse): IssueEtagFields {\n\tconst { status, updated } = issue.fields;\n\tif (status?.statusCategory == null) throw new Error(`Jira bulk fetch returned no status for ${issue.key}`);\n\n\tconst updatedDate = new Date(updated ?? Number.NaN);\n\tif (Number.isNaN(updatedDate.getTime())) {\n\t\tthrow new Error(`Jira bulk fetch returned no update time for ${issue.key}`);\n\t}\n\n\treturn { state: toJiraIssueState(status).category === 'DONE' ? 'closed' : 'opened', updatedDate: updatedDate };\n}\n"],"mappings":";;AAIA,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD;AAsCA,SAAS,UAAU,QAA4E;CAC9F,IAAI,UAAU,MAAM,OAAO;CAE3B,OAAO;EACN,IAAI,OAAO,aAAa;EACxB,MAAM,OAAO,eAAe;EAC5B,UAAU,OAAO,eAAe;EAChC,OAAO,OAAO,gBAAgB;EAC9B,WAAW,OAAO,aAAa,YAAY;EAC3C,KAAK;CACN;AACD;AAEA,SAAS,iBAAiB,KAA+C;CACxE,QAAQ,IAAI,YAAY,GAAxB;EACC,KAAK,OACJ,OAAO;EACR,KAAK,iBACJ,OAAO;EACR,KAAK,QACJ,OAAO;EACR,SACC,OAAO;CACT;AACD;AAEA,SAAS,iBAAiB,QAAsE;CAC/F,OAAO;EACN,IAAI,OAAO;EACX,MAAM,OAAO;EACb,OAAO,OAAO,eAAe;EAC7B,UAAU,iBAAiB,OAAO,eAA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mBAAmB,UAAU,EAAE,oBAAoB,mBAAmB,GAAG,GAChG;CACA,IAAI,aAAa,IAAI,UAAU,qBAAqB,KAAK,GAAG,CAAC;CAM7D,OAAO,oBAAmB,MAJH,QAAgC;EACtD,KAAK,IAAI,SAAS;EAClB,SAAS,EAAE,eAAe,UAAU,cAAc;CACnD,CAAC,EAAA,CACkC,MAAM,YAAY,WAAW;AACjE;;;;;AAMA,MAAa,uBAAuB;;;;;;;AA8BpC,eAAsB,4BACrB,SACA,aACA,YACA,MACmE;CACnE,MAAM,WAAW,MAAM,QAAsC;EAC5D,KAAK,GAAG,gBAAgB,GAAG,mBAAmB,UAAU,EAAE;EAC1D,QAAQ;EACR,SAAS;GAAE,eAAe,UAAU;GAAe,gBAAgB;EAAmB;EACtF,MAAM,KAAK,UAAU;GAAE,gBAAgB;GAAM,QAAQ,CAAC,UAAU,SAAS;EAAE,CAAC;CAC7E,CAAC;CAED,MAAM,SAAS,SAAS,MAAM;CAC9B,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,MAAM,IAAI,MAAM,oCAAoC;CAEhF,OAAO;EAAU;EAAQ,YAAY,SAAS,MAAM,aAAa,UAAU;CAAE;AAC9E;;;;;;;AAQA,SAAgB,sBAAsB,OAA+C;CACpF,MAAM,EAAE,QAAQ,YAAY,MAAM;CAClC,IAAI,QAAQ,kBAAkB,MAAM,MAAM,IAAI,MAAM,0CAA0C,MAAM,KAAK;CAEzG,MAAM,cAAc,IAAI,KAAK,WAAW,GAAU;CAClD,IAAI,OAAO,MAAM,YAAY,QAAQ,CAAC,GACrC,MAAM,IAAI,MAAM,+CAA+C,MAAM,KAAK;CAG3E,OAAO;EAAE,OAAO,iBAAiB,MAAM,CAAC,CAAC,aAAa,SAAS,WAAW;EAAuB;CAAY;AAC9G"}
|
|
1
|
+
{"version":3,"file":"jiraIssueByKey.js","names":[],"sources":["../../../../../plus/integrations/src/providers/jiraIssueByKey.ts"],"sourcesContent":["import { copyReadProvenance } from '@gitkraken/provider-apis/read-provenance';\nimport { trimTrailingSlashes } from '@gitlens/utils/path.js';\nimport type { IssueEtagFields } from '../models/integration.js';\nimport type { ProviderAccount, ProviderIssue, ProviderRequestFunction } from './models.js';\n\nconst jiraCloudApiUrl = 'https://api.atlassian.com/ex/jira';\nconst jiraIssueByKeyFields = [\n\t'assignee',\n\t'comment',\n\t'created',\n\t'creator',\n\t'description',\n\t'issuetype',\n\t'labels',\n\t'project',\n\t'status',\n\t'summary',\n\t'updated',\n\t'votes',\n];\n\ntype JiraIssueMemberResponse = {\n\taccountId?: string;\n\tdisplayName?: string | null;\n\temailAddress?: string | null;\n\tavatarUrls?: Record<string, string | undefined>;\n};\n\ntype JiraIssueStatusResponse = {\n\tid: string;\n\tname: string;\n\tstatusCategory: {\n\t\tcolorName: string;\n\t\tkey: string;\n\t\tname: string;\n\t};\n};\n\ntype JiraIssueByKeyResponse = {\n\tid: string;\n\tkey: string;\n\tfields: {\n\t\tassignee?: JiraIssueMemberResponse | null;\n\t\tcomment?: { comments?: unknown[]; total?: number };\n\t\tcreated: string;\n\t\tcreator?: JiraIssueMemberResponse | null;\n\t\tdescription?: string | null;\n\t\tissuetype?: { name?: string | null };\n\t\tlabels?: string[];\n\t\tproject?: { id?: string | null; key?: string | null; name?: string | null };\n\t\tstatus: JiraIssueStatusResponse;\n\t\tsummary: string;\n\t\tupdated: string;\n\t\tvotes?: { votes?: number | null };\n\t};\n};\n\nfunction toAccount(member: JiraIssueMemberResponse | null | undefined): ProviderAccount | null {\n\tif (member == null) return null;\n\n\treturn {\n\t\tid: member.accountId ?? '',\n\t\tname: member.displayName ?? null,\n\t\tusername: member.displayName ?? null,\n\t\temail: member.emailAddress ?? null,\n\t\tavatarUrl: member.avatarUrls?.['48x48'] ?? null,\n\t\turl: null,\n\t};\n}\n\nfunction toStatusCategory(key: string): 'TO_DO' | 'IN_PROGRESS' | 'DONE' {\n\tswitch (key.toLowerCase()) {\n\t\tcase 'new':\n\t\t\treturn 'TO_DO';\n\t\tcase 'indeterminate':\n\t\t\treturn 'IN_PROGRESS';\n\t\tcase 'done':\n\t\t\treturn 'DONE';\n\t\tdefault:\n\t\t\treturn 'TO_DO';\n\t}\n}\n\nfunction toJiraIssueState(status: JiraIssueStatusResponse): NonNullable<ProviderIssue['state']> {\n\treturn {\n\t\tid: status.id,\n\t\tname: status.name,\n\t\tcolor: status.statusCategory.colorName,\n\t\tcategory: toStatusCategory(status.statusCategory.key),\n\t};\n}\n\nfunction toIssueWebUrl(resourceUrl: string, key: string): string {\n\tconst url = new URL(resourceUrl);\n\turl.pathname = `${trimTrailingSlashes(url.pathname)}/browse/${encodeURIComponent(key)}`;\n\turl.search = '';\n\turl.hash = '';\n\treturn url.toString();\n}\n\nfunction fromJiraIssueByKey(issue: JiraIssueByKeyResponse, resourceId: string, resourceUrl: string): ProviderIssue {\n\tconst assignee = toAccount(issue.fields.assignee);\n\tconst project = issue.fields.project;\n\tconst status = issue.fields.status;\n\n\tconst result: ProviderIssue = {\n\t\tid: issue.id,\n\t\tcommentCount: issue.fields.comment?.total ?? issue.fields.comment?.comments?.length ?? null,\n\t\tnumber: issue.key,\n\t\ttitle: issue.fields.summary,\n\t\turl: toIssueWebUrl(resourceUrl, issue.key),\n\t\tclosedDate: null,\n\t\tcreatedDate: new Date(issue.fields.created),\n\t\tauthor: toAccount(issue.fields.creator),\n\t\tupdatedDate: new Date(issue.fields.updated),\n\t\tassignees: assignee != null ? [assignee] : [],\n\t\tdescription: issue.fields.description ?? null,\n\t\trepository: null,\n\t\tproject:\n\t\t\tproject != null\n\t\t\t\t? {\n\t\t\t\t\t\tname: project.name ?? '',\n\t\t\t\t\t\tresourceId: resourceId,\n\t\t\t\t\t\tkey: project.key ?? null,\n\t\t\t\t\t\tnamespace: null,\n\t\t\t\t\t\tid: project.id ?? null,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\tstate: toJiraIssueState(status),\n\t\ttype: issue.fields.issuetype?.name ?? null,\n\t\tupvoteCount: issue.fields.votes?.votes ?? null,\n\t\tlabels: (issue.fields.labels ?? []).map(label => ({\n\t\t\tcolor: null,\n\t\t\tdescription: null,\n\t\t\tid: null,\n\t\t\tname: label,\n\t\t})),\n\t};\n\treturn copyReadProvenance(result, issue);\n}\n\n/**\n * The SDK's Jira point read performs resource and field discovery before the issue GET. This focused path uses\n * caller-supplied resource identity so a cold lookup remains one upstream request.\n */\nexport async function requestJiraIssueByKey(\n\trequest: ProviderRequestFunction,\n\taccessToken: string,\n\tresourceId: string,\n\tresourceUrl: string,\n\tkey: string,\n): Promise<ProviderIssue> {\n\tconst url = new URL(\n\t\t`${jiraCloudApiUrl}/${encodeURIComponent(resourceId)}/rest/api/2/issue/${encodeURIComponent(key)}`,\n\t);\n\turl.searchParams.set('fields', jiraIssueByKeyFields.join(','));\n\n\tconst response = await request<JiraIssueByKeyResponse>({\n\t\turl: url.toString(),\n\t\theaders: { Authorization: `Bearer ${accessToken}` },\n\t});\n\treturn fromJiraIssueByKey(response.body, resourceId, resourceUrl);\n}\n\n/**\n * The most keys one bulk fetch takes. Atlassian allows up to 1000 for a request that names its fields explicitly, but\n * documents 100 as the default limit.\n */\nexport const jiraBulkFetchMaxKeys = 100;\n\n/**\n * One issue of a bulk fetch that asks for `status` and `updated` only. The bulk fetch is API v3 while the full read is\n * v2, but these two fields have the same shape in both: the v2 and v3 OpenAPI specs define the same `StatusDetails`\n * and `StatusCategory`, and a live comparison found both fields byte-identical. v3 differs in rich-text fields, which\n * it returns as ADF, so this request must never widen to `description`. `self` differs too, and is never read.\n */\nexport type JiraIssueEtagResponse = {\n\tid: string;\n\tkey: string;\n\tfields: Partial<Pick<JiraIssueByKeyResponse['fields'], 'status' | 'updated'>>;\n};\n\ntype JiraBulkFetchResponse = {\n\tissues?: JiraIssueEtagResponse[];\n\t/**\n\t * Only issues Jira could not return for a retriable error or a payload constraint, by numeric issue id rather than\n\t * the key asked for. Issues that don't exist or aren't visible are NOT listed here, nor in `issues`: they are\n\t * silently omitted, so a bulk fetch never proves an absence.\n\t */\n\tissueErrors?: { id?: string; errorMessage?: string }[];\n};\n\n/**\n * The cheap check behind the batch issue read's etags: `status` and `updated` of up to {@link jiraBulkFetchMaxKeys}\n * issues of one site in ONE request, where {@link requestJiraIssueByKey} reads one issue per request. Jira returns the\n * issues in its own order, each under its CURRENT key (a lowercase or moved key resolves to the issue it names now), and\n * omits the ones it can't find, so a caller matches them to its keys by key, never by position.\n */\nexport async function requestJiraIssuesEtagFields(\n\trequest: ProviderRequestFunction,\n\taccessToken: string,\n\tresourceId: string,\n\tkeys: readonly string[],\n): Promise<{ issues: JiraIssueEtagResponse[]; errorCount: number }> {\n\tconst response = await request<JiraBulkFetchResponse | null>({\n\t\turl: `${jiraCloudApiUrl}/${encodeURIComponent(resourceId)}/rest/api/3/issue/bulkfetch`,\n\t\tmethod: 'POST',\n\t\theaders: { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' },\n\t\tbody: JSON.stringify({ issueIdsOrKeys: keys, fields: ['status', 'updated'] }),\n\t});\n\n\tconst issues = response.body?.issues;\n\tif (!Array.isArray(issues)) throw new Error('Jira bulk fetch returned no issues');\n\n\treturn { issues: issues, errorCount: response.body?.issueErrors?.length ?? 0 };\n}\n\n/**\n * A bulk-fetched issue's change state, as the fields the full row's etag reads. {@link fromJiraIssueByKey} maps the\n * status with the same {@link toJiraIssueState} and never sets `closedDate`, so `toIssueShape` closes exactly the\n * issues whose status category is done. Throws on a missing status or an unparseable `updated`, so the target falls\n * through to the full read rather than matching an etag that would ignore its update time.\n */\nexport function toJiraIssueEtagFields(issue: JiraIssueEtagResponse): IssueEtagFields {\n\tconst { status, updated } = issue.fields;\n\tif (status?.statusCategory == null) throw new Error(`Jira bulk fetch returned no status for ${issue.key}`);\n\n\tconst updatedDate = new Date(updated ?? Number.NaN);\n\tif (Number.isNaN(updatedDate.getTime())) {\n\t\tthrow new Error(`Jira bulk fetch returned no update time for ${issue.key}`);\n\t}\n\n\treturn { state: toJiraIssueState(status).category === 'DONE'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AAC,UAAU,SAAS;EAAE,CAAC;CAC7E,CAAC;CAED,MAAM,SAAS,SAAS,MAAM;CAC9B,IAAI,CAAC,MAAM,QAAQ,MAAM,GAAG,MAAM,IAAI,MAAM,oCAAoC;CAEhF,OAAO;EAAU;EAAQ,YAAY,SAAS,MAAM,aAAa,UAAU;CAAE;AAC9E;;;;;;;AAQA,SAAgB,sBAAsB,OAA+C;CACpF,MAAM,EAAE,QAAQ,YAAY,MAAM;CAClC,IAAI,QAAQ,kBAAkB,MAAM,MAAM,IAAI,MAAM,0CAA0C,MAAM,KAAK;CAEzG,MAAM,cAAc,IAAI,KAAK,WAAW,GAAU;CAClD,IAAI,OAAO,MAAM,YAAY,QAAQ,CAAC,GACrC,MAAM,IAAI,MAAM,+CAA+C,MAAM,KAAK;CAG3E,OAAO;EAAE,OAAO,iBAAiB,MAAM,CAAC,CAAC,aAAa,SAAS,WAAW;EAAuB;CAAY;AAC9G"}
|
|
@@ -12,6 +12,7 @@ import { asanaIssueSorts, azureAccountWideIssueSorts, azureIssueSorts, githubAcc
|
|
|
12
12
|
import { fromPullRequestReviewDecision, toCompletedReviews, toProviderReviewDecision, toProviderReviews, toReviewRequests } from "./pullRequestReviews.js";
|
|
13
13
|
import { getEntityIdentifierInput } from "./utils.js";
|
|
14
14
|
import { isJiraIntegrationId } from "../utils/integration.utils.js";
|
|
15
|
+
import { copyReadProvenance } from "@gitkraken/provider-apis/read-provenance";
|
|
15
16
|
import { EntityIdentifierUtils, GitProviderUtils } from "@gitkraken/provider-apis";
|
|
16
17
|
//#region ../plus/integrations/src/providers/models.ts
|
|
17
18
|
const GitBuildStatusState = {
|
|
@@ -612,7 +613,7 @@ function getProviderIssueState(issue, providerId) {
|
|
|
612
613
|
function toIssueShape(issue, provider, options) {
|
|
613
614
|
if (issue.updatedDate == null || issue.url == null) return void 0;
|
|
614
615
|
const state = getProviderIssueState(issue, provider.id);
|
|
615
|
-
|
|
616
|
+
const result = {
|
|
616
617
|
type: "issue",
|
|
617
618
|
provider,
|
|
618
619
|
id: toIssueIdentifier(issue.number),
|
|
@@ -659,6 +660,7 @@ function toIssueShape(issue, provider, options) {
|
|
|
659
660
|
...issue.syncedWith != null ? { syncedWith: toIssueSyncedWith(issue.syncedWith) } : {},
|
|
660
661
|
...issue.milestone !== void 0 ? { milestone: toIssueMilestone(issue.milestone) } : {}
|
|
661
662
|
};
|
|
663
|
+
return copyReadProvenance(result, issue);
|
|
662
664
|
}
|
|
663
665
|
/**
|
|
664
666
|
* provider-apis' `id` is a GitHub milestone's per-repository number and a GitLab milestone's bare database id, so the
|
|
@@ -879,7 +881,7 @@ function toProviderRemoteInfo(ref) {
|
|
|
879
881
|
}
|
|
880
882
|
function toProviderPullRequest(pr) {
|
|
881
883
|
const prReviews = [...pr.reviewRequests ?? [], ...pr.latestReviews ?? []];
|
|
882
|
-
|
|
884
|
+
const result = {
|
|
883
885
|
id: pr.id,
|
|
884
886
|
graphQLId: pr.nodeId,
|
|
885
887
|
number: pr.number ?? Number.parseInt(pr.id, 10),
|
|
@@ -944,6 +946,7 @@ function toProviderPullRequest(pr) {
|
|
|
944
946
|
},
|
|
945
947
|
mergeableState: pr.mergeableState ? toProviderPullRequestMergeableState[pr.mergeableState] : void 0
|
|
946
948
|
};
|
|
949
|
+
return copyReadProvenance(result, pr);
|
|
947
950
|
}
|
|
948
951
|
/**
|
|
949
952
|
* `options.currentAccount` is what `authoredByMe` and `viewer` are resolved against, or `null` where the read tried to
|
|
@@ -956,7 +959,7 @@ function fromProviderPullRequest(pr, provider, options) {
|
|
|
956
959
|
const repositoryRemoteInfo = repository?.remoteInfo;
|
|
957
960
|
const headRepository = pr.headRepository;
|
|
958
961
|
const headRepositoryRemoteInfo = headRepository?.remoteInfo;
|
|
959
|
-
|
|
962
|
+
const result = new PullRequest(provider, fromProviderAccount(pr.author), pr.id, pr.graphQLId || pr.id, pr.title, pr.url ?? "", {
|
|
960
963
|
owner: repositoryOwner,
|
|
961
964
|
repo: repositoryName,
|
|
962
965
|
id: repository?.id || void 0
|
|
@@ -984,6 +987,7 @@ function fromProviderPullRequest(pr, provider, options) {
|
|
|
984
987
|
},
|
|
985
988
|
isCrossRepository: pr.isCrossRepository
|
|
986
989
|
}, pr.isDraft, pr.additions ?? void 0, pr.deletions ?? void 0, pr.commentCount ?? void 0, pr.upvoteCount ?? void 0, pr.reviewDecision ? fromPullRequestReviewDecision[pr.reviewDecision] : void 0, toReviewRequests(pr.reviews), toCompletedReviews(pr.reviews), pr.assignees?.map(fromProviderAccount) ?? void 0, toStatusCheckRollupState(pr.headCommit?.buildStatuses), options?.project, pr.version, pr.commitCount ?? void 0, void 0, pr.fileCount ?? void 0, pr.description ?? void 0, pr.number, options?.currentAccount != null ? authoredByCurrentAccount(pr.author, provider, options.currentAccount) : void 0, options?.projection, options?.currentAccount ?? void 0, options?.currentAccount === null && pullRequestNamesPeople(pr) ? true : void 0, pr.milestone !== void 0 ? toIssueMilestone(pr.milestone) : void 0);
|
|
990
|
+
return copyReadProvenance(result, pr);
|
|
987
991
|
}
|
|
988
992
|
/**
|
|
989
993
|
* A GitLens-native row (GitHub's own reads) tagged for the read that returned it, with `authoredByMe` and `viewer`
|
|
@@ -1059,7 +1063,7 @@ function fromProviderIssue(issue, integration, options) {
|
|
|
1059
1063
|
const identifier = toIssueIdentifier(issue.number);
|
|
1060
1064
|
const state = getProviderIssueState(issue, integration.id);
|
|
1061
1065
|
const viewer = toIssueViewer(issue, options?.viewer);
|
|
1062
|
-
|
|
1066
|
+
const result = new Issue$1(integration, identifier, issue.graphQLId ?? issue.id, issue.title, issue.url ?? "", issue.createdDate, issue.updatedDate ?? issue.closedDate ?? issue.createdDate, state === "closed", state, fromProviderAccount(issue.author), issue.assignees?.map(fromProviderAccount) ?? void 0, issue.repository != null ? {
|
|
1063
1067
|
owner: issue.repository.owner.login ?? "",
|
|
1064
1068
|
repo: issue.repository.name,
|
|
1065
1069
|
id: issue.repository.id || void 0
|
|
@@ -1072,6 +1076,7 @@ function fromProviderIssue(issue, integration, options) {
|
|
|
1072
1076
|
resourceId: options.project.resourceId,
|
|
1073
1077
|
resourceName: options.project.resourceName
|
|
1074
1078
|
} : toIssueProject(issue.project, integration), identifier, issue.type ?? void 0, toIssueProviderState(issue.state), integration.id === "jira" ? "jira-wiki" : void 0, toIssueIterations(issue), options?.projection, issue.descriptionField != null ? toIssueBodyField(issue.descriptionField) : void 0, viewer?.viewer, viewer?.viewerUnresolved, issue.syncedWith != null ? toIssueSyncedWith(issue.syncedWith) : void 0, issue.milestone !== void 0 ? toIssueMilestone(issue.milestone) : void 0);
|
|
1079
|
+
return copyReadProvenance(result, issue);
|
|
1075
1080
|
}
|
|
1076
1081
|
function toProviderPullRequestWithUniqueId(pr) {
|
|
1077
1082
|
const { reviews, mergeableState, ...providerPr } = toProviderPullRequest(pr);
|