@shivaedev/github 0.8.5 → 0.9.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +47 -3
  3. package/dist/GitHub.d.ts +100 -17
  4. package/dist/GitHub.d.ts.map +1 -1
  5. package/dist/GitHub.js +4 -1
  6. package/dist/GitHub.js.map +1 -1
  7. package/dist/GitHubToken.d.ts +2 -2
  8. package/dist/GitHubToken.d.ts.map +1 -1
  9. package/dist/GitHubToken.js +1 -1
  10. package/dist/GitHubToken.js.map +1 -1
  11. package/dist/appTokens.d.ts +6 -0
  12. package/dist/appTokens.d.ts.map +1 -0
  13. package/dist/appTokens.js +64 -0
  14. package/dist/appTokens.js.map +1 -0
  15. package/dist/artifacts.d.ts +1 -1
  16. package/dist/artifacts.d.ts.map +1 -1
  17. package/dist/artifacts.js +8 -5
  18. package/dist/artifacts.js.map +1 -1
  19. package/dist/authenticatedRequest.d.ts +1 -1
  20. package/dist/authenticatedRequest.d.ts.map +1 -1
  21. package/dist/authenticatedRequest.js +3 -2
  22. package/dist/authenticatedRequest.js.map +1 -1
  23. package/dist/cache.d.ts +2 -0
  24. package/dist/cache.d.ts.map +1 -1
  25. package/dist/cache.js +3 -0
  26. package/dist/cache.js.map +1 -1
  27. package/dist/checkRuns.d.ts +116 -11
  28. package/dist/checkRuns.d.ts.map +1 -1
  29. package/dist/checkRuns.js +39 -18
  30. package/dist/checkRuns.js.map +1 -1
  31. package/dist/githubApp.d.ts +2 -4
  32. package/dist/githubApp.d.ts.map +1 -1
  33. package/dist/githubApp.js +5 -53
  34. package/dist/githubApp.js.map +1 -1
  35. package/dist/installationClients.d.ts +185 -0
  36. package/dist/installationClients.d.ts.map +1 -0
  37. package/dist/installationClients.js +28 -0
  38. package/dist/installationClients.js.map +1 -0
  39. package/dist/json.d.ts.map +1 -1
  40. package/dist/json.js +4 -0
  41. package/dist/json.js.map +1 -1
  42. package/dist/representations.d.ts +4 -4
  43. package/dist/representations.d.ts.map +1 -1
  44. package/dist/representations.js +1 -1
  45. package/dist/representations.js.map +1 -1
  46. package/dist/requests.d.ts +2 -2
  47. package/dist/requests.d.ts.map +1 -1
  48. package/dist/requests.js +11 -9
  49. package/dist/requests.js.map +1 -1
  50. package/dist/status.d.ts +1 -1
  51. package/dist/status.d.ts.map +1 -1
  52. package/dist/stickyComments.d.ts +1 -1
  53. package/package.json +7 -7
  54. package/src/GitHub.ts +15 -1
  55. package/src/GitHubToken.ts +4 -2
  56. package/src/appTokens.ts +92 -0
  57. package/src/artifacts.ts +11 -6
  58. package/src/authenticatedRequest.ts +3 -1
  59. package/src/cache.ts +5 -0
  60. package/src/checkRuns.ts +58 -18
  61. package/src/githubApp.ts +6 -74
  62. package/src/installationClients.ts +44 -0
  63. package/src/json.ts +4 -0
  64. package/src/representations.ts +2 -2
  65. package/src/requests.ts +11 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.0 - 2026-11-02
4
+
5
+ ### Added
6
+
7
+ - Send PUT and DELETE through the shared authenticated mutation path, omit absent request bodies, and decode bodyless 204 results as `void` by omitting the response schema or using `Schema.Void`.
8
+ - Find the latest commit check run by name, app ID, or both with `findLatestCheckRun`, and create or update it with `upsertCheckRun`. Check-run responses expose the app ID when present and recognize GitHub Actions-only read statuses.
9
+ - One `githubApp` Layer now provides `GitHubApp` and `withInstallation` to share clients across installations, with separate token refresh, conditional caches and rate-limit state. The cache holds at most 100 clients, evicts the least recently used client when full and replaces clients after 30 minutes idle.
10
+
11
+ ### Fixed
12
+
13
+ - Installation lookups and token exchanges use the same rate-limit detection and retry deadlines as App and resource requests. Quota exhaustion returns typed `GitHubRateLimited`, and requests fail locally until its deadline instead of repeating authentication requests.
14
+ - Read HEAD responses and statuses 204, 205 and 304 as empty bytes or text; JSON decoding still rejects empty input.
15
+ - Limit encoded responses by bytes exposed by the native client stream, without comparing compressed Content-Length to decoded bytes. Fetch exposes decompressed bytes; Node's native HTTP transport exposes encoded bytes.
16
+ - Keep conditional response caches separate for requests with different query parameters. Refresh pagination Link metadata on 304 responses while reusing cached bodies and decoded values, so lists follow the current next page and stop when its Link disappears.
17
+ - Remove userinfo, query strings and fragments from status-error URLs.
18
+ - Keep pagination links on the request's origin.
19
+ - Release response bodies before returning status or body-size failures, and keep schema failures from holding HTTP connections.
20
+ - Release GitHub response bodies on rejection and before refreshing a rejected installation token, so repeated failures do not exhaust the connection pool.
21
+
22
+ ### Breaking
23
+
24
+ - Effectful `GitHubToken` providers can now fail with `GitHubRateLimited` alongside `GitHubAppError`. Consumers handling authentication failures must also handle `GitHubRateLimited` and use its `retryAt` when scheduling another attempt.
25
+ - Bounded response readers reject NaN, infinite and negative limits with the typed `InvalidBodyLimit` error from `errors.ts`. Pass a finite nonnegative byte limit and handle the new failure in the error channel.
26
+ - GitHub methods using the bounded response reader also expose `InvalidBodyLimit` from `@shivaedev/http/errors.ts` for invalid byte limits. Supply finite nonnegative limits and handle that failure alongside existing response failures.
27
+ - `CreateCheckRun` requires a conclusion when `status` is `completed`, with validation before any request. Consumers creating completed runs must supply `conclusion`; use `queued` or `in_progress` when no conclusion is available.
28
+ - `CheckRunStatus` includes `waiting`, `requested` and `pending` from GitHub Actions responses. Consumers with exhaustive status handling must add these cases. GitHub App create and update inputs remain restricted to `queued`, `in_progress` and `completed`.
29
+ - Pagination rejects automatic fetch redirects so custom headers cannot reach another origin. Pass a direct same-origin page URL instead of a redirecting URL; links to later pages must also use direct URLs. Other fetch options in the current Effect context are preserved. Use a client without redirect-following middleware.
30
+ - GitHub listing methods inherit the redirect restriction. List the repository's current API path instead of an endpoint that redirects after a rename or transfer.
31
+
32
+ ## 0.8.6 - 2026-11-01
33
+
34
+ ### Fixed
35
+
36
+ - Quality reports HTTP error branches written with `HttpStatus.fromLiteral` outside configured HTTP edges, including comparisons, switch cases and status-list membership.
37
+ - GitHub App requests and artifact storage downloads use the shared HTTP status filter while retaining their GitHub error tags and reasons.
38
+ - Server OTLP exports use the shared HTTP status filter to reset warning suppression after success and report redacted collector failures.
39
+
3
40
  ## 0.8.5 - 2026-11-01
4
41
 
5
42
  ### Changed
package/README.md CHANGED
@@ -42,7 +42,7 @@ await Effect.runPromise(program.pipe(Effect.provide(github)));
42
42
 
43
43
  The default base URL is `https://api.github.com`. Provide `GitHubConfig` from `@shivaedev/github/GitHubConfig.ts` with `{ apiUrl }` for another GitHub API endpoint.
44
44
 
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.
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`, `PATCH`, `PUT` or `DELETE` and decodes its response. Pass `undefined` for a bodyless request. For a 204 response, omit the schema to receive `void`, or pass `Schema.Void` explicitly; the service representation also supports `decode(Schema.Void)`. These mutations share authentication, quota observations and the single installation-token refresh. 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.
46
46
 
47
47
  For large comparisons and listings, allow up to 16 MiB through the same bounded, Schema-decoded path instead of maintaining a separate fetch, body reader and decoder in the application.
48
48
 
@@ -116,6 +116,25 @@ const repository = read("/repos/acme/widgets", Schema.Struct({ id: Schema.Number
116
116
 
117
117
  Provide `clients(privateKey).app` to `appInfo` or `installations`, and `.accessCheck` to `repository`, using `Effect.provide`. The `.background` client receives a full installation token. These Layers replace application-written JWT signing, installation-token exchanges, expiry timers and the resource-401 refresh wrapper; provide the client Layer once around the application or job for each installation and scope to share its token cache.
118
118
 
119
+ A single `githubApp(credentials)` Layer also provides `GitHubApp`, whose `installation(id)` method returns a cached `GitHub` client. Use `withInstallation` to run the usual GitHub operations for a selected installation without maintaining client Layers in the application:
120
+
121
+ ```ts
122
+ import { Effect, Layer, Redacted, Schema } from "effect";
123
+ import { FetchHttpClient } from "effect/http";
124
+ import { read } from "@shivaedev/github/GitHub.ts";
125
+ import { githubApp } from "@shivaedev/github/githubApp.ts";
126
+ import { withInstallation } from "@shivaedev/github/installationClients.ts";
127
+
128
+ const app = (privateKey: Redacted.Redacted<string>) => githubApp({ appId: "123456", privateKey }).pipe(Layer.provide(FetchHttpClient.layer));
129
+ const Repositories = Schema.Struct({ repositories: Schema.Array(Schema.Struct({ id: Schema.Number, name: Schema.String })) });
130
+ const repositories = read("/installation/repositories", Repositories);
131
+ const bothInstallations = Effect.all([withInstallation(7, repositories), withInstallation(8, repositories)]);
132
+ ```
133
+
134
+ Provide `app(privateKey)` once around `bothInstallations` or the application. Each installation has its own full-access token, conditional representations and rate-limit state. A 401 refreshes only that installation's rejected token; a rate limit blocks only that installation's resource. Existing scoped single-installation Layers remain available for access checks.
135
+
136
+ The shared cache holds at most 100 installation clients and evicts the least recently used client when full. Selecting a client renews its 30-minute idle lifetime; a client idle for that interval is replaced on its next selection. Expiry is lazy, with no background timer. Eviction discards the client's token and request state, and its next request exchanges a new token. Keep operations inside `withInstallation` so each selection uses the cache's current client.
137
+
119
138
  `scope` accepts `repositoryIds` or `repositories` (repository names), and a `permissions` record of GitHub permission names to `"read"`, `"write"` or `"admin"`. Omit `scope` for the installation's full access. Explicit `{ permissions: { metadata: "read" } }` requests a metadata-only token for access checks. GitHub decides whether the requested scope is allowed.
120
139
 
121
140
  Alternatively, pass `{ appId, privateKey, owner: "acme", repository: "widgets", scope? }`. The Layer resolves the installation through `GET /repos/{owner}/{repo}/installation` before exchanging the App JWT for an installation token. Signing uses Node's built-in crypto. The RS256 JWT carries the App ID as `iss`, `iat` 60 seconds before the current time, and `exp` ten minutes ahead.
@@ -124,7 +143,9 @@ Alternatively, pass `{ appId, privateKey, owner: "acme", repository: "widgets",
124
143
 
125
144
  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.
126
145
 
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.
146
+ Installation lookups and token exchanges follow the same primary and secondary rate-limit rules as resource and App-level requests: they fail with `GitHubRateLimited` and block further authentication requests locally until `retryAt`. Retry scheduling belongs to the caller.
147
+
148
+ Other 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.
128
149
 
129
150
  ### Downloading workflow-artifact archives
130
151
 
@@ -189,7 +210,30 @@ const report = Effect.gen(function* () {
189
210
  });
190
211
  ```
191
212
 
192
- `createCheckRun(owner, repo, input)` creates a check for `headSha` with a name and status. `updateCheckRun(owner, repo, id, input)` moves it to `in_progress` or `completed`; completion requires a conclusion. Output contains `title`, `summary` and optional `text`. An optional `detailsUrl` on creation and either update shape links to an external report; the returned `CheckRun.detailsUrl` is the GitHub URL or `null` when none exists. It is sent and decoded as `details_url`. Request and response Schemas are exported from `checkRuns.ts`.
213
+ `createCheckRun(owner, repo, input)` creates a check for `headSha` with a name and status. `updateCheckRun(owner, repo, id, input)` moves it to `in_progress` or `completed`; both creation and update with `status: "completed"` require a conclusion, including runtime validation before any request. Output contains `title`, `summary` and optional `text`. An optional `detailsUrl` on creation and either update shape links to an external report; the returned `CheckRun.detailsUrl` is the GitHub URL or `null` when none exists. It is sent and decoded as `details_url`. Request and response Schemas are exported from `checkRuns.ts`.
214
+
215
+ `findLatestCheckRun(owner, repo, { headSha, name?, appId? })` pages the commit's check runs and returns an `Option<CheckRun>`. Supply a name, an app ID, or both; both filters must match when supplied together. It selects the greatest run ID across all pages. `CheckRun.app` exposes the app ID when GitHub supplies it. Read statuses include GitHub Actions-only `waiting`, `requested` and `pending`, so another app's run in one of those states does not prevent ownership lookup.
216
+
217
+ `upsertCheckRun(owner, repo, input, appId?)` uses the same name and commit lookup, then updates the latest match or creates a run when none exists. Pass the app ID to keep another app's same-named check untouched. Without an app ID, use a name unique to your app. A lookup failure propagates without creating a run. Lookup and mutation are separate GitHub requests, so concurrent callers can create duplicates; callers own serialization.
218
+
219
+ ```ts
220
+ const publishCheck = (headSha: string) =>
221
+ Effect.gen(function* () {
222
+ const github = yield* GitHub;
223
+ return yield* github.upsertCheckRun(
224
+ "acme",
225
+ "widgets",
226
+ {
227
+ headSha,
228
+ name: "Coverage",
229
+ status: "completed",
230
+ conclusion: "success",
231
+ output: { title: "Coverage", summary: "90% covered" },
232
+ },
233
+ 123456,
234
+ );
235
+ });
236
+ ```
193
237
 
194
238
  ```ts
195
239
  const check = (headSha: string) =>
package/dist/GitHub.d.ts CHANGED
@@ -2,19 +2,29 @@ import { Effect, Schema, Stream } from "effect";
2
2
  import { HttpClient } from "effect/http";
3
3
  import { GitHubToken } from "#GitHubToken.ts";
4
4
  export declare const GitHub: import("effect/Context").Service<"@shivaedev/github/GitHub", Readonly<{
5
- readonly downloadArtifactArchive: (options: import("#artifacts.ts").ArtifactArchiveOptions) => Effect.Effect<Uint8Array<ArrayBuffer>, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubArtifactError | import("./errors.ts").GitHubArtifactTooLarge | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").RemoteHttpError | import("@shivaedev/http/errors.ts").RemoteRateLimited | import("@shivaedev/http/errors.ts").RemoteUnauthorized | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge, never>;
5
+ readonly downloadArtifactArchive: (options: import("#artifacts.ts").ArtifactArchiveOptions) => Effect.Effect<Uint8Array<ArrayBuffer>, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubArtifactError | import("./errors.ts").GitHubArtifactTooLarge | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").RemoteHttpError | import("@shivaedev/http/errors.ts").RemoteRateLimited | import("@shivaedev/http/errors.ts").RemoteUnauthorized | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge, never>;
6
6
  readonly list: (path: string, beforeRequest?: ((resource: string) => Effect.Effect<void, import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable>) | undefined, byteLimit?: number | undefined) => Effect.Effect<Stream.Stream<{
7
7
  decode: <TSchema extends Schema.Constraint>(schema: TSchema) => Effect.Effect<TSchema["Type"], Schema.SchemaError, TSchema["DecodingServices"]>;
8
8
  hasNext: boolean;
9
- }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, never>, never, never>;
9
+ }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, never>, never, never>;
10
10
  readonly read: (path: string, byteLimit?: number | undefined) => Effect.Effect<{
11
11
  decode: <TSchema extends Schema.Constraint>(schema: TSchema) => Effect.Effect<TSchema["Type"], Schema.SchemaError, TSchema["DecodingServices"]>;
12
- }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
13
- readonly write: (method: "PATCH" | "POST", path: string, body: unknown, byteLimit?: number | undefined) => Effect.Effect<{
12
+ }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
13
+ readonly write: (method: "DELETE" | "PATCH" | "POST" | "PUT", path: string, body?: unknown, byteLimit?: number | undefined) => Effect.Effect<{
14
14
  decode: <TSchema extends Schema.Constraint>(schema: TSchema) => Effect.Effect<TSchema["Type"], Schema.SchemaError, TSchema["DecodingServices"]>;
15
- }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
15
+ }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
16
16
  readonly createCheckRun: (owner: string, repo: string, input: {
17
+ readonly detailsUrl?: string | undefined;
18
+ readonly headSha: string;
19
+ readonly name: string;
20
+ readonly output?: {
21
+ readonly summary: string;
22
+ readonly text?: string | undefined;
23
+ readonly title: string;
24
+ } | undefined;
17
25
  readonly conclusion?: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | undefined;
26
+ readonly status: "in_progress" | "queued";
27
+ } | {
18
28
  readonly detailsUrl?: string | undefined;
19
29
  readonly headSha: string;
20
30
  readonly name: string;
@@ -23,8 +33,12 @@ export declare const GitHub: import("effect/Context").Service<"@shivaedev/github
23
33
  readonly text?: string | undefined;
24
34
  readonly title: string;
25
35
  } | undefined;
26
- readonly status: "completed" | "in_progress" | "queued";
36
+ readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out";
37
+ readonly status: "completed";
27
38
  }) => Effect.Effect<{
39
+ readonly app?: {
40
+ readonly id: number;
41
+ } | null | undefined;
28
42
  readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | null;
29
43
  readonly detailsUrl: string | null;
30
44
  readonly headSha: string;
@@ -35,8 +49,32 @@ export declare const GitHub: import("effect/Context").Service<"@shivaedev/github
35
49
  readonly text: string | null;
36
50
  readonly title: string | null;
37
51
  };
38
- readonly status: "completed" | "in_progress" | "queued";
39
- }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
52
+ readonly status: "completed" | "in_progress" | "pending" | "queued" | "requested" | "waiting";
53
+ }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
54
+ readonly findLatestCheckRun: (owner: string, repo: string, input: {
55
+ readonly appId?: number | undefined;
56
+ readonly headSha: string;
57
+ readonly name: string;
58
+ } | {
59
+ readonly appId: number;
60
+ readonly headSha: string;
61
+ readonly name?: string | undefined;
62
+ }) => Effect.Effect<import("effect/Option").Option<{
63
+ readonly app?: {
64
+ readonly id: number;
65
+ } | null | undefined;
66
+ readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | null;
67
+ readonly detailsUrl: string | null;
68
+ readonly headSha: string;
69
+ readonly id: number;
70
+ readonly name: string;
71
+ readonly output: {
72
+ readonly summary: string | null;
73
+ readonly text: string | null;
74
+ readonly title: string | null;
75
+ };
76
+ readonly status: "completed" | "in_progress" | "pending" | "queued" | "requested" | "waiting";
77
+ }>, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
40
78
  readonly updateCheckRun: (owner: string, repo: string, id: number, input: {
41
79
  readonly detailsUrl?: string | undefined;
42
80
  readonly output?: {
@@ -55,6 +93,47 @@ export declare const GitHub: import("effect/Context").Service<"@shivaedev/github
55
93
  } | undefined;
56
94
  readonly status: "completed";
57
95
  }) => Effect.Effect<{
96
+ readonly app?: {
97
+ readonly id: number;
98
+ } | null | undefined;
99
+ readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | null;
100
+ readonly detailsUrl: string | null;
101
+ readonly headSha: string;
102
+ readonly id: number;
103
+ readonly name: string;
104
+ readonly output: {
105
+ readonly summary: string | null;
106
+ readonly text: string | null;
107
+ readonly title: string | null;
108
+ };
109
+ readonly status: "completed" | "in_progress" | "pending" | "queued" | "requested" | "waiting";
110
+ }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
111
+ readonly upsertCheckRun: (owner: string, repo: string, input: {
112
+ readonly detailsUrl?: string | undefined;
113
+ readonly headSha: string;
114
+ readonly name: string;
115
+ readonly output?: {
116
+ readonly summary: string;
117
+ readonly text?: string | undefined;
118
+ readonly title: string;
119
+ } | undefined;
120
+ readonly conclusion?: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | undefined;
121
+ readonly status: "in_progress" | "queued";
122
+ } | {
123
+ readonly detailsUrl?: string | undefined;
124
+ readonly headSha: string;
125
+ readonly name: string;
126
+ readonly output?: {
127
+ readonly summary: string;
128
+ readonly text?: string | undefined;
129
+ readonly title: string;
130
+ } | undefined;
131
+ readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out";
132
+ readonly status: "completed";
133
+ }, appId?: number | undefined) => Effect.Effect<{
134
+ readonly app?: {
135
+ readonly id: number;
136
+ } | null | undefined;
58
137
  readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | null;
59
138
  readonly detailsUrl: string | null;
60
139
  readonly headSha: string;
@@ -65,8 +144,8 @@ export declare const GitHub: import("effect/Context").Service<"@shivaedev/github
65
144
  readonly text: string | null;
66
145
  readonly title: string | null;
67
146
  };
68
- readonly status: "completed" | "in_progress" | "queued";
69
- }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
147
+ readonly status: "completed" | "in_progress" | "pending" | "queued" | "requested" | "waiting";
148
+ }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
70
149
  readonly upsertStickyComment: (input: {
71
150
  readonly appId?: number | undefined;
72
151
  readonly author?: string | undefined;
@@ -85,19 +164,23 @@ export declare const GitHub: import("effect/Context").Service<"@shivaedev/github
85
164
  readonly login: string;
86
165
  readonly type?: string | undefined;
87
166
  } | null;
88
- }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
89
- readonly bytes: (path: string, accept: string, limit: number) => Effect.Effect<Uint8Array<ArrayBufferLike>, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
167
+ }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
168
+ readonly bytes: (path: string, accept: string, limit: number) => Effect.Effect<Uint8Array<ArrayBufferLike>, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
90
169
  readonly observations: () => Effect.Effect<import("#rateLimits.ts").RateLimitObservation[], never, never>;
91
170
  readonly resource: (path: string) => Effect.Effect<string, never, never>;
92
- readonly text: (path: string, accept: string, limit: number) => Effect.Effect<string, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
171
+ readonly text: (path: string, accept: string, limit: number) => Effect.Effect<string, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, never>;
93
172
  }>> & {
94
173
  readonly layer: import("effect/Layer").Layer<"@shivaedev/github/GitHub", never, GitHubToken | HttpClient.HttpClient>;
95
174
  };
96
- export declare function read<TSchema extends Schema.Constraint>(path: string, schema: TSchema, responseByteLimit?: number): Effect.Effect<TSchema["Type"], import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/http/errors.ts").RemoteStatusError, "@shivaedev/github/GitHub" | TSchema["DecodingServices"]>;
97
- export declare function list<TSchema extends Schema.Constraint>(path: string, schema: TSchema, responseByteLimit?: number): Stream.Stream<TSchema["Type"], import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, "@shivaedev/github/GitHub" | TSchema["DecodingServices"]>;
175
+ export declare function read<TSchema extends Schema.Constraint>(path: string, schema: TSchema, responseByteLimit?: number): Effect.Effect<TSchema["Type"], import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/http/errors.ts").RemoteStatusError, "@shivaedev/github/GitHub" | TSchema["DecodingServices"]>;
176
+ export declare function list<TSchema extends Schema.Constraint>(path: string, schema: TSchema, responseByteLimit?: number): Stream.Stream<TSchema["Type"], import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, "@shivaedev/github/GitHub" | TSchema["DecodingServices"]>;
98
177
  export declare function listBounded<TSchema extends Schema.Constraint>(path: string, schema: TSchema, pageCap: number, responseByteLimit?: number): Effect.Effect<{
99
178
  items: TSchema["Type"][];
100
179
  truncated: boolean;
101
- }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, "@shivaedev/github/GitHub" | TSchema["DecodingServices"]>;
102
- export declare function write<TSchema extends Schema.Constraint>(method: "POST" | "PATCH", path: string, body: unknown, schema: TSchema, responseByteLimit?: number): Effect.Effect<TSchema["Type"], import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/http/errors.ts").RemoteStatusError, "@shivaedev/github/GitHub" | TSchema["DecodingServices"]>;
180
+ }, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("effect/Cause").NoSuchElementError | import("@shivaedev/http/errors.ts").PaginationLinkError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/errors/taxonomy.ts").ServiceUnavailable | import("@shivaedev/http/errors.ts").RemoteStatusError, "@shivaedev/github/GitHub" | TSchema["DecodingServices"]>;
181
+ type WriteMethod = "POST" | "PATCH" | "PUT" | "DELETE";
182
+ export declare function write<TSchema extends Schema.Constraint>(method: WriteMethod, path: string, body: unknown, schema: TSchema, responseByteLimit?: number): ReturnType<typeof writeDecoded<TSchema>>;
183
+ export declare function write(method: WriteMethod, path: string, body?: unknown): ReturnType<typeof writeDecoded<typeof Schema.Void>>;
184
+ declare function writeDecoded<TSchema extends Schema.Constraint>(method: WriteMethod, path: string, body: unknown, schema: TSchema, responseByteLimit?: number): Effect.Effect<TSchema["Type"], import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | import("./errors.ts").GitHubTransportError | import("effect/http/HttpBody").HttpBodyError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | Schema.SchemaError | import("@shivaedev/http/errors.ts").RemoteStatusError, "@shivaedev/github/GitHub" | TSchema["DecodingServices"]>;
185
+ export {};
103
186
  //# sourceMappingURL=GitHub.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GitHub.d.ts","sourceRoot":"","sources":["../src/GitHub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAO9C,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BjB,CAAC;AAEH,wBAAgB,IAAI,CAAC,OAAO,SAAS,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,CAA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EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,CAAC,EAAE,MAAM,2pBAKhH;AAED,wBAAgB,WAAW,CAAC,OAAO,SAAS,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM;;;4nBAOxI;AAED,KAAK,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;AAEvD,wBAAgB,KAAK,CAAC,OAAO,SAAS,MAAM,CAAC,UAAU,EACtD,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,OAAO,EACf,iBAAiB,CAAC,EAAE,MAAM,GACxB,UAAU,CAAC,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AAC5C,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;AAK9H,iBAAS,YAAY,CAAC,OAAO,SAAS,MAAM,CAAC,UAAU,EACtD,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,OAAO,EACf,iBAAiB,CAAC,EAAE,MAAM,uiBAK1B"}
package/dist/GitHub.js CHANGED
@@ -50,7 +50,10 @@ export function list(path, schema, responseByteLimit) {
50
50
  export function listBounded(path, schema, pageCap, responseByteLimit) {
51
51
  return Stream.unwrap(Effect.flatMap(GitHub, (github) => github.list(path, undefined, responseByteLimit))).pipe(Stream.take(pageCap), Stream.mapEffect((page) => Effect.map(page.decode(Schema.Array(schema)), (items) => ({ items, truncated: page.hasNext }))), Stream.runCollect, Effect.map((pages) => ({ items: pages.flatMap((page) => page.items), truncated: pages.at(-1)?.truncated ?? false })));
52
52
  }
53
- export function write(method, path, body, schema, responseByteLimit) {
53
+ export function write(method, path, body, schema = Schema.Void, responseByteLimit) {
54
+ return writeDecoded(method, path, body, schema, responseByteLimit);
55
+ }
56
+ function writeDecoded(method, path, body, schema, responseByteLimit) {
54
57
  return Effect.flatMap(GitHub, (github) => Effect.flatMap(github.write(method, path, body, responseByteLimit), (response) => response.decode(schema)));
55
58
  }
56
59
  //# sourceMappingURL=GitHub.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GitHub.js","sourceRoot":"","sources":["../src/GitHub.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC;IACnC,EAAE,EAAE,0BAA0B;IAC9B,UAAU,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC;QACnC,MAAM,K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AAE,IAAI,EAAE,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAC1G,CAAC;AACH,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { Config, Context, Effect, Layer, Option, Redacted } from "effect";
2
2
  import { ChildProcessSpawner } from "effect/process";
3
- import { type GitHubAppError, GitHubTokenError } from "./errors.ts";
3
+ import { type GitHubAppError, type GitHubRateLimited, GitHubTokenError } from "#errors.ts";
4
4
  type Token = Option.Option<Redacted.Redacted<string>>;
5
- declare const GitHubToken_base: Context.ServiceClass<GitHubToken, "@shivaedev/github/GitHubToken", Effect.Effect<Token, GitHubAppError, never> | Token>;
5
+ declare const GitHubToken_base: Context.ServiceClass<GitHubToken, "@shivaedev/github/GitHubToken", Effect.Effect<Token, GitHubAppError | GitHubRateLimited, never> | Token>;
6
6
  export declare class GitHubToken extends GitHubToken_base {
7
7
  static readonly fromEnv: Layer.Layer<GitHubToken, Config.ConfigError, never>;
8
8
  static readonly fromEnvOrCli: Layer.Layer<GitHubToken, GitHubTokenError, ChildProcessSpawner.ChildProcessSpawner>;
@@ -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,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
+ {"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,KAAK,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE3F,KAAK,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;;AAMtD,qBAAa,WAAY,SAAQ,gBAEhC;IACA,MAAM,CAAC,QAAQ,CAAC,OAAO,sDAA+C;IAEtE,MAAM,CAAC,QAAQ,CAAC,YAAY,sFAmB1B;CACF"}
@@ -1,6 +1,6 @@
1
1
  import { Config, Context, Effect, Layer, Option, Redacted, Stream } from "effect";
2
2
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
3
- import { GitHubTokenError } from "./errors.js";
3
+ import { GitHubTokenError } from "#errors.ts";
4
4
  const environmentToken = Config.Redacted("GH_TOKEN").pipe(Config.orElse(() => Config.Redacted("GITHUB_TOKEN")), Config.option);
5
5
  export class GitHubToken extends Context.Service()("@shivaedev/github/GitHubToken") {
6
6
  static fromEnv = Layer.effect(GitHubToken)(environmentToken);
@@ -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,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;A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AAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxB,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YACzF,CAAC;YACD,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,gBAAgB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CACzH,CAAC;IACH,CAAC,CAAC,CACF,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ import { Layer } from "effect";
2
+ import { HttpClient } from "effect/http";
3
+ import { GitHubToken } from "#GitHubToken.ts";
4
+ import type { GitHubAppOptions } from "#githubApp.ts";
5
+ export declare function appTokens(options: GitHubAppOptions): Layer.Layer<GitHubToken, never, HttpClient.HttpClient>;
6
+ //# sourceMappingURL=appTokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appTokens.d.ts","sourceRoot":"","sources":["../src/appTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuC,KAAK,EAAiC,MAAM,QAAQ,CAAC;AACnG,OAAO,EAAE,UAAU,EAAqB,MAAM,aAAa,CAAC;AAM5D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAStD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,0DAsClD"}
@@ -0,0 +1,64 @@
1
+ import { Cache, Clock, Context, Effect, Exit, Layer, Option, Schema } from "effect";
2
+ import { HttpClient, HttpClientRequest } from "effect/http";
3
+ import { readBoundedJson } from "@shivaedev/http/body.ts";
4
+ import { appJwt } from "#appJwt.ts";
5
+ import { authenticatedRequest } from "#authenticatedRequest.ts";
6
+ import { GitHubAppError } from "#errors.ts";
7
+ import { GitHubConfig } from "#GitHubConfig.ts";
8
+ import { GitHubToken } from "#GitHubToken.ts";
9
+ import { rateLimits } from "#rateLimits.ts";
10
+ import { TokenRefresh } from "#TokenRefresh.ts";
11
+ const Installation = Schema.Struct({ id: Schema.Number });
12
+ const AccessToken = Schema.Struct({ expiresAt: Schema.DateFromString, token: Schema.RedactedFromValue(Schema.String) }).pipe(Schema.encodeKeys({ expiresAt: "expires_at" }));
13
+ export function appTokens(options) {
14
+ return Layer.effectContext(Effect.gen(function* () {
15
+ if (!("installationId" in options || "owner" in options)) {
16
+ return Context.make(GitHubToken, Effect.map(appJwt(options), Option.some)).pipe(Context.add(TokenRefresh, undefined));
17
+ }
18
+ const client = yield* HttpClient.HttpClient;
19
+ const { apiUrl } = yield* GitHubConfig;
20
+ let installationId = "installationId" in options ? options.installationId : undefined;
21
+ const request = appRequests(client, apiUrl);
22
+ const exchange = Effect.gen(function* () {
23
+ const jwt = yield* appJwt(options);
24
+ if (installationId === undefined && "owner" in options && options.owner !== undefined) {
25
+ const path = `/repos/${encodeURIComponent(options.owner)}/${encodeURIComponent(options.repository)}/installation`;
26
+ installationId = (yield* request("GET", path, jwt, Installation)).id;
27
+ }
28
+ const access = yield* request("POST", `/app/installations/${installationId}/access_tokens`, jwt, AccessToken, {
29
+ permissions: options.scope?.permissions,
30
+ repositories: options.scope?.repositories,
31
+ "repository_ids": options.scope?.repositoryIds,
32
+ });
33
+ const now = yield* Clock.currentTimeMillis;
34
+ return { ...access, timeToLive: Math.max(0, access.expiresAt.getTime() - now - 300_000) };
35
+ });
36
+ const cache = yield* Cache.makeWith((_) => exchange, {
37
+ capacity: 1,
38
+ timeToLive: (exit) => (Exit.isSuccess(exit) ? exit.value.timeToLive : 0),
39
+ });
40
+ return Context.make(GitHubToken, Effect.map(Cache.get(cache, undefined), ({ token }) => Option.some(token))).pipe(Context.add(TokenRefresh, (rejected) => Cache.invalidateWhen(cache, undefined, ({ token }) => Option.isSome(rejected) && token === rejected.value)));
41
+ }));
42
+ }
43
+ function appRequests(client, apiUrl) {
44
+ const scoped = HttpClient.withScope(client);
45
+ const rates = rateLimits();
46
+ return Effect.fnUntraced(function* (method, path, jwt, schema, body) {
47
+ let input = HttpClientRequest.make(method)(new URL(path, apiUrl).href, {
48
+ headers: { Accept: "application/vnd.github+json" },
49
+ });
50
+ if (body !== undefined) {
51
+ input = yield* HttpClientRequest.bodyJson(input, body).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: "encode" }, { cause })));
52
+ }
53
+ const response = yield* authenticatedRequest(scoped, Option.some(jwt), rates)(input).pipe(Effect.mapError((cause) => {
54
+ if (cause._tag === "GitHubRateLimited") {
55
+ return cause;
56
+ }
57
+ return cause._tag === "GitHubTransportError"
58
+ ? new GitHubAppError({ reason: "transport" }, { cause: cause.cause })
59
+ : new GitHubAppError({ reason: "status", status: "status" in cause ? cause.status : 403 });
60
+ }));
61
+ return yield* readBoundedJson(response, 64 * 1024, schema).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: cause._tag === "HttpClientError" ? "transport" : "response" }, { cause })));
62
+ }, Effect.scoped);
63
+ }
64
+ //# sourceMappingURL=appTokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appTokens.js","sourceRoot":"","sources":["../src/appTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAiB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,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C,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,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AACnB,CAAC"}
@@ -11,6 +11,6 @@ export interface ArtifactArchiveOptions {
11
11
  readonly repo: string;
12
12
  }
13
13
  export declare function artifacts(apiUrl: string, client: HttpClient.HttpClient, token: GitHubToken["Service"], rates: RateLimits, refresh?: typeof TokenRefresh.Service): {
14
- downloadArtifactArchive: (options: ArtifactArchiveOptions) => Effect.Effect<Uint8Array<ArrayBuffer>, import("./errors.ts").GitHubAppError | GitHubArtifactError | GitHubArtifactTooLarge | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | GitHubTransportError | import("@shivaedev/http/errors.ts").RemoteHttpError | import("@shivaedev/http/errors.ts").RemoteRateLimited | import("@shivaedev/http/errors.ts").RemoteUnauthorized | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge, never>;
14
+ downloadArtifactArchive: (options: ArtifactArchiveOptions) => Effect.Effect<Uint8Array<ArrayBuffer>, import("./errors.ts").GitHubAppError | GitHubArtifactError | GitHubArtifactTooLarge | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").RemoteHttpError | import("@shivaedev/http/errors.ts").RemoteRateLimited | import("@shivaedev/http/errors.ts").RemoteUnauthorized | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge, never>;
15
15
  };
16
16
  //# sourceMappingURL=artifacts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"artifacts.d.ts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AAE,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) => new GitHubTransportError({ path }, { 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 })),
@@ -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,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAYhG,MAAM,UAAU,SAAS,CACxB,MAAc,EACd,MAA6B,EAC7B,KAA6B,EAC7B,KAAiB,EACjB,OAAO,GAAgC,SAAS;IAEhD,MAAM,IAAI,GAAG,oBAAoB,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,E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CAAC;YACD,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,QAAQ,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"}
@@ -4,5 +4,5 @@ import { GitHubTransportError } from "./errors.ts";
4
4
  import type { GitHubToken } from "./GitHubToken.ts";
5
5
  import { type RateLimits } from "./rateLimits.ts";
6
6
  import type { TokenRefresh } from "./TokenRefresh.ts";
7
- export declare function authenticatedRequest<R>(client: HttpClient.HttpClient.With<HttpClientError.HttpClientError, R>, token: GitHubToken["Service"], rates: RateLimits, refresh?: typeof TokenRefresh.Service): (input: HttpClientRequest.HttpClientRequest, mode?: "manual" | "revalidate" | undefined) => Effect.Effect<import("effect/http/HttpClientResponse").HttpClientResponse, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | GitHubTransportError | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, R>;
7
+ export declare function authenticatedRequest<R>(client: HttpClient.HttpClient.With<HttpClientError.HttpClientError, R>, token: GitHubToken["Service"], rates: RateLimits, refresh?: typeof TokenRefresh.Service): (input: HttpClientRequest.HttpClientRequest, mode?: "manual" | "revalidate" | undefined) => Effect.Effect<import("effect/http/HttpClientResponse").HttpClientResponse, import("./errors.ts").GitHubAppError | import("./errors.ts").GitHubConversationLocked | import("./errors.ts").GitHubPermissionDenied | import("./errors.ts").GitHubRateLimited | GitHubTransportError | import("@shivaedev/http/errors.ts").InvalidBodyLimit | import("@shivaedev/http/errors.ts").ResponseBodyTooLarge | import("@shivaedev/http/errors.ts").RemoteStatusError, R>;
8
8
  //# sourceMappingURL=authenticatedRequest.d.ts.map