@mastra/factory 0.28.0-alpha.0 → 0.28.0-alpha.10
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 +528 -161
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +12 -6
- package/dist/auth.js.map +1 -1
- package/dist/boards/board-events.d.ts +54 -0
- package/dist/boards/board-events.d.ts.map +1 -0
- package/dist/boards/board-events.js +87 -0
- package/dist/boards/board-events.js.map +1 -0
- package/dist/boards/board-writes.d.ts +86 -0
- package/dist/boards/board-writes.d.ts.map +1 -0
- package/dist/boards/board-writes.js +266 -0
- package/dist/boards/board-writes.js.map +1 -0
- package/dist/boards/card-facts.d.ts +3 -1
- package/dist/boards/card-facts.d.ts.map +1 -1
- package/dist/boards/card-facts.js +30 -4
- package/dist/boards/card-facts.js.map +1 -1
- package/dist/boards/default-board.d.ts +7 -0
- package/dist/boards/default-board.d.ts.map +1 -0
- package/dist/boards/default-board.js +10 -0
- package/dist/boards/default-board.js.map +1 -0
- package/dist/boards/define-board.d.ts +56 -23
- package/dist/boards/define-board.d.ts.map +1 -1
- package/dist/boards/define-board.js +89 -45
- package/dist/boards/define-board.js.map +1 -1
- package/dist/boards/index.d.ts +6 -9
- package/dist/boards/index.d.ts.map +1 -1
- package/dist/boards/index.js +6 -20
- package/dist/boards/intake-routing.d.ts +55 -11
- package/dist/boards/intake-routing.d.ts.map +1 -1
- package/dist/boards/intake-routing.js +109 -19
- package/dist/boards/intake-routing.js.map +1 -1
- package/dist/boards/legacy-plan-role.d.ts.map +1 -1
- package/dist/boards/legacy-plan-role.js +14 -5
- package/dist/boards/legacy-plan-role.js.map +1 -1
- package/dist/boards/phase-automation.d.ts +7 -0
- package/dist/boards/phase-automation.d.ts.map +1 -1
- package/dist/boards/phase-automation.js +19 -3
- package/dist/boards/phase-automation.js.map +1 -1
- package/dist/boards/phase-runner.d.ts +18 -10
- package/dist/boards/phase-runner.d.ts.map +1 -1
- package/dist/boards/phase-runner.js +39 -34
- package/dist/boards/phase-runner.js.map +1 -1
- package/dist/boards/project-boards.d.ts +65 -8
- package/dist/boards/project-boards.d.ts.map +1 -1
- package/dist/boards/project-boards.js +217 -26
- package/dist/boards/project-boards.js.map +1 -1
- package/dist/boards/registry.d.ts +7 -1
- package/dist/boards/registry.d.ts.map +1 -1
- package/dist/boards/registry.js +19 -4
- package/dist/boards/registry.js.map +1 -1
- package/dist/boards/relocate.d.ts +1 -1
- package/dist/boards/relocate.d.ts.map +1 -1
- package/dist/boards/relocate.js +3 -2
- package/dist/boards/relocate.js.map +1 -1
- package/dist/boards/review.d.ts +5 -2
- package/dist/boards/review.d.ts.map +1 -1
- package/dist/boards/review.js +12 -11
- package/dist/boards/review.js.map +1 -1
- package/dist/boards/semantics.d.ts +160 -20
- package/dist/boards/semantics.d.ts.map +1 -1
- package/dist/boards/semantics.js +255 -23
- package/dist/boards/semantics.js.map +1 -1
- package/dist/boards/stored-board.d.ts +73 -1
- package/dist/boards/stored-board.d.ts.map +1 -1
- package/dist/boards/stored-board.js +157 -11
- package/dist/boards/stored-board.js.map +1 -1
- package/dist/boards/work-migrations.d.ts +43 -0
- package/dist/boards/work-migrations.d.ts.map +1 -0
- package/dist/boards/work-migrations.js +353 -0
- package/dist/boards/work-migrations.js.map +1 -0
- package/dist/boards/work-routes.d.ts +58 -0
- package/dist/boards/work-routes.d.ts.map +1 -0
- package/dist/boards/work-routes.js +270 -0
- package/dist/boards/work-routes.js.map +1 -0
- package/dist/boards/work-seeds.d.ts +9 -0
- package/dist/boards/work-seeds.d.ts.map +1 -0
- package/dist/boards/work-seeds.js +56 -0
- package/dist/boards/work-seeds.js.map +1 -0
- package/dist/boards/work.d.ts +8 -19
- package/dist/boards/work.d.ts.map +1 -1
- package/dist/boards/work.js +33 -281
- package/dist/boards/work.js.map +1 -1
- package/dist/environment/build-runner.d.ts.map +1 -1
- package/dist/environment/build-runner.js +2 -2
- package/dist/environment/build-runner.js.map +1 -1
- package/dist/environment/build-workflow.d.ts.map +1 -1
- package/dist/environment/build-workflow.js +6 -5
- package/dist/environment/build-workflow.js.map +1 -1
- package/dist/environment/build.d.ts +15 -2
- package/dist/environment/build.d.ts.map +1 -1
- package/dist/environment/build.js +32 -9
- package/dist/environment/build.js.map +1 -1
- package/dist/factory.d.ts +90 -9
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js +334 -141
- package/dist/factory.js.map +1 -1
- package/dist/feed-events.d.ts +4 -4
- package/dist/feed-events.d.ts.map +1 -1
- package/dist/feed-events.js +6 -6
- package/dist/feed-events.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/integrations/base.d.ts +12 -13
- package/dist/integrations/base.d.ts.map +1 -1
- package/dist/integrations/closing-references.d.ts +15 -0
- package/dist/integrations/closing-references.d.ts.map +1 -0
- package/dist/integrations/closing-references.js +69 -0
- package/dist/integrations/closing-references.js.map +1 -0
- package/dist/integrations/github/acceptance-labels.d.ts +4 -0
- package/dist/integrations/github/acceptance-labels.d.ts.map +1 -1
- package/dist/integrations/github/acceptance-labels.js +1 -1
- package/dist/integrations/github/acceptance-labels.js.map +1 -1
- package/dist/integrations/github/default-rules.d.ts +17 -75
- package/dist/integrations/github/default-rules.d.ts.map +1 -1
- package/dist/integrations/github/default-rules.js +134 -77
- package/dist/integrations/github/default-rules.js.map +1 -1
- package/dist/integrations/github/integration.d.ts.map +1 -1
- package/dist/integrations/github/integration.js +7 -3
- package/dist/integrations/github/integration.js.map +1 -1
- package/dist/integrations/github/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/github/issue-reconciler.js +21 -3
- package/dist/integrations/github/issue-reconciler.js.map +1 -1
- package/dist/integrations/github/provenance.js +1 -1
- package/dist/integrations/github/provenance.js.map +1 -1
- package/dist/integrations/github/pull-request-source.d.ts +8 -0
- package/dist/integrations/github/pull-request-source.d.ts.map +1 -0
- package/dist/integrations/github/pull-request-source.js +17 -0
- package/dist/integrations/github/pull-request-source.js.map +1 -0
- package/dist/integrations/github/reconcile-worker.d.ts +5 -1
- package/dist/integrations/github/reconcile-worker.d.ts.map +1 -1
- package/dist/integrations/github/reconcile-worker.js +39 -6
- package/dist/integrations/github/reconcile-worker.js.map +1 -1
- package/dist/integrations/github/review-status-comment.d.ts +61 -0
- package/dist/integrations/github/review-status-comment.d.ts.map +1 -0
- package/dist/integrations/github/review-status-comment.js +217 -0
- package/dist/integrations/github/review-status-comment.js.map +1 -0
- package/dist/integrations/github/review-status-reporter.d.ts +42 -0
- package/dist/integrations/github/review-status-reporter.d.ts.map +1 -0
- package/dist/integrations/github/review-status-reporter.js +104 -0
- package/dist/integrations/github/review-status-reporter.js.map +1 -0
- package/dist/integrations/github/review-status.d.ts +28 -0
- package/dist/integrations/github/review-status.d.ts.map +1 -0
- package/dist/integrations/github/review-status.js +95 -0
- package/dist/integrations/github/review-status.js.map +1 -0
- package/dist/integrations/github/routes.d.ts +4 -3
- package/dist/integrations/github/routes.d.ts.map +1 -1
- package/dist/integrations/github/routes.js +11 -91
- package/dist/integrations/github/routes.js.map +1 -1
- package/dist/integrations/github/rules.d.ts +92 -8
- package/dist/integrations/github/rules.d.ts.map +1 -1
- package/dist/integrations/github/rules.js +498 -103
- package/dist/integrations/github/rules.js.map +1 -1
- package/dist/integrations/github/sandbox.d.ts +10 -2
- package/dist/integrations/github/sandbox.d.ts.map +1 -1
- package/dist/integrations/github/sandbox.js +20 -4
- package/dist/integrations/github/sandbox.js.map +1 -1
- package/dist/integrations/github/session-subscriptions.js +2 -2
- package/dist/integrations/github/session-subscriptions.js.map +1 -1
- package/dist/integrations/github/token-refresh.d.ts +2 -1
- package/dist/integrations/github/token-refresh.d.ts.map +1 -1
- package/dist/integrations/github/token-refresh.js.map +1 -1
- package/dist/integrations/gitlab/agent-tools.js +1 -1
- package/dist/integrations/gitlab/default-rules.d.ts +96 -39
- package/dist/integrations/gitlab/default-rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/default-rules.js +109 -46
- package/dist/integrations/gitlab/default-rules.js.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/issue-reconciler.js +2 -1
- package/dist/integrations/gitlab/issue-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.d.ts.map +1 -1
- package/dist/integrations/gitlab/merge-request-reconciler.js +12 -5
- package/dist/integrations/gitlab/merge-request-reconciler.js.map +1 -1
- package/dist/integrations/gitlab/routes.d.ts.map +1 -1
- package/dist/integrations/gitlab/routes.js +2 -6
- package/dist/integrations/gitlab/routes.js.map +1 -1
- package/dist/integrations/gitlab/rules.d.ts +22 -1
- package/dist/integrations/gitlab/rules.d.ts.map +1 -1
- package/dist/integrations/gitlab/rules.js +188 -34
- package/dist/integrations/gitlab/rules.js.map +1 -1
- package/dist/integrations/gitlab/session-subscriptions.js +1 -1
- package/dist/integrations/incidentio/agent-tools.js +6 -6
- package/dist/integrations/incidentio/agent-tools.js.map +1 -1
- package/dist/integrations/incidentio/default-rules.d.ts +1 -9
- package/dist/integrations/incidentio/default-rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/default-rules.js +6 -7
- package/dist/integrations/incidentio/default-rules.js.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/incidentio/issue-reconciler.js +2 -1
- package/dist/integrations/incidentio/issue-reconciler.js.map +1 -1
- package/dist/integrations/incidentio/routes.d.ts +2 -2
- package/dist/integrations/incidentio/routes.d.ts.map +1 -1
- package/dist/integrations/incidentio/routes.js +11 -17
- package/dist/integrations/incidentio/routes.js.map +1 -1
- package/dist/integrations/incidentio/rules.d.ts +11 -4
- package/dist/integrations/incidentio/rules.d.ts.map +1 -1
- package/dist/integrations/incidentio/rules.js +52 -16
- package/dist/integrations/incidentio/rules.js.map +1 -1
- package/dist/integrations/issue-reconciler.js +1 -1
- package/dist/integrations/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/agent-tools.js +1 -1
- package/dist/integrations/jira/binding-scope.d.ts +5 -6
- package/dist/integrations/jira/binding-scope.d.ts.map +1 -1
- package/dist/integrations/jira/binding-scope.js +9 -11
- package/dist/integrations/jira/binding-scope.js.map +1 -1
- package/dist/integrations/jira/default-rules.d.ts +1 -9
- package/dist/integrations/jira/default-rules.d.ts.map +1 -1
- package/dist/integrations/jira/default-rules.js +6 -7
- package/dist/integrations/jira/default-rules.js.map +1 -1
- package/dist/integrations/jira/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/jira/issue-reconciler.js +2 -1
- package/dist/integrations/jira/issue-reconciler.js.map +1 -1
- package/dist/integrations/jira/routes.d.ts.map +1 -1
- package/dist/integrations/jira/routes.js +4 -9
- package/dist/integrations/jira/routes.js.map +1 -1
- package/dist/integrations/jira/rules.d.ts +11 -4
- package/dist/integrations/jira/rules.d.ts.map +1 -1
- package/dist/integrations/jira/rules.js +52 -16
- package/dist/integrations/jira/rules.js.map +1 -1
- package/dist/integrations/linear/agent-tools.d.ts +9 -1
- package/dist/integrations/linear/agent-tools.d.ts.map +1 -1
- package/dist/integrations/linear/agent-tools.js +81 -3
- package/dist/integrations/linear/agent-tools.js.map +1 -1
- package/dist/integrations/linear/default-rules.d.ts +1 -9
- package/dist/integrations/linear/default-rules.d.ts.map +1 -1
- package/dist/integrations/linear/default-rules.js +6 -7
- package/dist/integrations/linear/default-rules.js.map +1 -1
- package/dist/integrations/linear/integration.d.ts +4 -1
- package/dist/integrations/linear/integration.d.ts.map +1 -1
- package/dist/integrations/linear/integration.js +21 -1
- package/dist/integrations/linear/integration.js.map +1 -1
- package/dist/integrations/linear/issue-reconciler.d.ts.map +1 -1
- package/dist/integrations/linear/issue-reconciler.js +2 -1
- package/dist/integrations/linear/issue-reconciler.js.map +1 -1
- package/dist/integrations/linear/routes.d.ts +2 -1
- package/dist/integrations/linear/routes.d.ts.map +1 -1
- package/dist/integrations/linear/routes.js +16 -21
- package/dist/integrations/linear/routes.js.map +1 -1
- package/dist/integrations/linear/rules.d.ts +11 -4
- package/dist/integrations/linear/rules.d.ts.map +1 -1
- package/dist/integrations/linear/rules.js +50 -17
- package/dist/integrations/linear/rules.js.map +1 -1
- package/dist/integrations/platform/connect/routes.d.ts +7 -1
- package/dist/integrations/platform/connect/routes.d.ts.map +1 -1
- package/dist/integrations/platform/connect/routes.js +42 -5
- package/dist/integrations/platform/connect/routes.js.map +1 -1
- package/dist/integrations/platform/connect/session-tools.d.ts +12 -0
- package/dist/integrations/platform/connect/session-tools.d.ts.map +1 -0
- package/dist/integrations/platform/connect/session-tools.js +35 -0
- package/dist/integrations/platform/connect/session-tools.js.map +1 -0
- package/dist/integrations/platform/github/event-worker.d.ts +4 -1
- package/dist/integrations/platform/github/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/github/event-worker.js +39 -3
- package/dist/integrations/platform/github/event-worker.js.map +1 -1
- package/dist/integrations/platform/github/integration.d.ts +8 -0
- package/dist/integrations/platform/github/integration.d.ts.map +1 -1
- package/dist/integrations/platform/github/integration.js +132 -90
- package/dist/integrations/platform/github/integration.js.map +1 -1
- package/dist/integrations/platform/jira/agent-tools.js +1 -1
- package/dist/integrations/platform/jira/routes.d.ts.map +1 -1
- package/dist/integrations/platform/jira/routes.js +4 -9
- package/dist/integrations/platform/jira/routes.js.map +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts +1 -1
- package/dist/integrations/platform/linear/event-worker.d.ts.map +1 -1
- package/dist/integrations/platform/linear/event-worker.js +10 -1
- package/dist/integrations/platform/linear/event-worker.js.map +1 -1
- package/dist/integrations/platform/linear/integration.d.ts +1 -1
- package/dist/integrations/platform/linear/integration.d.ts.map +1 -1
- package/dist/integrations/platform/linear/integration.js +7 -8
- package/dist/integrations/platform/linear/integration.js.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.d.ts +2 -0
- package/dist/integrations/slack/channel-reply-processor.d.ts.map +1 -1
- package/dist/integrations/slack/channel-reply-processor.js +6 -1
- package/dist/integrations/slack/channel-reply-processor.js.map +1 -1
- package/dist/integrations/slack/chat-tools.js +1 -1
- package/dist/integrations/slack/connect-route.d.ts.map +1 -1
- package/dist/integrations/slack/connect-route.js +1 -1
- package/dist/integrations/slack/connect-route.js.map +1 -1
- package/dist/integrations/slack/integration.d.ts +0 -2
- package/dist/integrations/slack/integration.d.ts.map +1 -1
- package/dist/integrations/slack/integration.js +2 -5
- package/dist/integrations/slack/integration.js.map +1 -1
- package/dist/integrations/slack/reply-tool.js +1 -1
- package/dist/integrations/slack/run-error-card.js +1 -0
- package/dist/integrations/slack/run-error-card.js.map +1 -1
- package/dist/integrations/slack/share-file-tool.js +1 -1
- package/dist/integrations/slack/slack.d.ts +23 -30
- package/dist/integrations/slack/slack.d.ts.map +1 -1
- package/dist/integrations/slack/slack.js +131 -125
- package/dist/integrations/slack/slack.js.map +1 -1
- package/dist/integrations/slack/voice-clips.d.ts +32 -0
- package/dist/integrations/slack/voice-clips.d.ts.map +1 -0
- package/dist/integrations/slack/voice-clips.js +201 -0
- package/dist/integrations/slack/voice-clips.js.map +1 -0
- package/dist/integrations/workos/integration.d.ts.map +1 -1
- package/dist/integrations/workos/integration.js +1 -3
- package/dist/integrations/workos/integration.js.map +1 -1
- package/dist/links.d.ts +1 -2
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +4 -4
- package/dist/links.js.map +1 -1
- package/dist/mcp/routes.js +2 -2
- package/dist/mcp/routes.js.map +1 -1
- package/dist/packages/_internals/workspace/dist/index.js +1 -1
- package/dist/provider-display-name.d.ts.map +1 -1
- package/dist/provider-display-name.js +1 -0
- package/dist/provider-display-name.js.map +1 -1
- package/dist/routes/attention-parked.d.ts +1 -0
- package/dist/routes/attention-parked.d.ts.map +1 -1
- package/dist/routes/attention-parked.js +2 -2
- package/dist/routes/attention-parked.js.map +1 -1
- package/dist/routes/attention-providers.d.ts +0 -25
- package/dist/routes/attention-providers.d.ts.map +1 -1
- package/dist/routes/attention-providers.js +3 -151
- package/dist/routes/attention-providers.js.map +1 -1
- package/dist/routes/attention.d.ts +0 -2
- package/dist/routes/attention.d.ts.map +1 -1
- package/dist/routes/attention.js +2 -13
- package/dist/routes/attention.js.map +1 -1
- package/dist/routes/automation-runs.d.ts +5 -1
- package/dist/routes/automation-runs.d.ts.map +1 -1
- package/dist/routes/automation-runs.js +16 -4
- package/dist/routes/automation-runs.js.map +1 -1
- package/dist/routes/board-snapshot.d.ts +15 -0
- package/dist/routes/board-snapshot.d.ts.map +1 -0
- package/dist/routes/board-snapshot.js +41 -0
- package/dist/routes/board-snapshot.js.map +1 -0
- package/dist/routes/boards.d.ts +9 -7
- package/dist/routes/boards.d.ts.map +1 -1
- package/dist/routes/boards.js +59 -145
- package/dist/routes/boards.js.map +1 -1
- package/dist/routes/config.d.ts +11 -1
- package/dist/routes/config.d.ts.map +1 -1
- package/dist/routes/config.js +122 -29
- package/dist/routes/config.js.map +1 -1
- package/dist/routes/contracts.d.ts +366 -34
- package/dist/routes/contracts.d.ts.map +1 -1
- package/dist/routes/contracts.js +179 -51
- package/dist/routes/contracts.js.map +1 -1
- package/dist/routes/feed-events.d.ts +15 -0
- package/dist/routes/feed-events.d.ts.map +1 -0
- package/dist/routes/feed-events.js +68 -0
- package/dist/routes/feed-events.js.map +1 -0
- package/dist/routes/fs.d.ts +4 -0
- package/dist/routes/fs.d.ts.map +1 -1
- package/dist/routes/fs.js +9 -8
- package/dist/routes/fs.js.map +1 -1
- package/dist/routes/intake-routes.d.ts.map +1 -1
- package/dist/routes/intake-routes.js +25 -13
- package/dist/routes/intake-routes.js.map +1 -1
- package/dist/routes/intake.d.ts +0 -23
- package/dist/routes/intake.d.ts.map +1 -1
- package/dist/routes/intake.js +16 -314
- package/dist/routes/intake.js.map +1 -1
- package/dist/routes/knowledge.d.ts.map +1 -1
- package/dist/routes/knowledge.js +2 -5
- package/dist/routes/knowledge.js.map +1 -1
- package/dist/routes/mastra-gateway.d.ts +19 -0
- package/dist/routes/mastra-gateway.d.ts.map +1 -0
- package/dist/routes/mastra-gateway.js +120 -0
- package/dist/routes/mastra-gateway.js.map +1 -0
- package/dist/routes/oauth.d.ts.map +1 -1
- package/dist/routes/oauth.js +1 -4
- package/dist/routes/oauth.js.map +1 -1
- package/dist/routes/projects.d.ts +3 -0
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +80 -61
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/provider-credentials.d.ts +6 -1
- package/dist/routes/provider-credentials.d.ts.map +1 -1
- package/dist/routes/provider-credentials.js +44 -3
- package/dist/routes/provider-credentials.js.map +1 -1
- package/dist/routes/route.d.ts +8 -0
- package/dist/routes/route.d.ts.map +1 -1
- package/dist/routes/route.js +5 -1
- package/dist/routes/route.js.map +1 -1
- package/dist/routes/running-packages.d.ts +13 -0
- package/dist/routes/running-packages.d.ts.map +1 -0
- package/dist/routes/running-packages.js +45 -0
- package/dist/routes/running-packages.js.map +1 -0
- package/dist/routes/sandbox-envs.d.ts +26 -0
- package/dist/routes/sandbox-envs.d.ts.map +1 -0
- package/dist/routes/sandbox-envs.js +180 -0
- package/dist/routes/sandbox-envs.js.map +1 -0
- package/dist/routes/session-access.d.ts.map +1 -1
- package/dist/routes/session-access.js +12 -3
- package/dist/routes/session-access.js.map +1 -1
- package/dist/routes/skills.d.ts.map +1 -1
- package/dist/routes/skills.js +1 -4
- package/dist/routes/skills.js.map +1 -1
- package/dist/routes/source-control-sessions.d.ts.map +1 -1
- package/dist/routes/source-control-sessions.js +1 -3
- package/dist/routes/source-control-sessions.js.map +1 -1
- package/dist/routes/source-control-settings.d.ts.map +1 -1
- package/dist/routes/source-control-settings.js +3 -2
- package/dist/routes/source-control-settings.js.map +1 -1
- package/dist/routes/surface.d.ts +13 -9
- package/dist/routes/surface.d.ts.map +1 -1
- package/dist/routes/surface.js +116 -43
- package/dist/routes/surface.js.map +1 -1
- package/dist/routes/tenant-credentials.d.ts.map +1 -1
- package/dist/routes/tenant-credentials.js +5 -1
- package/dist/routes/tenant-credentials.js.map +1 -1
- package/dist/routes/voice.d.ts +48 -0
- package/dist/routes/voice.d.ts.map +1 -0
- package/dist/routes/voice.js +248 -0
- package/dist/routes/voice.js.map +1 -0
- package/dist/routes/work-items.d.ts +0 -3
- package/dist/routes/work-items.d.ts.map +1 -1
- package/dist/routes/work-items.js +39 -14
- package/dist/routes/work-items.js.map +1 -1
- package/dist/rules/binding-context.d.ts.map +1 -1
- package/dist/rules/binding-context.js +1 -0
- package/dist/rules/binding-context.js.map +1 -1
- package/dist/rules/decision-applicability.js +1 -1
- package/dist/rules/dispatcher.d.ts +28 -9
- package/dist/rules/dispatcher.d.ts.map +1 -1
- package/dist/rules/dispatcher.js +734 -143
- package/dist/rules/dispatcher.js.map +1 -1
- package/dist/rules/event-rules.d.ts +71 -1
- package/dist/rules/event-rules.d.ts.map +1 -1
- package/dist/rules/event-rules.js +94 -1
- package/dist/rules/event-rules.js.map +1 -1
- package/dist/rules/index.d.ts +2 -4
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +2 -3
- package/dist/rules/phase-goal.d.ts +54 -0
- package/dist/rules/phase-goal.d.ts.map +1 -0
- package/dist/rules/phase-goal.js +70 -0
- package/dist/rules/phase-goal.js.map +1 -0
- package/dist/rules/phase-tools.d.ts +11 -0
- package/dist/rules/phase-tools.d.ts.map +1 -0
- package/dist/rules/phase-tools.js +19 -0
- package/dist/rules/phase-tools.js.map +1 -0
- package/dist/rules/processor.d.ts.map +1 -1
- package/dist/rules/processor.js +116 -15
- package/dist/rules/processor.js.map +1 -1
- package/dist/rules/review-source-tool.d.ts +4 -1
- package/dist/rules/review-source-tool.d.ts.map +1 -1
- package/dist/rules/review-source-tool.js +24 -4
- package/dist/rules/review-source-tool.js.map +1 -1
- package/dist/rules/rule-group.d.ts +1 -1
- package/dist/rules/rule-group.d.ts.map +1 -1
- package/dist/rules/rule-group.js +15 -6
- package/dist/rules/rule-group.js.map +1 -1
- package/dist/rules/start-coordinator.d.ts +5 -1
- package/dist/rules/start-coordinator.d.ts.map +1 -1
- package/dist/rules/start-coordinator.js +9 -3
- package/dist/rules/start-coordinator.js.map +1 -1
- package/dist/rules/tools.d.ts.map +1 -1
- package/dist/rules/tools.js +39 -28
- package/dist/rules/tools.js.map +1 -1
- package/dist/rules/transition-service.d.ts +10 -7
- package/dist/rules/transition-service.d.ts.map +1 -1
- package/dist/rules/transition-service.js +63 -55
- package/dist/rules/transition-service.js.map +1 -1
- package/dist/rules/types.d.ts +140 -39
- package/dist/rules/types.d.ts.map +1 -1
- package/dist/rules/types.js +7 -41
- package/dist/rules/types.js.map +1 -1
- package/dist/rules/validation.d.ts.map +1 -1
- package/dist/rules/validation.js +89 -4
- package/dist/rules/validation.js.map +1 -1
- package/dist/run-error.d.ts +1 -1
- package/dist/run-error.d.ts.map +1 -1
- package/dist/run-error.js +38 -5
- package/dist/run-error.js.map +1 -1
- package/dist/sandbox/sandbox-env-cache.d.ts +33 -0
- package/dist/sandbox/sandbox-env-cache.d.ts.map +1 -0
- package/dist/sandbox/sandbox-env-cache.js +140 -0
- package/dist/sandbox/sandbox-env-cache.js.map +1 -0
- package/dist/sandbox/sandbox-env.d.ts +77 -0
- package/dist/sandbox/sandbox-env.d.ts.map +1 -0
- package/dist/sandbox/sandbox-env.js +130 -0
- package/dist/sandbox/sandbox-env.js.map +1 -0
- package/dist/secret-encryption.d.ts +21 -0
- package/dist/secret-encryption.d.ts.map +1 -1
- package/dist/secret-encryption.js +31 -4
- package/dist/secret-encryption.js.map +1 -1
- package/dist/session/credential-policy.d.ts +2 -2
- package/dist/session/credential-policy.d.ts.map +1 -1
- package/dist/session/credential-policy.js +3 -3
- package/dist/session/credential-policy.js.map +1 -1
- package/dist/session/default-model-hydration.d.ts +2 -2
- package/dist/session/default-model-hydration.d.ts.map +1 -1
- package/dist/session/default-model-hydration.js +4 -4
- package/dist/session/default-model-hydration.js.map +1 -1
- package/dist/session/live-sessions.d.ts +11 -4
- package/dist/session/live-sessions.d.ts.map +1 -1
- package/dist/session/live-sessions.js +31 -10
- package/dist/session/live-sessions.js.map +1 -1
- package/dist/session/self-review-gate.d.ts +6 -4
- package/dist/session/self-review-gate.d.ts.map +1 -1
- package/dist/session/self-review-gate.js +9 -12
- package/dist/session/self-review-gate.js.map +1 -1
- package/dist/session/session-threads.d.ts +10 -3
- package/dist/session/session-threads.d.ts.map +1 -1
- package/dist/session/session-threads.js +11 -1
- package/dist/session/session-threads.js.map +1 -1
- package/dist/session/source-control-tools.d.ts +39 -13
- package/dist/session/source-control-tools.d.ts.map +1 -1
- package/dist/session/source-control-tools.js +55 -61
- package/dist/session/source-control-tools.js.map +1 -1
- package/dist/session/work-item-state-processor.d.ts +24 -0
- package/dist/session/work-item-state-processor.d.ts.map +1 -0
- package/dist/session/work-item-state-processor.js +275 -0
- package/dist/session/work-item-state-processor.js.map +1 -0
- package/dist/skills/catalog.js +1 -1
- package/dist/storage/domains/audit/actions.d.ts +3 -2
- package/dist/storage/domains/audit/actions.d.ts.map +1 -1
- package/dist/storage/domains/audit/actions.js +7 -5
- package/dist/storage/domains/audit/actions.js.map +1 -1
- package/dist/storage/domains/audit/domain.d.ts.map +1 -1
- package/dist/storage/domains/audit/domain.js +1 -3
- package/dist/storage/domains/audit/domain.js.map +1 -1
- package/dist/storage/domains/boards/base.d.ts +107 -23
- package/dist/storage/domains/boards/base.d.ts.map +1 -1
- package/dist/storage/domains/boards/base.js +201 -65
- package/dist/storage/domains/boards/base.js.map +1 -1
- package/dist/storage/domains/boards/schemas.d.ts.map +1 -1
- package/dist/storage/domains/boards/schemas.js +25 -1
- package/dist/storage/domains/boards/schemas.js.map +1 -1
- package/dist/storage/domains/channel-identity/base.d.ts +0 -4
- package/dist/storage/domains/channel-identity/base.d.ts.map +1 -1
- package/dist/storage/domains/channel-identity/base.js +0 -7
- package/dist/storage/domains/channel-identity/base.js.map +1 -1
- package/dist/storage/domains/intake/base.d.ts +5 -45
- package/dist/storage/domains/intake/base.d.ts.map +1 -1
- package/dist/storage/domains/intake/base.js +11 -89
- package/dist/storage/domains/intake/base.js.map +1 -1
- package/dist/storage/domains/memory-settings/base.d.ts +0 -8
- package/dist/storage/domains/memory-settings/base.d.ts.map +1 -1
- package/dist/storage/domains/memory-settings/base.js +1 -11
- package/dist/storage/domains/memory-settings/base.js.map +1 -1
- package/dist/storage/domains/projects/base.d.ts +23 -9
- package/dist/storage/domains/projects/base.d.ts.map +1 -1
- package/dist/storage/domains/projects/base.js +24 -8
- package/dist/storage/domains/projects/base.js.map +1 -1
- package/dist/storage/domains/sandbox-envs/base.d.ts +70 -0
- package/dist/storage/domains/sandbox-envs/base.d.ts.map +1 -0
- package/dist/storage/domains/sandbox-envs/base.js +227 -0
- package/dist/storage/domains/sandbox-envs/base.js.map +1 -0
- package/dist/storage/domains/voice-settings/base.d.ts +31 -0
- package/dist/storage/domains/voice-settings/base.d.ts.map +1 -0
- package/dist/storage/domains/voice-settings/base.js +81 -0
- package/dist/storage/domains/voice-settings/base.js.map +1 -0
- package/dist/storage/domains/work-items/base.d.ts +93 -24
- package/dist/storage/domains/work-items/base.d.ts.map +1 -1
- package/dist/storage/domains/work-items/base.js +413 -188
- package/dist/storage/domains/work-items/base.js.map +1 -1
- package/dist/storage/domains/work-items/board-version.d.ts +6 -2
- package/dist/storage/domains/work-items/board-version.d.ts.map +1 -1
- package/dist/storage/domains/work-items/board-version.js +20 -9
- package/dist/storage/domains/work-items/board-version.js.map +1 -1
- package/dist/storage/domains/work-items/cards.d.ts +33 -5
- package/dist/storage/domains/work-items/cards.d.ts.map +1 -1
- package/dist/storage/domains/work-items/cards.js +208 -25
- package/dist/storage/domains/work-items/cards.js.map +1 -1
- package/dist/storage/domains/work-items/legacy-review.d.ts +63 -0
- package/dist/storage/domains/work-items/legacy-review.d.ts.map +1 -0
- package/dist/storage/domains/work-items/legacy-review.js +109 -0
- package/dist/storage/domains/work-items/legacy-review.js.map +1 -0
- package/dist/storage/domains/work-items/metrics.d.ts +12 -4
- package/dist/storage/domains/work-items/metrics.d.ts.map +1 -1
- package/dist/storage/domains/work-items/metrics.js +14 -32
- package/dist/storage/domains/work-items/metrics.js.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.d.ts +6 -2
- package/dist/storage/domains/work-items/work-item-schema.d.ts.map +1 -1
- package/dist/storage/domains/work-items/work-item-schema.js +83 -27
- package/dist/storage/domains/work-items/work-item-schema.js.map +1 -1
- package/dist/timing.d.ts +1 -0
- package/dist/timing.d.ts.map +1 -1
- package/dist/timing.js +1 -1
- package/dist/timing.js.map +1 -1
- package/dist/tools/approval-tools.d.ts.map +1 -1
- package/dist/tools/approval-tools.js +28 -9
- package/dist/tools/approval-tools.js.map +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/messaging-tools.d.ts +3 -0
- package/dist/tools/messaging-tools.d.ts.map +1 -1
- package/dist/tools/messaging-tools.js +2 -1
- package/dist/tools/messaging-tools.js.map +1 -1
- package/dist/tools/read-tools.d.ts +10 -6
- package/dist/tools/read-tools.d.ts.map +1 -1
- package/dist/tools/read-tools.js +89 -39
- package/dist/tools/read-tools.js.map +1 -1
- package/dist/tools/reports.d.ts +1 -0
- package/dist/tools/reports.d.ts.map +1 -1
- package/dist/tools/reports.js +2 -1
- package/dist/tools/reports.js.map +1 -1
- package/dist/tools/run-watch.d.ts +1 -1
- package/dist/tools/run-watch.d.ts.map +1 -1
- package/dist/tools/run-watch.js +1 -0
- package/dist/tools/run-watch.js.map +1 -1
- package/dist/tools/sandbox-tools.js +1 -1
- package/dist/tools/session-tools.d.ts +1 -1
- package/dist/tools/session-tools.d.ts.map +1 -1
- package/dist/tools/session-tools.js +1 -1
- package/dist/tools/session-tools.js.map +1 -1
- package/dist/tools/sessions-state-processor.d.ts +3 -1
- package/dist/tools/sessions-state-processor.d.ts.map +1 -1
- package/dist/tools/sessions-state-processor.js +13 -4
- package/dist/tools/sessions-state-processor.js.map +1 -1
- package/dist/tools/side-sessions.d.ts +2 -0
- package/dist/tools/side-sessions.d.ts.map +1 -1
- package/dist/tools/side-sessions.js +2 -1
- package/dist/tools/side-sessions.js.map +1 -1
- package/dist/tools/work-item-tools.d.ts +0 -3
- package/dist/tools/work-item-tools.d.ts.map +1 -1
- package/dist/tools/work-item-tools.js +10 -20
- package/dist/tools/work-item-tools.js.map +1 -1
- package/dist/voice/rate-limit.d.ts +13 -0
- package/dist/voice/rate-limit.d.ts.map +1 -0
- package/dist/voice/rate-limit.js +36 -0
- package/dist/voice/rate-limit.js.map +1 -0
- package/dist/voice/realtime.d.ts +13 -0
- package/dist/voice/realtime.d.ts.map +1 -0
- package/dist/voice/realtime.js +56 -0
- package/dist/voice/realtime.js.map +1 -0
- package/dist/voice/transcription.d.ts +51 -0
- package/dist/voice/transcription.d.ts.map +1 -0
- package/dist/voice/transcription.js +112 -0
- package/dist/voice/transcription.js.map +1 -0
- package/dist/work-item-branch.d.ts +13 -0
- package/dist/work-item-branch.d.ts.map +1 -1
- package/dist/work-item-branch.js +16 -1
- package/dist/work-item-branch.js.map +1 -1
- package/dist/work-items/create-work-item.d.ts +6 -0
- package/dist/work-items/create-work-item.d.ts.map +1 -1
- package/dist/work-items/create-work-item.js +28 -3
- package/dist/work-items/create-work-item.js.map +1 -1
- package/dist/work-items/description-context.d.ts +5 -0
- package/dist/work-items/description-context.d.ts.map +1 -0
- package/dist/work-items/description-context.js +17 -0
- package/dist/work-items/description-context.js.map +1 -0
- package/dist/work-items/providers/base.d.ts +4 -1
- package/dist/work-items/providers/base.d.ts.map +1 -1
- package/dist/work-items/providers/base.js +6 -1
- package/dist/work-items/providers/base.js.map +1 -1
- package/dist/work-items/providers/github.d.ts.map +1 -1
- package/dist/work-items/providers/github.js +2 -1
- package/dist/work-items/providers/github.js.map +1 -1
- package/dist/work-items/providers/gitlab.d.ts.map +1 -1
- package/dist/work-items/providers/gitlab.js +2 -1
- package/dist/work-items/providers/gitlab.js.map +1 -1
- package/dist/work-items/providers/jira.d.ts.map +1 -1
- package/dist/work-items/providers/jira.js +3 -2
- package/dist/work-items/providers/jira.js.map +1 -1
- package/dist/work-items/providers/linear.d.ts.map +1 -1
- package/dist/work-items/providers/linear.js +3 -2
- package/dist/work-items/providers/linear.js.map +1 -1
- package/dist/work-items/providers/types.d.ts +6 -0
- package/dist/work-items/providers/types.d.ts.map +1 -1
- package/dist/work-items/split-backfill.d.ts +13 -0
- package/dist/work-items/split-backfill.d.ts.map +1 -0
- package/dist/work-items/split-backfill.js +32 -0
- package/dist/work-items/split-backfill.js.map +1 -0
- package/dist/work-items/split-migration.d.ts +39 -2
- package/dist/work-items/split-migration.d.ts.map +1 -1
- package/dist/work-items/split-migration.js +178 -70
- package/dist/work-items/split-migration.js.map +1 -1
- package/dist/workspace.d.ts +3 -1
- package/dist/workspace.d.ts.map +1 -1
- package/dist/workspace.js +118 -34
- package/dist/workspace.js.map +1 -1
- package/factory-skills/configure-factory-rules/SKILL.md +13 -11
- package/factory-skills/factory-build/SKILL.md +64 -0
- package/factory-skills/factory-gitlab-rereview/SKILL.md +4 -4
- package/factory-skills/factory-gitlab-review/SKILL.md +6 -6
- package/factory-skills/factory-plan/SKILL.md +8 -10
- package/factory-skills/factory-rereview/SKILL.md +74 -28
- package/factory-skills/factory-review/SKILL.md +85 -29
- package/factory-skills/factory-self-review/SKILL.md +32 -13
- package/factory-skills/factory-triage/SKILL.md +36 -32
- package/package.json +12 -11
- package/dist/boards/index.js.map +0 -1
- package/dist/boards/pull-request-review.d.ts +0 -14
- package/dist/boards/pull-request-review.d.ts.map +0 -1
- package/dist/boards/pull-request-review.js +0 -81
- package/dist/boards/pull-request-review.js.map +0 -1
- package/dist/boards/work-tool-rules.d.ts +0 -8
- package/dist/boards/work-tool-rules.d.ts.map +0 -1
- package/dist/boards/work-tool-rules.js +0 -19
- package/dist/boards/work-tool-rules.js.map +0 -1
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts +0 -8
- package/dist/integrations/slack/emoji-shortcodes.generated.d.ts.map +0 -1
- package/dist/integrations/slack/emoji-shortcodes.generated.js +0 -1984
- package/dist/integrations/slack/emoji-shortcodes.generated.js.map +0 -1
- package/dist/integrations/slack/emoji.d.ts +0 -3
- package/dist/integrations/slack/emoji.d.ts.map +0 -1
- package/dist/integrations/slack/emoji.js +0 -11
- package/dist/integrations/slack/emoji.js.map +0 -1
- package/dist/integrations/slack/feed-publisher.d.ts +0 -26
- package/dist/integrations/slack/feed-publisher.d.ts.map +0 -1
- package/dist/integrations/slack/feed-publisher.js +0 -43
- package/dist/integrations/slack/feed-publisher.js.map +0 -1
- package/dist/routes/attention-activity.d.ts +0 -23
- package/dist/routes/attention-activity.d.ts.map +0 -1
- package/dist/routes/attention-activity.js +0 -154
- package/dist/routes/attention-activity.js.map +0 -1
- package/dist/rules/resolve.d.ts +0 -15
- package/dist/rules/resolve.d.ts.map +0 -1
- package/dist/rules/resolve.js +0 -22
- package/dist/rules/resolve.js.map +0 -1
- package/dist/storage/domains/comments/activity.d.ts +0 -40
- package/dist/storage/domains/comments/activity.d.ts.map +0 -1
- package/dist/storage/domains/comments/activity.js +0 -93
- package/dist/storage/domains/comments/activity.js.map +0 -1
- package/dist/storage/domains/comments/actor.d.ts +0 -51
- package/dist/storage/domains/comments/actor.d.ts.map +0 -1
- package/dist/storage/domains/comments/actor.js +0 -37
- package/dist/storage/domains/comments/actor.js.map +0 -1
- package/dist/storage/domains/comments/base.d.ts +0 -245
- package/dist/storage/domains/comments/base.d.ts.map +0 -1
- package/dist/storage/domains/comments/base.js +0 -539
- package/dist/storage/domains/comments/base.js.map +0 -1
- package/dist/storage/domains/comments/domain.d.ts +0 -135
- package/dist/storage/domains/comments/domain.d.ts.map +0 -1
- package/dist/storage/domains/comments/domain.js +0 -284
- package/dist/storage/domains/comments/domain.js.map +0 -1
- package/dist/storage/domains/comments/feed-context.d.ts +0 -22
- package/dist/storage/domains/comments/feed-context.d.ts.map +0 -1
- package/dist/storage/domains/comments/feed-context.js +0 -88
- package/dist/storage/domains/comments/feed-context.js.map +0 -1
- package/dist/storage/domains/comments/feed-sync.d.ts +0 -21
- package/dist/storage/domains/comments/feed-sync.d.ts.map +0 -1
- package/dist/storage/domains/comments/feed-sync.js +0 -1
- package/dist/storage/domains/comments/parse.d.ts +0 -23
- package/dist/storage/domains/comments/parse.d.ts.map +0 -1
- package/dist/storage/domains/comments/parse.js +0 -89
- package/dist/storage/domains/comments/parse.js.map +0 -1
- package/dist/storage/domains/comments/routes.d.ts +0 -24
- package/dist/storage/domains/comments/routes.d.ts.map +0 -1
- package/dist/storage/domains/comments/routes.js +0 -301
- package/dist/storage/domains/comments/routes.js.map +0 -1
- package/dist/storage/domains/comments/schema.d.ts +0 -5
- package/dist/storage/domains/comments/schema.d.ts.map +0 -1
- package/dist/storage/domains/comments/schema.js +0 -178
- package/dist/storage/domains/comments/schema.js.map +0 -1
- package/dist/storage/domains/comments/wire.d.ts +0 -40
- package/dist/storage/domains/comments/wire.d.ts.map +0 -1
- package/dist/storage/domains/comments/wire.js +0 -36
- package/dist/storage/domains/comments/wire.js.map +0 -1
- package/factory-skills/factory-complete-issue/SKILL.md +0 -24
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import { closeReason } from "../../boards/board-events.js";
|
|
1
2
|
import "../../boards/index.js";
|
|
2
|
-
import {
|
|
3
|
-
import { cardLabels
|
|
4
|
-
import { boardEventHandlers, boardForWorkItem, eventBoardId, rulePhaseField, withBoardClosure, workItemPhaseSemantics } from "../../boards/semantics.js";
|
|
3
|
+
import { toBoardSource } from "../../boards/project-boards.js";
|
|
4
|
+
import { cardLabels } from "../../boards/relocate.js";
|
|
5
|
+
import { boardEventHandlers, boardForWorkItem, cardBoardFlow, cardOwnsBranch, eventBoardId, intakeTarget, isTerminalWorkItem, newestOwnedOpenPullRequestNumber, pullRequestSources, rulePhaseField, withBoardClosure, withBoardFlow, workItemPhaseSemantics } from "../../boards/semantics.js";
|
|
5
6
|
import { requestsChangesVerdict } from "../../review-verdict.js";
|
|
6
|
-
import { selectEventRule } from "../../rules/event-rules.js";
|
|
7
|
+
import { deploymentOwnsEvent, routeEventDecision, selectEventRule, withoutRouteEvent } from "../../rules/event-rules.js";
|
|
7
8
|
import { assertFactoryDecisionTarget, validateFactoryRuleDecisions } from "../../rules/validation.js";
|
|
8
|
-
import { resolveIntakeLabelRoute } from "../../storage/domains/intake/base.js";
|
|
9
9
|
import { FACTORY_PULL_REQUEST_RECONCILIATION_KEY, WorkItemUpdateConflictError } from "../../storage/domains/work-items/base.js";
|
|
10
10
|
import { primarySource } from "../../storage/domains/work-items/work-item-schema.js";
|
|
11
|
+
import { workItemBranch, workItemBranchSource } from "../../work-item-branch.js";
|
|
12
|
+
import { closingIssueNumbers } from "../closing-references.js";
|
|
11
13
|
import { recordPullRequestHead } from "../pull-request-head.js";
|
|
14
|
+
import { isRepositoryPullRequest } from "./pull-request-source.js";
|
|
12
15
|
import { changeRequestTargetKey } from "./subscriptions.js";
|
|
13
16
|
import { createHash } from "crypto";
|
|
14
17
|
// src/integrations/github/rules.ts
|
|
@@ -73,6 +76,40 @@ function parseFactoryReviewCommand(body, target) {
|
|
|
73
76
|
target
|
|
74
77
|
};
|
|
75
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Points the card's session at a new comment or an edit on its issue. Only
|
|
81
|
+
* pointers travel (who, where, a link); Factory's own comments are skipped so
|
|
82
|
+
* a session is not woken by what it wrote.
|
|
83
|
+
*/
|
|
84
|
+
function activitySignalFor(context) {
|
|
85
|
+
const event = context.event === "issueCommentCreated" ? "work_item.commented" : context.event === "issueEdited" ? "work_item.edited" : void 0;
|
|
86
|
+
if (!event || !context.item || !context.issue) return void 0;
|
|
87
|
+
if (context.actor.type !== "github" || context.actor.factoryAuthored) return void 0;
|
|
88
|
+
return {
|
|
89
|
+
type: "signalActivity",
|
|
90
|
+
idempotencyKey: `${context.ingress.id}:activity`,
|
|
91
|
+
event,
|
|
92
|
+
reference: `${context.repository.fullName}#${context.issue.number}`,
|
|
93
|
+
url: (event === "work_item.commented" ? context.issueComment?.url : void 0) ?? context.issue.url,
|
|
94
|
+
...context.actor.login ? { author: context.actor.login } : {},
|
|
95
|
+
authorTrusted: context.actor.trusted
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** The status change a GitHub delivery reports. `not_planned` and `duplicate` closes are canceled work. */
|
|
99
|
+
function boardEventFor(context) {
|
|
100
|
+
switch (context.event) {
|
|
101
|
+
case "issueOpened": return { type: "work_item.created" };
|
|
102
|
+
case "issueReopened": return { type: "work_item.reopened" };
|
|
103
|
+
case "issueClosed": {
|
|
104
|
+
const stateReason = context.issue?.stateReason;
|
|
105
|
+
return {
|
|
106
|
+
type: "work_item.closed",
|
|
107
|
+
reason: closeReason(stateReason === "not_planned" || stateReason === "duplicate")
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
default: return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
76
113
|
function eventName(parsed) {
|
|
77
114
|
const action = string(parsed.payload.action);
|
|
78
115
|
if (parsed.event === "issues" && action === "opened") return "issueOpened";
|
|
@@ -81,6 +118,7 @@ function eventName(parsed) {
|
|
|
81
118
|
return object(changes?.title) || object(changes?.body) ? "issueEdited" : void 0;
|
|
82
119
|
}
|
|
83
120
|
if (parsed.event === "issues" && action === "closed") return "issueClosed";
|
|
121
|
+
if (parsed.event === "issues" && action === "reopened") return "issueReopened";
|
|
84
122
|
if (parsed.event === "issue_comment") {
|
|
85
123
|
if (object(object(parsed.payload.issue)?.pull_request)) {
|
|
86
124
|
if (action === "created") return "pullRequestCommentCreated";
|
|
@@ -126,6 +164,52 @@ function canonicalSourceKey(kind, itemNumber) {
|
|
|
126
164
|
function legacySourceKey(repositoryId, kind, itemNumber) {
|
|
127
165
|
return `github:${repositoryId}:${kind}:${itemNumber}`;
|
|
128
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* The head branch of a pull request pushed to the repository itself. A fork's branch lives in
|
|
169
|
+
* another repository, so its name says nothing about which card wrote it — anyone could name a
|
|
170
|
+
* fork branch after a card. A payload without `head.repo` (rebuilt from polled state) is the
|
|
171
|
+
* base repository's own record and keeps its branch.
|
|
172
|
+
*/
|
|
173
|
+
function sameRepositoryHeadBranch(pullRequest, repositoryId) {
|
|
174
|
+
const head = object(pullRequest?.head);
|
|
175
|
+
if (head && "repo" in head && number(object(head.repo)?.id) !== repositoryId) return void 0;
|
|
176
|
+
return string(head?.ref);
|
|
177
|
+
}
|
|
178
|
+
/** A card attributed to a different repository than the pull request's. */
|
|
179
|
+
function cardInOtherRepository(item, repositoryId, repositoryFullName) {
|
|
180
|
+
return (/^https?:\/\/[^/]+\/.+\/(?:issues|pull)\/\d+(?:[/?#]|$)/.test(item.externalSource?.url ?? "") || typeof item.workItem.metadata?.githubRepositoryId === "number") && !cardBelongsToRepository(item, repositoryId, repositoryFullName);
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* The work item a pull request's head branch belongs to: a session of the item checked it out,
|
|
184
|
+
* or it is the item's own branch name, which covers pull requests opened from a session that
|
|
185
|
+
* only follows the card (no session on the card holds the branch, and no provenance was
|
|
186
|
+
* recorded). Only a single match counts; two cards claiming one branch name neither.
|
|
187
|
+
*/
|
|
188
|
+
function branchAuthoringItem(items, headBranch, repositoryId, repositoryFullName) {
|
|
189
|
+
if (!headBranch) return void 0;
|
|
190
|
+
const matches = items.filter((item) => item.externalSource?.type !== "pull-request" && !cardInOtherRepository(item, repositoryId, repositoryFullName) && (Object.values(item.sessions).some((session) => session.branch === headBranch) || workItemBranch({
|
|
191
|
+
id: item.id,
|
|
192
|
+
source: workItemBranchSource(item.externalSource),
|
|
193
|
+
metadata: item.workItem.metadata
|
|
194
|
+
}) === headBranch));
|
|
195
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
196
|
+
}
|
|
197
|
+
/** Every source a card for this issue or pull request may be filed under. */
|
|
198
|
+
function githubItemSources(repositoryId, kind, itemNumber) {
|
|
199
|
+
return [canonicalSourceKey(kind, itemNumber), legacySourceKey(repositoryId, kind, itemNumber)].map((externalId) => ({
|
|
200
|
+
integrationId: "github",
|
|
201
|
+
type: kind,
|
|
202
|
+
externalId
|
|
203
|
+
}));
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The pull request source an issue card carries for this repository's pull request, when it was
|
|
207
|
+
* attached to the card rather than filed on a card of its own.
|
|
208
|
+
*/
|
|
209
|
+
function attachedPullRequestSource(item, repositoryId, repositoryFullName, pullRequestNumber) {
|
|
210
|
+
if (item.externalSource?.type === "pull-request") return void 0;
|
|
211
|
+
return pullRequestSources(item).find((source) => isRepositoryPullRequest(source, repositoryId, repositoryFullName, pullRequestNumber));
|
|
212
|
+
}
|
|
129
213
|
function provenanceTarget(repositoryId, pullRequestNumber) {
|
|
130
214
|
return `factory-pr-provenance:${repositoryId}:${pullRequestNumber}`;
|
|
131
215
|
}
|
|
@@ -181,8 +265,8 @@ function pullRequestProvenance(data, factoryProjectId) {
|
|
|
181
265
|
workItemId: data.workItemId
|
|
182
266
|
};
|
|
183
267
|
}
|
|
184
|
-
/** Identity under which label
|
|
185
|
-
const
|
|
268
|
+
/** Identity under which label and assignee syncs are recorded. */
|
|
269
|
+
const CARD_SYNC_USER_ID = "factory-rule-dispatcher";
|
|
186
270
|
/**
|
|
187
271
|
* Whether a login is Factory itself. Prefers the resolved identity, which is
|
|
188
272
|
* observed from Factory's own writes, and falls back to the configured slug.
|
|
@@ -198,6 +282,14 @@ var GithubRules = class {
|
|
|
198
282
|
constructor(options) {
|
|
199
283
|
this.options = options;
|
|
200
284
|
}
|
|
285
|
+
/** Brings the project's boards up to date, so the sync reads below see its stored boards. */
|
|
286
|
+
async loadBoards(scope) {
|
|
287
|
+
await toBoardSource(this.options.boards).load(scope);
|
|
288
|
+
}
|
|
289
|
+
/** The project's loaded boards; {@link loadBoards} runs before an event is handled. */
|
|
290
|
+
#boards(scope) {
|
|
291
|
+
return toBoardSource(this.options.boards).forProject(scope);
|
|
292
|
+
}
|
|
201
293
|
/**
|
|
202
294
|
* Whether a login is Factory itself. Prefers the resolved identity, which is
|
|
203
295
|
* observed from Factory's own writes, and falls back to the configured slug.
|
|
@@ -214,80 +306,31 @@ var GithubRules = class {
|
|
|
214
306
|
return slug ? `${slug.toLowerCase()}[bot]` : void 0;
|
|
215
307
|
}
|
|
216
308
|
/**
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* leaves built-in routing (Work) in charge.
|
|
220
|
-
*/
|
|
221
|
-
async #intakeTarget(project, repositoryName, labels) {
|
|
222
|
-
const intake = this.options.intake;
|
|
223
|
-
if (!intake) return void 0;
|
|
224
|
-
const { orgId, factoryProjectId } = project;
|
|
225
|
-
if (labels.length > 0) {
|
|
226
|
-
const routes = await intake.listLabelRoutes({
|
|
227
|
-
orgId,
|
|
228
|
-
factoryProjectId,
|
|
229
|
-
integrationId: "github"
|
|
230
|
-
});
|
|
231
|
-
const route = resolveIntakeLabelRoute(routes, labels);
|
|
232
|
-
const board = route ? this.options.boards.get(route.board) : void 0;
|
|
233
|
-
if (board) return {
|
|
234
|
-
board: board.id,
|
|
235
|
-
initialPhase: board.initialPhase
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
const slug = repositoryName.toLowerCase();
|
|
239
|
-
const binding = (await intake.listBindings({
|
|
240
|
-
orgId,
|
|
241
|
-
integrationId: "github"
|
|
242
|
-
})).find((candidate) => candidate.factoryProjectId === factoryProjectId && (candidate.sourceId === project.projectRepository.repositoryId || candidate.sourceId.toLowerCase() === slug));
|
|
243
|
-
const board = binding?.board ? this.options.boards.get(binding.board) : void 0;
|
|
244
|
-
return board ? {
|
|
245
|
-
board: board.id,
|
|
246
|
-
initialPhase: board.initialPhase
|
|
247
|
-
} : void 0;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* `labeled` / `unlabeled` are not rule events: the labels only decide which board the card belongs
|
|
251
|
-
* on, so the card is re-routed here and its label metadata refreshed. Cards a run owns, and
|
|
252
|
-
* finished cards, stay where they are.
|
|
309
|
+
* `labeled` / `unlabeled` are not rule events: the card's label metadata is refreshed and the card
|
|
310
|
+
* stays where it is. Intake routes placed it when it arrived; a label change doesn't move it.
|
|
253
311
|
*/
|
|
254
|
-
async #
|
|
312
|
+
async #syncIssueLabels(parsed, repositoryId, repositoryName, project) {
|
|
255
313
|
const issue = object(parsed.payload.issue);
|
|
256
314
|
const issueNumber = issue?.pull_request === void 0 ? number(issue?.number) : void 0;
|
|
257
315
|
if (!issueNumber) return { status: "ignored" };
|
|
258
316
|
const found = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, issueNumber, void 0, void 0, null);
|
|
259
317
|
if (!found || found.externalSource?.type !== "issue") return { status: "ignored" };
|
|
260
318
|
const labels = labelNames(issue?.labels);
|
|
261
|
-
|
|
262
|
-
let
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (!(error instanceof WorkItemUpdateConflictError)) throw error;
|
|
275
|
-
return { status: "ignored" };
|
|
276
|
-
}
|
|
277
|
-
if (!updated) return { status: "ignored" };
|
|
278
|
-
item = updated.item;
|
|
279
|
-
changed = true;
|
|
319
|
+
if (sameLabels(cardLabels(found), labels)) return { status: "ignored" };
|
|
320
|
+
let updated;
|
|
321
|
+
try {
|
|
322
|
+
updated = await this.options.storage.syncCard({
|
|
323
|
+
orgId: found.orgId,
|
|
324
|
+
id: found.id,
|
|
325
|
+
userId: CARD_SYNC_USER_ID,
|
|
326
|
+
patch: { metadata: { labels } },
|
|
327
|
+
expectedSourceRevision: primarySource(found)?.revision
|
|
328
|
+
});
|
|
329
|
+
} catch (error) {
|
|
330
|
+
if (!(error instanceof WorkItemUpdateConflictError)) throw error;
|
|
331
|
+
return { status: "ignored" };
|
|
280
332
|
}
|
|
281
|
-
|
|
282
|
-
const target = await this.#intakeTarget(project, repositoryName, labels);
|
|
283
|
-
const outcome = await moveCardToBoard({
|
|
284
|
-
workItems: this.options.storage,
|
|
285
|
-
boardRegistry: this.options.boards,
|
|
286
|
-
userId: LABEL_ROUTE_USER_ID,
|
|
287
|
-
item,
|
|
288
|
-
targetBoard: target?.board ?? "work"
|
|
289
|
-
});
|
|
290
|
-
return { status: changed || outcome === "moved" ? "committed" : "ignored" };
|
|
333
|
+
return { status: updated ? "committed" : "ignored" };
|
|
291
334
|
}
|
|
292
335
|
/**
|
|
293
336
|
* `assigned` / `unassigned` are not rule events either: an existing issue card only mirrors the
|
|
@@ -310,7 +353,7 @@ var GithubRules = class {
|
|
|
310
353
|
return { status: await this.options.storage.syncCard({
|
|
311
354
|
orgId: item.orgId,
|
|
312
355
|
id: item.id,
|
|
313
|
-
userId:
|
|
356
|
+
userId: CARD_SYNC_USER_ID,
|
|
314
357
|
patch: { metadata: {
|
|
315
358
|
assignees,
|
|
316
359
|
...payloadTime !== void 0 ? { githubAssigneesUpdatedAt: updatedAt } : {}
|
|
@@ -327,7 +370,7 @@ var GithubRules = class {
|
|
|
327
370
|
if (parsed.event !== "issues") return void 0;
|
|
328
371
|
switch (string(parsed.payload.action)) {
|
|
329
372
|
case "labeled":
|
|
330
|
-
case "unlabeled": return (...args) => this.#
|
|
373
|
+
case "unlabeled": return (...args) => this.#syncIssueLabels(...args);
|
|
331
374
|
case "assigned":
|
|
332
375
|
case "unassigned": return (...args) => this.#syncIssueAssignees(...args);
|
|
333
376
|
default: return;
|
|
@@ -354,7 +397,10 @@ var GithubRules = class {
|
|
|
354
397
|
});
|
|
355
398
|
if (projects.length === 0) return { status: "ignored" };
|
|
356
399
|
const results = [];
|
|
357
|
-
for (const project of projects)
|
|
400
|
+
for (const project of projects) {
|
|
401
|
+
await this.loadBoards(project);
|
|
402
|
+
results.push(await handle(project));
|
|
403
|
+
}
|
|
358
404
|
if (results.some((result) => result.status === "committed")) return { status: "committed" };
|
|
359
405
|
if (results.some((result) => result.status === "replayed")) return { status: "replayed" };
|
|
360
406
|
return results[0] ?? { status: "ignored" };
|
|
@@ -406,9 +452,9 @@ var GithubRules = class {
|
|
|
406
452
|
const requestedReviewer = string(object(parsed.payload.requested_reviewer)?.login);
|
|
407
453
|
const pullRequestAuthor = string(object(pullRequest?.user)?.login);
|
|
408
454
|
const pullRequestFactoryAuthored = provenance !== null || this.#isFactoryLogin(pullRequestAuthor);
|
|
409
|
-
const resolvedItem = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, issueNumber, pullRequestNumber,
|
|
410
|
-
const
|
|
411
|
-
const intake =
|
|
455
|
+
const resolvedItem = await this.#relatedItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, issueNumber, pullRequestNumber, sameRepositoryHeadBranch(pullRequest, repositoryId), reReviewEvent ? null : provenance, senderIsResponder && !reviewEntryRequested);
|
|
456
|
+
const matchedItem = reviewEntryRequested && resolvedItem?.externalSource?.type !== "pull-request" && !(resolvedItem && pullRequestNumber && attachedPullRequestSource(resolvedItem, repositoryId, repositoryName, pullRequestNumber)) ? void 0 : resolvedItem;
|
|
457
|
+
const intake = intakeTarget(this.#boards(project));
|
|
412
458
|
const actor = await githubActor(this.options.github, {
|
|
413
459
|
installationId,
|
|
414
460
|
repository: repositoryName,
|
|
@@ -416,6 +462,22 @@ var GithubRules = class {
|
|
|
416
462
|
factoryAuthored: !senderIsResponder && provenance !== null || this.#isFactoryLogin(login)
|
|
417
463
|
});
|
|
418
464
|
if (actor.type === "github" && actor.factoryAuthored && (event === "issueCommentCreated" || event === "issueCommentEdited") && string(issueComment?.body)?.includes(FACTORY_TRIAGE_COMMENT_MARKER)) return { status: "ignored" };
|
|
465
|
+
const home = event === "pullRequestOpened" && pullRequestNumber ? await this.#pullRequestHome({
|
|
466
|
+
orgId: project.orgId,
|
|
467
|
+
factoryProjectId: project.factoryProjectId,
|
|
468
|
+
repositoryId,
|
|
469
|
+
repositoryName,
|
|
470
|
+
pullRequestNumber,
|
|
471
|
+
matchedItem,
|
|
472
|
+
factoryAuthored: pullRequestFactoryAuthored,
|
|
473
|
+
authorTrusted: actor.type === "github" && actor.trusted && login === pullRequestAuthor,
|
|
474
|
+
body: string(pullRequest?.body)
|
|
475
|
+
}) : void 0;
|
|
476
|
+
const relatedItem = (home?.reason === "authored" ? home.card : void 0) ?? matchedItem;
|
|
477
|
+
const pullRequestHome = home ? {
|
|
478
|
+
workItemId: home.card.id,
|
|
479
|
+
reason: home.reason
|
|
480
|
+
} : void 0;
|
|
419
481
|
const evaluate = async (item, ingressIdentity, pullRequestIntake = false, attempt = 1) => {
|
|
420
482
|
const context = {
|
|
421
483
|
tenant: {
|
|
@@ -445,11 +507,13 @@ var GithubRules = class {
|
|
|
445
507
|
},
|
|
446
508
|
board: boardForWorkItem(item),
|
|
447
509
|
itemRevision: item.revision,
|
|
448
|
-
...withBoardClosure(this
|
|
449
|
-
...rulePhaseField(this
|
|
510
|
+
...withBoardClosure(this.#boards(project), item),
|
|
511
|
+
...rulePhaseField(this.#boards(project), item),
|
|
512
|
+
...withBoardFlow(this.#boards(project), item)
|
|
450
513
|
} : {},
|
|
451
514
|
...intake ? { intake } : {},
|
|
452
515
|
...pullRequestIntake ? { pullRequestIntake: true } : {},
|
|
516
|
+
...pullRequestHome ? { pullRequestHome } : {},
|
|
453
517
|
event,
|
|
454
518
|
deliveryId: parsed.deliveryId,
|
|
455
519
|
factory: { createdAt: factoryProject.createdAt.toISOString() },
|
|
@@ -497,6 +561,7 @@ var GithubRules = class {
|
|
|
497
561
|
...pullRequestAuthor ? { author: pullRequestAuthor } : {},
|
|
498
562
|
factoryAuthored: pullRequestFactoryAuthored,
|
|
499
563
|
headBranch: string(object(pullRequest?.head)?.ref) ?? "",
|
|
564
|
+
...string(object(pullRequest?.head)?.sha) ? { headSha: string(object(pullRequest?.head)?.sha).toLowerCase() } : {},
|
|
500
565
|
baseBranch: string(object(pullRequest?.base)?.ref) ?? ""
|
|
501
566
|
} } : {},
|
|
502
567
|
...reviewRequested && requestedReviewer ? { reviewRequest: {
|
|
@@ -512,8 +577,11 @@ var GithubRules = class {
|
|
|
512
577
|
...string(object(parsed.payload.review)?.body) ? { body: string(object(parsed.payload.review)?.body) } : {}
|
|
513
578
|
} } : {}
|
|
514
579
|
};
|
|
515
|
-
const
|
|
516
|
-
|
|
580
|
+
const boardEvent = boardEventFor(context);
|
|
581
|
+
if (boardEvent) context.boardEvent = boardEvent;
|
|
582
|
+
const ownedByDeployment = deploymentOwnsEvent(this.options.github.rules, boardEventHandlers(this.#boards(project), eventBoardId(context), "github"), event);
|
|
583
|
+
const rule = selectEventRule(this.options.github.rules, boardEventHandlers(this.#boards(project), eventBoardId(context), "github"), event);
|
|
584
|
+
let decision = void 0;
|
|
517
585
|
let decisions = [];
|
|
518
586
|
let outcome = { status: "accepted" };
|
|
519
587
|
try {
|
|
@@ -524,7 +592,7 @@ var GithubRules = class {
|
|
|
524
592
|
reason: decision.reason
|
|
525
593
|
};
|
|
526
594
|
else if (decision) decisions = validateFactoryRuleDecisions([decision]).map((entry) => {
|
|
527
|
-
assertFactoryDecisionTarget(entry, this
|
|
595
|
+
assertFactoryDecisionTarget(entry, this.#boards(project), item ? boardForWorkItem(item) : void 0);
|
|
528
596
|
return { ...entry };
|
|
529
597
|
});
|
|
530
598
|
} catch (error) {
|
|
@@ -535,6 +603,14 @@ var GithubRules = class {
|
|
|
535
603
|
reason: timedOut ? "Factory rule evaluation timed out." : error instanceof Error ? error.message.slice(0, 2e3) : "Factory GitHub rule failed."
|
|
536
604
|
};
|
|
537
605
|
}
|
|
606
|
+
if (ownedByDeployment) decisions = decisions.map(withoutRouteEvent);
|
|
607
|
+
if (!decision && !ownedByDeployment && outcome.status === "accepted") {
|
|
608
|
+
const routed = await routeEventDecision(context, this.options.storage, {
|
|
609
|
+
orgId: project.orgId,
|
|
610
|
+
factoryProjectId: project.factoryProjectId
|
|
611
|
+
}) ?? activitySignalFor(context);
|
|
612
|
+
if (routed) decisions = [{ ...routed }];
|
|
613
|
+
}
|
|
538
614
|
const committed = await this.options.storage.commitRuleEvaluation({
|
|
539
615
|
orgId: project.orgId,
|
|
540
616
|
factoryProjectId: project.factoryProjectId,
|
|
@@ -566,6 +642,16 @@ var GithubRules = class {
|
|
|
566
642
|
const headSha = string(object(pullRequest?.head)?.sha)?.toLowerCase();
|
|
567
643
|
if (event !== "pullRequestUpdated" || !headSha || !pullRequestNumber) return;
|
|
568
644
|
const headAt = timestamp(pullRequest?.updated_at);
|
|
645
|
+
if (relatedItem && attachedPullRequestSource(relatedItem, repositoryId, repositoryName, pullRequestNumber)) {
|
|
646
|
+
await recordPullRequestHead(this.options.storage, {
|
|
647
|
+
orgId: relatedItem.orgId,
|
|
648
|
+
id: relatedItem.id,
|
|
649
|
+
headSha,
|
|
650
|
+
headAt,
|
|
651
|
+
ownedPullRequestNumber: pullRequestNumber
|
|
652
|
+
});
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
569
655
|
if (relatedItem?.externalSource?.type !== "pull-request") return;
|
|
570
656
|
const parent = await this.#linkedClosureItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, pullRequestNumber, relatedItem);
|
|
571
657
|
await recordPullRequestHead(this.options.storage, {
|
|
@@ -590,14 +676,22 @@ var GithubRules = class {
|
|
|
590
676
|
const deliveryIdentity = `${installationId}:${parsed.deliveryId}`;
|
|
591
677
|
const pullRequestOpened = event === "pullRequestOpened";
|
|
592
678
|
const primary = await evaluate(evaluated, deliveryIdentity, pullRequestOpened);
|
|
593
|
-
const linked = (event === "pullRequestMerged" || event === "pullRequestClosed") && relatedItem && pullRequestNumber ? await this.#linkedClosureItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, pullRequestNumber, relatedItem
|
|
679
|
+
const linked = (event === "pullRequestMerged" || event === "pullRequestClosed") && relatedItem && pullRequestNumber ? await this.#linkedClosureItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, pullRequestNumber, relatedItem, relatedItem.externalSource?.type === "pull-request" && !relatedItem.parentWorkItemId && (pullRequestFactoryAuthored || pullRequestAuthor !== void 0 && await trustedCollaborator(this.options.github, {
|
|
680
|
+
installationId,
|
|
681
|
+
repository: repositoryName,
|
|
682
|
+
login: pullRequestAuthor
|
|
683
|
+
})) ? sameRepositoryHeadBranch(pullRequest, repositoryId) : void 0) : void 0;
|
|
594
684
|
const stampClosed = async (companionStatus) => {
|
|
595
685
|
if (!pullRequestNumber) return;
|
|
596
686
|
if (pullRequestOpened) {
|
|
597
687
|
const trusted = actor.type === "github" && actor.trusted || pullRequestFactoryAuthored;
|
|
598
688
|
if (!authoringItem || !trusted || authoringItem.metadata?.openPullRequestNumber === pullRequestNumber) return;
|
|
599
689
|
const reviewCard = await this.#linkedClosureItem(project.orgId, project.factoryProjectId, repositoryId, repositoryName, pullRequestNumber, authoringItem);
|
|
600
|
-
|
|
690
|
+
const attached = attachedPullRequestSource(authoringItem, repositoryId, repositoryName, pullRequestNumber);
|
|
691
|
+
const recordedState = reviewCard ? reviewCard.workItem.state : attached?.state;
|
|
692
|
+
if (!(companionStatus === "replayed" ? (reviewCard !== void 0 || attached !== void 0) && !["closed", "merged"].includes(recordedState ?? "") : !["closed", "merged"].includes(recordedState ?? ""))) return;
|
|
693
|
+
const headBranch = string(object(pullRequest?.head)?.ref);
|
|
694
|
+
if (!(home?.reason === "authored" || home === void 0 && (attached === void 0 || pullRequestFactoryAuthored || cardOwnsBranch(authoringItem, headBranch)))) return;
|
|
601
695
|
await this.options.storage.update({
|
|
602
696
|
orgId: authoringItem.orgId,
|
|
603
697
|
id: authoringItem.id,
|
|
@@ -614,10 +708,25 @@ var GithubRules = class {
|
|
|
614
708
|
for (const card of [relatedItem, linked]) {
|
|
615
709
|
if (!card) continue;
|
|
616
710
|
if (card.externalSource?.type !== "pull-request") {
|
|
711
|
+
const attached = attachedPullRequestSource(card, repositoryId, repositoryName, pullRequestNumber);
|
|
712
|
+
if (attached) await this.options.storage.syncWorkItemSource({
|
|
713
|
+
orgId: card.orgId,
|
|
714
|
+
factoryProjectId: card.factoryProjectId,
|
|
715
|
+
provider: attached.provider,
|
|
716
|
+
externalId: attached.externalId,
|
|
717
|
+
patch: {
|
|
718
|
+
state: event === "pullRequestMerged" ? "merged" : "closed",
|
|
719
|
+
metadata: {
|
|
720
|
+
state: "closed",
|
|
721
|
+
merged: event === "pullRequestMerged"
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
if (!attached && pullRequestSources(card).length > 0) continue;
|
|
617
726
|
const recorded = card.metadata?.openPullRequestNumber;
|
|
618
727
|
const settled = {
|
|
619
728
|
...(typeof recorded !== "number" || recorded === pullRequestNumber) && event === "pullRequestMerged" && typeof card.metadata?.reviewVerdict === "string" ? { reviewVerdict: null } : {},
|
|
620
|
-
...recorded === pullRequestNumber ? { openPullRequestNumber:
|
|
729
|
+
...recorded === pullRequestNumber ? { openPullRequestNumber: newestOwnedOpenPullRequestNumber(card, pullRequestNumber) } : {}
|
|
621
730
|
};
|
|
622
731
|
if (Object.keys(settled).length > 0) await this.options.storage.update({
|
|
623
732
|
orgId: card.orgId,
|
|
@@ -656,29 +765,133 @@ var GithubRules = class {
|
|
|
656
765
|
* heuristics. Returns nothing when the pull request has only one card, which
|
|
657
766
|
* is every pull request Factory did not open from a work item's session.
|
|
658
767
|
*/
|
|
659
|
-
async #linkedClosureItem(orgId, projectId, repositoryId, repositoryFullName, pullRequestNumber, resolved) {
|
|
660
|
-
|
|
768
|
+
async #linkedClosureItem(orgId, projectId, repositoryId, repositoryFullName, pullRequestNumber, resolved, headBranch) {
|
|
769
|
+
await this.options.storage.copyLegacyCards({
|
|
770
|
+
orgId,
|
|
771
|
+
factoryProjectId: projectId,
|
|
772
|
+
sources: githubItemSources(repositoryId, "pull-request", pullRequestNumber)
|
|
773
|
+
});
|
|
774
|
+
const items = await this.options.storage.listShared({
|
|
661
775
|
orgId,
|
|
662
776
|
factoryProjectId: projectId
|
|
663
777
|
});
|
|
664
|
-
const linked = resolved.externalSource?.type === "pull-request" ?
|
|
665
|
-
return linked
|
|
778
|
+
const linked = resolved.externalSource?.type === "pull-request" ? resolved.parentWorkItemId ? await this.#parentItem(orgId, projectId, items, resolved) : branchAuthoringItem(items, headBranch, repositoryId, repositoryFullName) : items.find((item) => item.parentWorkItemId === resolved.id && (item.externalSource?.externalId === canonicalSourceKey("pull-request", pullRequestNumber) || item.externalSource?.externalId === legacySourceKey(repositoryId, "pull-request", pullRequestNumber)) && cardBelongsToRepository(item, repositoryId, repositoryFullName));
|
|
779
|
+
return linked && linked.id !== resolved.id ? structuredClone(linked) : void 0;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* The existing card a pull request opened for the first time belongs with, or undefined when it
|
|
783
|
+
* gets a card of its own. The card must be open, in this repository, and not a pull request's
|
|
784
|
+
* own card. In order: the card that authored it (on a board that reviews pull requests), by provenance or session branch,
|
|
785
|
+
* when the pull request is Factory-authored or its author is trusted; it is filed there. Then,
|
|
786
|
+
* for a trusted author only, the card of the first issue its description says it closes; an
|
|
787
|
+
* intake route decides whether it joins that one. An untrusted author's pull request never
|
|
788
|
+
* lands on another card, whatever it says.
|
|
789
|
+
*/
|
|
790
|
+
async #pullRequestHome(input) {
|
|
791
|
+
if (!input.factoryAuthored && !input.authorTrusted) return void 0;
|
|
792
|
+
const items = await this.options.storage.listShared({
|
|
793
|
+
orgId: input.orgId,
|
|
794
|
+
factoryProjectId: input.factoryProjectId
|
|
795
|
+
});
|
|
796
|
+
if (items.some((item) => attachedPullRequestSource(item, input.repositoryId, input.repositoryName, input.pullRequestNumber) || item.externalSource?.type === "pull-request" && (item.externalSource.externalId === canonicalSourceKey("pull-request", input.pullRequestNumber) || item.externalSource.externalId === legacySourceKey(input.repositoryId, "pull-request", input.pullRequestNumber)) && cardBelongsToRepository(item, input.repositoryId, input.repositoryName))) return void 0;
|
|
797
|
+
const eligible = (card) => card.externalSource?.type !== "pull-request" && !isTerminalWorkItem(this.#boards(input), card) && cardBelongsToRepository(card, input.repositoryId, input.repositoryName);
|
|
798
|
+
if (input.matchedItem && eligible(input.matchedItem) && cardBoardFlow(this.#boards(input), input.matchedItem).pullRequestReview !== void 0) return {
|
|
799
|
+
card: input.matchedItem,
|
|
800
|
+
reason: "authored"
|
|
801
|
+
};
|
|
802
|
+
if (!input.authorTrusted) return void 0;
|
|
803
|
+
for (const issueNumber of closingIssueNumbers(input.body, {
|
|
804
|
+
provider: "github",
|
|
805
|
+
repository: input.repositoryName
|
|
806
|
+
})) {
|
|
807
|
+
const card = items.find((item) => (item.externalSource?.externalId === canonicalSourceKey("issue", issueNumber) || item.externalSource?.externalId === legacySourceKey(input.repositoryId, "issue", issueNumber)) && eligible(item));
|
|
808
|
+
if (card) return {
|
|
809
|
+
card: structuredClone(card),
|
|
810
|
+
reason: "closes"
|
|
811
|
+
};
|
|
812
|
+
}
|
|
666
813
|
}
|
|
667
814
|
async #relatedItem(orgId, projectId, repositoryId, repositoryFullName, issueNumber, pullRequestNumber, pullRequestHeadBranch, provenance, preferAuthoringItem = false) {
|
|
668
|
-
|
|
815
|
+
await this.options.storage.copyLegacyCards({
|
|
816
|
+
orgId,
|
|
817
|
+
factoryProjectId: projectId,
|
|
818
|
+
sources: [...issueNumber ? githubItemSources(repositoryId, "issue", issueNumber) : [], ...pullRequestNumber ? githubItemSources(repositoryId, "pull-request", pullRequestNumber) : []]
|
|
819
|
+
});
|
|
820
|
+
if (provenance) await this.options.storage.getForProject(orgId, projectId, provenance.workItemId);
|
|
821
|
+
const items = await this.options.storage.listShared({
|
|
669
822
|
orgId,
|
|
670
823
|
factoryProjectId: projectId
|
|
671
824
|
});
|
|
672
825
|
const resolved = this.#resolveItem(items, repositoryId, repositoryFullName, issueNumber, pullRequestNumber, pullRequestHeadBranch, provenance);
|
|
673
|
-
if (preferAuthoringItem && resolved?.externalSource?.type === "pull-request" && resolved.parentWorkItemId) return
|
|
674
|
-
return resolved;
|
|
826
|
+
if (preferAuthoringItem && resolved?.externalSource?.type === "pull-request" && resolved.parentWorkItemId) return structuredClone(await this.#parentItem(orgId, projectId, items, resolved) ?? resolved);
|
|
827
|
+
return resolved && structuredClone(resolved);
|
|
828
|
+
}
|
|
829
|
+
/** The card `child` was filed from; read on its own when the board list lacks it (not copied yet). */
|
|
830
|
+
async #parentItem(orgId, projectId, items, child) {
|
|
831
|
+
if (!child.parentWorkItemId) return void 0;
|
|
832
|
+
return items.find((item) => item.id === child.parentWorkItemId) ?? await this.options.storage.getForProject(orgId, projectId, child.parentWorkItemId) ?? void 0;
|
|
675
833
|
}
|
|
676
834
|
#resolveItem(items, repositoryId, repositoryFullName, issueNumber, pullRequestNumber, pullRequestHeadBranch, provenance) {
|
|
677
835
|
if (provenance) return items.find((item) => item.id === provenance.workItemId);
|
|
678
836
|
if (issueNumber) return items.find((item) => item.externalSource?.externalId === canonicalSourceKey("issue", issueNumber) && cardBelongsToRepository(item, repositoryId, repositoryFullName)) ?? items.find((item) => item.externalSource?.externalId === legacySourceKey(repositoryId, "issue", issueNumber));
|
|
679
|
-
if (pullRequestNumber) return items.find((item) => item.externalSource?.externalId === canonicalSourceKey("pull-request", pullRequestNumber) && cardBelongsToRepository(item, repositoryId, repositoryFullName)) ?? items.find((item) => item.externalSource?.externalId === legacySourceKey(repositoryId, "pull-request", pullRequestNumber)) ??
|
|
837
|
+
if (pullRequestNumber) return items.find((item) => item.externalSource?.externalId === canonicalSourceKey("pull-request", pullRequestNumber) && cardBelongsToRepository(item, repositoryId, repositoryFullName)) ?? items.find((item) => item.externalSource?.externalId === legacySourceKey(repositoryId, "pull-request", pullRequestNumber)) ?? items.find((item) => attachedPullRequestSource(item, repositoryId, repositoryFullName, pullRequestNumber)) ?? branchAuthoringItem(items, pullRequestHeadBranch, repositoryId, repositoryFullName);
|
|
680
838
|
}
|
|
681
839
|
};
|
|
840
|
+
/** The facts of an open, non-draft pull request as a version-control listing reports them. */
|
|
841
|
+
function listedPullRequestState(pullRequest) {
|
|
842
|
+
return {
|
|
843
|
+
number: Number(pullRequest.id),
|
|
844
|
+
title: pullRequest.title,
|
|
845
|
+
url: pullRequest.url,
|
|
846
|
+
state: "open",
|
|
847
|
+
draft: false,
|
|
848
|
+
merged: false,
|
|
849
|
+
assignees: pullRequest.assignees ?? [],
|
|
850
|
+
requestedReviewers: pullRequest.requestedReviewers ?? [],
|
|
851
|
+
labels: pullRequest.labels ?? [],
|
|
852
|
+
headBranch: pullRequest.headBranch,
|
|
853
|
+
baseBranch: pullRequest.baseBranch,
|
|
854
|
+
...pullRequest.author ? { author: pullRequest.author } : {},
|
|
855
|
+
createdAt: pullRequest.createdAt,
|
|
856
|
+
headSha: pullRequest.headSha,
|
|
857
|
+
updatedAt: pullRequest.updatedAt
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* Missed-open discovery reads at most this many pages per repository per sweep,
|
|
862
|
+
* so a repository flooded with pull requests (or a listing whose cursor never
|
|
863
|
+
* ends) cannot grow a sweep's API cost without limit. A missed open is among
|
|
864
|
+
* the newest, and thirty per page keeps the 600 newest in reach.
|
|
865
|
+
*/
|
|
866
|
+
const OPEN_PULL_REQUEST_DISCOVERY_MAX_PAGES = 20;
|
|
867
|
+
/**
|
|
868
|
+
* Missed-open discovery over an integration's version-control capability.
|
|
869
|
+
* GitHub lists open pull requests newest first, so paging stops at the first
|
|
870
|
+
* page opened entirely before `createdSince`, or at the page cap.
|
|
871
|
+
*/
|
|
872
|
+
function openPullRequestLister(versionControl) {
|
|
873
|
+
return async ({ installationId, repository, createdSince }) => {
|
|
874
|
+
const states = [];
|
|
875
|
+
let cursor = "1";
|
|
876
|
+
for (let page = 0; cursor !== null && page < OPEN_PULL_REQUEST_DISCOVERY_MAX_PAGES; page += 1) {
|
|
877
|
+
const listed = await versionControl.listPullRequests({
|
|
878
|
+
connection: {
|
|
879
|
+
type: "app-installation",
|
|
880
|
+
installationId
|
|
881
|
+
},
|
|
882
|
+
sourceId: repository,
|
|
883
|
+
state: "open",
|
|
884
|
+
includeDrafts: true,
|
|
885
|
+
cursor
|
|
886
|
+
});
|
|
887
|
+
const recent = listed.pullRequests.filter((pullRequest) => !(Date.parse(pullRequest.createdAt) < createdSince));
|
|
888
|
+
states.push(...recent.filter((pullRequest) => !pullRequest.draft).map(listedPullRequestState));
|
|
889
|
+
if (recent.length === 0) break;
|
|
890
|
+
cursor = listed.nextCursor;
|
|
891
|
+
}
|
|
892
|
+
return states;
|
|
893
|
+
};
|
|
894
|
+
}
|
|
682
895
|
const RECONCILE_ERROR_SAMPLE_LIMIT = 5;
|
|
683
896
|
function sameStrings(left, right) {
|
|
684
897
|
if (right === void 0) return true;
|
|
@@ -709,6 +922,16 @@ function reconcilablePullRequestNumber(item, repository) {
|
|
|
709
922
|
const canonical = /^github-pr:(\d+)$/.exec(externalId);
|
|
710
923
|
return canonical ? Number(canonical[1]) : void 0;
|
|
711
924
|
}
|
|
925
|
+
/** The number of an attached pull request source, when it belongs to the given repository. */
|
|
926
|
+
function attachedPullRequestNumber(source, repository) {
|
|
927
|
+
if (source.integrationId !== "github") return void 0;
|
|
928
|
+
if (source.url) {
|
|
929
|
+
const match = /^https?:\/\/[^/]+\/(.+)\/pull\/(\d+)(?:[/?#]|$)/.exec(source.url);
|
|
930
|
+
return match && match[1] === repository.fullName ? Number(match[2]) : void 0;
|
|
931
|
+
}
|
|
932
|
+
const legacy = /^pull-request:github:(\d+):pull-request:(\d+)$/.exec(source.externalId);
|
|
933
|
+
return legacy && Number(legacy[1]) === repository.id ? Number(legacy[2]) : void 0;
|
|
934
|
+
}
|
|
712
935
|
/**
|
|
713
936
|
* Extracts the issue number a work item tracks, but only when the item
|
|
714
937
|
* belongs to the given repository. Stricter than
|
|
@@ -821,6 +1044,17 @@ function polledPullRequestEvent(repository, pullRequestNumber, state) {
|
|
|
821
1044
|
}
|
|
822
1045
|
};
|
|
823
1046
|
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Replays an open pull request that has no card as the `opened` delivery
|
|
1049
|
+
* GitHub never sent. The delivery id is stable per pull request so repeat
|
|
1050
|
+
* sweeps dedupe at the ingress.
|
|
1051
|
+
*/
|
|
1052
|
+
function reconciledPullRequestOpenedEvent(repository, pullRequestNumber, state) {
|
|
1053
|
+
return {
|
|
1054
|
+
...polledPullRequestEvent(repository, pullRequestNumber, state),
|
|
1055
|
+
deliveryId: `reconcile:${repository.id}:pull-request:${pullRequestNumber}:opened`
|
|
1056
|
+
};
|
|
1057
|
+
}
|
|
824
1058
|
function reconciledClosedEvent(repository, pullRequestNumber, state) {
|
|
825
1059
|
const outcome = state.merged ? "merged" : "closed";
|
|
826
1060
|
return {
|
|
@@ -852,10 +1086,14 @@ function pullRequestPayload(pullRequestNumber, state) {
|
|
|
852
1086
|
assignees: githubUsers(state.assignees),
|
|
853
1087
|
requested_reviewers: githubUsers(state.requestedReviewers),
|
|
854
1088
|
labels: githubLabels(state.labels),
|
|
855
|
-
head: {
|
|
1089
|
+
head: {
|
|
1090
|
+
ref: state.headBranch,
|
|
1091
|
+
...state.headSha ? { sha: state.headSha } : {}
|
|
1092
|
+
},
|
|
856
1093
|
base: { ref: state.baseBranch }
|
|
857
1094
|
};
|
|
858
1095
|
if (state.createdAt) payload.created_at = state.createdAt;
|
|
1096
|
+
if (state.updatedAt) payload.updated_at = state.updatedAt;
|
|
859
1097
|
if (state.author) payload.user = { login: state.author };
|
|
860
1098
|
return payload;
|
|
861
1099
|
}
|
|
@@ -901,6 +1139,7 @@ async function retireReconciledSubscriptions(storage, repository, pullRequestNum
|
|
|
901
1139
|
* can miss a merge (cursor gaps, downtime, terminally failed decisions), so
|
|
902
1140
|
* this sweep compares still-open PR cards against actual GitHub state and
|
|
903
1141
|
* replays the merge through the normal rules ingress when they disagree.
|
|
1142
|
+
* Missed opens are {@link createGithubPullRequestDiscovery}'s, on its own cadence.
|
|
904
1143
|
*/
|
|
905
1144
|
function createGithubPullRequestReconciler(options, fetchPullRequest) {
|
|
906
1145
|
const rules = new GithubRules(options);
|
|
@@ -921,11 +1160,11 @@ function createGithubPullRequestReconciler(options, fetchPullRequest) {
|
|
|
921
1160
|
error: error instanceof Error ? error.message : String(error)
|
|
922
1161
|
});
|
|
923
1162
|
};
|
|
924
|
-
const
|
|
925
|
-
const scoped = repositories.filter((repository) => configured.has(`${repository.installationId}\u0000${repository.id}`));
|
|
1163
|
+
const scoped = await linkedRepositories(options, repositories);
|
|
926
1164
|
summary.repositories = scoped.length;
|
|
927
1165
|
for (const repository of scoped) {
|
|
928
1166
|
let cardsByNumber;
|
|
1167
|
+
let attachedOpen;
|
|
929
1168
|
let unanswered;
|
|
930
1169
|
try {
|
|
931
1170
|
const projects = await options.sourceControl.projectRepositories.listByExternalRepository({
|
|
@@ -934,9 +1173,11 @@ function createGithubPullRequestReconciler(options, fetchPullRequest) {
|
|
|
934
1173
|
});
|
|
935
1174
|
if (projects.length === 0) continue;
|
|
936
1175
|
cardsByNumber = /* @__PURE__ */ new Map();
|
|
1176
|
+
attachedOpen = /* @__PURE__ */ new Set();
|
|
937
1177
|
unanswered = [];
|
|
938
1178
|
for (const project of projects) {
|
|
939
|
-
|
|
1179
|
+
await rules.loadBoards(project);
|
|
1180
|
+
const items = await options.storage.listShared({
|
|
940
1181
|
orgId: project.orgId,
|
|
941
1182
|
factoryProjectId: project.factoryProjectId
|
|
942
1183
|
});
|
|
@@ -946,6 +1187,10 @@ function createGithubPullRequestReconciler(options, fetchPullRequest) {
|
|
|
946
1187
|
item,
|
|
947
1188
|
author: unansweredAuthor
|
|
948
1189
|
});
|
|
1190
|
+
if (item.externalSource?.type !== "pull-request" && !isTerminalWorkItem(toBoardSource(options.boards).forProject(item), item)) for (const source of pullRequestSources(item)) {
|
|
1191
|
+
const number = attachedPullRequestNumber(source, repository);
|
|
1192
|
+
if (number !== void 0 && !["closed", "merged"].includes(source.state ?? "")) attachedOpen.add(number);
|
|
1193
|
+
}
|
|
949
1194
|
const pullRequestNumber = reconcilablePullRequestNumber(item, repository);
|
|
950
1195
|
if (!pullRequestNumber) continue;
|
|
951
1196
|
const metadata = {
|
|
@@ -954,7 +1199,7 @@ function createGithubPullRequestReconciler(options, fetchPullRequest) {
|
|
|
954
1199
|
};
|
|
955
1200
|
const reconciliation = metadata[FACTORY_PULL_REQUEST_RECONCILIATION_KEY];
|
|
956
1201
|
const reconciledOutcome = reconciledPullRequestOutcome(metadata);
|
|
957
|
-
if (workItemPhaseSemantics(options.boards, item)?.kind === "terminal" && reconciledOutcome !== void 0 && reconciliation === reconciledOutcome) continue;
|
|
1202
|
+
if (workItemPhaseSemantics(toBoardSource(options.boards).forProject(item), item)?.kind === "terminal" && reconciledOutcome !== void 0 && reconciliation === reconciledOutcome) continue;
|
|
958
1203
|
const cards = cardsByNumber.get(pullRequestNumber) ?? [];
|
|
959
1204
|
cards.push(item);
|
|
960
1205
|
cardsByNumber.set(pullRequestNumber, cards);
|
|
@@ -1018,7 +1263,7 @@ function createGithubPullRequestReconciler(options, fetchPullRequest) {
|
|
|
1018
1263
|
if (state.state !== "closed") continue;
|
|
1019
1264
|
const cleanupFailures = /* @__PURE__ */ new Set();
|
|
1020
1265
|
for (const card of cards) {
|
|
1021
|
-
if (workItemPhaseSemantics(options.boards, card)?.kind !== "terminal") continue;
|
|
1266
|
+
if (workItemPhaseSemantics(toBoardSource(options.boards).forProject(card), card)?.kind !== "terminal") continue;
|
|
1022
1267
|
try {
|
|
1023
1268
|
await options.storage.supersedeDecisionsForWorkItem({
|
|
1024
1269
|
orgId: card.orgId,
|
|
@@ -1052,10 +1297,161 @@ function createGithubPullRequestReconciler(options, fetchPullRequest) {
|
|
|
1052
1297
|
} catch (error) {
|
|
1053
1298
|
recordFailure(repository, error, pullRequestNumber);
|
|
1054
1299
|
}
|
|
1300
|
+
for (const pullRequestNumber of attachedOpen) {
|
|
1301
|
+
if (cardsByNumber.has(pullRequestNumber)) continue;
|
|
1302
|
+
try {
|
|
1303
|
+
const state = await fetchPullRequest({
|
|
1304
|
+
installationId: repository.installationId,
|
|
1305
|
+
repository: repository.fullName,
|
|
1306
|
+
number: pullRequestNumber
|
|
1307
|
+
});
|
|
1308
|
+
summary.checked += 1;
|
|
1309
|
+
if (state?.state !== "closed") continue;
|
|
1310
|
+
await rules.ingest(reconciledClosedEvent(repository, pullRequestNumber, state));
|
|
1311
|
+
await retireReconciledSubscriptions(options.integrationStorage, repository, pullRequestNumber, state.merged);
|
|
1312
|
+
if (state.merged) summary.merged += 1;
|
|
1313
|
+
else summary.closed += 1;
|
|
1314
|
+
} catch (error) {
|
|
1315
|
+
recordFailure(repository, error, pullRequestNumber);
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
return summary;
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1322
|
+
/**
|
|
1323
|
+
* An installation can expose hundreds of repositories; only the ones actually
|
|
1324
|
+
* linked to a factory project can have cards, so sweeps scope to those up
|
|
1325
|
+
* front instead of probing each repository.
|
|
1326
|
+
*/
|
|
1327
|
+
async function linkedRepositories(options, repositories) {
|
|
1328
|
+
const configured = new Set((await options.sourceControl.projectRepositories.listConfiguredExternalKeys()).map((key) => `${key.installationExternalId}\u0000${key.repositoryExternalId}`));
|
|
1329
|
+
return repositories.filter((repository) => configured.has(`${repository.installationId}\u0000${repository.id}`));
|
|
1330
|
+
}
|
|
1331
|
+
/** A non-terminal card that holds an open pull request but no longer records it as the one it has out. */
|
|
1332
|
+
/**
|
|
1333
|
+
* Catches what the opened webhook (or its follow-up writes) missed, from the
|
|
1334
|
+
* open pull request list alone, so its GitHub cost is the listing's and does
|
|
1335
|
+
* not grow with the cards on the board:
|
|
1336
|
+
*
|
|
1337
|
+
* - an open pull request filed since the repository was linked that no card
|
|
1338
|
+
* holds is replayed as its `opened` delivery, which files it;
|
|
1339
|
+
* - an open pull request whose authoring card lost its open mark (the write
|
|
1340
|
+
* after the opening failed) is replayed the same way, which restores it.
|
|
1341
|
+
*
|
|
1342
|
+
* Both replays use one stable delivery id per pull request, so repeats in
|
|
1343
|
+
* later sweeps are absorbed by the ingress instead of filing a second card.
|
|
1344
|
+
*/
|
|
1345
|
+
function createGithubPullRequestDiscovery(options, listOpenPullRequests) {
|
|
1346
|
+
const rules = new GithubRules(options);
|
|
1347
|
+
const boards = toBoardSource(options.boards);
|
|
1348
|
+
return async (repositories) => {
|
|
1349
|
+
const summary = {
|
|
1350
|
+
repositories: 0,
|
|
1351
|
+
listed: 0,
|
|
1352
|
+
created: 0,
|
|
1353
|
+
repaired: 0,
|
|
1354
|
+
failed: 0,
|
|
1355
|
+
errors: []
|
|
1356
|
+
};
|
|
1357
|
+
const recordFailure = (repository, error, pullRequestNumber) => {
|
|
1358
|
+
summary.failed += 1;
|
|
1359
|
+
if (summary.errors.length < 5) summary.errors.push({
|
|
1360
|
+
repository: repository.fullName,
|
|
1361
|
+
...pullRequestNumber === void 0 ? {} : { pullRequestNumber },
|
|
1362
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1363
|
+
});
|
|
1364
|
+
};
|
|
1365
|
+
const scoped = await linkedRepositories(options, repositories);
|
|
1366
|
+
summary.repositories = scoped.length;
|
|
1367
|
+
for (const repository of scoped) {
|
|
1368
|
+
const carded = /* @__PURE__ */ new Set();
|
|
1369
|
+
const unmarked = /* @__PURE__ */ new Map();
|
|
1370
|
+
let linkedAt;
|
|
1371
|
+
try {
|
|
1372
|
+
const projects = await options.sourceControl.projectRepositories.listByExternalRepository({
|
|
1373
|
+
installationExternalId: String(repository.installationId),
|
|
1374
|
+
repositoryExternalId: String(repository.id)
|
|
1375
|
+
});
|
|
1376
|
+
if (projects.length === 0) continue;
|
|
1377
|
+
linkedAt = Math.min(...projects.map((project) => project.projectRepository.createdAt.getTime()));
|
|
1378
|
+
const items = [];
|
|
1379
|
+
for (const project of projects) {
|
|
1380
|
+
await rules.loadBoards(project);
|
|
1381
|
+
items.push(...await options.storage.listShared({
|
|
1382
|
+
orgId: project.orgId,
|
|
1383
|
+
factoryProjectId: project.factoryProjectId
|
|
1384
|
+
}));
|
|
1385
|
+
}
|
|
1386
|
+
const authoring = (item) => item !== void 0 && item.externalSource?.type !== "pull-request" && typeof item.metadata?.openPullRequestNumber !== "number" && !isTerminalWorkItem(boards.forProject(item), item);
|
|
1387
|
+
const byId = new Map(items.map((item) => [item.id, item]));
|
|
1388
|
+
for (const item of items) {
|
|
1389
|
+
for (const source of pullRequestSources(item)) {
|
|
1390
|
+
const number = attachedPullRequestNumber(source, repository);
|
|
1391
|
+
if (number === void 0) continue;
|
|
1392
|
+
carded.add(number);
|
|
1393
|
+
if (authoring(item) && !["closed", "merged"].includes(source.state ?? "")) unmarked.set(number, [...unmarked.get(number) ?? [], item]);
|
|
1394
|
+
}
|
|
1395
|
+
const number = reconcilablePullRequestNumber(item, repository);
|
|
1396
|
+
if (number === void 0) continue;
|
|
1397
|
+
carded.add(number);
|
|
1398
|
+
const parent = item.parentWorkItemId ? byId.get(item.parentWorkItemId) : void 0;
|
|
1399
|
+
if (parent && authoring(parent) && !["closed", "merged"].includes(item.workItem.state ?? "")) unmarked.set(number, [...unmarked.get(number) ?? [], parent]);
|
|
1400
|
+
}
|
|
1401
|
+
} catch (error) {
|
|
1402
|
+
recordFailure(repository, error);
|
|
1403
|
+
continue;
|
|
1404
|
+
}
|
|
1405
|
+
let open;
|
|
1406
|
+
try {
|
|
1407
|
+
open = await listOpenPullRequests({
|
|
1408
|
+
installationId: repository.installationId,
|
|
1409
|
+
repository: repository.fullName,
|
|
1410
|
+
createdSince: linkedAt
|
|
1411
|
+
});
|
|
1412
|
+
} catch (error) {
|
|
1413
|
+
recordFailure(repository, error);
|
|
1414
|
+
continue;
|
|
1415
|
+
}
|
|
1416
|
+
summary.listed += open.length;
|
|
1417
|
+
const restored = /* @__PURE__ */ new Set();
|
|
1418
|
+
for (const pullRequest of open) try {
|
|
1419
|
+
if (!carded.has(pullRequest.number)) {
|
|
1420
|
+
if ((await rules.ingest(reconciledPullRequestOpenedEvent(repository, pullRequest.number, pullRequest))).status === "committed") summary.created += 1;
|
|
1421
|
+
continue;
|
|
1422
|
+
}
|
|
1423
|
+
const candidate = await ownedUnmarkedCard(options, repository, pullRequest, (unmarked.get(pullRequest.number) ?? []).filter((card) => !restored.has(card.id)));
|
|
1424
|
+
if (!candidate) continue;
|
|
1425
|
+
restored.add(candidate.id);
|
|
1426
|
+
await rules.ingest(reconciledPullRequestOpenedEvent(repository, pullRequest.number, pullRequest));
|
|
1427
|
+
if ((await options.storage.get({
|
|
1428
|
+
orgId: candidate.orgId,
|
|
1429
|
+
id: candidate.id
|
|
1430
|
+
}))?.metadata?.openPullRequestNumber === pullRequest.number) summary.repaired += 1;
|
|
1431
|
+
} catch (error) {
|
|
1432
|
+
recordFailure(repository, error, pullRequest.number);
|
|
1433
|
+
}
|
|
1055
1434
|
}
|
|
1056
1435
|
return summary;
|
|
1057
1436
|
};
|
|
1058
1437
|
}
|
|
1438
|
+
/**
|
|
1439
|
+
* The unmarked card an open pull request's replayed opening would mark: the
|
|
1440
|
+
* one Factory's provenance names, which is the only link a replay resolves
|
|
1441
|
+
* back to the authoring card once the pull request has its own Review card.
|
|
1442
|
+
* Decided from storage, so a card holding someone else's pull request (or one
|
|
1443
|
+
* a replay cannot restore) costs no replay, and no permission lookup, per sweep.
|
|
1444
|
+
*/
|
|
1445
|
+
async function ownedUnmarkedCard(options, repository, pullRequest, candidates) {
|
|
1446
|
+
if (candidates.length === 0) return void 0;
|
|
1447
|
+
const provenance = await options.integrationStorage.subscriptions.listByTarget(provenanceTarget(repository.id, pullRequest.number), { status: "active" });
|
|
1448
|
+
return candidates.find((card) => provenance.some((subscription) => subscription.orgId === card.orgId && pullRequestProvenance(subscription.data, card.factoryProjectId)?.workItemId === card.id));
|
|
1449
|
+
}
|
|
1450
|
+
function attachGithubPullRequestDiscovery(github, context, listOpenPullRequests) {
|
|
1451
|
+
const options = githubRulesOptions(github, context);
|
|
1452
|
+
if (!options) return void 0;
|
|
1453
|
+
return createGithubPullRequestDiscovery(options, listOpenPullRequests);
|
|
1454
|
+
}
|
|
1059
1455
|
function githubRulesOptions(github, context) {
|
|
1060
1456
|
if (!context.runtime) return void 0;
|
|
1061
1457
|
return {
|
|
@@ -1066,7 +1462,6 @@ function githubRulesOptions(github, context) {
|
|
|
1066
1462
|
storage: context.runtime.workItems,
|
|
1067
1463
|
configVersion: context.runtime.configVersion,
|
|
1068
1464
|
boards: context.runtime.boards,
|
|
1069
|
-
intake: context.storage.intake,
|
|
1070
1465
|
...context.hooks?.onRepositoryPush ? { onRepositoryPush: context.hooks.onRepositoryPush } : {}
|
|
1071
1466
|
};
|
|
1072
1467
|
}
|
|
@@ -1081,6 +1476,6 @@ function attachGithubReconciler(github, context, fetchPullRequest) {
|
|
|
1081
1476
|
if (!options) return void 0;
|
|
1082
1477
|
return createGithubPullRequestReconciler(options, fetchPullRequest);
|
|
1083
1478
|
}
|
|
1084
|
-
export { GithubRules, RECONCILE_ERROR_SAMPLE_LIMIT, attachGithubReconciler, attachGithubRules, cardBelongsToRepository, createGithubPullRequestReconciler, githubRulesOptions, isFactoryGithubLogin, polledPullRequestEvent, reconcilableIssueNumber, reconciledClosedEvent, reconciledIssueClosedEvent, reconciledIssueOpenedEvent, reconciledIssueRelabeledEvent, sameStrings, sweepTrustLookup, trustedCollaborator };
|
|
1479
|
+
export { GithubRules, RECONCILE_ERROR_SAMPLE_LIMIT, activitySignalFor, attachGithubPullRequestDiscovery, attachGithubReconciler, attachGithubRules, attachedPullRequestSource, boardEventFor, cardBelongsToRepository, createGithubPullRequestDiscovery, createGithubPullRequestReconciler, githubItemSources, githubRulesOptions, isFactoryGithubLogin, listedPullRequestState, openPullRequestLister, polledPullRequestEvent, reconcilableIssueNumber, reconciledClosedEvent, reconciledIssueClosedEvent, reconciledIssueOpenedEvent, reconciledIssueRelabeledEvent, reconciledPullRequestOpenedEvent, sameStrings, sweepTrustLookup, trustedCollaborator };
|
|
1085
1480
|
|
|
1086
1481
|
//# sourceMappingURL=rules.js.map
|