@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.
Files changed (176) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +80 -22
  3. package/cli/dist/cli.js +6 -1
  4. package/cli/dist/commands/board-add.d.ts +3 -0
  5. package/cli/dist/commands/board-add.js +59 -0
  6. package/cli/dist/commands/board-judgment.d.ts +60 -0
  7. package/cli/dist/commands/board-judgment.js +144 -0
  8. package/cli/dist/commands/board-move.d.ts +3 -0
  9. package/cli/dist/commands/board-move.js +57 -0
  10. package/cli/dist/commands/board-readiness.d.ts +34 -0
  11. package/cli/dist/commands/board-readiness.js +108 -0
  12. package/cli/dist/commands/board-show.d.ts +3 -0
  13. package/cli/dist/commands/board-show.js +72 -0
  14. package/cli/dist/commands/board-sync.d.ts +3 -0
  15. package/cli/dist/commands/board-sync.js +111 -0
  16. package/cli/dist/commands/{project-info.d.ts → board-view.d.ts} +21 -7
  17. package/cli/dist/commands/{project-info.js → board-view.js} +22 -12
  18. package/cli/dist/commands/board.d.ts +3 -0
  19. package/cli/dist/commands/board.js +12 -0
  20. package/cli/dist/commands/branch.d.ts +3 -0
  21. package/cli/dist/commands/branch.js +100 -0
  22. package/cli/dist/commands/command-binding.js +4 -0
  23. package/cli/dist/commands/command-definition.d.ts +20 -6
  24. package/cli/dist/commands/command-definition.js +11 -7
  25. package/cli/dist/commands/command-help.js +2 -2
  26. package/cli/dist/commands/command-hint.d.ts +5 -0
  27. package/cli/dist/commands/command-hint.js +13 -0
  28. package/cli/dist/commands/command-stop.d.ts +5 -3
  29. package/cli/dist/commands/command-stop.js +7 -6
  30. package/cli/dist/commands/failure-kind.d.ts +3 -0
  31. package/cli/dist/commands/failure-kind.js +34 -0
  32. package/cli/dist/commands/failure.d.ts +6 -0
  33. package/cli/dist/commands/failure.js +29 -3
  34. package/cli/dist/commands/github-client.d.ts +6 -2
  35. package/cli/dist/commands/github-client.js +13 -3
  36. package/cli/dist/commands/help.js +8 -13
  37. package/cli/dist/commands/issue-board.d.ts +33 -0
  38. package/cli/dist/commands/issue-board.js +61 -1
  39. package/cli/dist/commands/issue-comment.js +47 -28
  40. package/cli/dist/commands/issue-create.js +548 -91
  41. package/cli/dist/commands/issue-dependency.d.ts +3 -0
  42. package/cli/dist/commands/issue-dependency.js +282 -0
  43. package/cli/dist/commands/issue-readiness.d.ts +94 -0
  44. package/cli/dist/commands/issue-readiness.js +218 -0
  45. package/cli/dist/commands/issue-reopen.d.ts +3 -0
  46. package/cli/dist/commands/issue-reopen.js +115 -0
  47. package/cli/dist/commands/issue-shared.d.ts +32 -19
  48. package/cli/dist/commands/issue-shared.js +82 -75
  49. package/cli/dist/commands/issue-show.d.ts +3 -0
  50. package/cli/dist/commands/issue-show.js +169 -0
  51. package/cli/dist/commands/issue.d.ts +0 -1
  52. package/cli/dist/commands/issue.js +6 -8
  53. package/cli/dist/commands/names.d.ts +33 -0
  54. package/cli/dist/commands/names.js +62 -0
  55. package/cli/dist/commands/output.d.ts +14 -2
  56. package/cli/dist/commands/output.js +14 -7
  57. package/cli/dist/commands/pr-waiting.d.ts +20 -0
  58. package/cli/dist/commands/pr-waiting.js +106 -0
  59. package/cli/dist/commands/pr.d.ts +19 -0
  60. package/cli/dist/commands/pr.js +242 -323
  61. package/cli/dist/commands/project-sync.d.ts +2 -1
  62. package/cli/dist/commands/project-sync.js +18 -9
  63. package/cli/dist/commands/project.d.ts +3 -2
  64. package/cli/dist/commands/project.js +212 -175
  65. package/cli/dist/commands/registry.js +13 -10
  66. package/cli/dist/commands/release.d.ts +2 -2
  67. package/cli/dist/commands/release.js +53 -114
  68. package/cli/dist/commands/renamed-commands.d.ts +26 -0
  69. package/cli/dist/commands/renamed-commands.js +53 -0
  70. package/cli/dist/commands/repository-match.js +3 -2
  71. package/cli/dist/commands/session-finish.d.ts +3 -0
  72. package/cli/dist/commands/session-finish.js +267 -0
  73. package/cli/dist/commands/session-start.d.ts +3 -0
  74. package/cli/dist/commands/{repository.js → session-start.js} +99 -128
  75. package/cli/dist/commands/session.d.ts +3 -0
  76. package/cli/dist/commands/session.js +82 -29
  77. package/cli/dist/commands/tracker-sync-dependabot.d.ts +7 -0
  78. package/cli/dist/commands/{dependabot.js → tracker-sync-dependabot.js} +57 -66
  79. package/cli/dist/commands/tracker-sync-security.d.ts +7 -0
  80. package/cli/dist/commands/{security.js → tracker-sync-security.js} +50 -61
  81. package/cli/dist/commands/tracker-sync.d.ts +7 -0
  82. package/cli/dist/commands/tracker-sync.js +3 -6
  83. package/cli/dist/commands/tracker.d.ts +3 -0
  84. package/cli/dist/commands/tracker.js +18 -0
  85. package/cli/dist/commands/usage-error.d.ts +4 -0
  86. package/cli/dist/commands/usage-error.js +6 -0
  87. package/cli/dist/commands/work-target.d.ts +12 -3
  88. package/cli/dist/commands/work-target.js +46 -5
  89. package/cli/dist/commands/worktree.js +32 -28
  90. package/cli/dist/domain/batch-plan.d.ts +73 -0
  91. package/cli/dist/domain/batch-plan.js +114 -0
  92. package/cli/dist/domain/blocked-by-change.d.ts +99 -0
  93. package/cli/dist/domain/blocked-by-change.js +101 -0
  94. package/cli/dist/domain/board-move.d.ts +90 -0
  95. package/cli/dist/domain/board-move.js +92 -0
  96. package/cli/dist/domain/branch-name.js +1 -1
  97. package/cli/dist/domain/command-hint.d.ts +85 -0
  98. package/cli/dist/domain/command-hint.js +148 -0
  99. package/cli/dist/domain/config.d.ts +4 -0
  100. package/cli/dist/domain/config.js +11 -1
  101. package/cli/dist/domain/dependabot.js +1 -1
  102. package/cli/dist/domain/errors.d.ts +5 -0
  103. package/cli/dist/domain/errors.js +5 -0
  104. package/cli/dist/domain/format.d.ts +51 -4
  105. package/cli/dist/domain/format.js +72 -6
  106. package/cli/dist/domain/frontmatter.d.ts +18 -3
  107. package/cli/dist/domain/frontmatter.js +38 -12
  108. package/cli/dist/domain/issue-order.d.ts +55 -0
  109. package/cli/dist/domain/issue-order.js +65 -0
  110. package/cli/dist/domain/issue-readout.d.ts +36 -0
  111. package/cli/dist/domain/pull-request.d.ts +71 -4
  112. package/cli/dist/domain/pull-request.js +59 -10
  113. package/cli/dist/domain/readiness.d.ts +27 -0
  114. package/cli/dist/domain/readiness.js +114 -3
  115. package/cli/dist/domain/reference-parser.d.ts +3 -1
  116. package/cli/dist/domain/reference-parser.js +6 -2
  117. package/cli/dist/domain/release.d.ts +7 -3
  118. package/cli/dist/domain/release.js +5 -12
  119. package/cli/dist/domain/repository-policy.d.ts +9 -3
  120. package/cli/dist/domain/repository-policy.js +8 -7
  121. package/cli/dist/domain/repository-resolver.js +4 -1
  122. package/cli/dist/domain/security-alerts.js +1 -1
  123. package/cli/dist/domain/state.d.ts +30 -0
  124. package/cli/dist/domain/state.js +39 -0
  125. package/cli/dist/domain/work-start.d.ts +34 -0
  126. package/cli/dist/domain/work-start.js +49 -0
  127. package/cli/dist/infra/authored-notes.d.ts +1 -1
  128. package/cli/dist/infra/authored-notes.js +10 -4
  129. package/cli/dist/infra/config-store.d.ts +4 -0
  130. package/cli/dist/infra/config-store.js +13 -0
  131. package/cli/dist/infra/git.d.ts +12 -0
  132. package/cli/dist/infra/git.js +13 -1
  133. package/cli/dist/infra/github/client.d.ts +5 -0
  134. package/cli/dist/infra/github/client.js +10 -7
  135. package/cli/dist/infra/github/errors.d.ts +18 -0
  136. package/cli/dist/infra/github/errors.js +22 -0
  137. package/cli/dist/infra/github/issues.d.ts +39 -3
  138. package/cli/dist/infra/github/issues.js +178 -23
  139. package/cli/dist/infra/github/projects.d.ts +35 -0
  140. package/cli/dist/infra/github/projects.js +89 -8
  141. package/cli/dist/infra/github/pulls.d.ts +24 -0
  142. package/cli/dist/infra/github/pulls.js +56 -0
  143. package/cli/dist/infra/github/queries.d.ts +12 -4
  144. package/cli/dist/infra/github/queries.js +156 -8
  145. package/cli/dist/infra/github/readout.d.ts +5 -1
  146. package/cli/dist/infra/github/readout.js +11 -0
  147. package/cli/dist/infra/github/repos.d.ts +18 -0
  148. package/cli/dist/infra/github/repos.js +31 -0
  149. package/cli/dist/infra/nx-scope.d.ts +1 -1
  150. package/cli/dist/infra/nx-scope.js +1 -1
  151. package/cli/dist/infra/state-store.d.ts +10 -1
  152. package/cli/dist/infra/state-store.js +14 -2
  153. package/cli/dist/infra/worktree-links.d.ts +3 -0
  154. package/cli/dist/infra/worktree-links.js +8 -1
  155. package/cli/dist/infra/worktree.d.ts +12 -1
  156. package/cli/dist/infra/worktree.js +40 -23
  157. package/cli/dist/mcp/result.d.ts +34 -6
  158. package/cli/dist/mcp/result.js +62 -18
  159. package/cli/dist/mcp/server.d.ts +2 -2
  160. package/cli/dist/mcp/server.js +24 -10
  161. package/cli/templates/comment/plan.md +14 -0
  162. package/cli/templates/issue/bug.md +1 -1
  163. package/cli/templates/issue/task-implement.md +13 -6
  164. package/cli/templates/issue/task.md +1 -1
  165. package/cli/templates/workflow/pecot-board-sync.yml +84 -0
  166. package/npm-shrinkwrap.json +2 -2
  167. package/package.json +1 -1
  168. package/cli/dist/commands/dependabot.d.ts +0 -3
  169. package/cli/dist/commands/issue-project.d.ts +0 -3
  170. package/cli/dist/commands/issue-project.js +0 -176
  171. package/cli/dist/commands/issue-quick.d.ts +0 -3
  172. package/cli/dist/commands/issue-quick.js +0 -126
  173. package/cli/dist/commands/issue-read.d.ts +0 -3
  174. package/cli/dist/commands/issue-read.js +0 -80
  175. package/cli/dist/commands/repository.d.ts +0 -5
  176. package/cli/dist/commands/security.d.ts +0 -3
@@ -23,6 +23,10 @@ export declare function saveConfig(config: ProjectConfig, file: string): void;
23
23
  export declare function getActiveConfigPath(): string | undefined;
24
24
  export declare function loadActiveConfig(): ProjectConfig | undefined;
25
25
  /**
26
+ projects/ にある設定の名前(拡張子 .json を除く。名前順)。ディレクトリが無ければ空
27
+ */
28
+ export declare function listProjectConfigNames(): readonly string[];
29
+ /**
26
30
  アクティブ設定を設定する。.active には .active のあるディレクトリ基準の相対パスを書く。ファイルが無ければ ConfigError
27
31
  */
28
32
  export declare function setActiveConfig(file: string): void;
@@ -67,6 +67,19 @@ export function loadActiveConfig() {
67
67
  return configPath === undefined ? undefined : loadConfig(configPath);
68
68
  }
69
69
  /**
70
+ projects/ にある設定の名前(拡張子 .json を除く。名前順)。ディレクトリが無ければ空
71
+ */
72
+ export function listProjectConfigNames() {
73
+ try {
74
+ return readdirSync(projectsDirectory()).filter(name => name.endsWith('.json')).map(name => name.slice(0, -'.json'.length)).toSorted(compareStrings);
75
+ }
76
+ catch (error) {
77
+ if (isFileNotFound(error))
78
+ return [];
79
+ throw error;
80
+ }
81
+ }
82
+ /**
70
83
  アクティブ設定を設定する。.active には .active のあるディレクトリ基準の相対パスを書く。ファイルが無ければ ConfigError
71
84
  */
72
85
  export function setActiveConfig(file) {
@@ -15,8 +15,20 @@ export interface GitOptions {
15
15
  true なら非 0 終了で GitCommandError を投げる
16
16
  */
17
17
  readonly check?: boolean | undefined;
18
+ /**
19
+ 足す環境変数。今の環境変数(stripGitEnvironment なら GIT_* を除いたもの)に重ねる
20
+ */
21
+ readonly env?: Readonly<Record<string, string>> | undefined;
22
+ /**
23
+ 時間切れ。過ぎたら止めて、exitCode が GIT_TIMED_OUT の結果を返す
24
+ */
25
+ readonly timeoutMilliseconds?: number | undefined;
18
26
  }
19
27
  /**
28
+ 時間切れで止めたときの exitCode
29
+ */
30
+ export declare const GIT_TIMED_OUT = -2;
31
+ /**
20
32
  check 付きの実行が非 0 で終わった(Python の CalledProcessError に当たる)
21
33
  */
22
34
  export declare class GitCommandError extends BaseError {
@@ -7,6 +7,13 @@ import { normalizeNewlines, pythonRepr, pythonStrip } from '../domain/python-for
7
7
  import { childStdin } from './child-stdin.js';
8
8
  import { isFileNotFound, toOsError } from './os-error.js';
9
9
  /**
10
+ 時間切れで止めたときの exitCode
11
+ */
12
+ export const GIT_TIMED_OUT = -2;
13
+ function isTimedOut(error) {
14
+ return error !== undefined && 'code' in error && error.code === 'ETIMEDOUT';
15
+ }
16
+ /**
10
17
  check 付きの実行が非 0 で終わった(Python の CalledProcessError に当たる)
11
18
  */
12
19
  export class GitCommandError extends BaseError {
@@ -31,13 +38,18 @@ git を実行する。標準出力・標準エラーは改行を \n に揃えた
31
38
  git や作業ディレクトリが見つからなければ OsError(code ENOENT)を投げる
32
39
  */
33
40
  export function runGit(arguments_, options = {}) {
41
+ // interface-env: none
42
+ const base = options.stripGitEnvironment === true ? withoutGitVariables() : (options.env === undefined ? undefined : process.env);
34
43
  const result = spawnSync('git', [...arguments_], {
35
44
  cwd: options.cwd,
36
- env: options.stripGitEnvironment === true ? withoutGitVariables() : undefined,
45
+ env: base === undefined ? undefined : { ...base, ...options.env },
37
46
  encoding: 'utf8',
38
47
  maxBuffer: MAX_OUTPUT_BYTES,
39
48
  stdio: [childStdin(), 'pipe', 'pipe'],
49
+ ...(options.timeoutMilliseconds !== undefined && { timeout: options.timeoutMilliseconds, killSignal: 'SIGKILL' }),
40
50
  });
51
+ if (isTimedOut(result.error))
52
+ return { exitCode: GIT_TIMED_OUT, stdout: normalizeNewlines(result.stdout), stderr: normalizeNewlines(result.stderr) };
41
53
  if (result.error !== undefined) {
42
54
  // spawnSync の ENOENT は path が `git` で入る。cwd が無いときも同じ ENOENT になる
43
55
  throw toOsError(result.error);
@@ -20,7 +20,12 @@ export interface RestRequestOptions {
20
20
  JSON の本文
21
21
  */
22
22
  readonly json?: JsonValue | undefined;
23
+ /**
24
+ X-GitHub-Api-Version の値。省略すると DEFAULT_API_VERSION
25
+ */
26
+ readonly apiVersion?: string | undefined;
23
27
  }
28
+ export declare const DEFAULT_API_VERSION = "2022-11-28";
24
29
  /**
25
30
  送信の失敗(接続できない・時間切れ)。Python の httpx の例外に当たり、PecotError ではない
26
31
  */
@@ -81,6 +81,7 @@ export function resolveApiUrlOverride() {
81
81
  }
82
82
  return trimTrailingSlashes(raw);
83
83
  }
84
+ export const DEFAULT_API_VERSION = '2022-11-28';
84
85
  /**
85
86
  送信の失敗(接続できない・時間切れ)。Python の httpx の例外に当たり、PecotError ではない
86
87
  */
@@ -365,11 +366,11 @@ or authenticate with the GitHub CLI:
365
366
  gh auth login -h ${host}`;
366
367
  }
367
368
  // github.com は Bearer、GHE Server は token(gh CLI 互換)
368
- requestHeaders() {
369
+ requestHeaders(apiVersion = DEFAULT_API_VERSION) {
369
370
  return {
370
371
  'Authorization': `${this.host === 'github.com' ? 'Bearer' : 'token'} ${this.token}`,
371
372
  'Accept': 'application/vnd.github+json',
372
- 'X-GitHub-Api-Version': '2022-11-28',
373
+ 'X-GitHub-Api-Version': apiVersion,
373
374
  };
374
375
  }
375
376
  /**
@@ -416,8 +417,10 @@ or authenticate with the GitHub CLI:
416
417
  throw new TransportFailure(describeTransportFailure(error), { cause: error });
417
418
  }
418
419
  }
419
- async sendRest(method, url, json) {
420
- const headers = json === undefined ? this.requestHeaders() : { ...this.requestHeaders(), 'Content-Type': 'application/json' };
420
+ async sendRest(method, url, options) {
421
+ const { json } = options;
422
+ const base = this.requestHeaders(options.apiVersion);
423
+ const headers = json === undefined ? base : { ...base, 'Content-Type': 'application/json' };
421
424
  return this.send(method, url, headers, json === undefined ? undefined : JSON.stringify(json));
422
425
  }
423
426
  // gql の HTTPXTransport.execute と同じ 4 つの失敗の文を作る。成功したら data と、許した errors
@@ -469,7 +472,7 @@ or authenticate with the GitHub CLI:
469
472
  }
470
473
  classifyGraphqlFailure(failure) {
471
474
  const { message } = failure;
472
- const detail = { cause: failure };
475
+ const detail = { cause: failure, errorType: failure.errorType };
473
476
  if (isUnauthorized(failure))
474
477
  return new GitHubAuthError(`GraphQL authentication error: ${message}`, detail);
475
478
  if (isRateLimited({ statusCode: failure.statusCode, errorType: failure.errorType, text: message })) {
@@ -512,8 +515,8 @@ or authenticate with the GitHub CLI:
512
515
  async restRequest(method, target, options = {}) {
513
516
  this.assertSameOrigin(target);
514
517
  const url = buildUrl(this.apiUrl, target, options.params);
515
- const response = await this.sendRest(method, url, options.json);
516
- return response.statusCode === 401 && this.retryWithFallbackToken() ? this.sendRest(method, url, options.json) : response;
518
+ const response = await this.sendRest(method, url, options);
519
+ return response.statusCode === 401 && this.retryWithFallbackToken() ? this.sendRest(method, url, options) : response;
517
520
  }
518
521
  /**
519
522
  REST の要求を送り、成功した応答の JSON を返す。失敗の応答は handleHttpError の例外にする。
@@ -9,6 +9,10 @@ export interface GitHubErrorDetail {
9
9
  */
10
10
  readonly responseBody?: string | undefined;
11
11
  /**
12
+ GraphQL の errors[0] の type(NOT_FOUND など。該当する場合)
13
+ */
14
+ readonly errorType?: string | undefined;
15
+ /**
12
16
  元の例外
13
17
  */
14
18
  readonly cause?: unknown;
@@ -19,6 +23,7 @@ GitHub API 操作エラーの基底
19
23
  export declare class GitHubAPIError extends PecotError {
20
24
  readonly statusCode: number | undefined;
21
25
  readonly responseBody: string | undefined;
26
+ readonly errorType: string | undefined;
22
27
  constructor(message: string, detail?: Readonly<GitHubErrorDetail>);
23
28
  }
24
29
  /**
@@ -37,6 +42,15 @@ export declare class GitHubNotFoundError extends GitHubAPIError {
37
42
  export declare class GitHubRateLimitError extends GitHubAPIError {
38
43
  }
39
44
  /**
45
+ Issue の依存関係(blockedBy など)に対応しない GHES(3.19 より前)のエラー。スキーマの失敗を、ほかの GitHubAPIError と見分けるために使う
46
+ */
47
+ export declare class DependenciesUnsupportedError extends GitHubAPIError {
48
+ }
49
+ /**
50
+ GraphQL の errors の NOT_FOUND を GitHubNotFoundError にする。文は変えない。GitHub は無い Issue を data の null でなくこの形で返すことがある
51
+ */
52
+ export declare function asNotFoundError(error: unknown): unknown;
53
+ /**
40
54
  このエラーが、ブランチ(ref)がもう無いことを表すか。`Reference does not exist` を含む 404・422 だけを「無い」と見なす
41
55
  */
42
56
  export declare function isMissingReferenceError(error: Readonly<GitHubAPIError>): boolean;
@@ -44,4 +58,8 @@ export declare function isMissingReferenceError(error: Readonly<GitHubAPIError>)
44
58
  別の要求が同時に閉じたことを示す 422 か(PR の Closes による自動 close など)
45
59
  */
46
60
  export declare function isClosedByAnotherRequest(error: Readonly<GitHubAPIError>): boolean;
61
+ /**
62
+ 古い GHES が、対応しないフィールドに返すスキーマの失敗か
63
+ */
64
+ export declare function isSchemaError(error: unknown): error is GitHubAPIError;
47
65
  //# sourceMappingURL=errors.d.ts.map
@@ -6,10 +6,12 @@ GitHub API 操作エラーの基底
6
6
  export class GitHubAPIError extends PecotError {
7
7
  statusCode;
8
8
  responseBody;
9
+ errorType;
9
10
  constructor(message, detail = {}) {
10
11
  super(message, detail.cause === undefined ? undefined : { cause: detail.cause });
11
12
  this.statusCode = detail.statusCode;
12
13
  this.responseBody = detail.responseBody;
14
+ this.errorType = detail.errorType;
13
15
  }
14
16
  }
15
17
  /**
@@ -28,6 +30,19 @@ export class GitHubNotFoundError extends GitHubAPIError {
28
30
  export class GitHubRateLimitError extends GitHubAPIError {
29
31
  }
30
32
  /**
33
+ Issue の依存関係(blockedBy など)に対応しない GHES(3.19 より前)のエラー。スキーマの失敗を、ほかの GitHubAPIError と見分けるために使う
34
+ */
35
+ export class DependenciesUnsupportedError extends GitHubAPIError {
36
+ }
37
+ /**
38
+ GraphQL の errors の NOT_FOUND を GitHubNotFoundError にする。文は変えない。GitHub は無い Issue を data の null でなくこの形で返すことがある
39
+ */
40
+ export function asNotFoundError(error) {
41
+ return error instanceof GitHubAPIError && !(error instanceof GitHubNotFoundError) && error.errorType === 'NOT_FOUND'
42
+ ? new GitHubNotFoundError(error.message, { cause: error, errorType: error.errorType })
43
+ : error;
44
+ }
45
+ /**
31
46
  このエラーが、ブランチ(ref)がもう無いことを表すか。`Reference does not exist` を含む 404・422 だけを「無い」と見なす
32
47
  */
33
48
  export function isMissingReferenceError(error) {
@@ -39,4 +54,11 @@ export function isMissingReferenceError(error) {
39
54
  export function isClosedByAnotherRequest(error) {
40
55
  return error.statusCode === 422 && error.responseBody?.includes('closed by another request') === true;
41
56
  }
57
+ const SCHEMA_ERROR_PHRASES = ['Cannot query field', 'doesn\'t exist', 'Unknown field'];
58
+ /**
59
+ 古い GHES が、対応しないフィールドに返すスキーマの失敗か
60
+ */
61
+ export function isSchemaError(error) {
62
+ return error instanceof GitHubAPIError && SCHEMA_ERROR_PHRASES.some(phrase => error.message.includes(phrase));
63
+ }
42
64
  //# sourceMappingURL=errors.js.map
@@ -1,5 +1,5 @@
1
1
  import type { JsonObject } from '../../domain/json.js';
2
- import type { IssuePrerequisitesReadout, PrerequisiteFieldNames } from '../../domain/issue-readout.js';
2
+ import type { BlockedByReferences, IssueBlockedByReferences, IssuePrerequisitesReadout, PrerequisiteFieldNames } from '../../domain/issue-readout.js';
3
3
  import type { JsonValue } from '../../domain/python-format.js';
4
4
  import { ProjectsApi } from './projects.js';
5
5
  export interface IssueNodeIdAndTitle {
@@ -57,10 +57,20 @@ export interface IssueSlim {
57
57
  readonly sub_issues: readonly IssueSubIssue[];
58
58
  readonly linked_branches: readonly string[];
59
59
  readonly linked_prs: readonly LinkedPullRequest[];
60
+ /**
61
+ 前提(blocked by)の件数(closed も数える)。Issue の依存関係に対応しない GHES では undefined
62
+ */
63
+ readonly blockedByCount: number | undefined;
60
64
  }
65
+ /**
66
+ 前提を 1 回で読む件数の上限
67
+ */
68
+ export declare const MAX_BLOCKED_BY = 50;
69
+ export declare const DEPENDENCIES_UNSUPPORTED = "this GitHub Enterprise Server does not support issue dependencies (blockedBy); version 3.19 or later is required";
61
70
  export declare class IssuesApi extends ProjectsApi {
62
71
  private executeDependencyMutation;
63
72
  private getIssueKindPhase1;
73
+ private fetchSlimIssue;
64
74
  /**
65
75
  Issue を作る。labels が空なら送らない
66
76
  */
@@ -92,20 +102,46 @@ export declare class IssuesApi extends ProjectsApi {
92
102
  */
93
103
  addBlockedBy(issueId: string, blockingIssueId: string): Promise<void>;
94
104
  /**
105
+ Issue の依存関係(blocked by)に対応するか。対応しない GHES(3.19 より前)は false
106
+ */
107
+ supportsBlockedBy(): Promise<boolean>;
108
+ /**
95
109
  前提(blocked by)を外す。addBlockedBy と同じ失敗をする
96
110
  */
97
111
  removeBlockedBy(issueId: string, blockingIssueId: string): Promise<void>;
98
112
  /**
99
- Issue と、その前提(blockedBy 先頭 50 件)を 1 回のクエリで読む。ボードの値は projectId のものだけ。
113
+ Issue と、その前提(blockedBy 先頭 blockedByFirst 件)を 1 回のクエリで読む。ボードの値は projectId のものだけ。
100
114
  blockedBy の部分エラーと、件数の上限による取りこぼしは、例外にせず blockedBy の read-failed で返す(呼ぶ側は判定の入力にする)。
101
115
  Issue の依存関係に対応しない GHES(3.19 より前)、blockedBy 以外の失敗は GitHubAPIError
102
116
  */
103
- getIssuePrerequisites(owner: string, repository: string, number: number, projectId: string, fieldNames: Readonly<PrerequisiteFieldNames>): Promise<IssuePrerequisitesReadout>;
117
+ getIssuePrerequisites(owner: string, repository: string, number: number, projectId: string, fieldNames: Readonly<PrerequisiteFieldNames>, blockedByFirst?: number): Promise<IssuePrerequisitesReadout>;
118
+ /**
119
+ Issue の node ID・本文・前提(先頭 blockedByFirst 件の参照と全体の件数)を、判定の読み取りより軽く読む。
120
+ blockedBy の部分エラーと null の node は、例外にせず read-failed で返す。
121
+ Issue の依存関係に対応しない GHES(3.19 より前)は DependenciesUnsupportedError
122
+ */
123
+ getIssueBlockedByReferences(owner: string, repository: string, number: number, blockedByFirst?: number): Promise<IssueBlockedByReferences>;
124
+ /**
125
+ その Issue を前提にしている Issue(blocking 先頭 blockingFirst 件)の参照と、全体の件数を読む。
126
+ total が issues の数より多ければ、読めなかった分がある。blocking の部分エラーと null の node は read-failed。
127
+ Issue の依存関係に対応しない GHES は DependenciesUnsupportedError
128
+ */
129
+ getIssueBlockingReferences(owner: string, repository: string, number: number, blockingFirst?: number): Promise<BlockedByReferences>;
130
+ /**
131
+ node ID の並びのそれぞれの前提を、まとめて読む(輪の探索の 1 段)。結果の鍵は node ID。
132
+ Issue でない・見つからない node と部分エラーは、その node だけ read-failed。
133
+ Issue の依存関係に対応しない GHES は DependenciesUnsupportedError
134
+ */
135
+ getBlockedByOfNodes(ids: readonly string[]): Promise<ReadonlyMap<string, BlockedByReferences>>;
104
136
  /**
105
137
  Issue 種別を軽く取る。issueType フィールドに対応しない GHES では、subIssues だけで判定する
106
138
  */
107
139
  getIssueKind(owner: string, repository: string, number: number): Promise<IssueKindResult>;
108
140
  /**
141
+ 親のサブ Issue を全件読む。1 ページ目は getIssueSlim と同じクエリで読み、続きがあるときだけ GetSubIssuesPage を回す
142
+ */
143
+ getAllSubIssues(owner: string, repository: string, number: number): Promise<readonly IssueSubIssue[]>;
144
+ /**
109
145
  Issue の詳細を取る(GraphQL)。親・サブ Issue・リンクブランチ・リンク PR を 1 回のクエリで取る
110
146
  */
111
147
  getIssueSlim(owner: string, repository: string, number: number, commentLimit?: number): Promise<IssueSlim>;
@@ -2,29 +2,69 @@
2
2
  // 返す値のキー名は、Python の辞書と同じ snake_case にする(CLI の JSON 出力がそのまま使う)。
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';
6
- import { asObject, isTruthy, numberOrNull, requireNumber, requireString, requireValue, stringOrNull, subIssuesTotal, truthyNodes } from './payload.js';
7
- import { MUTATION_ADD_BLOCKED_BY, MUTATION_ADD_SUB_ISSUE, MUTATION_REMOVE_BLOCKED_BY, QUERY_GET_ISSUE_KIND, QUERY_GET_ISSUE_KIND_PHASE1, QUERY_GET_ISSUE_NODE_ID, QUERY_GET_ISSUE_PREREQUISITES, QUERY_GET_ISSUE_SLIM, } from './queries.js';
8
- import { readBlockedBy, readIssue } from './readout.js';
5
+ import { DependenciesUnsupportedError, GitHubAPIError, GitHubNotFoundError, isSchemaError } from './errors.js';
6
+ import { asArray, asObject, isTruthy, numberOrNull, requireNumber, requireString, requireValue, stringOrNull, subIssuesTotal, truthyNodes } from './payload.js';
7
+ import { MUTATION_ADD_BLOCKED_BY, MUTATION_ADD_SUB_ISSUE, MUTATION_REMOVE_BLOCKED_BY, QUERY_GET_BLOCKED_BY_OF_NODES, QUERY_GET_ISSUE_BLOCKED_BY_REFERENCES, QUERY_GET_ISSUE_BLOCKING_REFERENCES, QUERY_GET_ISSUE_KIND, QUERY_HAS_ADD_BLOCKED_BY_INPUT, QUERY_GET_ISSUE_KIND_PHASE1, QUERY_GET_ISSUE_NODE_ID, QUERY_GET_ISSUE_PREREQUISITES, QUERY_GET_ISSUE_SLIM, QUERY_GET_ISSUE_SLIM_WITHOUT_BLOCKED_BY, QUERY_GET_SUB_ISSUES_PAGE, } from './queries.js';
8
+ import { readBlockedBy, readIssue, readIssueReference } from './readout.js';
9
9
  import { ProjectsApi } from './projects.js';
10
10
  import { repositoryPath } from './rest-path.js';
11
11
  const ISSUES_PER_PAGE = 100;
12
12
  const DEFAULT_COMMENT_LIMIT = 5;
13
- const SCHEMA_ERROR_PHRASES = ['Cannot query field', 'doesn\'t exist', 'Unknown field'];
13
+ /**
14
+ 前提を 1 回で読む件数の上限
15
+ */
16
+ export const MAX_BLOCKED_BY = 50;
14
17
  // issueType フィールドに対応しない GHES が返すスキーマの失敗
15
18
  function isIssueTypeSchemaError(error) {
16
- return error instanceof GitHubAPIError && error.message.includes('issueType') && SCHEMA_ERROR_PHRASES.some(phrase => error.message.includes(phrase));
19
+ return isSchemaError(error) && error.message.includes('issueType');
17
20
  }
18
- const DEPENDENCIES_UNSUPPORTED = 'this GitHub Enterprise Server does not support issue dependencies (blockedBy); version 3.19 or later is required';
19
- // blockedBy・addBlockedBy・removeBlockedBy・issueType に対応しない GHES(3.19 より前)が返すスキーマの失敗なら、分かる失敗に替える
21
+ export const DEPENDENCIES_UNSUPPORTED = 'this GitHub Enterprise Server does not support issue dependencies (blockedBy); version 3.19 or later is required';
22
+ // 依存関係のフィールド(blockedBy・blocking・addBlockedBy・removeBlockedBy)と issueType に対応しない GHES(3.19 より前)。
23
+ // そのスキーマの失敗なら、分かる失敗に替える
20
24
  function asDependenciesError(error) {
21
- const isSchemaError = error instanceof GitHubAPIError && SCHEMA_ERROR_PHRASES.some(phrase => error.message.includes(phrase));
22
- return isSchemaError && /blockedBy|issueType/iu.test(error.message) ? new GitHubAPIError(DEPENDENCIES_UNSUPPORTED, { cause: error }) : error;
25
+ return isSchemaError(error) && /blockedBy|blocking|issueType/iu.test(error.message) ? new DependenciesUnsupportedError(DEPENDENCIES_UNSUPPORTED, { cause: error }) : error;
23
26
  }
27
+ /**
28
+ nodes(ids:) の 1 回で渡せる node ID の上限
29
+ */
30
+ const MAX_NODES_PER_QUERY = 100;
24
31
  // 部分エラーのうち、対象の Issue の blockedBy の下のもの
25
32
  function isBlockedByPath(path) {
26
33
  return path[0] === 'repository' && path[1] === 'issue' && path[2] === 'blockedBy';
27
34
  }
35
+ // nodes(ids:) の部分エラーのうち、node の下のもの
36
+ function isNodesPath(path) {
37
+ return path[0] === 'nodes';
38
+ }
39
+ // 部分エラーのうち、対象の Issue の blocking の下のもの
40
+ function isBlockingPath(path) {
41
+ return path[0] === 'repository' && path[1] === 'issue' && path[2] === 'blocking';
42
+ }
43
+ // GitHub は無い Issue・リポを、data の null と、その道筋の NOT_FOUND の errors で返す。null を見て GitHubNotFoundError にする
44
+ function isIssueOrRepositoryPath(path) {
45
+ return path[0] === 'repository' && (path.length === 1 || (path[1] === 'issue' && path.length === 2));
46
+ }
47
+ // blockedBy(または blocking)の connection を参照にする。件数が足りないのは呼ぶ側が見るので、ここでは失敗にしない
48
+ function readBlockedByReferences(connection, field = 'blockedBy') {
49
+ if (!isTruthy(connection))
50
+ return { kind: 'read-failed', reason: `${field} is null` };
51
+ const nodes = asArray(jsonField(connection, 'nodes'));
52
+ if (nodes.some(node => !isTruthy(node)))
53
+ return { kind: 'read-failed', reason: `${field} has a null node` };
54
+ const issues = nodes.map(node => readIssueReference(node));
55
+ return { kind: 'ok', total: requireNumber(jsonField(connection, 'totalCount'), `${field}.totalCount`), issues };
56
+ }
57
+ // nodes(ids:) の 1 件を前提にする。message は、その node の部分エラー
58
+ function readNodeBlockedBy(node, id, message) {
59
+ if (message !== undefined)
60
+ return { kind: 'read-failed', reason: `blockedBy could not be read: ${message}` };
61
+ if (!isTruthy(node) || jsonField(node, 'id') !== id)
62
+ return { kind: 'read-failed', reason: 'the node is not an Issue or was not found' };
63
+ return readBlockedByReferences(jsonField(node, 'blockedBy'));
64
+ }
65
+ function numberOrUndefined(value) {
66
+ return typeof value === 'number' ? value : undefined;
67
+ }
28
68
  function stringOrEmpty(value) {
29
69
  return typeof value === 'string' ? value : '';
30
70
  }
@@ -38,6 +78,17 @@ function issueNode(result, owner, repository, number) {
38
78
  throw new GitHubNotFoundError(`Issue not found: ${owner}/${repository}/${String(number)}`);
39
79
  return requireValue(issue, 'issue');
40
80
  }
81
+ // 対象の Issue の親の参照。親が無い、またはリポジトリが読めない応答なら null
82
+ function readParentReference(issue) {
83
+ const parent = jsonField(issue, 'parent');
84
+ if (!isTruthy(parent))
85
+ return JSON_NULL;
86
+ const repository = jsonField(parent, 'repository');
87
+ const owner = stringOrNull(jsonField(jsonField(repository, 'owner'), 'login'));
88
+ const name = stringOrNull(jsonField(repository, 'name'));
89
+ const number = jsonField(parent, 'number');
90
+ return owner === JSON_NULL || name === JSON_NULL || typeof number !== 'number' ? JSON_NULL : { repository: { owner, repository: name }, number };
91
+ }
41
92
  function formatParent(parent) {
42
93
  if (!isTruthy(parent))
43
94
  return JSON_NULL;
@@ -74,6 +125,13 @@ function extractLinkedPullRequests(timelineItems) {
74
125
  }
75
126
  return pullRequests;
76
127
  }
128
+ function readSubIssueNodes(connection) {
129
+ return truthyNodes(connection).map(sub => ({
130
+ number: requireNumber(jsonField(sub, 'number'), 'subIssue.number'),
131
+ state: requireString(jsonField(sub, 'state'), 'subIssue.state'),
132
+ title: requireString(jsonField(sub, 'title'), 'subIssue.title'),
133
+ }));
134
+ }
77
135
  export class IssuesApi extends ProjectsApi {
78
136
  async executeDependencyMutation(mutation, variables) {
79
137
  try {
@@ -94,6 +152,20 @@ export class IssuesApi extends ProjectsApi {
94
152
  sub_issues_total: subIssuesTotal(issue),
95
153
  };
96
154
  }
155
+ // GetIssueSlim の応答の issue。前提の件数に対応しない GHES は、件数なしのクエリで読み直す
156
+ async fetchSlimIssue(owner, repository, number, commentLimit) {
157
+ const variables = { owner, repo: repository, number, commentLimit };
158
+ let result;
159
+ try {
160
+ result = await this.queryIssue(QUERY_GET_ISSUE_SLIM, variables);
161
+ }
162
+ catch (error) {
163
+ if (!isSchemaError(error) || !/blockedBy/iu.test(error.message))
164
+ throw error;
165
+ result = await this.queryIssue(QUERY_GET_ISSUE_SLIM_WITHOUT_BLOCKED_BY, variables);
166
+ }
167
+ return issueNode(result, owner, repository, number);
168
+ }
97
169
  /**
98
170
  Issue を作る。labels が空なら送らない
99
171
  */
@@ -128,7 +200,7 @@ export class IssuesApi extends ProjectsApi {
128
200
  Issue 番号から GraphQL Node ID とタイトルを、1 回のクエリで取る
129
201
  */
130
202
  async getIssueNodeIdAndTitle(owner, repository, number) {
131
- const result = await this.executeGraphql(QUERY_GET_ISSUE_NODE_ID, { owner, repo: repository, number });
203
+ const result = await this.queryIssue(QUERY_GET_ISSUE_NODE_ID, { owner, repo: repository, number });
132
204
  const issue = issueNode(result, owner, repository, number);
133
205
  return {
134
206
  id: requireString(jsonField(issue, 'id'), 'issue.id'),
@@ -159,21 +231,28 @@ export class IssuesApi extends ProjectsApi {
159
231
  await this.executeDependencyMutation(MUTATION_ADD_BLOCKED_BY, { issueId, blockingIssueId });
160
232
  }
161
233
  /**
234
+ Issue の依存関係(blocked by)に対応するか。対応しない GHES(3.19 より前)は false
235
+ */
236
+ async supportsBlockedBy() {
237
+ const result = await this.executeGraphql(QUERY_HAS_ADD_BLOCKED_BY_INPUT, {});
238
+ return jsonField(result, '__type') !== JSON_NULL;
239
+ }
240
+ /**
162
241
  前提(blocked by)を外す。addBlockedBy と同じ失敗をする
163
242
  */
164
243
  async removeBlockedBy(issueId, blockingIssueId) {
165
244
  await this.executeDependencyMutation(MUTATION_REMOVE_BLOCKED_BY, { issueId, blockingIssueId });
166
245
  }
167
246
  /**
168
- Issue と、その前提(blockedBy 先頭 50 件)を 1 回のクエリで読む。ボードの値は projectId のものだけ。
247
+ Issue と、その前提(blockedBy 先頭 blockedByFirst 件)を 1 回のクエリで読む。ボードの値は projectId のものだけ。
169
248
  blockedBy の部分エラーと、件数の上限による取りこぼしは、例外にせず blockedBy の read-failed で返す(呼ぶ側は判定の入力にする)。
170
249
  Issue の依存関係に対応しない GHES(3.19 より前)、blockedBy 以外の失敗は GitHubAPIError
171
250
  */
172
- async getIssuePrerequisites(owner, repository, number, projectId, fieldNames) {
173
- const variables = { owner, repo: repository, number, columnFieldName: fieldNames.columnFieldName, labelFieldName: fieldNames.labelFieldName };
251
+ async getIssuePrerequisites(owner, repository, number, projectId, fieldNames, blockedByFirst = MAX_BLOCKED_BY) {
252
+ const variables = { owner, repo: repository, number, columnFieldName: fieldNames.columnFieldName, labelFieldName: fieldNames.labelFieldName, blockedByFirst };
174
253
  let outcome;
175
254
  try {
176
- outcome = await this.executeGraphqlTolerating(QUERY_GET_ISSUE_PREREQUISITES, variables, isBlockedByPath);
255
+ outcome = await this.queryIssueTolerating(QUERY_GET_ISSUE_PREREQUISITES, variables, isBlockedByPath);
177
256
  }
178
257
  catch (error) {
179
258
  throw asDependenciesError(error);
@@ -182,11 +261,74 @@ export class IssuesApi extends ProjectsApi {
182
261
  const issue = issueNode(data, owner, repository, number);
183
262
  const messages = errors.map(error => stringOrEmpty(jsonField(error, 'message')));
184
263
  return {
185
- issue: { ...readIssue(issue, projectId, fieldNames), body: requireString(jsonField(issue, 'body'), 'issue.body') },
264
+ issue: { ...readIssue(issue, projectId, fieldNames), body: requireString(jsonField(issue, 'body'), 'issue.body'), parent: readParentReference(issue) },
186
265
  blockedBy: readBlockedBy(issue, projectId, fieldNames, messages),
187
266
  };
188
267
  }
189
268
  /**
269
+ Issue の node ID・本文・前提(先頭 blockedByFirst 件の参照と全体の件数)を、判定の読み取りより軽く読む。
270
+ blockedBy の部分エラーと null の node は、例外にせず read-failed で返す。
271
+ Issue の依存関係に対応しない GHES(3.19 より前)は DependenciesUnsupportedError
272
+ */
273
+ async getIssueBlockedByReferences(owner, repository, number, blockedByFirst = MAX_BLOCKED_BY) {
274
+ let outcome;
275
+ try {
276
+ outcome = await this.queryIssueTolerating(QUERY_GET_ISSUE_BLOCKED_BY_REFERENCES, { owner, repo: repository, number, blockedByFirst }, isBlockedByPath);
277
+ }
278
+ catch (error) {
279
+ throw asDependenciesError(error);
280
+ }
281
+ const issue = issueNode(outcome.data, owner, repository, number);
282
+ const messages = outcome.errors.map(error => stringOrEmpty(jsonField(error, 'message')));
283
+ return {
284
+ id: requireString(jsonField(issue, 'id'), 'issue.id'),
285
+ body: requireString(jsonField(issue, 'body'), 'issue.body'),
286
+ blockedBy: messages.length > 0 ? { kind: 'read-failed', reason: `blockedBy could not be read: ${messages.join('; ')}` } : readBlockedByReferences(jsonField(issue, 'blockedBy')),
287
+ };
288
+ }
289
+ /**
290
+ その Issue を前提にしている Issue(blocking 先頭 blockingFirst 件)の参照と、全体の件数を読む。
291
+ total が issues の数より多ければ、読めなかった分がある。blocking の部分エラーと null の node は read-failed。
292
+ Issue の依存関係に対応しない GHES は DependenciesUnsupportedError
293
+ */
294
+ async getIssueBlockingReferences(owner, repository, number, blockingFirst = MAX_BLOCKED_BY) {
295
+ let outcome;
296
+ try {
297
+ const variables = { owner, repo: repository, number, blockingFirst };
298
+ outcome = await this.executeGraphqlTolerating(QUERY_GET_ISSUE_BLOCKING_REFERENCES, variables, path => isBlockingPath(path) || isIssueOrRepositoryPath(path));
299
+ }
300
+ catch (error) {
301
+ throw asDependenciesError(error);
302
+ }
303
+ const issue = issueNode(outcome.data, owner, repository, number);
304
+ const messages = outcome.errors.filter(error => isBlockingPath(asArray(error['path']))).map(error => stringOrEmpty(jsonField(error, 'message')));
305
+ return messages.length > 0 ? { kind: 'read-failed', reason: `blocking could not be read: ${messages.join('; ')}` } : readBlockedByReferences(jsonField(issue, 'blocking'), 'blocking');
306
+ }
307
+ /**
308
+ node ID の並びのそれぞれの前提を、まとめて読む(輪の探索の 1 段)。結果の鍵は node ID。
309
+ Issue でない・見つからない node と部分エラーは、その node だけ read-failed。
310
+ Issue の依存関係に対応しない GHES は DependenciesUnsupportedError
311
+ */
312
+ async getBlockedByOfNodes(ids) {
313
+ const result = new Map();
314
+ for (let start = 0; start < ids.length; start += MAX_NODES_PER_QUERY) {
315
+ const chunk = ids.slice(start, start + MAX_NODES_PER_QUERY);
316
+ let outcome;
317
+ try {
318
+ outcome = await this.executeGraphqlTolerating(QUERY_GET_BLOCKED_BY_OF_NODES, { ids: [...chunk], blockedByFirst: MAX_BLOCKED_BY }, isNodesPath);
319
+ }
320
+ catch (error) {
321
+ throw asDependenciesError(error);
322
+ }
323
+ const nodes = asArray(jsonField(outcome.data, 'nodes'));
324
+ const failed = new Map(outcome.errors.map(error => [asArray(error['path'])[1], stringOrEmpty(jsonField(error, 'message'))]));
325
+ for (const [index, id] of chunk.entries()) {
326
+ result.set(id, readNodeBlockedBy(nodes.at(index), id, failed.get(index)));
327
+ }
328
+ }
329
+ return result;
330
+ }
331
+ /**
190
332
  Issue 種別を軽く取る。issueType フィールドに対応しない GHES では、subIssues だけで判定する
191
333
  */
192
334
  async getIssueKind(owner, repository, number) {
@@ -210,11 +352,27 @@ export class IssuesApi extends ProjectsApi {
210
352
  };
211
353
  }
212
354
  /**
355
+ 親のサブ Issue を全件読む。1 ページ目は getIssueSlim と同じクエリで読み、続きがあるときだけ GetSubIssuesPage を回す
356
+ */
357
+ async getAllSubIssues(owner, repository, number) {
358
+ const issue = await this.fetchSlimIssue(owner, repository, number, 0);
359
+ const subIssues = [];
360
+ let connection = jsonField(issue, 'subIssues');
361
+ for (;;) {
362
+ subIssues.push(...readSubIssueNodes(connection));
363
+ const pageInfo = jsonField(connection, 'pageInfo');
364
+ const cursor = jsonField(pageInfo, 'endCursor');
365
+ if (typeof cursor !== 'string' || jsonField(pageInfo, 'hasNextPage') !== true)
366
+ return subIssues;
367
+ const result = await this.queryIssue(QUERY_GET_SUB_ISSUES_PAGE, { owner, repo: repository, number, after: cursor });
368
+ connection = jsonField(issueNode(result, owner, repository, number), 'subIssues');
369
+ }
370
+ }
371
+ /**
213
372
  Issue の詳細を取る(GraphQL)。親・サブ Issue・リンクブランチ・リンク PR を 1 回のクエリで取る
214
373
  */
215
374
  async getIssueSlim(owner, repository, number, commentLimit = DEFAULT_COMMENT_LIMIT) {
216
- const result = await this.executeGraphql(QUERY_GET_ISSUE_SLIM, { owner, repo: repository, number, commentLimit });
217
- const issue = issueNode(result, owner, repository, number);
375
+ const issue = await this.fetchSlimIssue(owner, repository, number, commentLimit);
218
376
  return {
219
377
  number: requireNumber(jsonField(issue, 'number'), 'issue.number'),
220
378
  state: requireString(jsonField(issue, 'state'), 'issue.state'),
@@ -229,15 +387,12 @@ export class IssuesApi extends ProjectsApi {
229
387
  })),
230
388
  },
231
389
  parent: formatParent(jsonField(issue, 'parent')),
232
- sub_issues: truthyNodes(jsonField(issue, 'subIssues')).map(sub => ({
233
- number: requireNumber(jsonField(sub, 'number'), 'subIssue.number'),
234
- state: requireString(jsonField(sub, 'state'), 'subIssue.state'),
235
- title: requireString(jsonField(sub, 'title'), 'subIssue.title'),
236
- })),
390
+ sub_issues: readSubIssueNodes(jsonField(issue, 'subIssues')),
237
391
  linked_branches: truthyNodes(jsonField(issue, 'linkedBranches'))
238
392
  .filter(branch => isTruthy(jsonField(branch, 'ref')))
239
393
  .map(branch => requireString(jsonField(jsonField(branch, 'ref'), 'name'), 'linkedBranch.ref.name')),
240
394
  linked_prs: extractLinkedPullRequests(jsonField(issue, 'timelineItems')),
395
+ blockedByCount: numberOrUndefined(jsonField(jsonField(issue, 'blockedBy'), 'totalCount')),
241
396
  };
242
397
  }
243
398
  /**