@mastra/factory 0.18.0 → 0.19.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 +13 -1
- package/dist/boards/registry.d.ts.map +1 -1
- package/dist/boards/registry.js +0 -2
- package/dist/boards/registry.js.map +1 -1
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +12 -2
- package/dist/factory.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +10 -2
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +28 -4
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/integration.js +1 -1
- package/dist/integrations/github/reconcile-worker.d.ts.map +1 -1
- package/dist/integrations/github/reconcile-worker.js +1 -2
- package/dist/integrations/github/reconcile-worker.js.map +1 -1
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +2 -15
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +5 -0
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +17 -8
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/stale-reviews.d.ts +22 -0
- package/dist/integrations/github/stale-reviews.d.ts.map +1 -0
- package/dist/integrations/github/stale-reviews.js +70 -0
- package/dist/integrations/github/stale-reviews.js.map +1 -0
- package/dist/integrations/gitlab/version-control.d.ts.map +1 -1
- package/dist/integrations/gitlab/version-control.js +4 -5
- package/dist/integrations/gitlab/version-control.js.map +1 -1
- package/dist/integrations/gitlab/webhook.d.ts.map +1 -1
- package/dist/integrations/gitlab/webhook.js +2 -2
- package/dist/integrations/gitlab/webhook.js.map +1 -1
- package/dist/integrations/issue-reconcile-worker.d.ts.map +1 -1
- package/dist/integrations/issue-reconcile-worker.js +1 -2
- package/dist/integrations/issue-reconcile-worker.js.map +1 -1
- package/dist/integrations/jira/integration.d.ts.map +1 -1
- package/dist/integrations/jira/integration.js +7 -1
- package/dist/integrations/jira/integration.js.map +1 -1
- package/dist/integrations/linear/integration.d.ts.map +1 -1
- package/dist/integrations/linear/integration.js +10 -30
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +1 -2
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.js +1 -1
- package/dist/integrations/platform/gitlab/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/gitlab/event-worker.js +1 -2
- package/dist/integrations/platform/gitlab/event-worker.js.map +1 -1
- package/dist/integrations/platform/jira/integration.d.ts.map +1 -1
- package/dist/integrations/platform/jira/integration.js +7 -1
- package/dist/integrations/platform/jira/integration.js.map +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/linear/event-worker.js +1 -2
- package/dist/integrations/platform/linear/event-worker.js.map +1 -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/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +1 -2
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/review-verdict.d.ts +6 -0
- package/dist/review-verdict.d.ts.map +1 -0
- package/dist/review-verdict.js +14 -0
- package/dist/review-verdict.js.map +1 -0
- package/dist/routes/attention-providers.d.ts +6 -7
- package/dist/routes/attention-providers.d.ts.map +1 -1
- package/dist/routes/attention-providers.js +12 -5
- package/dist/routes/attention-providers.js.map +1 -1
- package/dist/routes/attention.d.ts +2 -0
- package/dist/routes/attention.d.ts.map +1 -1
- package/dist/routes/attention.js +9 -3
- package/dist/routes/attention.js.map +1 -1
- package/dist/routes/oauth.d.ts.map +1 -1
- package/dist/routes/oauth.js +3 -3
- package/dist/routes/oauth.js.map +1 -1
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +1 -2
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +10 -5
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/decision-applicability.d.ts +26 -0
- package/dist/rules/decision-applicability.d.ts.map +1 -0
- package/dist/rules/decision-applicability.js +47 -0
- package/dist/rules/decision-applicability.js.map +1 -0
- package/dist/rules/dispatcher.d.ts +4 -0
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +33 -24
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +5 -5
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +1 -2
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +18 -1
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +20 -0
- package/dist/rules/validation.js.map +1 -1
- package/dist/secret-encryption.js +2 -2
- package/dist/secret-encryption.js.map +1 -1
- package/dist/session/factory-session.d.ts.map +1 -1
- package/dist/session/factory-session.js +1 -2
- package/dist/session/factory-session.js.map +1 -1
- package/dist/session/source-control-tools.d.ts +9 -0
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +51 -2
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/state-signing.js +3 -3
- package/dist/state-signing.js.map +1 -1
- package/dist/storage/domains/audit/base.d.ts.map +1 -1
- package/dist/storage/domains/audit/base.js +2 -3
- package/dist/storage/domains/audit/base.js.map +1 -1
- package/dist/storage/domains/source-control/inmemory.d.ts.map +1 -1
- package/dist/storage/domains/source-control/inmemory.js +5 -6
- package/dist/storage/domains/source-control/inmemory.js.map +1 -1
- package/dist/storage/domains/work-items/base.d.ts +3 -0
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +15 -2
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/supervisor/write-tools.d.ts +2 -0
- package/dist/supervisor/write-tools.d.ts.map +1 -1
- package/dist/supervisor/write-tools.js +3 -0
- package/dist/supervisor/write-tools.js.map +1 -1
- package/factory-skills/configure-factory-rules/SKILL.md +1 -1
- package/factory-skills/factory-gitlab-rereview/SKILL.md +1 -1
- package/factory-skills/factory-gitlab-review/SKILL.md +1 -1
- package/factory-skills/factory-rereview/SKILL.md +12 -3
- package/factory-skills/factory-review/SKILL.md +12 -3
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-control.js","names":[],"sources":["../../../src/integrations/gitlab/version-control.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\n\nimport type { IntegrationConnection } from '../../capabilities/connection.js';\nimport type {\n PullRequest,\n PullRequestComment,\n RequestedReviewers,\n Review,\n ReviewComment,\n VersionControl,\n} from '../../capabilities/version-control.js';\nimport type { SourceControlStorageHandle } from '../../storage/domains/source-control/base.js';\nimport {\n GITLAB_DISCUSSIONS_PAGE_SIZE,\n GITLAB_MERGE_REQUESTS_PAGE_SIZE,\n GITLAB_NOTES_PAGE_SIZE,\n GitLabApiError,\n} from './api.js';\nimport type {\n GitLabApiClient,\n GitLabDiscussionNote,\n GitLabDiscussionPosition,\n GitLabMember,\n GitLabMergeRequest,\n GitLabNote,\n GitLabUser,\n} from './api.js';\n\nexport interface GitLabVersionControlContext {\n api: GitLabApiClient;\n connection: IntegrationConnection;\n host: string;\n webBaseUrl?: string;\n repositoryAccessToken?: () => Promise<string>;\n}\n\nexport interface GitLabVersionControlDependencies {\n contextForConnection(connection: IntegrationConnection): Promise<GitLabVersionControlContext>;\n contextForStoredInstallation?(\n connection: IntegrationConnection,\n host: string | undefined,\n ): Promise<GitLabVersionControlContext>;\n}\n\nexport function buildGitLabVersionControl(deps: GitLabVersionControlDependencies): VersionControl {\n let storage: SourceControlStorageHandle | undefined;\n\n const sourceControlStorage = (): SourceControlStorageHandle => {\n if (!storage) throw new Error('GitLab VersionControl is not initialized.');\n return storage;\n };\n\n const listPullRequests: VersionControl['listPullRequests'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const page = parsePositiveCursor(input.cursor);\n const state = input.state === 'open' ? 'opened' : input.state === 'closed' ? 'all' : (input.state ?? 'opened');\n const mergeRequests = await context.api.listMergeRequests(input.sourceId, { page, state });\n return {\n pullRequests: mergeRequests\n .filter(\n mergeRequest =>\n input.state !== 'closed' || mergeRequest.state === 'closed' || mergeRequest.state === 'merged',\n )\n .filter(mergeRequest => input.includeDrafts !== false || !isDraft(mergeRequest))\n .map(toPullRequest),\n nextCursor: mergeRequests.length === GITLAB_MERGE_REQUESTS_PAGE_SIZE ? String(page + 1) : null,\n };\n };\n\n const getPullRequest: VersionControl['getPullRequest'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n try {\n return toPullRequest(\n await context.api.getMergeRequest(input.sourceId, requirePositiveId(input.pullRequestId, 'merge request')),\n );\n } catch (error) {\n if (error instanceof GitLabApiError && error.status === 404) return null;\n throw error;\n }\n };\n\n const createPullRequest: VersionControl['createPullRequest'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const title = input.draft && !/^(?:draft:|\\[draft\\])/i.test(input.title) ? `Draft: ${input.title}` : input.title;\n return toPullRequest(\n await context.api.createMergeRequest(input.sourceId, {\n sourceBranch: input.headBranch,\n targetBranch: input.baseBranch,\n title,\n description: input.body,\n }),\n );\n };\n\n const updatePullRequest: VersionControl['updatePullRequest'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n return toPullRequest(\n await context.api.updateMergeRequest(input.sourceId, requirePositiveId(input.pullRequestId, 'merge request'), {\n title: input.title,\n description: input.body === null ? '' : input.body,\n targetBranch: input.baseBranch,\n stateEvent: input.state === 'closed' ? 'close' : input.state === 'open' ? 'reopen' : undefined,\n }),\n );\n };\n\n const closePullRequest: VersionControl['closePullRequest'] = input =>\n updatePullRequest({ ...input, state: 'closed' });\n\n const mergePullRequest: VersionControl['mergePullRequest'] = async input => {\n if (input.method === 'rebase') {\n throw notSupported('GitLab rebases merge requests asynchronously; rebase-and-merge is not supported.');\n }\n const context = await deps.contextForConnection(input.connection);\n const commitMessage = combinedCommitMessage(input.commitTitle, input.commitMessage);\n const result = await context.api.mergeMergeRequest(\n input.sourceId,\n requirePositiveId(input.pullRequestId, 'merge request'),\n {\n squash: input.method === 'squash',\n mergeCommitMessage: input.method === 'squash' ? undefined : commitMessage,\n squashCommitMessage: input.method === 'squash' ? commitMessage : undefined,\n },\n );\n const merged = result.state === 'merged' || Boolean(result.merged_at);\n return {\n merged,\n message: result.message ?? (merged ? 'Merge request merged.' : 'Merge request was not merged.'),\n sha: result.squash_commit_sha ?? result.merge_commit_sha ?? result.sha ?? null,\n };\n };\n\n const listComments: VersionControl['listComments'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const page = parsePositiveCursor(input.cursor);\n const notes = await context.api.listMergeRequestNotes(input.sourceId, mergeRequestIid, { page });\n return {\n comments: notes\n .filter(note => !note.system && note.type !== 'DiffNote')\n .map(note => toPullRequestComment(webBaseUrl(context), input.sourceId, mergeRequestIid, note)),\n nextCursor: notes.length === GITLAB_NOTES_PAGE_SIZE ? String(page + 1) : null,\n };\n };\n\n const createComment: VersionControl['createComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const note = await context.api.createMergeRequestNote(input.sourceId, mergeRequestIid, input.body);\n return toPullRequestComment(webBaseUrl(context), input.sourceId, mergeRequestIid, note);\n };\n\n const updateComment: VersionControl['updateComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const { mergeRequestIid, noteId } = parseNoteId(input.commentId);\n const note = await context.api.updateMergeRequestNote(input.sourceId, mergeRequestIid, noteId, input.body);\n return toPullRequestComment(webBaseUrl(context), input.sourceId, mergeRequestIid, note);\n };\n\n const deleteComment: VersionControl['deleteComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const { mergeRequestIid, noteId } = parseNoteId(input.commentId);\n await context.api.deleteMergeRequestNote(input.sourceId, mergeRequestIid, noteId);\n };\n\n const listReviews: VersionControl['listReviews'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const approvals = await context.api.getMergeRequestApprovals(input.sourceId, mergeRequestIid);\n return {\n reviews: (approvals.approved_by ?? []).map(({ user }) =>\n toApprovalReview(webBaseUrl(context), input.sourceId, mergeRequestIid, user),\n ),\n nextCursor: null,\n };\n };\n\n const getReview: VersionControl['getReview'] = async input => {\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const approvalPrefix = `${mergeRequestIid}:approval`;\n const commentPrefix = `${mergeRequestIid}:comment:`;\n if (\n input.reviewId !== approvalPrefix &&\n !input.reviewId.startsWith(`${approvalPrefix}:`) &&\n !input.reviewId.startsWith(commentPrefix)\n ) {\n return null;\n }\n const context = await deps.contextForConnection(input.connection);\n if (input.reviewId === approvalPrefix || input.reviewId.startsWith(`${approvalPrefix}:`)) {\n const reviewerKey = input.reviewId === approvalPrefix ? null : input.reviewId.slice(approvalPrefix.length + 1);\n if (reviewerKey === '') return null;\n const currentUser = reviewerKey === null ? await context.api.getCurrentUser() : null;\n const approvals = await context.api.getMergeRequestApprovals(input.sourceId, mergeRequestIid);\n const user = (approvals.approved_by ?? [])\n .map(entry => entry.user)\n .find(candidate =>\n reviewerKey === null\n ? (currentUser?.id !== undefined && candidate.id === currentUser.id) ||\n candidate.username === currentUser?.username\n : String(candidate.id ?? candidate.username) === reviewerKey,\n );\n return user ? toApprovalReview(webBaseUrl(context), input.sourceId, mergeRequestIid, user) : null;\n }\n const noteId = parsePositiveInteger(input.reviewId.slice(commentPrefix.length));\n if (noteId === null) return null;\n try {\n const note = await context.api.getMergeRequestNote(input.sourceId, mergeRequestIid, noteId);\n if (note.system || note.type === 'DiffNote') return null;\n return toCommentReview(webBaseUrl(context), input.sourceId, mergeRequestIid, note);\n } catch (error) {\n if (error instanceof GitLabApiError && error.status === 404) return null;\n throw error;\n }\n };\n\n const createReview: VersionControl['createReview'] = async input =>\n submitReviewAction(deps, {\n connection: input.connection,\n sourceId: input.sourceId,\n pullRequestId: input.pullRequestId,\n event: input.event,\n body: input.body,\n commitId: input.commitId,\n });\n\n const updateReview: VersionControl['updateReview'] = async () => {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab does not expose mutable pending review objects.');\n };\n\n const submitReview: VersionControl['submitReview'] = async input =>\n submitReviewAction(deps, {\n connection: input.connection,\n sourceId: input.sourceId,\n pullRequestId: input.pullRequestId,\n event: input.event,\n body: input.body,\n });\n\n const dismissReview: VersionControl['dismissReview'] = async () => {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab approval dismissal has no GitHub review equivalent.');\n };\n\n const deletePendingReview: VersionControl['deletePendingReview'] = async () => {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab does not expose pending review objects.');\n };\n\n const listReviewComments: VersionControl['listReviewComments'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const page = parsePositiveCursor(input.cursor);\n const discussions = await context.api.listMergeRequestDiscussions(input.sourceId, mergeRequestIid, { page });\n return {\n comments: discussions.flatMap(discussion => {\n const position = discussionPosition(discussion.notes);\n if (!position) return [];\n const root = discussion.notes.find(note => note.position) ?? discussion.notes[0];\n const replyToId = root ? packDiscussionNoteId(mergeRequestIid, discussion.id, root.id) : null;\n return discussion.notes\n .filter(note => !note.system)\n .map(note =>\n toReviewComment(\n webBaseUrl(context),\n input.sourceId,\n mergeRequestIid,\n discussion.id,\n note,\n note === root ? null : replyToId,\n position,\n ),\n );\n }),\n nextCursor: discussions.length === GITLAB_DISCUSSIONS_PAGE_SIZE ? String(page + 1) : null,\n };\n };\n\n const createReviewComment: VersionControl['createReviewComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n if (input.replyToId) {\n const thread = parseReviewReplyId(input.replyToId);\n if (thread.mergeRequestIid !== mergeRequestIid) {\n throw new GitLabApiError('GitLab discussion does not belong to the requested merge request.', 400);\n }\n const discussion = await context.api.getMergeRequestDiscussion(\n input.sourceId,\n mergeRequestIid,\n thread.discussionId,\n );\n const position = discussionPosition(discussion.notes);\n if (!position) throw new GitLabApiError('GitLab discussion is not anchored to a diff.', 400);\n const root = discussion.notes.find(note => note.position) ?? discussion.notes[0];\n if (!root) throw new GitLabApiError('GitLab discussion response did not include a note.', 502);\n const note = await context.api.addMergeRequestDiscussionNote(\n input.sourceId,\n mergeRequestIid,\n thread.discussionId,\n input.body,\n );\n return toReviewComment(\n webBaseUrl(context),\n input.sourceId,\n mergeRequestIid,\n thread.discussionId,\n note,\n packDiscussionNoteId(mergeRequestIid, thread.discussionId, root.id),\n position,\n );\n }\n\n const mergeRequest = await context.api.getMergeRequest(input.sourceId, mergeRequestIid);\n if (!mergeRequest.diff_refs) {\n throw new GitLabApiError('GitLab merge request diff refs are not ready.', 409);\n }\n if (mergeRequest.diff_refs.head_sha !== input.commitId) {\n throw new GitLabApiError('GitLab merge request changed since this review comment was prepared.', 409);\n }\n const { path, line, side } = input;\n if (typeof path !== 'string' || typeof line !== 'number' || (side !== 'left' && side !== 'right')) {\n throw new GitLabApiError('GitLab diff review comment position is invalid.', 400);\n }\n if ((input.startLine === undefined) !== (input.startSide === undefined)) {\n throw new GitLabApiError('A multi-line GitLab review comment requires both startLine and startSide.', 400);\n }\n const position: GitLabDiscussionPosition = {\n position_type: 'text',\n ...mergeRequest.diff_refs,\n old_path: path,\n new_path: path,\n old_line: side === 'left' ? line : undefined,\n new_line: side === 'right' ? line : undefined,\n ...(input.startLine !== undefined && input.startSide\n ? {\n line_range: {\n start: discussionLine(path, input.startLine, input.startSide),\n end: discussionLine(path, line, side),\n },\n }\n : {}),\n };\n const discussion = await context.api.createMergeRequestDiscussion(input.sourceId, mergeRequestIid, {\n body: input.body,\n commitId: input.commitId,\n position,\n });\n const note = discussion.notes.find(candidate => candidate.position) ?? discussion.notes[0];\n if (!note) throw new GitLabApiError('GitLab discussion response did not include a note.', 502);\n return toReviewComment(webBaseUrl(context), input.sourceId, mergeRequestIid, discussion.id, note, null, position);\n };\n\n const updateReviewComment: VersionControl['updateReviewComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const reference = parseDiscussionNoteId(input.commentId);\n const discussion = await context.api.getMergeRequestDiscussion(\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n );\n const position = discussionPosition(discussion.notes);\n if (!position) throw new GitLabApiError('GitLab discussion is not anchored to a diff.', 400);\n const root = discussion.notes.find(candidate => candidate.position) ?? discussion.notes[0];\n if (!root) throw new GitLabApiError('GitLab discussion response did not include a note.', 502);\n const note = await context.api.updateMergeRequestDiscussionNote(\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n reference.noteId,\n input.body,\n );\n return toReviewComment(\n webBaseUrl(context),\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n note,\n note.id === root.id ? null : packDiscussionNoteId(reference.mergeRequestIid, reference.discussionId, root.id),\n position,\n );\n };\n\n const deleteReviewComment: VersionControl['deleteReviewComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const reference = parseDiscussionNoteId(input.commentId);\n await context.api.deleteMergeRequestDiscussionNote(\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n reference.noteId,\n );\n };\n\n const resolveReviewThread: NonNullable<VersionControl['resolveReviewThread']> = async input => {\n const context = await deps.contextForConnection(input.connection);\n const reference = parseDiscussionNoteId(input.commentId);\n await context.api.resolveMergeRequestDiscussion(\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n input.resolved,\n );\n };\n\n const listRequestedReviewers: VersionControl['listRequestedReviewers'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequest = await context.api.getMergeRequest(\n input.sourceId,\n requirePositiveId(input.pullRequestId, 'merge request'),\n );\n return toRequestedReviewers(mergeRequest);\n };\n\n const requestReviewers: VersionControl['requestReviewers'] = async input => {\n rejectTeamReviewers(input.teams);\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const mergeRequest = await context.api.getMergeRequest(input.sourceId, mergeRequestIid);\n const requestedMembers = await resolveMembers(context.api, input.sourceId, input.users ?? []);\n const currentIds = await reviewerIds(context.api, input.sourceId, mergeRequest.reviewers ?? []);\n const reviewerIdsToSet = [...new Set([...currentIds, ...requestedMembers.map(member => member.id)])];\n return toRequestedReviewers(\n await context.api.setMergeRequestReviewers(input.sourceId, mergeRequestIid, reviewerIdsToSet),\n );\n };\n\n const removeRequestedReviewers: VersionControl['removeRequestedReviewers'] = async input => {\n rejectTeamReviewers(input.teams);\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const mergeRequest = await context.api.getMergeRequest(input.sourceId, mergeRequestIid);\n const removals = new Set((input.users ?? []).map(username => username.toLowerCase()));\n const retained = (mergeRequest.reviewers ?? []).filter(user => !removals.has(user.username.toLowerCase()));\n const retainedIds = await reviewerIds(context.api, input.sourceId, retained);\n return toRequestedReviewers(\n await context.api.setMergeRequestReviewers(input.sourceId, mergeRequestIid, retainedIds),\n );\n };\n\n return {\n initialize: input => {\n storage = input.storage;\n },\n registerInstallation: async ({ orgId, userId, installation }) => {\n const requestedConnection = parseConnection(installation.metadata?.connection);\n if (!requestedConnection) {\n throw new GitLabApiError('GitLab installation metadata must include a valid connection.', 400);\n }\n const context = await deps.contextForConnection(requestedConnection);\n return sourceControlStorage().installations.upsert({\n orgId,\n connectedByUserId: userId,\n externalId: installation.externalId,\n accountName: installation.accountName,\n accountType: installation.accountType,\n providerMetadata: {\n ...installation.metadata,\n connection: context.connection,\n host: normalizeHost(context.host),\n },\n });\n },\n registerRepositories: async ({ orgId, installationId, repositories }) => {\n const normalizedRepositories = repositories.map(repository => ({\n ...repository,\n slug: normalizeSlug(repository.slug),\n }));\n return await Promise.all(\n normalizedRepositories.map(repository =>\n sourceControlStorage().repositories.upsert({\n orgId,\n input: {\n installationId,\n externalId: repository.externalId,\n slug: repository.slug,\n defaultBranch: repository.defaultBranch,\n providerMetadata: repository.metadata,\n },\n }),\n ),\n );\n },\n getRepositoryTarget: async ({ orgId, repositoryId }) => {\n const repository = await sourceControlStorage().repositories.get({ orgId, id: repositoryId });\n if (!repository) throw new Error('Version-control repository not found.');\n const installation = await sourceControlStorage().installations.get({\n orgId,\n id: repository.installationId,\n });\n if (!installation) throw new Error('Version-control installation not found.');\n const connection = parseConnection(installation.providerMetadata.connection);\n if (!connection) throw new GitLabApiError('GitLab installation connection metadata is invalid.', 500);\n const context = await (deps.contextForStoredInstallation ?? deps.contextForConnection)(\n connection,\n typeof installation.providerMetadata.host === 'string' ? installation.providerMetadata.host : undefined,\n );\n // The API uses GitLab's immutable numeric project ID because Platform's\n // proxy normalizes encoded path slashes; retain the slug for browser URLs.\n return { connection: context.connection, sourceId: `${repository.externalId}:${repository.slug}` };\n },\n getRepositoryAccess: async ({ orgId, repositoryId }) => {\n const repository = await sourceControlStorage().repositories.get({ orgId, id: repositoryId });\n if (!repository) throw new Error('Version-control repository not found.');\n const installation = await sourceControlStorage().installations.get({\n orgId,\n id: repository.installationId,\n });\n if (!installation) throw new Error('Version-control installation not found.');\n const connection = parseConnection(installation.providerMetadata.connection);\n if (!connection) throw new GitLabApiError('GitLab installation connection metadata is invalid.', 500);\n const context = await (deps.contextForStoredInstallation ?? deps.contextForConnection)(\n connection,\n typeof installation.providerMetadata.host === 'string' ? installation.providerMetadata.host : undefined,\n );\n if (!context.repositoryAccessToken) {\n throw notSupported('This GitLab connection does not expose credentials for repository cloning.');\n }\n const token = await context.repositoryAccessToken();\n const baseUrl = webBaseUrl(context);\n const slug = normalizeSlug(repository.slug);\n return {\n cloneUrl: `${baseUrl}/${slug}.git`,\n authorization: { scheme: 'bearer', token, username: 'oauth2' },\n };\n },\n listPullRequests,\n getPullRequest,\n createPullRequest,\n updatePullRequest,\n closePullRequest,\n mergePullRequest,\n listComments,\n resolveReviewThread,\n createComment,\n updateComment,\n deleteComment,\n listReviews,\n getReview,\n createReview,\n updateReview,\n submitReview,\n dismissReview,\n deletePendingReview,\n listReviewComments,\n createReviewComment,\n updateReviewComment,\n deleteReviewComment,\n listRequestedReviewers,\n requestReviewers,\n removeRequestedReviewers,\n };\n}\n\nasync function submitReviewAction(\n deps: GitLabVersionControlDependencies,\n input: {\n connection: IntegrationConnection;\n sourceId: string;\n pullRequestId: string;\n event: 'approve' | 'request-changes' | 'comment' | undefined;\n body?: string;\n commitId?: string;\n },\n): Promise<Review> {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n if (input.event === 'request-changes') {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab has no first-class request-changes review event.');\n }\n if (input.event === undefined) {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab has no first-class pending review object.');\n }\n if (input.event === 'approve') {\n const body = input.body?.trim();\n await context.api.approveMergeRequest(input.sourceId, mergeRequestIid, input.commitId);\n const comment = body\n ? toPullRequestComment(\n webBaseUrl(context),\n input.sourceId,\n mergeRequestIid,\n await context.api.createMergeRequestNote(input.sourceId, mergeRequestIid, body),\n )\n : null;\n return {\n id: String(mergeRequestIid) + ':approval',\n url: comment?.url ?? mergeRequestUrl(webBaseUrl(context), input.sourceId, mergeRequestIid),\n author: comment?.author ?? null,\n body: comment?.body ?? null,\n state: 'approved',\n commitId: null,\n submittedAt: comment?.createdAt ?? null,\n };\n }\n const body = input.body?.trim();\n if (!body) throw new GitLabApiError('GitLab comment reviews require a body.', 400);\n const note = await context.api.createMergeRequestNote(input.sourceId, mergeRequestIid, body);\n return toCommentReview(webBaseUrl(context), input.sourceId, mergeRequestIid, note);\n}\n\nfunction toCommentReview(host: string, sourceId: string, mergeRequestIid: number, note: GitLabNote): Review {\n const comment = toPullRequestComment(host, sourceId, mergeRequestIid, note);\n return {\n id: `${mergeRequestIid}:comment:${note.id}`,\n url: comment.url,\n author: comment.author,\n body: comment.body,\n state: 'commented',\n commitId: null,\n submittedAt: note.created_at,\n };\n}\n\nfunction toApprovalReview(host: string, sourceId: string, mergeRequestIid: number, user: GitLabUser): Review {\n return {\n id: `${mergeRequestIid}:approval:${user.id ?? user.username}`,\n url: mergeRequestUrl(host, sourceId, mergeRequestIid),\n author: displayName(user),\n body: null,\n state: 'approved',\n commitId: null,\n submittedAt: null,\n };\n}\n\nfunction toReviewComment(\n host: string,\n sourceId: string,\n mergeRequestIid: number,\n discussionId: string,\n note: GitLabDiscussionNote,\n replyToId: string | null,\n fallbackPosition?: GitLabDiscussionPosition,\n): ReviewComment {\n const position = note.position ?? fallbackPosition;\n if (!position) throw new GitLabApiError('GitLab review comment is missing its diff position.', 502);\n const base = toPullRequestComment(host, sourceId, mergeRequestIid, note);\n const side = position.new_line !== null && position.new_line !== undefined ? 'right' : 'left';\n return {\n ...base,\n id: packDiscussionNoteId(mergeRequestIid, discussionId, note.id),\n path: side === 'right' ? position.new_path : position.old_path,\n line: side === 'right' ? (position.new_line ?? null) : (position.old_line ?? null),\n side,\n commitId: position.head_sha,\n replyToId,\n };\n}\n\nfunction mergeRequestUrl(host: string, sourceId: string, mergeRequestIid: number): string {\n return `${host}/${sourcePath(sourceId)}/-/merge_requests/${mergeRequestIid}`;\n}\n\nfunction webBaseUrl(context: GitLabVersionControlContext): string {\n const host = normalizeHost(context.host);\n if (!context.webBaseUrl) return `https://${host}`;\n let url: URL;\n try {\n url = new URL(context.webBaseUrl);\n } catch {\n throw new GitLabApiError('GitLab web base URL is invalid.', 400);\n }\n const loopback =\n url.hostname === 'localhost' || url.hostname === '[::1]' || /^127(?:\\.\\d{1,3}){3}$/.test(url.hostname);\n if (\n url.host !== host ||\n (url.protocol !== 'https:' && !(url.protocol === 'http:' && loopback)) ||\n url.username ||\n url.password ||\n url.search ||\n url.hash\n ) {\n throw new GitLabApiError('GitLab web base URL is invalid.', 400);\n }\n return `${url.origin}${url.pathname.replace(/\\/+$/, '')}`;\n}\n\nfunction sourcePath(sourceId: string): string {\n const match = /^\\d+:(.+)$/.exec(sourceId);\n return normalizeSlug(match?.[1] ?? sourceId);\n}\n\nfunction packDiscussionId(mergeRequestIid: number, discussionId: string): string {\n if (!discussionId || discussionId.includes(':')) {\n throw new GitLabApiError('GitLab discussion id is invalid.', 400);\n }\n return `${mergeRequestIid}:${discussionId}`;\n}\n\nfunction packDiscussionNoteId(mergeRequestIid: number, discussionId: string, noteId: number): string {\n return `${packDiscussionId(mergeRequestIid, discussionId)}:${noteId}`;\n}\n\nfunction parseReviewReplyId(value: string): { mergeRequestIid: number; discussionId: string } {\n const parts = value.split(':');\n if (parts.length === 2) return parseDiscussionId(value);\n if (parts.length === 3 && parts[1]) {\n requirePositiveId(parts[2]!, 'discussion note');\n return {\n mergeRequestIid: requirePositiveId(parts[0]!, 'merge request'),\n discussionId: parts[1],\n };\n }\n throw new GitLabApiError('GitLab review reply id is invalid.', 400);\n}\n\nfunction parseDiscussionId(value: string): { mergeRequestIid: number; discussionId: string } {\n const parts = value.split(':');\n if (parts.length !== 2 || !parts[1]) throw new GitLabApiError('GitLab discussion id is invalid.', 400);\n return {\n mergeRequestIid: requirePositiveId(parts[0]!, 'merge request'),\n discussionId: parts[1],\n };\n}\n\nfunction parseDiscussionNoteId(value: string): { mergeRequestIid: number; discussionId: string; noteId: number } {\n const parts = value.split(':');\n if (parts.length !== 3 || !parts[1]) throw new GitLabApiError('GitLab discussion note id is invalid.', 400);\n return {\n mergeRequestIid: requirePositiveId(parts[0]!, 'merge request'),\n discussionId: parts[1],\n noteId: requirePositiveId(parts[2]!, 'discussion note'),\n };\n}\n\nfunction discussionPosition(notes: GitLabDiscussionNote[]): GitLabDiscussionPosition | undefined {\n return notes.find(note => note.position)?.position ?? undefined;\n}\n\nfunction discussionLine(path: string, line: number, side: 'left' | 'right') {\n const pathHash = createHash('sha1').update(path).digest('hex');\n const oldLine = side === 'left' ? line : undefined;\n const newLine = side === 'right' ? line : undefined;\n return {\n line_code: `${pathHash}_${oldLine ?? 0}_${newLine ?? 0}`,\n type: side === 'left' ? ('old' as const) : ('new' as const),\n old_line: oldLine,\n new_line: newLine,\n };\n}\n\nfunction toRequestedReviewers(mergeRequest: GitLabMergeRequest): RequestedReviewers {\n return {\n users: (mergeRequest.reviewers ?? []).map(user => user.username),\n teams: [],\n };\n}\n\nasync function resolveMembers(api: GitLabApiClient, sourceId: string, usernames: string[]): Promise<GitLabMember[]> {\n return Promise.all(usernames.map(username => resolveMember(api, sourceId, username)));\n}\n\nasync function resolveMember(api: GitLabApiClient, sourceId: string, username: string): Promise<GitLabMember> {\n const normalized = username.trim();\n if (!normalized) throw new GitLabApiError('GitLab reviewer username is invalid.', 400);\n const members = await api.listProjectMembers(sourceId, { query: normalized });\n const member = members.find(candidate => candidate.username.toLowerCase() === normalized.toLowerCase());\n if (!member) throw new GitLabApiError(`GitLab reviewer ${normalized} is not a project member.`, 404);\n return member;\n}\n\nasync function reviewerIds(api: GitLabApiClient, sourceId: string, users: GitLabUser[]): Promise<number[]> {\n return Promise.all(users.map(async user => user.id ?? (await resolveMember(api, sourceId, user.username)).id));\n}\n\nfunction rejectTeamReviewers(teams: string[] | undefined): void {\n if (!teams?.length) return;\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab merge requests do not have a direct team-reviewer equivalent.');\n}\n\nfunction notSupported(message: string): GitLabApiError {\n return new GitLabApiError(message, 501);\n}\n\nfunction toPullRequest(mergeRequest: GitLabMergeRequest): PullRequest {\n return {\n id: String(mergeRequest.iid),\n title: mergeRequest.title,\n url: mergeRequest.web_url,\n author: displayName(mergeRequest.author),\n assignees: mergeRequest.assignees?.map(user => user.username),\n requestedReviewers: mergeRequest.reviewers?.map(user => user.username),\n labels: mergeRequest.labels,\n body: mergeRequest.description?.trim() ? mergeRequest.description : null,\n state: mergeRequest.state === 'closed' || mergeRequest.state === 'merged' ? 'closed' : 'open',\n draft: isDraft(mergeRequest),\n merged: mergeRequest.state === 'merged' || Boolean(mergeRequest.merged_at),\n mergeable: mergeableState(mergeRequest.merge_status),\n baseBranch: mergeRequest.target_branch,\n headBranch: mergeRequest.source_branch,\n headSha: mergeRequest.sha,\n createdAt: mergeRequest.created_at,\n updatedAt: mergeRequest.updated_at,\n };\n}\n\nfunction toPullRequestComment(\n host: string,\n sourceId: string,\n mergeRequestIid: number,\n note: GitLabNote,\n): PullRequestComment {\n return {\n id: `${mergeRequestIid}:${note.id}`,\n url: `${mergeRequestUrl(host, sourceId, mergeRequestIid)}#note_${note.id}`,\n author: displayName(note.author),\n body: note.body,\n createdAt: note.created_at,\n updatedAt: note.updated_at ?? note.created_at,\n };\n}\n\nfunction displayName(user: { name?: string | null; username: string } | null | undefined): string | null {\n return user?.username || user?.name?.trim() || null;\n}\n\nfunction isDraft(mergeRequest: GitLabMergeRequest): boolean {\n return mergeRequest.draft ?? mergeRequest.work_in_progress ?? /^(?:draft:|\\[draft\\])/i.test(mergeRequest.title);\n}\n\nfunction mergeableState(status: string | undefined): boolean | null {\n if (status === 'can_be_merged') return true;\n if (status === 'cannot_be_merged') return false;\n return null;\n}\n\nfunction combinedCommitMessage(title: string | undefined, body: string | undefined): string | undefined {\n const parts = [title?.trim(), body?.trim()].filter((part): part is string => Boolean(part));\n return parts.length > 0 ? parts.join('\\n\\n') : undefined;\n}\n\nfunction parseNoteId(value: string): { mergeRequestIid: number; noteId: number } {\n const parts = value.split(':');\n if (parts.length !== 2) throw new GitLabApiError('GitLab merge request note id is invalid.', 400);\n return {\n mergeRequestIid: requirePositiveId(parts[0]!, 'merge request'),\n noteId: requirePositiveId(parts[1]!, 'note'),\n };\n}\n\nfunction parsePositiveCursor(cursor: string | undefined): number {\n if (cursor === undefined) return 1;\n const page = parsePositiveInteger(cursor);\n if (page === null) throw new GitLabApiError('GitLab cursor must be a positive page number.', 400);\n return page;\n}\n\nfunction requirePositiveId(value: string, resource: string): number {\n const parsed = parsePositiveInteger(value);\n if (parsed === null) throw new GitLabApiError(`GitLab ${resource} id must be a positive integer.`, 400);\n return parsed;\n}\n\nfunction parsePositiveInteger(value: string): number | null {\n if (!/^\\d+$/.test(value)) return null;\n const parsed = Number(value);\n return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;\n}\n\nfunction parseConnection(value: unknown): IntegrationConnection | null {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return null;\n const connection = value as Record<string, unknown>;\n if (connection.type === 'oauth' && typeof connection.accessToken === 'string' && connection.accessToken.length > 0) {\n return { type: 'oauth', accessToken: connection.accessToken };\n }\n if (\n connection.type === 'app-installation' &&\n Number.isSafeInteger(connection.installationId) &&\n Number(connection.installationId) > 0\n ) {\n return { type: 'app-installation', installationId: Number(connection.installationId) };\n }\n return null;\n}\n\nfunction normalizeHost(value: string): string {\n const host = value.trim();\n if (!host || host.includes('/') || host.includes('@')) throw new GitLabApiError('GitLab host is invalid.', 400);\n let parsed: URL;\n try {\n parsed = new URL(`https://${host}`);\n } catch {\n throw new GitLabApiError('GitLab host is invalid.', 400);\n }\n if (parsed.host !== host) throw new GitLabApiError('GitLab host is invalid.', 400);\n return host;\n}\n\nfunction normalizeSlug(value: string): string {\n const slug = value.replace(/^\\/+|\\/+$/g, '');\n const segments = slug.split('/');\n if (!slug || segments.some(segment => !/^[A-Za-z0-9_.-]+$/.test(segment) || segment === '.' || segment === '..')) {\n throw new GitLabApiError('GitLab repository slug is invalid.', 400);\n }\n return slug;\n}\n"],"mappings":";;;AA4CA,SAAgB,0BAA0B,MAAwD;CAChG,IAAI;CAEJ,MAA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ACA,IAAI,OAAO,SAAS,MAAM,MAAM,IAAI,eAAe,2BAA2B,GAAG;CACjF,OAAO;AACT;AAEA,SAAS,cAAc,OAAuB;CAC5C,MAAM,OAAO,MAAM,QAAQ,cAAc,EAAE;CAC3C,MAAM,WAAW,KAAK,MAAM,GAAG;CAC/B,IAAI,CAAC,QAAQ,SAAS,MAAK,YAAW,CAAC,oBAAoB,KAAK,OAAO,KAAK,YAAY,OAAO,YAAY,IAAI,GAC7G,MAAM,IAAI,eAAe,sCAAsC,GAAG;CAEpE,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"version-control.js","names":[],"sources":["../../../src/integrations/gitlab/version-control.ts"],"sourcesContent":["import type { IntegrationConnection } from '../../capabilities/connection.js';\nimport type {\n PullRequest,\n PullRequestComment,\n RequestedReviewers,\n Review,\n ReviewComment,\n VersionControl,\n} from '../../capabilities/version-control.js';\nimport type { SourceControlStorageHandle } from '../../storage/domains/source-control/base.js';\nimport {\n GITLAB_DISCUSSIONS_PAGE_SIZE,\n GITLAB_MERGE_REQUESTS_PAGE_SIZE,\n GITLAB_NOTES_PAGE_SIZE,\n GitLabApiError,\n} from './api.js';\nimport type {\n GitLabApiClient,\n GitLabDiscussionNote,\n GitLabDiscussionPosition,\n GitLabMember,\n GitLabMergeRequest,\n GitLabNote,\n GitLabUser,\n} from './api.js';\n\nexport interface GitLabVersionControlContext {\n api: GitLabApiClient;\n connection: IntegrationConnection;\n host: string;\n webBaseUrl?: string;\n repositoryAccessToken?: () => Promise<string>;\n}\n\nexport interface GitLabVersionControlDependencies {\n contextForConnection(connection: IntegrationConnection): Promise<GitLabVersionControlContext>;\n contextForStoredInstallation?(\n connection: IntegrationConnection,\n host: string | undefined,\n ): Promise<GitLabVersionControlContext>;\n}\n\nexport function buildGitLabVersionControl(deps: GitLabVersionControlDependencies): VersionControl {\n let storage: SourceControlStorageHandle | undefined;\n\n const sourceControlStorage = (): SourceControlStorageHandle => {\n if (!storage) throw new Error('GitLab VersionControl is not initialized.');\n return storage;\n };\n\n const listPullRequests: VersionControl['listPullRequests'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const page = parsePositiveCursor(input.cursor);\n const state = input.state === 'open' ? 'opened' : input.state === 'closed' ? 'all' : (input.state ?? 'opened');\n const mergeRequests = await context.api.listMergeRequests(input.sourceId, { page, state });\n return {\n pullRequests: mergeRequests\n .filter(\n mergeRequest =>\n input.state !== 'closed' || mergeRequest.state === 'closed' || mergeRequest.state === 'merged',\n )\n .filter(mergeRequest => input.includeDrafts !== false || !isDraft(mergeRequest))\n .map(toPullRequest),\n nextCursor: mergeRequests.length === GITLAB_MERGE_REQUESTS_PAGE_SIZE ? String(page + 1) : null,\n };\n };\n\n const getPullRequest: VersionControl['getPullRequest'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n try {\n return toPullRequest(\n await context.api.getMergeRequest(input.sourceId, requirePositiveId(input.pullRequestId, 'merge request')),\n );\n } catch (error) {\n if (error instanceof GitLabApiError && error.status === 404) return null;\n throw error;\n }\n };\n\n const createPullRequest: VersionControl['createPullRequest'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const title = input.draft && !/^(?:draft:|\\[draft\\])/i.test(input.title) ? `Draft: ${input.title}` : input.title;\n return toPullRequest(\n await context.api.createMergeRequest(input.sourceId, {\n sourceBranch: input.headBranch,\n targetBranch: input.baseBranch,\n title,\n description: input.body,\n }),\n );\n };\n\n const updatePullRequest: VersionControl['updatePullRequest'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n return toPullRequest(\n await context.api.updateMergeRequest(input.sourceId, requirePositiveId(input.pullRequestId, 'merge request'), {\n title: input.title,\n description: input.body === null ? '' : input.body,\n targetBranch: input.baseBranch,\n stateEvent: input.state === 'closed' ? 'close' : input.state === 'open' ? 'reopen' : undefined,\n }),\n );\n };\n\n const closePullRequest: VersionControl['closePullRequest'] = input =>\n updatePullRequest({ ...input, state: 'closed' });\n\n const mergePullRequest: VersionControl['mergePullRequest'] = async input => {\n if (input.method === 'rebase') {\n throw notSupported('GitLab rebases merge requests asynchronously; rebase-and-merge is not supported.');\n }\n const context = await deps.contextForConnection(input.connection);\n const commitMessage = combinedCommitMessage(input.commitTitle, input.commitMessage);\n const result = await context.api.mergeMergeRequest(\n input.sourceId,\n requirePositiveId(input.pullRequestId, 'merge request'),\n {\n squash: input.method === 'squash',\n mergeCommitMessage: input.method === 'squash' ? undefined : commitMessage,\n squashCommitMessage: input.method === 'squash' ? commitMessage : undefined,\n },\n );\n const merged = result.state === 'merged' || Boolean(result.merged_at);\n return {\n merged,\n message: result.message ?? (merged ? 'Merge request merged.' : 'Merge request was not merged.'),\n sha: result.squash_commit_sha ?? result.merge_commit_sha ?? result.sha ?? null,\n };\n };\n\n const listComments: VersionControl['listComments'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const page = parsePositiveCursor(input.cursor);\n const notes = await context.api.listMergeRequestNotes(input.sourceId, mergeRequestIid, { page });\n return {\n comments: notes\n .filter(note => !note.system && note.type !== 'DiffNote')\n .map(note => toPullRequestComment(webBaseUrl(context), input.sourceId, mergeRequestIid, note)),\n nextCursor: notes.length === GITLAB_NOTES_PAGE_SIZE ? String(page + 1) : null,\n };\n };\n\n const createComment: VersionControl['createComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const note = await context.api.createMergeRequestNote(input.sourceId, mergeRequestIid, input.body);\n return toPullRequestComment(webBaseUrl(context), input.sourceId, mergeRequestIid, note);\n };\n\n const updateComment: VersionControl['updateComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const { mergeRequestIid, noteId } = parseNoteId(input.commentId);\n const note = await context.api.updateMergeRequestNote(input.sourceId, mergeRequestIid, noteId, input.body);\n return toPullRequestComment(webBaseUrl(context), input.sourceId, mergeRequestIid, note);\n };\n\n const deleteComment: VersionControl['deleteComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const { mergeRequestIid, noteId } = parseNoteId(input.commentId);\n await context.api.deleteMergeRequestNote(input.sourceId, mergeRequestIid, noteId);\n };\n\n const listReviews: VersionControl['listReviews'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const approvals = await context.api.getMergeRequestApprovals(input.sourceId, mergeRequestIid);\n return {\n reviews: (approvals.approved_by ?? []).map(({ user }) =>\n toApprovalReview(webBaseUrl(context), input.sourceId, mergeRequestIid, user),\n ),\n nextCursor: null,\n };\n };\n\n const getReview: VersionControl['getReview'] = async input => {\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const approvalPrefix = `${mergeRequestIid}:approval`;\n const commentPrefix = `${mergeRequestIid}:comment:`;\n if (\n input.reviewId !== approvalPrefix &&\n !input.reviewId.startsWith(`${approvalPrefix}:`) &&\n !input.reviewId.startsWith(commentPrefix)\n ) {\n return null;\n }\n const context = await deps.contextForConnection(input.connection);\n if (input.reviewId === approvalPrefix || input.reviewId.startsWith(`${approvalPrefix}:`)) {\n const reviewerKey = input.reviewId === approvalPrefix ? null : input.reviewId.slice(approvalPrefix.length + 1);\n if (reviewerKey === '') return null;\n const currentUser = reviewerKey === null ? await context.api.getCurrentUser() : null;\n const approvals = await context.api.getMergeRequestApprovals(input.sourceId, mergeRequestIid);\n const user = (approvals.approved_by ?? [])\n .map(entry => entry.user)\n .find(candidate =>\n reviewerKey === null\n ? (currentUser?.id !== undefined && candidate.id === currentUser.id) ||\n candidate.username === currentUser?.username\n : String(candidate.id ?? candidate.username) === reviewerKey,\n );\n return user ? toApprovalReview(webBaseUrl(context), input.sourceId, mergeRequestIid, user) : null;\n }\n const noteId = parsePositiveInteger(input.reviewId.slice(commentPrefix.length));\n if (noteId === null) return null;\n try {\n const note = await context.api.getMergeRequestNote(input.sourceId, mergeRequestIid, noteId);\n if (note.system || note.type === 'DiffNote') return null;\n return toCommentReview(webBaseUrl(context), input.sourceId, mergeRequestIid, note);\n } catch (error) {\n if (error instanceof GitLabApiError && error.status === 404) return null;\n throw error;\n }\n };\n\n const createReview: VersionControl['createReview'] = async input =>\n submitReviewAction(deps, {\n connection: input.connection,\n sourceId: input.sourceId,\n pullRequestId: input.pullRequestId,\n event: input.event,\n body: input.body,\n commitId: input.commitId,\n });\n\n const updateReview: VersionControl['updateReview'] = async () => {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab does not expose mutable pending review objects.');\n };\n\n const submitReview: VersionControl['submitReview'] = async input =>\n submitReviewAction(deps, {\n connection: input.connection,\n sourceId: input.sourceId,\n pullRequestId: input.pullRequestId,\n event: input.event,\n body: input.body,\n });\n\n const dismissReview: VersionControl['dismissReview'] = async () => {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab approval dismissal has no GitHub review equivalent.');\n };\n\n const deletePendingReview: VersionControl['deletePendingReview'] = async () => {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab does not expose pending review objects.');\n };\n\n const listReviewComments: VersionControl['listReviewComments'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const page = parsePositiveCursor(input.cursor);\n const discussions = await context.api.listMergeRequestDiscussions(input.sourceId, mergeRequestIid, { page });\n return {\n comments: discussions.flatMap(discussion => {\n const position = discussionPosition(discussion.notes);\n if (!position) return [];\n const root = discussion.notes.find(note => note.position) ?? discussion.notes[0];\n const replyToId = root ? packDiscussionNoteId(mergeRequestIid, discussion.id, root.id) : null;\n return discussion.notes\n .filter(note => !note.system)\n .map(note =>\n toReviewComment(\n webBaseUrl(context),\n input.sourceId,\n mergeRequestIid,\n discussion.id,\n note,\n note === root ? null : replyToId,\n position,\n ),\n );\n }),\n nextCursor: discussions.length === GITLAB_DISCUSSIONS_PAGE_SIZE ? String(page + 1) : null,\n };\n };\n\n const createReviewComment: VersionControl['createReviewComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n if (input.replyToId) {\n const thread = parseReviewReplyId(input.replyToId);\n if (thread.mergeRequestIid !== mergeRequestIid) {\n throw new GitLabApiError('GitLab discussion does not belong to the requested merge request.', 400);\n }\n const discussion = await context.api.getMergeRequestDiscussion(\n input.sourceId,\n mergeRequestIid,\n thread.discussionId,\n );\n const position = discussionPosition(discussion.notes);\n if (!position) throw new GitLabApiError('GitLab discussion is not anchored to a diff.', 400);\n const root = discussion.notes.find(note => note.position) ?? discussion.notes[0];\n if (!root) throw new GitLabApiError('GitLab discussion response did not include a note.', 502);\n const note = await context.api.addMergeRequestDiscussionNote(\n input.sourceId,\n mergeRequestIid,\n thread.discussionId,\n input.body,\n );\n return toReviewComment(\n webBaseUrl(context),\n input.sourceId,\n mergeRequestIid,\n thread.discussionId,\n note,\n packDiscussionNoteId(mergeRequestIid, thread.discussionId, root.id),\n position,\n );\n }\n\n const mergeRequest = await context.api.getMergeRequest(input.sourceId, mergeRequestIid);\n if (!mergeRequest.diff_refs) {\n throw new GitLabApiError('GitLab merge request diff refs are not ready.', 409);\n }\n if (mergeRequest.diff_refs.head_sha !== input.commitId) {\n throw new GitLabApiError('GitLab merge request changed since this review comment was prepared.', 409);\n }\n const { path, line, side } = input;\n if (typeof path !== 'string' || typeof line !== 'number' || (side !== 'left' && side !== 'right')) {\n throw new GitLabApiError('GitLab diff review comment position is invalid.', 400);\n }\n if ((input.startLine === undefined) !== (input.startSide === undefined)) {\n throw new GitLabApiError('A multi-line GitLab review comment requires both startLine and startSide.', 400);\n }\n const position: GitLabDiscussionPosition = {\n position_type: 'text',\n ...mergeRequest.diff_refs,\n old_path: path,\n new_path: path,\n old_line: side === 'left' ? line : undefined,\n new_line: side === 'right' ? line : undefined,\n ...(input.startLine !== undefined && input.startSide\n ? {\n line_range: {\n start: await discussionLine(path, input.startLine, input.startSide),\n end: await discussionLine(path, line, side),\n },\n }\n : {}),\n };\n const discussion = await context.api.createMergeRequestDiscussion(input.sourceId, mergeRequestIid, {\n body: input.body,\n commitId: input.commitId,\n position,\n });\n const note = discussion.notes.find(candidate => candidate.position) ?? discussion.notes[0];\n if (!note) throw new GitLabApiError('GitLab discussion response did not include a note.', 502);\n return toReviewComment(webBaseUrl(context), input.sourceId, mergeRequestIid, discussion.id, note, null, position);\n };\n\n const updateReviewComment: VersionControl['updateReviewComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const reference = parseDiscussionNoteId(input.commentId);\n const discussion = await context.api.getMergeRequestDiscussion(\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n );\n const position = discussionPosition(discussion.notes);\n if (!position) throw new GitLabApiError('GitLab discussion is not anchored to a diff.', 400);\n const root = discussion.notes.find(candidate => candidate.position) ?? discussion.notes[0];\n if (!root) throw new GitLabApiError('GitLab discussion response did not include a note.', 502);\n const note = await context.api.updateMergeRequestDiscussionNote(\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n reference.noteId,\n input.body,\n );\n return toReviewComment(\n webBaseUrl(context),\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n note,\n note.id === root.id ? null : packDiscussionNoteId(reference.mergeRequestIid, reference.discussionId, root.id),\n position,\n );\n };\n\n const deleteReviewComment: VersionControl['deleteReviewComment'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const reference = parseDiscussionNoteId(input.commentId);\n await context.api.deleteMergeRequestDiscussionNote(\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n reference.noteId,\n );\n };\n\n const resolveReviewThread: NonNullable<VersionControl['resolveReviewThread']> = async input => {\n const context = await deps.contextForConnection(input.connection);\n const reference = parseDiscussionNoteId(input.commentId);\n await context.api.resolveMergeRequestDiscussion(\n input.sourceId,\n reference.mergeRequestIid,\n reference.discussionId,\n input.resolved,\n );\n };\n\n const listRequestedReviewers: VersionControl['listRequestedReviewers'] = async input => {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequest = await context.api.getMergeRequest(\n input.sourceId,\n requirePositiveId(input.pullRequestId, 'merge request'),\n );\n return toRequestedReviewers(mergeRequest);\n };\n\n const requestReviewers: VersionControl['requestReviewers'] = async input => {\n rejectTeamReviewers(input.teams);\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const mergeRequest = await context.api.getMergeRequest(input.sourceId, mergeRequestIid);\n const requestedMembers = await resolveMembers(context.api, input.sourceId, input.users ?? []);\n const currentIds = await reviewerIds(context.api, input.sourceId, mergeRequest.reviewers ?? []);\n const reviewerIdsToSet = [...new Set([...currentIds, ...requestedMembers.map(member => member.id)])];\n return toRequestedReviewers(\n await context.api.setMergeRequestReviewers(input.sourceId, mergeRequestIid, reviewerIdsToSet),\n );\n };\n\n const removeRequestedReviewers: VersionControl['removeRequestedReviewers'] = async input => {\n rejectTeamReviewers(input.teams);\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n const mergeRequest = await context.api.getMergeRequest(input.sourceId, mergeRequestIid);\n const removals = new Set((input.users ?? []).map(username => username.toLowerCase()));\n const retained = (mergeRequest.reviewers ?? []).filter(user => !removals.has(user.username.toLowerCase()));\n const retainedIds = await reviewerIds(context.api, input.sourceId, retained);\n return toRequestedReviewers(\n await context.api.setMergeRequestReviewers(input.sourceId, mergeRequestIid, retainedIds),\n );\n };\n\n return {\n initialize: input => {\n storage = input.storage;\n },\n registerInstallation: async ({ orgId, userId, installation }) => {\n const requestedConnection = parseConnection(installation.metadata?.connection);\n if (!requestedConnection) {\n throw new GitLabApiError('GitLab installation metadata must include a valid connection.', 400);\n }\n const context = await deps.contextForConnection(requestedConnection);\n return sourceControlStorage().installations.upsert({\n orgId,\n connectedByUserId: userId,\n externalId: installation.externalId,\n accountName: installation.accountName,\n accountType: installation.accountType,\n providerMetadata: {\n ...installation.metadata,\n connection: context.connection,\n host: normalizeHost(context.host),\n },\n });\n },\n registerRepositories: async ({ orgId, installationId, repositories }) => {\n const normalizedRepositories = repositories.map(repository => ({\n ...repository,\n slug: normalizeSlug(repository.slug),\n }));\n return await Promise.all(\n normalizedRepositories.map(repository =>\n sourceControlStorage().repositories.upsert({\n orgId,\n input: {\n installationId,\n externalId: repository.externalId,\n slug: repository.slug,\n defaultBranch: repository.defaultBranch,\n providerMetadata: repository.metadata,\n },\n }),\n ),\n );\n },\n getRepositoryTarget: async ({ orgId, repositoryId }) => {\n const repository = await sourceControlStorage().repositories.get({ orgId, id: repositoryId });\n if (!repository) throw new Error('Version-control repository not found.');\n const installation = await sourceControlStorage().installations.get({\n orgId,\n id: repository.installationId,\n });\n if (!installation) throw new Error('Version-control installation not found.');\n const connection = parseConnection(installation.providerMetadata.connection);\n if (!connection) throw new GitLabApiError('GitLab installation connection metadata is invalid.', 500);\n const context = await (deps.contextForStoredInstallation ?? deps.contextForConnection)(\n connection,\n typeof installation.providerMetadata.host === 'string' ? installation.providerMetadata.host : undefined,\n );\n // The API uses GitLab's immutable numeric project ID because Platform's\n // proxy normalizes encoded path slashes; retain the slug for browser URLs.\n return { connection: context.connection, sourceId: `${repository.externalId}:${repository.slug}` };\n },\n getRepositoryAccess: async ({ orgId, repositoryId }) => {\n const repository = await sourceControlStorage().repositories.get({ orgId, id: repositoryId });\n if (!repository) throw new Error('Version-control repository not found.');\n const installation = await sourceControlStorage().installations.get({\n orgId,\n id: repository.installationId,\n });\n if (!installation) throw new Error('Version-control installation not found.');\n const connection = parseConnection(installation.providerMetadata.connection);\n if (!connection) throw new GitLabApiError('GitLab installation connection metadata is invalid.', 500);\n const context = await (deps.contextForStoredInstallation ?? deps.contextForConnection)(\n connection,\n typeof installation.providerMetadata.host === 'string' ? installation.providerMetadata.host : undefined,\n );\n if (!context.repositoryAccessToken) {\n throw notSupported('This GitLab connection does not expose credentials for repository cloning.');\n }\n const token = await context.repositoryAccessToken();\n const baseUrl = webBaseUrl(context);\n const slug = normalizeSlug(repository.slug);\n return {\n cloneUrl: `${baseUrl}/${slug}.git`,\n authorization: { scheme: 'bearer', token, username: 'oauth2' },\n };\n },\n listPullRequests,\n getPullRequest,\n createPullRequest,\n updatePullRequest,\n closePullRequest,\n mergePullRequest,\n listComments,\n resolveReviewThread,\n createComment,\n updateComment,\n deleteComment,\n listReviews,\n getReview,\n createReview,\n updateReview,\n submitReview,\n dismissReview,\n deletePendingReview,\n listReviewComments,\n createReviewComment,\n updateReviewComment,\n deleteReviewComment,\n listRequestedReviewers,\n requestReviewers,\n removeRequestedReviewers,\n };\n}\n\nasync function submitReviewAction(\n deps: GitLabVersionControlDependencies,\n input: {\n connection: IntegrationConnection;\n sourceId: string;\n pullRequestId: string;\n event: 'approve' | 'request-changes' | 'comment' | undefined;\n body?: string;\n commitId?: string;\n },\n): Promise<Review> {\n const context = await deps.contextForConnection(input.connection);\n const mergeRequestIid = requirePositiveId(input.pullRequestId, 'merge request');\n if (input.event === 'request-changes') {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab has no first-class request-changes review event.');\n }\n if (input.event === undefined) {\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab has no first-class pending review object.');\n }\n if (input.event === 'approve') {\n const body = input.body?.trim();\n await context.api.approveMergeRequest(input.sourceId, mergeRequestIid, input.commitId);\n const comment = body\n ? toPullRequestComment(\n webBaseUrl(context),\n input.sourceId,\n mergeRequestIid,\n await context.api.createMergeRequestNote(input.sourceId, mergeRequestIid, body),\n )\n : null;\n return {\n id: String(mergeRequestIid) + ':approval',\n url: comment?.url ?? mergeRequestUrl(webBaseUrl(context), input.sourceId, mergeRequestIid),\n author: comment?.author ?? null,\n body: comment?.body ?? null,\n state: 'approved',\n commitId: null,\n submittedAt: comment?.createdAt ?? null,\n };\n }\n const body = input.body?.trim();\n if (!body) throw new GitLabApiError('GitLab comment reviews require a body.', 400);\n const note = await context.api.createMergeRequestNote(input.sourceId, mergeRequestIid, body);\n return toCommentReview(webBaseUrl(context), input.sourceId, mergeRequestIid, note);\n}\n\nfunction toCommentReview(host: string, sourceId: string, mergeRequestIid: number, note: GitLabNote): Review {\n const comment = toPullRequestComment(host, sourceId, mergeRequestIid, note);\n return {\n id: `${mergeRequestIid}:comment:${note.id}`,\n url: comment.url,\n author: comment.author,\n body: comment.body,\n state: 'commented',\n commitId: null,\n submittedAt: note.created_at,\n };\n}\n\nfunction toApprovalReview(host: string, sourceId: string, mergeRequestIid: number, user: GitLabUser): Review {\n return {\n id: `${mergeRequestIid}:approval:${user.id ?? user.username}`,\n url: mergeRequestUrl(host, sourceId, mergeRequestIid),\n author: displayName(user),\n body: null,\n state: 'approved',\n commitId: null,\n submittedAt: null,\n };\n}\n\nfunction toReviewComment(\n host: string,\n sourceId: string,\n mergeRequestIid: number,\n discussionId: string,\n note: GitLabDiscussionNote,\n replyToId: string | null,\n fallbackPosition?: GitLabDiscussionPosition,\n): ReviewComment {\n const position = note.position ?? fallbackPosition;\n if (!position) throw new GitLabApiError('GitLab review comment is missing its diff position.', 502);\n const base = toPullRequestComment(host, sourceId, mergeRequestIid, note);\n const side = position.new_line !== null && position.new_line !== undefined ? 'right' : 'left';\n return {\n ...base,\n id: packDiscussionNoteId(mergeRequestIid, discussionId, note.id),\n path: side === 'right' ? position.new_path : position.old_path,\n line: side === 'right' ? (position.new_line ?? null) : (position.old_line ?? null),\n side,\n commitId: position.head_sha,\n replyToId,\n };\n}\n\nfunction mergeRequestUrl(host: string, sourceId: string, mergeRequestIid: number): string {\n return `${host}/${sourcePath(sourceId)}/-/merge_requests/${mergeRequestIid}`;\n}\n\nfunction webBaseUrl(context: GitLabVersionControlContext): string {\n const host = normalizeHost(context.host);\n if (!context.webBaseUrl) return `https://${host}`;\n let url: URL;\n try {\n url = new URL(context.webBaseUrl);\n } catch {\n throw new GitLabApiError('GitLab web base URL is invalid.', 400);\n }\n const loopback =\n url.hostname === 'localhost' || url.hostname === '[::1]' || /^127(?:\\.\\d{1,3}){3}$/.test(url.hostname);\n if (\n url.host !== host ||\n (url.protocol !== 'https:' && !(url.protocol === 'http:' && loopback)) ||\n url.username ||\n url.password ||\n url.search ||\n url.hash\n ) {\n throw new GitLabApiError('GitLab web base URL is invalid.', 400);\n }\n return `${url.origin}${url.pathname.replace(/\\/+$/, '')}`;\n}\n\nfunction sourcePath(sourceId: string): string {\n const match = /^\\d+:(.+)$/.exec(sourceId);\n return normalizeSlug(match?.[1] ?? sourceId);\n}\n\nfunction packDiscussionId(mergeRequestIid: number, discussionId: string): string {\n if (!discussionId || discussionId.includes(':')) {\n throw new GitLabApiError('GitLab discussion id is invalid.', 400);\n }\n return `${mergeRequestIid}:${discussionId}`;\n}\n\nfunction packDiscussionNoteId(mergeRequestIid: number, discussionId: string, noteId: number): string {\n return `${packDiscussionId(mergeRequestIid, discussionId)}:${noteId}`;\n}\n\nfunction parseReviewReplyId(value: string): { mergeRequestIid: number; discussionId: string } {\n const parts = value.split(':');\n if (parts.length === 2) return parseDiscussionId(value);\n if (parts.length === 3 && parts[1]) {\n requirePositiveId(parts[2]!, 'discussion note');\n return {\n mergeRequestIid: requirePositiveId(parts[0]!, 'merge request'),\n discussionId: parts[1],\n };\n }\n throw new GitLabApiError('GitLab review reply id is invalid.', 400);\n}\n\nfunction parseDiscussionId(value: string): { mergeRequestIid: number; discussionId: string } {\n const parts = value.split(':');\n if (parts.length !== 2 || !parts[1]) throw new GitLabApiError('GitLab discussion id is invalid.', 400);\n return {\n mergeRequestIid: requirePositiveId(parts[0]!, 'merge request'),\n discussionId: parts[1],\n };\n}\n\nfunction parseDiscussionNoteId(value: string): { mergeRequestIid: number; discussionId: string; noteId: number } {\n const parts = value.split(':');\n if (parts.length !== 3 || !parts[1]) throw new GitLabApiError('GitLab discussion note id is invalid.', 400);\n return {\n mergeRequestIid: requirePositiveId(parts[0]!, 'merge request'),\n discussionId: parts[1],\n noteId: requirePositiveId(parts[2]!, 'discussion note'),\n };\n}\n\nfunction discussionPosition(notes: GitLabDiscussionNote[]): GitLabDiscussionPosition | undefined {\n return notes.find(note => note.position)?.position ?? undefined;\n}\n\nasync function discussionLine(path: string, line: number, side: 'left' | 'right') {\n const pathHash = Buffer.from(await globalThis.crypto.subtle.digest('SHA-1', new TextEncoder().encode(path))).toString(\n 'hex',\n );\n const oldLine = side === 'left' ? line : undefined;\n const newLine = side === 'right' ? line : undefined;\n return {\n line_code: `${pathHash}_${oldLine ?? 0}_${newLine ?? 0}`,\n type: side === 'left' ? ('old' as const) : ('new' as const),\n old_line: oldLine,\n new_line: newLine,\n };\n}\n\nfunction toRequestedReviewers(mergeRequest: GitLabMergeRequest): RequestedReviewers {\n return {\n users: (mergeRequest.reviewers ?? []).map(user => user.username),\n teams: [],\n };\n}\n\nasync function resolveMembers(api: GitLabApiClient, sourceId: string, usernames: string[]): Promise<GitLabMember[]> {\n return Promise.all(usernames.map(username => resolveMember(api, sourceId, username)));\n}\n\nasync function resolveMember(api: GitLabApiClient, sourceId: string, username: string): Promise<GitLabMember> {\n const normalized = username.trim();\n if (!normalized) throw new GitLabApiError('GitLab reviewer username is invalid.', 400);\n const members = await api.listProjectMembers(sourceId, { query: normalized });\n const member = members.find(candidate => candidate.username.toLowerCase() === normalized.toLowerCase());\n if (!member) throw new GitLabApiError(`GitLab reviewer ${normalized} is not a project member.`, 404);\n return member;\n}\n\nasync function reviewerIds(api: GitLabApiClient, sourceId: string, users: GitLabUser[]): Promise<number[]> {\n return Promise.all(users.map(async user => user.id ?? (await resolveMember(api, sourceId, user.username)).id));\n}\n\nfunction rejectTeamReviewers(teams: string[] | undefined): void {\n if (!teams?.length) return;\n // FLAGGED FOR MANUAL REVIEW (spec §6.2)\n throw notSupported('GitLab merge requests do not have a direct team-reviewer equivalent.');\n}\n\nfunction notSupported(message: string): GitLabApiError {\n return new GitLabApiError(message, 501);\n}\n\nfunction toPullRequest(mergeRequest: GitLabMergeRequest): PullRequest {\n return {\n id: String(mergeRequest.iid),\n title: mergeRequest.title,\n url: mergeRequest.web_url,\n author: displayName(mergeRequest.author),\n assignees: mergeRequest.assignees?.map(user => user.username),\n requestedReviewers: mergeRequest.reviewers?.map(user => user.username),\n labels: mergeRequest.labels,\n body: mergeRequest.description?.trim() ? mergeRequest.description : null,\n state: mergeRequest.state === 'closed' || mergeRequest.state === 'merged' ? 'closed' : 'open',\n draft: isDraft(mergeRequest),\n merged: mergeRequest.state === 'merged' || Boolean(mergeRequest.merged_at),\n mergeable: mergeableState(mergeRequest.merge_status),\n baseBranch: mergeRequest.target_branch,\n headBranch: mergeRequest.source_branch,\n headSha: mergeRequest.sha,\n createdAt: mergeRequest.created_at,\n updatedAt: mergeRequest.updated_at,\n };\n}\n\nfunction toPullRequestComment(\n host: string,\n sourceId: string,\n mergeRequestIid: number,\n note: GitLabNote,\n): PullRequestComment {\n return {\n id: `${mergeRequestIid}:${note.id}`,\n url: `${mergeRequestUrl(host, sourceId, mergeRequestIid)}#note_${note.id}`,\n author: displayName(note.author),\n body: note.body,\n createdAt: note.created_at,\n updatedAt: note.updated_at ?? note.created_at,\n };\n}\n\nfunction displayName(user: { name?: string | null; username: string } | null | undefined): string | null {\n return user?.username || user?.name?.trim() || null;\n}\n\nfunction isDraft(mergeRequest: GitLabMergeRequest): boolean {\n return mergeRequest.draft ?? mergeRequest.work_in_progress ?? /^(?:draft:|\\[draft\\])/i.test(mergeRequest.title);\n}\n\nfunction mergeableState(status: string | undefined): boolean | null {\n if (status === 'can_be_merged') return true;\n if (status === 'cannot_be_merged') return false;\n return null;\n}\n\nfunction combinedCommitMessage(title: string | undefined, body: string | undefined): string | undefined {\n const parts = [title?.trim(), body?.trim()].filter((part): part is string => Boolean(part));\n return parts.length > 0 ? parts.join('\\n\\n') : undefined;\n}\n\nfunction parseNoteId(value: string): { mergeRequestIid: number; noteId: number } {\n const parts = value.split(':');\n if (parts.length !== 2) throw new GitLabApiError('GitLab merge request note id is invalid.', 400);\n return {\n mergeRequestIid: requirePositiveId(parts[0]!, 'merge request'),\n noteId: requirePositiveId(parts[1]!, 'note'),\n };\n}\n\nfunction parsePositiveCursor(cursor: string | undefined): number {\n if (cursor === undefined) return 1;\n const page = parsePositiveInteger(cursor);\n if (page === null) throw new GitLabApiError('GitLab cursor must be a positive page number.', 400);\n return page;\n}\n\nfunction requirePositiveId(value: string, resource: string): number {\n const parsed = parsePositiveInteger(value);\n if (parsed === null) throw new GitLabApiError(`GitLab ${resource} id must be a positive integer.`, 400);\n return parsed;\n}\n\nfunction parsePositiveInteger(value: string): number | null {\n if (!/^\\d+$/.test(value)) return null;\n const parsed = Number(value);\n return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;\n}\n\nfunction parseConnection(value: unknown): IntegrationConnection | null {\n if (!value || typeof value !== 'object' || Array.isArray(value)) return null;\n const connection = value as Record<string, unknown>;\n if (connection.type === 'oauth' && typeof connection.accessToken === 'string' && connection.accessToken.length > 0) {\n return { type: 'oauth', accessToken: connection.accessToken };\n }\n if (\n connection.type === 'app-installation' &&\n Number.isSafeInteger(connection.installationId) &&\n Number(connection.installationId) > 0\n ) {\n return { type: 'app-installation', installationId: Number(connection.installationId) };\n }\n return null;\n}\n\nfunction normalizeHost(value: string): string {\n const host = value.trim();\n if (!host || host.includes('/') || host.includes('@')) throw new GitLabApiError('GitLab host is invalid.', 400);\n let parsed: URL;\n try {\n parsed = new URL(`https://${host}`);\n } catch {\n throw new GitLabApiError('GitLab host is invalid.', 400);\n }\n if (parsed.host !== host) throw new GitLabApiError('GitLab host is invalid.', 400);\n return host;\n}\n\nfunction normalizeSlug(value: string): string {\n const slug = value.replace(/^\\/+|\\/+$/g, '');\n const segments = slug.split('/');\n if (!slug || segments.some(segment => !/^[A-Za-z0-9_.-]+$/.test(segment) || segment === '.' || segment === '..')) {\n throw new GitLabApiError('GitLab repository slug is invalid.', 400);\n }\n return slug;\n}\n"],"mappings":";;AA0CA,SAAgB,0BAA0B,MAAwD;CAChG,IAAI;CAEJ,MAAM,6BAAyD;EAC7D,IAAI,CAAC,SAAS,MAAM,IAAI,MAAM,2CAA2C;EACzE,O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B,kBAAkB,CACtC,CAAC,EAAE,OAAO,EACV,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,OAAO,CAAC,mBAAmB,GAAG,mBAAmB,CAAC,CAsCpD;AAcD,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,mBAAmB,GAAG,qBAAqB,CA2BjG;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAQpG;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,mBAAmB,CAAC,CA6B9B;AAED,wBAAsB,mBAAmB,CACvC,CAAC,EAAE,OAAO,EACV,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,mBAAmB,CAAC,CAK9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dispatchGitLabWebhook } from "./webhook-dispatch.js";
|
|
2
|
-
import {
|
|
2
|
+
import { timingSafeEqual } from "crypto";
|
|
3
3
|
//#region src/integrations/gitlab/webhook.ts
|
|
4
4
|
const SUPPORTED_GITLAB_WEBHOOK_EVENTS = /* @__PURE__ */ new Set([
|
|
5
5
|
"Issue Hook",
|
|
@@ -88,7 +88,7 @@ async function parseGitLabWebhook(c, secret) {
|
|
|
88
88
|
message: "Payload must be a JSON object"
|
|
89
89
|
}
|
|
90
90
|
};
|
|
91
|
-
const deliveryId = normalizeHeader(c.req.header("webhook-id")) ?? normalizeHeader(c.req.header("idempotency-key")) ?? normalizeHeader(c.req.header("x-gitlab-webhook-uuid")) ?? normalizeHeader(c.req.header("x-gitlab-event-uuid")) ??
|
|
91
|
+
const deliveryId = normalizeHeader(c.req.header("webhook-id")) ?? normalizeHeader(c.req.header("idempotency-key")) ?? normalizeHeader(c.req.header("x-gitlab-webhook-uuid")) ?? normalizeHeader(c.req.header("x-gitlab-event-uuid")) ?? Buffer.from(await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(`${event}\0${rawBody}`))).toString("hex");
|
|
92
92
|
const instanceHost = normalizeInstanceHost(c.req.header("x-gitlab-instance"));
|
|
93
93
|
return {
|
|
94
94
|
event,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook.js","names":[],"sources":["../../../src/integrations/gitlab/webhook.ts"],"sourcesContent":["import { createHash, timingSafeEqual } from 'node:crypto';\nimport type { Context } from 'hono';\n\nimport { dispatchGitLabWebhook } from './webhook-dispatch.js';\nimport type { GitLabWebhookDispatchDependencies } from './webhook-dispatch.js';\n\nexport const SUPPORTED_GITLAB_WEBHOOK_EVENTS = new Set(['Issue Hook', 'Note Hook', 'Merge Request Hook', 'Push Hook']);\n\nexport interface ParsedGitLabWebhook {\n event: string;\n deliveryId: string;\n instanceHost?: string;\n payload: Record<string, unknown>;\n}\n\nexport interface GitLabWebhookMetadata {\n event: string;\n projectId?: number;\n projectPath?: string;\n issueIid?: number;\n mergeRequestIid?: number;\n noteableType?: string;\n sender?: string;\n}\n\nexport type GitLabWebhookResult =\n | { status: 202; body: { ok: true; ignored?: true } }\n | { status: 400; body: { error: 'bad_request'; message: string } }\n | { status: 401; body: { error: 'unauthorized'; message: string } };\n\n/**\n * What processing an already-parsed delivery needs: the rules ingress and,\n * when a controller is mounted, the subscription dispatch. Shared by the\n * direct webhook route and the Platform event poller.\n */\nexport interface GitLabWebhookProcessOptions extends Partial<Omit<GitLabWebhookDispatchDependencies, 'controller'>> {\n ingestFactoryEvent?: (event: ParsedGitLabWebhook) => Promise<unknown>;\n /** When present, merge-request activity is also delivered to subscribed sessions. */\n controller?: GitLabWebhookDispatchDependencies['controller'];\n}\n\nexport interface GitLabWebhookHandlerOptions extends GitLabWebhookProcessOptions {\n webhookSecret?: string;\n}\n\n/**\n * `object_kind` values GitLab puts in every webhook body, mapped to the\n * `X-Gitlab-Event` header the direct route keys on. A body reaching Factory\n * without its headers (the Platform event log stores only the payload) is\n * normalized through this table so both ingress paths see the same event name.\n */\nconst GITLAB_OBJECT_KIND_EVENTS: Record<string, string> = {\n issue: 'Issue Hook',\n note: 'Note Hook',\n merge_request: 'Merge Request Hook',\n push: 'Push Hook',\n};\n\nfunction normalizeHeader(value: string | undefined | null): string | null {\n if (!value) return null;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\nfunction normalizeInstanceHost(value: string | null | undefined): string | undefined {\n if (!value) return undefined;\n try {\n return new URL(value.includes('://') ? value : 'https://' + value).host.toLowerCase();\n } catch {\n return undefined;\n }\n}\n\nexport function verifyGitLabToken(receivedToken: string, secret: string): boolean {\n const received = Buffer.from(receivedToken, 'utf8');\n const expected = Buffer.from(secret, 'utf8');\n return received.length === expected.length && timingSafeEqual(received, expected);\n}\n\nexport async function parseGitLabWebhook(\n c: Context,\n secret: string | undefined,\n): Promise<ParsedGitLabWebhook | GitLabWebhookResult> {\n if (!secret) {\n return { status: 401, body: { error: 'unauthorized', message: 'GitLab webhook secret is not configured' } };\n }\n\n const event = normalizeHeader(c.req.header('x-gitlab-event'));\n const token = normalizeHeader(c.req.header('x-gitlab-token'));\n if (!event) return { status: 400, body: { error: 'bad_request', message: 'Missing x-gitlab-event header' } };\n if (!token) return { status: 401, body: { error: 'unauthorized', message: 'Missing x-gitlab-token header' } };\n if (!verifyGitLabToken(token, secret)) {\n return { status: 401, body: { error: 'unauthorized', message: 'Invalid GitLab webhook token' } };\n }\n\n const rawBody = await c.req.text();\n let payload: unknown;\n try {\n payload = JSON.parse(rawBody);\n } catch {\n return { status: 400, body: { error: 'bad_request', message: 'Malformed JSON payload' } };\n }\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n return { status: 400, body: { error: 'bad_request', message: 'Payload must be a JSON object' } };\n }\n const deliveryId =\n normalizeHeader(c.req.header('webhook-id')) ??\n normalizeHeader(c.req.header('idempotency-key')) ??\n normalizeHeader(c.req.header('x-gitlab-webhook-uuid')) ??\n normalizeHeader(c.req.header('x-gitlab-event-uuid')) ??\n createHash('sha256').update(event).update('\\0').update(rawBody).digest('hex');\n const instanceHost = normalizeInstanceHost(c.req.header('x-gitlab-instance'));\n return {\n event,\n deliveryId,\n ...(instanceHost ? { instanceHost } : {}),\n payload: payload as Record<string, unknown>,\n };\n}\n\nfunction getObject(value: unknown): Record<string, unknown> | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction getString(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\nfunction getNumber(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\nexport function normalizeGitLabWebhookMetadata(parsed: ParsedGitLabWebhook): GitLabWebhookMetadata {\n const project = getObject(parsed.payload.project);\n const attributes = getObject(parsed.payload.object_attributes);\n const issue = getObject(parsed.payload.issue);\n const mergeRequest = getObject(parsed.payload.merge_request);\n const user = getObject(parsed.payload.user);\n const objectIid = getNumber(attributes?.iid);\n const noteableType = getString(attributes?.noteable_type);\n return {\n event: parsed.event,\n projectId: getNumber(project?.id),\n projectPath: getString(project?.path_with_namespace),\n issueIid:\n parsed.event === 'Issue Hook'\n ? objectIid\n : noteableType === 'Issue'\n ? (getNumber(issue?.iid) ?? objectIid)\n : undefined,\n mergeRequestIid:\n parsed.event === 'Merge Request Hook'\n ? objectIid\n : noteableType === 'MergeRequest'\n ? (getNumber(mergeRequest?.iid) ?? objectIid)\n : undefined,\n noteableType,\n sender: getString(parsed.payload.user_username) ?? getString(user?.username) ?? getString(user?.name),\n };\n}\n\n/**\n * Build the parsed form of a GitLab webhook from its raw body alone, for\n * deliveries that arrive without HTTP headers. The event name comes from\n * `object_kind`; the caller supplies a delivery id that is stable across\n * replays so rules replay handling and session dedupe keys behave as they do\n * for a direct delivery. Returns null when the body is not a webhook object or\n * its kind is one Factory does not handle, which callers treat exactly like an\n * unsupported event header: acknowledged and dropped.\n */\nexport function parseGitLabWebhookBody(body: unknown, deliveryId: string): ParsedGitLabWebhook | null {\n const payload = getObject(body);\n const objectKind = getString(payload?.object_kind);\n const id = normalizeHeader(deliveryId);\n if (!payload || !objectKind || !id) return null;\n const event = GITLAB_OBJECT_KIND_EVENTS[objectKind];\n if (!event) return null;\n return { event, deliveryId: id, payload };\n}\n\n/**\n * Process a parsed delivery: rules ingress first, then session dispatch when a\n * controller is mounted. Ingestion failures propagate so the caller can retry\n * the delivery (GitLab redelivers on a non-2xx; the poller leaves its cursor\n * in place).\n */\nexport async function processGitLabWebhook(\n parsed: ParsedGitLabWebhook,\n options: GitLabWebhookProcessOptions,\n): Promise<GitLabWebhookResult> {\n if (!SUPPORTED_GITLAB_WEBHOOK_EVENTS.has(parsed.event)) {\n return { status: 202, body: { ok: true, ignored: true } };\n }\n\n console.info('[GitLab Webhook]', normalizeGitLabWebhookMetadata(parsed), { deliveryId: parsed.deliveryId });\n if (options.ingestFactoryEvent) await options.ingestFactoryEvent(parsed);\n if (!options.controller) return { status: 202, body: { ok: true } };\n\n const { ingestFactoryEvent: _ingest, controller, ...dispatch } = options;\n const result = await dispatchGitLabWebhook(parsed, {\n onSenderRejected: notification => {\n console.info('[GitLab Webhook] sender not authorized', {\n deliveryId: parsed.deliveryId,\n repository: notification.metadata.projectPath,\n sender: notification.metadata.sender,\n kind: notification.kind,\n });\n },\n ...dispatch,\n controller,\n });\n if (result.failed > 0) {\n console.warn(`[GitLab Webhook] ${result.failed} subscribed target(s) failed for delivery ${parsed.deliveryId}.`);\n }\n if (!result.ignored) console.info('[GitLab Webhook] session delivery', { deliveryId: parsed.deliveryId, ...result });\n // The rules ingress already acknowledged the event; an event no session\n // subscribes to is still a handled delivery, not an ignored one.\n return { status: 202, body: { ok: true } };\n}\n\nexport async function handleGitLabWebhook(\n c: Context,\n options: GitLabWebhookHandlerOptions,\n): Promise<GitLabWebhookResult> {\n const parsed = await parseGitLabWebhook(c, options.webhookSecret);\n if ('status' in parsed) return parsed;\n const { webh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AAQ;EAAK,MAAM,EAAE,IAAI,KAAK;CAAE;CAElE,MAAM,EAAE,oBAAoB,SAAS,YAAY,GAAG,aAAa;CACjE,MAAM,SAAS,MAAM,sBAAsB,QAAQ;EACjD,mBAAkB,iBAAgB;GAChC,QAAQ,KAAK,0CAA0C;IACrD,YAAY,OAAO;IACnB,YAAY,aAAa,SAAS;IAClC,QAAQ,aAAa,SAAS;IAC9B,MAAM,aAAa;GACrB,CAAC;EACH;EACA,GAAG;EACH;CACF,CAAC;CACD,IAAI,OAAO,SAAS,GAClB,QAAQ,KAAK,oBAAoB,OAAO,OAAO,4CAA4C,OAAO,WAAW,EAAE;CAEjH,IAAI,CAAC,OAAO,SAAS,QAAQ,KAAK,qCAAqC;EAAE,YAAY,OAAO;EAAY,GAAG;CAAO,CAAC;CAGnH,OAAO;EAAE,QAAQ;EAAK,MAAM,EAAE,IAAI,KAAK;CAAE;AAC3C;AAEA,eAAsB,oBACpB,GACA,SAC8B;CAC9B,MAAM,SAAS,MAAM,mBAAmB,GAAG,QAAQ,aAAa;CAChE,IAAI,YAAY,QAAQ,OAAO;CAC/B,MAAM,EAAE,eAAe,SAAS,GAAG,YAAY;CAC/C,OAAO,qBAAqB,QAAQ,OAAO;AAC7C"}
|
|
1
|
+
{"version":3,"file":"webhook.js","names":[],"sources":["../../../src/integrations/gitlab/webhook.ts"],"sourcesContent":["import { timingSafeEqual } from 'node:crypto';\nimport type { Context } from 'hono';\n\nimport { dispatchGitLabWebhook } from './webhook-dispatch.js';\nimport type { GitLabWebhookDispatchDependencies } from './webhook-dispatch.js';\n\nexport const SUPPORTED_GITLAB_WEBHOOK_EVENTS = new Set(['Issue Hook', 'Note Hook', 'Merge Request Hook', 'Push Hook']);\n\nexport interface ParsedGitLabWebhook {\n event: string;\n deliveryId: string;\n instanceHost?: string;\n payload: Record<string, unknown>;\n}\n\nexport interface GitLabWebhookMetadata {\n event: string;\n projectId?: number;\n projectPath?: string;\n issueIid?: number;\n mergeRequestIid?: number;\n noteableType?: string;\n sender?: string;\n}\n\nexport type GitLabWebhookResult =\n | { status: 202; body: { ok: true; ignored?: true } }\n | { status: 400; body: { error: 'bad_request'; message: string } }\n | { status: 401; body: { error: 'unauthorized'; message: string } };\n\n/**\n * What processing an already-parsed delivery needs: the rules ingress and,\n * when a controller is mounted, the subscription dispatch. Shared by the\n * direct webhook route and the Platform event poller.\n */\nexport interface GitLabWebhookProcessOptions extends Partial<Omit<GitLabWebhookDispatchDependencies, 'controller'>> {\n ingestFactoryEvent?: (event: ParsedGitLabWebhook) => Promise<unknown>;\n /** When present, merge-request activity is also delivered to subscribed sessions. */\n controller?: GitLabWebhookDispatchDependencies['controller'];\n}\n\nexport interface GitLabWebhookHandlerOptions extends GitLabWebhookProcessOptions {\n webhookSecret?: string;\n}\n\n/**\n * `object_kind` values GitLab puts in every webhook body, mapped to the\n * `X-Gitlab-Event` header the direct route keys on. A body reaching Factory\n * without its headers (the Platform event log stores only the payload) is\n * normalized through this table so both ingress paths see the same event name.\n */\nconst GITLAB_OBJECT_KIND_EVENTS: Record<string, string> = {\n issue: 'Issue Hook',\n note: 'Note Hook',\n merge_request: 'Merge Request Hook',\n push: 'Push Hook',\n};\n\nfunction normalizeHeader(value: string | undefined | null): string | null {\n if (!value) return null;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\nfunction normalizeInstanceHost(value: string | null | undefined): string | undefined {\n if (!value) return undefined;\n try {\n return new URL(value.includes('://') ? value : 'https://' + value).host.toLowerCase();\n } catch {\n return undefined;\n }\n}\n\nexport function verifyGitLabToken(receivedToken: string, secret: string): boolean {\n const received = Buffer.from(receivedToken, 'utf8');\n const expected = Buffer.from(secret, 'utf8');\n return received.length === expected.length && timingSafeEqual(received, expected);\n}\n\nexport async function parseGitLabWebhook(\n c: Context,\n secret: string | undefined,\n): Promise<ParsedGitLabWebhook | GitLabWebhookResult> {\n if (!secret) {\n return { status: 401, body: { error: 'unauthorized', message: 'GitLab webhook secret is not configured' } };\n }\n\n const event = normalizeHeader(c.req.header('x-gitlab-event'));\n const token = normalizeHeader(c.req.header('x-gitlab-token'));\n if (!event) return { status: 400, body: { error: 'bad_request', message: 'Missing x-gitlab-event header' } };\n if (!token) return { status: 401, body: { error: 'unauthorized', message: 'Missing x-gitlab-token header' } };\n if (!verifyGitLabToken(token, secret)) {\n return { status: 401, body: { error: 'unauthorized', message: 'Invalid GitLab webhook token' } };\n }\n\n const rawBody = await c.req.text();\n let payload: unknown;\n try {\n payload = JSON.parse(rawBody);\n } catch {\n return { status: 400, body: { error: 'bad_request', message: 'Malformed JSON payload' } };\n }\n if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n return { status: 400, body: { error: 'bad_request', message: 'Payload must be a JSON object' } };\n }\n const deliveryId =\n normalizeHeader(c.req.header('webhook-id')) ??\n normalizeHeader(c.req.header('idempotency-key')) ??\n normalizeHeader(c.req.header('x-gitlab-webhook-uuid')) ??\n normalizeHeader(c.req.header('x-gitlab-event-uuid')) ??\n Buffer.from(\n await globalThis.crypto.subtle.digest('SHA-256', new TextEncoder().encode(`${event}\\0${rawBody}`)),\n ).toString('hex');\n const instanceHost = normalizeInstanceHost(c.req.header('x-gitlab-instance'));\n return {\n event,\n deliveryId,\n ...(instanceHost ? { instanceHost } : {}),\n payload: payload as Record<string, unknown>,\n };\n}\n\nfunction getObject(value: unknown): Record<string, unknown> | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as Record<string, unknown>) : undefined;\n}\n\nfunction getString(value: unknown): string | undefined {\n return typeof value === 'string' && value.length > 0 ? value : undefined;\n}\n\nfunction getNumber(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\nexport function normalizeGitLabWebhookMetadata(parsed: ParsedGitLabWebhook): GitLabWebhookMetadata {\n const project = getObject(parsed.payload.project);\n const attributes = getObject(parsed.payload.object_attributes);\n const issue = getObject(parsed.payload.issue);\n const mergeRequest = getObject(parsed.payload.merge_request);\n const user = getObject(parsed.payload.user);\n const objectIid = getNumber(attributes?.iid);\n const noteableType = getString(attributes?.noteable_type);\n return {\n event: parsed.event,\n projectId: getNumber(project?.id),\n projectPath: getString(project?.path_with_namespace),\n issueIid:\n parsed.event === 'Issue Hook'\n ? objectIid\n : noteableType === 'Issue'\n ? (getNumber(issue?.iid) ?? objectIid)\n : undefined,\n mergeRequestIid:\n parsed.event === 'Merge Request Hook'\n ? objectIid\n : noteableType === 'MergeRequest'\n ? (getNumber(mergeRequest?.iid) ?? objectIid)\n : undefined,\n noteableType,\n sender: getString(parsed.payload.user_username) ?? getString(user?.username) ?? getString(user?.name),\n };\n}\n\n/**\n * Build the parsed form of a GitLab webhook from its raw body alone, for\n * deliveries that arrive without HTTP headers. The event name comes from\n * `object_kind`; the caller supplies a delivery id that is stable across\n * replays so rules replay handling and session dedupe keys behave as they do\n * for a direct delivery. Returns null when the body is not a webhook object or\n * its kind is one Factory does not handle, which callers treat exactly like an\n * unsupported event header: acknowledged and dropped.\n */\nexport function parseGitLabWebhookBody(body: unknown, deliveryId: string): ParsedGitLabWebhook | null {\n const payload = getObject(body);\n const objectKind = getString(payload?.object_kind);\n const id = normalizeHeader(deliveryId);\n if (!payload || !objectKind || !id) return null;\n const event = GITLAB_OBJECT_KIND_EVENTS[objectKind];\n if (!event) return null;\n return { event, deliveryId: id, payload };\n}\n\n/**\n * Process a parsed delivery: rules ingress first, then session dispatch when a\n * controller is mounted. Ingestion failures propagate so the caller can retry\n * the delivery (GitLab redelivers on a non-2xx; the poller leaves its cursor\n * in place).\n */\nexport async function processGitLabWebhook(\n parsed: ParsedGitLabWebhook,\n options: GitLabWebhookProcessOptions,\n): Promise<GitLabWebhookResult> {\n if (!SUPPORTED_GITLAB_WEBHOOK_EVENTS.has(parsed.event)) {\n return { status: 202, body: { ok: true, ignored: true } };\n }\n\n console.info('[GitLab Webhook]', normalizeGitLabWebhookMetadata(parsed), { deliveryId: parsed.deliveryId });\n if (options.ingestFactoryEvent) await options.ingestFactoryEvent(parsed);\n if (!options.controller) return { status: 202, body: { ok: true } };\n\n const { ingestFactoryEvent: _ingest, controller, ...dispatch } = options;\n const result = await dispatchGitLabWebhook(parsed, {\n onSenderRejected: notification => {\n console.info('[GitLab Webhook] sender not authorized', {\n deliveryId: parsed.deliveryId,\n repository: notification.metadata.projectPath,\n sender: notification.metadata.sender,\n kind: notification.kind,\n });\n },\n ...dispatch,\n controller,\n });\n if (result.failed > 0) {\n console.warn(`[GitLab Webhook] ${result.failed} subscribed target(s) failed for delivery ${parsed.deliveryId}.`);\n }\n if (!result.ignored) console.info('[GitLab Webhook] session delivery', { deliveryId: parsed.deliveryId, ...result });\n // The rules ingress already acknowledged the event; an event no session\n // subscribes to is still a handled delivery, not an ignored one.\n return { status: 202, body: { ok: true } };\n}\n\nexport async function handleGitLabWebhook(\n c: Context,\n options: GitLabWebhookHandlerOptions,\n): Promise<GitLabWebhookResult> {\n const parsed = await parseGitLabWebhook(c, options.webhookSecret);\n if ('status' in parsed) return parsed;\n const { webhookSecret: _secret, ...process } = options;\n return processGitLabWebhook(parsed, process);\n}\n"],"mappings":";;;AAMA,MAAa,kDAAkC,IAAI,IAAI;CAAC;CAAc;CAAa;CAAsB;AAAW,CAAC;;;;;;;AA6CrH,MAAM,4BAAoD;CACxD,OAAO;CACP,MAAM;CACN,eAAe;CACf,MAAM;AACR;AAEA,SAAS,gBAAgB,OAAiD;CACxE,IAAI,CAAC,OAAO,OAAO;CACnB,MAAM,UAAU,MAAM,KAAK;CAC3B,OAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAEA,SAAS,sBAAsB,OAAsD;CACnF,IAAI,CAAC,OAAO,OAAO,KAAA;CACnB,IAAI;EACF,OAAO,IAAI,IAAI,MAAM,SAAS,KAAK,IAAI,QAAQ,aAAa,KAAK,CAAC,CAAC,KAAK,YAAY;CACtF,QAAQ;EACN;CACF;AACF;AAEA,SAAgB,kBAAkB,eAAuB,QAAyB;CAChF,MAAM,WAAW,OAAO,KAAK,eAAe,MA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pB,GACA,SAC8B;CAC9B,MAAM,SAAS,MAAM,mBAAmB,GAAG,QAAQ,aAAa;CAChE,IAAI,YAAY,QAAQ,OAAO;CAC/B,MAAM,EAAE,eAAe,SAAS,GAAG,YAAY;CAC/C,OAAO,qBAAqB,QAAQ,OAAO;AAC7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue-reconcile-worker.d.ts","sourceRoot":"","sources":["../../src/integrations/issue-reconcile-worker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"issue-reconcile-worker.d.ts","sourceRoot":"","sources":["../../src/integrations/issue-reconcile-worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,eAAO,MAAM,mCAAmC,QAAa,CAAC;AAG9D,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,eAAe,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,oBAAqB,SAAQ,YAAY;;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAcV,MAAM,EAAE,0BAA0B;IAaxC,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAKrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ3B,IAAI,SAAS,IAAI,OAAO,CAEvB;CAyDF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NoopLeaseProvider, isLeaseProvider } from "@mastra/core/events";
|
|
2
|
-
import { randomUUID } from "crypto";
|
|
3
2
|
import { MastraWorker } from "@mastra/core/worker";
|
|
4
3
|
//#region src/integrations/issue-reconcile-worker.ts
|
|
5
4
|
const DEFAULT_ISSUE_RECONCILE_INTERVAL_MS = 5 * 6e4;
|
|
@@ -11,7 +10,7 @@ var IssueReconcileWorker = class extends MastraWorker {
|
|
|
11
10
|
#intervalMs;
|
|
12
11
|
#leaseTtlMs;
|
|
13
12
|
#leaseKey;
|
|
14
|
-
#leaseOwner = randomUUID();
|
|
13
|
+
#leaseOwner = globalThis.crypto.randomUUID();
|
|
15
14
|
#running = false;
|
|
16
15
|
#timer;
|
|
17
16
|
#inFlight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue-reconcile-worker.js","names":["#integrationId","#reconcile","#intervalMs","#leaseTtlMs","#leaseKey","#leaseOwner","#leaseProvider","#running","#schedule","#timer","#inFlight","#tick"],"sources":["../../src/integrations/issue-reconcile-worker.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"issue-reconcile-worker.js","names":["#integrationId","#reconcile","#intervalMs","#leaseTtlMs","#leaseKey","#leaseOwner","#leaseProvider","#running","#schedule","#timer","#inFlight","#tick"],"sources":["../../src/integrations/issue-reconcile-worker.ts"],"sourcesContent":["import { isLeaseProvider, NoopLeaseProvider } from '@mastra/core/events';\nimport type { LeaseProvider, PubSub } from '@mastra/core/events';\nimport { MastraWorker } from '@mastra/core/worker';\nimport type { WorkerDeps } from '@mastra/core/worker';\n\nimport type { IssueReconciler } from './issue-reconciler.js';\n\nexport const DEFAULT_ISSUE_RECONCILE_INTERVAL_MS = 5 * 60_000;\nconst MIN_LEASE_TTL_MS = 30_000;\n\nexport interface IssueReconcileWorkerConfig {\n integrationId: string;\n reconcile: IssueReconciler;\n intervalMs?: number;\n}\n\nexport class IssueReconcileWorker extends MastraWorker {\n readonly name: string;\n\n readonly #integrationId: string;\n readonly #reconcile: IssueReconciler;\n readonly #intervalMs: number;\n readonly #leaseTtlMs: number;\n readonly #leaseKey: string;\n readonly #leaseOwner = globalThis.crypto.randomUUID();\n\n #running = false;\n #timer: ReturnType<typeof setTimeout> | undefined;\n #inFlight: Promise<void> | undefined;\n #leaseProvider: LeaseProvider = NoopLeaseProvider;\n\n constructor(config: IssueReconcileWorkerConfig) {\n super();\n this.#integrationId = config.integrationId;\n this.name = `${config.integrationId}-issue-reconcile`;\n this.#leaseKey = `${config.integrationId}:issue-reconcile`;\n this.#reconcile = config.reconcile;\n this.#intervalMs = config.intervalMs ?? DEFAULT_ISSUE_RECONCILE_INTERVAL_MS;\n if (!Number.isFinite(this.#intervalMs) || this.#intervalMs <= 0) {\n throw new Error(`${config.integrationId} issue reconcile interval must be a positive number.`);\n }\n this.#leaseTtlMs = Math.max(MIN_LEASE_TTL_MS, this.#intervalMs * 3);\n }\n\n async init(deps: WorkerDeps): Promise<void> {\n await super.init(deps);\n this.#leaseProvider = getLeaseProvider(deps.pubsub);\n }\n\n async start(): Promise<void> {\n if (this.#running) return;\n if (!this.deps) throw new Error('IssueReconcileWorker: call init() before start()');\n this.#running = true;\n this.deps.logger.info(`${this.#integrationId} issue reconcile worker started`, { intervalMs: this.#intervalMs });\n this.#schedule(0);\n }\n\n async stop(): Promise<void> {\n if (!this.#running) return;\n this.#running = false;\n if (this.#timer) clearTimeout(this.#timer);\n this.#timer = undefined;\n await this.#inFlight;\n }\n\n get isRunning(): boolean {\n return this.#running;\n }\n\n #schedule(delayMs: number): void {\n if (!this.#running) return;\n this.#timer = setTimeout(() => {\n this.#timer = undefined;\n const run = this.#tick().finally(() => {\n this.#inFlight = undefined;\n this.#schedule(this.#intervalMs);\n });\n this.#inFlight = run;\n }, delayMs);\n this.#timer.unref?.();\n }\n\n async #tick(): Promise<void> {\n const lease = await this.#leaseProvider\n .acquireLease(this.#leaseKey, this.#leaseOwner, this.#leaseTtlMs)\n .catch(() => ({ acquired: false }));\n if (!lease.acquired) return;\n\n // A sweep that traverses many projects/orgs can outrun the lease TTL;\n // renew periodically so a replica can't grab the expired lease and start\n // an overlapping sweep partway through this one.\n const renewalTimer = setInterval(\n () => {\n void this.#leaseProvider.renewLease(this.#leaseKey, this.#leaseOwner, this.#leaseTtlMs).catch(error => {\n this.deps?.logger.warn(`${this.#integrationId} issue reconcile lease renewal failed`, {\n error: error instanceof Error ? error.message : String(error),\n });\n });\n },\n Math.max(1_000, Math.floor(this.#leaseTtlMs / 3)),\n );\n renewalTimer.unref?.();\n\n try {\n const startedAt = Date.now();\n const { errors, ...counts } = await this.#reconcile();\n const context = { ...counts, durationMs: Date.now() - startedAt };\n if (counts.failed > 0) {\n this.deps?.logger.warn(`${this.#integrationId} issue reconcile sweep completed with failures`, {\n ...context,\n errors,\n });\n } else {\n this.deps?.logger.debug(`${this.#integrationId} issue reconcile sweep completed`, context);\n }\n } catch (error) {\n this.deps?.logger.warn(`${this.#integrationId} issue reconcile sweep failed`, {\n error: error instanceof Error ? error.message : String(error),\n });\n } finally {\n clearInterval(renewalTimer);\n await this.#leaseProvider.releaseLease(this.#leaseKey, this.#leaseOwner).catch(() => undefined);\n }\n }\n}\n\nfunction getLeaseProvider(pubsub: PubSub): LeaseProvider {\n const getProvider = (pubsub as PubSub & { getLeaseProvider?: () => LeaseProvider | undefined }).getLeaseProvider;\n if (typeof getProvider === 'function') return getProvider.call(pubsub) ?? NoopLeaseProvider;\n return isLeaseProvider(pubsub) ? pubsub : ((pubsub as PubSub & { lease?: LeaseProvider }).lease ?? NoopLeaseProvider);\n}\n"],"mappings":";;;AAOA,MAAa,sCAAsC,IAAI;AACvD,MAAM,mBAAmB;AAQzB,IAAa,uBAAb,cAA0C,aAAa;CACrD;CAEA;CACA;CACA;CACA;CACA;CACA,cAAuB,WAAW,OAAO,WAAW;CAEpD,WAAW;CACX;CACA;CACA,iBAAgC;CAEhC,YAAY,QAAoC;EAC9C,MAAM;EACN,KAAKA,iBAAiB,OAAO;EAC7B,KAAK,OAAO,GAAG,OAAO,cAAc;EACpC,KAAKI,YAAY,GAAG,OAAO,cAAc;EACzC,KAAKH,aAAa,OAAO;EACzB,KAAKC,cAAc,OAAO,cAAA;EAC1B,IAAI,CA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,CAAC,EAAE,MAAM,EAAE,EACrB,MAAM,CAAC,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC;QAAE,MAAM,EAAE,KAAK,CAAC,WAAW,GAAG;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAyH5F;;;;OAIG;IACH,MAAM,CAAC,GAAG,EAAE,kBAAkB,GAAG,QAAQ,EAAE;IAS3C;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,kBAAkB,GAAG,YAAY,EAAE;IAchD;;;;OAIG;IACG,UAAU,CAAC,IAAI,EAAE;QAAE,cAAc,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIrF,sEAAsE;IACtE,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAOvC"}
|
|
@@ -260,7 +260,13 @@ var JiraIntegration = class {
|
|
|
260
260
|
if (err instanceof JiraApiError && err.status === 404) return null;
|
|
261
261
|
throw err;
|
|
262
262
|
}
|
|
263
|
-
|
|
263
|
+
let comment;
|
|
264
|
+
try {
|
|
265
|
+
comment = await this.api.createComment(key, body);
|
|
266
|
+
} catch (err) {
|
|
267
|
+
if (err instanceof JiraApiError && err.status === 404) return null;
|
|
268
|
+
throw err;
|
|
269
|
+
}
|
|
264
270
|
return {
|
|
265
271
|
id: comment.id,
|
|
266
272
|
url: `${this.baseUrl}/browse/${key}?focusedCommentId=${comment.id}`
|