-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathazureDevOpsWorkService.tsx
76 lines (64 loc) · 2.22 KB
/
azureDevOpsWorkService.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { TeamFieldValues, TeamSettingsIteration } from 'azure-devops-extension-api/Work';
import { WorkRestClient } from 'azure-devops-extension-api/Work/WorkClient';
import { getClient } from 'azure-devops-extension-api/Common';
import { getProjectId } from '../utilities/servicesHelper';
class WorkService {
private _httpWorkClient: WorkRestClient;
constructor() {
if (!this._httpWorkClient) {
this._httpWorkClient = getClient(WorkRestClient);
}
}
/**
* Gets the iterations for the current project and a given team
*/
public async getIterations(teamId: string, timeframe?: string):
Promise<TeamSettingsIteration[]> {
const projectId = await getProjectId();
const teamContext = {
project: '',
projectId,
team: '',
teamId
};
let teamIterations: TeamSettingsIteration[] = [];
try {
teamIterations = await this._httpWorkClient.getTeamIterations(teamContext, timeframe);
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
catch (e: any) {
if (e.serverError?.typeKey === 'CurrentIterationDoesNotExistException') {
// TODO: Enable once trackTrace is supported
// appInsightsClient.trackTrace(TelemetryExceptions.CurrentTeamIterationNotFound, e);
}
else {
// TODO (enpolat) : appInsightsClient.trackException(new Error(e.message));
console.error('An exception occurred while trying to get the team iterations ', e);
}
}
return teamIterations;
}
/**
* Gets the team field values (default being area paths) for project and team
*/
public async getTeamFieldValues(teamId: string):
Promise<TeamFieldValues> {
const projectId = await getProjectId();
const teamContext = {
project: '',
projectId,
team: '',
teamId
};
let teamFieldValues: TeamFieldValues = undefined;
try {
teamFieldValues = await this._httpWorkClient.getTeamFieldValues(teamContext);
}
catch (e) {
// TODO (enpolat) : appInsightsClient.trackException(new Error(e.message));
console.error('An exception occurred while trying to get the team field values: ', e);
}
return teamFieldValues;
}
}
export const workService = new WorkService();