@effected/github 0.31.0 → 0.32.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/CheckRun.js +24 -5
- package/index.d.ts +42 -2
- package/package.json +6 -6
package/CheckRun.js
CHANGED
|
@@ -3,7 +3,7 @@ import { GitHubError } from "./GitHubError.js";
|
|
|
3
3
|
import { numericId } from "./internal/ids.js";
|
|
4
4
|
import { unstubbed } from "./internal/unstubbed.js";
|
|
5
5
|
import { Repo } from "./Repo.js";
|
|
6
|
-
import { Cause, Context, DateTime, Effect, Exit, Layer, Option, Ref, Schema } from "effect";
|
|
6
|
+
import { Cause, Context, DateTime, Duration, Effect, Exit, Layer, Option, Ref, Schedule, Schema } from "effect";
|
|
7
7
|
|
|
8
8
|
// src/CheckRun.ts
|
|
9
9
|
/** How a check run finished. @public */
|
|
@@ -369,6 +369,23 @@ const refOf = (operation, raw) => decodeRef(!isRecord(raw) ? raw : {
|
|
|
369
369
|
annotationsCount: output.annotations_count
|
|
370
370
|
})) } : {}
|
|
371
371
|
}).pipe(Effect.catchTag("SchemaError", (error) => Effect.fail(GitHubError.decode(operation, "GitHub returned an unexpected check run", error))));
|
|
372
|
+
/**
|
|
373
|
+
* Retry a check-run PATCH that GitHub answered 404, three times over 1.75s.
|
|
374
|
+
*
|
|
375
|
+
* @remarks
|
|
376
|
+
* GitHub's checks API reads after writes from a replica, so a PATCH sent
|
|
377
|
+
* within about a second of the POST that created the run can 404 on a run
|
|
378
|
+
* that exists. The client's `RetryPolicy` never retries a 404, rightly
|
|
379
|
+
* for every other route, so this one is scoped to the two check-run PATCH
|
|
380
|
+
* routes. The waits (250ms, 500ms, 1s) run on `Clock`, so `TestClock` drives
|
|
381
|
+
* them, and a genuinely wrong id still fails with its original 404, 1.75s
|
|
382
|
+
* later.
|
|
383
|
+
*/
|
|
384
|
+
const retryStaleNotFound = (self) => Effect.retry(self, {
|
|
385
|
+
schedule: Schedule.exponential(Duration.millis(250)),
|
|
386
|
+
times: 3,
|
|
387
|
+
while: (error) => error.kind === "notFound"
|
|
388
|
+
});
|
|
372
389
|
/** The current time as GitHub's ISO 8601 timestamp, from `Clock` so `TestClock` drives it. */
|
|
373
390
|
const isoNow = Effect.map(DateTime.now, DateTime.formatIso);
|
|
374
391
|
const make = (client) => {
|
|
@@ -412,7 +429,7 @@ const make = (client) => {
|
|
|
412
429
|
id,
|
|
413
430
|
conclusion
|
|
414
431
|
});
|
|
415
|
-
|
|
432
|
+
const body = {
|
|
416
433
|
owner,
|
|
417
434
|
repo,
|
|
418
435
|
check_run_id: id,
|
|
@@ -421,7 +438,8 @@ const make = (client) => {
|
|
|
421
438
|
completed_at: yield* isoNow,
|
|
422
439
|
...output !== void 0 ? { output: wireOutput(output) } : {},
|
|
423
440
|
...options?.detailsUrl !== void 0 ? { details_url: options.detailsUrl } : {}
|
|
424
|
-
}
|
|
441
|
+
};
|
|
442
|
+
return yield* retryStaleNotFound(client.request("PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}", body));
|
|
425
443
|
});
|
|
426
444
|
const complete = Effect.fn("CheckRun.complete")(function* (id, conclusion, output, options) {
|
|
427
445
|
yield* completePatch(id, conclusion, output, options);
|
|
@@ -437,7 +455,7 @@ const make = (client) => {
|
|
|
437
455
|
repo,
|
|
438
456
|
id
|
|
439
457
|
});
|
|
440
|
-
|
|
458
|
+
const body = {
|
|
441
459
|
owner,
|
|
442
460
|
repo,
|
|
443
461
|
check_run_id: id,
|
|
@@ -445,7 +463,8 @@ const make = (client) => {
|
|
|
445
463
|
...options?.status !== void 0 ? { status: options.status } : {},
|
|
446
464
|
...options?.status === "in_progress" ? { started_at: yield* isoNow } : {},
|
|
447
465
|
...options?.detailsUrl !== void 0 ? { details_url: options.detailsUrl } : {}
|
|
448
|
-
}
|
|
466
|
+
};
|
|
467
|
+
return yield* retryStaleNotFound(client.request("PATCH /repos/{owner}/{repo}/check-runs/{check_run_id}", body));
|
|
449
468
|
});
|
|
450
469
|
return {
|
|
451
470
|
create,
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed GitHub REST and GraphQL for Effect: a route-keyed client, one error
|
|
3
|
+
* taxonomy, GitHub App auth, and one resource service per GitHub noun.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* `GitHubClient.request` types both the parameters and the returned `data` from
|
|
7
|
+
* the route literal. Every REST failure is a `GitHubError` whose `kind` you
|
|
8
|
+
* branch on. Resource services (`GitBranch`, `GitTag`, `CheckRun`,
|
|
9
|
+
* `PullRequest`, `GitHubRelease` and others) turn multi-call sequences into one
|
|
10
|
+
* call, and a configuration tier writes secrets, variables, rulesets,
|
|
11
|
+
* deployment environments and security settings. `GitHubApp` mints and revokes
|
|
12
|
+
* installation tokens, `AuthenticatedApp` reads the app itself and its webhook
|
|
13
|
+
* deliveries, and `GitHubUserAuth` runs the OAuth web flow an app uses to act
|
|
14
|
+
* as a user.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { GitHubClient } from "@effected/github";
|
|
19
|
+
* import { Effect } from "effect";
|
|
20
|
+
*
|
|
21
|
+
* const program = Effect.gen(function* () {
|
|
22
|
+
* const client = yield* GitHubClient;
|
|
23
|
+
* const repo = yield* client.request("GET /repos/{owner}/{repo}", { owner: "effect-ts", repo: "effect" });
|
|
24
|
+
* return repo.default_branch;
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // GITHUB_TOKEN is read through the ambient ConfigProvider.
|
|
28
|
+
* Effect.runPromise(program.pipe(Effect.provide(GitHubClient.layerFromConfig())));
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @packageDocumentation
|
|
32
|
+
*/
|
|
1
33
|
import { BareLineReference, CLOSING_KEYWORDS, ClosingKeyword, IssueReference, harvestIssueReferences, parseBareLineReference } from "@effected/github-references";
|
|
2
34
|
import { JwksResolver, JwtError } from "@effected/jwt";
|
|
3
35
|
import { Cause, Config, Context, Duration, Effect, Layer, Option, Redacted, Result, Schedule, Schema, Scope, Stream } from "effect";
|
|
@@ -2085,8 +2117,11 @@ interface CheckRunShape {
|
|
|
2085
2117
|
*
|
|
2086
2118
|
* `update(id)` with neither still sends **one** PATCH, carrying nothing but
|
|
2087
2119
|
* the run's coordinates. GitHub accepts it and changes nothing; it is not
|
|
2088
|
-
* skipped, so every call is
|
|
2089
|
-
*
|
|
2120
|
+
* skipped, so every call is one request and a caller's error handling sees
|
|
2121
|
+
* a missing run or a revoked token the same way either way.
|
|
2122
|
+
*
|
|
2123
|
+
* A 404 is retried three times over 1.75s, as for `complete`: GitHub can
|
|
2124
|
+
* answer 404 for a run created moments earlier.
|
|
2090
2125
|
*/
|
|
2091
2126
|
readonly update: (id: number, output?: CheckRunOutput, options?: UpdateCheckRunOptions) => Effect.Effect<void, GitHubError, Repo>;
|
|
2092
2127
|
/**
|
|
@@ -2133,6 +2168,11 @@ interface CheckRunShape {
|
|
|
2133
2168
|
* rendered output; a given output is cut to GitHub's byte limits first.
|
|
2134
2169
|
* `options.detailsUrl` points the finished run somewhere, such as the
|
|
2135
2170
|
* workflow run that produced it.
|
|
2171
|
+
*
|
|
2172
|
+
* A 404 is retried three times over 1.75s (on `Clock`) before it fails:
|
|
2173
|
+
* GitHub's checks API can answer 404 for a run created moments earlier.
|
|
2174
|
+
* Every other failure follows the client's retry policy. A retry resends
|
|
2175
|
+
* the first attempt's `completed_at`.
|
|
2136
2176
|
*/
|
|
2137
2177
|
readonly complete: (id: number, conclusion: (typeof CheckConclusion.literals)[number], output?: CheckRunOutput, options?: CompleteCheckRunOptions) => Effect.Effect<void, GitHubError, Repo>;
|
|
2138
2178
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effected/github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Typed GitHub REST and GraphQL services over the octokit core request surface, with app auth and resource helpers.",
|
|
6
6
|
"keywords": [
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"./package.json": "./package.json"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@effected/crypto": "^0.
|
|
42
|
-
"@effected/github-references": "^0.
|
|
43
|
-
"@effected/jwt": "^0.
|
|
44
|
-
"@effected/oidc": "^0.
|
|
45
|
-
"@effected/semver": "^0.
|
|
41
|
+
"@effected/crypto": "^0.7.0",
|
|
42
|
+
"@effected/github-references": "^0.15.0",
|
|
43
|
+
"@effected/jwt": "^0.10.0",
|
|
44
|
+
"@effected/oidc": "^0.5.0",
|
|
45
|
+
"@effected/semver": "^0.24.0",
|
|
46
46
|
"@octokit/core": "^7.0.6",
|
|
47
47
|
"@octokit/plugin-paginate-rest": "^16.0.0",
|
|
48
48
|
"@octokit/types": "^18.0.0",
|