autoforce 0.1.18 → 0.1.20

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.
@@ -1,26 +1,22 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { graphql } from "@octokit/graphql";
11
2
  import { Octokit } from "octokit";
12
3
  export class GitHubApi {
13
- getRepository() {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- if (this._repository === undefined) {
16
- const repository = yield this.getRepositoryObject();
17
- this._repository = repository;
18
- }
19
- return this._repository;
20
- });
4
+ repoVar;
5
+ projectNumber;
6
+ graphqlAuth;
7
+ octokit;
8
+ _repository;
9
+ _labels;
10
+ _milestones;
11
+ _defaultColors = { 'red': 'b60205', 'orange': 'd93f0b', 'yellow': 'fbca04', 'green': '0e8a16', 'dupont': '006b75', 'light-blue': '1d76db', 'blue': '0052cc', 'purple': '5319e7', 'pastel-red': 'e99695', 'pastel-orange': 'f9d0c4', 'pastel-yellow': 'fef2c0', 'pastel-green': 'c2e0c6', 'pastel-dupont': 'bfdadc', 'pastel-light': 'c5def5', 'pastel-blue': 'bfd4f2', 'pastel-purple': 'd4c5f9' };
12
+ async getRepository() {
13
+ if (this._repository === undefined) {
14
+ const repository = await this.getRepositoryObject();
15
+ this._repository = repository;
16
+ }
17
+ return this._repository;
21
18
  }
22
19
  constructor(token, owner, repo, projectNumber) {
23
- this._defaultColors = { 'red': 'b60205', 'orange': 'd93f0b', 'yellow': 'fbca04', 'green': '0e8a16', 'dupont': '006b75', 'light-blue': '1d76db', 'blue': '0052cc', 'purple': '5319e7', 'pastel-red': 'e99695', 'pastel-orange': 'f9d0c4', 'pastel-yellow': 'fef2c0', 'pastel-green': 'c2e0c6', 'pastel-dupont': 'bfdadc', 'pastel-light': 'c5def5', 'pastel-blue': 'bfd4f2', 'pastel-purple': 'd4c5f9' };
24
20
  this.repoVar = { owner, repo };
25
21
  this.projectNumber = projectNumber;
26
22
  this.graphqlAuth = graphql.defaults({
@@ -33,17 +29,16 @@ export class GitHubApi {
33
29
  auth: token
34
30
  });
35
31
  }
36
- createLabel(name_1) {
37
- return __awaiter(this, arguments, void 0, function* (name, color = 'random') {
38
- const repositoryId = (yield this.getRepository()).id;
39
- if (color === 'random') {
40
- color = this.getRandomColor();
41
- }
42
- else if (this._defaultColors[color] !== undefined) {
43
- color = this._defaultColors[color];
44
- }
45
- const variables = { name, repositoryId, color };
46
- const mutationCreateLabel = `
32
+ async createLabel(name, color = 'random') {
33
+ const repositoryId = (await this.getRepository()).id;
34
+ if (color === 'random') {
35
+ color = this.getRandomColor();
36
+ }
37
+ else if (this._defaultColors[color] !== undefined) {
38
+ color = this._defaultColors[color];
39
+ }
40
+ const variables = { name, repositoryId, color };
41
+ const mutationCreateLabel = `
47
42
  mutation createLabel( $name: String!, $repositoryId: ID!, $color: String! ) {
48
43
  createLabel(
49
44
  input: {
@@ -59,52 +54,46 @@ export class GitHubApi {
59
54
  }
60
55
  }
61
56
  }`;
62
- try {
63
- const { createLabel } = yield this.graphqlAuth(mutationCreateLabel, variables);
64
- return createLabel.label;
65
- }
66
- catch (error) {
67
- console.log(error);
68
- }
69
- return;
70
- });
57
+ try {
58
+ const { createLabel } = await this.graphqlAuth(mutationCreateLabel, variables);
59
+ return createLabel.label;
60
+ }
61
+ catch (error) {
62
+ console.log(error);
63
+ }
64
+ return;
71
65
  }
72
66
  getRandomColor() {
73
67
  const colors = Object.values(this._defaultColors);
74
68
  const number = Math.floor(Math.random() * colors.length);
75
69
  return colors[number];
76
70
  }
77
- createMilestone(title_1) {
78
- return __awaiter(this, arguments, void 0, function* (title, state = 'open', description, dueOn) {
79
- const result = yield this.octokit.request(`POST /repos/${this.repoVar.owner}/${this.repoVar.repo}/milestones`, {
80
- title,
81
- state,
82
- description,
83
- due_on: dueOn,
84
- headers: {
85
- 'X-GitHub-Api-Version': '2022-11-28'
86
- }
87
- });
88
- const milestone = { id: result.data.node_id, title: result.data.title, description: result.data.description, dueOn: result.data.due_on, url: result.data.url };
89
- return milestone;
71
+ async createMilestone(title, state = 'open', description, dueOn) {
72
+ const result = await this.octokit.request(`POST /repos/${this.repoVar.owner}/${this.repoVar.repo}/milestones`, {
73
+ title,
74
+ state,
75
+ description,
76
+ due_on: dueOn,
77
+ headers: {
78
+ 'X-GitHub-Api-Version': '2022-11-28'
79
+ }
90
80
  });
81
+ const milestone = { id: result.data.node_id, title: result.data.title, description: result.data.description, dueOn: result.data.due_on, url: result.data.url };
82
+ return milestone;
91
83
  }
92
- getUser() {
93
- return __awaiter(this, void 0, void 0, function* () {
94
- const query = `{
84
+ async getUser() {
85
+ const query = `{
95
86
  viewer {
96
87
  login
97
88
  id
98
89
  }
99
90
  }`;
100
- const { viewer } = yield this.graphqlAuth(query);
101
- return viewer;
102
- });
91
+ const { viewer } = await this.graphqlAuth(query);
92
+ return viewer;
103
93
  }
104
- getLabels() {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- if (this._labels === undefined) {
107
- const query = `
94
+ async getLabels() {
95
+ if (this._labels === undefined) {
96
+ const query = `
108
97
  query getRepo($owner:String!, $repo: String! ) {
109
98
  repository(owner: $owner, name: $repo) {
110
99
  labels(last: 10, orderBy: { field: CREATED_AT, direction: DESC}) {
@@ -117,16 +106,14 @@ export class GitHubApi {
117
106
  }
118
107
  }
119
108
  `;
120
- const { repository } = yield this.graphqlAuth(query, this.repoVar);
121
- this._labels = repository.labels.nodes;
122
- }
123
- return this._labels;
124
- });
109
+ const { repository } = await this.graphqlAuth(query, this.repoVar);
110
+ this._labels = repository.labels.nodes;
111
+ }
112
+ return this._labels;
125
113
  }
126
- getMilestones() {
127
- return __awaiter(this, void 0, void 0, function* () {
128
- if (this._milestones === undefined) {
129
- const query = `
114
+ async getMilestones() {
115
+ if (this._milestones === undefined) {
116
+ const query = `
130
117
  query getRepo($owner:String!, $repo: String! ) {
131
118
  repository(owner: $owner, name: $repo) {
132
119
  milestones(last: 10, states: OPEN, orderBy: { field: CREATED_AT, direction: DESC} ) {
@@ -140,15 +127,13 @@ export class GitHubApi {
140
127
  }
141
128
  }
142
129
  `;
143
- const { repository } = yield this.graphqlAuth(query, this.repoVar);
144
- this._milestones = repository.milestones.nodes;
145
- }
146
- return this._milestones;
147
- });
130
+ const { repository } = await this.graphqlAuth(query, this.repoVar);
131
+ this._milestones = repository.milestones.nodes;
132
+ }
133
+ return this._milestones;
148
134
  }
149
- getRepositoryObject() {
150
- return __awaiter(this, void 0, void 0, function* () {
151
- const query = `
135
+ async getRepositoryObject() {
136
+ const query = `
152
137
  query getRepo($owner:String!, $repo: String!, $projectNumber: Int! ) {
153
138
  repository(owner: $owner, name: $repo) {
154
139
  id
@@ -168,16 +153,14 @@ export class GitHubApi {
168
153
  }
169
154
  }
170
155
  `;
171
- const { repository } = yield this.graphqlAuth(query, Object.assign({ projectNumber: this.projectNumber }, this.repoVar));
172
- return repository;
173
- });
156
+ const { repository } = await this.graphqlAuth(query, { projectNumber: this.projectNumber, ...this.repoVar });
157
+ return repository;
174
158
  }
175
- createPullRequest(branchName, title, body) {
176
- return __awaiter(this, void 0, void 0, function* () {
177
- const repositoryId = (yield this.getRepository()).id;
178
- const headRefName = 'main';
179
- const baseRefName = branchName;
180
- const mutationPullRequest = `
159
+ async createPullRequest(branchName, title, body) {
160
+ const repositoryId = (await this.getRepository()).id;
161
+ const headRefName = 'main';
162
+ const baseRefName = branchName;
163
+ const mutationPullRequest = `
181
164
  mutation createPullRequest( $baseRefName: String!, $headRefName: String!, $headRepositoryId: ID, $repositoryId: ID!, $title: String!, $body: String ) {
182
165
  createPullRequest(
183
166
  input: {
@@ -194,20 +177,17 @@ export class GitHubApi {
194
177
  }
195
178
  }
196
179
  }`;
197
- try {
198
- const { createPullRequest } = yield this.graphqlAuth(mutationPullRequest, { baseRefName, headRefName, headRepositoryId: repositoryId, repositoryId, title, body });
199
- return createPullRequest.pullRequest ? true : false;
200
- }
201
- catch (error) {
202
- console.log(error);
203
- }
204
- return false;
205
- });
180
+ try {
181
+ const { createPullRequest } = await this.graphqlAuth(mutationPullRequest, { baseRefName, headRefName, headRepositoryId: repositoryId, repositoryId, title, body });
182
+ return createPullRequest.pullRequest ? true : false;
183
+ }
184
+ catch (error) {
185
+ console.log(error);
186
+ }
187
+ return false;
206
188
  }
207
- assignBranchToIssue(issueNumber, branchName, commitSha) {
208
- return __awaiter(this, void 0, void 0, function* () {
209
- var _a;
210
- const query = `
189
+ async assignBranchToIssue(issueNumber, branchName, commitSha) {
190
+ const query = `
211
191
  query getIssue($owner:String!, $repo: String!, $issueNumber: Int!) {
212
192
  repository(owner: $owner, name: $repo) {
213
193
  issue(number: $issueNumber) {
@@ -216,10 +196,10 @@ export class GitHubApi {
216
196
  }
217
197
  }
218
198
  `;
219
- const { repository } = yield this.graphqlAuth(query, Object.assign({ issueNumber: Number.parseInt(issueNumber) }, this.repoVar));
220
- const issue = repository.issue;
221
- const commit = yield this.getCommit(commitSha);
222
- const mutation = `
199
+ const { repository } = await this.graphqlAuth(query, { issueNumber: Number.parseInt(issueNumber), ...this.repoVar });
200
+ const issue = repository.issue;
201
+ const commit = await this.getCommit(commitSha);
202
+ const mutation = `
223
203
  mutation createLinkedBranch( $issueId: ID!, $oid: GitObjectID!, $branchName: String!) {
224
204
  createLinkedBranch(input: {
225
205
  issueId: $issueId
@@ -232,13 +212,11 @@ export class GitHubApi {
232
212
  }
233
213
  }
234
214
  }`;
235
- const { createLinkedBranch } = yield this.graphqlAuth(mutation, { issueId: issue.id, oid: commit.oid, branchName });
236
- return ((_a = createLinkedBranch === null || createLinkedBranch === void 0 ? void 0 : createLinkedBranch.issue) === null || _a === void 0 ? void 0 : _a.id) ? true : false;
237
- });
215
+ const { createLinkedBranch } = await this.graphqlAuth(mutation, { issueId: issue.id, oid: commit.oid, branchName });
216
+ return createLinkedBranch?.issue?.id ? true : false;
238
217
  }
239
- getCommit(commitSha) {
240
- return __awaiter(this, void 0, void 0, function* () {
241
- const query = `
218
+ async getCommit(commitSha) {
219
+ const query = `
242
220
  query getCommit($owner:String!, $repo: String!, $commitSha: String!) {
243
221
  repository(owner: $owner, name: $repo) {
244
222
  object(expression: $commitSha) {
@@ -249,8 +227,7 @@ export class GitHubApi {
249
227
  }
250
228
  }
251
229
  } `;
252
- const { repository } = yield this.graphqlAuth(query, Object.assign({ commitSha }, this.repoVar));
253
- return repository.object;
254
- });
230
+ const { repository } = await this.graphqlAuth(query, { commitSha, ...this.repoVar });
231
+ return repository.object;
255
232
  }
256
233
  }
@@ -1,22 +1,13 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { logWarning } from "./color.js";
11
2
  import { GitHubApi } from "./github-graphql.js";
12
3
  export class GitHubProjectApi extends GitHubApi {
4
+ projectNumber;
13
5
  constructor(token, owner, repo, projectNumber) {
14
6
  super(token, owner, repo);
15
7
  this.projectNumber = projectNumber;
16
8
  }
17
- getColumnValueMap() {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- const query = `
9
+ async getColumnValueMap() {
10
+ const query = `
20
11
  query getFieldOptions($owner:String!, $repo: String!, $projectNumber: Int!) {
21
12
  repository(owner: $owner, name: $repo) {
22
13
  projectV2(number: $projectNumber) {
@@ -34,55 +25,48 @@ export class GitHubProjectApi extends GitHubApi {
34
25
  }
35
26
  }
36
27
  `;
37
- const { repository } = yield this.graphqlAuth(query, Object.assign({ projectNumber: this.projectNumber }, this.repoVar));
38
- const mapValues = {};
39
- for (const option of repository.projectV2.field.options) {
40
- mapValues[option.name] = option.id;
41
- }
42
- return mapValues;
43
- });
28
+ const { repository } = await this.graphqlAuth(query, { projectNumber: this.projectNumber, ...this.repoVar });
29
+ const mapValues = {};
30
+ for (const option of repository.projectV2.field.options) {
31
+ mapValues[option.name] = option.id;
32
+ }
33
+ return mapValues;
44
34
  }
45
- findMilestoneByName(title) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- if (title) {
48
- const milestones = yield this.getMilestones();
49
- if (milestones.length > 0) {
50
- for (const milestone of milestones) {
51
- if (milestone.title === title) {
52
- return milestone;
53
- }
35
+ async findMilestoneByName(title) {
36
+ if (title) {
37
+ const milestones = await this.getMilestones();
38
+ if (milestones.length > 0) {
39
+ for (const milestone of milestones) {
40
+ if (milestone.title === title) {
41
+ return milestone;
54
42
  }
55
43
  }
56
44
  }
57
- return;
58
- });
45
+ }
46
+ return;
59
47
  }
60
- findLabelByName(name) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- if (name) {
63
- const labels = yield this.getLabels();
64
- if (labels.length > 0) {
65
- for (const label of labels) {
66
- if (label.name === name) {
67
- return label;
68
- }
48
+ async findLabelByName(name) {
49
+ if (name) {
50
+ const labels = await this.getLabels();
51
+ if (labels.length > 0) {
52
+ for (const label of labels) {
53
+ if (label.name === name) {
54
+ return label;
69
55
  }
70
56
  }
71
57
  }
72
- return;
73
- });
58
+ }
59
+ return;
74
60
  }
75
- createIssue(title, state, label, body, milestone) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- var _a, _b;
78
- const user = yield this.getUser();
79
- const repository = yield this.getRepository();
80
- const repositoryId = repository.id;
81
- const labelId = (label === null || label === void 0 ? void 0 : label.startsWith('LA_')) ? label : (_a = (yield this.findLabelByName(label))) === null || _a === void 0 ? void 0 : _a.id;
82
- const milestoneId = (milestone === null || milestone === void 0 ? void 0 : milestone.startsWith('MI_')) ? milestone : (_b = (yield this.findMilestoneByName(milestone))) === null || _b === void 0 ? void 0 : _b.id;
83
- const projectId = repository.projectV2.id;
84
- const variables = { labelId, body, assignId: user.id, projectId, repositoryId, title, milestoneId: milestoneId ? milestoneId : null };
85
- const mutationIssue = `
61
+ async createIssue(title, state, label, body, milestone) {
62
+ const user = await this.getUser();
63
+ const repository = await this.getRepository();
64
+ const repositoryId = repository.id;
65
+ const labelId = label?.startsWith('LA_') ? label : (await this.findLabelByName(label))?.id;
66
+ const milestoneId = milestone?.startsWith('MI_') ? milestone : (await this.findMilestoneByName(milestone))?.id;
67
+ const projectId = repository.projectV2.id;
68
+ const variables = { labelId, body, assignId: user.id, projectId, repositoryId, title, milestoneId: milestoneId ? milestoneId : null };
69
+ const mutationIssue = `
86
70
  mutation createIssue($repositoryId: ID!, $assignId: ID!, $title: String!, $body: String, $milestoneId: ID ${labelId ? ', $labelId: ID!' : ''} ) {
87
71
  createIssue(
88
72
  input: {
@@ -106,12 +90,12 @@ export class GitHubProjectApi extends GitHubApi {
106
90
  }
107
91
  }
108
92
  }`;
109
- const { createIssue } = yield this.graphqlAuth(mutationIssue, variables);
110
- const issue = createIssue.issue;
111
- if (!state || !issue.number) {
112
- return issue;
113
- }
114
- const mutationItem = `
93
+ const { createIssue } = await this.graphqlAuth(mutationIssue, variables);
94
+ const issue = createIssue.issue;
95
+ if (!state || !issue.number) {
96
+ return issue;
97
+ }
98
+ const mutationItem = `
115
99
  mutation addProjectV2ItemById($projectId: ID!, $contentId: ID! ) {
116
100
  addProjectV2ItemById(
117
101
  input: {
@@ -125,16 +109,16 @@ export class GitHubProjectApi extends GitHubApi {
125
109
  }
126
110
  }
127
111
  }`;
128
- const { addProjectV2ItemById } = yield this.graphqlAuth(mutationItem, { projectId, contentId: issue.id });
129
- const itemId = addProjectV2ItemById.item.id;
130
- const fieldId = repository.projectV2.field.id;
131
- const mapValues = yield this.getColumnValueMap();
132
- const columnValue = mapValues[state];
133
- if (!columnValue) {
134
- logWarning(`No se encontro la columna ${state} en las lista de columnas del proyecto ${Object.keys(mapValues).join(",")}`);
135
- }
136
- else {
137
- const mutationColumn = `
112
+ const { addProjectV2ItemById } = await this.graphqlAuth(mutationItem, { projectId, contentId: issue.id });
113
+ const itemId = addProjectV2ItemById.item.id;
114
+ const fieldId = repository.projectV2.field.id;
115
+ const mapValues = await this.getColumnValueMap();
116
+ const columnValue = mapValues[state];
117
+ if (!columnValue) {
118
+ logWarning(`No se encontro la columna ${state} en las lista de columnas del proyecto ${Object.keys(mapValues).join(",")}`);
119
+ }
120
+ else {
121
+ const mutationColumn = `
138
122
  mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $columnValue: String!) {
139
123
  updateProjectV2ItemFieldValue(
140
124
  input: {
@@ -147,24 +131,19 @@ export class GitHubProjectApi extends GitHubApi {
147
131
  clientMutationId
148
132
  }
149
133
  }`;
150
- yield this.graphqlAuth(mutationColumn, { projectId, itemId, fieldId, columnValue });
151
- }
152
- return issue;
153
- });
134
+ await this.graphqlAuth(mutationColumn, { projectId, itemId, fieldId, columnValue });
135
+ }
136
+ return issue;
154
137
  }
155
- getIssueState(issueNumber) {
156
- return __awaiter(this, void 0, void 0, function* () {
157
- var _a, _b, _c;
158
- const issue = yield this._getIssue(issueNumber);
159
- return (_c = (_b = (_a = issue.projectItems) === null || _a === void 0 ? void 0 : _a.nodes[0]) === null || _b === void 0 ? void 0 : _b.fieldValueByName) === null || _c === void 0 ? void 0 : _c.name;
160
- });
138
+ async getIssueState(issueNumber) {
139
+ const issue = await this._getIssue(issueNumber);
140
+ return issue.projectItems?.nodes[0]?.fieldValueByName?.name;
161
141
  }
162
142
  getIssueName(title) {
163
143
  return title.toLowerCase().replaceAll(' ', '-');
164
144
  }
165
- _getIssue(issueNumber) {
166
- return __awaiter(this, void 0, void 0, function* () {
167
- const query = `
145
+ async _getIssue(issueNumber) {
146
+ const query = `
168
147
  query getIssue($owner:String!, $repo: String!, $issueNumber: Int!) {
169
148
  repository(owner: $owner, name: $repo) {
170
149
  issue(number: $issueNumber) {
@@ -210,38 +189,32 @@ export class GitHubProjectApi extends GitHubApi {
210
189
  }
211
190
  }
212
191
  `;
213
- const { repository } = yield this.graphqlAuth(query, Object.assign({ issueNumber: Number.parseInt(issueNumber) }, this.repoVar));
214
- return repository.issue;
215
- });
192
+ const { repository } = await this.graphqlAuth(query, { issueNumber: Number.parseInt(issueNumber), ...this.repoVar });
193
+ return repository.issue;
216
194
  }
217
- getIssue(issueNumber) {
218
- return __awaiter(this, void 0, void 0, function* () {
219
- const issue = yield this._getIssue(issueNumber);
220
- const issueObject = { number: issue.number, title: issue.title, id: issue.id, url: issue.url, body: issue.body };
221
- issueObject.name = this.getIssueName(issue.title);
222
- if (issue.linkedBranches.nodes.length > 0) {
223
- issueObject.branch = issue.linkedBranches.nodes[0].ref.name;
224
- }
225
- if (issue.projectItems.nodes.length > 0) {
226
- issueObject.state = issue.projectItems.nodes[0].fieldValueByName.name;
227
- }
228
- if (issue.labels.nodes.length > 0) {
229
- issueObject.labels = [];
230
- for (const node of issue.labels.nodes) {
231
- issueObject.labels.push(node.name);
232
- }
195
+ async getIssue(issueNumber) {
196
+ const issue = await this._getIssue(issueNumber);
197
+ const issueObject = { number: issue.number, title: issue.title, id: issue.id, url: issue.url, body: issue.body };
198
+ issueObject.name = this.getIssueName(issue.title);
199
+ if (issue.linkedBranches.nodes.length > 0) {
200
+ issueObject.branch = issue.linkedBranches.nodes[0].ref.name;
201
+ }
202
+ if (issue.projectItems.nodes.length > 0) {
203
+ issueObject.state = issue.projectItems.nodes[0].fieldValueByName.name;
204
+ }
205
+ if (issue.labels.nodes.length > 0) {
206
+ issueObject.labels = [];
207
+ for (const node of issue.labels.nodes) {
208
+ issueObject.labels.push(node.name);
233
209
  }
234
- return issueObject;
235
- });
210
+ }
211
+ return issueObject;
236
212
  }
237
- getIssues() {
238
- return __awaiter(this, void 0, void 0, function* () {
239
- return yield this.getIssuesWithFilter(`{ states: OPEN }`);
240
- });
213
+ async getIssues() {
214
+ return await this.getIssuesWithFilter(`{ states: OPEN }`);
241
215
  }
242
- getIssuesWithFilter(filterBy) {
243
- return __awaiter(this, void 0, void 0, function* () {
244
- const query = `
216
+ async getIssuesWithFilter(filterBy) {
217
+ const query = `
245
218
  query getIssues($owner:String!, $repo: String!) {
246
219
  repository(owner: $owner, name: $repo) {
247
220
  issues(last: 10, filterBy: ${filterBy} ) {
@@ -272,19 +245,17 @@ export class GitHubProjectApi extends GitHubApi {
272
245
  }
273
246
  }
274
247
  `;
275
- const { repository } = yield this.graphqlAuth(query, this.repoVar);
276
- return repository.issues.nodes;
277
- });
248
+ const { repository } = await this.graphqlAuth(query, this.repoVar);
249
+ return repository.issues.nodes;
278
250
  }
279
- moveIssue(issueNumber, state) {
280
- return __awaiter(this, void 0, void 0, function* () {
281
- const issue = yield this._getIssue(issueNumber);
282
- const itemId = issue.projectItems.nodes[0].id;
283
- const projectId = issue.projectItems.nodes[0].project.id;
284
- const fieldId = issue.projectItems.nodes[0].fieldValueByName.field.id;
285
- const mapValues = yield this.getColumnValueMap();
286
- const columnValue = mapValues[state];
287
- const mutation = `
251
+ async moveIssue(issueNumber, state) {
252
+ const issue = await this._getIssue(issueNumber);
253
+ const itemId = issue.projectItems.nodes[0].id;
254
+ const projectId = issue.projectItems.nodes[0].project.id;
255
+ const fieldId = issue.projectItems.nodes[0].fieldValueByName.field.id;
256
+ const mapValues = await this.getColumnValueMap();
257
+ const columnValue = mapValues[state];
258
+ const mutation = `
288
259
  mutation($projectId: ID!, $itemId: ID!, $fieldId: ID!, $columnValue: String!) {
289
260
  updateProjectV2ItemFieldValue(
290
261
  input: {
@@ -299,15 +270,13 @@ export class GitHubProjectApi extends GitHubApi {
299
270
  }
300
271
  }
301
272
  }`;
302
- const { updateProjectV2ItemFieldValue } = yield this.graphqlAuth(mutation, { projectId, itemId, fieldId, columnValue });
303
- return (updateProjectV2ItemFieldValue === null || updateProjectV2ItemFieldValue === void 0 ? void 0 : updateProjectV2ItemFieldValue.projectV2Item) ? true : false;
304
- });
273
+ const { updateProjectV2ItemFieldValue } = await this.graphqlAuth(mutation, { projectId, itemId, fieldId, columnValue });
274
+ return updateProjectV2ItemFieldValue?.projectV2Item ? true : false;
305
275
  }
306
- assignIssueToMe(issueNumber) {
307
- return __awaiter(this, void 0, void 0, function* () {
308
- const user = yield this.getUser();
309
- const issue = yield this._getIssue(issueNumber);
310
- const mutation = `
276
+ async assignIssueToMe(issueNumber) {
277
+ const user = await this.getUser();
278
+ const issue = await this._getIssue(issueNumber);
279
+ const mutation = `
311
280
  mutation assignUser( $issueId: ID!, $userId: ID!) {
312
281
  addAssigneesToAssignable(input: {
313
282
  assignableId: $issueId
@@ -321,8 +290,7 @@ export class GitHubProjectApi extends GitHubApi {
321
290
  }
322
291
  }
323
292
  `;
324
- const { addAssigneesToAssignable } = yield this.graphqlAuth(mutation, { issueId: issue.id, userId: user.id });
325
- return addAssigneesToAssignable.assignable.assignees.totalCount > 0;
326
- });
293
+ const { addAssigneesToAssignable } = await this.graphqlAuth(mutation, { issueId: issue.id, userId: user.id });
294
+ return addAssigneesToAssignable.assignable.assignees.totalCount > 0;
327
295
  }
328
296
  }