@theholocron/github-client 1.58.0-alpha.43 → 1.58.0-alpha.45

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
@@ -17,7 +17,7 @@ import { ErrorSink, Logger } from "@theholocron/observability/core";
17
17
  interface GraphQLClient {
18
18
  /**
19
19
  * Sends one query or mutation to `POST /graphql` and returns its `data`. Throws a `ProviderApiError` (status `200`, with the
20
- * response's `errors` array) when GitHub answers with errors, and the transport's own `ProviderApiError` for a network or HTTP failure.
20
+ * distinct `errors` as a JSON string in `details`) when GitHub answers with errors, and the transport's own `ProviderApiError` for a network or HTTP failure.
21
21
  */
22
22
  query<T>(document: string, variables?: Record<string, unknown>): Promise<T>;
23
23
  }
package/dist/index.mjs CHANGED
@@ -1,5 +1,28 @@
1
1
  import { ProviderApiError, createRestClient } from "@theholocron/http-client";
2
2
  import { createHmac, timingSafeEqual } from "node:crypto";
3
+ // src/graphql/describe-graphql-errors.ts
4
+ /**
5
+ * Collapses a GraphQL `errors` array. GitHub repeats one error for every node a query exceeded a limit on, so a single
6
+ * failure can arrive as hundreds of identical entries; each distinct message is printed once, with its `type` and
7
+ * `path` when it has them.
8
+ */
9
+ function describeGraphQLErrors(errors) {
10
+ const seen = /* @__PURE__ */ new Set();
11
+ const distinct = [];
12
+ const lines = [];
13
+ for (const e of errors) {
14
+ const where = [e.type, e.path && e.path.length > 0 ? e.path.join(".") : void 0].filter(Boolean).join(", ");
15
+ const line = where ? `${e.message} [${where}]` : e.message;
16
+ if (seen.has(line)) continue;
17
+ seen.add(line);
18
+ distinct.push(e);
19
+ lines.push(line);
20
+ }
21
+ return {
22
+ distinct,
23
+ text: lines.join("; ")
24
+ };
25
+ }
3
26
  // src/graphql/graphql.ts
4
27
  /** A {@link GraphQLClient} for GitHub's GraphQL API, built on the shared REST transport. */
5
28
  function createGitHubGraphQLClient(config) {
@@ -19,7 +42,10 @@ function createGitHubGraphQLClient(config) {
19
42
  variables
20
43
  }
21
44
  });
22
- if (result.errors && result.errors.length > 0) throw new ProviderApiError(`GitHub GraphQL → ${result.errors.map((e) => e.message).join("; ")}`, 200, result.errors);
45
+ if (result.errors && result.errors.length > 0) {
46
+ const { distinct, text } = describeGraphQLErrors(result.errors);
47
+ throw new ProviderApiError(`GitHub GraphQL → ${text}`, 200, JSON.stringify(distinct));
48
+ }
23
49
  return result.data;
24
50
  } };
25
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/github-client",
3
- "version": "1.58.0-alpha.43",
3
+ "version": "1.58.0-alpha.45",
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/http-client": "^1.58.0-alpha.43",
36
- "@theholocron/observability": "^0.7.0-alpha.5"
35
+ "@theholocron/observability": "^0.7.0-alpha.5",
36
+ "@theholocron/http-client": "^1.58.0-alpha.45"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^26",
@@ -45,10 +45,10 @@
45
45
  "tsdown": "^0.23.7",
46
46
  "typescript": "^5.9.3",
47
47
  "vitest": "^5.1.0",
48
- "@theholocron/vitest-config": "^8.9.0-alpha.21",
49
- "@theholocron/tsdown-config": "^8.9.0-alpha.21",
50
48
  "@theholocron/eslint-config": "^8.9.0-alpha.21",
51
- "@theholocron/tsconfig": "^8.9.0-alpha.21"
49
+ "@theholocron/vitest-config": "^8.9.0-alpha.21",
50
+ "@theholocron/tsconfig": "^8.9.0-alpha.21",
51
+ "@theholocron/tsdown-config": "^8.9.0-alpha.21"
52
52
  },
53
53
  "engines": {
54
54
  "node": ">=22.0.0"