@shivaedev/github 0.7.2 → 0.8.1

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 ADDED
@@ -0,0 +1,147 @@
1
+ # Changelog
2
+
3
+ ## 0.8.1 - 2026-10-31
4
+
5
+ ### Fixed
6
+
7
+ - Include `CHANGELOG.md` in published package contents so release notes are available in `node_modules`.
8
+ - Release checks reject published package `files` lists that omit `CHANGELOG.md`, naming the package and how to include it.
9
+
10
+ ## 0.8.0 - 2026-10-30
11
+
12
+ ### Added
13
+
14
+ - GitHub provides `GitHubToken.fromEnvOrCli`: resolve `GH_TOKEN`, then `GITHUB_TOKEN`, then `gh auth token` through Effect's child-process service. Authentication failures carry `GitHubTokenError` with string reasons and a non-enumerable cause.
15
+
16
+ ### Fixed
17
+
18
+ - Fleet consumes the shared token provider and pr-watch's typed-failure metadata.
19
+ - GitHub transport and artifact failure mappings retain their original non-enumerable cause. Watcher response, state and outage failures retain their causes.
20
+
21
+ ### Breaking
22
+
23
+ - Replace `GitHubAppError.stage` with string `reason` literals: `sign`, `encode`, `transport`, `status` and `response`. Migrate `stage === "sign"` handlers to `reason === "sign"`; replace `stage === "exchange"` handlers with the appropriate exchange reason. HTTP refusals retain `status`. Caught signing, encoding, transport and response failures retain their original non-enumerable `cause`; keep causes in trusted diagnostics because underlying requests can contain credentials.
24
+ - pr-watch preserves GitHub and HTTP errors in its failure channel. Match their original classes or tags instead of expecting every failure to be `WatchError`. Use `requestFailure` for display and retry metadata; it now returns metadata without replacing the error. `WatchError` requires a string `reason`; use `reason: "cooldown"` instead of `retryable: true` for a local cooldown.
25
+ - Replace the removed pr-watch `githubToken` Layer with `GitHubToken.fromEnvOrCli` from `@shivaedev/github/GitHubToken.ts`.
26
+ - The CLI uses Effect CLI and NodeRuntime. Signal interruption exits with 130 instead of 0; callers that treat interrupted watches as clean shutdowns must accept 130. Help and parse errors use Effect CLI's format. Replace `argumentsFor` and the static `help` export with `program` for CLI execution or `optionsFor` for validation of parsed settings. `program` now requires Effect CLI's standard environment services. `Watcher.poll` diagnostic callbacks now receive the original typed failure; use `requestFailure(failure).message` to render it. `confirmQueue(options, snapshot)` reads `GitHubHttp` from the Effect environment instead of a service parameter.
27
+ - Fleet PR watch streams also preserve these typed failures. Consumers that caught only `WatchError` must match the original GitHub or HTTP failure tags, or the existing authentication `ServiceUnavailable` tag.
28
+
29
+ ## 0.7.2 - 2026-10-30
30
+
31
+ ### Changed
32
+
33
+ - Require Effect 4.0.6 and align the Effect companion package peers and generated starter catalog to the same exact release. Install the 4.0.6 Effect stack together.
34
+
35
+ ### Fixed
36
+
37
+ - Register hosted RPC cache-control handling through Effect 4.0.6's request-scoped pre-response API so responses keep `private, no-store`.
38
+ - Accept native RPC's `application/x-ndjson` media type while preserving `application/ndjson` callers at the transport guard.
39
+ - Keep subscriptions open after their HTTP request body completes; closing the socket still cancels them.
40
+
41
+ ## 0.7.1 - 2026-10-29
42
+
43
+ ### Changed
44
+
45
+ - Release with updated workspace dependencies.
46
+
47
+ ## 0.7.0 - 2026-10-27
48
+
49
+ ### Added
50
+
51
+ - Check-run creation and updates accept `detailsUrl`, and returned check runs decode the report link from `details_url`.
52
+ - List pages expose `hasNext`; `listBounded` returns decoded items and a `truncated` flag without fetching beyond its page cap.
53
+ - Call verifyWebhook without a Schema to verify a signature without decoding the body.
54
+
55
+ ## 0.6.0 - 2026-10-27
56
+
57
+ ### Changed
58
+
59
+ - Depend on `@shivaedev/http` and `@shivaedev/errors` instead of `@shivaedev/contract` and `@shivaedev/platform`. Artifact downloads read through the shared bounded body reader of `@shivaedev/http` and still fail with `GitHubArtifactTooLarge` over the caller's byte cap.
60
+
61
+ ### Breaking
62
+
63
+ - Rename `@shivaedev/effect-github` to `@shivaedev/github`. Change dependency declarations and imports from `@shivaedev/effect-github/...` to `@shivaedev/github/...`; module paths inside the package are unchanged.
64
+
65
+ ## 0.5.1 - 2026-10-26
66
+
67
+ ### Changed
68
+
69
+ - Release with updated workspace dependencies.
70
+
71
+ ## 0.5.0 - 2026-10-26
72
+
73
+ ### Added
74
+
75
+ - Provide the shared expected failure schemas and `rejectedField` in `@shivaedev/effect-contract/errors/`, so browser-safe contract consumers can use them without depending on Platform. Tags, schema fields and RPC encoding remain the same.
76
+ - Authenticate App-level requests, including Schema-decoded `GET /app` and paginated `GET /app/installations`, with `githubApp({ appId, privateKey })`.
77
+ - Downscope installation tokens with `scope.repositoryIds`, `scope.repositories` and `scope.permissions`, including metadata-only access checks; omit the scope for full installation access.
78
+ - Refresh a cached installation token after a resource 401 and retry once, sharing replacement exchanges across concurrent requests and preserving a typed failure on a second 401.
79
+ - Download workflow-artifact ZIP archives with `GitHub.downloadArtifactArchive({ owner, repo, artifactId, byteLimit })`. The client reads GitHub's redirect explicitly, requests storage without GitHub credentials, and enforces the caller's byte cap while streaming. Missing or expired artifacts fail with `GitHubArtifactError`; oversized archives stop with `GitHubArtifactTooLarge`. This replaces application-owned redirect handling and archive byte limits.
80
+ - Match sticky comments with `appId` to require the marker at the start of the body, the matching `performed_via_github_app.id` and a bot author. Existing marker-inclusion and optional `author` login matching remain available.
81
+ - Classify GitHub's integration permission refusal as `GitHubPermissionDenied` and locked conversations as `GitHubConversationLocked`, each with the request path. Other 403s remain HTTP errors; primary and secondary rate limits retain precedence.
82
+ - Configure JSON response caps with `GitHubConfig.responseByteLimit` or a trailing byte-limit argument on `read`, `list` and `write`, including their representation methods. The default remains 1 MiB; larger comparisons and listings can allow 16 MiB while retaining streaming size enforcement, typed `ResponseBodyTooLarge` failures and Schema decoding.
83
+
84
+ ### Fixed
85
+
86
+ - Refresh a rejected GitHub App installation token when downloading a workflow artifact archive and retry once, returning a typed failure on a second 401.
87
+
88
+ ### Breaking
89
+
90
+ - Move all imports from `@shivaedev/platform/errors/taxonomy.ts` to `@shivaedev/effect-contract/errors/taxonomy.ts`, and from `@shivaedev/platform/errors/rejectedField.ts` to `@shivaedev/effect-contract/errors/rejectedField.ts`. The old modules are removed. Add a direct `@shivaedev/effect-contract` dependency if the consuming package does not already declare one. Admin, GitHub, Work Board and Work Fleet public failure types now refer to these shared classes.
91
+ - Generated apps use the new imports. The create-app updater applies the starter changes through its usual three-way patch; it does not rewrite imports in app-owned files. Replace both old import paths above in those files when upgrading existing apps.
92
+ - Permission and locked-conversation 403s now fail with the GitHub-specific errors instead of `RemoteHttpError`. Move handlers for those cases to `Effect.catchTag("GitHubPermissionDenied", ...)` and `Effect.catchTag("GitHubConversationLocked", ...)`; keep `RemoteHttpError` handling for other HTTP refusals.
93
+
94
+ ## 0.4.4 - 2026-10-25
95
+
96
+ ### Changed
97
+
98
+ - Release with updated workspace dependencies.
99
+
100
+ ## 0.4.3 - 2026-10-25
101
+
102
+ ### Changed
103
+
104
+ - Release with updated workspace dependencies.
105
+
106
+ ## 0.4.2 - 2026-10-25
107
+
108
+ ### Changed
109
+
110
+ - Release with updated workspace dependencies.
111
+
112
+ ## 0.4.1 - 2026-10-25
113
+
114
+ ### Changed
115
+
116
+ - Release with updated workspace dependencies.
117
+
118
+ ## 0.4.0 - 2026-10-25
119
+
120
+ ### Added
121
+
122
+ - Render untrusted text as literal Markdown text, code spans and table cells, and build row reports within a UTF-8 byte budget with a count of omitted rows.
123
+
124
+ ## 0.3.0 - 2026-10-25
125
+
126
+ ### Added
127
+
128
+ - Upsert sticky pull-request comments by hidden marker across comment pages, optionally matching an author login.
129
+ - Create check runs for a head SHA and move them through in progress to completed with a conclusion and output through Schema-typed requests and responses.
130
+
131
+ ## 0.2.0 - 2026-10-25
132
+
133
+ ### Added
134
+
135
+ - Authenticate GitHub REST requests as an App installation with built-in RS256 signing, repository installation lookup, and cached installation tokens shared across concurrent requests until their refresh point.
136
+ - Verify webhook signatures against raw bytes with HMAC SHA-256 and a constant-time comparison before decoding the delivery with the caller's Schema. Signature and App authentication failures stay typed and exclude credentials from errors and telemetry.
137
+ - GitHub paged reads accept a caller policy before each request and expose the observed resource for a path.
138
+
139
+ ### Breaking
140
+
141
+ - `GitHubToken` may now contain a lazy Effect as well as a static Option. Consumers reading the service directly must resolve it with `Effect.isEffect(value) ? yield* value : value` before inspecting the Option. Existing `Layer.succeed(GitHubToken)` providers and `GitHubToken.fromEnv` need no changes.
142
+
143
+ ## 0.1.0 - 2026-10-25
144
+
145
+ ### Added
146
+
147
+ - Share token-authenticated GitHub REST reads and JSON writes through an Effect service, with Schema decoding, lazy Link pagination, bounded bodies, ETag revalidation and per-resource rate-limit observations and UTC retry instants.
package/README.md CHANGED
@@ -38,6 +38,8 @@ await Effect.runPromise(program.pipe(Effect.provide(github)));
38
38
 
39
39
  `GitHubToken.fromEnv` reads `GH_TOKEN`, then `GITHUB_TOKEN`, through Effect Config. If neither is set, requests are unauthenticated. To supply a token directly, provide `GitHubToken` with `Option.some(Redacted.make(token))`; use `Option.none()` for anonymous access. Requests send `Accept: application/vnd.github+json` and `X-GitHub-Api-Version: 2022-11-28`.
40
40
 
41
+ `GitHubToken.fromEnvOrCli` uses the same environment precedence, then runs `gh auth token` through Effect `ChildProcessSpawner` when neither variable is set. Provide the spawner with this Layer. Authentication failure is a typed `GitHubTokenError` with a string `reason` (`config`, `command` or `refused`) and a non-enumerable `cause`.
42
+
41
43
  The default base URL is `https://api.github.com`. Provide `GitHubConfig` from `@shivaedev/github/GitHubConfig.ts` with `{ apiUrl }` for another GitHub API endpoint.
42
44
 
43
45
  `read(path, schema)` decodes a JSON response. `list(path, itemSchema)` returns a Stream of decoded items across GitHub's Link pages, and stops fetching when consumption stops. `write(method, path, body, schema)` sends JSON with `POST` or `PATCH` and decodes its response. JSON response bodies default to a 1 MiB cap. Set `GitHubConfig.responseByteLimit` once for a client or pass a trailing byte-limit argument to these helpers for one request. The cap applies to each list page and is enforced while reading, before Schema decoding; exceeding it fails with typed `ResponseBodyTooLarge` without buffering the complete body. The conditional cache holds up to 1000 representations and keeps decoded values separate for each Schema.
@@ -122,7 +124,7 @@ Alternatively, pass `{ appId, privateKey, owner: "acme", repository: "widgets",
122
124
 
123
125
  An installation token is fetched on the first request and reused until five minutes before `expires_at`, using Effect's Clock. Concurrent requests through the same Layer share the in-flight exchange, including at refresh. A resource 401 invalidates only the rejected cached token and retries once with a newly exchanged token; simultaneous 401s share that exchange. A second 401 fails with typed `RemoteUnauthorized`. App-level JWTs and custom tokens are not automatically retried.
124
126
 
125
- A rejected exchange fails with `GitHubAppError` from `errors.ts`; a 401 has `{ stage: "exchange", status: 401 }`. Signing failures have `stage: "sign"`. These errors and their logs and spans contain no private key, App JWT or installation token.
127
+ App authentication failures use `GitHubAppError` from `errors.ts`. Its string `reason` distinguishes `"sign"` (JWT signing), `"encode"` (request body encoding), `"transport"` (sending or reading the response), `"status"` (an HTTP refusal) and `"response"` (invalid or oversized response data). A refused exchange or installation lookup with HTTP 401 has `{ reason: "status", status: 401 }`. Caught failures remain available as a non-enumerable `cause`, excluded from JSON serialization; causes can contain credentials from the underlying HTTP request, so keep them in trusted diagnostics. The serialized errors, logs and spans exclude the private key, App JWT and installation token.
126
128
 
127
129
  ### Downloading workflow-artifact archives
128
130
 
@@ -1,9 +1,11 @@
1
- import { Config, Context, Effect, Layer, type Option, type Redacted } from "effect";
2
- import type { GitHubAppError } from "./errors.ts";
1
+ import { Config, Context, Effect, Layer, Option, Redacted } from "effect";
2
+ import { ChildProcessSpawner } from "effect/process";
3
+ import { type GitHubAppError, GitHubTokenError } from "./errors.ts";
3
4
  type Token = Option.Option<Redacted.Redacted<string>>;
4
5
  declare const GitHubToken_base: Context.ServiceClass<GitHubToken, "@shivaedev/github/GitHubToken", Effect.Effect<Token, GitHubAppError, never> | Token>;
5
6
  export declare class GitHubToken extends GitHubToken_base {
6
7
  static readonly fromEnv: Layer.Layer<GitHubToken, Config.ConfigError, never>;
8
+ static readonly fromEnvOrCli: Layer.Layer<GitHubToken, GitHubTokenError, ChildProcessSpawner.ChildProcessSpawner>;
7
9
  }
8
10
  export {};
9
11
  //# sourceMappingURL=GitHubToken.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GitHubToken.d.ts","sourceRoot":"","sources":["../src/GitHubToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;;AAEtD,qBAAa,WAAY,SAAQ,gBAA6G;IAC7I,MAAM,CAAC,QAAQ,CAAC,OAAO,sDAQrB;CACF"}
1
+ {"version":3,"file":"GitHubToken.d.ts","sourceRoot":"","sources":["../src/GitHubToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAU,MAAM,QAAQ,CAAC;AAClF,OAAO,EAAgB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,KAAK,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpE,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;;AAMtD,qBAAa,WAAY,SAAQ,gBAA6G;IAC7I,MAAM,CAAC,QAAQ,CAAC,OAAO,sDAA+C;IAEtE,MAAM,CAAC,QAAQ,CAAC,YAAY,sFAmB1B;CACF"}
@@ -1,8 +1,24 @@
1
- import { Config, Context, Effect, Layer } from "effect";
1
+ import { Config, Context, Effect, Layer, Option, Redacted, Stream } from "effect";
2
+ import { ChildProcess, ChildProcessSpawner } from "effect/process";
3
+ import { GitHubTokenError } from "./errors.js";
4
+ const environmentToken = Config.Redacted("GH_TOKEN").pipe(Config.orElse(() => Config.Redacted("GITHUB_TOKEN")), Config.option);
2
5
  export class GitHubToken extends Context.Service()("@shivaedev/github/GitHubToken") {
3
- static fromEnv = Layer.effect(GitHubToken)(Effect.gen(function* () {
4
- const token = yield* Config.Redacted("GH_TOKEN").pipe(Config.orElse(() => Config.Redacted("GITHUB_TOKEN")), Config.option);
5
- return token;
6
+ static fromEnv = Layer.effect(GitHubToken)(environmentToken);
7
+ static fromEnvOrCli = Layer.effect(GitHubToken)(Effect.gen(function* () {
8
+ const token = yield* environmentToken.pipe(Effect.mapError((cause) => new GitHubTokenError({ reason: "config" }, { cause })));
9
+ if (Option.isSome(token)) {
10
+ return token;
11
+ }
12
+ return yield* Effect.scoped(Effect.gen(function* () {
13
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
14
+ const child = yield* spawner.spawn(ChildProcess.make("gh", ["auth", "token"], { stderr: "ignore" }));
15
+ const output = yield* child.stdout.pipe(Stream.decodeText, Stream.mkString);
16
+ const exit = yield* child.exitCode;
17
+ if (Number(exit) !== 0) {
18
+ return yield* Effect.fail(new GitHubTokenError({ reason: "refused" }, { cause: exit }));
19
+ }
20
+ return Option.some(Redacted.make(output.trim()));
21
+ }).pipe(Effect.catchTag("PlatformError", (cause) => Effect.fail(new GitHubTokenError({ reason: "command" }, { cause })))));
6
22
  }));
7
23
  }
8
24
  //# sourceMappingURL=GitHubToken.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GitHubToken.js","sourceRoot":"","sources":["../src/GitHubToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAA8B,MAAM,QAAQ,CAAC;AAKpF,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAA6D,CAAC,+BAA+B,CAAC;IAC7I,MAAM,CAAU,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,CAClD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACnB,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,MAAM,CAA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AAC;IACH,CAAC,CAAC,CACF,CAAC;CACF"}
package/dist/appJwt.js CHANGED
@@ -4,7 +4,7 @@ import { GitHubAppError } from "#errors.ts";
4
4
  export const appJwt = Effect.fnUntraced(function* (options) {
5
5
  const now = Math.floor((yield* Clock.currentTimeMillis) / 1000);
6
6
  return yield* Effect.try({
7
- catch: () => new GitHubAppError({ stage: "sign" }),
7
+ catch: (cause) => new GitHubAppError({ reason: "sign" }, { cause }),
8
8
  try: () => {
9
9
  const header = Buffer.from(JSON.stringify({ alg: "RS256", typ: "JWT" })).toString("base64url");
10
10
  const payload = Buffer.from(JSON.stringify({ exp: now + 600, iat: now - 60, iss: options.appId })).toString("base64url");
@@ -1 +1 @@
1
- {"version":3,"file":"appJwt.js","sourceRoot":"","sources":["../src/appJwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAO5C,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,OAAuB;IACzE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC,CAAC;IAChE,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;QACxB,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAClD,GAAG,EAAE,GAAG,EAAE;YACT,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CA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AAG,EAAE;YACT,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAC/F,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YACzH,MAAM,KAAK,GAAG,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC;YACrC,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACtI,CAAC;KACD,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
package/dist/artifacts.js CHANGED
@@ -11,20 +11,20 @@ export function artifacts(apiUrl, client, token, rates, refresh = undefined) {
11
11
  downloadArtifactArchive: (options) => Effect.scoped(Effect.gen(function* () {
12
12
  const path = `/repos/${encodeURIComponent(options.owner)}/${encodeURIComponent(options.repo)}/actions/artifacts/${options.artifactId}/zip`;
13
13
  const redirect = yield* send(HttpClientRequest.get(new URL(path, apiUrl).href, { accept: "application/vnd.github+json" }), "manual").pipe(Effect.catchTags({
14
- RemoteGone: (error) => Effect.fail(new GitHubArtifactError({ stage: "redirect", status: error.status })),
15
- RemoteNotFound: (error) => Effect.fail(new GitHubArtifactError({ stage: "redirect", status: error.status })),
14
+ RemoteGone: (error) => Effect.fail(new GitHubArtifactError({ stage: "redirect", status: error.status }, { cause: error })),
15
+ RemoteNotFound: (error) => Effect.fail(new GitHubArtifactError({ stage: "redirect", status: error.status }, { cause: error })),
16
16
  }));
17
17
  const location = redirect.headers.location;
18
18
  if (redirect.status !== HttpStatus.fromLiteral("Found") || location === undefined) {
19
19
  return yield* new GitHubArtifactError({ stage: "redirect", status: redirect.status });
20
20
  }
21
- const response = yield* download.get(location).pipe(Effect.provideService(FetchHttpClient.RequestInit, { credentials: "omit", redirect: "manual" }), Effect.mapError(() => new GitHubTransportError({ path })));
21
+ const response = yield* download.get(location).pipe(Effect.provideService(FetchHttpClient.RequestInit, { credentials: "omit", redirect: "manual" }), Effect.mapError((cause) => new GitHubTransportError({ path }, { cause })));
22
22
  if (response.status < HttpStatus.fromLiteral("OK") || response.status >= HttpStatus.fromLiteral("MultipleChoices")) {
23
23
  return yield* new GitHubArtifactError({ stage: "download", status: response.status });
24
24
  }
25
25
  return yield* readBoundedBody(response, options.byteLimit).pipe(Effect.catchTags({
26
- HttpClientError: () => Effect.fail(new GitHubTransportError({ path })),
27
- ResponseBodyTooLarge: ({ limit }) => Effect.fail(new GitHubArtifactTooLarge({ limit })),
26
+ HttpClientError: (cause) => Effect.fail(new GitHubTransportError({ path }, { cause })),
27
+ ResponseBodyTooLarge: (cause) => Effect.fail(new GitHubArtifactTooLarge({ limit: cause.limit }, { cause })),
28
28
  }));
29
29
  })),
30
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../src/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO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AI,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CACzE,CAAC;YACF,IAAI,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,IAAI,UAAU,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBACpH,OAAO,KAAK,CAAC,CAAC,IAAI,mBAAmB,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;YACvF,CAAC;YACD,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"}
@@ -15,7 +15,7 @@ export function authenticatedRequest(client, token, rates, refresh = undefined)
15
15
  }
16
16
  function send(current) {
17
17
  const sent = client.execute(withCredential(input, current));
18
- return (mode === "manual" ? sent.pipe(Effect.provideService(FetchHttpClient.RequestInit, { credentials: "omit", redirect: "manual" })) : sent).pipe(Effect.mapError(() => new GitHubTransportError({ path })));
18
+ return (mode === "manual" ? sent.pipe(Effect.provideService(FetchHttpClient.RequestInit, { credentials: "omit", redirect: "manual" })) : sent).pipe(Effect.mapError((cause) => new GitHubTransportError({ path }, { cause })));
19
19
  }
20
20
  const credential = yield* accessToken;
21
21
  let response = yield* send(credential);
@@ -25,7 +25,7 @@ export function authenticatedRequest(client, token, rates, refresh = undefined)
25
25
  }
26
26
  const observedResource = rates.observe(response);
27
27
  if (!((mode === "revalidate" && isUnchanged(response)) || (mode === "manual" && response.status === HttpStatus.fromLiteral("Found")))) {
28
- yield* checkStatus(response, observedResource, rates.failures.get(observedResource) ?? 0).pipe(Effect.catchTag("HttpClientError", () => Effect.fail(new GitHubTransportError({ path }))), Effect.catchTag("GitHubRateLimited", (error) => {
28
+ yield* checkStatus(response, observedResource, rates.failures.get(observedResource) ?? 0).pipe(Effect.catchTag("HttpClientError", (cause) => Effect.fail(new GitHubTransportError({ path }, { cause }))), Effect.catchTag("GitHubRateLimited", (error) => {
29
29
  rates.blocked.set(error.resource, error);
30
30
  rates.failures.set(error.resource, (rates.failures.get(error.resource) ?? 0) + 1);
31
31
  return failRateLimited(path, error, rates.observations.get(error.resource)?.remaining);
@@ -1 +1 @@
1
- {"version":3,"file":"authenticatedRequest.js","sourceRoot":"","sources":["../src/authenticatedRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAyC,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxG,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAmB,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAGvE,MAAM,UAAU,oBAAoB,CACnC,MAAsE,EACtE,KAA6B,EAC7B,KAAiB,EACjB,OAAO,GAAgC,SAAS;IAEhD,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAA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AAK,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBAClF,OAAO,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC;YACxF,CAAC,CAAC,CACF,CAAC;QACH,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACxC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACvC,OAAO,QAAQ,CAAC;IACjB,CAAC,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,KAA0C,EAAE,UAAoD;IACvH,MAAM,OAAO,GAAG,iBAAiB,CAAC,SAAS,CAAC,KAAK,EAAE,sBAAsB,EAAE,YAAY,CAAC,CAAC;IACzF,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,UAAU,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;AAClJ,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -19,12 +19,30 @@ declare const GitHubTransportError_base: Schema.Class<GitHubTransportError, Sche
19
19
  readonly path: Schema.String;
20
20
  }>, import("effect/Cause").YieldableError>;
21
21
  export declare class GitHubTransportError extends GitHubTransportError_base {
22
+ constructor(fields: {
23
+ readonly path: string;
24
+ }, options?: ErrorOptions);
22
25
  }
23
- declare const GitHubAppError_base: Schema.Class<GitHubAppError, Schema.TaggedStruct<"GitHubAppError", {
24
- readonly stage: Schema.Literals<readonly ["sign", "exchange"]>;
26
+ declare const GitHubTokenError_base: Schema.Class<GitHubTokenError, Schema.TaggedStruct<"GitHubTokenError", {
27
+ readonly reason: Schema.Literals<readonly ["config", "command", "refused"]>;
28
+ }>, import("effect/Cause").YieldableError>;
29
+ export declare class GitHubTokenError extends GitHubTokenError_base {
30
+ constructor(fields: {
31
+ readonly reason: "config" | "command" | "refused";
32
+ }, options?: ErrorOptions);
33
+ get message(): string;
34
+ }
35
+ declare const AppFailure: Schema.Struct<{
36
+ readonly reason: Schema.Literals<readonly ["sign", "encode", "transport", "status", "response"]>;
37
+ readonly status: Schema.optional<Schema.Number>;
38
+ }>;
39
+ declare const GitHubAppError_base: Schema.Class<GitHubAppError, Schema.Struct<{
40
+ readonly _tag: Schema.tag<"GitHubAppError">;
41
+ readonly reason: Schema.Literals<readonly ["sign", "encode", "transport", "status", "response"]>;
25
42
  readonly status: Schema.optional<Schema.Number>;
26
43
  }>, import("effect/Cause").YieldableError>;
27
44
  export declare class GitHubAppError extends GitHubAppError_base {
45
+ constructor(fields: typeof AppFailure.Type, options?: ErrorOptions);
28
46
  }
29
47
  declare const GitHubWebhookSignatureError_base: Schema.Class<GitHubWebhookSignatureError, Schema.TaggedStruct<"GitHubWebhookSignatureError", {}>, import("effect/Cause").YieldableError>;
30
48
  export declare class GitHubWebhookSignatureError extends GitHubWebhookSignatureError_base {
@@ -34,11 +52,18 @@ declare const GitHubArtifactError_base: Schema.Class<GitHubArtifactError, Schema
34
52
  readonly status: Schema.Number;
35
53
  }>, import("effect/Cause").YieldableError>;
36
54
  export declare class GitHubArtifactError extends GitHubArtifactError_base {
55
+ constructor(fields: {
56
+ readonly stage: "redirect" | "download";
57
+ readonly status: number;
58
+ }, options?: ErrorOptions);
37
59
  }
38
60
  declare const GitHubArtifactTooLarge_base: Schema.Class<GitHubArtifactTooLarge, Schema.TaggedStruct<"GitHubArtifactTooLarge", {
39
61
  readonly limit: Schema.Number;
40
62
  }>, import("effect/Cause").YieldableError>;
41
63
  export declare class GitHubArtifactTooLarge extends GitHubArtifactTooLarge_base {
64
+ constructor(fields: {
65
+ readonly limit: number;
66
+ }, options?: ErrorOptions);
42
67
  }
43
68
  export {};
44
69
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;AAEhC,qBAAa,sBAAuB,SAAQ,2BAE1C;CAAG;;;;AAEL,qBAAa,wBAAyB,SAAQ,6BAE5C;CAAG;;;;;AAEL,qBAAa,iBAAkB,SAAQ,sBAGrC;CAAG;;;;AAEL,qBAAa,oBAAqB,SAAQ,yBAExC;CAAG;;;;;AAEL,qBAAa,cAAe,SAAQ,mBAGlC;CAAG;;AAEL,qBAAa,2BAA4B,SAAQ,gCAAoF;CAAG;;;;;AAExI,qBAAa,mBAAoB,SAAQ,wBAGvC;CAAG;;;;AAEL,qBAAa,sBAAuB,SAAQ,2BAE1C;CAAG"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;AAEhC,qBAAa,sBAAuB,SAAQ,2BAE1C;CAAG;;;;AAEL,qBAAa,wBAAyB,SAAQ,6BAE5C;CAAG;;;;;AAEL,qBAAa,iBAAkB,SAAQ,sBAGrC;CAAG;;;;AAEL,qBAAa,oBAAqB,SAAQ,yBAExC;IACD,YAAY,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,YAAY,EAGpE;CACD;;;;AAED,qBAAa,gBAAiB,SAAQ,qBAEpC;IACD,YAAY,MAAM,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,YAAY,EAGhG;IAED,IAAa,OAAO,WAEnB;CACD;AAED,QAAA,MAAM,UAAU;;;EAGd,CAAC;;;;;;AAEH,qBAAa,cAAe,SAAQ,mBAAkE;IACrG,YAAY,MAAM,EAAE,OAAO,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,YAAY,EAGjE;CACD;;AAED,qBAAa,2BAA4B,SAAQ,gCAAoF;CAAG;;;;;AAExI,qBAAa,mBAAoB,SAAQ,wBAGvC;IACD,YAAY,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,YAAY,EAG/G;CACD;;;;AAED,qBAAa,sBAAuB,SAAQ,2BAE1C;IACD,YAAY,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,OAAO,CAAC,EAAE,YAAY,EAGrE;CACD"}
package/dist/errors.js CHANGED
@@ -15,11 +15,31 @@ export class GitHubRateLimited extends Schema.TaggedError()("GitHubRateLimited",
15
15
  export class GitHubTransportError extends Schema.TaggedError()("GitHubTransportError", {
16
16
  path: Schema.String,
17
17
  }) {
18
+ constructor(fields, options) {
19
+ super(fields);
20
+ Object.defineProperty(this, "cause", { value: options?.cause });
21
+ }
18
22
  }
19
- export class GitHubAppError extends Schema.TaggedError()("GitHubAppError", {
20
- stage: Schema.Literals(["sign", "exchange"]),
21
- status: Schema.optional(Schema.Number),
23
+ export class GitHubTokenError extends Schema.TaggedError()("GitHubTokenError", {
24
+ reason: Schema.Literals(["config", "command", "refused"]),
22
25
  }) {
26
+ constructor(fields, options) {
27
+ super(fields);
28
+ Object.defineProperty(this, "cause", { value: options?.cause });
29
+ }
30
+ get message() {
31
+ return "GitHub authentication unavailable; set GH_TOKEN or GITHUB_TOKEN, or sign in with gh";
32
+ }
33
+ }
34
+ const AppFailure = Schema.Struct({
35
+ reason: Schema.Literals(["sign", "encode", "transport", "status", "response"]),
36
+ status: Schema.optional(Schema.Number),
37
+ });
38
+ export class GitHubAppError extends Schema.TaggedError()("GitHubAppError", AppFailure) {
39
+ constructor(fields, options) {
40
+ super(fields);
41
+ Object.defineProperty(this, "cause", { value: options?.cause });
42
+ }
23
43
  }
24
44
  export class GitHubWebhookSignatureError extends Schema.TaggedError()("GitHubWebhookSignatureError", {}) {
25
45
  }
@@ -27,9 +47,17 @@ export class GitHubArtifactError extends Schema.TaggedError()("GitHubArtifactErr
27
47
  stage: Schema.Literals(["redirect", "download"]),
28
48
  status: Schema.Number,
29
49
  }) {
50
+ constructor(fields, options) {
51
+ super(fields);
52
+ Object.defineProperty(this, "cause", { value: options?.cause });
53
+ }
30
54
  }
31
55
  export class GitHubArtifactTooLarge extends Schema.TaggedError()("GitHubArtifactTooLarge", {
32
56
  limit: Schema.Number,
33
57
  }) {
58
+ constructor(fields, options) {
59
+ super(fields);
60
+ Object.defineProperty(this, "cause", { value: options?.cause });
61
+ }
34
62
  }
35
63
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,OAAO,sBAAuB,SAAQ,MAAM,CAAC,WAAW,EAA0B,CAAC,wBAAwB,EAAE;IAClH,IAAI,EAAE,MAAM,CAAC,MAAM;CACnB,CAAC;CAAG;AAEL,MAAM,OAAO,wBAAyB,SAAQ,MAAM,CAAC,WAAW,EAA4B,CAAC,0BAA0B,EAAE;IACxH,IAAI,EAAE,MAAM,CAAC,MAAM;CACnB,CAAC;CAAG;AAEL,MAAM,OAAO,iBAAkB,SAAQ,MAAM,CAAC,WAAW,EAAqB,CAAC,mBAAmB,EAAE;IACnG,QAAQ,EAAE,MAAM,CAAC,MAAM;IACvB,OAAO,EAAE,MAAM,CAAC,WAAW;CAC3B,CAAC;CAAG;AAEL,MAAM,OAAO,oBAAqB,SAAQ,MAAM,CAAC,WAAW,EAAwB,CAAC,sBAAsB,EAA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d,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACjE,CAAC;CACD;AAED,MAAM,OAAO,2BAA4B,SAAQ,MAAM,CAAC,WAAW,EAA+B,CAAC,6BAA6B,EAAE,EAAE,CAAC;CAAG;AAExI,MAAM,OAAO,mBAAoB,SAAQ,MAAM,CAAC,WAAW,EAAuB,CAAC,qBAAqB,EAAE;IACzG,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAChD,MAAM,EAAE,MAAM,CAAC,MAAM;CACrB,CAAC;IACD,YAAY,MAA4E,EAAE,OAAsB;QAC/G,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACjE,CAAC;CACD;AAED,MAAM,OAAO,sBAAuB,SAAQ,MAAM,CAAC,WAAW,EAA0B,CAAC,wBAAwB,EAAE;IAClH,KAAK,EAAE,MAAM,CAAC,MAAM;CACpB,CAAC;IACD,YAAY,MAAkC,EAAE,OAAsB;QACrE,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IACjE,CAAC;CACD"}
package/dist/githubApp.js CHANGED
@@ -44,13 +44,13 @@ function appRequests(client, apiUrl) {
44
44
  headers: { Accept: "application/vnd.github+json", Authorization: `Bearer ${Redacted.value(jwt)}`, "X-GitHub-Api-Version": "2022-11-28" },
45
45
  });
46
46
  if (body !== undefined) {
47
- input = yield* HttpClientRequest.bodyJson(input, body).pipe(Effect.mapError(() => new GitHubAppError({ stage: "exchange" })));
47
+ input = yield* HttpClientRequest.bodyJson(input, body).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: "encode" }, { cause })));
48
48
  }
49
- const response = yield* client.execute(input).pipe(Effect.mapError(() => new GitHubAppError({ stage: "exchange" })));
49
+ const response = yield* client.execute(input).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: "transport" }, { cause })));
50
50
  if (response.status < HttpStatus.fromLiteral("OK") || response.status >= HttpStatus.fromLiteral("MultipleChoices")) {
51
- return yield* new GitHubAppError({ stage: "exchange", status: response.status });
51
+ return yield* new GitHubAppError({ reason: "status", status: response.status });
52
52
  }
53
- return yield* readBoundedJson(response, 64 * 1024, schema).pipe(Effect.mapError(() => new GitHubAppError({ stage: "exchange" })));
53
+ return yield* readBoundedJson(response, 64 * 1024, schema).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: cause._tag === "HttpClientError" ? "transport" : "response" }, { cause })));
54
54
  });
55
55
  }
56
56
  //# sourceMappingURL=githubApp.js.map
@@ -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,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAuB,MAAM,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAehD,MAAM,YAAY,GAAG,MA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EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9I,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QACvI,IAAI,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,MAAM,IAAI,UAAU,CAAC,WAAW,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACpH,OAAO,KAAK,CAAC,CAAC,IAAI,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,KAAK,CAAC,CAAC,eAAe,CAAC,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,CAC9D,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,cAAc,CAAC,EAAE,MAAM,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/dist/requests.js CHANGED
@@ -23,7 +23,7 @@ export function requests(client, token, rates, refresh = undefined) {
23
23
  }
24
24
  return cached;
25
25
  }
26
- const bytes = yield* readBoundedBody(response, limit).pipe(Effect.catchTag("HttpClientError", () => Effect.fail(new GitHubTransportError({ path: new URL(input.url).pathname }))));
26
+ const bytes = yield* readBoundedBody(response, limit).pipe(Effect.catchTag("HttpClientError", (cause) => Effect.fail(new GitHubTransportError({ path: new URL(input.url).pathname }, { cause }))));
27
27
  const entry = { bytes, decoded: new Map(), response };
28
28
  if (input.method === "GET" && response.headers.etag !== undefined) {
29
29
  cache.set(key, entry);
@@ -1 +1 @@
1
- {"version":3,"file":"requests.js","sourceRoot":"","sources":["../src/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAmB,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAuB,aAAa,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAGnD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,MAAM,UAAU,QAAQ,CACvB,MAA6B,EAC7B,KAA6B,EAC7B,KAAiB,EACjB,OAAO,GAAgC,SAAS;IAEhD,MAAM,KAAK,GAAG,aAAa,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,QAAQ,CAAC,EAAE,KAA0C,EAAE,KAAa;QACtG,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACnD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACnE,IAAI,OAAO,GAAG,iBAAiB,CAAC,YAAY,CAAC,KAAK,EAA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J,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/github",
3
- "version": "0.7.2",
3
+ "version": "0.8.1",
4
4
  "description": "Typed GitHub REST requests, conditional reads and resource budgets for Effect applications",
5
5
  "keywords": [
6
6
  "effect"
@@ -39,20 +39,21 @@
39
39
  "!src/**/*.test.ts",
40
40
  "!src/**/*.spec.ts",
41
41
  "!src/**/test-support",
42
+ "CHANGELOG.md",
42
43
  "README.md"
43
44
  ],
44
45
  "dependencies": {
45
- "@shivaedev/errors": "0.1.1",
46
- "@shivaedev/http": "0.2.0",
47
- "@shivaedev/service": "0.5.1"
46
+ "@shivaedev/errors": "0.1.3",
47
+ "@shivaedev/http": "0.3.1",
48
+ "@shivaedev/service": "0.6.0"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@effect/platform-node": "4.0.6",
51
52
  "@effect/platform-node-shared": "4.0.6",
52
53
  "@effect/vitest": "4.0.6",
53
- "@shivaedev/quality": "0.45.0",
54
- "@shivaedev/test": "0.10.1",
55
- "@shivaedev/test-story": "0.24.0",
54
+ "@shivaedev/quality": "0.48.1",
55
+ "@shivaedev/test": "0.12.0",
56
+ "@shivaedev/test-story": "0.27.0",
56
57
  "@types/node": "24.19.2",
57
58
  "effect": "4.0.6",
58
59
  "typescript": "7.0.2",
@@ -1,16 +1,34 @@
1
- import { Config, Context, Effect, Layer, type Option, type Redacted } from "effect";
2
- import type { GitHubAppError } from "./errors.ts";
1
+ import { Config, Context, Effect, Layer, Option, Redacted, Stream } from "effect";
2
+ import { ChildProcess, ChildProcessSpawner } from "effect/process";
3
+ import { type GitHubAppError, GitHubTokenError } from "./errors.ts";
3
4
 
4
5
  type Token = Option.Option<Redacted.Redacted<string>>;
6
+ const environmentToken = Config.Redacted("GH_TOKEN").pipe(
7
+ Config.orElse(() => Config.Redacted("GITHUB_TOKEN")),
8
+ Config.option,
9
+ );
5
10
 
6
11
  export class GitHubToken extends Context.Service<GitHubToken, Token | Effect.Effect<Token, GitHubAppError>>()("@shivaedev/github/GitHubToken") {
7
- static readonly fromEnv = Layer.effect(GitHubToken)(
12
+ static readonly fromEnv = Layer.effect(GitHubToken)(environmentToken);
13
+
14
+ static readonly fromEnvOrCli = Layer.effect(GitHubToken)(
8
15
  Effect.gen(function* () {
9
- const token = yield* Config.Redacted("GH_TOKEN").pipe(
10
- Config.orElse(() => Config.Redacted("GITHUB_TOKEN")),
11
- Config.option,
16
+ const token = yield* environmentToken.pipe(Effect.mapError((cause) => new GitHubTokenError({ reason: "config" }, { cause })));
17
+ if (Option.isSome(token)) {
18
+ return token;
19
+ }
20
+ return yield* Effect.scoped(
21
+ Effect.gen(function* () {
22
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
23
+ const child = yield* spawner.spawn(ChildProcess.make("gh", ["auth", "token"], { stderr: "ignore" }));
24
+ const output = yield* child.stdout.pipe(Stream.decodeText, Stream.mkString);
25
+ const exit = yield* child.exitCode;
26
+ if (Number(exit) !== 0) {
27
+ return yield* Effect.fail(new GitHubTokenError({ reason: "refused" }, { cause: exit }));
28
+ }
29
+ return Option.some(Redacted.make(output.trim()));
30
+ }).pipe(Effect.catchTag("PlatformError", (cause) => Effect.fail(new GitHubTokenError({ reason: "command" }, { cause })))),
12
31
  );
13
- return token;
14
32
  }),
15
33
  );
16
34
  }
package/src/appJwt.ts CHANGED
@@ -10,7 +10,7 @@ export interface AppCredentials {
10
10
  export const appJwt = Effect.fnUntraced(function* (options: AppCredentials) {
11
11
  const now = Math.floor((yield* Clock.currentTimeMillis) / 1000);
12
12
  return yield* Effect.try({
13
- catch: () => new GitHubAppError({ stage: "sign" }),
13
+ catch: (cause) => new GitHubAppError({ reason: "sign" }, { cause }),
14
14
  try: () => {
15
15
  const header = Buffer.from(JSON.stringify({ alg: "RS256", typ: "JWT" })).toString("base64url");
16
16
  const payload = Buffer.from(JSON.stringify({ exp: now + 600, iat: now - 60, iss: options.appId })).toString("base64url");
package/src/artifacts.ts CHANGED
@@ -31,8 +31,8 @@ export function artifacts(
31
31
  const path = `/repos/${encodeURIComponent(options.owner)}/${encodeURIComponent(options.repo)}/actions/artifacts/${options.artifactId}/zip`;
32
32
  const redirect = yield* send(HttpClientRequest.get(new URL(path, apiUrl).href, { accept: "application/vnd.github+json" }), "manual").pipe(
33
33
  Effect.catchTags({
34
- RemoteGone: (error) => Effect.fail(new GitHubArtifactError({ stage: "redirect", status: error.status })),
35
- RemoteNotFound: (error) => Effect.fail(new GitHubArtifactError({ stage: "redirect", status: error.status })),
34
+ RemoteGone: (error) => Effect.fail(new GitHubArtifactError({ stage: "redirect", status: error.status }, { cause: error })),
35
+ RemoteNotFound: (error) => Effect.fail(new GitHubArtifactError({ stage: "redirect", status: error.status }, { cause: error })),
36
36
  }),
37
37
  );
38
38
  const location = redirect.headers.location;
@@ -41,15 +41,15 @@ export function artifacts(
41
41
  }
42
42
  const response = yield* download.get(location).pipe(
43
43
  Effect.provideService(FetchHttpClient.RequestInit, { credentials: "omit", redirect: "manual" }),
44
- Effect.mapError(() => new GitHubTransportError({ path })),
44
+ Effect.mapError((cause) => new GitHubTransportError({ path }, { cause })),
45
45
  );
46
46
  if (response.status < HttpStatus.fromLiteral("OK") || response.status >= HttpStatus.fromLiteral("MultipleChoices")) {
47
47
  return yield* new GitHubArtifactError({ stage: "download", status: response.status });
48
48
  }
49
49
  return yield* readBoundedBody(response, options.byteLimit).pipe(
50
50
  Effect.catchTags({
51
- HttpClientError: () => Effect.fail(new GitHubTransportError({ path })),
52
- ResponseBodyTooLarge: ({ limit }) => Effect.fail(new GitHubArtifactTooLarge({ limit })),
51
+ HttpClientError: (cause) => Effect.fail(new GitHubTransportError({ path }, { cause })),
52
+ ResponseBodyTooLarge: (cause) => Effect.fail(new GitHubArtifactTooLarge({ limit: cause.limit }, { cause })),
53
53
  }),
54
54
  );
55
55
  }),
@@ -25,7 +25,7 @@ export function authenticatedRequest<R>(
25
25
  const sent = client.execute(withCredential(input, current));
26
26
  return (
27
27
  mode === "manual" ? sent.pipe(Effect.provideService(FetchHttpClient.RequestInit, { credentials: "omit", redirect: "manual" })) : sent
28
- ).pipe(Effect.mapError(() => new GitHubTransportError({ path })));
28
+ ).pipe(Effect.mapError((cause) => new GitHubTransportError({ path }, { cause })));
29
29
  }
30
30
  const credential = yield* accessToken;
31
31
  let response = yield* send(credential);
@@ -36,7 +36,7 @@ export function authenticatedRequest<R>(
36
36
  const observedResource = rates.observe(response);
37
37
  if (!((mode === "revalidate" && isUnchanged(response)) || (mode === "manual" && response.status === HttpStatus.fromLiteral("Found")))) {
38
38
  yield* checkStatus(response, observedResource, rates.failures.get(observedResource) ?? 0).pipe(
39
- Effect.catchTag("HttpClientError", () => Effect.fail(new GitHubTransportError({ path }))),
39
+ Effect.catchTag("HttpClientError", (cause) => Effect.fail(new GitHubTransportError({ path }, { cause }))),
40
40
  Effect.catchTag("GitHubRateLimited", (error) => {
41
41
  rates.blocked.set(error.resource, error);
42
42
  rates.failures.set(error.resource, (rates.failures.get(error.resource) ?? 0) + 1);
package/src/errors.ts CHANGED
@@ -15,20 +15,55 @@ export class GitHubRateLimited extends Schema.TaggedError<GitHubRateLimited>()("
15
15
 
16
16
  export class GitHubTransportError extends Schema.TaggedError<GitHubTransportError>()("GitHubTransportError", {
17
17
  path: Schema.String,
18
- }) {}
18
+ }) {
19
+ constructor(fields: { readonly path: string }, options?: ErrorOptions) {
20
+ super(fields);
21
+ Object.defineProperty(this, "cause", { value: options?.cause });
22
+ }
23
+ }
24
+
25
+ export class GitHubTokenError extends Schema.TaggedError<GitHubTokenError>()("GitHubTokenError", {
26
+ reason: Schema.Literals(["config", "command", "refused"]),
27
+ }) {
28
+ constructor(fields: { readonly reason: "config" | "command" | "refused" }, options?: ErrorOptions) {
29
+ super(fields);
30
+ Object.defineProperty(this, "cause", { value: options?.cause });
31
+ }
19
32
 
20
- export class GitHubAppError extends Schema.TaggedError<GitHubAppError>()("GitHubAppError", {
21
- stage: Schema.Literals(["sign", "exchange"]),
33
+ override get message() {
34
+ return "GitHub authentication unavailable; set GH_TOKEN or GITHUB_TOKEN, or sign in with gh";
35
+ }
36
+ }
37
+
38
+ const AppFailure = Schema.Struct({
39
+ reason: Schema.Literals(["sign", "encode", "transport", "status", "response"]),
22
40
  status: Schema.optional(Schema.Number),
23
- }) {}
41
+ });
42
+
43
+ export class GitHubAppError extends Schema.TaggedError<GitHubAppError>()("GitHubAppError", AppFailure) {
44
+ constructor(fields: typeof AppFailure.Type, options?: ErrorOptions) {
45
+ super(fields);
46
+ Object.defineProperty(this, "cause", { value: options?.cause });
47
+ }
48
+ }
24
49
 
25
50
  export class GitHubWebhookSignatureError extends Schema.TaggedError<GitHubWebhookSignatureError>()("GitHubWebhookSignatureError", {}) {}
26
51
 
27
52
  export class GitHubArtifactError extends Schema.TaggedError<GitHubArtifactError>()("GitHubArtifactError", {
28
53
  stage: Schema.Literals(["redirect", "download"]),
29
54
  status: Schema.Number,
30
- }) {}
55
+ }) {
56
+ constructor(fields: { readonly stage: "redirect" | "download"; readonly status: number }, options?: ErrorOptions) {
57
+ super(fields);
58
+ Object.defineProperty(this, "cause", { value: options?.cause });
59
+ }
60
+ }
31
61
 
32
62
  export class GitHubArtifactTooLarge extends Schema.TaggedError<GitHubArtifactTooLarge>()("GitHubArtifactTooLarge", {
33
63
  limit: Schema.Number,
34
- }) {}
64
+ }) {
65
+ constructor(fields: { readonly limit: number }, options?: ErrorOptions) {
66
+ super(fields);
67
+ Object.defineProperty(this, "cause", { value: options?.cause });
68
+ }
69
+ }
package/src/githubApp.ts CHANGED
@@ -77,12 +77,14 @@ function appRequests(client: HttpClient.HttpClient, apiUrl: string) {
77
77
  headers: { Accept: "application/vnd.github+json", Authorization: `Bearer ${Redacted.value(jwt)}`, "X-GitHub-Api-Version": "2022-11-28" },
78
78
  });
79
79
  if (body !== undefined) {
80
- input = yield* HttpClientRequest.bodyJson(input, body).pipe(Effect.mapError(() => new GitHubAppError({ stage: "exchange" })));
80
+ input = yield* HttpClientRequest.bodyJson(input, body).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: "encode" }, { cause })));
81
81
  }
82
- const response = yield* client.execute(input).pipe(Effect.mapError(() => new GitHubAppError({ stage: "exchange" })));
82
+ const response = yield* client.execute(input).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: "transport" }, { cause })));
83
83
  if (response.status < HttpStatus.fromLiteral("OK") || response.status >= HttpStatus.fromLiteral("MultipleChoices")) {
84
- return yield* new GitHubAppError({ stage: "exchange", status: response.status });
84
+ return yield* new GitHubAppError({ reason: "status", status: response.status });
85
85
  }
86
- return yield* readBoundedJson(response, 64 * 1024, schema).pipe(Effect.mapError(() => new GitHubAppError({ stage: "exchange" })));
86
+ return yield* readBoundedJson(response, 64 * 1024, schema).pipe(
87
+ Effect.mapError((cause) => new GitHubAppError({ reason: cause._tag === "HttpClientError" ? "transport" : "response" }, { cause })),
88
+ );
87
89
  });
88
90
  }
package/src/requests.ts CHANGED
@@ -33,7 +33,7 @@ export function requests(
33
33
  return cached;
34
34
  }
35
35
  const bytes = yield* readBoundedBody(response, limit).pipe(
36
- Effect.catchTag("HttpClientError", () => Effect.fail(new GitHubTransportError({ path: new URL(input.url).pathname }))),
36
+ Effect.catchTag("HttpClientError", (cause) => Effect.fail(new GitHubTransportError({ path: new URL(input.url).pathname }, { cause }))),
37
37
  );
38
38
  const entry: CachedResponse = { bytes, decoded: new Map(), response };
39
39
  if (input.method === "GET" && response.headers.etag !== undefined) {