@theholocron/github-client 1.58.0-alpha.45 → 1.58.0-alpha.47
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/dist/index.d.mts +47 -1
- package/dist/index.mjs +61 -0
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -121,6 +121,8 @@ interface GitHubCheckRun {
|
|
|
121
121
|
html_url: string;
|
|
122
122
|
/** The check's own "Details" link, when it set one. */
|
|
123
123
|
details_url?: string | null;
|
|
124
|
+
/** When the run started, an ISO time; absent while it is queued. */
|
|
125
|
+
started_at?: string | null;
|
|
124
126
|
}
|
|
125
127
|
/** The body of an `updateCheckRun()` request; every field is optional. */
|
|
126
128
|
interface UpdateCheckRunInput {
|
|
@@ -356,6 +358,10 @@ interface GitHubIssue {
|
|
|
356
358
|
name?: string | null;
|
|
357
359
|
email?: string | null;
|
|
358
360
|
} | null;
|
|
361
|
+
/** Everyone the issue is assigned to; absent where the response does not list them. */
|
|
362
|
+
assignees?: Array<{
|
|
363
|
+
login: string;
|
|
364
|
+
}>;
|
|
359
365
|
/** When the issue was last updated, as an ISO 8601 timestamp. */
|
|
360
366
|
updated_at: string;
|
|
361
367
|
/** The URL of the issue's page on GitHub. */
|
|
@@ -369,6 +375,10 @@ interface GitHubIssue {
|
|
|
369
375
|
} | null;
|
|
370
376
|
/** The issue's GraphQL node id. */
|
|
371
377
|
node_id?: string;
|
|
378
|
+
/** The issue's Type (Bug, Feature, Task), or `null` when it has none; absent where the organization has no types. */
|
|
379
|
+
type?: {
|
|
380
|
+
name: string;
|
|
381
|
+
} | null;
|
|
372
382
|
/** Set when the item is a pull request; GitHub's issues API returns pull requests too. */
|
|
373
383
|
pull_request?: unknown;
|
|
374
384
|
}
|
|
@@ -496,6 +506,8 @@ interface RepoPropertyValue {
|
|
|
496
506
|
interface GitHubPullRequest {
|
|
497
507
|
/** The pull request's number. */
|
|
498
508
|
number: number;
|
|
509
|
+
/** The pull request's GraphQL node id (what `markReadyForReview` and a board's `addProjectV2ItemById` take). */
|
|
510
|
+
node_id?: string;
|
|
499
511
|
/** The pull request's title. */
|
|
500
512
|
title: string;
|
|
501
513
|
/** The pull request's description, as written (markdown); `null` when it has none. */
|
|
@@ -548,6 +560,30 @@ interface GitHubPullRequest {
|
|
|
548
560
|
/** `dirty` means it conflicts with its base; see `mergeable`. */
|
|
549
561
|
mergeable_state?: string;
|
|
550
562
|
}
|
|
563
|
+
/** The body of {@link pulls}`.createPullRequest`. */
|
|
564
|
+
interface CreatePullRequestInput {
|
|
565
|
+
/** The title. */
|
|
566
|
+
title: string;
|
|
567
|
+
/** The branch with the changes. */
|
|
568
|
+
head: string;
|
|
569
|
+
/** The branch to merge into. */
|
|
570
|
+
base: string;
|
|
571
|
+
/** The description (markdown). */
|
|
572
|
+
body?: string;
|
|
573
|
+
/** Open it as a draft. */
|
|
574
|
+
draft?: boolean;
|
|
575
|
+
}
|
|
576
|
+
/** The fields {@link pulls}`.updatePullRequest` can change; a field left out is left alone. */
|
|
577
|
+
interface UpdatePullRequestInput {
|
|
578
|
+
/** The title. */
|
|
579
|
+
title?: string;
|
|
580
|
+
/** The description (markdown). */
|
|
581
|
+
body?: string;
|
|
582
|
+
/** The branch to merge into. */
|
|
583
|
+
base?: string;
|
|
584
|
+
/** Open or close it. */
|
|
585
|
+
state?: "open" | "closed";
|
|
586
|
+
}
|
|
551
587
|
/** A commit's name/email as git itself recorded it — `commit.author`/`commit.committer`, distinct from the GitHub-account `author` below (a commit can carry any email, linked to a GitHub account or not). */
|
|
552
588
|
interface GitHubCommitIdentity {
|
|
553
589
|
name: string;
|
|
@@ -1066,6 +1102,12 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
1066
1102
|
getIssue: (repo: string, number: number) => Promise<GitHubIssue>;
|
|
1067
1103
|
createIssue: (repo: string, body: Record<string, unknown>) => Promise<GitHubIssue>;
|
|
1068
1104
|
updateIssue: (repo: string, number: number, body: Record<string, unknown>) => Promise<GitHubIssue>;
|
|
1105
|
+
addSubIssue: (repo: string, number: number, subIssueId: number, replaceParent?: boolean) => Promise<GitHubIssue>;
|
|
1106
|
+
removeSubIssue: (repo: string, number: number, subIssueId: number) => Promise<GitHubIssue>;
|
|
1107
|
+
getParent: (repo: string, number: number) => Promise<GitHubIssue | null>;
|
|
1108
|
+
listBlockedBy: (repo: string, number: number) => Promise<GitHubIssue[]>;
|
|
1109
|
+
addBlockedBy: (repo: string, number: number, blockerId: number) => Promise<GitHubIssue>;
|
|
1110
|
+
removeBlockedBy: (repo: string, number: number, blockerId: number) => Promise<GitHubIssue>;
|
|
1069
1111
|
addLabels: (repo: string, number: number, labels: string[]) => Promise<void>;
|
|
1070
1112
|
removeLabel: (repo: string, number: number, label: string) => Promise<void>;
|
|
1071
1113
|
createComment: (repo: string, number: number, body: string) => Promise<void>;
|
|
@@ -1101,6 +1143,10 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
1101
1143
|
};
|
|
1102
1144
|
pulls: {
|
|
1103
1145
|
getPullRequest: (repo: string, number: number) => Promise<GitHubPullRequest>;
|
|
1146
|
+
createPullRequest: (repo: string, input: CreatePullRequestInput) => Promise<GitHubPullRequest>;
|
|
1147
|
+
updatePullRequest: (repo: string, number: number, input: UpdatePullRequestInput) => Promise<GitHubPullRequest>;
|
|
1148
|
+
listOpenByHead: (repo: string, branch: string) => Promise<GitHubPullRequest[]>;
|
|
1149
|
+
markReadyForReview: (nodeId: string) => Promise<void>;
|
|
1104
1150
|
listPullRequests: (repo: string, state: "open" | "closed") => Promise<GitHubPullRequest[]>;
|
|
1105
1151
|
listCommits: (repo: string, number: number) => Promise<GitHubPullRequestCommit[]>;
|
|
1106
1152
|
listFiles: (repo: string, number: number) => Promise<GitHubPullRequestFile[]>;
|
|
@@ -1168,4 +1214,4 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
1168
1214
|
};
|
|
1169
1215
|
/** The client returned by `createGitHubClient()`: one group of methods per GitHub API area. */
|
|
1170
1216
|
export type GitHubClient = ReturnType<typeof createGitHubClient>;
|
|
1171
|
-
export type { CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunOutput, CheckRunStatus, CodeScanningSetupResult, CreateCheckRunInput, CreatePagesPayload, CreatePullInput, CreateReviewComment, CreateReviewInput, GitBlob, GitCommit, GitContents, GitDirectoryEntry, GitHubApp, GitHubAppAccount, GitHubAppCredentials, GitHubAppInstallation, GitHubCheckRun, GitHubClientOptions, GitHubContents, GitHubEnvironment, GitHubInstallationWebhookPayload, GitHubIssue, GitHubIssueComment, GitHubIssueField, GitHubIssueFieldOption, GitHubIssueFieldValue, GitHubLabel, GitHubMilestone, GitHubPages, GitHubPublicKey, GitHubPullRequest, GitHubPullRequestCommit, GitHubPullRequestFile, GitHubPullRequestReview, GitHubPullRequestWebhookPayload, GitHubPushWebhookPayload, GitHubRepo, GitHubRuleset, GitHubRulesetDetail, GitHubUser, GitHubUserWithExpiry, GitHubVariable, GitHubWebhookHeaders, GitHubWorkflowRun, GitPull, GitRef, GitTree, GitTreeItem, GraphQLClient, InstallationAccessToken, IssueFieldValueInput, IssueSearchParams, ListDirectoryOptions, OrgProperty, OrgSecretInfo, OrgSecretVisibility, PagesBuildStatus, PagesBuildType, PutContentsInput, PutContentsResult, RepoPropertyValue, RepoTeam, ReviewThread, SecretScope, TeamMember, TeamPermission, UpdateCheckRunInput, UpdatePagesPayload, VariableScope, VariableVisibility, WorkflowRunFilter };
|
|
1217
|
+
export type { CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunOutput, CheckRunStatus, CodeScanningSetupResult, CreateCheckRunInput, CreatePagesPayload, CreatePullInput, CreatePullRequestInput, CreateReviewComment, CreateReviewInput, GitBlob, GitCommit, GitContents, GitDirectoryEntry, GitHubApp, GitHubAppAccount, GitHubAppCredentials, GitHubAppInstallation, GitHubCheckRun, GitHubClientOptions, GitHubContents, GitHubEnvironment, GitHubInstallationWebhookPayload, GitHubIssue, GitHubIssueComment, GitHubIssueField, GitHubIssueFieldOption, GitHubIssueFieldValue, GitHubLabel, GitHubMilestone, GitHubPages, GitHubPublicKey, GitHubPullRequest, GitHubPullRequestCommit, GitHubPullRequestFile, GitHubPullRequestReview, GitHubPullRequestWebhookPayload, GitHubPushWebhookPayload, GitHubRepo, GitHubRuleset, GitHubRulesetDetail, GitHubUser, GitHubUserWithExpiry, GitHubVariable, GitHubWebhookHeaders, GitHubWorkflowRun, GitPull, GitRef, GitTree, GitTreeItem, GraphQLClient, InstallationAccessToken, IssueFieldValueInput, IssueSearchParams, ListDirectoryOptions, OrgProperty, OrgSecretInfo, OrgSecretVisibility, PagesBuildStatus, PagesBuildType, PutContentsInput, PutContentsResult, RepoPropertyValue, RepoTeam, ReviewThread, SecretScope, TeamMember, TeamPermission, UpdateCheckRunInput, UpdatePagesPayload, UpdatePullRequestInput, VariableScope, VariableVisibility, WorkflowRunFilter };
|
package/dist/index.mjs
CHANGED
|
@@ -322,6 +322,37 @@ function issues(rest) {
|
|
|
322
322
|
method: "PATCH",
|
|
323
323
|
body
|
|
324
324
|
}),
|
|
325
|
+
/** Makes `subIssueId` (an issue's numeric `id`, not its number) a sub-issue of the issue `number`; `replaceParent` moves it from another parent. */
|
|
326
|
+
addSubIssue: (repo, number, subIssueId, replaceParent = false) => rest.request(`${repoBase(repo)}/issues/${number}/sub_issues`, {
|
|
327
|
+
method: "POST",
|
|
328
|
+
body: {
|
|
329
|
+
sub_issue_id: subIssueId,
|
|
330
|
+
...replaceParent ? { replace_parent: true } : {}
|
|
331
|
+
}
|
|
332
|
+
}),
|
|
333
|
+
/** Takes `subIssueId` (an issue's numeric `id`) off the issue `number`, its parent. */
|
|
334
|
+
removeSubIssue: (repo, number, subIssueId) => rest.request(`${repoBase(repo)}/issues/${number}/sub_issue`, {
|
|
335
|
+
method: "DELETE",
|
|
336
|
+
body: { sub_issue_id: subIssueId }
|
|
337
|
+
}),
|
|
338
|
+
/** The parent of the issue `number`, or `null` when it has none (GitHub answers 404). */
|
|
339
|
+
getParent: async (repo, number) => {
|
|
340
|
+
try {
|
|
341
|
+
return await rest.request(`${repoBase(repo)}/issues/${number}/parent`);
|
|
342
|
+
} catch (err) {
|
|
343
|
+
if (err.status === 404) return null;
|
|
344
|
+
throw err;
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
/** The issues that block the issue `number`. */
|
|
348
|
+
listBlockedBy: (repo, number) => rest.request(`${repoBase(repo)}/issues/${number}/dependencies/blocked_by?per_page=100`),
|
|
349
|
+
/** Records that `blockerId` (an issue's numeric `id`) blocks the issue `number`. */
|
|
350
|
+
addBlockedBy: (repo, number, blockerId) => rest.request(`${repoBase(repo)}/issues/${number}/dependencies/blocked_by`, {
|
|
351
|
+
method: "POST",
|
|
352
|
+
body: { issue_id: blockerId }
|
|
353
|
+
}),
|
|
354
|
+
/** Removes the record that `blockerId` (an issue's numeric `id`) blocks the issue `number`. */
|
|
355
|
+
removeBlockedBy: (repo, number, blockerId) => rest.request(`${repoBase(repo)}/issues/${number}/dependencies/blocked_by/${blockerId}`, { method: "DELETE" }),
|
|
325
356
|
addLabels: (repo, number, labels) => rest.request(`${repoBase(repo)}/issues/${number}/labels`, {
|
|
326
357
|
method: "POST",
|
|
327
358
|
body: { labels }
|
|
@@ -471,6 +502,13 @@ const LIST_REVIEW_THREADS_QUERY = `
|
|
|
471
502
|
}
|
|
472
503
|
}
|
|
473
504
|
`;
|
|
505
|
+
const MARK_READY_MUTATION = `
|
|
506
|
+
mutation($pullRequestId: ID!) {
|
|
507
|
+
markPullRequestReadyForReview(input: { pullRequestId: $pullRequestId }) {
|
|
508
|
+
pullRequest { id isDraft }
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
`;
|
|
474
512
|
const RESOLVE_REVIEW_THREAD_MUTATION = `
|
|
475
513
|
mutation($threadId: ID!) {
|
|
476
514
|
resolveReviewThread(input: { threadId: $threadId }) {
|
|
@@ -488,6 +526,29 @@ function pulls(rest, graphql) {
|
|
|
488
526
|
return {
|
|
489
527
|
getPullRequest: (repo, number) => rest.request(`${repoBase(repo)}/pulls/${number}`),
|
|
490
528
|
/**
|
|
529
|
+
* Opens a pull request (`POST /pulls`). GitHub answers 422 when the head has no commit beyond the base or a pull
|
|
530
|
+
* request for the same head and base is already open.
|
|
531
|
+
*/
|
|
532
|
+
createPullRequest: (repo, input) => rest.request(`${repoBase(repo)}/pulls`, {
|
|
533
|
+
method: "POST",
|
|
534
|
+
body: { ...input }
|
|
535
|
+
}),
|
|
536
|
+
/** Changes a pull request's own fields (`PATCH /pulls/{number}`). Labels, assignees and the milestone are the issues API's. */
|
|
537
|
+
updatePullRequest: (repo, number, input) => rest.request(`${repoBase(repo)}/pulls/${number}`, {
|
|
538
|
+
method: "PATCH",
|
|
539
|
+
body: { ...input }
|
|
540
|
+
}),
|
|
541
|
+
/** The open pull requests whose head is `branch` of the repository itself (`GET /pulls?head=owner:branch`). */
|
|
542
|
+
listOpenByHead: (repo, branch) => {
|
|
543
|
+
const [owner] = splitRepo(repo);
|
|
544
|
+
return rest.request(`${repoBase(repo)}/pulls?state=open&head=${encodeURIComponent(`${owner}:${branch}`)}&per_page=100`);
|
|
545
|
+
},
|
|
546
|
+
/**
|
|
547
|
+
* Takes a draft pull request out of draft (GraphQL `markPullRequestReadyForReview`; REST has no call). Takes the
|
|
548
|
+
* node id, which a pull request read carries as `node_id`.
|
|
549
|
+
*/
|
|
550
|
+
markReadyForReview: (nodeId) => graphql.query(MARK_READY_MUTATION, { pullRequestId: nodeId }),
|
|
551
|
+
/**
|
|
491
552
|
* Every pull request in one state, newest first, read a page at a time until a page comes back short.
|
|
492
553
|
* `closed` includes the merged ones; tell them apart by `merged_at`.
|
|
493
554
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/github-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.47",
|
|
4
4
|
"description": "A TypeScript client for the GitHub REST API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/
|
|
36
|
-
"@theholocron/
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.47",
|
|
36
|
+
"@theholocron/observability": "^0.7.0-alpha.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vitest": "^5.1.0",
|
|
48
48
|
"@theholocron/eslint-config": "^8.9.0-alpha.21",
|
|
49
|
-
"@theholocron/vitest-config": "^8.9.0-alpha.21",
|
|
50
49
|
"@theholocron/tsconfig": "^8.9.0-alpha.21",
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.21",
|
|
51
51
|
"@theholocron/tsdown-config": "^8.9.0-alpha.21"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|