@theholocron/holocron-plugin-github 5.0.0-alpha.394 → 5.0.0-alpha.395
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 +11 -1
- package/dist/index.mjs +41 -1
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -86,8 +86,18 @@ export declare class GitHubIssues implements Issues {
|
|
|
86
86
|
private readonly labels;
|
|
87
87
|
constructor(client: GitHubClient, opts: IssuesOptions);
|
|
88
88
|
getMyself(): Promise<TrackerUser>;
|
|
89
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Searches the repo's issues, newest update first, leaving out pull requests.
|
|
91
|
+
*
|
|
92
|
+
* With `filter.text`, the issues are paged (newest update first, 100 a page, at most 20 pages) and compared
|
|
93
|
+
* client-side, without regard to case, until `limit` matches are found or the issues run out. GitHub's issue
|
|
94
|
+
* search (`GET /search/issues`) is deliberately not used: it indexes the words of a body, so punctuation and an
|
|
95
|
+
* HTML comment such as `<!-- holocron:idea notes/a.md -->` cannot be relied on to match, it is limited to 30
|
|
96
|
+
* requests a minute and it is eventually consistent (an issue made a moment ago may be missing). Paging has none
|
|
97
|
+
* of those limits, at the cost of reading up to 20 pages of a very large repository.
|
|
98
|
+
*/
|
|
90
99
|
search(filter: IssueSearchFilter): Promise<Issue[]>;
|
|
100
|
+
private searchText;
|
|
91
101
|
/** Fetches one issue by its key. */
|
|
92
102
|
get(key: string): Promise<Issue>;
|
|
93
103
|
/** Creates an issue and returns its key as `#<number>`; the milestone is resolved from its title. */
|
package/dist/index.mjs
CHANGED
|
@@ -483,6 +483,10 @@ async function update(client, repo, issue, record, options) {
|
|
|
483
483
|
};
|
|
484
484
|
}
|
|
485
485
|
// src/capabilities/issues.ts
|
|
486
|
+
/** Issues read per request when `search` has a `text`; GitHub's largest page. */
|
|
487
|
+
const TEXT_PAGE_SIZE = 100;
|
|
488
|
+
/** Pages `search` reads for a `text` before it stops (the 2000 most recently updated issues). */
|
|
489
|
+
const TEXT_MAX_PAGES = 20;
|
|
486
490
|
/** The GitHub implementation of the `issues` capability, backed by GitHub Issues and status labels. */
|
|
487
491
|
var GitHubIssues = class {
|
|
488
492
|
client;
|
|
@@ -510,8 +514,18 @@ var GitHubIssues = class {
|
|
|
510
514
|
...raw.email ? { emailAddress: raw.email } : {}
|
|
511
515
|
};
|
|
512
516
|
}
|
|
513
|
-
/**
|
|
517
|
+
/**
|
|
518
|
+
* Searches the repo's issues, newest update first, leaving out pull requests.
|
|
519
|
+
*
|
|
520
|
+
* With `filter.text`, the issues are paged (newest update first, 100 a page, at most 20 pages) and compared
|
|
521
|
+
* client-side, without regard to case, until `limit` matches are found or the issues run out. GitHub's issue
|
|
522
|
+
* search (`GET /search/issues`) is deliberately not used: it indexes the words of a body, so punctuation and an
|
|
523
|
+
* HTML comment such as `<!-- holocron:idea notes/a.md -->` cannot be relied on to match, it is limited to 30
|
|
524
|
+
* requests a minute and it is eventually consistent (an issue made a moment ago may be missing). Paging has none
|
|
525
|
+
* of those limits, at the cost of reading up to 20 pages of a very large repository.
|
|
526
|
+
*/
|
|
514
527
|
async search(filter) {
|
|
528
|
+
if (filter.text) return this.searchText(filter, filter.text);
|
|
515
529
|
const params = {
|
|
516
530
|
state: filter.openOnly ? "open" : "all",
|
|
517
531
|
sort: "updated",
|
|
@@ -530,6 +544,32 @@ var GitHubIssues = class {
|
|
|
530
544
|
assignee: params.assignee
|
|
531
545
|
})).filter((i) => !i.pull_request).map((i) => this.mapIssue(i));
|
|
532
546
|
}
|
|
547
|
+
async searchText(filter, text) {
|
|
548
|
+
const needle = text.toLowerCase();
|
|
549
|
+
const limit = filter.limit ?? 50;
|
|
550
|
+
const assignee = filter.assignee === "currentUser" ? (await this.getMyself()).id : filter.assignee || void 0;
|
|
551
|
+
const found = [];
|
|
552
|
+
for (let page = 1; page <= TEXT_MAX_PAGES; page++) {
|
|
553
|
+
const raw = await this.client.issues.listIssues(this.repo, {
|
|
554
|
+
state: filter.openOnly ? "open" : "all",
|
|
555
|
+
sort: "updated",
|
|
556
|
+
direction: "desc",
|
|
557
|
+
per_page: TEXT_PAGE_SIZE,
|
|
558
|
+
page,
|
|
559
|
+
filter: "all",
|
|
560
|
+
...assignee ? { assignee } : {}
|
|
561
|
+
});
|
|
562
|
+
for (const issue of raw) {
|
|
563
|
+
if (issue.pull_request) continue;
|
|
564
|
+
if (`${issue.title}\n${issue.body ?? ""}`.toLowerCase().includes(needle)) {
|
|
565
|
+
found.push(this.mapIssue(issue));
|
|
566
|
+
if (found.length >= limit) return found;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (raw.length < TEXT_PAGE_SIZE) break;
|
|
570
|
+
}
|
|
571
|
+
return found;
|
|
572
|
+
}
|
|
533
573
|
/** Fetches one issue by its key. */
|
|
534
574
|
async get(key) {
|
|
535
575
|
const number = parseIssueNumber(key, this.owner, this.repoName);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-github",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.395",
|
|
4
4
|
"description": "Holocron plugin for GitHub. Implements source, ci, secrets, environments, and issues capabilities against the GitHub REST API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ci",
|
|
@@ -44,21 +44,21 @@
|
|
|
44
44
|
"tsx": "4.23.15",
|
|
45
45
|
"typescript": "^5.9.3",
|
|
46
46
|
"vitest": "^5.1.0",
|
|
47
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
48
|
-
"@theholocron/eslint-config": "^8.9.0-alpha.15",
|
|
47
|
+
"@theholocron/cli": "5.0.0-alpha.395",
|
|
49
48
|
"@theholocron/fs-utils": "^1.17.0-alpha.3",
|
|
50
|
-
"@theholocron/github-client": "^1.58.0-alpha.25",
|
|
51
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.15",
|
|
52
49
|
"@theholocron/misc-utils": "^1.17.0-alpha.3",
|
|
53
|
-
"@theholocron/
|
|
50
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.15",
|
|
51
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.15",
|
|
54
52
|
"@theholocron/tsdown-config": "^8.9.0-alpha.15",
|
|
55
|
-
"@theholocron/
|
|
53
|
+
"@theholocron/http-client": "^1.58.0-alpha.27",
|
|
54
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.15",
|
|
55
|
+
"@theholocron/github-client": "^1.58.0-alpha.27"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@theholocron/fs-utils": "^1.16.0",
|
|
59
59
|
"@theholocron/github-client": "^1.58.0",
|
|
60
60
|
"@theholocron/misc-utils": "^1.16.0",
|
|
61
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
61
|
+
"@theholocron/cli": "5.0.0-alpha.395"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=22"
|