@sentry/junior-github 0.237.0 → 0.238.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-UB3DDGLH.js → chunk-EYBKPQTJ.js} +49 -12
- package/dist/events/deployment.d.ts +5 -0
- package/dist/events/issue.d.ts +5 -0
- package/dist/events/pull-request.d.ts +5 -0
- package/dist/events/release.d.ts +5 -0
- package/dist/events/repository.d.ts +5 -0
- package/dist/index.js +22 -3
- package/dist/testing.js +1 -1
- package/dist/tool-support/attribution.d.ts +7 -0
- package/package.json +2 -2
|
@@ -16,6 +16,10 @@ var GITHUB_DEPLOYMENT_SUGGESTED_EVENTS = [
|
|
|
16
16
|
"deployment.failed",
|
|
17
17
|
"deployment.error"
|
|
18
18
|
];
|
|
19
|
+
var GITHUB_DEPLOYMENT_SOURCE_IDENTIFIER = {
|
|
20
|
+
format: "deployment-source:owner/repo[:environment]:<full-commit-sha>",
|
|
21
|
+
pattern: /^deployment-source:[^\s/:#]+\/[^\s/:#]+(?::[^\s:]+)?:[0-9a-f]+$/
|
|
22
|
+
};
|
|
19
23
|
function gitHubDeploymentSourceResource(input) {
|
|
20
24
|
const commitSha = input.commitSha.toLowerCase();
|
|
21
25
|
const environment = input.environment?.trim();
|
|
@@ -48,6 +52,10 @@ var GITHUB_ISSUE_SUGGESTED_EVENTS = [
|
|
|
48
52
|
"issue.closed",
|
|
49
53
|
"issue.reopened"
|
|
50
54
|
];
|
|
55
|
+
var GITHUB_ISSUE_IDENTIFIER = {
|
|
56
|
+
format: "owner/repo#number",
|
|
57
|
+
pattern: /^[^\s/:#]+\/[^\s/:#]+#\d+$/
|
|
58
|
+
};
|
|
51
59
|
function gitHubIssueResource(input) {
|
|
52
60
|
return {
|
|
53
61
|
label: `GitHub issue ${input.repo}#${input.number}`,
|
|
@@ -124,6 +132,10 @@ var GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema.parse({
|
|
|
124
132
|
description: "true when the pull request is a draft"
|
|
125
133
|
}
|
|
126
134
|
});
|
|
135
|
+
var GITHUB_PULL_REQUEST_IDENTIFIER = {
|
|
136
|
+
format: "owner/repo#number",
|
|
137
|
+
pattern: /^[^\s/:#]+\/[^\s/:#]+#\d+$/
|
|
138
|
+
};
|
|
127
139
|
function gitHubPullRequestResource(input) {
|
|
128
140
|
return {
|
|
129
141
|
label: `GitHub PR ${input.repo}#${input.number}`,
|
|
@@ -148,6 +160,10 @@ function gitHubPullRequestSubscribable(input) {
|
|
|
148
160
|
// src/events/release.ts
|
|
149
161
|
var GITHUB_RELEASE_EVENTS = ["release.published"];
|
|
150
162
|
var GITHUB_RELEASE_SUGGESTED_EVENTS = ["release.published"];
|
|
163
|
+
var GITHUB_RELEASE_SOURCE_IDENTIFIER = {
|
|
164
|
+
format: "release-source:owner/repo[:tag]",
|
|
165
|
+
pattern: /^release-source:[^\s/:#]+\/[^\s/:#]+(?::[^\s:]+)?$/
|
|
166
|
+
};
|
|
151
167
|
function gitHubReleaseSourceResource(input) {
|
|
152
168
|
const repo = input.repo.toLowerCase();
|
|
153
169
|
const tag = input.tag?.trim();
|
|
@@ -168,6 +184,10 @@ function gitHubReleaseSourceSubscribable(input) {
|
|
|
168
184
|
}
|
|
169
185
|
|
|
170
186
|
// src/events/repository.ts
|
|
187
|
+
var GITHUB_REPOSITORY_IDENTIFIER = {
|
|
188
|
+
format: "owner/repo",
|
|
189
|
+
pattern: /^[^\s/:#]+\/[^\s/:#]+$/
|
|
190
|
+
};
|
|
171
191
|
function gitHubRepositoryResource(input) {
|
|
172
192
|
return {
|
|
173
193
|
label: `GitHub repository ${input.repo}`,
|
|
@@ -1626,18 +1646,30 @@ function normalizePullRequestReviewEvent(deliveryId, body, botEmail) {
|
|
|
1626
1646
|
pullRequestAuthorData(parsed.data.pull_request.user),
|
|
1627
1647
|
pullRequestHeadBranchData(parsed.data.pull_request.head?.ref)
|
|
1628
1648
|
]);
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1649
|
+
const event = {
|
|
1650
|
+
eventKey: gitHubEventKey2(deliveryId, eventType),
|
|
1651
|
+
eventType,
|
|
1652
|
+
occurredAtMs: Date.now(),
|
|
1653
|
+
identifier: resource.identifier,
|
|
1654
|
+
trustedSummary: eventType === "pull_request.review.approved" ? `${resource.label} was approved${reviewer ? ` by ${reviewer}` : ""}.` : eventType === "pull_request.review.changes_requested" ? `${resource.label} received requested changes${reviewer ? ` from ${reviewer}` : ""}.` : `${resource.label} received a review comment${reviewer ? ` from ${reviewer}` : ""}.`,
|
|
1655
|
+
...data ? { data } : void 0,
|
|
1656
|
+
untrustedText: parsed.data.review.body ?? void 0
|
|
1657
|
+
};
|
|
1658
|
+
const events = pullRequestTargets2(event, repo);
|
|
1659
|
+
if (eventType !== "pull_request.review.approved" || !parsed.data.review.body?.trim()) {
|
|
1660
|
+
return events;
|
|
1661
|
+
}
|
|
1662
|
+
return [
|
|
1663
|
+
...events,
|
|
1664
|
+
...pullRequestTargets2(
|
|
1665
|
+
{
|
|
1666
|
+
...event,
|
|
1667
|
+
eventKey: gitHubEventKey2(deliveryId, "pull_request.review.commented"),
|
|
1668
|
+
eventType: "pull_request.review.commented"
|
|
1669
|
+
},
|
|
1670
|
+
repo
|
|
1671
|
+
)
|
|
1672
|
+
];
|
|
1641
1673
|
}
|
|
1642
1674
|
var pullRequestWebhookSchema = z2.object({
|
|
1643
1675
|
action: z2.string(),
|
|
@@ -1870,18 +1902,23 @@ export {
|
|
|
1870
1902
|
readGrantPermissions,
|
|
1871
1903
|
GITHUB_ISSUE_EVENTS,
|
|
1872
1904
|
GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
1905
|
+
GITHUB_ISSUE_IDENTIFIER,
|
|
1873
1906
|
gitHubIssueSubscribable,
|
|
1874
1907
|
GITHUB_DEPLOYMENT_EVENTS,
|
|
1875
1908
|
GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
|
|
1909
|
+
GITHUB_DEPLOYMENT_SOURCE_IDENTIFIER,
|
|
1876
1910
|
gitHubDeploymentSourceSubscribable,
|
|
1877
1911
|
GITHUB_PULL_REQUEST_EVENTS,
|
|
1878
1912
|
gitHubPullRequestEventGuidance,
|
|
1879
1913
|
GITHUB_PULL_REQUEST_SUGGESTED_EVENTS,
|
|
1880
1914
|
GITHUB_PULL_REQUEST_MATCH_FIELDS,
|
|
1915
|
+
GITHUB_PULL_REQUEST_IDENTIFIER,
|
|
1881
1916
|
gitHubPullRequestSubscribable,
|
|
1882
1917
|
GITHUB_RELEASE_EVENTS,
|
|
1883
1918
|
GITHUB_RELEASE_SUGGESTED_EVENTS,
|
|
1919
|
+
GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
1884
1920
|
gitHubReleaseSourceSubscribable,
|
|
1921
|
+
GITHUB_REPOSITORY_IDENTIFIER,
|
|
1885
1922
|
gitHubRepositorySubscribable,
|
|
1886
1923
|
botLoginFromEmail,
|
|
1887
1924
|
isBotLogin,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
2
|
export declare const GITHUB_DEPLOYMENT_EVENTS: readonly ["deployment.created", "deployment.queued", "deployment.pending", "deployment.in_progress", "deployment.succeeded", "deployment.failed", "deployment.error"];
|
|
3
3
|
export declare const GITHUB_DEPLOYMENT_SUGGESTED_EVENTS: string[];
|
|
4
|
+
/** The identifier shape that `gitHubDeploymentSourceResource` builds. */
|
|
5
|
+
export declare const GITHUB_DEPLOYMENT_SOURCE_IDENTIFIER: {
|
|
6
|
+
format: string;
|
|
7
|
+
pattern: RegExp;
|
|
8
|
+
};
|
|
4
9
|
/** Build the stable deployment-source identity shared by tools and webhooks. */
|
|
5
10
|
export declare function gitHubDeploymentSourceResource(input: {
|
|
6
11
|
commitSha: string;
|
package/dist/events/issue.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
2
|
export declare const GITHUB_ISSUE_EVENTS: string[];
|
|
3
3
|
export declare const GITHUB_ISSUE_SUGGESTED_EVENTS: string[];
|
|
4
|
+
/** The identifier shape that `gitHubIssueResource` builds. */
|
|
5
|
+
export declare const GITHUB_ISSUE_IDENTIFIER: {
|
|
6
|
+
format: string;
|
|
7
|
+
pattern: RegExp;
|
|
8
|
+
};
|
|
4
9
|
/** Build the stable issue identity shared by tools and webhooks. */
|
|
5
10
|
export declare function gitHubIssueResource(input: {
|
|
6
11
|
number: number;
|
|
@@ -22,6 +22,11 @@ export declare const GITHUB_PULL_REQUEST_MATCH_FIELDS: Record<string, {
|
|
|
22
22
|
description: string;
|
|
23
23
|
enum?: string[] | undefined;
|
|
24
24
|
}>;
|
|
25
|
+
/** The identifier shape that `gitHubPullRequestResource` builds. */
|
|
26
|
+
export declare const GITHUB_PULL_REQUEST_IDENTIFIER: {
|
|
27
|
+
format: string;
|
|
28
|
+
pattern: RegExp;
|
|
29
|
+
};
|
|
25
30
|
/** Build the stable pull request identity shared by tools and webhooks. */
|
|
26
31
|
export declare function gitHubPullRequestResource(input: {
|
|
27
32
|
number: number;
|
package/dist/events/release.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
2
|
export declare const GITHUB_RELEASE_EVENTS: readonly ["release.published"];
|
|
3
3
|
export declare const GITHUB_RELEASE_SUGGESTED_EVENTS: string[];
|
|
4
|
+
/** The identifier shape that `gitHubReleaseSourceResource` builds. */
|
|
5
|
+
export declare const GITHUB_RELEASE_SOURCE_IDENTIFIER: {
|
|
6
|
+
format: string;
|
|
7
|
+
pattern: RegExp;
|
|
8
|
+
};
|
|
4
9
|
/** Build the stable release-source identity shared by tools and webhooks. */
|
|
5
10
|
export declare function gitHubReleaseSourceResource(input: {
|
|
6
11
|
repo: string;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import type { SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
|
+
/** The identifier shape that `gitHubRepositoryResource` builds. */
|
|
3
|
+
export declare const GITHUB_REPOSITORY_IDENTIFIER: {
|
|
4
|
+
format: string;
|
|
5
|
+
pattern: RegExp;
|
|
6
|
+
};
|
|
2
7
|
/** Build the stable repository identity shared by tools and webhooks. */
|
|
3
8
|
export declare function gitHubRepositoryResource(input: {
|
|
4
9
|
repo: string;
|
package/dist/index.js
CHANGED
|
@@ -5,16 +5,21 @@ import {
|
|
|
5
5
|
GITHUB_AUTH_TOKEN_ENV,
|
|
6
6
|
GITHUB_AUTH_TOKEN_PLACEHOLDER,
|
|
7
7
|
GITHUB_DEPLOYMENT_EVENTS,
|
|
8
|
+
GITHUB_DEPLOYMENT_SOURCE_IDENTIFIER,
|
|
8
9
|
GITHUB_DEPLOYMENT_SUGGESTED_EVENTS,
|
|
9
10
|
GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES,
|
|
10
11
|
GITHUB_INSTALLATION_ID_ENV,
|
|
11
12
|
GITHUB_ISSUE_EVENTS,
|
|
13
|
+
GITHUB_ISSUE_IDENTIFIER,
|
|
12
14
|
GITHUB_ISSUE_SUGGESTED_EVENTS,
|
|
13
15
|
GITHUB_PULL_REQUEST_EVENTS,
|
|
16
|
+
GITHUB_PULL_REQUEST_IDENTIFIER,
|
|
14
17
|
GITHUB_PULL_REQUEST_MATCH_FIELDS,
|
|
15
18
|
GITHUB_PULL_REQUEST_SUGGESTED_EVENTS,
|
|
16
19
|
GITHUB_RELEASE_EVENTS,
|
|
20
|
+
GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
17
21
|
GITHUB_RELEASE_SUGGESTED_EVENTS,
|
|
22
|
+
GITHUB_REPOSITORY_IDENTIFIER,
|
|
18
23
|
GitHubPluginSetupError,
|
|
19
24
|
HTTP_READ_METHODS,
|
|
20
25
|
USER_TOKEN_GRANTS,
|
|
@@ -46,7 +51,7 @@ import {
|
|
|
46
51
|
readGrantPermissions,
|
|
47
52
|
requireEnv,
|
|
48
53
|
resolveUserAccount
|
|
49
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-EYBKPQTJ.js";
|
|
50
55
|
|
|
51
56
|
// src/plugin.ts
|
|
52
57
|
import {
|
|
@@ -511,6 +516,11 @@ ${footer}` : footer;
|
|
|
511
516
|
var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
|
|
512
517
|
var GITHUB_REQUEST_ATTRIBUTION_END = "<!-- junior-request-attribution:end -->";
|
|
513
518
|
var SLACK_USER_ID_DISPLAY_PATTERN = /^[UW][A-Z0-9]{5,}$/;
|
|
519
|
+
var GITHUB_LOGIN_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/;
|
|
520
|
+
function linkedGitHubLogin(user) {
|
|
521
|
+
const login = user?.identities.find((identity) => identity.provider === "github")?.handle?.trim().replace(/^@/, "");
|
|
522
|
+
return login && GITHUB_LOGIN_PATTERN.test(login) ? login : void 0;
|
|
523
|
+
}
|
|
514
524
|
function cleanDisplayValue(value, userId) {
|
|
515
525
|
const cleaned = value?.replace(/[\r\n<>]/g, " ").trim();
|
|
516
526
|
if (!cleaned) {
|
|
@@ -535,6 +545,10 @@ function requesterLabel(args) {
|
|
|
535
545
|
if (actor.platform === "system") {
|
|
536
546
|
return `Junior system actor \`${actor.name}\``;
|
|
537
547
|
}
|
|
548
|
+
const login = linkedGitHubLogin(user);
|
|
549
|
+
if (login) {
|
|
550
|
+
return `@${login}`;
|
|
551
|
+
}
|
|
538
552
|
const userId = actor.userId;
|
|
539
553
|
const display = cleanDisplayValue(user?.displayName, userId) ?? cleanDisplayValue(identity?.displayName, userId) ?? cleanDisplayValue(identity?.handle, userId) ?? cleanDisplayValue(actor.fullName, userId) ?? cleanDisplayValue(actor.userName, userId);
|
|
540
554
|
return display ? `**${display.replaceAll("*", "\\*")}**` : void 0;
|
|
@@ -545,7 +559,7 @@ function parseExistingLabels(blockContents) {
|
|
|
545
559
|
return [];
|
|
546
560
|
}
|
|
547
561
|
const withoutLeadIn = trimmed.replace(/^(?:Requested by|via)\s+/i, "");
|
|
548
|
-
return withoutLeadIn.split(/,\s*(
|
|
562
|
+
return withoutLeadIn.split(/,\s*(?=\*\*|@|Junior system actor `|via\s)/i).map((entry) => entry.trim().replace(/^via\s+/i, "")).filter(Boolean);
|
|
549
563
|
}
|
|
550
564
|
function formatAttributionBlock(labels) {
|
|
551
565
|
return `${GITHUB_REQUEST_ATTRIBUTION_START}
|
|
@@ -1360,7 +1374,7 @@ async function assignPullRequestRequester(ctx, input, result) {
|
|
|
1360
1374
|
if (!ctx.actor || ctx.actor.platform === "system") return;
|
|
1361
1375
|
try {
|
|
1362
1376
|
const requester = await ctx.users.resolveActor();
|
|
1363
|
-
const assignee = requester?.user
|
|
1377
|
+
const assignee = linkedGitHubLogin(requester?.user);
|
|
1364
1378
|
if (!assignee) return;
|
|
1365
1379
|
const repo = parseRepo4(input.repo);
|
|
1366
1380
|
const response = await ctx.egress.fetch({
|
|
@@ -4695,16 +4709,19 @@ function githubPlugin(options = {}) {
|
|
|
4695
4709
|
resourceTypes: [
|
|
4696
4710
|
{
|
|
4697
4711
|
type: "deployment_source",
|
|
4712
|
+
identifier: GITHUB_DEPLOYMENT_SOURCE_IDENTIFIER,
|
|
4698
4713
|
supportedEvents: [...GITHUB_DEPLOYMENT_EVENTS],
|
|
4699
4714
|
suggestedEvents: [...GITHUB_DEPLOYMENT_SUGGESTED_EVENTS]
|
|
4700
4715
|
},
|
|
4701
4716
|
{
|
|
4702
4717
|
type: "issue",
|
|
4718
|
+
identifier: GITHUB_ISSUE_IDENTIFIER,
|
|
4703
4719
|
supportedEvents: [...GITHUB_ISSUE_EVENTS],
|
|
4704
4720
|
suggestedEvents: [...GITHUB_ISSUE_SUGGESTED_EVENTS]
|
|
4705
4721
|
},
|
|
4706
4722
|
{
|
|
4707
4723
|
type: "pull_request",
|
|
4724
|
+
identifier: GITHUB_PULL_REQUEST_IDENTIFIER,
|
|
4708
4725
|
supportedEvents: [...GITHUB_PULL_REQUEST_EVENTS],
|
|
4709
4726
|
suggestedEvents: [...GITHUB_PULL_REQUEST_SUGGESTED_EVENTS],
|
|
4710
4727
|
matchFields: GITHUB_PULL_REQUEST_MATCH_FIELDS,
|
|
@@ -4714,11 +4731,13 @@ function githubPlugin(options = {}) {
|
|
|
4714
4731
|
},
|
|
4715
4732
|
{
|
|
4716
4733
|
type: "release_source",
|
|
4734
|
+
identifier: GITHUB_RELEASE_SOURCE_IDENTIFIER,
|
|
4717
4735
|
supportedEvents: [...GITHUB_RELEASE_EVENTS],
|
|
4718
4736
|
suggestedEvents: [...GITHUB_RELEASE_SUGGESTED_EVENTS]
|
|
4719
4737
|
},
|
|
4720
4738
|
{
|
|
4721
4739
|
type: "repository",
|
|
4740
|
+
identifier: GITHUB_REPOSITORY_IDENTIFIER,
|
|
4722
4741
|
supportedEvents: [
|
|
4723
4742
|
...GITHUB_ISSUE_EVENTS,
|
|
4724
4743
|
...GITHUB_PULL_REQUEST_EVENTS
|
package/dist/testing.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { Actor, Identity, PluginLogger, User } from "@sentry/junior-plugin-api";
|
|
2
2
|
export declare const GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start -->";
|
|
3
3
|
export declare const GITHUB_REQUEST_ATTRIBUTION_END = "<!-- junior-request-attribution:end -->";
|
|
4
|
+
/**
|
|
5
|
+
* Return the GitHub login linked to a user, when it is a valid login.
|
|
6
|
+
*
|
|
7
|
+
* Attribution mentions and PR assignment use this login so the requester gets
|
|
8
|
+
* GitHub notifications for the issue or pull request.
|
|
9
|
+
*/
|
|
10
|
+
export declare function linkedGitHubLogin(user: User | undefined): string | undefined;
|
|
4
11
|
/**
|
|
5
12
|
* Append or replace runtime-owned requester attribution in a GitHub body.
|
|
6
13
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.238.1",
|
|
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.5.4",
|
|
34
|
-
"@sentry/junior-plugin-api": "0.
|
|
34
|
+
"@sentry/junior-plugin-api": "0.238.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@oxlint/plugins": "1.79.0",
|