@sentry/junior-github 0.115.0 → 0.116.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/SETUP.md +2 -2
- package/dist/db/schema.d.ts +5 -5
- package/dist/index.js +24 -16
- package/dist/permissions.d.ts +1 -3
- package/dist/plugin.d.ts +6 -6
- package/dist/pull-request-outcomes/store.d.ts +1 -1
- package/package.json +2 -2
package/SETUP.md
CHANGED
|
@@ -116,11 +116,11 @@ githubPlugin({
|
|
|
116
116
|
});
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
|
|
119
|
+
Installation-read token requests remain read-only by requesting read-capable configured permissions at `read` level and omitting GitHub permission fields that have no `read` value. Installation-write token requests intentionally omit the `permissions` field, so GitHub applies the complete permission envelope approved on the App installation. GitHub remains the source of truth for whether a permission name or level exists.
|
|
120
120
|
|
|
121
121
|
GitHub App user-to-server tokens do not use OAuth scopes as their permission model. Their effective access is limited by the GitHub App's installed permissions, the app installation's repository access, and the requesting user's own GitHub access. Repository-scoped installation tokens instead use the App permission envelope and installation repository access without borrowing the requesting user's authority. GitHub returns an empty `scope` value for user-to-server tokens, so Junior cannot verify granted scopes from the token response.
|
|
122
122
|
|
|
123
|
-
If you pass `additionalUserScopes`, Junior includes those values in the authorization URL and records the requested scope string as a local reauthorization contract. This does not expand or prove GitHub API permissions. Configure provider-enforced access in the GitHub App settings; `appPermissions` only
|
|
123
|
+
If you pass `additionalUserScopes`, Junior includes those values in the authorization URL and records the requested scope string as a local reauthorization contract. This does not expand or prove GitHub API permissions. Configure provider-enforced access in the GitHub App settings; `appPermissions` only controls read-token downscoping:
|
|
124
124
|
|
|
125
125
|
```ts
|
|
126
126
|
githubPlugin({
|
package/dist/db/schema.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const githubPullRequestStateSchema: z.ZodEnum<{
|
|
3
|
-
merged: "merged";
|
|
4
3
|
open: "open";
|
|
4
|
+
merged: "merged";
|
|
5
5
|
closed_unmerged: "closed_unmerged";
|
|
6
6
|
}>;
|
|
7
7
|
export type GitHubPullRequestState = z.output<typeof githubPullRequestStateSchema>;
|
|
@@ -308,7 +308,7 @@ export declare const juniorGitHubPullRequests: import("drizzle-orm/pg-core").PgT
|
|
|
308
308
|
tableName: "junior_github_pull_requests";
|
|
309
309
|
dataType: "string";
|
|
310
310
|
columnType: "PgText";
|
|
311
|
-
data: "
|
|
311
|
+
data: "open" | "merged" | "closed_unmerged";
|
|
312
312
|
driverParam: string;
|
|
313
313
|
notNull: true;
|
|
314
314
|
hasDefault: false;
|
|
@@ -320,7 +320,7 @@ export declare const juniorGitHubPullRequests: import("drizzle-orm/pg-core").PgT
|
|
|
320
320
|
identity: undefined;
|
|
321
321
|
generated: undefined;
|
|
322
322
|
}, {}, {
|
|
323
|
-
$type: "
|
|
323
|
+
$type: "open" | "merged" | "closed_unmerged";
|
|
324
324
|
}>;
|
|
325
325
|
commitComposition: import("drizzle-orm/pg-core").PgColumn<{
|
|
326
326
|
name: "commit_composition";
|
|
@@ -857,7 +857,7 @@ export declare const githubSqlSchema: {
|
|
|
857
857
|
tableName: "junior_github_pull_requests";
|
|
858
858
|
dataType: "string";
|
|
859
859
|
columnType: "PgText";
|
|
860
|
-
data: "
|
|
860
|
+
data: "open" | "merged" | "closed_unmerged";
|
|
861
861
|
driverParam: string;
|
|
862
862
|
notNull: true;
|
|
863
863
|
hasDefault: false;
|
|
@@ -869,7 +869,7 @@ export declare const githubSqlSchema: {
|
|
|
869
869
|
identity: undefined;
|
|
870
870
|
generated: undefined;
|
|
871
871
|
}, {}, {
|
|
872
|
-
$type: "
|
|
872
|
+
$type: "open" | "merged" | "closed_unmerged";
|
|
873
873
|
}>;
|
|
874
874
|
commitComposition: import("drizzle-orm/pg-core").PgColumn<{
|
|
875
875
|
name: "commit_composition";
|
package/dist/index.js
CHANGED
|
@@ -64,15 +64,6 @@ function readGrantPermissions(permissions) {
|
|
|
64
64
|
}
|
|
65
65
|
return readOnly;
|
|
66
66
|
}
|
|
67
|
-
function permissionCapabilities(permissions) {
|
|
68
|
-
if (permissions === void 0) {
|
|
69
|
-
return void 0;
|
|
70
|
-
}
|
|
71
|
-
return Object.entries(permissions).map(([normalizedScope, rawLevel]) => {
|
|
72
|
-
const scope = normalizedScope.replace(/_/g, "-");
|
|
73
|
-
return `github.${scope}.${rawLevel}`;
|
|
74
|
-
}).sort();
|
|
75
|
-
}
|
|
76
67
|
|
|
77
68
|
// src/tools/create-issue.ts
|
|
78
69
|
import {
|
|
@@ -527,6 +518,7 @@ import { z as z2 } from "zod";
|
|
|
527
518
|
import { subscribableResourceSchema } from "@sentry/junior-plugin-api";
|
|
528
519
|
var GITHUB_PULL_REQUEST_CREATE_IDEMPOTENCY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
529
520
|
var GITHUB_PULL_REQUEST_CREATE_LOCK_TTL_MS = 6e4;
|
|
521
|
+
var RESOURCE_LINK_LABEL_MAX_LENGTH = 256;
|
|
530
522
|
var GitHubPullRequestCreateRejectedError = class extends Error {
|
|
531
523
|
status;
|
|
532
524
|
constructor(message, status) {
|
|
@@ -759,6 +751,20 @@ function gitHubPullRequestToolResult(input, result) {
|
|
|
759
751
|
});
|
|
760
752
|
return { ...result, ...subscribable ? { subscribable } : {} };
|
|
761
753
|
}
|
|
754
|
+
async function annotatePullRequest(ctx, input, result) {
|
|
755
|
+
const repo = parseRepo2(input.repo);
|
|
756
|
+
const label = `${repo.owner}/${repo.name} #${result.number}: ${nonEmptyString3(input.title, "title")}`.slice(
|
|
757
|
+
0,
|
|
758
|
+
RESOURCE_LINK_LABEL_MAX_LENGTH
|
|
759
|
+
);
|
|
760
|
+
await ctx.annotations?.upsert({
|
|
761
|
+
kind: "resource_link",
|
|
762
|
+
key: `${repo.owner.toLowerCase()}/${repo.name.toLowerCase()}#${result.number}`,
|
|
763
|
+
label,
|
|
764
|
+
url: result.url,
|
|
765
|
+
status: input.draft ? "draft" : "open"
|
|
766
|
+
});
|
|
767
|
+
}
|
|
762
768
|
function gitHubPullRequestStructuredResult(input, result) {
|
|
763
769
|
const data = gitHubPullRequestToolResult(input, result);
|
|
764
770
|
return {
|
|
@@ -788,12 +794,15 @@ function createGitHubPullRequestTool(ctx) {
|
|
|
788
794
|
async () => {
|
|
789
795
|
const state = createPullRequestState(await ctx.state.get(key));
|
|
790
796
|
if (state?.status === "completed") {
|
|
797
|
+
const completedInput = state.input ?? parsedInput;
|
|
798
|
+
const completedResult = {
|
|
799
|
+
number: state.number,
|
|
800
|
+
url: state.url
|
|
801
|
+
};
|
|
802
|
+
await annotatePullRequest(ctx, completedInput, completedResult);
|
|
791
803
|
return gitHubPullRequestStructuredResult(
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
number: state.number,
|
|
795
|
-
url: state.url
|
|
796
|
-
}
|
|
804
|
+
completedInput,
|
|
805
|
+
completedResult
|
|
797
806
|
);
|
|
798
807
|
}
|
|
799
808
|
if (state?.status === "pending") {
|
|
@@ -832,6 +841,7 @@ function createGitHubPullRequestTool(ctx) {
|
|
|
832
841
|
{ cause: error }
|
|
833
842
|
);
|
|
834
843
|
}
|
|
844
|
+
await annotatePullRequest(ctx, parsedInput, result);
|
|
835
845
|
return gitHubPullRequestStructuredResult(parsedInput, result);
|
|
836
846
|
} catch (error) {
|
|
837
847
|
if (isEgressAuthRequired2(error) || isDefinitiveGitHubPullRequestCreateRejection(error)) {
|
|
@@ -3826,7 +3836,6 @@ function githubPlugin(options = {}) {
|
|
|
3826
3836
|
const declaredAppPermissions = normalizePermissions(options.appPermissions);
|
|
3827
3837
|
const declaredReadPermissions = declaredAppPermissions ? readGrantPermissions(declaredAppPermissions) : void 0;
|
|
3828
3838
|
const loadReadPermissions = createPermissionCache();
|
|
3829
|
-
const appCapabilities = permissionCapabilities(declaredAppPermissions);
|
|
3830
3839
|
const userScopes = normalizeScopeList(options.additionalUserScopes);
|
|
3831
3840
|
const userScope = userScopes.length ? userScopes.join(" ") : void 0;
|
|
3832
3841
|
return defineJuniorPlugin({
|
|
@@ -3835,7 +3844,6 @@ function githubPlugin(options = {}) {
|
|
|
3835
3844
|
name: "github",
|
|
3836
3845
|
displayName: "GitHub",
|
|
3837
3846
|
description: "GitHub issue, pull request, and repository workflows via GitHub App",
|
|
3838
|
-
...appCapabilities ? { capabilities: appCapabilities } : {},
|
|
3839
3847
|
configKeys: ["org", "repo"],
|
|
3840
3848
|
domains: ["api.github.com", "github.com", "uploads.github.com"],
|
|
3841
3849
|
envVars: {
|
package/dist/permissions.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export type GitHubAppPermissionLevel = "admin" | "read" | "write";
|
|
2
2
|
export type GitHubAppPermissions = Record<string, GitHubAppPermissionLevel>;
|
|
3
|
-
/** Validate the configured GitHub App
|
|
3
|
+
/** Validate the configured GitHub App read-token permission declaration. */
|
|
4
4
|
export declare function normalizePermissions(permissions: GitHubAppPermissions | undefined): GitHubAppPermissions | undefined;
|
|
5
5
|
/** Build the read-only installation-token permission body. */
|
|
6
6
|
export declare function readGrantPermissions(permissions: Record<string, unknown> | undefined): Record<string, "read">;
|
|
7
|
-
/** Expose configured permissions as plugin capabilities for host policy checks. */
|
|
8
|
-
export declare function permissionCapabilities(permissions: GitHubAppPermissions | undefined): string[] | undefined;
|
package/dist/plugin.d.ts
CHANGED
|
@@ -16,13 +16,13 @@ export interface GitHubPluginOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
additionalUserScopes?: string[];
|
|
18
18
|
/**
|
|
19
|
-
* GitHub App permissions Junior should
|
|
20
|
-
*
|
|
19
|
+
* GitHub App permissions Junior should downscope to read for
|
|
20
|
+
* installation-read tokens.
|
|
21
21
|
*
|
|
22
|
-
* Keys may use GitHub permission names with underscores or hyphens.
|
|
23
|
-
*
|
|
24
|
-
* the
|
|
25
|
-
*
|
|
22
|
+
* Keys may use GitHub permission names with underscores or hyphens.
|
|
23
|
+
* Installation-write tokens inherit the App installation's complete
|
|
24
|
+
* permission envelope. GitHub remains the source of truth for whether a
|
|
25
|
+
* permission exists.
|
|
26
26
|
*/
|
|
27
27
|
appPermissions?: GitHubAppPermissions;
|
|
28
28
|
/** Environment variable containing the GitHub App id. */
|
|
@@ -15,8 +15,8 @@ declare const githubPullRequestOutcomeInputSchema: z.ZodObject<{
|
|
|
15
15
|
repositoryFullName: z.ZodString;
|
|
16
16
|
repositoryId: z.ZodString;
|
|
17
17
|
state: z.ZodEnum<{
|
|
18
|
-
merged: "merged";
|
|
19
18
|
open: "open";
|
|
19
|
+
merged: "merged";
|
|
20
20
|
closed_unmerged: "closed_unmerged";
|
|
21
21
|
}>;
|
|
22
22
|
updatedAt: z.ZodDate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.116.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@sinclair/typebox": "^0.34.49",
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
33
|
"zod": "^4.4.3",
|
|
34
|
-
"@sentry/junior-plugin-api": "0.
|
|
34
|
+
"@sentry/junior-plugin-api": "0.116.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "^25.9.1",
|