@mastra/factory 0.30.0 → 0.31.0-alpha.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/README.md +32 -10
- package/dist/factory.d.ts +12 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +72 -31
- package/dist/factory.js.map +1 -1
- package/dist/integrations/gitlab/api.d.ts +3 -2
- package/dist/integrations/gitlab/api.d.ts.map +1 -1
- package/dist/integrations/gitlab/api.js +12 -9
- package/dist/integrations/gitlab/api.js.map +1 -1
- package/dist/integrations/issue-reconcile-worker.d.ts +5 -0
- package/dist/integrations/issue-reconcile-worker.d.ts.map +1 -1
- package/dist/integrations/issue-reconcile-worker.js +17 -1
- package/dist/integrations/issue-reconcile-worker.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +22 -13
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +63 -64
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/foundation/connect-binding.d.ts +125 -0
- package/dist/integrations/platform/foundation/connect-binding.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/connect-binding.js +252 -0
- package/dist/integrations/platform/foundation/connect-binding.js.map +1 -0
- package/dist/integrations/platform/foundation/connect-event-poller.d.ts +49 -0
- package/dist/integrations/platform/foundation/connect-event-poller.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/connect-event-poller.js +304 -0
- package/dist/integrations/platform/foundation/connect-event-poller.js.map +1 -0
- package/dist/integrations/platform/foundation/connect-events.d.ts +31 -0
- package/dist/integrations/platform/foundation/connect-events.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/connect-events.js +7 -0
- package/dist/integrations/platform/foundation/connect-events.js.map +1 -0
- package/dist/integrations/platform/foundation/index.d.ts +10 -0
- package/dist/integrations/platform/foundation/index.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/index.js +6 -0
- package/dist/integrations/platform/foundation/intake.d.ts +39 -0
- package/dist/integrations/platform/foundation/intake.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/intake.js +45 -0
- package/dist/integrations/platform/foundation/intake.js.map +1 -0
- package/dist/integrations/platform/foundation/integration.d.ts +84 -0
- package/dist/integrations/platform/foundation/integration.d.ts.map +1 -0
- package/dist/integrations/platform/foundation/integration.js +107 -0
- package/dist/integrations/platform/foundation/integration.js.map +1 -0
- package/dist/integrations/platform/github/event-worker.d.ts +2 -2
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +4 -8
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +3 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +131 -70
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/gitlab/connect-events.d.ts +22 -0
- package/dist/integrations/platform/gitlab/connect-events.d.ts.map +1 -0
- package/dist/integrations/platform/gitlab/connect-events.js +49 -0
- package/dist/integrations/platform/gitlab/connect-events.js.map +1 -0
- package/dist/integrations/platform/gitlab/integration.d.ts +24 -15
- package/dist/integrations/platform/gitlab/integration.d.ts.map +1 -1
- package/dist/integrations/platform/gitlab/integration.js +61 -26
- package/dist/integrations/platform/gitlab/integration.js.map +1 -1
- package/dist/integrations/platform/incidentio/intake.d.ts +33 -0
- package/dist/integrations/platform/incidentio/intake.d.ts.map +1 -0
- package/dist/integrations/platform/incidentio/intake.js +271 -0
- package/dist/integrations/platform/incidentio/intake.js.map +1 -0
- package/dist/integrations/platform/incidentio/integration.d.ts +11 -23
- package/dist/integrations/platform/incidentio/integration.d.ts.map +1 -1
- package/dist/integrations/platform/incidentio/integration.js +27 -297
- package/dist/integrations/platform/incidentio/integration.js.map +1 -1
- package/dist/integrations/platform/jira/intake.d.ts +60 -0
- package/dist/integrations/platform/jira/intake.d.ts.map +1 -0
- package/dist/integrations/platform/jira/intake.js +445 -0
- package/dist/integrations/platform/jira/intake.js.map +1 -0
- package/dist/integrations/platform/jira/integration.d.ts +13 -37
- package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
- package/dist/integrations/platform/jira/integration.js +29 -468
- package/dist/integrations/platform/jira/integration.js.map +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts +2 -2
- package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/linear/event-worker.js +5 -9
- package/dist/integrations/platform/linear/event-worker.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts +3 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +9 -9
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/platform/logging.d.ts +6 -0
- package/dist/integrations/platform/logging.d.ts.map +1 -0
- package/dist/integrations/platform/logging.js +25 -0
- package/dist/integrations/platform/logging.js.map +1 -0
- package/dist/integrations/platform/platform-connect.d.ts +38 -0
- package/dist/integrations/platform/platform-connect.d.ts.map +1 -0
- package/dist/integrations/platform/platform-connect.js +109 -0
- package/dist/integrations/platform/platform-connect.js.map +1 -0
- package/dist/integrations/platform/vanta/integration.d.ts +12 -18
- package/dist/integrations/platform/vanta/integration.d.ts.map +1 -1
- package/dist/integrations/platform/vanta/integration.js +38 -38
- package/dist/integrations/platform/vanta/integration.js.map +1 -1
- package/dist/memory-embedder.d.ts +11 -0
- package/dist/memory-embedder.d.ts.map +1 -0
- package/dist/memory-embedder.js +19 -0
- package/dist/memory-embedder.js.map +1 -0
- package/dist/metrics/config.d.ts +1 -1
- package/dist/metrics/config.d.ts.map +1 -1
- package/dist/metrics/config.js +1 -0
- package/dist/metrics/config.js.map +1 -1
- package/dist/metrics/index.js +2 -2
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics/sandbox.d.ts +3 -3
- package/dist/metrics/sandbox.js +13 -13
- package/dist/metrics/sandbox.js.map +1 -1
- package/dist/metrics/session.d.ts +28 -0
- package/dist/metrics/session.d.ts.map +1 -0
- package/dist/metrics/session.js +76 -0
- package/dist/metrics/session.js.map +1 -0
- package/dist/routes/source-control-sessions.d.ts +5 -0
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +65 -7
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/surface.d.ts +5 -0
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +1 -0
- package/dist/routes/surface.js.map +1 -1
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/processor.d.ts +29 -1
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +156 -23
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/public-failure-reason.js +1 -1
- package/dist/rules/public-failure-reason.js.map +1 -1
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +33 -9
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +2 -0
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +4 -2
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/work-item-branch.d.ts +7 -1
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +9 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/card-facts.d.ts.map +1 -1
- package/dist/work-items/card-facts.js +2 -2
- package/dist/work-items/card-facts.js.map +1 -1
- package/package.json +9 -9
- package/dist/integrations/platform/api-client.d.ts +0 -34
- package/dist/integrations/platform/api-client.d.ts.map +0 -1
- package/dist/integrations/platform/api-client.js +0 -186
- package/dist/integrations/platform/api-client.js.map +0 -1
- package/dist/integrations/platform/gitlab/event-worker.d.ts +0 -64
- package/dist/integrations/platform/gitlab/event-worker.d.ts.map +0 -1
- package/dist/integrations/platform/gitlab/event-worker.js +0 -304
- package/dist/integrations/platform/gitlab/event-worker.js.map +0 -1
|
@@ -10,7 +10,8 @@ import { attachGithubPullRequestDiscovery, attachGithubReconciler, attachGithubR
|
|
|
10
10
|
import { createGithubSubscriptionTools, parseCreatedPullRequest, subscribeCurrentSessionToPullRequest } from "../../github/session-subscriptions.js";
|
|
11
11
|
import { settleOrAbort } from "../../github/settle-or-abort.js";
|
|
12
12
|
import { parseAuthorizedBotsEnv } from "../../github/webhook.js";
|
|
13
|
-
import {
|
|
13
|
+
import { logPlatformBootInfo, logPlatformInfo, logPlatformWarn } from "../logging.js";
|
|
14
|
+
import { createPlatformConnectClient, platformErrorStatus } from "../platform-connect.js";
|
|
14
15
|
import { PlatformGithubEventWorker } from "./event-worker.js";
|
|
15
16
|
import { registerApiRoute } from "@mastra/core/server";
|
|
16
17
|
import { Octokit } from "@octokit/rest";
|
|
@@ -334,10 +335,10 @@ var PlatformGithubIntegration = class {
|
|
|
334
335
|
cloneUrl,
|
|
335
336
|
authorization: {
|
|
336
337
|
scheme: "bearer",
|
|
337
|
-
token: (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
|
|
338
|
+
token: (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, { body: {
|
|
338
339
|
repositories: [repositoryName],
|
|
339
340
|
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
340
|
-
})).token
|
|
341
|
+
} })).token
|
|
341
342
|
}
|
|
342
343
|
};
|
|
343
344
|
setBounded(this.#repositoryAccessCache, cacheKey, {
|
|
@@ -356,10 +357,10 @@ var PlatformGithubIntegration = class {
|
|
|
356
357
|
if (candidateInstallationId === null) continue;
|
|
357
358
|
let token;
|
|
358
359
|
try {
|
|
359
|
-
token = await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${candidateInstallationId}/token`, {
|
|
360
|
+
token = await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${candidateInstallationId}/token`, { body: {
|
|
360
361
|
repositories: [repositoryName],
|
|
361
362
|
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
362
|
-
});
|
|
363
|
+
} });
|
|
363
364
|
} catch (candidateErr) {
|
|
364
365
|
if (isDeadInstallation(candidateErr)) continue;
|
|
365
366
|
throw candidateErr;
|
|
@@ -407,10 +408,10 @@ var PlatformGithubIntegration = class {
|
|
|
407
408
|
if (installationId === null) throw new Error("GitHub installation id is invalid.");
|
|
408
409
|
const authorization = {
|
|
409
410
|
scheme: "bearer",
|
|
410
|
-
token: (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
|
|
411
|
+
token: (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, { body: {
|
|
411
412
|
repositories: found.map((repository) => splitRepository(repository.slug).repo),
|
|
412
413
|
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
413
|
-
})).token
|
|
414
|
+
} })).token
|
|
414
415
|
};
|
|
415
416
|
const expiresAt = Date.now() + REPOSITORY_ACCESS_CACHE_TTL_MS;
|
|
416
417
|
const access = {
|
|
@@ -452,6 +453,7 @@ var PlatformGithubIntegration = class {
|
|
|
452
453
|
createReviewComment: (input) => this.#createReviewComment(input),
|
|
453
454
|
updateReviewComment: (input) => this.#updateReviewComment(input),
|
|
454
455
|
deleteReviewComment: (input) => this.#deleteReviewComment(input),
|
|
456
|
+
resolveReviewThread: (input) => this.#resolveReviewThread(input),
|
|
455
457
|
listRequestedReviewers: (input) => this.#requestedReviewers("GET", input),
|
|
456
458
|
requestReviewers: (input) => this.#requestedReviewers("POST", input),
|
|
457
459
|
removeRequestedReviewers: (input) => this.#requestedReviewers("DELETE", input),
|
|
@@ -459,9 +461,8 @@ var PlatformGithubIntegration = class {
|
|
|
459
461
|
};
|
|
460
462
|
constructor(options = {}) {
|
|
461
463
|
this.#rules = resolveGithubRules(options.rules);
|
|
462
|
-
|
|
463
|
-
this.#
|
|
464
|
-
this.#endpointHost = new URL(config.baseUrl).host;
|
|
464
|
+
this.#client = createPlatformConnectClient(options.connect);
|
|
465
|
+
this.#endpointHost = new URL(this.#client.baseUrl).host;
|
|
465
466
|
this.#slug = options.slug;
|
|
466
467
|
this.identity = new GithubAppIdentity(process.env.MASTRA_PLATFORM_GITHUB_APP_SLUG?.trim() || PLATFORM_GITHUB_APP_SLUG);
|
|
467
468
|
this.authorizedBots = parseAuthorizedBotsEnv(process.env.MASTRACODE_GITHUB_AUTHORIZED_BOTS) ?? [];
|
|
@@ -844,7 +845,7 @@ var PlatformGithubIntegration = class {
|
|
|
844
845
|
}
|
|
845
846
|
const existing = comments.filter((comment) => comment.body.includes("<!-- mastra-factory-triage -->") && this.isFactoryCommentAuthor(comment.user?.login)).sort((left, right) => left.id - right.id)[0];
|
|
846
847
|
if (existing) {
|
|
847
|
-
const comment = await this.#client.request("PATCH", repositoryPath(input.repository, `issues/comments/${existing.id}`), { body: input.body });
|
|
848
|
+
const comment = await this.#client.request("PATCH", repositoryPath(input.repository, `issues/comments/${existing.id}`), { body: { body: input.body } });
|
|
848
849
|
this.#observeSelfAuthor(comment, void 0);
|
|
849
850
|
return {
|
|
850
851
|
action: "updated",
|
|
@@ -852,7 +853,7 @@ var PlatformGithubIntegration = class {
|
|
|
852
853
|
url: comment.htmlUrl
|
|
853
854
|
};
|
|
854
855
|
}
|
|
855
|
-
const comment = await this.#client.request("POST", repositoryPath(input.repository, `issues/${input.issueNumber}/comments`), { body: input.body });
|
|
856
|
+
const comment = await this.#client.request("POST", repositoryPath(input.repository, `issues/${input.issueNumber}/comments`), { body: { body: input.body } });
|
|
856
857
|
this.#observeSelfAuthor(comment, void 0);
|
|
857
858
|
return {
|
|
858
859
|
action: "created",
|
|
@@ -904,7 +905,7 @@ var PlatformGithubIntegration = class {
|
|
|
904
905
|
if (inFlight) return settleOrAbort(inFlight, signal, void 0);
|
|
905
906
|
const lookup = (async () => {
|
|
906
907
|
try {
|
|
907
|
-
const result = await this.#client.request("GET", `${API_PREFIX}/github/repos/${encodeURIComponent(repository.owner)}/${encodeURIComponent(repository.repo)}/collaborators/${encodeURIComponent(username)}/permission`,
|
|
908
|
+
const result = await this.#client.request("GET", `${API_PREFIX}/github/repos/${encodeURIComponent(repository.owner)}/${encodeURIComponent(repository.repo)}/collaborators/${encodeURIComponent(username)}/permission`, { signal: AbortSignal.timeout(COLLABORATOR_PERMISSION_LOOKUP_TIMEOUT_MS) });
|
|
908
909
|
setBounded(this.#collaboratorPermissionCache, cacheKey, {
|
|
909
910
|
permission: result.permission,
|
|
910
911
|
expiresAt: Date.now() + COLLABORATOR_PERMISSION_CACHE_TTL_MS
|
|
@@ -962,13 +963,13 @@ var PlatformGithubIntegration = class {
|
|
|
962
963
|
async mintInstallationToken(installationId) {
|
|
963
964
|
const repositories = await this.listInstallationRepos(installationId);
|
|
964
965
|
if (repositories.length === 0 || repositories.length > MAX_REPOSITORIES_PER_TOKEN) throw new Error("Platform GitHub token minting requires between one and ten installation repositories.");
|
|
965
|
-
return (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, {
|
|
966
|
+
return (await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${installationId}/token`, { body: {
|
|
966
967
|
repositories: repositories.map((repository) => repository.name),
|
|
967
968
|
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
968
|
-
})).token;
|
|
969
|
+
} })).token;
|
|
969
970
|
}
|
|
970
971
|
async addIssueLabels(_installationId, sourceId, issueNumber, labels) {
|
|
971
|
-
return (await this.#client.request("POST", repositoryPath(sourceId, `issues/${issueNumber}/labels`), { labels })).labels;
|
|
972
|
+
return (await this.#client.request("POST", repositoryPath(sourceId, `issues/${issueNumber}/labels`), { body: { labels } })).labels;
|
|
972
973
|
}
|
|
973
974
|
async removeIssueLabel(_installationId, sourceId, issueNumber, label) {
|
|
974
975
|
const name = label.trim();
|
|
@@ -1031,9 +1032,12 @@ var PlatformGithubIntegration = class {
|
|
|
1031
1032
|
}
|
|
1032
1033
|
try {
|
|
1033
1034
|
return parseIntakeIssue(repository, await this.#client.request("PATCH", repositoryPath(repository, `issues/${issueNumber}`), {
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1035
|
+
body: {
|
|
1036
|
+
state: targetState,
|
|
1037
|
+
...stateReason ? { state_reason: stateReason } : {}
|
|
1038
|
+
},
|
|
1039
|
+
...actingUser(input.actingUserId)
|
|
1040
|
+
}));
|
|
1037
1041
|
} catch (error) {
|
|
1038
1042
|
if (isNotFound(error)) return null;
|
|
1039
1043
|
throw error;
|
|
@@ -1053,7 +1057,10 @@ var PlatformGithubIntegration = class {
|
|
|
1053
1057
|
const repository = requireSource(input.sourceId, "GitHub Intake requires a repository source.");
|
|
1054
1058
|
const issueNumber = requirePositiveId(input.issueId, "issue");
|
|
1055
1059
|
try {
|
|
1056
|
-
const comment = await this.#client.request("POST", repositoryPath(repository, `issues/${issueNumber}/comments`), {
|
|
1060
|
+
const comment = await this.#client.request("POST", repositoryPath(repository, `issues/${issueNumber}/comments`), {
|
|
1061
|
+
body: { body: input.body },
|
|
1062
|
+
...actingUser(input.actingUserId)
|
|
1063
|
+
});
|
|
1057
1064
|
this.#observeSelfAuthor(comment, input.actingUserId);
|
|
1058
1065
|
return {
|
|
1059
1066
|
id: String(comment.id),
|
|
@@ -1089,22 +1096,25 @@ var PlatformGithubIntegration = class {
|
|
|
1089
1096
|
async #createPullRequest(input) {
|
|
1090
1097
|
requireGithubConnection(input.connection);
|
|
1091
1098
|
const result = await this.#client.request("POST", repositoryPath(input.sourceId, "pulls"), {
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1099
|
+
body: {
|
|
1100
|
+
head: input.headBranch,
|
|
1101
|
+
base: input.baseBranch,
|
|
1102
|
+
title: input.title,
|
|
1103
|
+
body: input.body,
|
|
1104
|
+
draft: input.draft
|
|
1105
|
+
},
|
|
1106
|
+
...actingUser(input.actingUserId)
|
|
1107
|
+
});
|
|
1098
1108
|
const created = parsePullRequest(result);
|
|
1099
1109
|
if (input.actingUserId && input.connection.type === "app-installation") try {
|
|
1100
1110
|
const user = await this.#fetchUserConnection(input.actingUserId);
|
|
1101
1111
|
const login = user.githubUsername;
|
|
1102
1112
|
if (user.connected && login) {
|
|
1103
1113
|
const { owner, repo } = splitRepository(input.sourceId);
|
|
1104
|
-
const { token } = await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${input.connection.installationId}/token`, {
|
|
1114
|
+
const { token } = await this.#client.request("POST", `${API_PREFIX}/github-app/installations/${input.connection.installationId}/token`, { body: {
|
|
1105
1115
|
repositories: [repo],
|
|
1106
1116
|
permissions: REPOSITORY_TOKEN_PERMISSIONS
|
|
1107
|
-
});
|
|
1117
|
+
} });
|
|
1108
1118
|
const { data } = await new Octokit({
|
|
1109
1119
|
auth: token,
|
|
1110
1120
|
request: { timeout: 15e3 }
|
|
@@ -1130,18 +1140,24 @@ var PlatformGithubIntegration = class {
|
|
|
1130
1140
|
}
|
|
1131
1141
|
async #updatePullRequest(input) {
|
|
1132
1142
|
return parsePullRequest(await this.#client.request("PATCH", pullRequestPath(input, input.pullRequestId), {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1143
|
+
body: {
|
|
1144
|
+
title: input.title,
|
|
1145
|
+
body: input.body === null ? "" : input.body,
|
|
1146
|
+
base: input.baseBranch,
|
|
1147
|
+
state: input.state
|
|
1148
|
+
},
|
|
1149
|
+
...actingUser(input.actingUserId)
|
|
1150
|
+
}));
|
|
1138
1151
|
}
|
|
1139
1152
|
#mergePullRequest(input) {
|
|
1140
1153
|
return this.#client.request("PUT", `${pullRequestPath(input, input.pullRequestId)}/merge`, {
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1154
|
+
body: {
|
|
1155
|
+
commitTitle: input.commitTitle,
|
|
1156
|
+
commitMessage: input.commitMessage,
|
|
1157
|
+
method: input.method
|
|
1158
|
+
},
|
|
1159
|
+
...actingUser(input.actingUserId)
|
|
1160
|
+
});
|
|
1145
1161
|
}
|
|
1146
1162
|
async #listComments(input) {
|
|
1147
1163
|
const page = parsePositiveCursor(input.cursor);
|
|
@@ -1152,17 +1168,23 @@ var PlatformGithubIntegration = class {
|
|
|
1152
1168
|
};
|
|
1153
1169
|
}
|
|
1154
1170
|
async #createComment(input) {
|
|
1155
|
-
const comment = await this.#client.request("POST", repositoryPath(input.sourceId, `issues/${requirePositiveId(input.pullRequestId, "pull request")}/comments`), {
|
|
1171
|
+
const comment = await this.#client.request("POST", repositoryPath(input.sourceId, `issues/${requirePositiveId(input.pullRequestId, "pull request")}/comments`), {
|
|
1172
|
+
body: { body: input.body },
|
|
1173
|
+
...actingUser(input.actingUserId)
|
|
1174
|
+
});
|
|
1156
1175
|
this.#observeSelfAuthor(comment, input.actingUserId);
|
|
1157
1176
|
return parseComment(comment);
|
|
1158
1177
|
}
|
|
1159
1178
|
async #updateComment(input) {
|
|
1160
1179
|
requireGithubConnection(input.connection);
|
|
1161
|
-
return parseComment(await this.#client.request("PATCH", repositoryPath(input.sourceId, `issues/comments/${requirePositiveId(input.commentId, "comment")}`), {
|
|
1180
|
+
return parseComment(await this.#client.request("PATCH", repositoryPath(input.sourceId, `issues/comments/${requirePositiveId(input.commentId, "comment")}`), {
|
|
1181
|
+
body: { body: input.body },
|
|
1182
|
+
...actingUser(input.actingUserId)
|
|
1183
|
+
}));
|
|
1162
1184
|
}
|
|
1163
1185
|
async #deleteComment(input) {
|
|
1164
1186
|
requireGithubConnection(input.connection);
|
|
1165
|
-
await this.#client.request("DELETE", repositoryPath(input.sourceId, `issues/comments/${requirePositiveId(input.commentId, "comment")}`),
|
|
1187
|
+
await this.#client.request("DELETE", repositoryPath(input.sourceId, `issues/comments/${requirePositiveId(input.commentId, "comment")}`), { ...actingUser(input.actingUserId) });
|
|
1166
1188
|
}
|
|
1167
1189
|
async #listReviews(input) {
|
|
1168
1190
|
const page = parsePositiveCursor(input.cursor);
|
|
@@ -1182,26 +1204,32 @@ var PlatformGithubIntegration = class {
|
|
|
1182
1204
|
}
|
|
1183
1205
|
async #createReview(input) {
|
|
1184
1206
|
return parseReview(await this.#client.request("POST", `${pullRequestPath(input, input.pullRequestId)}/reviews`, {
|
|
1185
|
-
body:
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1207
|
+
body: {
|
|
1208
|
+
body: input.body,
|
|
1209
|
+
commitId: input.commitId,
|
|
1210
|
+
event: input.event ? reviewEvent(input.event) : void 0
|
|
1211
|
+
},
|
|
1212
|
+
...actingUser(input.actingUserId)
|
|
1213
|
+
}));
|
|
1189
1214
|
}
|
|
1190
1215
|
async #publishCommitCheck(input) {
|
|
1191
1216
|
requireGithubConnection(input.connection);
|
|
1192
1217
|
const run = await this.#client.request("POST", repositoryPath(input.sourceId, "check-runs"), {
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
status: "
|
|
1197
|
-
|
|
1218
|
+
body: {
|
|
1219
|
+
name: input.name,
|
|
1220
|
+
headSha: input.headSha,
|
|
1221
|
+
...input.status === "in-progress" ? { status: "in_progress" } : {
|
|
1222
|
+
status: "completed",
|
|
1223
|
+
conclusion: input.status
|
|
1224
|
+
},
|
|
1225
|
+
output: {
|
|
1226
|
+
title: input.title.slice(0, CHECK_TITLE_LIMIT),
|
|
1227
|
+
summary: input.summary.slice(0, CHECK_TEXT_LIMIT),
|
|
1228
|
+
...input.details ? { text: input.details.slice(0, CHECK_TEXT_LIMIT) } : {}
|
|
1229
|
+
}
|
|
1198
1230
|
},
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
summary: input.summary.slice(0, CHECK_TEXT_LIMIT),
|
|
1202
|
-
...input.details ? { text: input.details.slice(0, CHECK_TEXT_LIMIT) } : {}
|
|
1203
|
-
}
|
|
1204
|
-
}, { actingUserId: input.actingUserId });
|
|
1231
|
+
...actingUser(input.actingUserId)
|
|
1232
|
+
});
|
|
1205
1233
|
return {
|
|
1206
1234
|
id: String(run.id),
|
|
1207
1235
|
name: input.name,
|
|
@@ -1211,19 +1239,28 @@ var PlatformGithubIntegration = class {
|
|
|
1211
1239
|
};
|
|
1212
1240
|
}
|
|
1213
1241
|
async #updateReview(input) {
|
|
1214
|
-
return parseReview(await this.#client.request("PUT", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}`, {
|
|
1242
|
+
return parseReview(await this.#client.request("PUT", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}`, {
|
|
1243
|
+
body: { body: input.body },
|
|
1244
|
+
...actingUser(input.actingUserId)
|
|
1245
|
+
}));
|
|
1215
1246
|
}
|
|
1216
1247
|
async #submitReview(input) {
|
|
1217
1248
|
return parseReview(await this.#client.request("POST", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}/events`, {
|
|
1218
|
-
body:
|
|
1219
|
-
|
|
1220
|
-
|
|
1249
|
+
body: {
|
|
1250
|
+
body: input.body,
|
|
1251
|
+
event: reviewEvent(input.event)
|
|
1252
|
+
},
|
|
1253
|
+
...actingUser(input.actingUserId)
|
|
1254
|
+
}));
|
|
1221
1255
|
}
|
|
1222
1256
|
async #dismissReview(input) {
|
|
1223
|
-
return parseReview(await this.#client.request("PUT", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}/dismissals`, {
|
|
1257
|
+
return parseReview(await this.#client.request("PUT", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}/dismissals`, {
|
|
1258
|
+
body: { message: input.message },
|
|
1259
|
+
...actingUser(input.actingUserId)
|
|
1260
|
+
}));
|
|
1224
1261
|
}
|
|
1225
1262
|
async #deletePendingReview(input) {
|
|
1226
|
-
await this.#client.request("DELETE", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}`,
|
|
1263
|
+
await this.#client.request("DELETE", `${pullRequestPath(input, input.pullRequestId)}/reviews/${requirePositiveId(input.reviewId, "review")}`, { ...actingUser(input.actingUserId) });
|
|
1227
1264
|
}
|
|
1228
1265
|
async #listReviewComments(input) {
|
|
1229
1266
|
const page = parsePositiveCursor(input.cursor);
|
|
@@ -1251,22 +1288,38 @@ var PlatformGithubIntegration = class {
|
|
|
1251
1288
|
startSide: input.startSide?.toUpperCase()
|
|
1252
1289
|
};
|
|
1253
1290
|
}
|
|
1254
|
-
return parseReviewComment(await this.#client.request("POST", `${pullRequestPath(input, input.pullRequestId)}/comments`,
|
|
1291
|
+
return parseReviewComment(await this.#client.request("POST", `${pullRequestPath(input, input.pullRequestId)}/comments`, {
|
|
1292
|
+
body,
|
|
1293
|
+
...actingUser(input.actingUserId)
|
|
1294
|
+
}));
|
|
1255
1295
|
}
|
|
1256
1296
|
async #updateReviewComment(input) {
|
|
1257
1297
|
requireGithubConnection(input.connection);
|
|
1258
|
-
return parseReviewComment(await this.#client.request("PATCH", repositoryPath(input.sourceId, `pulls/comments/${requirePositiveId(input.commentId, "review comment")}`), {
|
|
1298
|
+
return parseReviewComment(await this.#client.request("PATCH", repositoryPath(input.sourceId, `pulls/comments/${requirePositiveId(input.commentId, "review comment")}`), {
|
|
1299
|
+
body: { body: input.body },
|
|
1300
|
+
...actingUser(input.actingUserId)
|
|
1301
|
+
}));
|
|
1259
1302
|
}
|
|
1260
1303
|
async #deleteReviewComment(input) {
|
|
1261
1304
|
requireGithubConnection(input.connection);
|
|
1262
|
-
await this.#client.request("DELETE", repositoryPath(input.sourceId, `pulls/comments/${requirePositiveId(input.commentId, "review comment")}`),
|
|
1305
|
+
await this.#client.request("DELETE", repositoryPath(input.sourceId, `pulls/comments/${requirePositiveId(input.commentId, "review comment")}`), { ...actingUser(input.actingUserId) });
|
|
1306
|
+
}
|
|
1307
|
+
async #resolveReviewThread(input) {
|
|
1308
|
+
requireGithubConnection(input.connection);
|
|
1309
|
+
await this.#client.request("PUT", repositoryPath(input.sourceId, `pulls/comments/${requirePositiveId(input.commentId, "review comment")}/thread`), {
|
|
1310
|
+
body: { resolved: input.resolved },
|
|
1311
|
+
...actingUser(input.actingUserId)
|
|
1312
|
+
});
|
|
1263
1313
|
}
|
|
1264
1314
|
#requestedReviewers(method, input) {
|
|
1265
1315
|
requireGithubConnection(input.connection);
|
|
1266
|
-
return this.#client.request(method, `${pullRequestPath(input, input.pullRequestId)}/requested-reviewers`, method === "GET" ?
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1316
|
+
return this.#client.request(method, `${pullRequestPath(input, input.pullRequestId)}/requested-reviewers`, method === "GET" ? {} : {
|
|
1317
|
+
body: {
|
|
1318
|
+
users: input.users,
|
|
1319
|
+
teams: input.teams
|
|
1320
|
+
},
|
|
1321
|
+
...actingUser(input.actingUserId)
|
|
1322
|
+
});
|
|
1270
1323
|
}
|
|
1271
1324
|
};
|
|
1272
1325
|
function repositoryPath(sourceId, suffix) {
|
|
@@ -1423,11 +1476,19 @@ function reviewEvent(event) {
|
|
|
1423
1476
|
if (event === "request-changes") return "REQUEST_CHANGES";
|
|
1424
1477
|
return "COMMENT";
|
|
1425
1478
|
}
|
|
1479
|
+
/**
|
|
1480
|
+
* Names the Factory user a platform GitHub write acts for, so the platform
|
|
1481
|
+
* authors it with that user's GitHub connection instead of the App bot.
|
|
1482
|
+
*/
|
|
1483
|
+
function actingUser(actingUserId) {
|
|
1484
|
+
return actingUserId ? { headers: { "x-acting-user-id": actingUserId } } : {};
|
|
1485
|
+
}
|
|
1426
1486
|
function isNotFound(error) {
|
|
1427
|
-
return error
|
|
1487
|
+
return platformErrorStatus(error) === 404;
|
|
1428
1488
|
}
|
|
1429
1489
|
function isDeadInstallation(error) {
|
|
1430
|
-
|
|
1490
|
+
const status = platformErrorStatus(error);
|
|
1491
|
+
return status === 404 || status === 409;
|
|
1431
1492
|
}
|
|
1432
1493
|
export { PlatformGithubIntegration };
|
|
1433
1494
|
|