@theholocron/github-client 1.58.0-alpha.42 → 1.58.0-alpha.44
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 +1 -1
- package/dist/index.mjs +27 -1
- package/package.json +5 -5
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
|
-
*
|
|
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)
|
|
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.
|
|
3
|
+
"version": "1.58.0-alpha.44",
|
|
4
4
|
"description": "A TypeScript client for the GitHub REST API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -32,23 +32,23 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.44",
|
|
36
36
|
"@theholocron/observability": "^0.7.0-alpha.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26",
|
|
40
40
|
"@vitest/coverage-v8": "^5.1.0",
|
|
41
41
|
"@vitest/eslint-plugin": "^1.6.28",
|
|
42
|
-
"eslint": "^10.
|
|
42
|
+
"eslint": "^10.15.0",
|
|
43
43
|
"eslint-plugin-n": "^18.5.0",
|
|
44
44
|
"globals": "^17.14.0",
|
|
45
45
|
"tsdown": "^0.23.7",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vitest": "^5.1.0",
|
|
48
|
-
"@theholocron/eslint-config": "^8.9.0-alpha.21",
|
|
49
48
|
"@theholocron/tsconfig": "^8.9.0-alpha.21",
|
|
50
49
|
"@theholocron/tsdown-config": "^8.9.0-alpha.21",
|
|
51
|
-
"@theholocron/vitest-config": "^8.9.0-alpha.21"
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.21",
|
|
51
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.21"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22.0.0"
|