@mcp-consultant-tools/azure-devops 27.0.0-beta.1 → 27.0.0-beta.11
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/build/AzureDevOpsService.d.ts +64 -0
- package/build/AzureDevOpsService.d.ts.map +1 -1
- package/build/AzureDevOpsService.js +424 -2
- package/build/AzureDevOpsService.js.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +991 -13
- package/build/index.js.map +1 -1
- package/build/sync/file-utils.d.ts +86 -0
- package/build/sync/file-utils.d.ts.map +1 -0
- package/build/sync/file-utils.js +224 -0
- package/build/sync/file-utils.js.map +1 -0
- package/build/sync/git-utils.d.ts +31 -0
- package/build/sync/git-utils.d.ts.map +1 -0
- package/build/sync/git-utils.js +116 -0
- package/build/sync/git-utils.js.map +1 -0
- package/build/sync/html-converter.d.ts +32 -0
- package/build/sync/html-converter.d.ts.map +1 -0
- package/build/sync/html-converter.js +91 -0
- package/build/sync/html-converter.js.map +1 -0
- package/build/sync/html-detection.d.ts +93 -0
- package/build/sync/html-detection.d.ts.map +1 -0
- package/build/sync/html-detection.js +169 -0
- package/build/sync/html-detection.js.map +1 -0
- package/build/sync/index.d.ts +12 -0
- package/build/sync/index.d.ts.map +1 -0
- package/build/sync/index.js +12 -0
- package/build/sync/index.js.map +1 -0
- package/build/sync/markdown-serializer.d.ts +136 -0
- package/build/sync/markdown-serializer.d.ts.map +1 -0
- package/build/sync/markdown-serializer.js +646 -0
- package/build/sync/markdown-serializer.js.map +1 -0
- package/build/sync/task-serializer.d.ts +93 -0
- package/build/sync/task-serializer.d.ts.map +1 -0
- package/build/sync/task-serializer.js +395 -0
- package/build/sync/task-serializer.js.map +1 -0
- package/build/tool-examples.d.ts +56 -0
- package/build/tool-examples.d.ts.map +1 -0
- package/build/tool-examples.js +142 -0
- package/build/tool-examples.js.map +1 -0
- package/package.json +3 -1
|
@@ -281,6 +281,8 @@ export declare class AzureDevOpsService {
|
|
|
281
281
|
* @returns Work items matching the query
|
|
282
282
|
*/
|
|
283
283
|
queryWorkItems(project: string, wiql: string, maxResults?: number): Promise<any>;
|
|
284
|
+
runSavedQuery(project: string, queryId: string, maxResults?: number): Promise<any>;
|
|
285
|
+
getSavedQuery(project: string, queryId: string): Promise<any>;
|
|
284
286
|
/**
|
|
285
287
|
* Get comments/discussion for a work item
|
|
286
288
|
* @param project The project name
|
|
@@ -304,6 +306,15 @@ export declare class AzureDevOpsService {
|
|
|
304
306
|
* @returns Updated work item
|
|
305
307
|
*/
|
|
306
308
|
updateWorkItem(project: string, workItemId: number, patchOperations: any[]): Promise<any>;
|
|
309
|
+
/**
|
|
310
|
+
* Set work item field(s) to markdown format.
|
|
311
|
+
* This is IRREVERSIBLE - once set to markdown, cannot revert to HTML.
|
|
312
|
+
*
|
|
313
|
+
* @param project - Project name
|
|
314
|
+
* @param workItemId - Work item ID
|
|
315
|
+
* @param fields - Array of field names to set to markdown format (e.g., ['System.Description'])
|
|
316
|
+
*/
|
|
317
|
+
setFieldsToMarkdownFormat(project: string, workItemId: number, fields: string[]): Promise<void>;
|
|
307
318
|
/**
|
|
308
319
|
* Create a new work item
|
|
309
320
|
* @param project The project name
|
|
@@ -338,6 +349,30 @@ export declare class AzureDevOpsService {
|
|
|
338
349
|
* @returns Variable group details with variables
|
|
339
350
|
*/
|
|
340
351
|
getVariableGroup(project: string, groupId: number): Promise<any>;
|
|
352
|
+
/**
|
|
353
|
+
* Get build status with optional timeline and logs
|
|
354
|
+
* @param project The project name
|
|
355
|
+
* @param buildId The build ID
|
|
356
|
+
* @param detail Level of detail: 'summary', 'timeline', or 'full'
|
|
357
|
+
* @param timelineScope Scope for timeline: 'stages', 'jobs', 'all', 'problems'
|
|
358
|
+
* @param maxIssues Maximum issues per record
|
|
359
|
+
*/
|
|
360
|
+
getBuildStatus(project: string, buildId: number, detail?: string, timelineScope?: 'stages' | 'jobs' | 'all' | 'problems', maxIssues?: number): Promise<any>;
|
|
361
|
+
/**
|
|
362
|
+
* Get build timeline with step-by-step breakdown
|
|
363
|
+
* @param project The project name
|
|
364
|
+
* @param buildId The build ID
|
|
365
|
+
* @param scope Filter scope: 'stages', 'jobs', 'all', 'problems'
|
|
366
|
+
* @param maxIssues Maximum issues per record
|
|
367
|
+
*/
|
|
368
|
+
getBuildTimeline(project: string, buildId: number, scope?: 'stages' | 'jobs' | 'all' | 'problems', maxIssues?: number): Promise<any>;
|
|
369
|
+
/**
|
|
370
|
+
* Get build logs (list or specific log content)
|
|
371
|
+
* @param project The project name
|
|
372
|
+
* @param buildId The build ID
|
|
373
|
+
* @param logId Optional specific log ID to retrieve content
|
|
374
|
+
*/
|
|
375
|
+
getBuildLogs(project: string, buildId: number, logId?: number): Promise<any>;
|
|
341
376
|
/**
|
|
342
377
|
* List all Git repositories in a project
|
|
343
378
|
* @param project The project name
|
|
@@ -404,5 +439,34 @@ export declare class AzureDevOpsService {
|
|
|
404
439
|
* @returns Created thread
|
|
405
440
|
*/
|
|
406
441
|
addPullRequestThread(project: string, repositoryId: string, pullRequestId: number, content: string, filePath?: string, lineNumber?: number, status?: 'active' | 'fixed' | 'wontFix' | 'closed' | 'byDesign' | 'pending'): Promise<any>;
|
|
442
|
+
/**
|
|
443
|
+
* Create a new pull request
|
|
444
|
+
*/
|
|
445
|
+
createPullRequest(project: string, repositoryId: string, sourceRefName: string, targetRefName: string, title: string, description?: string, reviewerIds?: string[], isDraft?: boolean): Promise<any>;
|
|
446
|
+
/**
|
|
447
|
+
* Update an existing pull request (title, description, status, draft)
|
|
448
|
+
*/
|
|
449
|
+
updatePullRequest(project: string, repositoryId: string, pullRequestId: number, updates: {
|
|
450
|
+
title?: string;
|
|
451
|
+
description?: string;
|
|
452
|
+
status?: 'abandoned' | 'active';
|
|
453
|
+
isDraft?: boolean;
|
|
454
|
+
}): Promise<any>;
|
|
455
|
+
/**
|
|
456
|
+
* Complete (merge) a pull request
|
|
457
|
+
*/
|
|
458
|
+
completePullRequest(project: string, repositoryId: string, pullRequestId: number, mergeStrategy?: 'squash' | 'noFastForward' | 'rebase' | 'rebaseMerge', deleteSourceBranch?: boolean, transitionWorkItems?: boolean, mergeCommitMessage?: string): Promise<any>;
|
|
459
|
+
/**
|
|
460
|
+
* Add or remove a reviewer from a pull request
|
|
461
|
+
*/
|
|
462
|
+
addOrRemovePrReviewer(project: string, repositoryId: string, pullRequestId: number, reviewerId: string, isRequired?: boolean, remove?: boolean): Promise<any>;
|
|
463
|
+
/**
|
|
464
|
+
* Submit a vote on a pull request
|
|
465
|
+
*/
|
|
466
|
+
votePullRequest(project: string, repositoryId: string, pullRequestId: number, vote: 'approve' | 'approveWithSuggestions' | 'noResponse' | 'waitForAuthor' | 'reject', reviewerId?: string): Promise<any>;
|
|
467
|
+
/**
|
|
468
|
+
* Reply to a PR thread and optionally update thread status
|
|
469
|
+
*/
|
|
470
|
+
replyToPrThread(project: string, repositoryId: string, pullRequestId: number, threadId: number, content?: string, status?: 'active' | 'fixed' | 'wontFix' | 'closed' | 'byDesign' | 'pending'): Promise<any>;
|
|
407
471
|
}
|
|
408
472
|
//# sourceMappingURL=AzureDevOpsService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AzureDevOpsService.d.ts","sourceRoot":"","sources":["../src/AzureDevOpsService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AzureDevOpsService.d.ts","sourceRoot":"","sources":["../src/AzureDevOpsService.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,UAAU,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,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,UAAU,EAAE,MAAM,EAClB,UAAU,CAAC,EAAE,OAAO,EACpB,MAAM,CAAC,EAAE,OAAO,GACf,OAAO,CAAC,GAAG,CAAC;IA+Bf;;OAEG;IACG,eAAe,CACnB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,SAAS,GAAG,wBAAwB,GAAG,YAAY,GAAG,eAAe,GAAG,QAAQ,EACtF,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,GAAG,CAAC;IA4Cf;;OAEG;IACG,eAAe,CACnB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAC1E,OAAO,CAAC,GAAG,CAAC;CAsChB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import { marked } from 'marked';
|
|
3
|
+
import { getAllLargeTextFields } from './sync/html-detection.js';
|
|
3
4
|
export class AzureDevOpsService {
|
|
4
5
|
config;
|
|
5
6
|
baseUrl;
|
|
@@ -504,6 +505,35 @@ export class AzureDevOpsService {
|
|
|
504
505
|
workItems: workItems.value
|
|
505
506
|
};
|
|
506
507
|
}
|
|
508
|
+
async runSavedQuery(project, queryId, maxResults = 200) {
|
|
509
|
+
this.validateProject(project);
|
|
510
|
+
const queryResult = await this.makeRequest(`${project}/_apis/wit/wiql/${queryId}?api-version=${this.apiVersion}`, 'GET');
|
|
511
|
+
if (!queryResult.workItems || queryResult.workItems.length === 0) {
|
|
512
|
+
return {
|
|
513
|
+
queryId,
|
|
514
|
+
project,
|
|
515
|
+
totalCount: 0,
|
|
516
|
+
workItems: []
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
const workItemIds = queryResult.workItems
|
|
520
|
+
.slice(0, maxResults)
|
|
521
|
+
.map((wi) => wi.id);
|
|
522
|
+
const workItems = await this.makeRequest(`${project}/_apis/wit/workitemsbatch?api-version=${this.apiVersion}`, 'POST', {
|
|
523
|
+
ids: workItemIds,
|
|
524
|
+
$expand: 'all'
|
|
525
|
+
});
|
|
526
|
+
return {
|
|
527
|
+
queryId,
|
|
528
|
+
project,
|
|
529
|
+
totalCount: workItems.value.length,
|
|
530
|
+
workItems: workItems.value
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
async getSavedQuery(project, queryId) {
|
|
534
|
+
this.validateProject(project);
|
|
535
|
+
return this.makeRequest(`${project}/_apis/wit/queries/${queryId}?api-version=${this.apiVersion}`, 'GET');
|
|
536
|
+
}
|
|
507
537
|
/**
|
|
508
538
|
* Get comments/discussion for a work item
|
|
509
539
|
* @param project The project name
|
|
@@ -514,8 +544,8 @@ export class AzureDevOpsService {
|
|
|
514
544
|
this.validateProject(project);
|
|
515
545
|
// Comments API requires -preview suffix (not GA in 7.1)
|
|
516
546
|
const response = await this.makeRequest(`${project}/_apis/wit/workItems/${workItemId}/comments?api-version=7.1-preview`);
|
|
517
|
-
//
|
|
518
|
-
const comments = response.value || [];
|
|
547
|
+
// v7.1 Comments API returns array in response.comments, not response.value
|
|
548
|
+
const comments = response.comments || response.value || [];
|
|
519
549
|
return {
|
|
520
550
|
workItemId,
|
|
521
551
|
project,
|
|
@@ -582,6 +612,25 @@ export class AzureDevOpsService {
|
|
|
582
612
|
project
|
|
583
613
|
};
|
|
584
614
|
}
|
|
615
|
+
/**
|
|
616
|
+
* Set work item field(s) to markdown format.
|
|
617
|
+
* This is IRREVERSIBLE - once set to markdown, cannot revert to HTML.
|
|
618
|
+
*
|
|
619
|
+
* @param project - Project name
|
|
620
|
+
* @param workItemId - Work item ID
|
|
621
|
+
* @param fields - Array of field names to set to markdown format (e.g., ['System.Description'])
|
|
622
|
+
*/
|
|
623
|
+
async setFieldsToMarkdownFormat(project, workItemId, fields) {
|
|
624
|
+
if (!this.config.enableWorkItemWrite) {
|
|
625
|
+
throw new Error('Work item write operations are disabled. Set AZUREDEVOPS_ENABLE_WORK_ITEM_WRITE=true to enable.');
|
|
626
|
+
}
|
|
627
|
+
const patchOperations = fields.map(field => ({
|
|
628
|
+
op: 'add',
|
|
629
|
+
path: `/multilineFieldsFormat/${field}`,
|
|
630
|
+
value: 'Markdown'
|
|
631
|
+
}));
|
|
632
|
+
await this.updateWorkItem(project, workItemId, patchOperations);
|
|
633
|
+
}
|
|
585
634
|
/**
|
|
586
635
|
* Create a new work item
|
|
587
636
|
* @param project The project name
|
|
@@ -606,6 +655,19 @@ export class AzureDevOpsService {
|
|
|
606
655
|
value: fields[field]
|
|
607
656
|
});
|
|
608
657
|
});
|
|
658
|
+
// Auto-set markdown format for large text fields that are being set
|
|
659
|
+
// This ensures all new work items use markdown format (irreversible)
|
|
660
|
+
// Uses getAllLargeTextFields() to include custom fields like Custom.Howtotest
|
|
661
|
+
const allLargeTextFields = getAllLargeTextFields();
|
|
662
|
+
for (const field of allLargeTextFields) {
|
|
663
|
+
if (fields[field] !== undefined) {
|
|
664
|
+
patchOperations.push({
|
|
665
|
+
op: 'add',
|
|
666
|
+
path: `/multilineFieldsFormat/${field}`,
|
|
667
|
+
value: 'Markdown'
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
}
|
|
609
671
|
// Handle parentId parameter (simplified parent relationship)
|
|
610
672
|
if (parentId !== undefined) {
|
|
611
673
|
const parentUrl = `${this.baseUrl}/${encodeURIComponent(project)}/_apis/wit/workItems/${parentId}`;
|
|
@@ -726,6 +788,181 @@ export class AzureDevOpsService {
|
|
|
726
788
|
};
|
|
727
789
|
}
|
|
728
790
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
791
|
+
// BUILD TROUBLESHOOTING OPERATIONS (Read-only)
|
|
792
|
+
// NOTE: These methods are duplicated in azure-devops-admin package.
|
|
793
|
+
// If you update these, also update packages/azure-devops-admin/src/AzureDevOpsAdminService.ts
|
|
794
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
795
|
+
/**
|
|
796
|
+
* Get build status with optional timeline and logs
|
|
797
|
+
* @param project The project name
|
|
798
|
+
* @param buildId The build ID
|
|
799
|
+
* @param detail Level of detail: 'summary', 'timeline', or 'full'
|
|
800
|
+
* @param timelineScope Scope for timeline: 'stages', 'jobs', 'all', 'problems'
|
|
801
|
+
* @param maxIssues Maximum issues per record
|
|
802
|
+
*/
|
|
803
|
+
async getBuildStatus(project, buildId, detail = 'summary', timelineScope = 'problems', maxIssues = 5) {
|
|
804
|
+
this.validateProject(project);
|
|
805
|
+
const response = await this.makeRequest(`${project}/_apis/build/builds/${buildId}?api-version=${this.apiVersion}`);
|
|
806
|
+
const result = {
|
|
807
|
+
id: response.id,
|
|
808
|
+
buildNumber: response.buildNumber,
|
|
809
|
+
status: response.status,
|
|
810
|
+
result: response.result,
|
|
811
|
+
queueTime: response.queueTime,
|
|
812
|
+
startTime: response.startTime,
|
|
813
|
+
finishTime: response.finishTime,
|
|
814
|
+
sourceBranch: response.sourceBranch,
|
|
815
|
+
sourceVersion: response.sourceVersion,
|
|
816
|
+
definition: response.definition ? {
|
|
817
|
+
id: response.definition.id,
|
|
818
|
+
name: response.definition.name
|
|
819
|
+
} : null,
|
|
820
|
+
requestedBy: response.requestedBy?.displayName,
|
|
821
|
+
requestedFor: response.requestedFor?.displayName,
|
|
822
|
+
reason: response.reason,
|
|
823
|
+
priority: response.priority,
|
|
824
|
+
project: response.project?.name,
|
|
825
|
+
url: response._links?.web?.href
|
|
826
|
+
};
|
|
827
|
+
if (detail === 'timeline' || detail === 'full') {
|
|
828
|
+
const timeline = await this.getBuildTimeline(project, buildId, timelineScope, maxIssues);
|
|
829
|
+
result.timeline = timeline;
|
|
830
|
+
}
|
|
831
|
+
if (detail === 'full') {
|
|
832
|
+
const logs = await this.getBuildLogs(project, buildId);
|
|
833
|
+
result.logs = logs;
|
|
834
|
+
}
|
|
835
|
+
return result;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Get build timeline with step-by-step breakdown
|
|
839
|
+
* @param project The project name
|
|
840
|
+
* @param buildId The build ID
|
|
841
|
+
* @param scope Filter scope: 'stages', 'jobs', 'all', 'problems'
|
|
842
|
+
* @param maxIssues Maximum issues per record
|
|
843
|
+
*/
|
|
844
|
+
async getBuildTimeline(project, buildId, scope = 'problems', maxIssues = 5) {
|
|
845
|
+
this.validateProject(project);
|
|
846
|
+
const response = await this.makeRequest(`${project}/_apis/build/builds/${buildId}/timeline?api-version=${this.apiVersion}`);
|
|
847
|
+
const allRecords = response.records || [];
|
|
848
|
+
const summary = {
|
|
849
|
+
total: allRecords.length,
|
|
850
|
+
byType: {},
|
|
851
|
+
byResult: {},
|
|
852
|
+
totalErrors: 0,
|
|
853
|
+
totalWarnings: 0,
|
|
854
|
+
failed: [],
|
|
855
|
+
};
|
|
856
|
+
for (const record of allRecords) {
|
|
857
|
+
summary.byType[record.type] = (summary.byType[record.type] || 0) + 1;
|
|
858
|
+
if (record.result) {
|
|
859
|
+
summary.byResult[record.result] = (summary.byResult[record.result] || 0) + 1;
|
|
860
|
+
}
|
|
861
|
+
summary.totalErrors += record.errorCount || 0;
|
|
862
|
+
summary.totalWarnings += record.warningCount || 0;
|
|
863
|
+
if (record.result === 'failed' || record.result === 'canceled') {
|
|
864
|
+
summary.failed.push(`${record.type}: ${record.name}`);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
let filteredRecords = allRecords;
|
|
868
|
+
switch (scope) {
|
|
869
|
+
case 'stages':
|
|
870
|
+
filteredRecords = allRecords.filter((r) => r.type === 'Stage');
|
|
871
|
+
break;
|
|
872
|
+
case 'jobs':
|
|
873
|
+
filteredRecords = allRecords.filter((r) => r.type === 'Stage' || r.type === 'Job');
|
|
874
|
+
break;
|
|
875
|
+
case 'problems':
|
|
876
|
+
filteredRecords = allRecords.filter((r) => (r.errorCount && r.errorCount > 0) ||
|
|
877
|
+
(r.warningCount && r.warningCount > 0) ||
|
|
878
|
+
r.result === 'failed' ||
|
|
879
|
+
r.result === 'canceled');
|
|
880
|
+
break;
|
|
881
|
+
case 'all':
|
|
882
|
+
default:
|
|
883
|
+
break;
|
|
884
|
+
}
|
|
885
|
+
const truncateIssues = (issues, max) => {
|
|
886
|
+
if (!issues || issues.length === 0)
|
|
887
|
+
return { items: [], totalCount: 0, truncated: false };
|
|
888
|
+
const sorted = [...issues].sort((a, b) => {
|
|
889
|
+
const priority = (issue) => {
|
|
890
|
+
if (issue.type === 'error')
|
|
891
|
+
return 0;
|
|
892
|
+
if (issue.type === 'warning')
|
|
893
|
+
return 1;
|
|
894
|
+
return 2;
|
|
895
|
+
};
|
|
896
|
+
return priority(a) - priority(b);
|
|
897
|
+
});
|
|
898
|
+
return {
|
|
899
|
+
items: sorted.slice(0, max),
|
|
900
|
+
totalCount: issues.length,
|
|
901
|
+
truncated: issues.length > max
|
|
902
|
+
};
|
|
903
|
+
};
|
|
904
|
+
const mappedRecords = filteredRecords.map((record) => {
|
|
905
|
+
const truncatedIssues = truncateIssues(record.issues, maxIssues);
|
|
906
|
+
return {
|
|
907
|
+
id: record.id,
|
|
908
|
+
parentId: record.parentId,
|
|
909
|
+
type: record.type,
|
|
910
|
+
name: record.name,
|
|
911
|
+
state: record.state,
|
|
912
|
+
result: record.result,
|
|
913
|
+
startTime: record.startTime,
|
|
914
|
+
finishTime: record.finishTime,
|
|
915
|
+
order: record.order,
|
|
916
|
+
errorCount: record.errorCount,
|
|
917
|
+
warningCount: record.warningCount,
|
|
918
|
+
log: record.log ? { id: record.log.id } : null,
|
|
919
|
+
issues: truncatedIssues.items,
|
|
920
|
+
issuesTruncated: truncatedIssues.truncated,
|
|
921
|
+
totalIssueCount: truncatedIssues.totalCount
|
|
922
|
+
};
|
|
923
|
+
});
|
|
924
|
+
return {
|
|
925
|
+
buildId,
|
|
926
|
+
project,
|
|
927
|
+
scope,
|
|
928
|
+
summary,
|
|
929
|
+
recordCount: mappedRecords.length,
|
|
930
|
+
records: mappedRecords
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Get build logs (list or specific log content)
|
|
935
|
+
* @param project The project name
|
|
936
|
+
* @param buildId The build ID
|
|
937
|
+
* @param logId Optional specific log ID to retrieve content
|
|
938
|
+
*/
|
|
939
|
+
async getBuildLogs(project, buildId, logId) {
|
|
940
|
+
this.validateProject(project);
|
|
941
|
+
if (logId !== undefined) {
|
|
942
|
+
const response = await this.makeRequest(`${project}/_apis/build/builds/${buildId}/logs/${logId}?api-version=${this.apiVersion}`);
|
|
943
|
+
return {
|
|
944
|
+
buildId,
|
|
945
|
+
logId,
|
|
946
|
+
project,
|
|
947
|
+
content: response
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
const response = await this.makeRequest(`${project}/_apis/build/builds/${buildId}/logs?api-version=${this.apiVersion}`);
|
|
951
|
+
return {
|
|
952
|
+
buildId,
|
|
953
|
+
project,
|
|
954
|
+
totalCount: response.value.length,
|
|
955
|
+
logs: response.value.map((log) => ({
|
|
956
|
+
id: log.id,
|
|
957
|
+
type: log.type,
|
|
958
|
+
lineCount: log.lineCount,
|
|
959
|
+
createdOn: log.createdOn,
|
|
960
|
+
lastChangedOn: log.lastChangedOn,
|
|
961
|
+
url: log.url
|
|
962
|
+
}))
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
729
966
|
// PULL REQUEST OPERATIONS
|
|
730
967
|
// ═══════════════════════════════════════════════════════════════════════════════
|
|
731
968
|
/**
|
|
@@ -1004,5 +1241,190 @@ export class AzureDevOpsService {
|
|
|
1004
1241
|
project
|
|
1005
1242
|
};
|
|
1006
1243
|
}
|
|
1244
|
+
/**
|
|
1245
|
+
* Create a new pull request
|
|
1246
|
+
*/
|
|
1247
|
+
async createPullRequest(project, repositoryId, sourceRefName, targetRefName, title, description, reviewerIds, isDraft) {
|
|
1248
|
+
this.validateProject(project);
|
|
1249
|
+
if (!this.config.enablePullRequestWrite) {
|
|
1250
|
+
throw new Error('Pull request write operations are disabled. Set AZUREDEVOPS_ENABLE_PR_WRITE=true to enable.');
|
|
1251
|
+
}
|
|
1252
|
+
const body = {
|
|
1253
|
+
sourceRefName,
|
|
1254
|
+
targetRefName,
|
|
1255
|
+
title,
|
|
1256
|
+
description: description || '',
|
|
1257
|
+
isDraft: isDraft || false,
|
|
1258
|
+
};
|
|
1259
|
+
if (reviewerIds && reviewerIds.length > 0) {
|
|
1260
|
+
body.reviewers = reviewerIds.map(id => ({ id }));
|
|
1261
|
+
}
|
|
1262
|
+
const response = await this.makeRequest(`${project}/_apis/git/repositories/${repositoryId}/pullrequests?api-version=${this.apiVersion}`, 'POST', body, false, { 'Content-Type': 'application/json' });
|
|
1263
|
+
return {
|
|
1264
|
+
pullRequestId: response.pullRequestId,
|
|
1265
|
+
title: response.title,
|
|
1266
|
+
status: response.status,
|
|
1267
|
+
isDraft: response.isDraft,
|
|
1268
|
+
sourceBranch: response.sourceRefName?.replace('refs/heads/', ''),
|
|
1269
|
+
targetBranch: response.targetRefName?.replace('refs/heads/', ''),
|
|
1270
|
+
createdBy: response.createdBy?.displayName,
|
|
1271
|
+
creationDate: response.creationDate,
|
|
1272
|
+
url: response.url,
|
|
1273
|
+
project
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* Update an existing pull request (title, description, status, draft)
|
|
1278
|
+
*/
|
|
1279
|
+
async updatePullRequest(project, repositoryId, pullRequestId, updates) {
|
|
1280
|
+
this.validateProject(project);
|
|
1281
|
+
if (!this.config.enablePullRequestWrite) {
|
|
1282
|
+
throw new Error('Pull request write operations are disabled. Set AZUREDEVOPS_ENABLE_PR_WRITE=true to enable.');
|
|
1283
|
+
}
|
|
1284
|
+
const body = {};
|
|
1285
|
+
if (updates.title !== undefined)
|
|
1286
|
+
body.title = updates.title;
|
|
1287
|
+
if (updates.description !== undefined)
|
|
1288
|
+
body.description = updates.description;
|
|
1289
|
+
if (updates.status !== undefined)
|
|
1290
|
+
body.status = updates.status;
|
|
1291
|
+
if (updates.isDraft !== undefined)
|
|
1292
|
+
body.isDraft = updates.isDraft;
|
|
1293
|
+
const response = await this.makeRequest(`${project}/_apis/git/repositories/${repositoryId}/pullrequests/${pullRequestId}?api-version=${this.apiVersion}`, 'PATCH', body, false, { 'Content-Type': 'application/json' });
|
|
1294
|
+
return {
|
|
1295
|
+
pullRequestId: response.pullRequestId,
|
|
1296
|
+
title: response.title,
|
|
1297
|
+
description: response.description ? this.truncate(response.description, 200) : null,
|
|
1298
|
+
status: response.status,
|
|
1299
|
+
isDraft: response.isDraft,
|
|
1300
|
+
project
|
|
1301
|
+
};
|
|
1302
|
+
}
|
|
1303
|
+
/**
|
|
1304
|
+
* Complete (merge) a pull request
|
|
1305
|
+
*/
|
|
1306
|
+
async completePullRequest(project, repositoryId, pullRequestId, mergeStrategy = 'squash', deleteSourceBranch = true, transitionWorkItems = true, mergeCommitMessage) {
|
|
1307
|
+
this.validateProject(project);
|
|
1308
|
+
if (!this.config.enablePullRequestWrite) {
|
|
1309
|
+
throw new Error('Pull request write operations are disabled. Set AZUREDEVOPS_ENABLE_PR_WRITE=true to enable.');
|
|
1310
|
+
}
|
|
1311
|
+
// Fetch current PR to get lastMergeSourceCommit
|
|
1312
|
+
const currentPr = await this.makeRequest(`${project}/_apis/git/repositories/${repositoryId}/pullrequests/${pullRequestId}?api-version=${this.apiVersion}`);
|
|
1313
|
+
const mergeStrategyMap = {
|
|
1314
|
+
noFastForward: 1,
|
|
1315
|
+
squash: 2,
|
|
1316
|
+
rebase: 3,
|
|
1317
|
+
rebaseMerge: 4,
|
|
1318
|
+
};
|
|
1319
|
+
const body = {
|
|
1320
|
+
status: 'completed',
|
|
1321
|
+
lastMergeSourceCommit: currentPr.lastMergeSourceCommit,
|
|
1322
|
+
completionOptions: {
|
|
1323
|
+
mergeStrategy: mergeStrategyMap[mergeStrategy],
|
|
1324
|
+
deleteSourceBranch,
|
|
1325
|
+
transitionWorkItems,
|
|
1326
|
+
},
|
|
1327
|
+
};
|
|
1328
|
+
if (mergeCommitMessage) {
|
|
1329
|
+
body.completionOptions.mergeCommitMessage = mergeCommitMessage;
|
|
1330
|
+
}
|
|
1331
|
+
const response = await this.makeRequest(`${project}/_apis/git/repositories/${repositoryId}/pullrequests/${pullRequestId}?api-version=${this.apiVersion}`, 'PATCH', body, false, { 'Content-Type': 'application/json' });
|
|
1332
|
+
return {
|
|
1333
|
+
pullRequestId: response.pullRequestId,
|
|
1334
|
+
title: response.title,
|
|
1335
|
+
status: response.status,
|
|
1336
|
+
mergeStrategy,
|
|
1337
|
+
closedDate: response.closedDate,
|
|
1338
|
+
project
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Add or remove a reviewer from a pull request
|
|
1343
|
+
*/
|
|
1344
|
+
async addOrRemovePrReviewer(project, repositoryId, pullRequestId, reviewerId, isRequired, remove) {
|
|
1345
|
+
this.validateProject(project);
|
|
1346
|
+
if (!this.config.enablePullRequestWrite) {
|
|
1347
|
+
throw new Error('Pull request write operations are disabled. Set AZUREDEVOPS_ENABLE_PR_WRITE=true to enable.');
|
|
1348
|
+
}
|
|
1349
|
+
const url = `${project}/_apis/git/repositories/${repositoryId}/pullrequests/${pullRequestId}/reviewers/${reviewerId}?api-version=${this.apiVersion}`;
|
|
1350
|
+
if (remove) {
|
|
1351
|
+
await this.makeRequest(url, 'DELETE');
|
|
1352
|
+
return { pullRequestId, reviewerId, action: 'removed', project };
|
|
1353
|
+
}
|
|
1354
|
+
const body = { id: reviewerId };
|
|
1355
|
+
if (isRequired !== undefined) {
|
|
1356
|
+
body.isRequired = isRequired;
|
|
1357
|
+
}
|
|
1358
|
+
const response = await this.makeRequest(url, 'PUT', body, false, { 'Content-Type': 'application/json' });
|
|
1359
|
+
return {
|
|
1360
|
+
pullRequestId,
|
|
1361
|
+
reviewerId: response.id,
|
|
1362
|
+
displayName: response.displayName,
|
|
1363
|
+
isRequired: response.isRequired,
|
|
1364
|
+
vote: response.vote,
|
|
1365
|
+
action: 'added',
|
|
1366
|
+
project
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
/**
|
|
1370
|
+
* Submit a vote on a pull request
|
|
1371
|
+
*/
|
|
1372
|
+
async votePullRequest(project, repositoryId, pullRequestId, vote, reviewerId) {
|
|
1373
|
+
this.validateProject(project);
|
|
1374
|
+
if (!this.config.enablePullRequestWrite) {
|
|
1375
|
+
throw new Error('Pull request write operations are disabled. Set AZUREDEVOPS_ENABLE_PR_WRITE=true to enable.');
|
|
1376
|
+
}
|
|
1377
|
+
const voteMap = {
|
|
1378
|
+
approve: 10,
|
|
1379
|
+
approveWithSuggestions: 5,
|
|
1380
|
+
noResponse: 0,
|
|
1381
|
+
waitForAuthor: -5,
|
|
1382
|
+
reject: -10,
|
|
1383
|
+
};
|
|
1384
|
+
// If no reviewerId, resolve authenticated user
|
|
1385
|
+
let userId = reviewerId;
|
|
1386
|
+
if (!userId) {
|
|
1387
|
+
const connectionData = await this.makeRequest('_apis/connectionData');
|
|
1388
|
+
userId = connectionData.authenticatedUser?.id;
|
|
1389
|
+
if (!userId) {
|
|
1390
|
+
throw new Error('Could not resolve authenticated user ID. Provide reviewerId explicitly.');
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
const body = { vote: voteMap[vote] };
|
|
1394
|
+
const response = await this.makeRequest(`${project}/_apis/git/repositories/${repositoryId}/pullrequests/${pullRequestId}/reviewers/${userId}?api-version=${this.apiVersion}`, 'PUT', body, false, { 'Content-Type': 'application/json' });
|
|
1395
|
+
return {
|
|
1396
|
+
pullRequestId,
|
|
1397
|
+
reviewerId: response.id,
|
|
1398
|
+
displayName: response.displayName,
|
|
1399
|
+
vote: response.vote,
|
|
1400
|
+
voteLabel: vote,
|
|
1401
|
+
project
|
|
1402
|
+
};
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Reply to a PR thread and optionally update thread status
|
|
1406
|
+
*/
|
|
1407
|
+
async replyToPrThread(project, repositoryId, pullRequestId, threadId, content, status) {
|
|
1408
|
+
this.validateProject(project);
|
|
1409
|
+
if (!this.config.enablePullRequestWrite) {
|
|
1410
|
+
throw new Error('Pull request write operations are disabled. Set AZUREDEVOPS_ENABLE_PR_WRITE=true to enable.');
|
|
1411
|
+
}
|
|
1412
|
+
const results = { pullRequestId, threadId, project };
|
|
1413
|
+
// Add reply comment if content provided
|
|
1414
|
+
if (content) {
|
|
1415
|
+
const commentResponse = await this.makeRequest(`${project}/_apis/git/repositories/${repositoryId}/pullrequests/${pullRequestId}/threads/${threadId}/comments?api-version=${this.apiVersion}`, 'POST', { content, parentCommentId: 0, commentType: 1 }, false, { 'Content-Type': 'application/json' });
|
|
1416
|
+
results.comment = {
|
|
1417
|
+
id: commentResponse.id,
|
|
1418
|
+
content: commentResponse.content,
|
|
1419
|
+
author: commentResponse.author?.displayName,
|
|
1420
|
+
};
|
|
1421
|
+
}
|
|
1422
|
+
// Update thread status if provided
|
|
1423
|
+
if (status) {
|
|
1424
|
+
await this.makeRequest(`${project}/_apis/git/repositories/${repositoryId}/pullrequests/${pullRequestId}/threads/${threadId}?api-version=${this.apiVersion}`, 'PATCH', { status }, false, { 'Content-Type': 'application/json' });
|
|
1425
|
+
results.status = status;
|
|
1426
|
+
}
|
|
1427
|
+
return results;
|
|
1428
|
+
}
|
|
1007
1429
|
}
|
|
1008
1430
|
//# sourceMappingURL=AzureDevOpsService.js.map
|