@shivaedev/github 0.8.6 → 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.
- package/CHANGELOG.md +29 -0
- package/README.md +47 -3
- package/dist/GitHub.d.ts +100 -17
- package/dist/GitHub.d.ts.map +1 -1
- package/dist/GitHub.js +4 -1
- package/dist/GitHub.js.map +1 -1
- package/dist/GitHubToken.d.ts +2 -2
- package/dist/GitHubToken.d.ts.map +1 -1
- package/dist/GitHubToken.js +1 -1
- package/dist/GitHubToken.js.map +1 -1
- package/dist/appTokens.d.ts +6 -0
- package/dist/appTokens.d.ts.map +1 -0
- package/dist/appTokens.js +64 -0
- package/dist/appTokens.js.map +1 -0
- package/dist/artifacts.d.ts +1 -1
- package/dist/authenticatedRequest.d.ts +1 -1
- package/dist/authenticatedRequest.d.ts.map +1 -1
- package/dist/authenticatedRequest.js +3 -2
- package/dist/authenticatedRequest.js.map +1 -1
- package/dist/cache.d.ts +2 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +3 -0
- package/dist/cache.js.map +1 -1
- package/dist/checkRuns.d.ts +116 -11
- package/dist/checkRuns.d.ts.map +1 -1
- package/dist/checkRuns.js +39 -18
- package/dist/checkRuns.js.map +1 -1
- package/dist/githubApp.d.ts +2 -4
- package/dist/githubApp.d.ts.map +1 -1
- package/dist/githubApp.js +5 -55
- package/dist/githubApp.js.map +1 -1
- package/dist/installationClients.d.ts +185 -0
- package/dist/installationClients.d.ts.map +1 -0
- package/dist/installationClients.js +28 -0
- package/dist/installationClients.js.map +1 -0
- package/dist/json.d.ts.map +1 -1
- package/dist/json.js +4 -0
- package/dist/json.js.map +1 -1
- package/dist/representations.d.ts +4 -4
- package/dist/representations.d.ts.map +1 -1
- package/dist/representations.js +1 -1
- package/dist/representations.js.map +1 -1
- package/dist/requests.d.ts +2 -2
- package/dist/requests.d.ts.map +1 -1
- package/dist/requests.js +11 -9
- package/dist/requests.js.map +1 -1
- package/dist/status.d.ts +1 -1
- package/dist/status.d.ts.map +1 -1
- package/dist/stickyComments.d.ts +1 -1
- package/package.json +7 -7
- package/src/GitHub.ts +15 -1
- package/src/GitHubToken.ts +4 -2
- package/src/appTokens.ts +92 -0
- package/src/authenticatedRequest.ts +3 -1
- package/src/cache.ts +5 -0
- package/src/checkRuns.ts +58 -18
- package/src/githubApp.ts +6 -80
- package/src/installationClients.ts +44 -0
- package/src/json.ts +4 -0
- package/src/representations.ts +2 -2
- package/src/requests.ts +11 -9
package/dist/cache.js
CHANGED
package/dist/cache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,mBAAmB,CAAC,MAAsB,EAAE,QAA+C;IAC1G,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,aAAa;IAC5B,MAAM,OAAO,GAAG,IAAI,GAAG,EAA0B,CAAC;IAClD,OAAO;QACN,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QACtC,GAAG,CAAC,GAAW,EAAE,KAAqB;YACrC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACxB,IAAI,OAAO,CAAC,IAAI,GAAG,IAAI,EAAE,CAAC;gBACzB,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;gBACpC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;oBACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBAC7B,CAAC;YACF,CAAC;QACF,CAAC;KACD,CAAC;AACH,CAAC"}
|
package/dist/checkRuns.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
1
|
+
import { Effect, Option, Schema } from "effect";
|
|
2
2
|
import type { Representations } from "#representations.ts";
|
|
3
3
|
export declare const CheckRunOutput: Schema.Struct<{
|
|
4
4
|
readonly summary: Schema.String;
|
|
@@ -6,9 +6,22 @@ export declare const CheckRunOutput: Schema.Struct<{
|
|
|
6
6
|
readonly title: Schema.String;
|
|
7
7
|
}>;
|
|
8
8
|
export declare const CheckRunConclusion: Schema.Literals<readonly ["action_required", "cancelled", "failure", "neutral", "success", "skipped", "stale", "timed_out"]>;
|
|
9
|
-
export declare const CheckRunStatus: Schema.Literals<readonly ["queued", "in_progress", "completed"]>;
|
|
10
|
-
export declare const CreateCheckRun: Schema.encodeKeys<Schema.Struct<{
|
|
9
|
+
export declare const CheckRunStatus: Schema.Literals<readonly ["queued", "in_progress", "completed", "waiting", "requested", "pending"]>;
|
|
10
|
+
export declare const CreateCheckRun: Schema.Union<readonly [Schema.encodeKeys<Schema.Struct<{
|
|
11
|
+
readonly detailsUrl: Schema.optional<Schema.String>;
|
|
12
|
+
readonly headSha: Schema.String;
|
|
13
|
+
readonly name: Schema.String;
|
|
14
|
+
readonly output: Schema.optional<Schema.Struct<{
|
|
15
|
+
readonly summary: Schema.String;
|
|
16
|
+
readonly text: Schema.optional<Schema.String>;
|
|
17
|
+
readonly title: Schema.String;
|
|
18
|
+
}>>;
|
|
11
19
|
readonly conclusion: Schema.optional<Schema.Literals<readonly ["action_required", "cancelled", "failure", "neutral", "success", "skipped", "stale", "timed_out"]>>;
|
|
20
|
+
readonly status: Schema.Literals<readonly ["queued", "in_progress"]>;
|
|
21
|
+
}>, {
|
|
22
|
+
readonly detailsUrl: "details_url";
|
|
23
|
+
readonly headSha: "head_sha";
|
|
24
|
+
}>, Schema.encodeKeys<Schema.Struct<{
|
|
12
25
|
readonly detailsUrl: Schema.optional<Schema.String>;
|
|
13
26
|
readonly headSha: Schema.String;
|
|
14
27
|
readonly name: Schema.String;
|
|
@@ -17,11 +30,12 @@ export declare const CreateCheckRun: Schema.encodeKeys<Schema.Struct<{
|
|
|
17
30
|
readonly text: Schema.optional<Schema.String>;
|
|
18
31
|
readonly title: Schema.String;
|
|
19
32
|
}>>;
|
|
20
|
-
readonly
|
|
33
|
+
readonly conclusion: Schema.Literals<readonly ["action_required", "cancelled", "failure", "neutral", "success", "skipped", "stale", "timed_out"]>;
|
|
34
|
+
readonly status: Schema.Literal<"completed">;
|
|
21
35
|
}>, {
|
|
22
36
|
readonly detailsUrl: "details_url";
|
|
23
37
|
readonly headSha: "head_sha";
|
|
24
|
-
}>;
|
|
38
|
+
}>]>;
|
|
25
39
|
export declare const UpdateCheckRun: Schema.Union<readonly [Schema.encodeKeys<Schema.Struct<{
|
|
26
40
|
readonly detailsUrl: Schema.optional<Schema.String>;
|
|
27
41
|
readonly output: Schema.optional<Schema.Struct<{
|
|
@@ -45,6 +59,9 @@ export declare const UpdateCheckRun: Schema.Union<readonly [Schema.encodeKeys<Sc
|
|
|
45
59
|
readonly detailsUrl: "details_url";
|
|
46
60
|
}>]>;
|
|
47
61
|
export declare const CheckRun: Schema.encodeKeys<Schema.Struct<{
|
|
62
|
+
readonly app: Schema.optional<Schema.NullOr<Schema.Struct<{
|
|
63
|
+
readonly id: Schema.Number;
|
|
64
|
+
}>>>;
|
|
48
65
|
readonly conclusion: Schema.NullOr<Schema.Literals<readonly ["action_required", "cancelled", "failure", "neutral", "success", "skipped", "stale", "timed_out"]>>;
|
|
49
66
|
readonly detailsUrl: Schema.NullOr<Schema.String>;
|
|
50
67
|
readonly headSha: Schema.String;
|
|
@@ -55,14 +72,33 @@ export declare const CheckRun: Schema.encodeKeys<Schema.Struct<{
|
|
|
55
72
|
readonly text: Schema.NullOr<Schema.String>;
|
|
56
73
|
readonly title: Schema.NullOr<Schema.String>;
|
|
57
74
|
}>;
|
|
58
|
-
readonly status: Schema.Literals<readonly ["queued", "in_progress", "completed"]>;
|
|
75
|
+
readonly status: Schema.Literals<readonly ["queued", "in_progress", "completed", "waiting", "requested", "pending"]>;
|
|
59
76
|
}>, {
|
|
60
77
|
readonly detailsUrl: "details_url";
|
|
61
78
|
readonly headSha: "head_sha";
|
|
62
79
|
}>;
|
|
80
|
+
export declare const FindCheckRun: Schema.Union<readonly [Schema.Struct<{
|
|
81
|
+
readonly appId: Schema.optional<Schema.Number>;
|
|
82
|
+
readonly headSha: Schema.String;
|
|
83
|
+
readonly name: Schema.String;
|
|
84
|
+
}>, Schema.Struct<{
|
|
85
|
+
readonly appId: Schema.Number;
|
|
86
|
+
readonly headSha: Schema.String;
|
|
87
|
+
readonly name: Schema.optional<Schema.String>;
|
|
88
|
+
}>]>;
|
|
63
89
|
export declare function checkRuns(client: Representations): {
|
|
64
90
|
createCheckRun: (owner: string, repo: string, input: {
|
|
91
|
+
readonly detailsUrl?: string | undefined;
|
|
92
|
+
readonly headSha: string;
|
|
93
|
+
readonly name: string;
|
|
94
|
+
readonly output?: {
|
|
95
|
+
readonly summary: string;
|
|
96
|
+
readonly text?: string | undefined;
|
|
97
|
+
readonly title: string;
|
|
98
|
+
} | undefined;
|
|
65
99
|
readonly conclusion?: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | undefined;
|
|
100
|
+
readonly status: "in_progress" | "queued";
|
|
101
|
+
} | {
|
|
66
102
|
readonly detailsUrl?: string | undefined;
|
|
67
103
|
readonly headSha: string;
|
|
68
104
|
readonly name: string;
|
|
@@ -71,8 +107,36 @@ export declare function checkRuns(client: Representations): {
|
|
|
71
107
|
readonly text?: string | undefined;
|
|
72
108
|
readonly title: string;
|
|
73
109
|
} | undefined;
|
|
74
|
-
readonly
|
|
110
|
+
readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out";
|
|
111
|
+
readonly status: "completed";
|
|
75
112
|
}) => Effect.Effect<{
|
|
113
|
+
readonly app?: {
|
|
114
|
+
readonly id: number;
|
|
115
|
+
} | null | undefined;
|
|
116
|
+
readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | null;
|
|
117
|
+
readonly detailsUrl: string | null;
|
|
118
|
+
readonly headSha: string;
|
|
119
|
+
readonly id: number;
|
|
120
|
+
readonly name: string;
|
|
121
|
+
readonly output: {
|
|
122
|
+
readonly summary: string | null;
|
|
123
|
+
readonly text: string | null;
|
|
124
|
+
readonly title: string | null;
|
|
125
|
+
};
|
|
126
|
+
readonly status: "completed" | "in_progress" | "pending" | "queued" | "requested" | "waiting";
|
|
127
|
+
}, 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>;
|
|
128
|
+
findLatestCheckRun: (owner: string, repo: string, input: {
|
|
129
|
+
readonly appId?: number | undefined;
|
|
130
|
+
readonly headSha: string;
|
|
131
|
+
readonly name: string;
|
|
132
|
+
} | {
|
|
133
|
+
readonly appId: number;
|
|
134
|
+
readonly headSha: string;
|
|
135
|
+
readonly name?: string | undefined;
|
|
136
|
+
}) => Effect.Effect<Option.Option<{
|
|
137
|
+
readonly app?: {
|
|
138
|
+
readonly id: number;
|
|
139
|
+
} | null | undefined;
|
|
76
140
|
readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | null;
|
|
77
141
|
readonly detailsUrl: string | null;
|
|
78
142
|
readonly headSha: string;
|
|
@@ -83,8 +147,8 @@ export declare function checkRuns(client: Representations): {
|
|
|
83
147
|
readonly text: string | null;
|
|
84
148
|
readonly title: string | null;
|
|
85
149
|
};
|
|
86
|
-
readonly status: "completed" | "in_progress" | "queued";
|
|
87
|
-
}
|
|
150
|
+
readonly status: "completed" | "in_progress" | "pending" | "queued" | "requested" | "waiting";
|
|
151
|
+
}>, 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>;
|
|
88
152
|
updateCheckRun: (owner: string, repo: string, id: number, input: {
|
|
89
153
|
readonly detailsUrl?: string | undefined;
|
|
90
154
|
readonly output?: {
|
|
@@ -103,6 +167,47 @@ export declare function checkRuns(client: Representations): {
|
|
|
103
167
|
} | undefined;
|
|
104
168
|
readonly status: "completed";
|
|
105
169
|
}) => Effect.Effect<{
|
|
170
|
+
readonly app?: {
|
|
171
|
+
readonly id: number;
|
|
172
|
+
} | null | undefined;
|
|
173
|
+
readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | null;
|
|
174
|
+
readonly detailsUrl: string | null;
|
|
175
|
+
readonly headSha: string;
|
|
176
|
+
readonly id: number;
|
|
177
|
+
readonly name: string;
|
|
178
|
+
readonly output: {
|
|
179
|
+
readonly summary: string | null;
|
|
180
|
+
readonly text: string | null;
|
|
181
|
+
readonly title: string | null;
|
|
182
|
+
};
|
|
183
|
+
readonly status: "completed" | "in_progress" | "pending" | "queued" | "requested" | "waiting";
|
|
184
|
+
}, 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>;
|
|
185
|
+
upsertCheckRun: (owner: string, repo: string, input: {
|
|
186
|
+
readonly detailsUrl?: string | undefined;
|
|
187
|
+
readonly headSha: string;
|
|
188
|
+
readonly name: string;
|
|
189
|
+
readonly output?: {
|
|
190
|
+
readonly summary: string;
|
|
191
|
+
readonly text?: string | undefined;
|
|
192
|
+
readonly title: string;
|
|
193
|
+
} | undefined;
|
|
194
|
+
readonly conclusion?: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | undefined;
|
|
195
|
+
readonly status: "in_progress" | "queued";
|
|
196
|
+
} | {
|
|
197
|
+
readonly detailsUrl?: string | undefined;
|
|
198
|
+
readonly headSha: string;
|
|
199
|
+
readonly name: string;
|
|
200
|
+
readonly output?: {
|
|
201
|
+
readonly summary: string;
|
|
202
|
+
readonly text?: string | undefined;
|
|
203
|
+
readonly title: string;
|
|
204
|
+
} | undefined;
|
|
205
|
+
readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out";
|
|
206
|
+
readonly status: "completed";
|
|
207
|
+
}, appId?: number | undefined) => Effect.Effect<{
|
|
208
|
+
readonly app?: {
|
|
209
|
+
readonly id: number;
|
|
210
|
+
} | null | undefined;
|
|
106
211
|
readonly conclusion: "action_required" | "cancelled" | "failure" | "neutral" | "skipped" | "stale" | "success" | "timed_out" | null;
|
|
107
212
|
readonly detailsUrl: string | null;
|
|
108
213
|
readonly headSha: string;
|
|
@@ -113,7 +218,7 @@ export declare function checkRuns(client: Representations): {
|
|
|
113
218
|
readonly text: string | null;
|
|
114
219
|
readonly title: string | null;
|
|
115
220
|
};
|
|
116
|
-
readonly status: "completed" | "in_progress" | "queued";
|
|
117
|
-
}, 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>;
|
|
221
|
+
readonly status: "completed" | "in_progress" | "pending" | "queued" | "requested" | "waiting";
|
|
222
|
+
}, 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>;
|
|
118
223
|
};
|
|
119
224
|
//# sourceMappingURL=checkRuns.d.ts.map
|
package/dist/checkRuns.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkRuns.d.ts","sourceRoot":"","sources":["../src/checkRuns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"checkRuns.d.ts","sourceRoot":"","sources":["../src/checkRuns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,eAAO,MAAM,cAAc;;;;EAIzB,CAAC;AAEH,eAAO,MAAM,kBAAkB,8HAAsH,CAAC;AACtJ,eAAO,MAAM,cAAc,qGAA6F,CAAC;AAQzH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOzB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;IAYzB,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;EASyD,CAAC;AAI/E,eAAO,MAAM,YAAY;;;;;;;;IAGvB,CAAC;AAEH,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuChD"}
|
package/dist/checkRuns.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import { Effect, Schema } from "effect";
|
|
1
|
+
import { Effect, Option, Schema, Stream } from "effect";
|
|
2
2
|
export const CheckRunOutput = Schema.Struct({
|
|
3
3
|
summary: Schema.String,
|
|
4
4
|
text: Schema.optional(Schema.String),
|
|
5
5
|
title: Schema.String,
|
|
6
6
|
});
|
|
7
7
|
export const CheckRunConclusion = Schema.Literals(["action_required", "cancelled", "failure", "neutral", "success", "skipped", "stale", "timed_out"]);
|
|
8
|
-
export const CheckRunStatus = Schema.Literals(["queued", "in_progress", "completed"]);
|
|
9
|
-
|
|
10
|
-
conclusion: Schema.optional(CheckRunConclusion),
|
|
8
|
+
export const CheckRunStatus = Schema.Literals(["queued", "in_progress", "completed", "waiting", "requested", "pending"]);
|
|
9
|
+
const createFields = {
|
|
11
10
|
detailsUrl: Schema.optional(Schema.String),
|
|
12
11
|
headSha: Schema.String,
|
|
13
12
|
name: Schema.String,
|
|
14
13
|
output: Schema.optional(CheckRunOutput),
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
};
|
|
15
|
+
export const CreateCheckRun = Schema.Union([
|
|
16
|
+
Schema.Struct({ ...createFields, conclusion: Schema.optional(CheckRunConclusion), status: Schema.Literals(["queued", "in_progress"]) }).pipe(Schema.encodeKeys({ detailsUrl: "details_url", headSha: "head_sha" })),
|
|
17
|
+
Schema.Struct({ ...createFields, conclusion: CheckRunConclusion, status: Schema.Literal("completed") }).pipe(Schema.encodeKeys({ detailsUrl: "details_url", headSha: "head_sha" })),
|
|
18
|
+
]);
|
|
17
19
|
export const UpdateCheckRun = Schema.Union([
|
|
18
20
|
Schema.Struct({
|
|
19
21
|
detailsUrl: Schema.optional(Schema.String),
|
|
@@ -28,6 +30,7 @@ export const UpdateCheckRun = Schema.Union([
|
|
|
28
30
|
}).pipe(Schema.encodeKeys({ detailsUrl: "details_url" })),
|
|
29
31
|
]);
|
|
30
32
|
export const CheckRun = Schema.Struct({
|
|
33
|
+
app: Schema.optional(Schema.NullOr(Schema.Struct({ id: Schema.Number }))),
|
|
31
34
|
conclusion: Schema.NullOr(CheckRunConclusion),
|
|
32
35
|
detailsUrl: Schema.NullOr(Schema.String),
|
|
33
36
|
headSha: Schema.String,
|
|
@@ -36,18 +39,36 @@ export const CheckRun = Schema.Struct({
|
|
|
36
39
|
output: Schema.Struct({ summary: Schema.NullOr(Schema.String), text: Schema.NullOr(Schema.String), title: Schema.NullOr(Schema.String) }),
|
|
37
40
|
status: CheckRunStatus,
|
|
38
41
|
}).pipe(Schema.encodeKeys({ detailsUrl: "details_url", headSha: "head_sha" }));
|
|
42
|
+
const CheckRunPage = Schema.Struct({ checkRuns: Schema.Array(CheckRun) }).pipe(Schema.encodeKeys({ checkRuns: "check_runs" }));
|
|
43
|
+
export const FindCheckRun = Schema.Union([
|
|
44
|
+
Schema.Struct({ appId: Schema.optional(Schema.Number), headSha: Schema.String, name: Schema.String }),
|
|
45
|
+
Schema.Struct({ appId: Schema.Number, headSha: Schema.String, name: Schema.optional(Schema.String) }),
|
|
46
|
+
]);
|
|
39
47
|
export function checkRuns(client) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const createCheckRun = Effect.fn("GitHub.createCheckRun")(function* (owner, repo, input) {
|
|
49
|
+
const body = yield* Schema.encodeEffect(CreateCheckRun)(input);
|
|
50
|
+
const response = yield* client.write("POST", `/repos/${owner}/${repo}/check-runs`, body);
|
|
51
|
+
return yield* response.decode(CheckRun);
|
|
52
|
+
});
|
|
53
|
+
const updateCheckRun = Effect.fn("GitHub.updateCheckRun")(function* (owner, repo, id, input) {
|
|
54
|
+
const body = yield* Schema.encodeEffect(UpdateCheckRun)(input);
|
|
55
|
+
const response = yield* client.write("PATCH", `/repos/${owner}/${repo}/check-runs/${id}`, body);
|
|
56
|
+
return yield* response.decode(CheckRun);
|
|
57
|
+
});
|
|
58
|
+
const findLatestCheckRun = Effect.fn("GitHub.findLatestCheckRun")(function* (owner, repo, input) {
|
|
59
|
+
const { headSha, name, appId } = yield* Schema.decodeUnknownEffect(FindCheckRun)(input);
|
|
60
|
+
const query = new URLSearchParams({ filter: "all", "per_page": "100" });
|
|
61
|
+
if (name !== undefined) {
|
|
62
|
+
query.set("check_name", name);
|
|
63
|
+
}
|
|
64
|
+
const pages = yield* client.list(`/repos/${owner}/${repo}/commits/${encodeURIComponent(headSha)}/check-runs?${query}`);
|
|
65
|
+
return yield* pages.pipe(Stream.mapEffect((page) => page.decode(CheckRunPage)), Stream.flatMap((page) => Stream.fromIterable(page.checkRuns)), Stream.filter((run) => (name === undefined || run.name === name) && (appId === undefined || run.app?.id === appId)), Stream.runFold(() => Option.none(), (latest, run) => (Option.isNone(latest) || run.id > latest.value.id ? Option.some(run) : latest)));
|
|
66
|
+
});
|
|
67
|
+
const upsertCheckRun = Effect.fn("GitHub.upsertCheckRun")(function* (owner, repo, input, appId) {
|
|
68
|
+
yield* Schema.encodeEffect(CreateCheckRun)(input);
|
|
69
|
+
const existing = yield* findLatestCheckRun(owner, repo, { appId, headSha: input.headSha, name: input.name });
|
|
70
|
+
return yield* Option.isSome(existing) ? updateCheckRun(owner, repo, existing.value.id, input) : createCheckRun(owner, repo, input);
|
|
71
|
+
});
|
|
72
|
+
return { createCheckRun, findLatestCheckRun, updateCheckRun, upsertCheckRun };
|
|
52
73
|
}
|
|
53
74
|
//# sourceMappingURL=checkRuns.js.map
|
package/dist/checkRuns.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkRuns.js","sourceRoot":"","sources":["../src/checkRuns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"checkRuns.js","sourceRoot":"","sources":["../src/checkRuns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC,MAAM;IACtB,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC,MAAM;CACpB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;AACtJ,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC,CAAC;AAEzH,MAAM,YAAY,GAAG;IACpB,UAAU,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC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AkB,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC/E,CAAC"}
|
package/dist/githubApp.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
import {
|
|
3
|
-
import { type AppCredentials } from "#appJwt.ts";
|
|
4
|
-
import { GitHubToken } from "#GitHubToken.ts";
|
|
2
|
+
import type { AppCredentials } from "#appJwt.ts";
|
|
5
3
|
export interface InstallationScope {
|
|
6
4
|
readonly permissions?: Readonly<Record<string, "read" | "write" | "admin">>;
|
|
7
5
|
readonly repositories?: readonly string[];
|
|
@@ -20,5 +18,5 @@ export type GitHubAppOptions = AppCredentials & ({
|
|
|
20
18
|
readonly repository?: never;
|
|
21
19
|
readonly scope?: never;
|
|
22
20
|
});
|
|
23
|
-
export declare function githubApp(options: GitHubAppOptions): Layer.Layer<GitHubToken, never, HttpClient.HttpClient>;
|
|
21
|
+
export declare function githubApp(options: GitHubAppOptions): Layer.Layer<"@shivaedev/github/GitHubApp" | import("./GitHubToken.ts").GitHubToken, never, import("effect/http/HttpClient").HttpClient>;
|
|
24
22
|
//# sourceMappingURL=githubApp.d.ts.map
|
package/dist/githubApp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubApp.d.ts","sourceRoot":"","sources":["../src/githubApp.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"githubApp.d.ts","sourceRoot":"","sources":["../src/githubApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAIjD,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAC5E,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1C,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C;AAED,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAC5C,CACG;IAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAAE,GACvE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAAE,GAC3F;IAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAClH,CAAC;AAEH,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,2IAGlD"}
|
package/dist/githubApp.js
CHANGED
|
@@ -1,58 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { filterStatus } from "@shivaedev/http/filterStatus.ts";
|
|
5
|
-
import { appJwt } from "#appJwt.ts";
|
|
6
|
-
import { GitHubAppError } from "#errors.ts";
|
|
7
|
-
import { GitHubConfig } from "#GitHubConfig.ts";
|
|
8
|
-
import { GitHubToken } from "#GitHubToken.ts";
|
|
9
|
-
import { TokenRefresh } from "#TokenRefresh.ts";
|
|
10
|
-
const Installation = Schema.Struct({ id: Schema.Number });
|
|
11
|
-
const AccessToken = Schema.Struct({ expiresAt: Schema.DateFromString, token: Schema.RedactedFromValue(Schema.String) }).pipe(Schema.encodeKeys({ expiresAt: "expires_at" }));
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { appTokens } from "#appTokens.ts";
|
|
3
|
+
import { GitHubApp, GitHubAppCredentials } from "#installationClients.ts";
|
|
12
4
|
export function githubApp(options) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return Context.make(GitHubToken, Effect.map(appJwt(options), Option.some)).pipe(Context.add(TokenRefresh, undefined));
|
|
16
|
-
}
|
|
17
|
-
const client = yield* HttpClient.HttpClient;
|
|
18
|
-
const { apiUrl } = yield* GitHubConfig;
|
|
19
|
-
const clock = yield* Clock.Clock;
|
|
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
|
-
return 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
|
-
});
|
|
34
|
-
const cache = yield* Cache.makeWith((_) => exchange, {
|
|
35
|
-
capacity: 1,
|
|
36
|
-
timeToLive: (exit) => (Exit.isSuccess(exit) ? Math.max(0, exit.value.expiresAt.getTime() - clock.currentTimeMillisUnsafe() - 300_000) : 0),
|
|
37
|
-
});
|
|
38
|
-
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)));
|
|
39
|
-
}));
|
|
40
|
-
}
|
|
41
|
-
function appRequests(client, apiUrl) {
|
|
42
|
-
const checked = filterStatus(client);
|
|
43
|
-
return Effect.fnUntraced(function* (method, path, jwt, schema, body) {
|
|
44
|
-
let input = HttpClientRequest.make(method)(new URL(path, apiUrl).href, {
|
|
45
|
-
headers: { Accept: "application/vnd.github+json", Authorization: `Bearer ${Redacted.value(jwt)}`, "X-GitHub-Api-Version": "2022-11-28" },
|
|
46
|
-
});
|
|
47
|
-
if (body !== undefined) {
|
|
48
|
-
input = yield* HttpClientRequest.bodyJson(input, body).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: "encode" }, { cause })));
|
|
49
|
-
}
|
|
50
|
-
const response = yield* checked
|
|
51
|
-
.execute(input)
|
|
52
|
-
.pipe(Effect.mapError((cause) => cause._tag === "HttpClientError"
|
|
53
|
-
? new GitHubAppError({ reason: "transport" }, { cause })
|
|
54
|
-
: new GitHubAppError({ reason: "status", status: cause.status })));
|
|
55
|
-
return yield* readBoundedJson(response, 64 * 1024, schema).pipe(Effect.mapError((cause) => new GitHubAppError({ reason: cause._tag === "HttpClientError" ? "transport" : "response" }, { cause })));
|
|
56
|
-
});
|
|
5
|
+
const authentication = appTokens(options);
|
|
6
|
+
return Layer.merge(authentication, GitHubApp.layer.pipe(Layer.provide(Layer.succeed(GitHubAppCredentials)({ credentials: options }))));
|
|
57
7
|
}
|
|
58
8
|
//# sourceMappingURL=githubApp.js.map
|
package/dist/githubApp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"githubApp.js","sourceRoot":"","sources":["../src/githubApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"githubApp.js","sourceRoot":"","sources":["../src/githubApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAe1E,MAAM,UAAU,SAAS,CAAC,OAAyB;IAClD,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IAC1C,OAAO,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACxI,CAAC"}
|