@usine/github 0.1.2 → 0.2.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/README.md +31 -55
- package/dist/access.d.ts +30 -8
- package/dist/access.d.ts.map +1 -1
- package/dist/access.js +31 -8
- package/dist/access.js.map +1 -1
- package/dist/credentials.d.ts +6 -6
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +6 -6
- package/dist/credentials.js.map +1 -1
- package/dist/error.d.ts +28 -10
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +32 -7
- package/dist/error.js.map +1 -1
- package/dist/github-app.d.ts +12 -9
- package/dist/github-app.d.ts.map +1 -1
- package/dist/github-app.js +43 -29
- package/dist/github-app.js.map +1 -1
- package/dist/graphql.d.ts +11 -0
- package/dist/graphql.d.ts.map +1 -0
- package/dist/graphql.js +47 -0
- package/dist/graphql.js.map +1 -0
- package/dist/http.d.ts +9 -3
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +26 -8
- package/dist/http.js.map +1 -1
- package/dist/installation.d.ts +17 -9
- package/dist/installation.d.ts.map +1 -1
- package/dist/installation.js +17 -9
- package/dist/installation.js.map +1 -1
- package/dist/item-history.d.ts +57 -0
- package/dist/item-history.d.ts.map +1 -0
- package/dist/item-history.js +190 -0
- package/dist/item-history.js.map +1 -0
- package/dist/item-writer.d.ts +2 -2
- package/dist/item-writer.d.ts.map +1 -1
- package/dist/item-writer.js +1 -1
- package/dist/item-writer.js.map +1 -1
- package/dist/jwt.d.ts +3 -3
- package/dist/jwt.d.ts.map +1 -1
- package/dist/jwt.js +4 -4
- package/dist/jwt.js.map +1 -1
- package/dist/label-writer.d.ts +2 -2
- package/dist/label-writer.d.ts.map +1 -1
- package/dist/label-writer.js +2 -2
- package/dist/label-writer.js.map +1 -1
- package/dist/local-secrets.d.ts +2 -2
- package/dist/local-secrets.d.ts.map +1 -1
- package/dist/local-secrets.js +6 -6
- package/dist/local-secrets.js.map +1 -1
- package/dist/polling/content.js +2 -2
- package/dist/polling/detection.d.ts +9 -9
- package/dist/polling/detection.d.ts.map +1 -1
- package/dist/polling/detection.js +9 -9
- package/dist/polling/detection.js.map +1 -1
- package/dist/polling/labels.d.ts +5 -5
- package/dist/polling/labels.d.ts.map +1 -1
- package/dist/polling/labels.js +5 -5
- package/dist/polling/labels.js.map +1 -1
- package/dist/polling/payload.d.ts +10 -6
- package/dist/polling/payload.d.ts.map +1 -1
- package/dist/polling/payload.js +15 -11
- package/dist/polling/payload.js.map +1 -1
- package/dist/polling/polling.d.ts +18 -6
- package/dist/polling/polling.d.ts.map +1 -1
- package/dist/polling/polling.js +59 -52
- package/dist/polling/polling.js.map +1 -1
- package/dist/polling/queries.d.ts +6 -1
- package/dist/polling/queries.d.ts.map +1 -1
- package/dist/polling/queries.js +16 -0
- package/dist/polling/queries.js.map +1 -1
- package/package.json +8 -3
package/dist/github-app.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LoopPermissions } from "@usine/core/loop";
|
|
1
2
|
import { RepositoryName } from "@usine/core/repository";
|
|
2
3
|
import { Context, Effect, Layer } from "effect";
|
|
3
4
|
import { HttpClient } from "effect/unstable/http";
|
|
@@ -10,21 +11,23 @@ declare const GitHubApp_base: Context.ServiceClass<GitHubApp, "@usine/github/Git
|
|
|
10
11
|
readonly installation: () => Effect.Effect<Installation, GitHubAppError>;
|
|
11
12
|
/** Returns the shared installation-wide token for orchestrator operations, renewing it near expiry. */
|
|
12
13
|
readonly installationToken: () => Effect.Effect<InstallationToken, GitHubAppError>;
|
|
13
|
-
/**
|
|
14
|
+
/** Returns the access of every registry repository, with each uncovered Project as its own error. */
|
|
14
15
|
readonly projectAccess: (registry: ReadonlyArray<RepositoryName>) => Effect.Effect<ReadonlyArray<ProjectAccess>, GitHubAppError>;
|
|
15
|
-
/**
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Mints a new Worker token for the covered Project's repository, with the permissions
|
|
18
|
+
* `WORKER_TOKEN_PERMISSIONS` lists for the Loop permission level.
|
|
19
|
+
*/
|
|
20
|
+
readonly workerToken: (project: CoveredProject, permissions: LoopPermissions) => Effect.Effect<InstallationToken, GitHubAppError>;
|
|
17
21
|
}>;
|
|
18
22
|
/**
|
|
19
|
-
* The factory's GitHub identity and repository access.
|
|
20
|
-
*
|
|
21
|
-
* newly minted for the repository assigned to its Attempt.
|
|
23
|
+
* The factory's GitHub App identity and repository access. Orchestrator operations share an
|
|
24
|
+
* installation-wide token; each Worker token is minted for its Attempt's repository.
|
|
22
25
|
*/
|
|
23
26
|
export declare class GitHubApp extends GitHubApp_base {
|
|
24
27
|
static readonly layer: Layer.Layer<GitHubApp, AppAuthenticationError, GitHubCredentials | HttpClient.HttpClient>;
|
|
25
28
|
}
|
|
26
|
-
export { REQUIRED_REPOSITORY_PERMISSIONS, deriveProjectAccess, missingPermissions, type InstalledRepository, type RequiredRepositoryPermission, CoveredProject, ProjectNotInstalledError, ProjectAccess, AppPermissionError, } from "./access.ts";
|
|
29
|
+
export { REQUIRED_REPOSITORY_PERMISSIONS, WORKER_TOKEN_PERMISSIONS, deriveProjectAccess, missingPermissions, type InstalledRepository, type RequiredRepositoryPermission, CoveredProject, ProjectNotInstalledError, ProjectAccess, AppPermissionError, } from "./access.ts";
|
|
27
30
|
export { AppId, PrivateKey, RedactedPrivateKey, AppCredentials, GitHubCredentials, AppAuthenticationError, } from "./credentials.ts";
|
|
28
|
-
export { InstallationId, RepositoryId, Installation, InstallationWide, SingleRepository, TokenScope, InstallationToken, InstallationDiscoveryReason, InstallationDiscoveryError, } from "./installation.ts";
|
|
29
|
-
export { GitHubOperation, GitHubApiError, GitHubRateLimitError, InvalidGitHubResponseError, GitHubAppError, } from "./error.ts";
|
|
31
|
+
export { AppSlug, InstallationId, RepositoryId, Installation, InstallationWide, SingleRepository, TokenScope, InstallationToken, InstallationDiscoveryReason, InstallationDiscoveryError, } from "./installation.ts";
|
|
32
|
+
export { GitHubOperation, GitHubApiError, GitHubRateLimitError, InvalidGitHubResponseError, GitHubAppError, isRefusal, } from "./error.ts";
|
|
30
33
|
//# sourceMappingURL=github-app.d.ts.map
|
package/dist/github-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-app.d.ts","sourceRoot":"","sources":["../src/github-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAEL,OAAO,EAEP,MAAM,EACN,KAAK,EAKN,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,UAAU,EAAyC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"github-app.d.ts","sourceRoot":"","sources":["../src/github-app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAEL,OAAO,EAEP,MAAM,EACN,KAAK,EAKN,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,UAAU,EAAyC,MAAM,sBAAsB,CAAC;AAUzF,OAAO,EAAE,KAAK,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,aAAa,EAKnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,KAAK,cAAc,EAIpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAEL,YAAY,EAGZ,iBAAiB,EAKlB,MAAM,mBAAmB,CAAC;;IA8DvB,4EAA4E;2BACrD,MAAM,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,CAAC;IACxE,uGAAuG;gCAC3E,MAAM,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC;IAClF,qGAAqG;4BAC7E,CACtB,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,KACpC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC;IAChE;;;OAGG;0BACmB,CACpB,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,eAAe,KACzB,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC;;AAtBzD;;;GAGG;AACH,qBAAa,SAAU,SAAQ,cAoBD;IAC5B,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAChC,SAAS,EACT,sBAAsB,EACtB,iBAAiB,GAAG,UAAU,CAAC,UAAU,CAC1C,CA0MC;CACH;AAED,OAAO,EACL,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,cAAc,EACd,wBAAwB,EACxB,aAAa,EACb,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,OAAO,EACP,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,cAAc,EACd,SAAS,GACV,MAAM,YAAY,CAAC"}
|
package/dist/github-app.js
CHANGED
|
@@ -2,22 +2,23 @@ import { RepositoryName } from "@usine/core/repository";
|
|
|
2
2
|
import { Clock, Context, DateTime, Effect, Layer, Option, Redacted, Schema, SynchronizedRef, } from "effect";
|
|
3
3
|
import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/unstable/http";
|
|
4
4
|
import { appJwtSigner } from "./jwt.js";
|
|
5
|
-
import { API_ROOT, authorized, invalidResponse, statusError, transportError } from "./http.js";
|
|
5
|
+
import { API_ROOT, authorized, invalidResponse, statusError, transportError, withGitHubReason, } from "./http.js";
|
|
6
6
|
import { GitHubCredentials } from "./credentials.js";
|
|
7
|
-
import { AppPermissionError, REQUIRED_REPOSITORY_PERMISSIONS, deriveProjectAccess, missingPermissions, } from "./access.js";
|
|
7
|
+
import { AppPermissionError, REQUIRED_REPOSITORY_PERMISSIONS, WORKER_TOKEN_PERMISSIONS, deriveProjectAccess, missingPermissions, } from "./access.js";
|
|
8
8
|
import { InvalidGitHubResponseError, } from "./error.js";
|
|
9
|
-
import { Installation, InstallationDiscoveryError, InstallationId, InstallationToken, InstallationWide, RepositoryId, SingleRepository, } from "./installation.js";
|
|
9
|
+
import { AppSlug, Installation, InstallationDiscoveryError, InstallationId, InstallationToken, InstallationWide, RepositoryId, SingleRepository, } from "./installation.js";
|
|
10
10
|
const TOKEN_MAX_LIFETIME_MS = 60 * 60 * 1_000;
|
|
11
|
-
/**
|
|
11
|
+
/** The margin for clock skew between GitHub and this machine when checking token expiry, in milliseconds. */
|
|
12
12
|
const TOKEN_CLOCK_SKEW_MARGIN_MS = 3 * 60 * 1_000;
|
|
13
|
-
/**
|
|
13
|
+
/** The remaining token lifetime below which the shared lease is renewed, in milliseconds. */
|
|
14
14
|
const LEASE_RENEWAL_MARGIN_MS = 5 * 60 * 1_000;
|
|
15
15
|
const InstallationResponse = Schema.Struct({
|
|
16
16
|
id: InstallationId,
|
|
17
|
+
appSlug: AppSlug,
|
|
17
18
|
account: Schema.Struct({ login: Schema.NonEmptyString }),
|
|
18
19
|
permissions: Schema.Record(Schema.String, Schema.String),
|
|
19
20
|
suspendedAt: Schema.NullOr(Schema.String),
|
|
20
|
-
}).pipe(Schema.encodeKeys({ suspendedAt: "suspended_at" }));
|
|
21
|
+
}).pipe(Schema.encodeKeys({ appSlug: "app_slug", suspendedAt: "suspended_at" }));
|
|
21
22
|
const InstallationsResponse = Schema.Array(InstallationResponse);
|
|
22
23
|
const RepositoryResponse = Schema.Struct({
|
|
23
24
|
id: RepositoryId,
|
|
@@ -32,7 +33,7 @@ const TokenResponse = Schema.Struct({
|
|
|
32
33
|
expiresAt: Schema.DateTimeUtcFromString,
|
|
33
34
|
repositories: Schema.OptionFromOptionalKey(Schema.Array(RepositoryResponse)),
|
|
34
35
|
}).pipe(Schema.encodeKeys({ expiresAt: "expires_at" }));
|
|
35
|
-
/**
|
|
36
|
+
/** Returns the operation name and request body for minting a token of `scope`. */
|
|
36
37
|
const mintPlan = (scope) => scope._tag === "InstallationWide"
|
|
37
38
|
? {
|
|
38
39
|
operation: "mint-installation-token",
|
|
@@ -41,27 +42,30 @@ const mintPlan = (scope) => scope._tag === "InstallationWide"
|
|
|
41
42
|
: {
|
|
42
43
|
operation: "mint-worker-token",
|
|
43
44
|
body: {
|
|
44
|
-
permissions:
|
|
45
|
+
permissions: WORKER_TOKEN_PERMISSIONS[scope.permissions],
|
|
45
46
|
repository_ids: [scope.repositoryId],
|
|
46
47
|
},
|
|
47
48
|
};
|
|
48
49
|
/**
|
|
49
|
-
* The factory's GitHub identity and repository access.
|
|
50
|
-
*
|
|
51
|
-
* newly minted for the repository assigned to its Attempt.
|
|
50
|
+
* The factory's GitHub App identity and repository access. Orchestrator operations share an
|
|
51
|
+
* installation-wide token; each Worker token is minted for its Attempt's repository.
|
|
52
52
|
*/
|
|
53
53
|
export class GitHubApp extends Context.Service()("@usine/github/GitHubApp") {
|
|
54
54
|
static layer = Layer.effect(GitHubApp, Effect.gen(function* () {
|
|
55
55
|
const credentials = yield* GitHubCredentials;
|
|
56
56
|
const sign = yield* appJwtSigner(credentials);
|
|
57
57
|
const http = yield* HttpClient.HttpClient;
|
|
58
|
-
/** Sends one request and decodes its JSON body.
|
|
58
|
+
/** Sends one request and decodes its JSON body. Fails with a typed GitHub error otherwise. */
|
|
59
59
|
const fetchJson = (operation, request, schema) => Effect.gen(function* () {
|
|
60
60
|
const response = yield* http
|
|
61
61
|
.execute(request)
|
|
62
62
|
.pipe(Effect.mapError((error) => transportError(operation, error)));
|
|
63
63
|
if (response.status < 200 || response.status >= 300) {
|
|
64
|
-
|
|
64
|
+
const failure = statusError(operation, response, yield* Clock.currentTimeMillis);
|
|
65
|
+
if (failure._tag === "GitHubRateLimitError")
|
|
66
|
+
return yield* failure;
|
|
67
|
+
const explained = yield* withGitHubReason(failure, response);
|
|
68
|
+
return yield* explained;
|
|
65
69
|
}
|
|
66
70
|
return yield* HttpClientResponse.schemaBodyJson(schema)(response).pipe(Effect.mapError((error) => invalidResponse(operation, error.message)));
|
|
67
71
|
});
|
|
@@ -71,33 +75,42 @@ export class GitHubApp extends Context.Service()("@usine/github/GitHubApp") {
|
|
|
71
75
|
if (found === undefined) {
|
|
72
76
|
return yield* new InstallationDiscoveryError({
|
|
73
77
|
reason: "missing",
|
|
74
|
-
message: "The GitHub App is not installed on
|
|
78
|
+
message: "The GitHub App is not installed on any account. Install it on the account that owns the repositories.",
|
|
75
79
|
});
|
|
76
80
|
}
|
|
77
81
|
if (others.length > 0) {
|
|
78
82
|
return yield* new InstallationDiscoveryError({
|
|
79
83
|
reason: "multiple",
|
|
80
|
-
message: "The GitHub App
|
|
84
|
+
message: "The GitHub App has more than one installation. Uninstall it from every account except one.",
|
|
81
85
|
});
|
|
82
86
|
}
|
|
83
87
|
if (found.suspendedAt !== null) {
|
|
84
88
|
return yield* new InstallationDiscoveryError({
|
|
85
89
|
reason: "suspended",
|
|
86
|
-
message: "The GitHub App installation is suspended",
|
|
90
|
+
message: "The GitHub App installation is suspended. Unsuspend it in the installation settings on GitHub.",
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
93
|
const missing = missingPermissions(found.permissions);
|
|
90
94
|
if (missing.length > 0) {
|
|
91
95
|
return yield* new AppPermissionError({
|
|
92
96
|
missing,
|
|
93
|
-
message: `The GitHub App installation is missing permissions: ${missing.join(", ")}
|
|
97
|
+
message: `The GitHub App installation is missing permissions: ${missing.join(", ")}. Grant them in the GitHub App settings, then approve the change on the installation.`,
|
|
94
98
|
});
|
|
95
99
|
}
|
|
96
|
-
return new Installation({
|
|
100
|
+
return new Installation({
|
|
101
|
+
id: found.id,
|
|
102
|
+
accountLogin: found.account.login,
|
|
103
|
+
appSlug: found.appSlug,
|
|
104
|
+
});
|
|
97
105
|
});
|
|
98
106
|
const mintToken = Effect.fn("GitHubApp.mintToken")(function* (installationId, scope) {
|
|
99
107
|
const { operation, body } = mintPlan(scope);
|
|
100
|
-
yield* Effect.annotateCurrentSpan({
|
|
108
|
+
yield* Effect.annotateCurrentSpan({
|
|
109
|
+
installationId,
|
|
110
|
+
operation,
|
|
111
|
+
scope: scope._tag,
|
|
112
|
+
permissions: scope._tag === "SingleRepository" ? scope.permissions : "installation",
|
|
113
|
+
});
|
|
101
114
|
const jwt = yield* sign();
|
|
102
115
|
const response = yield* fetchJson(operation, HttpClientRequest.post(`${API_ROOT}/app/installations/${installationId}/access_tokens`).pipe(HttpClientRequest.bodyJsonUnsafe(body), authorized(jwt)), TokenResponse);
|
|
103
116
|
const now = yield* Clock.currentTimeMillis;
|
|
@@ -105,8 +118,8 @@ export class GitHubApp extends Context.Service()("@usine/github/GitHubApp") {
|
|
|
105
118
|
if (lifetime <= 0 || lifetime > TOKEN_MAX_LIFETIME_MS + TOKEN_CLOCK_SKEW_MARGIN_MS) {
|
|
106
119
|
return yield* new InvalidGitHubResponseError({
|
|
107
120
|
operation,
|
|
108
|
-
message: "GitHub returned an installation token
|
|
109
|
-
detail: `expires_at ${DateTime.formatIso(response.expiresAt)}
|
|
121
|
+
message: "GitHub returned an installation token that is expired or exceeds the one-hour lifetime limit",
|
|
122
|
+
detail: `expires_at ${DateTime.formatIso(response.expiresAt)} is ${lifetime}ms from now`,
|
|
110
123
|
});
|
|
111
124
|
}
|
|
112
125
|
if (lifetime > TOKEN_MAX_LIFETIME_MS) {
|
|
@@ -121,8 +134,8 @@ export class GitHubApp extends Context.Service()("@usine/github/GitHubApp") {
|
|
|
121
134
|
!(confirmed.length === 1 && confirmed.every((repo) => repo.id === scope.repositoryId))) {
|
|
122
135
|
return yield* new InvalidGitHubResponseError({
|
|
123
136
|
operation,
|
|
124
|
-
message: "GitHub did not confirm that the worker token is scoped to exactly one
|
|
125
|
-
detail: `expected repository
|
|
137
|
+
message: "GitHub did not confirm that the worker token is scoped to exactly one repository",
|
|
138
|
+
detail: `expected repository ID ${scope.repositoryId}, got [${confirmed.map((repo) => repo.id).join(", ")}]`,
|
|
126
139
|
});
|
|
127
140
|
}
|
|
128
141
|
return new InstallationToken({
|
|
@@ -141,14 +154,14 @@ export class GitHubApp extends Context.Service()("@usine/github/GitHubApp") {
|
|
|
141
154
|
if (response.repositories.length === 0) {
|
|
142
155
|
return yield* new InvalidGitHubResponseError({
|
|
143
156
|
operation: "list-installation-repositories",
|
|
144
|
-
message: "GitHub
|
|
157
|
+
message: "GitHub returned an empty page before it listed total_count repositories",
|
|
145
158
|
detail: `page ${page} was empty after ${installed.length} of ${response.totalCount} repositories`,
|
|
146
159
|
});
|
|
147
160
|
}
|
|
148
161
|
}
|
|
149
162
|
});
|
|
150
163
|
const leaseRef = yield* SynchronizedRef.make(Option.none());
|
|
151
|
-
/** Returns the current lease, renewing it inside the ref
|
|
164
|
+
/** Returns the current lease, renewing it inside the ref if its token is within the margin. */
|
|
152
165
|
const lease = Effect.fn("GitHubApp.lease")(() => SynchronizedRef.modifyEffect(leaseRef, (current) => Effect.gen(function* () {
|
|
153
166
|
const now = yield* Clock.currentTimeMillis;
|
|
154
167
|
if (Option.isSome(current) &&
|
|
@@ -170,15 +183,16 @@ export class GitHubApp extends Context.Service()("@usine/github/GitHubApp") {
|
|
|
170
183
|
const installed = yield* installedRepositories(token);
|
|
171
184
|
return deriveProjectAccess(installation, registry, installed);
|
|
172
185
|
}),
|
|
173
|
-
workerToken: Effect.fn("GitHubApp.workerToken")((project) => mintToken(project.installationId, new SingleRepository({
|
|
186
|
+
workerToken: Effect.fn("GitHubApp.workerToken")((project, permissions) => mintToken(project.installationId, new SingleRepository({
|
|
174
187
|
repository: project.repository,
|
|
175
188
|
repositoryId: project.repositoryId,
|
|
189
|
+
permissions,
|
|
176
190
|
}))),
|
|
177
191
|
};
|
|
178
192
|
}));
|
|
179
193
|
}
|
|
180
|
-
export { REQUIRED_REPOSITORY_PERMISSIONS, deriveProjectAccess, missingPermissions, CoveredProject, ProjectNotInstalledError, ProjectAccess, AppPermissionError, } from "./access.js";
|
|
194
|
+
export { REQUIRED_REPOSITORY_PERMISSIONS, WORKER_TOKEN_PERMISSIONS, deriveProjectAccess, missingPermissions, CoveredProject, ProjectNotInstalledError, ProjectAccess, AppPermissionError, } from "./access.js";
|
|
181
195
|
export { AppId, PrivateKey, RedactedPrivateKey, AppCredentials, GitHubCredentials, AppAuthenticationError, } from "./credentials.js";
|
|
182
|
-
export { InstallationId, RepositoryId, Installation, InstallationWide, SingleRepository, TokenScope, InstallationToken, InstallationDiscoveryReason, InstallationDiscoveryError, } from "./installation.js";
|
|
183
|
-
export { GitHubOperation, GitHubApiError, GitHubRateLimitError, InvalidGitHubResponseError, GitHubAppError, } from "./error.js";
|
|
196
|
+
export { AppSlug, InstallationId, RepositoryId, Installation, InstallationWide, SingleRepository, TokenScope, InstallationToken, InstallationDiscoveryReason, InstallationDiscoveryError, } from "./installation.js";
|
|
197
|
+
export { GitHubOperation, GitHubApiError, GitHubRateLimitError, InvalidGitHubResponseError, GitHubAppError, isRefusal, } from "./error.js";
|
|
184
198
|
//# sourceMappingURL=github-app.js.map
|
package/dist/github-app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-app.js","sourceRoot":"","sources":["../src/github-app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"github-app.js","sourceRoot":"","sources":["../src/github-app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,MAAM,EACN,KAAK,EACL,MAAM,EACN,QA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,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,2BAA2B,EAC3B,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,cAAc,EACd,SAAS,GACV,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { type HttpClient } from "effect/unstable/http";
|
|
3
|
+
import { GitHubRateLimitError } from "./error.ts";
|
|
4
|
+
import type { InstallationToken } from "./installation.ts";
|
|
5
|
+
/**
|
|
6
|
+
* Sends one GraphQL query with `token` and decodes `data` with `dataSchema`. Fails with
|
|
7
|
+
* `GitHubRateLimitError` on rate limiting, and with GitHub's messages on other errors. A
|
|
8
|
+
* NOT_FOUND error leaves its null field for `dataSchema` to decode.
|
|
9
|
+
*/
|
|
10
|
+
export declare const queryGraphql: <S extends Schema.Codec<unknown, unknown, never, unknown>>(http: HttpClient.HttpClient, token: InstallationToken, operation: "create-repository-label" | "discover-installation" | "fetch-issue-snapshot" | "fetch-item-labels" | "fetch-item-timeline" | "fetch-pull-request-snapshot" | "find-missing-issues" | "list-installation-repositories" | "list-repository-labels" | "mint-installation-token" | "mint-worker-token" | "poll-repository-changes" | "update-item-labels", query: string, variables: Readonly<Record<string, Schema.Json>>, dataSchema: S) => Effect.Effect<S["Type"], import("./error.ts").GitHubApiError | GitHubRateLimitError | import("./error.ts").InvalidGitHubResponseError, S["DecodingServices"]>;
|
|
11
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,KAAK,UAAU,EAAyC,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAwB,MAAM,YAAY,CAAC;AASxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAkB3D;;;;GAIG;AACH,eAAO,MAAM,YAAY,GACvB,CAAC,SAAS,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,2oBA8CxD,CAAC"}
|
package/dist/graphql.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Clock, DateTime, Effect, Option, Schema } from "effect";
|
|
2
|
+
import { HttpClientRequest, HttpClientResponse } from "effect/unstable/http";
|
|
3
|
+
import { GitHubRateLimitError } from "./error.js";
|
|
4
|
+
import { API_ROOT, authorized, invalidResponse, rateLimitRetryEpoch, statusError, transportError, } from "./http.js";
|
|
5
|
+
/** The wait for a GraphQL rate limit without reset headers, in milliseconds. */
|
|
6
|
+
const GRAPHQL_RATE_LIMIT_FALLBACK_MS = 60_000;
|
|
7
|
+
/** The GraphQL response envelope. `errors` can arrive with HTTP 200. */
|
|
8
|
+
const GraphqlEnvelope = Schema.Struct({
|
|
9
|
+
data: Schema.optionalKey(Schema.Unknown),
|
|
10
|
+
errors: Schema.optionalKey(Schema.Array(Schema.Struct({
|
|
11
|
+
message: Schema.String,
|
|
12
|
+
type: Schema.optionalKey(Schema.String),
|
|
13
|
+
}))),
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* Sends one GraphQL query with `token` and decodes `data` with `dataSchema`. Fails with
|
|
17
|
+
* `GitHubRateLimitError` on rate limiting, and with GitHub's messages on other errors. A
|
|
18
|
+
* NOT_FOUND error leaves its null field for `dataSchema` to decode.
|
|
19
|
+
*/
|
|
20
|
+
export const queryGraphql = Effect.fn("GitHub.queryGraphql")(function* (http, token, operation, query, variables, dataSchema) {
|
|
21
|
+
const request = HttpClientRequest.post(`${API_ROOT}/graphql`).pipe(HttpClientRequest.bodyJsonUnsafe({ query, variables }), authorized(token.value));
|
|
22
|
+
const response = yield* http
|
|
23
|
+
.execute(request)
|
|
24
|
+
.pipe(Effect.mapError((error) => transportError(operation, error)));
|
|
25
|
+
const now = yield* Clock.currentTimeMillis;
|
|
26
|
+
if (response.status !== 200)
|
|
27
|
+
return yield* statusError(operation, response, now);
|
|
28
|
+
const envelope = yield* HttpClientResponse.schemaBodyJson(GraphqlEnvelope)(response).pipe(Effect.mapError((error) => invalidResponse(operation, error.message)));
|
|
29
|
+
if (envelope.errors !== undefined && envelope.errors.length > 0) {
|
|
30
|
+
const rateLimited = envelope.errors.some((error) => error.type === "RATE_LIMITED");
|
|
31
|
+
if (rateLimited) {
|
|
32
|
+
const retryAt = Option.getOrElse(rateLimitRetryEpoch(response.headers, now), () => now + GRAPHQL_RATE_LIMIT_FALLBACK_MS);
|
|
33
|
+
return yield* new GitHubRateLimitError({
|
|
34
|
+
operation,
|
|
35
|
+
retryAt: DateTime.makeUnsafe(retryAt),
|
|
36
|
+
message: "GitHub GraphQL API rate limit exceeded",
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
// GitHub reports a missing Item as a NOT_FOUND error with a null field, which `dataSchema`
|
|
40
|
+
// decodes as absent.
|
|
41
|
+
if (!envelope.errors.every((error) => error.type === "NOT_FOUND")) {
|
|
42
|
+
return yield* invalidResponse(operation, `GraphQL errors: ${envelope.errors.map((error) => error.message).join("; ")}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return yield* Schema.decodeUnknownEffect(dataSchema)(envelope.data).pipe(Effect.mapError((error) => invalidResponse(operation, error.message)));
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=graphql.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.js","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO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C,eAAe,CAC3B,SAAS,EACT,mBAAmB,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC9E,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CACtE,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CACtE,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/http.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { Option, Redacted } from "effect";
|
|
1
|
+
import { Effect, Option, Redacted } from "effect";
|
|
2
2
|
import { HttpClientRequest, type HttpClientResponse } from "effect/unstable/http";
|
|
3
3
|
import type { HttpClientError } from "effect/unstable/http/HttpClientError";
|
|
4
4
|
import { GitHubApiError, GitHubRateLimitError, InvalidGitHubResponseError, type GitHubOperation } from "./error.ts";
|
|
5
5
|
export declare const API_ROOT = "https://api.github.com";
|
|
6
6
|
export declare const authorized: (credential: Redacted.Redacted<string>) => (self: HttpClientRequest.HttpClientRequest) => HttpClientRequest.HttpClientRequest;
|
|
7
7
|
export declare const transportError: (operation: GitHubOperation, error: HttpClientError) => GitHubApiError;
|
|
8
|
+
/**
|
|
9
|
+
* Returns `failure` with the `message` field of GitHub's error response appended, for example
|
|
10
|
+
* `The permissions requested are not granted to this installation.`. Returns `failure`
|
|
11
|
+
* unchanged if the body has no such field.
|
|
12
|
+
*/
|
|
13
|
+
export declare const withGitHubReason: (failure: GitHubApiError, response: HttpClientResponse.HttpClientResponse) => Effect.Effect<GitHubApiError>;
|
|
8
14
|
export declare const invalidResponse: (operation: GitHubOperation, detail: string) => InvalidGitHubResponseError;
|
|
9
15
|
type Headers = HttpClientResponse.HttpClientResponse["headers"];
|
|
10
16
|
export declare const retryAfterMillis: (value: string | undefined, now: number) => Option.Option<number>;
|
|
11
17
|
export declare const rateLimitResetMillis: (headers: Headers, threshold: number) => Option.Option<number>;
|
|
12
18
|
export declare const pollIntervalMillis: (headers: Headers, now: number) => Option.Option<number>;
|
|
13
|
-
/**
|
|
19
|
+
/** Returns the epoch milliseconds when GitHub allows the next request, from `retry-after` or an exhausted primary rate limit. */
|
|
14
20
|
export declare const rateLimitRetryEpoch: (headers: Headers, now: number) => Option.Option<number>;
|
|
15
|
-
/**
|
|
21
|
+
/** Returns the typed error for a non-2xx GitHub response: `GitHubRateLimitError` for a 403 or 429 with a known retry time, otherwise `GitHubApiError`. */
|
|
16
22
|
export declare const statusError: (operation: GitHubOperation, response: HttpClientResponse.HttpClientResponse, now: number) => GitHubApiError | GitHubRateLimitError;
|
|
17
23
|
export {};
|
|
18
24
|
//# sourceMappingURL=http.d.ts.map
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAU,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,QAAQ,2BAA2B,CAAC;AAGjD,eAAO,MAAM,UAAU,eAAgB,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,uFAM5D,CAAC;AAEL,eAAO,MAAM,cAAc,cAAe,eAAe,SAAS,eAAe,mBAQ7E,CAAC;AAKL;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,YAClB,cAAc,YACb,kBAAkB,CAAC,kBAAkB,KAC9C,MAAM,CAAC,MAAM,CAAC,cAAc,CAmB5B,CAAC;AAEJ,eAAO,MAAM,eAAe,cAAe,eAAe,UAAU,MAAM,+BAKtE,CAAC;AAEL,KAAK,OAAO,GAAG,kBAAkB,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;AAQhE,eAAO,MAAM,gBAAgB,UAAW,MAAM,GAAG,SAAS,OAAO,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAM7F,CAAC;AAEF,eAAO,MAAM,oBAAoB,YACtB,OAAO,aACL,MAAM,KAChB,MAAM,CAAC,MAAM,CAAC,MAAM,CAMtB,CAAC;AAEF,eAAO,MAAM,kBAAkB,YAAa,OAAO,OAAO,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CACG,CAAC;AAS3F,iIAAiI;AACjI,eAAO,MAAM,mBAAmB,YAAa,OAAO,OAAO,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CACQ,CAAC;AAEjG,0JAA0J;AAC1J,eAAO,MAAM,WAAW,cACX,eAAe,YAChB,kBAAkB,CAAC,kBAAkB,OAC1C,MAAM,KACV,cAAc,GAAG,oBAanB,CAAC"}
|
package/dist/http.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateTime, Option, Redacted } from "effect";
|
|
1
|
+
import { DateTime, Effect, Option, Redacted, Schema } from "effect";
|
|
2
2
|
import { HttpClientRequest } from "effect/unstable/http";
|
|
3
3
|
import { GitHubApiError, GitHubRateLimitError, InvalidGitHubResponseError, } from "./error.js";
|
|
4
4
|
export const API_ROOT = "https://api.github.com";
|
|
@@ -13,12 +13,30 @@ export const transportError = (operation, error) => new GitHubApiError({
|
|
|
13
13
|
operation,
|
|
14
14
|
status: error.response === undefined ? Option.none() : Option.some(error.response.status),
|
|
15
15
|
message: error.response === undefined
|
|
16
|
-
? "
|
|
17
|
-
: `GitHub
|
|
16
|
+
? "Could not send the request to GitHub"
|
|
17
|
+
: `GitHub returned HTTP status ${error.response.status}`,
|
|
18
18
|
});
|
|
19
|
+
const ErrorBody = Schema.Struct({ message: Schema.NonEmptyString });
|
|
20
|
+
const decodeErrorBody = Schema.decodeUnknownOption(ErrorBody);
|
|
21
|
+
/**
|
|
22
|
+
* Returns `failure` with the `message` field of GitHub's error response appended, for example
|
|
23
|
+
* `The permissions requested are not granted to this installation.`. Returns `failure`
|
|
24
|
+
* unchanged if the body has no such field.
|
|
25
|
+
*/
|
|
26
|
+
export const withGitHubReason = (failure, response) => response.json.pipe(Effect.map((body) => Option.match(decodeErrorBody(body), {
|
|
27
|
+
onNone: () => failure,
|
|
28
|
+
onSome: ({ message }) => new GitHubApiError({
|
|
29
|
+
operation: failure.operation,
|
|
30
|
+
status: failure.status,
|
|
31
|
+
message: `${failure.message}: ${message}`,
|
|
32
|
+
}),
|
|
33
|
+
})), Effect.catch((error) => Effect.logDebug("GitHub's error response has no JSON body to read a reason from", {
|
|
34
|
+
operation: failure.operation,
|
|
35
|
+
message: error.message,
|
|
36
|
+
}).pipe(Effect.as(failure))));
|
|
19
37
|
export const invalidResponse = (operation, detail) => new InvalidGitHubResponseError({
|
|
20
38
|
operation,
|
|
21
|
-
message: "GitHub returned a response
|
|
39
|
+
message: "GitHub returned a response in an unexpected format",
|
|
22
40
|
detail,
|
|
23
41
|
});
|
|
24
42
|
const parseInteger = (value) => {
|
|
@@ -48,21 +66,21 @@ const latestEpoch = (candidates) => {
|
|
|
48
66
|
const epochs = candidates.flatMap((candidate) => Option.match(candidate, { onNone: () => [], onSome: (value) => [value] }));
|
|
49
67
|
return epochs.length === 0 ? Option.none() : Option.some(Math.max(...epochs));
|
|
50
68
|
};
|
|
51
|
-
/**
|
|
69
|
+
/** Returns the epoch milliseconds when GitHub allows the next request, from `retry-after` or an exhausted primary rate limit. */
|
|
52
70
|
export const rateLimitRetryEpoch = (headers, now) => latestEpoch([retryAfterMillis(headers["retry-after"], now), rateLimitResetMillis(headers, 0)]);
|
|
53
|
-
/**
|
|
71
|
+
/** Returns the typed error for a non-2xx GitHub response: `GitHubRateLimitError` for a 403 or 429 with a known retry time, otherwise `GitHubApiError`. */
|
|
54
72
|
export const statusError = (operation, response, now) => {
|
|
55
73
|
const retryAt = Option.flatMap(rateLimitRetryEpoch(response.headers, now), DateTime.make);
|
|
56
74
|
return (response.status === 403 || response.status === 429) && Option.isSome(retryAt)
|
|
57
75
|
? new GitHubRateLimitError({
|
|
58
76
|
operation,
|
|
59
77
|
retryAt: retryAt.value,
|
|
60
|
-
message: "GitHub
|
|
78
|
+
message: "GitHub API rate limit exceeded",
|
|
61
79
|
})
|
|
62
80
|
: new GitHubApiError({
|
|
63
81
|
operation,
|
|
64
82
|
status: Option.some(response.status),
|
|
65
|
-
message: `GitHub
|
|
83
|
+
message: `GitHub returned HTTP status ${response.status}`,
|
|
66
84
|
});
|
|
67
85
|
};
|
|
68
86
|
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAA2B,MAAM,sBAAsB,CAAC;AAElF,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,0BAA0B,GAE3B,MAAM,YAAY,CA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E,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YACpC,OAAO,EAAE,+BAA+B,QAAQ,CAAC,MAAM,EAAE;SAC1D,CAAC,CAAC;AACT,CAAC,CAAC"}
|
package/dist/installation.d.ts
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
/** The
|
|
2
|
+
/** The ID of an installation of the factory's GitHub App. */
|
|
3
3
|
export declare const InstallationId: Schema.brand<Schema.Int, "GitHubInstallationId">;
|
|
4
4
|
export type InstallationId = typeof InstallationId.Type;
|
|
5
|
-
/** GitHub's numeric repository
|
|
5
|
+
/** GitHub's numeric repository ID, used to restrict installation tokens. */
|
|
6
6
|
export declare const RepositoryId: Schema.brand<Schema.Int, "GitHubRepositoryId">;
|
|
7
7
|
export type RepositoryId = typeof RepositoryId.Type;
|
|
8
|
+
/**
|
|
9
|
+
* The App's URL name. GitHub's GraphQL API reports the App's own changes with a `Bot` actor
|
|
10
|
+
* whose login is this slug; the REST login adds `[bot]`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const AppSlug: Schema.brand<Schema.NonEmptyString, "GitHubAppSlug">;
|
|
13
|
+
export type AppSlug = typeof AppSlug.Type;
|
|
8
14
|
declare const Installation_base: Schema.Class<Installation, Schema.Struct<{
|
|
9
15
|
readonly id: Schema.brand<Schema.Int, "GitHubInstallationId">;
|
|
10
16
|
readonly accountLogin: Schema.NonEmptyString;
|
|
17
|
+
readonly appSlug: Schema.brand<Schema.NonEmptyString, "GitHubAppSlug">;
|
|
11
18
|
}>, {}>;
|
|
12
|
-
/** The
|
|
19
|
+
/** The App installation, its owner account, and the App's slug. */
|
|
13
20
|
export declare class Installation extends Installation_base {
|
|
14
21
|
}
|
|
15
22
|
declare const InstallationWide_base: Schema.Class<InstallationWide, Schema.TaggedStruct<"InstallationWide", {}>, {}>;
|
|
16
|
-
/**
|
|
23
|
+
/** A token scope that covers every repository of the installation. */
|
|
17
24
|
export declare class InstallationWide extends InstallationWide_base {
|
|
18
25
|
}
|
|
19
26
|
declare const SingleRepository_base: Schema.Class<SingleRepository, Schema.TaggedStruct<"SingleRepository", {
|
|
20
27
|
readonly repository: Schema.brand<Schema.String, "RepositoryName">;
|
|
21
28
|
readonly repositoryId: Schema.brand<Schema.Int, "GitHubRepositoryId">;
|
|
29
|
+
readonly permissions: Schema.Literals<readonly ["write", "read"]>;
|
|
22
30
|
}>, {}>;
|
|
23
|
-
/**
|
|
31
|
+
/** A token scope restricted to one Attempt's repository, at the Loop's permission level (`WORKER_TOKEN_PERMISSIONS`). */
|
|
24
32
|
export declare class SingleRepository extends SingleRepository_base {
|
|
25
33
|
}
|
|
26
|
-
/** The repository
|
|
34
|
+
/** The repository scope requested when minting an installation token. */
|
|
27
35
|
export declare const TokenScope: Schema.Union<readonly [typeof InstallationWide, typeof SingleRepository]>;
|
|
28
36
|
export type TokenScope = typeof TokenScope.Type;
|
|
29
37
|
declare const InstallationToken_base: Schema.Class<InstallationToken, Schema.Struct<{
|
|
@@ -31,17 +39,17 @@ declare const InstallationToken_base: Schema.Class<InstallationToken, Schema.Str
|
|
|
31
39
|
readonly expiresAt: Schema.DateTimeUtc;
|
|
32
40
|
readonly scope: Schema.Union<readonly [typeof InstallationWide, typeof SingleRepository]>;
|
|
33
41
|
}>, {}>;
|
|
34
|
-
/** A redacted installation
|
|
42
|
+
/** A redacted installation token with its expiry and repository scope. */
|
|
35
43
|
export declare class InstallationToken extends InstallationToken_base {
|
|
36
44
|
}
|
|
37
|
-
/**
|
|
45
|
+
/** The reason installation discovery couldn't select one usable installation. */
|
|
38
46
|
export declare const InstallationDiscoveryReason: Schema.Literals<readonly ["missing", "multiple", "suspended"]>;
|
|
39
47
|
export type InstallationDiscoveryReason = typeof InstallationDiscoveryReason.Type;
|
|
40
48
|
declare const InstallationDiscoveryError_base: Schema.Class<InstallationDiscoveryError, Schema.TaggedStruct<"InstallationDiscoveryError", {
|
|
41
49
|
readonly reason: Schema.Literals<readonly ["missing", "multiple", "suspended"]>;
|
|
42
50
|
readonly message: Schema.NonEmptyString;
|
|
43
51
|
}>, import("effect/Cause").YieldableError>;
|
|
44
|
-
/** The App has no
|
|
52
|
+
/** The error when the App has no single active installation. */
|
|
45
53
|
export declare class InstallationDiscoveryError extends InstallationDiscoveryError_base {
|
|
46
54
|
}
|
|
47
55
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installation.d.ts","sourceRoot":"","sources":["../src/installation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"installation.d.ts","sourceRoot":"","sources":["../src/installation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,6DAA6D;AAC7D,eAAO,MAAM,cAAc,kDAAyD,CAAC;AACrF,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD,4EAA4E;AAC5E,eAAO,MAAM,YAAY,gDAAuD,CAAC;AACjF,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;AAEpD;;;GAGG;AACH,eAAO,MAAM,OAAO,sDAA4D,CAAC;AACjF,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;;;;;;AAE1C,mEAAmE;AACnE,qBAAa,YAAa,SAAQ,iBAIhC;CAAG;;AAEL,sEAAsE;AACtE,qBAAa,gBAAiB,SAAQ,qBAEb;CAAG;;;;;;AAE5B,yHAAyH;AACzH,qBAAa,gBAAiB,SAAQ,qBAMpC;CAAG;AAEL,yEAAyE;AACzE,eAAO,MAAM,UAAU,2EAAqD,CAAC;AAC7E,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;;;;;;AAEhD,0EAA0E;AAC1E,qBAAa,iBAAkB,SAAQ,sBAMrC;CAAG;AAEL,iFAAiF;AACjF,eAAO,MAAM,2BAA2B,gEAAwD,CAAC;AACjG,MAAM,MAAM,2BAA2B,GAAG,OAAO,2BAA2B,CAAC,IAAI,CAAC;;;;;AAElF,gEAAgE;AAChE,qBAAa,0BAA2B,SAAQ,+BAK9C;CAAG"}
|