@pecot/workflow-mcp 5.0.0 → 6.0.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/.claude-plugin/plugin.json +1 -1
- package/README.md +80 -22
- package/cli/dist/cli.js +6 -1
- package/cli/dist/commands/board-add.d.ts +3 -0
- package/cli/dist/commands/board-add.js +59 -0
- package/cli/dist/commands/board-judgment.d.ts +60 -0
- package/cli/dist/commands/board-judgment.js +144 -0
- package/cli/dist/commands/board-move.d.ts +3 -0
- package/cli/dist/commands/board-move.js +57 -0
- package/cli/dist/commands/board-readiness.d.ts +34 -0
- package/cli/dist/commands/board-readiness.js +108 -0
- package/cli/dist/commands/board-show.d.ts +3 -0
- package/cli/dist/commands/board-show.js +72 -0
- package/cli/dist/commands/board-sync.d.ts +3 -0
- package/cli/dist/commands/board-sync.js +111 -0
- package/cli/dist/commands/{project-info.d.ts → board-view.d.ts} +21 -7
- package/cli/dist/commands/{project-info.js → board-view.js} +22 -12
- package/cli/dist/commands/board.d.ts +3 -0
- package/cli/dist/commands/board.js +12 -0
- package/cli/dist/commands/branch.d.ts +3 -0
- package/cli/dist/commands/branch.js +100 -0
- package/cli/dist/commands/command-binding.js +4 -0
- package/cli/dist/commands/command-definition.d.ts +20 -6
- package/cli/dist/commands/command-definition.js +11 -7
- package/cli/dist/commands/command-help.js +2 -2
- package/cli/dist/commands/command-hint.d.ts +5 -0
- package/cli/dist/commands/command-hint.js +13 -0
- package/cli/dist/commands/command-stop.d.ts +5 -3
- package/cli/dist/commands/command-stop.js +7 -6
- package/cli/dist/commands/failure-kind.d.ts +3 -0
- package/cli/dist/commands/failure-kind.js +34 -0
- package/cli/dist/commands/failure.d.ts +6 -0
- package/cli/dist/commands/failure.js +29 -3
- package/cli/dist/commands/github-client.d.ts +6 -2
- package/cli/dist/commands/github-client.js +13 -3
- package/cli/dist/commands/help.js +8 -13
- package/cli/dist/commands/issue-board.d.ts +33 -0
- package/cli/dist/commands/issue-board.js +61 -1
- package/cli/dist/commands/issue-comment.js +47 -28
- package/cli/dist/commands/issue-create.js +548 -91
- package/cli/dist/commands/issue-dependency.d.ts +3 -0
- package/cli/dist/commands/issue-dependency.js +282 -0
- package/cli/dist/commands/issue-readiness.d.ts +94 -0
- package/cli/dist/commands/issue-readiness.js +218 -0
- package/cli/dist/commands/issue-reopen.d.ts +3 -0
- package/cli/dist/commands/issue-reopen.js +115 -0
- package/cli/dist/commands/issue-shared.d.ts +32 -19
- package/cli/dist/commands/issue-shared.js +82 -75
- package/cli/dist/commands/issue-show.d.ts +3 -0
- package/cli/dist/commands/issue-show.js +169 -0
- package/cli/dist/commands/issue.d.ts +0 -1
- package/cli/dist/commands/issue.js +6 -8
- package/cli/dist/commands/names.d.ts +33 -0
- package/cli/dist/commands/names.js +62 -0
- package/cli/dist/commands/output.d.ts +14 -2
- package/cli/dist/commands/output.js +14 -7
- package/cli/dist/commands/pr-waiting.d.ts +20 -0
- package/cli/dist/commands/pr-waiting.js +106 -0
- package/cli/dist/commands/pr.d.ts +19 -0
- package/cli/dist/commands/pr.js +242 -323
- package/cli/dist/commands/project-sync.d.ts +2 -1
- package/cli/dist/commands/project-sync.js +18 -9
- package/cli/dist/commands/project.d.ts +3 -2
- package/cli/dist/commands/project.js +212 -175
- package/cli/dist/commands/registry.js +13 -10
- package/cli/dist/commands/release.d.ts +2 -2
- package/cli/dist/commands/release.js +53 -114
- package/cli/dist/commands/renamed-commands.d.ts +26 -0
- package/cli/dist/commands/renamed-commands.js +53 -0
- package/cli/dist/commands/repository-match.js +3 -2
- package/cli/dist/commands/session-finish.d.ts +3 -0
- package/cli/dist/commands/session-finish.js +267 -0
- package/cli/dist/commands/session-start.d.ts +3 -0
- package/cli/dist/commands/{repository.js → session-start.js} +99 -128
- package/cli/dist/commands/session.d.ts +3 -0
- package/cli/dist/commands/session.js +82 -29
- package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
- package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +57 -66
- package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
- package/cli/dist/commands/{security.js → tracker-sync-security.js} +50 -61
- package/cli/dist/commands/tracker-sync.d.ts +7 -0
- package/cli/dist/commands/tracker-sync.js +3 -6
- package/cli/dist/commands/tracker.d.ts +3 -0
- package/cli/dist/commands/tracker.js +18 -0
- package/cli/dist/commands/usage-error.d.ts +4 -0
- package/cli/dist/commands/usage-error.js +6 -0
- package/cli/dist/commands/work-target.d.ts +12 -3
- package/cli/dist/commands/work-target.js +46 -5
- package/cli/dist/commands/worktree.js +32 -28
- package/cli/dist/domain/batch-plan.d.ts +73 -0
- package/cli/dist/domain/batch-plan.js +114 -0
- package/cli/dist/domain/blocked-by-change.d.ts +99 -0
- package/cli/dist/domain/blocked-by-change.js +101 -0
- package/cli/dist/domain/board-move.d.ts +90 -0
- package/cli/dist/domain/board-move.js +92 -0
- package/cli/dist/domain/branch-name.js +1 -1
- package/cli/dist/domain/command-hint.d.ts +85 -0
- package/cli/dist/domain/command-hint.js +148 -0
- package/cli/dist/domain/config.d.ts +4 -0
- package/cli/dist/domain/config.js +11 -1
- package/cli/dist/domain/dependabot.js +1 -1
- package/cli/dist/domain/errors.d.ts +5 -0
- package/cli/dist/domain/errors.js +5 -0
- package/cli/dist/domain/format.d.ts +51 -4
- package/cli/dist/domain/format.js +72 -6
- package/cli/dist/domain/frontmatter.d.ts +18 -3
- package/cli/dist/domain/frontmatter.js +38 -12
- package/cli/dist/domain/issue-order.d.ts +55 -0
- package/cli/dist/domain/issue-order.js +65 -0
- package/cli/dist/domain/issue-readout.d.ts +36 -0
- package/cli/dist/domain/pull-request.d.ts +71 -4
- package/cli/dist/domain/pull-request.js +59 -10
- package/cli/dist/domain/readiness.d.ts +27 -0
- package/cli/dist/domain/readiness.js +114 -3
- package/cli/dist/domain/reference-parser.d.ts +3 -1
- package/cli/dist/domain/reference-parser.js +6 -2
- package/cli/dist/domain/release.d.ts +7 -3
- package/cli/dist/domain/release.js +5 -12
- package/cli/dist/domain/repository-policy.d.ts +9 -3
- package/cli/dist/domain/repository-policy.js +8 -7
- package/cli/dist/domain/repository-resolver.js +4 -1
- package/cli/dist/domain/security-alerts.js +1 -1
- package/cli/dist/domain/state.d.ts +30 -0
- package/cli/dist/domain/state.js +39 -0
- package/cli/dist/domain/work-start.d.ts +34 -0
- package/cli/dist/domain/work-start.js +49 -0
- package/cli/dist/infra/authored-notes.d.ts +1 -1
- package/cli/dist/infra/authored-notes.js +10 -4
- package/cli/dist/infra/config-store.d.ts +4 -0
- package/cli/dist/infra/config-store.js +13 -0
- package/cli/dist/infra/git.d.ts +12 -0
- package/cli/dist/infra/git.js +13 -1
- package/cli/dist/infra/github/client.d.ts +5 -0
- package/cli/dist/infra/github/client.js +10 -7
- package/cli/dist/infra/github/errors.d.ts +18 -0
- package/cli/dist/infra/github/errors.js +22 -0
- package/cli/dist/infra/github/issues.d.ts +39 -3
- package/cli/dist/infra/github/issues.js +178 -23
- package/cli/dist/infra/github/projects.d.ts +35 -0
- package/cli/dist/infra/github/projects.js +89 -8
- package/cli/dist/infra/github/pulls.d.ts +24 -0
- package/cli/dist/infra/github/pulls.js +56 -0
- package/cli/dist/infra/github/queries.d.ts +12 -4
- package/cli/dist/infra/github/queries.js +156 -8
- package/cli/dist/infra/github/readout.d.ts +5 -1
- package/cli/dist/infra/github/readout.js +11 -0
- package/cli/dist/infra/github/repos.d.ts +18 -0
- package/cli/dist/infra/github/repos.js +31 -0
- package/cli/dist/infra/nx-scope.d.ts +1 -1
- package/cli/dist/infra/nx-scope.js +1 -1
- package/cli/dist/infra/state-store.d.ts +10 -1
- package/cli/dist/infra/state-store.js +14 -2
- package/cli/dist/infra/worktree-links.d.ts +3 -0
- package/cli/dist/infra/worktree-links.js +8 -1
- package/cli/dist/infra/worktree.d.ts +12 -1
- package/cli/dist/infra/worktree.js +40 -23
- package/cli/dist/mcp/result.d.ts +34 -6
- package/cli/dist/mcp/result.js +62 -18
- package/cli/dist/mcp/server.d.ts +2 -2
- package/cli/dist/mcp/server.js +24 -10
- package/cli/templates/comment/plan.md +14 -0
- package/cli/templates/issue/bug.md +1 -1
- package/cli/templates/issue/task-implement.md +13 -6
- package/cli/templates/issue/task.md +1 -1
- package/cli/templates/workflow/pecot-board-sync.yml +84 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/cli/dist/commands/dependabot.d.ts +0 -3
- package/cli/dist/commands/issue-project.d.ts +0 -3
- package/cli/dist/commands/issue-project.js +0 -176
- package/cli/dist/commands/issue-quick.d.ts +0 -3
- package/cli/dist/commands/issue-quick.js +0 -126
- package/cli/dist/commands/issue-read.d.ts +0 -3
- package/cli/dist/commands/issue-read.js +0 -80
- package/cli/dist/commands/repository.d.ts +0 -5
- package/cli/dist/commands/security.d.ts +0 -3
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import type { JsonObject } from '../../domain/json.js';
|
|
2
2
|
import type { LinkedRepository } from '../../domain/config.js';
|
|
3
3
|
import type { FieldOptionInput } from '../../domain/field-options.js';
|
|
4
|
+
import type { BoardItem } from '../../domain/format.js';
|
|
5
|
+
import type { JsonValue } from '../../domain/python-format.js';
|
|
6
|
+
import type { GraphqlOutcome, PathPredicate } from './client.js';
|
|
4
7
|
import { ReposApi } from './repos.js';
|
|
8
|
+
/**
|
|
9
|
+
Issue のボードのアイテム。isArchived はアイテムのアーカイブで、Status の Archived とは別
|
|
10
|
+
*/
|
|
11
|
+
export interface IssueProjectItem {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly isArchived: boolean;
|
|
14
|
+
}
|
|
5
15
|
export interface ListProjectItemsOptions {
|
|
6
16
|
/**
|
|
7
17
|
取得する最大件数。省略または 0 なら全件
|
|
@@ -15,6 +25,10 @@ export interface ListProjectItemsOptions {
|
|
|
15
25
|
excludeArchived のとき、ステータスを見るフィールド名
|
|
16
26
|
*/
|
|
17
27
|
readonly workflowFieldName?: string | undefined;
|
|
28
|
+
/**
|
|
29
|
+
Issue の依存関係に対応しない GHES で、足したフィールドを除いたクエリで読み直したときに呼ぶ
|
|
30
|
+
*/
|
|
31
|
+
readonly onLegacy?: (() => void) | undefined;
|
|
18
32
|
}
|
|
19
33
|
/**
|
|
20
34
|
SingleSelect フィールドの選択肢
|
|
@@ -34,6 +48,14 @@ export interface LinkResult {
|
|
|
34
48
|
export declare class ProjectsApi extends ReposApi {
|
|
35
49
|
private queryAsUser;
|
|
36
50
|
/**
|
|
51
|
+
Issue を読むクエリ。無い Issue・リポジトリの NOT_FOUND を GitHubNotFoundError にする
|
|
52
|
+
*/
|
|
53
|
+
protected queryIssue(query: string, variables: Readonly<Record<string, JsonValue>>): Promise<JsonObject>;
|
|
54
|
+
/**
|
|
55
|
+
queryIssue の、部分エラーを許す版
|
|
56
|
+
*/
|
|
57
|
+
protected queryIssueTolerating(query: string, variables: Readonly<Record<string, JsonValue>>, isTolerated: PathPredicate): Promise<GraphqlOutcome>;
|
|
58
|
+
/**
|
|
37
59
|
プロジェクトボードのアイテムを取得する(ページネーション対応)
|
|
38
60
|
*/
|
|
39
61
|
listProjectItems(projectId: string, options?: Readonly<ListProjectItemsOptions>): Promise<readonly JsonObject[]>;
|
|
@@ -46,6 +68,10 @@ export declare class ProjectsApi extends ReposApi {
|
|
|
46
68
|
*/
|
|
47
69
|
updateProjectItemField(projectId: string, itemId: string, fieldId: string, optionId: string): Promise<string>;
|
|
48
70
|
/**
|
|
71
|
+
アーカイブ済みのアイテムをボードに戻す
|
|
72
|
+
*/
|
|
73
|
+
unarchiveProjectItem(projectId: string, itemId: string): Promise<void>;
|
|
74
|
+
/**
|
|
49
75
|
プロジェクトボードからアイテムを削除し、削除したアイテムの ID を返す
|
|
50
76
|
*/
|
|
51
77
|
deleteProjectItem(projectId: string, itemId: string): Promise<string>;
|
|
@@ -71,6 +97,15 @@ export declare class ProjectsApi extends ReposApi {
|
|
|
71
97
|
*/
|
|
72
98
|
getItemIdByIssue(projectId: string, owner: string, repository: string, issueNumber: number): Promise<string | undefined>;
|
|
73
99
|
/**
|
|
100
|
+
getItemIdByIssue と同じ引き方で、アイテムの ID とアーカイブ済みかを取る
|
|
101
|
+
*/
|
|
102
|
+
getIssueProjectItem(projectId: string, owner: string, repository: string, issueNumber: number): Promise<IssueProjectItem | undefined>;
|
|
103
|
+
/**
|
|
104
|
+
Issue 1 件の、指定のプロジェクトの項目を、readBoard の一覧の項目と同じ形で返す(札は含めない)。
|
|
105
|
+
workflow は進行の列の値で、空なら null。Issue やリポジトリが無い、またはプロジェクトに無ければ undefined
|
|
106
|
+
*/
|
|
107
|
+
getIssueBoardItem(projectId: string, owner: string, repository: string, issueNumber: number, workflowFieldName: string): Promise<BoardItem | undefined>;
|
|
108
|
+
/**
|
|
74
109
|
プロジェクトアイテムで値が入っている単一選択フィールドの ID を取る。アイテムが見つからなければ空
|
|
75
110
|
*/
|
|
76
111
|
getItemSetFieldIds(projectId: string, owner: string, repository: string, issueNumber: number, itemId: string): Promise<ReadonlySet<string>>;
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
// owner が user か organization かは分からないので、user のクエリを先に試し、失敗したら organization を試す。
|
|
3
3
|
import { isJsonObject, jsonField } from '../../domain/json.js';
|
|
4
4
|
import { JSON_NULL } from '../../domain/json-null.js';
|
|
5
|
-
import { GitHubAPIError, GitHubNotFoundError } from './errors.js';
|
|
5
|
+
import { asNotFoundError, GitHubAPIError, GitHubNotFoundError, isSchemaError } from './errors.js';
|
|
6
6
|
import { asArray, asObject, isTruthy, requireString, truthyNodes } from './payload.js';
|
|
7
|
-
import { MUTATION_ADD_TO_PROJECT, MUTATION_CREATE_PROJECT, MUTATION_CREATE_PROJECT_FIELD, MUTATION_DELETE_PROJECT_ITEM, MUTATION_LINK_PROJECT_REPOSITORY, MUTATION_UPDATE_PROJECT_FIELD, MUTATION_UPDATE_PROJECT_ITEM_FIELD, QUERY_GET_ISSUE_PROJECT_ITEMS, QUERY_GET_LINKED_REPOSITORIES_ORG, QUERY_GET_LINKED_REPOSITORIES_USER, QUERY_GET_ORG_NODE_ID, QUERY_GET_PROJECT_FIELDS_ORG, QUERY_GET_PROJECT_FIELDS_USER, QUERY_GET_PROJECT_ID_ORG, QUERY_GET_PROJECT_ID_USER, QUERY_GET_USER_NODE_ID, QUERY_LIST_PROJECT_ITEMS, QUERY_LIST_PROJECTS_ORG, QUERY_LIST_PROJECTS_USER, } from './queries.js';
|
|
7
|
+
import { MUTATION_ADD_TO_PROJECT, MUTATION_CREATE_PROJECT, MUTATION_CREATE_PROJECT_FIELD, MUTATION_DELETE_PROJECT_ITEM, MUTATION_UNARCHIVE_PROJECT_ITEM, MUTATION_LINK_PROJECT_REPOSITORY, MUTATION_UPDATE_PROJECT_FIELD, MUTATION_UPDATE_PROJECT_ITEM_FIELD, QUERY_GET_ISSUE_BOARD_ITEM, QUERY_GET_ISSUE_PROJECT_ITEMS, QUERY_GET_LINKED_REPOSITORIES_ORG, QUERY_GET_LINKED_REPOSITORIES_USER, QUERY_GET_ORG_NODE_ID, QUERY_GET_PROJECT_FIELDS_ORG, QUERY_GET_PROJECT_FIELDS_USER, QUERY_GET_PROJECT_ID_ORG, QUERY_GET_PROJECT_ID_USER, QUERY_GET_USER_NODE_ID, QUERY_LIST_PROJECT_ITEMS, QUERY_LIST_PROJECT_ITEMS_LEGACY, QUERY_LIST_PROJECTS_ORG, QUERY_LIST_PROJECTS_USER, } from './queries.js';
|
|
8
8
|
import { ReposApi } from './repos.js';
|
|
9
|
+
// 着手の判定に足したフィールドの名前が出るスキーマの失敗(`Field 'x' doesn't exist` と `Cannot query field "x"`)
|
|
10
|
+
const READINESS_FIELD_ERROR = /(?:Field '|field ")(?:issueType|subIssues|parent|blockedBy)['"]/u;
|
|
9
11
|
const MAX_ARCHIVED_CONSECUTIVE = 50;
|
|
10
12
|
const DEFAULT_PROJECT_LIMIT = 20;
|
|
11
13
|
function lowerText(value) {
|
|
@@ -45,15 +47,52 @@ export class ProjectsApi extends ReposApi {
|
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
/**
|
|
50
|
+
Issue を読むクエリ。無い Issue・リポジトリの NOT_FOUND を GitHubNotFoundError にする
|
|
51
|
+
*/
|
|
52
|
+
async queryIssue(query, variables) {
|
|
53
|
+
try {
|
|
54
|
+
return await this.executeGraphql(query, variables);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw asNotFoundError(error);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
queryIssue の、部分エラーを許す版
|
|
62
|
+
*/
|
|
63
|
+
async queryIssueTolerating(query, variables, isTolerated) {
|
|
64
|
+
try {
|
|
65
|
+
return await this.executeGraphqlTolerating(query, variables, isTolerated);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
throw asNotFoundError(error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
48
72
|
プロジェクトボードのアイテムを取得する(ページネーション対応)
|
|
49
73
|
*/
|
|
50
74
|
async listProjectItems(projectId, options = {}) {
|
|
51
|
-
const { limit, excludeArchived = false, workflowFieldName = '' } = options;
|
|
75
|
+
const { limit, excludeArchived = false, workflowFieldName = '', onLegacy } = options;
|
|
76
|
+
let query = QUERY_LIST_PROJECT_ITEMS;
|
|
52
77
|
let allItems = [];
|
|
53
78
|
let cursor = JSON_NULL;
|
|
54
79
|
let archivedConsecutive = 0;
|
|
55
80
|
for (;;) {
|
|
56
|
-
|
|
81
|
+
let result;
|
|
82
|
+
try {
|
|
83
|
+
result = await this.executeGraphql(query, { projectId, cursor });
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
// 古い GHES は blockedBy などを知らない。足す前のクエリで先頭から読み直す
|
|
87
|
+
if (query === QUERY_LIST_PROJECT_ITEMS_LEGACY || !isSchemaError(error) || !READINESS_FIELD_ERROR.test(error.message))
|
|
88
|
+
throw error;
|
|
89
|
+
query = QUERY_LIST_PROJECT_ITEMS_LEGACY;
|
|
90
|
+
allItems = [];
|
|
91
|
+
cursor = JSON_NULL;
|
|
92
|
+
archivedConsecutive = 0;
|
|
93
|
+
onLegacy?.();
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
57
96
|
const node = jsonField(result, 'node');
|
|
58
97
|
if (!isTruthy(node))
|
|
59
98
|
break;
|
|
@@ -111,6 +150,14 @@ export class ProjectsApi extends ReposApi {
|
|
|
111
150
|
return requireString(jsonField(item, 'id'), 'projectV2Item.id');
|
|
112
151
|
}
|
|
113
152
|
/**
|
|
153
|
+
アーカイブ済みのアイテムをボードに戻す
|
|
154
|
+
*/
|
|
155
|
+
async unarchiveProjectItem(projectId, itemId) {
|
|
156
|
+
const result = await this.executeGraphql(MUTATION_UNARCHIVE_PROJECT_ITEM, { projectId, itemId });
|
|
157
|
+
if (!isTruthy(jsonField(jsonField(result, 'unarchiveProjectV2Item'), 'item')))
|
|
158
|
+
throw new GitHubAPIError('failed to unarchive the project item');
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
114
161
|
プロジェクトボードからアイテムを削除し、削除したアイテムの ID を返す
|
|
115
162
|
*/
|
|
116
163
|
async deleteProjectItem(projectId, itemId) {
|
|
@@ -171,7 +218,14 @@ export class ProjectsApi extends ReposApi {
|
|
|
171
218
|
Issue から直接引くので、全アイテムの走査は要らない。Issue やリポジトリが無い、またはプロジェクトに無ければ undefined
|
|
172
219
|
*/
|
|
173
220
|
async getItemIdByIssue(projectId, owner, repository, issueNumber) {
|
|
174
|
-
const
|
|
221
|
+
const item = await this.getIssueProjectItem(projectId, owner, repository, issueNumber);
|
|
222
|
+
return item?.id;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
getItemIdByIssue と同じ引き方で、アイテムの ID とアーカイブ済みかを取る
|
|
226
|
+
*/
|
|
227
|
+
async getIssueProjectItem(projectId, owner, repository, issueNumber) {
|
|
228
|
+
const result = await this.queryIssue(QUERY_GET_ISSUE_PROJECT_ITEMS, { owner, repo: repository, number: issueNumber });
|
|
175
229
|
const repositoryNode = jsonField(result, 'repository');
|
|
176
230
|
if (!isTruthy(repositoryNode))
|
|
177
231
|
return undefined;
|
|
@@ -180,16 +234,43 @@ export class ProjectsApi extends ReposApi {
|
|
|
180
234
|
return undefined;
|
|
181
235
|
const projectItems = truthyNodes(jsonField(issue, 'projectItems'));
|
|
182
236
|
for (const item of projectItems) {
|
|
183
|
-
if (jsonField(jsonField(item, 'project'), 'id')
|
|
184
|
-
|
|
237
|
+
if (jsonField(jsonField(item, 'project'), 'id') !== projectId)
|
|
238
|
+
continue;
|
|
239
|
+
return { id: requireString(jsonField(item, 'id'), 'projectItems.nodes.id'), isArchived: jsonField(item, 'isArchived') === true };
|
|
185
240
|
}
|
|
186
241
|
return undefined;
|
|
187
242
|
}
|
|
188
243
|
/**
|
|
244
|
+
Issue 1 件の、指定のプロジェクトの項目を、readBoard の一覧の項目と同じ形で返す(札は含めない)。
|
|
245
|
+
workflow は進行の列の値で、空なら null。Issue やリポジトリが無い、またはプロジェクトに無ければ undefined
|
|
246
|
+
*/
|
|
247
|
+
async getIssueBoardItem(projectId, owner, repository, issueNumber, workflowFieldName) {
|
|
248
|
+
const result = await this.executeGraphql(QUERY_GET_ISSUE_BOARD_ITEM, { owner, repo: repository, number: issueNumber, workflowFieldName });
|
|
249
|
+
const issue = jsonField(jsonField(result, 'repository'), 'issue');
|
|
250
|
+
if (!isTruthy(issue))
|
|
251
|
+
return undefined;
|
|
252
|
+
const item = truthyNodes(jsonField(issue, 'projectItems')).find(node => jsonField(jsonField(node, 'project'), 'id') === projectId);
|
|
253
|
+
if (item === undefined)
|
|
254
|
+
return undefined;
|
|
255
|
+
const workflow = jsonField(jsonField(item, 'workflow'), 'name');
|
|
256
|
+
const owning = jsonField(issue, 'repository');
|
|
257
|
+
return {
|
|
258
|
+
id: requireString(jsonField(item, 'id'), 'projectItems.nodes.id'),
|
|
259
|
+
workflow: typeof workflow === 'string' ? workflow : JSON_NULL,
|
|
260
|
+
title: jsonField(issue, 'title') ?? '',
|
|
261
|
+
content: {
|
|
262
|
+
number: jsonField(issue, 'number') ?? JSON_NULL,
|
|
263
|
+
state: jsonField(issue, 'state') ?? JSON_NULL,
|
|
264
|
+
url: jsonField(issue, 'url') ?? JSON_NULL,
|
|
265
|
+
repository: `${requireString(jsonField(jsonField(owning, 'owner'), 'login'), 'issue.repository.owner.login')}/${requireString(jsonField(owning, 'name'), 'issue.repository.name')}`,
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
189
270
|
プロジェクトアイテムで値が入っている単一選択フィールドの ID を取る。アイテムが見つからなければ空
|
|
190
271
|
*/
|
|
191
272
|
async getItemSetFieldIds(projectId, owner, repository, issueNumber, itemId) {
|
|
192
|
-
const result = await this.
|
|
273
|
+
const result = await this.queryIssue(QUERY_GET_ISSUE_PROJECT_ITEMS, { owner, repo: repository, number: issueNumber });
|
|
193
274
|
const issue = jsonField(jsonField(result, 'repository'), 'issue');
|
|
194
275
|
const fieldIds = new Set();
|
|
195
276
|
const items = truthyNodes(jsonField(issue, 'projectItems'));
|
|
@@ -44,6 +44,17 @@ export interface ReviewThread {
|
|
|
44
44
|
readonly line: number | null;
|
|
45
45
|
readonly comments: readonly ReviewThreadComment[];
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
GitHub のスタック。pullRequests は下の段からの PR 番号
|
|
49
|
+
*/
|
|
50
|
+
export interface PullRequestStack {
|
|
51
|
+
readonly number: number;
|
|
52
|
+
readonly pullRequests: readonly number[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
Stacks API が求める X-GitHub-Api-Version(https://docs.github.com/en/rest/pulls/stacks)
|
|
56
|
+
*/
|
|
57
|
+
export declare const STACKS_API_VERSION = "2026-03-10";
|
|
47
58
|
export interface PullRequestWithReviews extends PullRequestBase {
|
|
48
59
|
readonly reviews: readonly PullRequestReview[];
|
|
49
60
|
readonly review_threads: readonly ReviewThread[];
|
|
@@ -72,6 +83,19 @@ export declare class PullsApi extends IssuesApi {
|
|
|
72
83
|
*/
|
|
73
84
|
mergePullRequest(owner: string, repository: string, number: number, mergeMethod?: string): Promise<JsonObject>;
|
|
74
85
|
/**
|
|
86
|
+
その PR が入っているスタックを読む。入っていなければ undefined。
|
|
87
|
+
スタックの機能が無いリポは GitHubNotFoundError
|
|
88
|
+
*/
|
|
89
|
+
getStackOfPullRequest(owner: string, repository: string, pullRequestNumber: number): Promise<PullRequestStack | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
スタックを作る。pullRequestNumbers は下の段からの順
|
|
92
|
+
*/
|
|
93
|
+
createStack(owner: string, repository: string, pullRequestNumbers: readonly number[]): Promise<PullRequestStack>;
|
|
94
|
+
/**
|
|
95
|
+
既にあるスタックの一番上に PR を足す。pullRequestNumbers は下からの順
|
|
96
|
+
*/
|
|
97
|
+
addToStack(owner: string, repository: string, stackNumber: number, pullRequestNumbers: readonly number[]): Promise<PullRequestStack>;
|
|
98
|
+
/**
|
|
75
99
|
open の dependabot の PR を全件取る(GraphQL)。pullRequests に author の引数が無いので、全ページを辿ってから絞る。
|
|
76
100
|
GraphQL のノードをそのまま返す
|
|
77
101
|
*/
|
|
@@ -10,6 +10,29 @@ import { asObject, isTruthy, numberOrNull, requireNumber, requireString, require
|
|
|
10
10
|
import { QUERY_GET_PULL_REQUEST_SLIM, QUERY_GET_PULL_REQUEST_WITH_REVIEWS, QUERY_LIST_OPEN_PULL_REQUESTS, QUERY_LIST_PULL_REQUESTS_BY_HEAD } from './queries.js';
|
|
11
11
|
import { readPullRequests } from './readout.js';
|
|
12
12
|
import { repositoryPath } from './rest-path.js';
|
|
13
|
+
/**
|
|
14
|
+
Stacks API が求める X-GitHub-Api-Version(https://docs.github.com/en/rest/pulls/stacks)
|
|
15
|
+
*/
|
|
16
|
+
export const STACKS_API_VERSION = '2026-03-10';
|
|
17
|
+
function readStack(value) {
|
|
18
|
+
if (!isJsonObject(value))
|
|
19
|
+
throwMalformed('stack');
|
|
20
|
+
const pullRequests = jsonField(value, 'pull_requests');
|
|
21
|
+
if (!isJsonArray(pullRequests))
|
|
22
|
+
throwMalformed('stack.pull_requests');
|
|
23
|
+
return {
|
|
24
|
+
number: requireNumber(jsonField(value, 'number'), 'stack.number'),
|
|
25
|
+
pullRequests: pullRequests.map(pullRequest => requireNumber(jsonField(pullRequest, 'number'), 'stack.pull_requests.number')),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// 番号の型を問わずに、その PR を含むか。数でない番号でも含めば、readStack が形の誤りとして止める
|
|
29
|
+
function hasPullRequestNumber(stack, pullRequestNumber) {
|
|
30
|
+
const pullRequests = jsonField(stack, 'pull_requests');
|
|
31
|
+
return isJsonArray(pullRequests) && pullRequests.some((pullRequest) => {
|
|
32
|
+
const number = jsonField(pullRequest, 'number');
|
|
33
|
+
return number === pullRequestNumber || number === String(pullRequestNumber);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
13
36
|
// author がある場合だけ login を読む。author が無い(削除されたユーザーなど)、または login が空なら null
|
|
14
37
|
function loginOrNull(author) {
|
|
15
38
|
const login = jsonField(author, 'login');
|
|
@@ -131,6 +154,39 @@ export class PullsApi extends IssuesApi {
|
|
|
131
154
|
});
|
|
132
155
|
}
|
|
133
156
|
/**
|
|
157
|
+
その PR が入っているスタックを読む。入っていなければ undefined。
|
|
158
|
+
スタックの機能が無いリポは GitHubNotFoundError
|
|
159
|
+
*/
|
|
160
|
+
async getStackOfPullRequest(owner, repository, pullRequestNumber) {
|
|
161
|
+
const stacks = await this.restJson('GET', `${repositoryPath(owner, repository)}/stacks`, {
|
|
162
|
+
params: { pull_request: pullRequestNumber },
|
|
163
|
+
apiVersion: STACKS_API_VERSION,
|
|
164
|
+
});
|
|
165
|
+
if (!isJsonArray(stacks))
|
|
166
|
+
throwMalformed('stacks');
|
|
167
|
+
// 関係の無いスタックの形の誤りで登録を止めないよう、探している PR を含むものだけ厳しく読む
|
|
168
|
+
const found = stacks.find(stack => hasPullRequestNumber(stack, pullRequestNumber));
|
|
169
|
+
return found === undefined ? undefined : readStack(found);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
スタックを作る。pullRequestNumbers は下の段からの順
|
|
173
|
+
*/
|
|
174
|
+
async createStack(owner, repository, pullRequestNumbers) {
|
|
175
|
+
return readStack(await this.restJson('POST', `${repositoryPath(owner, repository)}/stacks`, {
|
|
176
|
+
json: { pull_requests: [...pullRequestNumbers] },
|
|
177
|
+
apiVersion: STACKS_API_VERSION,
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
既にあるスタックの一番上に PR を足す。pullRequestNumbers は下からの順
|
|
182
|
+
*/
|
|
183
|
+
async addToStack(owner, repository, stackNumber, pullRequestNumbers) {
|
|
184
|
+
return readStack(await this.restJson('POST', `${repositoryPath(owner, repository)}/stacks/${String(stackNumber)}/add`, {
|
|
185
|
+
json: { pull_requests: [...pullRequestNumbers] },
|
|
186
|
+
apiVersion: STACKS_API_VERSION,
|
|
187
|
+
}));
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
134
190
|
open の dependabot の PR を全件取る(GraphQL)。pullRequests に author の引数が無いので、全ページを辿ってから絞る。
|
|
135
191
|
GraphQL のノードをそのまま返す
|
|
136
192
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare const QUERY_LIST_PROJECT_ITEMS
|
|
1
|
+
export declare const QUERY_LIST_PROJECT_ITEMS: string;
|
|
2
|
+
export declare const QUERY_LIST_PROJECT_ITEMS_LEGACY: string;
|
|
2
3
|
export declare const QUERY_LIST_PROJECT_ITEMS_FILTERED = "query ($projectId: ID!, $cursor: String, $filterQuery: String) {\n node(id: $projectId) {\n ... on ProjectV2 {\n items(first: 100, after: $cursor, query: $filterQuery) {\n nodes {\n id\n updatedAt\n fieldValues(first: 10) {\n nodes {\n ... on ProjectV2ItemFieldSingleSelectValue {\n field {\n ... on ProjectV2SingleSelectField {\n name\n }\n }\n name\n }\n }\n }\n content {\n ... on Issue {\n id\n number\n title\n state\n url\n labels(first: 10) {\n nodes {\n name\n }\n }\n repository {\n owner {\n login\n }\n name\n }\n }\n ... on PullRequest {\n id\n number\n title\n state\n url\n repository {\n owner {\n login\n }\n name\n }\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n}";
|
|
3
4
|
export declare const QUERY_GET_ISSUE_NODE_ID = "query ($owner: String!, $repo: String!, $number: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n id\n title\n }\n }\n}";
|
|
4
5
|
export declare const QUERY_GET_LINKED_REPOSITORIES_USER = "query ($owner: String!, $projectNumber: Int!) {\n user(login: $owner) {\n projectV2(number: $projectNumber) {\n repositories(first: 100) {\n nodes {\n owner {\n login\n }\n name\n }\n }\n }\n }\n}";
|
|
@@ -10,9 +11,10 @@ export declare const MUTATION_LINK_PROJECT_REPOSITORY = "mutation ($projectId: I
|
|
|
10
11
|
export declare const MUTATION_ADD_TO_PROJECT = "mutation ($projectId: ID!, $contentId: ID!) {\n addProjectV2ItemById(input: { projectId: $projectId, contentId: $contentId }) {\n item {\n id\n }\n }\n}";
|
|
11
12
|
export declare const MUTATION_UPDATE_PROJECT_ITEM_FIELD = "mutation ($projectId: ID!, $itemId: ID!, $fieldId: ID!, $optionId: String!) {\n updateProjectV2ItemFieldValue(\n input: {\n projectId: $projectId\n itemId: $itemId\n fieldId: $fieldId\n value: { singleSelectOptionId: $optionId }\n }\n ) {\n projectV2Item {\n id\n }\n }\n}";
|
|
12
13
|
export declare const MUTATION_DELETE_PROJECT_ITEM = "mutation ($projectId: ID!, $itemId: ID!) {\n deleteProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {\n deletedItemId\n }\n}";
|
|
14
|
+
export declare const MUTATION_UNARCHIVE_PROJECT_ITEM = "mutation ($projectId: ID!, $itemId: ID!) {\n unarchiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {\n item {\n id\n }\n }\n}";
|
|
13
15
|
export declare const MUTATION_ADD_SUB_ISSUE = "mutation ($parentId: ID!, $childId: ID!) {\n addSubIssue(input: { issueId: $parentId, subIssueId: $childId }) {\n issue {\n number\n }\n subIssue {\n number\n }\n }\n}";
|
|
14
16
|
export declare const MUTATION_CREATE_LINKED_BRANCH = "mutation CreateLinkedBranch($input: CreateLinkedBranchInput!) {\n createLinkedBranch(input: $input) {\n linkedBranch {\n ref {\n name\n prefix\n }\n }\n }\n}";
|
|
15
|
-
export declare const QUERY_GET_ISSUE_PROJECT_ITEMS = "query ($owner: String!, $repo: String!, $number: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n projectItems(first: 20) {\n nodes {\n id\n project {\n id\n }\n fieldValues(first: 20) {\n nodes {\n ... on ProjectV2ItemFieldSingleSelectValue {\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}";
|
|
17
|
+
export declare const QUERY_GET_ISSUE_PROJECT_ITEMS = "query ($owner: String!, $repo: String!, $number: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n projectItems(first: 20) {\n nodes {\n id\n isArchived\n project {\n id\n }\n fieldValues(first: 20) {\n nodes {\n ... on ProjectV2ItemFieldSingleSelectValue {\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}";
|
|
16
18
|
export declare const QUERY_LIST_PROJECTS_USER = "query ($owner: String!, $first: Int!) {\n user(login: $owner) {\n projectsV2(first: $first) {\n nodes {\n number\n title\n url\n id\n }\n }\n }\n}";
|
|
17
19
|
export declare const QUERY_LIST_PROJECTS_ORG = "query ($owner: String!, $first: Int!) {\n organization(login: $owner) {\n projectsV2(first: $first) {\n nodes {\n number\n title\n url\n id\n }\n }\n }\n}";
|
|
18
20
|
export declare const QUERY_GET_PROJECT_FIELDS_USER = "query ($owner: String!, $projectNumber: Int!) {\n user(login: $owner) {\n projectV2(number: $projectNumber) {\n id\n title\n url\n fields(first: 50) {\n nodes {\n ... on ProjectV2SingleSelectField {\n id\n databaseId\n name\n options {\n id\n name\n color\n description\n }\n }\n ... on ProjectV2Field {\n id\n name\n }\n }\n }\n views(first: 1) {\n nodes {\n number\n }\n }\n }\n }\n}";
|
|
@@ -24,13 +26,19 @@ export declare const QUERY_GET_ORG_NODE_ID = "query ($login: String!) {\n organ
|
|
|
24
26
|
export declare const MUTATION_CREATE_PROJECT = "mutation ($ownerId: ID!, $title: String!) {\n createProjectV2(input: { ownerId: $ownerId, title: $title }) {\n projectV2 {\n id\n number\n title\n url\n }\n }\n}";
|
|
25
27
|
export declare const QUERY_GET_ISSUE_KIND = "query ($owner: String!, $repo: String!, $number: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n number\n state\n issueType {\n name\n }\n subIssues(first: 1) {\n totalCount\n }\n }\n }\n}";
|
|
26
28
|
export declare const QUERY_GET_ISSUE_KIND_PHASE1 = "query ($owner: String!, $repo: String!, $number: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n number\n state\n subIssues(first: 1) {\n totalCount\n }\n }\n }\n}";
|
|
27
|
-
export declare const QUERY_GET_ISSUE_SLIM
|
|
29
|
+
export declare const QUERY_GET_ISSUE_SLIM: string;
|
|
30
|
+
export declare const QUERY_GET_ISSUE_SLIM_WITHOUT_BLOCKED_BY: string;
|
|
28
31
|
export declare const QUERY_GET_SUB_ISSUES_PAGE = "query ($owner: String!, $repo: String!, $number: Int!, $after: String!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n subIssues(first: 100, after: $after) {\n nodes {\n number\n state\n title\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n}";
|
|
29
32
|
export declare const QUERY_GET_PULL_REQUEST_SLIM = "query ($owner: String!, $repo: String!, $number: Int!) {\n repository(owner: $owner, name: $repo) {\n pullRequest(number: $number) {\n number\n state\n title\n body\n headRefName\n baseRefName\n isDraft\n mergeable\n comments {\n totalCount\n }\n closingIssuesReferences(first: 10) {\n nodes {\n number\n title\n }\n }\n reviews(first: 10) {\n nodes {\n state\n author {\n login\n }\n }\n }\n }\n }\n}";
|
|
30
33
|
export declare const QUERY_GET_PULL_REQUEST_WITH_REVIEWS = "query ($owner: String!, $repo: String!, $number: Int!) {\n repository(owner: $owner, name: $repo) {\n pullRequest(number: $number) {\n number\n state\n title\n body\n headRefName\n baseRefName\n isDraft\n mergeable\n comments {\n totalCount\n }\n closingIssuesReferences(first: 10) {\n nodes {\n number\n title\n }\n }\n reviews(first: 20) {\n nodes {\n state\n body\n author {\n login\n }\n submittedAt\n }\n }\n reviewThreads(first: 50) {\n nodes {\n isResolved\n path\n line\n comments(first: 10) {\n nodes {\n author {\n login\n }\n body\n createdAt\n }\n }\n }\n }\n }\n }\n}";
|
|
31
34
|
export declare const QUERY_LIST_OPEN_PULL_REQUESTS = "query ($owner: String!, $repo: String!, $after: String) {\n repository(owner: $owner, name: $repo) {\n pullRequests(\n first: 25\n states: OPEN\n after: $after\n orderBy: { field: CREATED_AT, direction: ASC }\n ) {\n pageInfo {\n hasNextPage\n endCursor\n }\n nodes {\n number\n title\n url\n createdAt\n author {\n __typename\n login\n }\n isInMergeQueue\n autoMergeRequest {\n enabledAt\n }\n mergeable\n baseRef {\n target {\n ... on Commit {\n committedDate\n }\n }\n }\n firstCommits: commits(first: 1) {\n nodes {\n commit {\n message\n signature {\n isValid\n }\n author {\n user {\n login\n }\n }\n }\n }\n }\n headCommits: commits(last: 1) {\n nodes {\n commit {\n statusCheckRollup {\n state\n }\n }\n }\n }\n lastForcePush: timelineItems(last: 1, itemTypes: [HEAD_REF_FORCE_PUSHED_EVENT]) {\n nodes {\n ... on HeadRefForcePushedEvent {\n createdAt\n }\n }\n }\n lastDequeue: timelineItems(last: 1, itemTypes: [REMOVED_FROM_MERGE_QUEUE_EVENT]) {\n nodes {\n ... on RemovedFromMergeQueueEvent {\n createdAt\n }\n }\n }\n }\n }\n }\n}";
|
|
35
|
+
export declare const QUERY_HAS_ADD_BLOCKED_BY_INPUT = "{\n __type(name: \"AddBlockedByInput\") {\n name\n }\n}";
|
|
32
36
|
export declare const MUTATION_ADD_BLOCKED_BY = "mutation ($issueId: ID!, $blockingIssueId: ID!) {\n addBlockedBy(input: { issueId: $issueId, blockingIssueId: $blockingIssueId }) {\n issue {\n number\n }\n blockingIssue {\n number\n }\n }\n}";
|
|
33
37
|
export declare const MUTATION_REMOVE_BLOCKED_BY = "mutation ($issueId: ID!, $blockingIssueId: ID!) {\n removeBlockedBy(input: { issueId: $issueId, blockingIssueId: $blockingIssueId }) {\n issue {\n number\n }\n blockingIssue {\n number\n }\n }\n}";
|
|
34
|
-
export declare const QUERY_GET_ISSUE_PREREQUISITES = "query ($owner: String!, $repo: String!, $number: Int!, $columnFieldName: String!, $labelFieldName: String!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n ...PrerequisiteIssueFields\n body\n blockedBy(first:
|
|
38
|
+
export declare const QUERY_GET_ISSUE_PREREQUISITES = "query ($owner: String!, $repo: String!, $number: Int!, $columnFieldName: String!, $labelFieldName: String!, $blockedByFirst: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n ...PrerequisiteIssueFields\n body\n parent {\n number\n repository {\n owner {\n login\n }\n name\n }\n }\n blockedBy(first: $blockedByFirst) {\n totalCount\n nodes {\n ...PrerequisiteIssueFields\n }\n }\n }\n }\n}\n\nfragment PrerequisiteIssueFields on Issue {\n id\n number\n state\n title\n repository {\n owner {\n login\n }\n name\n }\n issueType {\n name\n }\n subIssues(first: 1) {\n totalCount\n }\n projectItems(first: 20, includeArchived: false) {\n totalCount\n nodes {\n project {\n id\n }\n column: fieldValueByName(name: $columnFieldName) {\n ...SingleSelectValueFields\n }\n label: fieldValueByName(name: $labelFieldName) {\n ...SingleSelectValueFields\n }\n }\n }\n linkedBranches(first: 10) {\n totalCount\n nodes {\n ref {\n name\n associatedPullRequests(first: 10) {\n totalCount\n nodes {\n ...PullRequestFields\n }\n }\n }\n }\n }\n closedByPullRequestsReferences(first: 10, includeClosedPrs: true) {\n totalCount\n nodes {\n ...PullRequestFields\n }\n }\n timelineItems(\n itemTypes: [CONNECTED_EVENT, DISCONNECTED_EVENT, CROSS_REFERENCED_EVENT]\n first: 20\n ) {\n totalCount\n nodes {\n __typename\n ... on ConnectedEvent {\n subject {\n ... on PullRequest {\n ...PullRequestFields\n }\n }\n }\n ... on DisconnectedEvent {\n subject {\n ... on PullRequest {\n ...PullRequestFields\n }\n }\n }\n ... on CrossReferencedEvent {\n willCloseTarget\n source {\n ... on PullRequest {\n ...PullRequestFields\n }\n }\n }\n }\n }\n}\n\nfragment SingleSelectValueFields on ProjectV2ItemFieldValue {\n ... on ProjectV2ItemFieldSingleSelectValue {\n name\n optionId\n field {\n ... on ProjectV2SingleSelectField {\n id\n }\n }\n }\n}\n\nfragment PullRequestFields on PullRequest {\n number\n state\n headRefName\n baseRefName\n isDraft\n isCrossRepository\n repository {\n owner {\n login\n }\n name\n }\n}";
|
|
35
39
|
export declare const QUERY_LIST_PULL_REQUESTS_BY_HEAD = "query ($owner: String!, $repo: String!, $headRefName: String!) {\n repository(owner: $owner, name: $repo) {\n pullRequests(\n headRefName: $headRefName\n states: [OPEN, CLOSED, MERGED]\n first: 20\n orderBy: { field: CREATED_AT, direction: DESC }\n ) {\n pageInfo {\n hasNextPage\n }\n nodes {\n ...PullRequestFields\n }\n }\n }\n}\n\nfragment PullRequestFields on PullRequest {\n number\n state\n headRefName\n baseRefName\n isDraft\n isCrossRepository\n repository {\n owner {\n login\n }\n name\n }\n}";
|
|
40
|
+
export declare const QUERY_GET_ISSUE_BLOCKED_BY_REFERENCES = "query ($owner: String!, $repo: String!, $number: Int!, $blockedByFirst: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n id\n body\n blockedBy(first: $blockedByFirst) {\n totalCount\n nodes {\n ...BlockedByReferenceFields\n }\n }\n }\n }\n}\n\nfragment BlockedByReferenceFields on Issue {\n id\n number\n state\n repository {\n owner {\n login\n }\n name\n }\n}";
|
|
41
|
+
export declare const QUERY_GET_BLOCKED_BY_OF_NODES = "query ($ids: [ID!]!, $blockedByFirst: Int!) {\n nodes(ids: $ids) {\n ... on Issue {\n id\n blockedBy(first: $blockedByFirst) {\n totalCount\n nodes {\n ...BlockedByReferenceFields\n }\n }\n }\n }\n}\n\nfragment BlockedByReferenceFields on Issue {\n id\n number\n state\n repository {\n owner {\n login\n }\n name\n }\n}";
|
|
42
|
+
export declare const QUERY_GET_ISSUE_BLOCKING_REFERENCES = "query ($owner: String!, $repo: String!, $number: Int!, $blockingFirst: Int!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n blocking(first: $blockingFirst) {\n totalCount\n nodes {\n ...BlockedByReferenceFields\n }\n }\n }\n }\n}\n\nfragment BlockedByReferenceFields on Issue {\n id\n number\n state\n repository {\n owner {\n login\n }\n name\n }\n}";
|
|
43
|
+
export declare const QUERY_GET_ISSUE_BOARD_ITEM = "query ($owner: String!, $repo: String!, $number: Int!, $workflowFieldName: String!) {\n repository(owner: $owner, name: $repo) {\n issue(number: $number) {\n number\n title\n state\n url\n repository {\n owner {\n login\n }\n name\n }\n projectItems(first: 20, includeArchived: false) {\n nodes {\n id\n project {\n id\n }\n workflow: fieldValueByName(name: $workflowFieldName) {\n ... on ProjectV2ItemFieldSingleSelectValue {\n name\n }\n }\n }\n }\n }\n }\n}";
|
|
36
44
|
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -1,8 +1,29 @@
|
|
|
1
1
|
// GitHub GraphQL API のクエリ・mutation 文字列。
|
|
2
2
|
// 先頭の 30 個は cli/core/github/queries.py を gql が送る形で写し、一致は infra/github/tests/queries.test.ts が固定する。
|
|
3
3
|
// 末尾の blocked by 関係の 4 個は Python に無く、graphql-js の print の出力の形で書く。
|
|
4
|
-
//
|
|
5
|
-
|
|
4
|
+
// 着手の判定に使う、Issue の依存関係・種別・親のフィールド。Issue の依存関係に対応しない GHES では通らない
|
|
5
|
+
const ISSUE_READINESS_FIELDS = `
|
|
6
|
+
issueType {
|
|
7
|
+
name
|
|
8
|
+
}
|
|
9
|
+
subIssues(first: 1) {
|
|
10
|
+
totalCount
|
|
11
|
+
}
|
|
12
|
+
parent {
|
|
13
|
+
number
|
|
14
|
+
repository {
|
|
15
|
+
owner {
|
|
16
|
+
login
|
|
17
|
+
}
|
|
18
|
+
name
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
blockedBy(first: 1) {
|
|
22
|
+
totalCount
|
|
23
|
+
}`;
|
|
24
|
+
// 一覧のクエリ。operationName が空なら無名。readinessFields は Issue の枝に足すフィールド
|
|
25
|
+
function listProjectItemsQuery(operationName, readinessFields) {
|
|
26
|
+
return `query${operationName === '' ? ' ' : ` ${operationName}`}($projectId: ID!, $cursor: String) {
|
|
6
27
|
node(id: $projectId) {
|
|
7
28
|
... on ProjectV2 {
|
|
8
29
|
items(first: 100, after: $cursor) {
|
|
@@ -27,7 +48,7 @@ export const QUERY_LIST_PROJECT_ITEMS = `query ($projectId: ID!, $cursor: String
|
|
|
27
48
|
number
|
|
28
49
|
title
|
|
29
50
|
state
|
|
30
|
-
url
|
|
51
|
+
url${readinessFields}
|
|
31
52
|
labels(first: 10) {
|
|
32
53
|
nodes {
|
|
33
54
|
name
|
|
@@ -63,6 +84,11 @@ export const QUERY_LIST_PROJECT_ITEMS = `query ($projectId: ID!, $cursor: String
|
|
|
63
84
|
}
|
|
64
85
|
}
|
|
65
86
|
}`;
|
|
87
|
+
}
|
|
88
|
+
// プロジェクトアイテム一覧取得(ページネーション対応)
|
|
89
|
+
export const QUERY_LIST_PROJECT_ITEMS = listProjectItemsQuery('', ISSUE_READINESS_FIELDS);
|
|
90
|
+
// 上の一覧から、Issue の依存関係に対応しない GHES で通らないフィールドを除いたもの
|
|
91
|
+
export const QUERY_LIST_PROJECT_ITEMS_LEGACY = listProjectItemsQuery('ListProjectItemsLegacy', '');
|
|
66
92
|
// プロジェクトアイテム一覧取得(フィルタリング対応)
|
|
67
93
|
export const QUERY_LIST_PROJECT_ITEMS_FILTERED = `query ($projectId: ID!, $cursor: String, $filterQuery: String) {
|
|
68
94
|
node(id: $projectId) {
|
|
@@ -226,6 +252,14 @@ export const MUTATION_DELETE_PROJECT_ITEM = `mutation ($projectId: ID!, $itemId:
|
|
|
226
252
|
deletedItemId
|
|
227
253
|
}
|
|
228
254
|
}`;
|
|
255
|
+
// プロジェクトアイテムのアーカイブを解く
|
|
256
|
+
export const MUTATION_UNARCHIVE_PROJECT_ITEM = `mutation ($projectId: ID!, $itemId: ID!) {
|
|
257
|
+
unarchiveProjectV2Item(input: { projectId: $projectId, itemId: $itemId }) {
|
|
258
|
+
item {
|
|
259
|
+
id
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}`;
|
|
229
263
|
// サブIssue紐づけ
|
|
230
264
|
export const MUTATION_ADD_SUB_ISSUE = `mutation ($parentId: ID!, $childId: ID!) {
|
|
231
265
|
addSubIssue(input: { issueId: $parentId, subIssueId: $childId }) {
|
|
@@ -255,6 +289,7 @@ export const QUERY_GET_ISSUE_PROJECT_ITEMS = `query ($owner: String!, $repo: Str
|
|
|
255
289
|
projectItems(first: 20) {
|
|
256
290
|
nodes {
|
|
257
291
|
id
|
|
292
|
+
isArchived
|
|
258
293
|
project {
|
|
259
294
|
id
|
|
260
295
|
}
|
|
@@ -458,8 +493,9 @@ export const QUERY_GET_ISSUE_KIND_PHASE1 = `query ($owner: String!, $repo: Strin
|
|
|
458
493
|
}
|
|
459
494
|
}
|
|
460
495
|
}`;
|
|
461
|
-
// Issue
|
|
462
|
-
|
|
496
|
+
// Issue詳細取得のクエリ。blockedByCount は前提の件数のフィールド。Issue の依存関係に対応しない GHES では通らない
|
|
497
|
+
function getIssueSlimQuery(operationName, blockedByCount) {
|
|
498
|
+
return `query${operationName === '' ? ' ' : ` ${operationName}`}($owner: String!, $repo: String!, $number: Int!, $commentLimit: Int!) {
|
|
463
499
|
repository(owner: $owner, name: $repo) {
|
|
464
500
|
issue(number: $number) {
|
|
465
501
|
number
|
|
@@ -526,10 +562,18 @@ export const QUERY_GET_ISSUE_SLIM = `query ($owner: String!, $repo: String!, $nu
|
|
|
526
562
|
}
|
|
527
563
|
}
|
|
528
564
|
}
|
|
529
|
-
}
|
|
565
|
+
}${blockedByCount}
|
|
530
566
|
}
|
|
531
567
|
}
|
|
532
568
|
}`;
|
|
569
|
+
}
|
|
570
|
+
// Issue詳細取得(スリム版 - 必要なフィールドのみ。前提の件数つき)
|
|
571
|
+
export const QUERY_GET_ISSUE_SLIM = getIssueSlimQuery('', `
|
|
572
|
+
blockedBy(first: 1) {
|
|
573
|
+
totalCount
|
|
574
|
+
}`);
|
|
575
|
+
// 上のクエリから、前提の件数を除いたもの。Issue の依存関係を持たない GHES で読み直すのに使う
|
|
576
|
+
export const QUERY_GET_ISSUE_SLIM_WITHOUT_BLOCKED_BY = getIssueSlimQuery('GetIssueSlimWithoutBlockedBy', '');
|
|
533
577
|
// Python 版 queries.py の QUERY_GET_SUB_ISSUES_PAGE と逐語で一致させる。
|
|
534
578
|
export const QUERY_GET_SUB_ISSUES_PAGE = `query ($owner: String!, $repo: String!, $number: Int!, $after: String!) {
|
|
535
579
|
repository(owner: $owner, name: $repo) {
|
|
@@ -709,6 +753,12 @@ export const QUERY_LIST_OPEN_PULL_REQUESTS = `query ($owner: String!, $repo: Str
|
|
|
709
753
|
}
|
|
710
754
|
}
|
|
711
755
|
}`;
|
|
756
|
+
// 前提(blocked by)を付ける入力の型があるか。対応しない GHES(3.19 より前)では null になる
|
|
757
|
+
export const QUERY_HAS_ADD_BLOCKED_BY_INPUT = `{
|
|
758
|
+
__type(name: "AddBlockedByInput") {
|
|
759
|
+
name
|
|
760
|
+
}
|
|
761
|
+
}`;
|
|
712
762
|
// 前提(blocked by)を付ける。issueId が待つ側、blockingIssueId が前提
|
|
713
763
|
export const MUTATION_ADD_BLOCKED_BY = `mutation ($issueId: ID!, $blockingIssueId: ID!) {
|
|
714
764
|
addBlockedBy(input: { issueId: $issueId, blockingIssueId: $blockingIssueId }) {
|
|
@@ -840,12 +890,21 @@ const SINGLE_SELECT_VALUE_FIELDS = `fragment SingleSelectValueFields on ProjectV
|
|
|
840
890
|
}
|
|
841
891
|
}`;
|
|
842
892
|
// Issue と、その前提(blockedBy)を 1 回で読む。PR は 3 つの読み口から集める
|
|
843
|
-
export const QUERY_GET_ISSUE_PREREQUISITES = `query ($owner: String!, $repo: String!, $number: Int!, $columnFieldName: String!, $labelFieldName: String!) {
|
|
893
|
+
export const QUERY_GET_ISSUE_PREREQUISITES = `query ($owner: String!, $repo: String!, $number: Int!, $columnFieldName: String!, $labelFieldName: String!, $blockedByFirst: Int!) {
|
|
844
894
|
repository(owner: $owner, name: $repo) {
|
|
845
895
|
issue(number: $number) {
|
|
846
896
|
...PrerequisiteIssueFields
|
|
847
897
|
body
|
|
848
|
-
|
|
898
|
+
parent {
|
|
899
|
+
number
|
|
900
|
+
repository {
|
|
901
|
+
owner {
|
|
902
|
+
login
|
|
903
|
+
}
|
|
904
|
+
name
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
blockedBy(first: $blockedByFirst) {
|
|
849
908
|
totalCount
|
|
850
909
|
nodes {
|
|
851
910
|
...PrerequisiteIssueFields
|
|
@@ -880,4 +939,93 @@ export const QUERY_LIST_PULL_REQUESTS_BY_HEAD = `query ($owner: String!, $repo:
|
|
|
880
939
|
}
|
|
881
940
|
|
|
882
941
|
${PULL_REQUEST_FIELDS}`;
|
|
942
|
+
const BLOCKED_BY_REFERENCE_FIELDS = `fragment BlockedByReferenceFields on Issue {
|
|
943
|
+
id
|
|
944
|
+
number
|
|
945
|
+
state
|
|
946
|
+
repository {
|
|
947
|
+
owner {
|
|
948
|
+
login
|
|
949
|
+
}
|
|
950
|
+
name
|
|
951
|
+
}
|
|
952
|
+
}`;
|
|
953
|
+
// 前提の追加・削除の前の読み取り。判定の読み取りより軽く、本文と前提の参照だけを取る
|
|
954
|
+
export const QUERY_GET_ISSUE_BLOCKED_BY_REFERENCES = `query ($owner: String!, $repo: String!, $number: Int!, $blockedByFirst: Int!) {
|
|
955
|
+
repository(owner: $owner, name: $repo) {
|
|
956
|
+
issue(number: $number) {
|
|
957
|
+
id
|
|
958
|
+
body
|
|
959
|
+
blockedBy(first: $blockedByFirst) {
|
|
960
|
+
totalCount
|
|
961
|
+
nodes {
|
|
962
|
+
...BlockedByReferenceFields
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
${BLOCKED_BY_REFERENCE_FIELDS}`;
|
|
970
|
+
// 輪をたどる 1 段分。node ID の並びのそれぞれの前提を、まとめて読む
|
|
971
|
+
export const QUERY_GET_BLOCKED_BY_OF_NODES = `query ($ids: [ID!]!, $blockedByFirst: Int!) {
|
|
972
|
+
nodes(ids: $ids) {
|
|
973
|
+
... on Issue {
|
|
974
|
+
id
|
|
975
|
+
blockedBy(first: $blockedByFirst) {
|
|
976
|
+
totalCount
|
|
977
|
+
nodes {
|
|
978
|
+
...BlockedByReferenceFields
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
${BLOCKED_BY_REFERENCE_FIELDS}`;
|
|
986
|
+
// その Issue を前提にしている Issue(blocking)の参照。PR を作った後に、待つ側の Issue を絞るために読む
|
|
987
|
+
export const QUERY_GET_ISSUE_BLOCKING_REFERENCES = `query ($owner: String!, $repo: String!, $number: Int!, $blockingFirst: Int!) {
|
|
988
|
+
repository(owner: $owner, name: $repo) {
|
|
989
|
+
issue(number: $number) {
|
|
990
|
+
blocking(first: $blockingFirst) {
|
|
991
|
+
totalCount
|
|
992
|
+
nodes {
|
|
993
|
+
...BlockedByReferenceFields
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
${BLOCKED_BY_REFERENCE_FIELDS}`;
|
|
1001
|
+
// Issue 1 件の、指定のプロジェクトの項目と進行の列。ボード全体を読まずに、列を動かす対象を読む
|
|
1002
|
+
export const QUERY_GET_ISSUE_BOARD_ITEM = `query ($owner: String!, $repo: String!, $number: Int!, $workflowFieldName: String!) {
|
|
1003
|
+
repository(owner: $owner, name: $repo) {
|
|
1004
|
+
issue(number: $number) {
|
|
1005
|
+
number
|
|
1006
|
+
title
|
|
1007
|
+
state
|
|
1008
|
+
url
|
|
1009
|
+
repository {
|
|
1010
|
+
owner {
|
|
1011
|
+
login
|
|
1012
|
+
}
|
|
1013
|
+
name
|
|
1014
|
+
}
|
|
1015
|
+
projectItems(first: 20, includeArchived: false) {
|
|
1016
|
+
nodes {
|
|
1017
|
+
id
|
|
1018
|
+
project {
|
|
1019
|
+
id
|
|
1020
|
+
}
|
|
1021
|
+
workflow: fieldValueByName(name: $workflowFieldName) {
|
|
1022
|
+
... on ProjectV2ItemFieldSingleSelectValue {
|
|
1023
|
+
name
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}`;
|
|
883
1031
|
//# sourceMappingURL=queries.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockedByReadout, IssueReadout, PrerequisiteFieldNames, PullRequestReadout } from '../../domain/issue-readout.js';
|
|
1
|
+
import type { BlockedByReadout, BlockedByReference, IssueReadout, PrerequisiteFieldNames, PullRequestReadout } from '../../domain/issue-readout.js';
|
|
2
2
|
import type { JsonValue } from '../../domain/python-format.js';
|
|
3
3
|
/**
|
|
4
4
|
PR のノード 1 つ。`... on PullRequest` の型でない node は空で届くので、undefined を返す。
|
|
@@ -15,4 +15,8 @@ export declare function readIssue(issue: JsonValue, projectId: string, fieldName
|
|
|
15
15
|
- 対象か前提の Issue の connection が、件数の上限で取りこぼされている
|
|
16
16
|
*/
|
|
17
17
|
export declare function readBlockedBy(target: JsonValue, projectId: string, fieldNames: Readonly<PrerequisiteFieldNames>, errorMessages?: readonly string[]): BlockedByReadout;
|
|
18
|
+
/**
|
|
19
|
+
前提 1 件の参照(node ID・番号・リポ・状態)。node は BlockedByReferenceFields の形
|
|
20
|
+
*/
|
|
21
|
+
export declare function readIssueReference(node: JsonValue | undefined): BlockedByReference;
|
|
18
22
|
//# sourceMappingURL=readout.d.ts.map
|