@effected/github 0.23.0 → 0.24.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.
- package/ActionsOidc.js +17 -4
- package/ArtifactMetadata.js +4 -5
- package/Attestation.js +5 -6
- package/AuthenticatedApp.js +8 -9
- package/CheckRun.js +12 -13
- package/CodeScanning.js +5 -6
- package/DeploymentEnvironment.js +6 -7
- package/GitBranch.js +11 -12
- package/GitCommit.js +7 -8
- package/GitHubApp.js +9 -10
- package/GitHubClient.js +42 -11
- package/GitHubCommit.js +7 -8
- package/GitHubContent.js +5 -6
- package/GitHubIssue.js +10 -11
- package/GitHubRelease.js +10 -11
- package/GitHubRepository.js +10 -10
- package/GitTag.js +9 -10
- package/InstallationTokenStore.js +5 -3
- package/PullRequest.js +14 -15
- package/PullRequestComment.js +7 -8
- package/RepositorySecret.js +9 -10
- package/RepositorySecurity.js +9 -10
- package/RepositoryVariable.js +9 -10
- package/Ruleset.js +8 -9
- package/WorkflowDispatch.js +10 -10
- package/index.d.ts +36 -34
- package/internal/unstubbed.js +25 -0
- package/package.json +4 -4
package/ActionsOidc.js
CHANGED
|
@@ -191,10 +191,23 @@ const testClaims = (overrides = {}) => ({
|
|
|
191
191
|
*
|
|
192
192
|
* @public
|
|
193
193
|
*/
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
var ActionsOidc = class {
|
|
195
|
+
constructor() {}
|
|
196
|
+
/** The Actions OIDC issuer, `https://token.actions.githubusercontent.com`. */
|
|
197
|
+
static issuer = ISSUER;
|
|
198
|
+
/** Verify a runner-issued OIDC token: signature against GitHub's JWKS, iss, aud, exp/nbf, then typed claims. */
|
|
199
|
+
static verify = verify;
|
|
200
|
+
/**
|
|
201
|
+
* A valid claims payload for tests, overridable field by field.
|
|
202
|
+
*
|
|
203
|
+
* @remarks
|
|
204
|
+
* Wire-shaped (snake_case keys, string ids) and complete except for the
|
|
205
|
+
* time claims `iat` and `exp`, which depend on the clock: a signer stamps
|
|
206
|
+
* them, as `TestIssuer.sign` from `@effected/jwt/testing` does. `iss` is
|
|
207
|
+
* {@link ActionsOidc.issuer}; `aud` is a placeholder to override with the
|
|
208
|
+
* audience under test.
|
|
209
|
+
*/
|
|
210
|
+
static testClaims = testClaims;
|
|
198
211
|
};
|
|
199
212
|
|
|
200
213
|
export { ActionsOidc, ActionsOidcClaims, ActionsOidcClaimsFromWire };
|
package/ArtifactMetadata.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
1
2
|
import { GitHubClient } from "./GitHubClient.js";
|
|
2
3
|
import { Repo } from "./Repo.js";
|
|
3
4
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
@@ -37,14 +38,12 @@ var StorageRecordInput = class extends Schema.Class("StorageRecordInput")({
|
|
|
37
38
|
var ArtifactMetadata = class ArtifactMetadata extends Context.Service()("@effected/github/ArtifactMetadata") {
|
|
38
39
|
/** The live service, built over a `GitHubClient`. */
|
|
39
40
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
40
|
-
/** An in-memory double; unstubbed
|
|
41
|
-
static makeTest = (overrides = {}) => ({ createStorageRecord: overrides.createStorageRecord ?? (() =>
|
|
41
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
42
|
+
static makeTest = (overrides = {}) => ({ createStorageRecord: overrides.createStorageRecord ?? (() => dies("createStorageRecord")) });
|
|
42
43
|
/** {@link ArtifactMetadata.makeTest} behind a `Layer`. */
|
|
43
44
|
static layerTest = (overrides = {}) => Layer.succeed(ArtifactMetadata, ArtifactMetadata.makeTest(overrides));
|
|
44
45
|
};
|
|
45
|
-
const
|
|
46
|
-
throw new Error(`ArtifactMetadata.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
47
|
-
};
|
|
46
|
+
const dies = unstubbed("ArtifactMetadata.makeTest");
|
|
48
47
|
const make = (client) => ({ createStorageRecord: Effect.fn("ArtifactMetadata.createStorageRecord")(function* (input) {
|
|
49
48
|
const { owner } = yield* Repo;
|
|
50
49
|
yield* Effect.annotateCurrentSpan({
|
package/Attestation.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
1
2
|
import { GitHubClient } from "./GitHubClient.js";
|
|
2
3
|
import { Repo } from "./Repo.js";
|
|
3
4
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
@@ -54,17 +55,15 @@ const ListResponse = Schema.Struct({ attestations: Schema.optionalKey(Schema.Arr
|
|
|
54
55
|
var Attestation = class Attestation extends Context.Service()("@effected/github/Attestation") {
|
|
55
56
|
/** The live service, built over a `GitHubClient`. */
|
|
56
57
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
57
|
-
/** An in-memory double; unstubbed
|
|
58
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
58
59
|
static makeTest = (overrides = {}) => ({
|
|
59
|
-
upload: overrides.upload ?? (() =>
|
|
60
|
-
listForSubject: overrides.listForSubject ?? (() =>
|
|
60
|
+
upload: overrides.upload ?? (() => dies("upload")),
|
|
61
|
+
listForSubject: overrides.listForSubject ?? (() => dies("listForSubject"))
|
|
61
62
|
});
|
|
62
63
|
/** {@link Attestation.makeTest} behind a `Layer`. */
|
|
63
64
|
static layerTest = (overrides = {}) => Layer.succeed(Attestation, Attestation.makeTest(overrides));
|
|
64
65
|
};
|
|
65
|
-
const
|
|
66
|
-
throw new Error(`Attestation.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
67
|
-
};
|
|
66
|
+
const dies = unstubbed("Attestation.makeTest");
|
|
68
67
|
const make = (client) => ({
|
|
69
68
|
upload: Effect.fn("Attestation.upload")(function* (bundle) {
|
|
70
69
|
const { owner, repo } = yield* Repo;
|
package/AuthenticatedApp.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GitHubError } from "./GitHubError.js";
|
|
2
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
2
3
|
import { GitHubClient } from "./GitHubClient.js";
|
|
3
4
|
import { numericId } from "./internal/ids.js";
|
|
4
5
|
import { Context, Effect, Layer, Schema, Stream } from "effect";
|
|
@@ -118,20 +119,18 @@ var DeliveryAttempt = class extends Schema.Class("DeliveryAttempt")({
|
|
|
118
119
|
var AuthenticatedApp = class AuthenticatedApp extends Context.Service()("@effected/github/AuthenticatedApp") {
|
|
119
120
|
/** The live service, built over an App-JWT `GitHubClient`. */
|
|
120
121
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
121
|
-
/** An in-memory double; unstubbed
|
|
122
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
122
123
|
static makeTest = (overrides = {}) => ({
|
|
123
|
-
get: overrides.get ?? (() =>
|
|
124
|
-
deliveries: overrides.deliveries ?? (() =>
|
|
125
|
-
delivery: overrides.delivery ?? (() =>
|
|
126
|
-
redeliver: overrides.redeliver ?? (() =>
|
|
127
|
-
uninstall: overrides.uninstall ?? (() =>
|
|
124
|
+
get: overrides.get ?? (() => dies("get")),
|
|
125
|
+
deliveries: overrides.deliveries ?? (() => Stream.fromEffect(dies("deliveries"))),
|
|
126
|
+
delivery: overrides.delivery ?? (() => dies("delivery")),
|
|
127
|
+
redeliver: overrides.redeliver ?? (() => dies("redeliver")),
|
|
128
|
+
uninstall: overrides.uninstall ?? (() => dies("uninstall"))
|
|
128
129
|
});
|
|
129
130
|
/** {@link AuthenticatedApp.makeTest} behind a `Layer`. */
|
|
130
131
|
static layerTest = (overrides = {}) => Layer.succeed(AuthenticatedApp, AuthenticatedApp.makeTest(overrides));
|
|
131
132
|
};
|
|
132
|
-
const
|
|
133
|
-
throw new Error(`AuthenticatedApp.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
134
|
-
};
|
|
133
|
+
const dies = unstubbed("AuthenticatedApp.makeTest");
|
|
135
134
|
const decodeDelivery = Schema.decodeUnknownEffect(DeliveryAttempt);
|
|
136
135
|
const decodeApp = Schema.decodeUnknownEffect(AppInfo);
|
|
137
136
|
/** A nullable int64 id, narrowed like every other id. */
|
package/CheckRun.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GitHubError } from "./GitHubError.js";
|
|
2
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
2
3
|
import { GitHubClient } from "./GitHubClient.js";
|
|
3
4
|
import { Repo } from "./Repo.js";
|
|
4
5
|
import { numericId } from "./internal/ids.js";
|
|
@@ -239,24 +240,22 @@ var CheckRunRef = class extends Schema.Class("CheckRunRef")({
|
|
|
239
240
|
var CheckRun = class CheckRun extends Context.Service()("@effected/github/CheckRun") {
|
|
240
241
|
/** The live service, built over a `GitHubClient`. */
|
|
241
242
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
242
|
-
/** An in-memory double; unstubbed
|
|
243
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
243
244
|
static makeTest = (overrides = {}) => ({
|
|
244
|
-
create: overrides.create ?? (() =>
|
|
245
|
-
get: overrides.get ?? (() =>
|
|
246
|
-
update: overrides.update ?? (() =>
|
|
247
|
-
updateRef: overrides.updateRef ?? (() =>
|
|
248
|
-
list: overrides.list ?? (() =>
|
|
249
|
-
findByExternalId: overrides.findByExternalId ?? (() =>
|
|
250
|
-
complete: overrides.complete ?? (() =>
|
|
251
|
-
completeRef: overrides.completeRef ?? (() =>
|
|
252
|
-
withCheckRun: overrides.withCheckRun ?? (() =>
|
|
245
|
+
create: overrides.create ?? (() => dies("create")),
|
|
246
|
+
get: overrides.get ?? (() => dies("get")),
|
|
247
|
+
update: overrides.update ?? (() => dies("update")),
|
|
248
|
+
updateRef: overrides.updateRef ?? (() => dies("updateRef")),
|
|
249
|
+
list: overrides.list ?? (() => dies("list")),
|
|
250
|
+
findByExternalId: overrides.findByExternalId ?? (() => dies("findByExternalId")),
|
|
251
|
+
complete: overrides.complete ?? (() => dies("complete")),
|
|
252
|
+
completeRef: overrides.completeRef ?? (() => dies("completeRef")),
|
|
253
|
+
withCheckRun: overrides.withCheckRun ?? (() => dies("withCheckRun"))
|
|
253
254
|
});
|
|
254
255
|
/** {@link CheckRun.makeTest} behind a `Layer`. */
|
|
255
256
|
static layerTest = (overrides = {}) => Layer.succeed(CheckRun, CheckRun.makeTest(overrides));
|
|
256
257
|
};
|
|
257
|
-
const
|
|
258
|
-
throw new Error(`CheckRun.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
259
|
-
};
|
|
258
|
+
const dies = unstubbed("CheckRun.makeTest");
|
|
260
259
|
const wireOutput = (output) => {
|
|
261
260
|
const capped = output.truncated();
|
|
262
261
|
return {
|
package/CodeScanning.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
1
2
|
import { GitHubClient } from "./GitHubClient.js";
|
|
2
3
|
import { Repo } from "./Repo.js";
|
|
3
4
|
import { Context, Effect, Layer } from "effect";
|
|
@@ -25,17 +26,15 @@ var CodeScanning = class CodeScanning extends Context.Service()("@effected/githu
|
|
|
25
26
|
* with a clean typecheck.
|
|
26
27
|
*/
|
|
27
28
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
28
|
-
/** An in-memory double; unstubbed
|
|
29
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
29
30
|
static makeTest = (overrides = {}) => ({
|
|
30
|
-
configure: overrides.configure ?? (() =>
|
|
31
|
-
languages: overrides.languages ?? (() =>
|
|
31
|
+
configure: overrides.configure ?? (() => dies("configure")),
|
|
32
|
+
languages: overrides.languages ?? (() => dies("languages"))
|
|
32
33
|
});
|
|
33
34
|
/** {@link CodeScanning.makeTest} behind a `Layer`. */
|
|
34
35
|
static layerTest = (overrides = {}) => Layer.succeed(CodeScanning, CodeScanning.makeTest(overrides));
|
|
35
36
|
};
|
|
36
|
-
const
|
|
37
|
-
throw new Error(`CodeScanning.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
38
|
-
};
|
|
37
|
+
const dies = unstubbed("CodeScanning.makeTest");
|
|
39
38
|
const SETUP_KEYS = [
|
|
40
39
|
"state",
|
|
41
40
|
"languages",
|
package/DeploymentEnvironment.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
1
2
|
import { GitHubClient } from "./GitHubClient.js";
|
|
2
3
|
import { Repo } from "./Repo.js";
|
|
3
4
|
import { Context, Effect, Layer } from "effect";
|
|
@@ -34,18 +35,16 @@ var DeploymentEnvironment = class DeploymentEnvironment extends Context.Service(
|
|
|
34
35
|
* further down throws at import time with a clean typecheck.
|
|
35
36
|
*/
|
|
36
37
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
37
|
-
/** An in-memory double; unstubbed
|
|
38
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
38
39
|
static makeTest = (overrides = {}) => ({
|
|
39
|
-
upsert: overrides.upsert ?? (() =>
|
|
40
|
-
list: overrides.list ?? (() =>
|
|
41
|
-
delete: overrides.delete ?? (() =>
|
|
40
|
+
upsert: overrides.upsert ?? (() => dies("upsert")),
|
|
41
|
+
list: overrides.list ?? (() => dies("list")),
|
|
42
|
+
delete: overrides.delete ?? (() => dies("delete"))
|
|
42
43
|
});
|
|
43
44
|
/** {@link DeploymentEnvironment.makeTest} behind a `Layer`. */
|
|
44
45
|
static layerTest = (overrides = {}) => Layer.succeed(DeploymentEnvironment, DeploymentEnvironment.makeTest(overrides));
|
|
45
46
|
};
|
|
46
|
-
const
|
|
47
|
-
throw new Error(`DeploymentEnvironment.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
48
|
-
};
|
|
47
|
+
const dies = unstubbed("DeploymentEnvironment.makeTest");
|
|
49
48
|
const make = (client) => {
|
|
50
49
|
return {
|
|
51
50
|
upsert: Effect.fn("DeploymentEnvironment.upsert")(function* (name, config = {}) {
|
package/GitBranch.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GitHubError } from "./GitHubError.js";
|
|
2
2
|
import { GraphQLDocument } from "./GraphQL.js";
|
|
3
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
3
4
|
import { GitHubClient } from "./GitHubClient.js";
|
|
4
5
|
import { Repo } from "./Repo.js";
|
|
5
6
|
import { Context, Effect, Layer, Option, Schema } from "effect";
|
|
@@ -50,23 +51,21 @@ var GitBranch = class GitBranch extends Context.Service()("@effected/github/GitB
|
|
|
50
51
|
* layer is built.
|
|
51
52
|
*/
|
|
52
53
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
53
|
-
/** An in-memory double; unstubbed
|
|
54
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
54
55
|
static makeTest = (overrides = {}) => ({
|
|
55
|
-
create: overrides.create ?? (() =>
|
|
56
|
-
upsert: overrides.upsert ?? (() =>
|
|
57
|
-
exists: overrides.exists ?? (() =>
|
|
58
|
-
sha: overrides.sha ?? (() =>
|
|
59
|
-
shaOption: overrides.shaOption ?? (() =>
|
|
60
|
-
reset: overrides.reset ?? (() =>
|
|
61
|
-
delete: overrides.delete ?? (() =>
|
|
62
|
-
createLinked: overrides.createLinked ?? (() =>
|
|
56
|
+
create: overrides.create ?? (() => dies("create")),
|
|
57
|
+
upsert: overrides.upsert ?? (() => dies("upsert")),
|
|
58
|
+
exists: overrides.exists ?? (() => dies("exists")),
|
|
59
|
+
sha: overrides.sha ?? (() => dies("sha")),
|
|
60
|
+
shaOption: overrides.shaOption ?? (() => dies("shaOption")),
|
|
61
|
+
reset: overrides.reset ?? (() => dies("reset")),
|
|
62
|
+
delete: overrides.delete ?? (() => dies("delete")),
|
|
63
|
+
createLinked: overrides.createLinked ?? (() => dies("createLinked"))
|
|
63
64
|
});
|
|
64
65
|
/** {@link GitBranch.makeTest} behind a `Layer`. */
|
|
65
66
|
static layerTest = (overrides = {}) => Layer.succeed(GitBranch, GitBranch.makeTest(overrides));
|
|
66
67
|
};
|
|
67
|
-
const
|
|
68
|
-
throw new Error(`GitBranch.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
69
|
-
};
|
|
68
|
+
const dies = unstubbed("GitBranch.makeTest");
|
|
70
69
|
/**
|
|
71
70
|
* `main`, `refs/heads/main` and `heads/main` all name the same branch.
|
|
72
71
|
*
|
package/GitCommit.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
1
2
|
import { GitHubClient } from "./GitHubClient.js";
|
|
2
3
|
import { Repo } from "./Repo.js";
|
|
3
4
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
@@ -86,19 +87,17 @@ var CommitRef = class extends Schema.Class("CommitRef")({
|
|
|
86
87
|
var GitCommit = class GitCommit extends Context.Service()("@effected/github/GitCommit") {
|
|
87
88
|
/** The live service, built over a `GitHubClient`. */
|
|
88
89
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
89
|
-
/** An in-memory double; unstubbed
|
|
90
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
90
91
|
static makeTest = (overrides = {}) => ({
|
|
91
|
-
get: overrides.get ?? (() =>
|
|
92
|
-
createTree: overrides.createTree ?? (() =>
|
|
93
|
-
createCommit: overrides.createCommit ?? (() =>
|
|
94
|
-
commitFiles: overrides.commitFiles ?? (() =>
|
|
92
|
+
get: overrides.get ?? (() => dies("get")),
|
|
93
|
+
createTree: overrides.createTree ?? (() => dies("createTree")),
|
|
94
|
+
createCommit: overrides.createCommit ?? (() => dies("createCommit")),
|
|
95
|
+
commitFiles: overrides.commitFiles ?? (() => dies("commitFiles"))
|
|
95
96
|
});
|
|
96
97
|
/** {@link GitCommit.makeTest} behind a `Layer`. */
|
|
97
98
|
static layerTest = (overrides = {}) => Layer.succeed(GitCommit, GitCommit.makeTest(overrides));
|
|
98
99
|
};
|
|
99
|
-
const
|
|
100
|
-
throw new Error(`GitCommit.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
101
|
-
};
|
|
100
|
+
const dies = unstubbed("GitCommit.makeTest");
|
|
102
101
|
/** The Git Database tree entry for one change. */
|
|
103
102
|
const treeEntry = (change) => change._tag === "FileContent" ? {
|
|
104
103
|
path: change.path,
|
package/GitHubApp.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GitHubError } from "./GitHubError.js";
|
|
2
2
|
import { GitHubGraphQLError } from "./GraphQL.js";
|
|
3
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
3
4
|
import { GitHubClient, makeClientShape } from "./GitHubClient.js";
|
|
4
5
|
import { numericId } from "./internal/ids.js";
|
|
5
6
|
import { InstallationTokenStore } from "./InstallationTokenStore.js";
|
|
@@ -435,16 +436,16 @@ var GitHubApp = class GitHubApp extends Context.Service()("@effected/github/GitH
|
|
|
435
436
|
...options,
|
|
436
437
|
token: cached.token.token
|
|
437
438
|
})));
|
|
438
|
-
/** An in-memory double; unstubbed
|
|
439
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
439
440
|
static makeTest = (overrides = {}) => {
|
|
440
|
-
const token = overrides.token ?? (() =>
|
|
441
|
+
const token = overrides.token ?? (() => dies("token"));
|
|
441
442
|
return {
|
|
442
443
|
token,
|
|
443
|
-
scopedToken: overrides.scopedToken ?? (() =>
|
|
444
|
-
revoke: overrides.revoke ?? (() =>
|
|
445
|
-
identity: overrides.identity ?? (() =>
|
|
446
|
-
botUser: overrides.botUser ?? (() =>
|
|
447
|
-
installations: overrides.installations ?? (() =>
|
|
444
|
+
scopedToken: overrides.scopedToken ?? (() => dies("scopedToken")),
|
|
445
|
+
revoke: overrides.revoke ?? (() => dies("revoke")),
|
|
446
|
+
identity: overrides.identity ?? (() => dies("identity")),
|
|
447
|
+
botUser: overrides.botUser ?? (() => dies("botUser")),
|
|
448
|
+
installations: overrides.installations ?? (() => dies("installations")),
|
|
448
449
|
cachedToken: overrides.cachedToken ?? makeCachedToken(token)
|
|
449
450
|
};
|
|
450
451
|
};
|
|
@@ -515,9 +516,7 @@ const makeCachedToken = (token) => {
|
|
|
515
516
|
};
|
|
516
517
|
});
|
|
517
518
|
};
|
|
518
|
-
const
|
|
519
|
-
throw new Error(`GitHubApp.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
520
|
-
};
|
|
519
|
+
const dies = unstubbed("GitHubApp.makeTest");
|
|
521
520
|
/** Mint an app JWT: iat 60 s in the past (clock drift), exp 9 minutes after now (GitHub caps at 10). */
|
|
522
521
|
const mintJwt = (credentials) => Effect.gen(function* () {
|
|
523
522
|
const key = yield* JwtKey.fromPkcs8Pem(credentials.privateKey, { alg: "RS256" });
|
package/GitHubClient.js
CHANGED
|
@@ -3,6 +3,7 @@ import { GitHubGraphQLError } from "./GraphQL.js";
|
|
|
3
3
|
import { RetryPolicy } from "./Resilience.js";
|
|
4
4
|
import { makeTransport } from "./internal/octokit.js";
|
|
5
5
|
import { fromArray, paginate } from "./internal/paginate.js";
|
|
6
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
6
7
|
import { Clock, Config, Context, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
7
8
|
|
|
8
9
|
// src/GitHubClient.ts
|
|
@@ -10,7 +11,7 @@ import { Clock, Config, Context, Effect, Layer, Option, Schema, Stream } from "e
|
|
|
10
11
|
const DEFAULT_PER_PAGE = 100;
|
|
11
12
|
/**
|
|
12
13
|
* A raw HTTP failure recorded for {@link GitHubClient.layerFixture}, made by
|
|
13
|
-
* {@link (GitHubFixtures:
|
|
14
|
+
* {@link (GitHubFixtures:class).failure}.
|
|
14
15
|
*
|
|
15
16
|
* @remarks
|
|
16
17
|
* Branded, so a fixture's data payload that happens to have a `status` and a
|
|
@@ -45,12 +46,42 @@ const isRawFailure = (value) => typeof value === "object" && value !== null && v
|
|
|
45
46
|
*
|
|
46
47
|
* @public
|
|
47
48
|
*/
|
|
48
|
-
|
|
49
|
+
var GitHubFixtures = class {
|
|
50
|
+
constructor() {}
|
|
51
|
+
/**
|
|
52
|
+
* A raw failure: what GitHub answered, classified at call time by the same
|
|
53
|
+
* classifier the live client uses.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* Record it wherever a fixture accepts a `GitHubError` (`request`, and so
|
|
57
|
+
* `requestDecoded`, and `paginate`). Each call fails with
|
|
58
|
+
* `GitHubError.fromResponse(route, response, now)`, `now` read from `Clock`,
|
|
59
|
+
* so a rate-limit reset header is measured against the `TestClock`. Prefer it
|
|
60
|
+
* to a hand-built `GitHubError` when the test is about GitHub's actual
|
|
61
|
+
* response: the classification is then the package's, not the test's.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { GitHubClient, GitHubFixtures } from "@effected/github";
|
|
66
|
+
*
|
|
67
|
+
* const layer = GitHubClient.layerFixture({
|
|
68
|
+
* request: {
|
|
69
|
+
* "POST /repos/{owner}/{repo}/releases": GitHubFixtures.failure({
|
|
70
|
+
* status: 422,
|
|
71
|
+
* body: {
|
|
72
|
+
* message: "Validation Failed",
|
|
73
|
+
* errors: [{ resource: "Release", code: "already_exists", field: "tag_name" }],
|
|
74
|
+
* },
|
|
75
|
+
* }),
|
|
76
|
+
* },
|
|
77
|
+
* });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
static failure = (response) => new RawFailure(response);
|
|
81
|
+
};
|
|
49
82
|
const resolvePolicy = (retry) => retry === void 0 ? RetryPolicy.default : retry === "off" ? RetryPolicy.none : retry;
|
|
50
83
|
const perPageOf = (options) => options?.perPage ?? DEFAULT_PER_PAGE;
|
|
51
|
-
const
|
|
52
|
-
throw new Error(`GitHubClient.makeTest: ${member}() was called but not stubbed — pass an override, or use GitHubClient.layerFixture for recorded responses.`);
|
|
53
|
-
};
|
|
84
|
+
const dies = unstubbed("GitHubClient.makeTest", "pass an override, or use GitHubClient.layerFixture for recorded responses.");
|
|
54
85
|
/**
|
|
55
86
|
* The typed GitHub API client.
|
|
56
87
|
*
|
|
@@ -127,11 +158,11 @@ var GitHubClient = class GitHubClient extends Context.Service()("@effected/githu
|
|
|
127
158
|
* {@link GitHubClient.layerFixture}.
|
|
128
159
|
*/
|
|
129
160
|
static makeTest = (overrides = {}) => ({
|
|
130
|
-
request: overrides.request ?? (() =>
|
|
131
|
-
requestDecoded: overrides.requestDecoded ?? (() =>
|
|
132
|
-
paginate: overrides.paginate ?? (() =>
|
|
133
|
-
paginateStream: overrides.paginateStream ?? (() =>
|
|
134
|
-
graphql: overrides.graphql ?? (() =>
|
|
161
|
+
request: overrides.request ?? (() => dies("request")),
|
|
162
|
+
requestDecoded: overrides.requestDecoded ?? (() => dies("requestDecoded")),
|
|
163
|
+
paginate: overrides.paginate ?? (() => dies("paginate")),
|
|
164
|
+
paginateStream: overrides.paginateStream ?? (() => Stream.fromEffect(dies("paginateStream"))),
|
|
165
|
+
graphql: overrides.graphql ?? (() => dies("graphql")),
|
|
135
166
|
rateLimit: overrides.rateLimit ?? Effect.succeed(Option.none())
|
|
136
167
|
});
|
|
137
168
|
/** {@link GitHubClient.makeTest} behind a `Layer`. */
|
|
@@ -150,7 +181,7 @@ var GitHubClient = class GitHubClient extends Context.Service()("@effected/githu
|
|
|
150
181
|
*
|
|
151
182
|
* **It records every call it serves, including one that fails.** A call
|
|
152
183
|
* answered by a recorded `GitHubError` or a
|
|
153
|
-
* {@link (GitHubFixtures:
|
|
184
|
+
* {@link (GitHubFixtures:class).failure} is recorded before it fails, so
|
|
154
185
|
* one fixture both records the calls and classifies a raw failure the way
|
|
155
186
|
* the live client would; there is no need to classify by hand inside a
|
|
156
187
|
* {@link GitHubClient.layerTest} handler.
|
package/GitHubCommit.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { paginate } from "./internal/paginate.js";
|
|
2
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
2
3
|
import { GitHubClient } from "./GitHubClient.js";
|
|
3
4
|
import { Repo } from "./Repo.js";
|
|
4
5
|
import { Context, Effect, Layer, Option, Schema, Stream } from "effect";
|
|
@@ -114,19 +115,17 @@ var CommitComparison = class extends Schema.Class("CommitComparison")({
|
|
|
114
115
|
var GitHubCommit = class GitHubCommit extends Context.Service()("@effected/github/GitHubCommit") {
|
|
115
116
|
/** The live service, built over a `GitHubClient`. */
|
|
116
117
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
117
|
-
/** An in-memory double; unstubbed
|
|
118
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
118
119
|
static makeTest = (overrides = {}) => ({
|
|
119
|
-
get: overrides.get ?? (() =>
|
|
120
|
-
list: overrides.list ?? (() =>
|
|
121
|
-
compare: overrides.compare ?? (() =>
|
|
122
|
-
changedFiles: overrides.changedFiles ?? (() =>
|
|
120
|
+
get: overrides.get ?? (() => dies("get")),
|
|
121
|
+
list: overrides.list ?? (() => dies("list")),
|
|
122
|
+
compare: overrides.compare ?? (() => dies("compare")),
|
|
123
|
+
changedFiles: overrides.changedFiles ?? (() => dies("changedFiles"))
|
|
123
124
|
});
|
|
124
125
|
/** {@link GitHubCommit.makeTest} behind a `Layer`. */
|
|
125
126
|
static layerTest = (overrides = {}) => Layer.succeed(GitHubCommit, GitHubCommit.makeTest(overrides));
|
|
126
127
|
};
|
|
127
|
-
const
|
|
128
|
-
throw new Error(`GitHubCommit.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
129
|
-
};
|
|
128
|
+
const dies = unstubbed("GitHubCommit.makeTest");
|
|
130
129
|
const summarize = (raw) => CommitSummary.make({
|
|
131
130
|
sha: raw.sha,
|
|
132
131
|
message: raw.commit.message,
|
package/GitHubContent.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GitHubError } from "./GitHubError.js";
|
|
2
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
2
3
|
import { GitHubClient } from "./GitHubClient.js";
|
|
3
4
|
import { Repo } from "./Repo.js";
|
|
4
5
|
import { Context, Effect, Layer, Option, Result } from "effect";
|
|
@@ -35,17 +36,15 @@ const utf8 = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
|
35
36
|
var GitHubContent = class GitHubContent extends Context.Service()("@effected/github/GitHubContent") {
|
|
36
37
|
/** The live service, built over a `GitHubClient`. */
|
|
37
38
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
38
|
-
/** An in-memory double; unstubbed
|
|
39
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
39
40
|
static makeTest = (overrides = {}) => ({
|
|
40
|
-
getFile: overrides.getFile ?? (() =>
|
|
41
|
-
getFileOption: overrides.getFileOption ?? (() =>
|
|
41
|
+
getFile: overrides.getFile ?? (() => dies("getFile")),
|
|
42
|
+
getFileOption: overrides.getFileOption ?? (() => dies("getFileOption"))
|
|
42
43
|
});
|
|
43
44
|
/** {@link GitHubContent.makeTest} behind a `Layer`. */
|
|
44
45
|
static layerTest = (overrides = {}) => Layer.succeed(GitHubContent, GitHubContent.makeTest(overrides));
|
|
45
46
|
};
|
|
46
|
-
const
|
|
47
|
-
throw new Error(`GitHubContent.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
48
|
-
};
|
|
47
|
+
const dies = unstubbed("GitHubContent.makeTest");
|
|
49
48
|
const make = (client) => {
|
|
50
49
|
const getFile = Effect.fn("GitHubContent.getFile")(function* (path, options) {
|
|
51
50
|
const { owner, repo } = yield* Repo;
|
package/GitHubIssue.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GraphQLDocument } from "./GraphQL.js";
|
|
2
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
2
3
|
import { GitHubClient } from "./GitHubClient.js";
|
|
3
4
|
import { Repo } from "./Repo.js";
|
|
4
5
|
import { numericId } from "./internal/ids.js";
|
|
@@ -127,22 +128,20 @@ const CrossReferencedDocument = GraphQLDocument.make({
|
|
|
127
128
|
var GitHubIssue = class GitHubIssue extends Context.Service()("@effected/github/GitHubIssue") {
|
|
128
129
|
/** The live service, built over a `GitHubClient`. */
|
|
129
130
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
130
|
-
/** An in-memory double; unstubbed
|
|
131
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
131
132
|
static makeTest = (overrides = {}) => ({
|
|
132
|
-
get: overrides.get ?? (() =>
|
|
133
|
-
list: overrides.list ?? (() =>
|
|
134
|
-
close: overrides.close ?? (() =>
|
|
135
|
-
comment: overrides.comment ?? (() =>
|
|
136
|
-
commentOnce: overrides.commentOnce ?? (() =>
|
|
137
|
-
linkedIssues: overrides.linkedIssues ?? (() =>
|
|
138
|
-
isCrossReferencedBy: overrides.isCrossReferencedBy ?? (() =>
|
|
133
|
+
get: overrides.get ?? (() => dies("get")),
|
|
134
|
+
list: overrides.list ?? (() => dies("list")),
|
|
135
|
+
close: overrides.close ?? (() => dies("close")),
|
|
136
|
+
comment: overrides.comment ?? (() => dies("comment")),
|
|
137
|
+
commentOnce: overrides.commentOnce ?? (() => dies("commentOnce")),
|
|
138
|
+
linkedIssues: overrides.linkedIssues ?? (() => dies("linkedIssues")),
|
|
139
|
+
isCrossReferencedBy: overrides.isCrossReferencedBy ?? (() => dies("isCrossReferencedBy"))
|
|
139
140
|
});
|
|
140
141
|
/** {@link GitHubIssue.makeTest} behind a `Layer`. */
|
|
141
142
|
static layerTest = (overrides = {}) => Layer.succeed(GitHubIssue, GitHubIssue.makeTest(overrides));
|
|
142
143
|
};
|
|
143
|
-
const
|
|
144
|
-
throw new Error(`GitHubIssue.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
145
|
-
};
|
|
144
|
+
const dies = unstubbed("GitHubIssue.makeTest");
|
|
146
145
|
/**
|
|
147
146
|
* The REST calendar version this module's requests pin.
|
|
148
147
|
*
|
package/GitHubRelease.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GitHubError } from "./GitHubError.js";
|
|
2
|
+
import { unstubbed } from "./internal/unstubbed.js";
|
|
2
3
|
import { GitHubClient } from "./GitHubClient.js";
|
|
3
4
|
import { Repo } from "./Repo.js";
|
|
4
5
|
import { Context, Effect, Layer, Option, Schema } from "effect";
|
|
@@ -59,22 +60,20 @@ var ReleaseAsset = class extends Schema.Class("ReleaseAsset")({
|
|
|
59
60
|
var GitHubRelease = class GitHubRelease extends Context.Service()("@effected/github/GitHubRelease") {
|
|
60
61
|
/** The live service, built over a `GitHubClient`. */
|
|
61
62
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
62
|
-
/** An in-memory double; unstubbed
|
|
63
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
63
64
|
static makeTest = (overrides = {}) => ({
|
|
64
|
-
create: overrides.create ?? (() =>
|
|
65
|
-
getByTag: overrides.getByTag ?? (() =>
|
|
66
|
-
getByTagOption: overrides.getByTagOption ?? (() =>
|
|
67
|
-
list: overrides.list ?? (() =>
|
|
68
|
-
update: overrides.update ?? (() =>
|
|
69
|
-
uploadAsset: overrides.uploadAsset ?? (() =>
|
|
70
|
-
listAssets: overrides.listAssets ?? (() =>
|
|
65
|
+
create: overrides.create ?? (() => dies("create")),
|
|
66
|
+
getByTag: overrides.getByTag ?? (() => dies("getByTag")),
|
|
67
|
+
getByTagOption: overrides.getByTagOption ?? (() => dies("getByTagOption")),
|
|
68
|
+
list: overrides.list ?? (() => dies("list")),
|
|
69
|
+
update: overrides.update ?? (() => dies("update")),
|
|
70
|
+
uploadAsset: overrides.uploadAsset ?? (() => dies("uploadAsset")),
|
|
71
|
+
listAssets: overrides.listAssets ?? (() => dies("listAssets"))
|
|
71
72
|
});
|
|
72
73
|
/** {@link GitHubRelease.makeTest} behind a `Layer`. */
|
|
73
74
|
static layerTest = (overrides = {}) => Layer.succeed(GitHubRelease, GitHubRelease.makeTest(overrides));
|
|
74
75
|
};
|
|
75
|
-
const
|
|
76
|
-
throw new Error(`GitHubRelease.makeTest: ${member}() was called but not stubbed — pass an override.`);
|
|
77
|
-
};
|
|
76
|
+
const dies = unstubbed("GitHubRelease.makeTest");
|
|
78
77
|
const project = (raw) => ReleaseInfo.make({
|
|
79
78
|
id: raw.id,
|
|
80
79
|
tag: raw.tag_name,
|
package/GitHubRepository.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GraphQLDocument } from "./GraphQL.js";
|
|
2
|
+
import { unstubbed, unstubbedRead } from "./internal/unstubbed.js";
|
|
2
3
|
import { GitHubClient } from "./GitHubClient.js";
|
|
3
4
|
import { Repo } from "./Repo.js";
|
|
4
5
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
@@ -195,21 +196,20 @@ const preparePatch = (patch) => {
|
|
|
195
196
|
var GitHubRepository = class GitHubRepository extends Context.Service()("@effected/github/GitHubRepository") {
|
|
196
197
|
/** The live service, built over a `GitHubClient`. */
|
|
197
198
|
static layer = Layer.effect(this, Effect.map(GitHubClient, (client) => make(client)));
|
|
198
|
-
/** An in-memory double; unstubbed
|
|
199
|
+
/** An in-memory double; an unstubbed member dies when run, naming itself. */
|
|
199
200
|
static makeTest = (overrides = {}) => ({
|
|
200
|
-
settings: overrides.settings ??
|
|
201
|
-
updateSettings: overrides.updateSettings ?? (() =>
|
|
202
|
-
defaultBranch: overrides.defaultBranch ??
|
|
203
|
-
nodeId: overrides.nodeId ??
|
|
204
|
-
ownerType: overrides.ownerType ??
|
|
205
|
-
applySettings: overrides.applySettings ?? (() =>
|
|
201
|
+
settings: overrides.settings ?? unread("settings"),
|
|
202
|
+
updateSettings: overrides.updateSettings ?? (() => dies("updateSettings")),
|
|
203
|
+
defaultBranch: overrides.defaultBranch ?? unread("defaultBranch"),
|
|
204
|
+
nodeId: overrides.nodeId ?? unread("nodeId"),
|
|
205
|
+
ownerType: overrides.ownerType ?? unread("ownerType"),
|
|
206
|
+
applySettings: overrides.applySettings ?? (() => dies("applySettings"))
|
|
206
207
|
});
|
|
207
208
|
/** {@link GitHubRepository.makeTest} behind a `Layer`. */
|
|
208
209
|
static layerTest = (overrides = {}) => Layer.succeed(GitHubRepository, GitHubRepository.makeTest(overrides));
|
|
209
210
|
};
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
};
|
|
211
|
+
const dies = unstubbed("GitHubRepository.makeTest");
|
|
212
|
+
const unread = unstubbedRead("GitHubRepository.makeTest");
|
|
213
213
|
const make = (client) => {
|
|
214
214
|
const settings = Effect.fn("GitHubRepository.settings")(function* () {
|
|
215
215
|
const { owner, repo } = yield* Repo;
|