diff --git a/src/plus/integrations/providers/azure/azure.ts b/src/plus/integrations/providers/azure/azure.ts index 8b754ce31cede..7c90d56f73ff9 100644 --- a/src/plus/integrations/providers/azure/azure.ts +++ b/src/plus/integrations/providers/azure/azure.ts @@ -27,6 +27,7 @@ import { Logger } from '../../../../system/logger'; import type { LogScope } from '../../../../system/logger.scope'; import { getLogScope } from '../../../../system/logger.scope'; import { maybeStopWatch } from '../../../../system/stopwatch'; +import type { AzurePullRequest, WorkItem } from './models'; export class AzureDevOpsApi implements Disposable { private readonly _disposable: Disposable; @@ -77,67 +78,8 @@ export class AzureDevOpsApi implements Disposable { const [projectName, _, repoName] = repo.split('/'); try { - interface ResultAzureUser { - displayName: string; - url: string; - _links: { - avatar: { - href: string; - }; - }; - id: string; - uniqueName: string; - imageUrl: string; - descriptor: string; - } - interface WorkItemResult { - _links: { - fields: { - href: string; - }; - html: { - href: string; - }; - self: { - href: string; - }; - workItemComments: { - href: string; - }; - workItemRevisions: { - href: string; - }; - workItemType: { - href: string; - }; - workItemUpdates: { - href: string; - }; - }; - fields: { - 'System.AreaPath': string; - 'System.TeamProject': string; - 'System.IterationPath': string; - 'System.WorkItemType': string; - 'System.State': string; - 'System.Reason': string; - 'System.CreatedDate': string; - 'System.CreatedBy': ResultAzureUser; - 'System.ChangedDate': string; - 'System.ChangedBy': ResultAzureUser; - 'System.CommentCount': number; - 'System.Title': string; - 'Microsoft.VSTS.Common.StateChangeDate': string; - 'Microsoft.VSTS.Common.Priority': number; - 'Microsoft.VSTS.Common.Severity': string; - 'Microsoft.VSTS.Common.ValueArea': string; - }; - id: number; - rev: number; - url: string; - } // Try to get the Work item (wit) first with specific fields - const issueResult = await this.request( + const issueResult = await this.request( provider, token, options?.baseUrl, @@ -163,67 +105,7 @@ export class AzureDevOpsApi implements Disposable { }; } - interface PullRequestResult { - repository: unknown; - pullRequestId: number; - codeReviewId: number; - status: string; - createdBy: ResultAzureUser; - creationDate: string; - closedDate: string; - title: string; - description: string; - sourceRefName: string; - targetRefName: string; - isDraft: boolean; - mergeId: string; - lastMergeSourceCommit: { - commitId: string; - url: string; - }; - lastMergeTargetCommit: { - commitId: string; - url: string; - }; - reviewers: unknown[]; - url: string; - _links: { - self: { - href: string; - }; - repository: { - href: string; - }; - workItems: { - href: string; - }; - sourceBranch: { - href: string; - }; - targetBranch: { - href: string; - }; - statuses: { - href: string; - }; - sourceCommit: { - href: string; - }; - targetCommit: { - href: string; - }; - createdBy: { - href: string; - }; - iterations: { - href: string; - }; - }; - supportsIterations: boolean; - artifactId: string; - } - - const prResult = await this.request( + const prResult = await this.request( provider, token, options?.baseUrl, diff --git a/src/plus/integrations/providers/azure/models.ts b/src/plus/integrations/providers/azure/models.ts new file mode 100644 index 0000000000000..38ab9259665f0 --- /dev/null +++ b/src/plus/integrations/providers/azure/models.ts @@ -0,0 +1,90 @@ +export interface AzureUser { + displayName: string; + url: string; + _links: { + avatar: { + href: string; + }; + }; + id: string; + uniqueName: string; + imageUrl: string; + descriptor: string; +} + +export interface AzureLink { + href: string; +} + +export interface WorkItem { + _links: { + fields: AzureLink; + html: AzureLink; + self: AzureLink; + workItemComments: AzureLink; + workItemRevisions: AzureLink; + workItemType: AzureLink; + workItemUpdates: AzureLink; + }; + fields: { + // 'System.AreaPath': string; + // 'System.TeamProject': string; + // 'System.IterationPath': string; + 'System.WorkItemType': string; + 'System.State': string; + // 'System.Reason': string; + 'System.CreatedDate': string; + // 'System.CreatedBy': AzureUser; + 'System.ChangedDate': string; + // 'System.ChangedBy': AzureUser; + // 'System.CommentCount': number; + 'System.Title': string; + // 'Microsoft.VSTS.Common.StateChangeDate': string; + // 'Microsoft.VSTS.Common.Priority': number; + // 'Microsoft.VSTS.Common.Severity': string; + // 'Microsoft.VSTS.Common.ValueArea': string; + }; + id: number; + rev: number; + url: string; +} + +export interface AzurePullRequest { + repository: unknown; + pullRequestId: number; + codeReviewId: number; + status: string; + createdBy: AzureUser; + creationDate: string; + closedDate: string; + title: string; + description: string; + sourceRefName: string; + targetRefName: string; + isDraft: boolean; + mergeId: string; + lastMergeSourceCommit: { + commitId: string; + url: string; + }; + lastMergeTargetCommit: { + commitId: string; + url: string; + }; + reviewers: unknown[]; + url: string; + _links: { + self: AzureLink; + repository: AzureLink; + workItems: AzureLink; + sourceBranch: AzureLink; + targetBranch: AzureLink; + statuses: AzureLink; + sourceCommit: AzureLink; + targetCommit: AzureLink; + createdBy: AzureLink; + iterations: AzureLink; + }; + supportsIterations: boolean; + artifactId: string; +}