@theholocron/github-client 1.58.0-alpha.66 → 1.58.0-alpha.68

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 CHANGED
@@ -1265,6 +1265,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
1265
1265
  update: (org: string, id: number, input: IssueTypeInput) => Promise<OrgIssueTypeInfo>;
1266
1266
  };
1267
1267
  issues: {
1268
+ countSearch: (repo: string, query: string) => Promise<number>;
1268
1269
  listIssues: (repo: string, params?: IssueSearchParams) => Promise<GitHubIssue[]>;
1269
1270
  getIssue: (repo: string, number: number) => Promise<GitHubIssue>;
1270
1271
  createIssue: (repo: string, body: Record<string, unknown>) => Promise<GitHubIssue>;
package/dist/index.mjs CHANGED
@@ -161,9 +161,21 @@ function checks(rest) {
161
161
  };
162
162
  }
163
163
  // src/environments/environments.ts
164
+ const PAGE_SIZE$1 = 100;
165
+ /** A stop for a response that never ends; 100 pages is 10,000 environments, far past GitHub's limit. */
166
+ const MAX_PAGES$3 = 100;
164
167
  function environments(rest) {
165
168
  return {
166
- listEnvironments: (repo) => rest.request(`${repoBase(repo)}/environments`).then((r) => r.environments),
169
+ /** Every environment, all pages: GitHub lists 30 by default and at most 100 a page. */
170
+ listEnvironments: async (repo) => {
171
+ const all = [];
172
+ for (let page = 1; page <= MAX_PAGES$3; page += 1) {
173
+ const r = await rest.request(`${repoBase(repo)}/environments?per_page=${PAGE_SIZE$1}&page=${page}`);
174
+ all.push(...r.environments);
175
+ if (r.environments.length < PAGE_SIZE$1 || all.length >= r.total_count) break;
176
+ }
177
+ return all;
178
+ },
167
179
  upsertEnvironment: (repo, name, body) => rest.request(`${repoBase(repo)}/environments/${encodeURIComponent(name)}`, {
168
180
  method: "PUT",
169
181
  body
@@ -410,6 +422,17 @@ function issueTypes(rest) {
410
422
  // src/issues/issues.ts
411
423
  function issues(rest) {
412
424
  return {
425
+ /**
426
+ * How many issues a search matches inside one repository (`GET /search/issues`, one item asked for, only the count
427
+ * read). The query is the text of GitHub's filter box; `repo:<repo>` is added. A query the search refuses answers 422.
428
+ */
429
+ countSearch: async (repo, query) => {
430
+ const qs = new URLSearchParams({
431
+ q: `${query} repo:${repo}`,
432
+ per_page: "1"
433
+ });
434
+ return (await rest.request(`/search/issues?${qs.toString()}`)).total_count;
435
+ },
413
436
  listIssues: (repo, params = {}) => {
414
437
  const qs = new URLSearchParams();
415
438
  if (params.state) qs.set("state", params.state);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/github-client",
3
- "version": "1.58.0-alpha.66",
3
+ "version": "1.58.0-alpha.68",
4
4
  "description": "A TypeScript client for the GitHub REST API",
5
5
  "keywords": [
6
6
  "github",
@@ -32,7 +32,7 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "@theholocron/http-client": "^1.58.0-alpha.66",
35
+ "@theholocron/http-client": "^1.58.0-alpha.68",
36
36
  "@theholocron/observability": "^0.7.0-alpha.9"
37
37
  },
38
38
  "devDependencies": {