@shivaedev/github 0.8.4 → 0.8.6
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/CHANGELOG.md +14 -0
- package/dist/artifacts.d.ts.map +1 -1
- package/dist/artifacts.js +8 -5
- package/dist/artifacts.js.map +1 -1
- package/dist/githubApp.js +7 -5
- package/dist/githubApp.js.map +1 -1
- package/package.json +4 -4
- package/src/artifacts.ts +11 -6
- package/src/githubApp.ts +11 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.6 - 2026-11-01
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Quality reports HTTP error branches written with `HttpStatus.fromLiteral` outside configured HTTP edges, including comparisons, switch cases and status-list membership.
|
|
8
|
+
- GitHub App requests and artifact storage downloads use the shared HTTP status filter while retaining their GitHub error tags and reasons.
|
|
9
|
+
- Server OTLP exports use the shared HTTP status filter to reset warning suppression after success and report redacted collector failures.
|
|
10
|
+
|
|
11
|
+
## 0.8.5 - 2026-11-01
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- Update `@shivaedev/errors` from 0.4.0 to 0.4.1.
|
|
16
|
+
|
|
3
17
|
## 0.8.4 - 2026-10-31
|
|
4
18
|
|
|
5
19
|
### Changed
|
package/dist/artifacts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAmB,UAAU,
|
|
1
|
+
{"version":3,"file":"artifacts.d.ts","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAmB,UAAU,EAA2C,MAAM,aAAa,CAAC;AAMnG,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAQD,wBAAgB,SAAS,CACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,CAAC,UAAU,EAC7B,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,EAC7B,KAAK,EAAE,UAAU,EACjB,OAAO,GAAE,OAAO,YAAY,CAAC,OAAmB;IAK/C,uBAAuB,YAAY,sBAAsB;EA2B1D"}
|
package/dist/artifacts.js
CHANGED
|
@@ -2,11 +2,17 @@ import { Effect } from "effect";
|
|
|
2
2
|
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { readBoundedBody } from "@shivaedev/http/body.ts";
|
|
5
|
+
import { filterStatus } from "@shivaedev/http/filterStatus.ts";
|
|
5
6
|
import { authenticatedRequest } from "./authenticatedRequest.js";
|
|
6
7
|
import { GitHubArtifactError, GitHubArtifactTooLarge, GitHubTransportError } from "./errors.js";
|
|
8
|
+
function downloadFailure(path, cause) {
|
|
9
|
+
return cause._tag === "HttpClientError"
|
|
10
|
+
? new GitHubTransportError({ path }, { cause })
|
|
11
|
+
: new GitHubArtifactError({ stage: "download", status: cause.status });
|
|
12
|
+
}
|
|
7
13
|
export function artifacts(apiUrl, client, token, rates, refresh = undefined) {
|
|
8
14
|
const send = authenticatedRequest(HttpClient.withScope(client), token, rates, refresh);
|
|
9
|
-
const download = HttpClient.withScope(client);
|
|
15
|
+
const download = filterStatus(HttpClient.withScope(client));
|
|
10
16
|
return {
|
|
11
17
|
downloadArtifactArchive: (options) => Effect.scoped(Effect.gen(function* () {
|
|
12
18
|
const path = `/repos/${encodeURIComponent(options.owner)}/${encodeURIComponent(options.repo)}/actions/artifacts/${options.artifactId}/zip`;
|
|
@@ -18,10 +24,7 @@ export function artifacts(apiUrl, client, token, rates, refresh = undefined) {
|
|
|
18
24
|
if (redirect.status !== HttpStatus.fromLiteral("Found") || location === undefined) {
|
|
19
25
|
return yield* new GitHubArtifactError({ stage: "redirect", status: redirect.status });
|
|
20
26
|
}
|
|
21
|
-
const response = yield* download.get(location).pipe(Effect.provideService(FetchHttpClient.RequestInit, { credentials: "omit", redirect: "manual" }), Effect.mapError((cause) =>
|
|
22
|
-
if (response.status < HttpStatus.fromLiteral("OK") || response.status >= HttpStatus.fromLiteral("MultipleChoices")) {
|
|
23
|
-
return yield* new GitHubArtifactError({ stage: "download", status: response.status });
|
|
24
|
-
}
|
|
27
|
+
const response = yield* download.get(location).pipe(Effect.provideService(FetchHttpClient.RequestInit, { credentials: "omit", redirect: "manual" }), Effect.mapError((cause) => downloadFailure(path, cause)));
|
|
25
28
|
return yield* readBoundedBody(response, options.byteLimit).pipe(Effect.catchTags({
|
|
26
29
|
HttpClientError: (cause) => Effect.fail(new GitHubTransportError({ path }, { cause })),
|
|
27
30
|
ResponseBodyTooLarge: (cause) => Effect.fail(new GitHubArtifactTooLarge({ limit: cause.limit }, { cause })),
|
package/dist/artifacts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,C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AQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAClD,MAAM,CAAC,cAAc,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAC/F,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CACxD,CAAC;YACF,OAAO,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAC9D,MAAM,CAAC,SAAS,CAAC;gBAChB,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,oBAAoB,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;gBACtF,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;aAC3G,CAAC,CACF,CAAC;QACH,CAAC,CAAC,CACF;KACF,CAAC;AACH,CAAC"}
|
package/dist/githubApp.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Cache, Clock, Context, Effect, Exit, Layer, Option, Redacted, Schema } from "effect";
|
|
2
2
|
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
3
|
-
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
3
|
import { readBoundedJson } from "@shivaedev/http/body.ts";
|
|
4
|
+
import { filterStatus } from "@shivaedev/http/filterStatus.ts";
|
|
5
5
|
import { appJwt } from "#appJwt.ts";
|
|
6
6
|
import { GitHubAppError } from "#errors.ts";
|
|
7
7
|
import { GitHubConfig } from "#GitHubConfig.ts";
|
|
@@ -39,6 +39,7 @@ export function githubApp(options) {
|
|
|
39
39
|
}));
|
|
40
40
|
}
|
|
41
41
|
function appRequests(client, apiUrl) {
|
|
42
|
+
const checked = filterStatus(client);
|
|
42
43
|
return Effect.fnUntraced(function* (method, path, jwt, schema, body) {
|
|
43
44
|
let input = HttpClientRequest.make(method)(new URL(path, apiUrl).href, {
|
|
44
45
|
headers: { Accept: "application/vnd.github+json", Authorization: `Bearer ${Redacted.value(jwt)}`, "X-GitHub-Api-Version": "2022-11-28" },
|
|
@@ -46,10 +47,11 @@ function appRequests(client, apiUrl) {
|
|
|
46
47
|
if (body !== undefined) {
|
|
47
48
|
input = yield* HttpClientRequest.bodyJson(input, body).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: "encode" }, { cause })));
|
|
48
49
|
}
|
|
49
|
-
const response = yield*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
const response = yield* checked
|
|
51
|
+
.execute(input)
|
|
52
|
+
.pipe(Effect.mapError((cause) => cause._tag === "HttpClientError"
|
|
53
|
+
? new GitHubAppError({ reason: "transport" }, { cause })
|
|
54
|
+
: new GitHubAppError({ reason: "status", status: cause.status })));
|
|
53
55
|
return yield* readBoundedJson(response, 64 * 1024, schema).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: cause._tag === "HttpClientError" ? "transport" : "response" }, { cause })));
|
|
54
56
|
});
|
|
55
57
|
}
|
package/dist/githubApp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubApp.js","sourceRoot":"","sources":["../src/githubApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,
|
|
1
|
+
{"version":3,"file":"githubApp.js","sourceRoot":"","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,EAAE,KAAK,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAClI,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/github",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.6",
|
|
4
4
|
"description": "Typed GitHub REST requests, conditional reads and resource budgets for Effect applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"README.md"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@shivaedev/errors": "0.4.
|
|
46
|
+
"@shivaedev/errors": "0.4.1",
|
|
47
47
|
"@shivaedev/http": "0.3.1",
|
|
48
48
|
"@shivaedev/service": "0.6.0"
|
|
49
49
|
},
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"@effect/platform-node": "4.0.6",
|
|
52
52
|
"@effect/platform-node-shared": "4.0.6",
|
|
53
53
|
"@effect/vitest": "4.0.6",
|
|
54
|
-
"@shivaedev/quality": "0.
|
|
54
|
+
"@shivaedev/quality": "0.54.0",
|
|
55
55
|
"@shivaedev/test": "0.12.0",
|
|
56
|
-
"@shivaedev/test-story": "0.
|
|
56
|
+
"@shivaedev/test-story": "0.32.0",
|
|
57
57
|
"@types/node": "24.19.2",
|
|
58
58
|
"effect": "4.0.6",
|
|
59
59
|
"typescript": "7.0.2",
|
package/src/artifacts.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
|
|
2
|
+
import { FetchHttpClient, HttpClient, type HttpClientError, HttpClientRequest } from "effect/http";
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { readBoundedBody } from "@shivaedev/http/body.ts";
|
|
5
|
+
import type { RemoteStatusError } from "@shivaedev/http/errors.ts";
|
|
6
|
+
import { filterStatus } from "@shivaedev/http/filterStatus.ts";
|
|
5
7
|
import { authenticatedRequest } from "./authenticatedRequest.ts";
|
|
6
8
|
import { GitHubArtifactError, GitHubArtifactTooLarge, GitHubTransportError } from "./errors.ts";
|
|
7
9
|
import type { GitHubToken } from "./GitHubToken.ts";
|
|
@@ -15,6 +17,12 @@ export interface ArtifactArchiveOptions {
|
|
|
15
17
|
readonly repo: string;
|
|
16
18
|
}
|
|
17
19
|
|
|
20
|
+
function downloadFailure(path: string, cause: HttpClientError.HttpClientError | RemoteStatusError) {
|
|
21
|
+
return cause._tag === "HttpClientError"
|
|
22
|
+
? new GitHubTransportError({ path }, { cause })
|
|
23
|
+
: new GitHubArtifactError({ stage: "download", status: cause.status });
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
export function artifacts(
|
|
19
27
|
apiUrl: string,
|
|
20
28
|
client: HttpClient.HttpClient,
|
|
@@ -23,7 +31,7 @@ export function artifacts(
|
|
|
23
31
|
refresh: typeof TokenRefresh.Service = undefined,
|
|
24
32
|
) {
|
|
25
33
|
const send = authenticatedRequest(HttpClient.withScope(client), token, rates, refresh);
|
|
26
|
-
const download = HttpClient.withScope(client);
|
|
34
|
+
const download = filterStatus(HttpClient.withScope(client));
|
|
27
35
|
return {
|
|
28
36
|
downloadArtifactArchive: (options: ArtifactArchiveOptions) =>
|
|
29
37
|
Effect.scoped(
|
|
@@ -41,11 +49,8 @@ export function artifacts(
|
|
|
41
49
|
}
|
|
42
50
|
const response = yield* download.get(location).pipe(
|
|
43
51
|
Effect.provideService(FetchHttpClient.RequestInit, { credentials: "omit", redirect: "manual" }),
|
|
44
|
-
Effect.mapError((cause) =>
|
|
52
|
+
Effect.mapError((cause) => downloadFailure(path, cause)),
|
|
45
53
|
);
|
|
46
|
-
if (response.status < HttpStatus.fromLiteral("OK") || response.status >= HttpStatus.fromLiteral("MultipleChoices")) {
|
|
47
|
-
return yield* new GitHubArtifactError({ stage: "download", status: response.status });
|
|
48
|
-
}
|
|
49
54
|
return yield* readBoundedBody(response, options.byteLimit).pipe(
|
|
50
55
|
Effect.catchTags({
|
|
51
56
|
HttpClientError: (cause) => Effect.fail(new GitHubTransportError({ path }, { cause })),
|
package/src/githubApp.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Cache, Clock, Context, Effect, Exit, Layer, Option, Redacted, Schema } from "effect";
|
|
2
2
|
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
3
|
-
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
3
|
import { readBoundedJson } from "@shivaedev/http/body.ts";
|
|
4
|
+
import { filterStatus } from "@shivaedev/http/filterStatus.ts";
|
|
5
5
|
import { type AppCredentials, appJwt } from "#appJwt.ts";
|
|
6
6
|
import { GitHubAppError } from "#errors.ts";
|
|
7
7
|
import { GitHubConfig } from "#GitHubConfig.ts";
|
|
@@ -66,6 +66,7 @@ export function githubApp(options: GitHubAppOptions) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
function appRequests(client: HttpClient.HttpClient, apiUrl: string) {
|
|
69
|
+
const checked = filterStatus(client);
|
|
69
70
|
return Effect.fnUntraced(function* <TSchema extends Schema.Constraint>(
|
|
70
71
|
method: "GET" | "POST",
|
|
71
72
|
path: string,
|
|
@@ -79,10 +80,15 @@ function appRequests(client: HttpClient.HttpClient, apiUrl: string) {
|
|
|
79
80
|
if (body !== undefined) {
|
|
80
81
|
input = yield* HttpClientRequest.bodyJson(input, body).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: "encode" }, { cause })));
|
|
81
82
|
}
|
|
82
|
-
const response = yield*
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
const response = yield* checked
|
|
84
|
+
.execute(input)
|
|
85
|
+
.pipe(
|
|
86
|
+
Effect.mapError((cause) =>
|
|
87
|
+
cause._tag === "HttpClientError"
|
|
88
|
+
? new GitHubAppError({ reason: "transport" }, { cause })
|
|
89
|
+
: new GitHubAppError({ reason: "status", status: cause.status }),
|
|
90
|
+
),
|
|
91
|
+
);
|
|
86
92
|
return yield* readBoundedJson(response, 64 * 1024, schema).pipe(
|
|
87
93
|
Effect.mapError((cause) => new GitHubAppError({ reason: cause._tag === "HttpClientError" ? "transport" : "response" }, { cause })),
|
|
88
94
|
);
|