@dxos/plugin-github 0.7.4 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/PLUGIN.mdl +784 -0
- package/dist/lib/GitHubCapabilities.mjs +10 -0
- package/dist/lib/GitHubCapabilities.mjs.map +1 -0
- package/dist/lib/GitHubEvents.mjs +15 -0
- package/dist/lib/GitHubEvents.mjs.map +1 -0
- package/dist/lib/GitHubOperation.mjs +358 -0
- package/dist/lib/GitHubOperation.mjs.map +1 -0
- package/dist/lib/GitHubPlugin.mjs +16 -0
- package/dist/lib/GitHubPlugin.mjs.map +1 -0
- package/dist/lib/Walkthrough.mjs +59 -0
- package/dist/lib/Walkthrough.mjs.map +1 -0
- package/dist/lib/capabilities.browser.mjs +54 -0
- package/dist/lib/capabilities.browser.mjs.map +1 -0
- package/dist/lib/capabilities.mjs +54 -0
- package/dist/lib/capabilities.mjs.map +1 -0
- package/dist/lib/capabilities.node.mjs +30 -0
- package/dist/lib/capabilities.node.mjs.map +1 -0
- package/dist/lib/capabilities.tauri.mjs +54 -0
- package/dist/lib/capabilities.tauri.mjs.map +1 -0
- package/dist/lib/capabilities.workerd.mjs +30 -0
- package/dist/lib/capabilities.workerd.mjs.map +1 -0
- package/dist/lib/chunk-ImportPullRequestDialog.mjs +116 -0
- package/dist/lib/chunk-ImportPullRequestDialog.mjs.map +1 -0
- package/dist/lib/chunk-PLUGIN.mjs +6 -0
- package/dist/lib/chunk-PLUGIN.mjs.map +1 -0
- package/dist/lib/chunk-PullRequestArticle.mjs +1486 -0
- package/dist/lib/chunk-PullRequestArticle.mjs.map +1 -0
- package/dist/lib/chunk-PullRequestArticle2.mjs +2 -0
- package/dist/lib/chunk-PullRequestCardMenu.mjs +123 -0
- package/dist/lib/chunk-PullRequestCardMenu.mjs.map +1 -0
- package/dist/lib/chunk-PullRequestsArticle.mjs +594 -0
- package/dist/lib/chunk-PullRequestsArticle.mjs.map +1 -0
- package/dist/lib/chunk-WalkthroughArticle.mjs +26 -0
- package/dist/lib/chunk-WalkthroughArticle.mjs.map +1 -0
- package/dist/lib/chunk-add-pull-request-comment.mjs +19 -0
- package/dist/lib/chunk-add-pull-request-comment.mjs.map +1 -0
- package/dist/lib/chunk-add-pull-request-review-comment.mjs +25 -0
- package/dist/lib/chunk-add-pull-request-review-comment.mjs.map +1 -0
- package/dist/lib/chunk-app-graph-builder.mjs +39 -0
- package/dist/lib/chunk-app-graph-builder.mjs.map +1 -0
- package/dist/lib/chunk-connector.mjs +70 -0
- package/dist/lib/chunk-connector.mjs.map +1 -0
- package/dist/lib/chunk-constants.mjs +11 -0
- package/dist/lib/chunk-constants.mjs.map +1 -0
- package/dist/lib/chunk-errors.mjs +29 -0
- package/dist/lib/chunk-errors.mjs.map +1 -0
- package/dist/lib/chunk-generate-walkthrough.mjs +86 -0
- package/dist/lib/chunk-generate-walkthrough.mjs.map +1 -0
- package/dist/lib/chunk-generate.mjs +719 -0
- package/dist/lib/chunk-generate.mjs.map +1 -0
- package/dist/lib/chunk-get-pull-request-diff.mjs +25 -0
- package/dist/lib/chunk-get-pull-request-diff.mjs.map +1 -0
- package/dist/lib/chunk-get-pull-request-status.mjs +29 -0
- package/dist/lib/chunk-get-pull-request-status.mjs.map +1 -0
- package/dist/lib/chunk-get-repositories.mjs +32 -0
- package/dist/lib/chunk-get-repositories.mjs.map +1 -0
- package/dist/lib/chunk-github-api.mjs +375 -0
- package/dist/lib/chunk-github-api.mjs.map +1 -0
- package/dist/lib/chunk-github-link.mjs +59 -0
- package/dist/lib/chunk-github-link.mjs.map +1 -0
- package/dist/lib/chunk-import-pull-request-from-snapshot.mjs +25 -0
- package/dist/lib/chunk-import-pull-request-from-snapshot.mjs.map +1 -0
- package/dist/lib/chunk-import-pull-request.mjs +96 -0
- package/dist/lib/chunk-import-pull-request.mjs.map +1 -0
- package/dist/lib/chunk-link-resolver.mjs +109 -0
- package/dist/lib/chunk-link-resolver.mjs.map +1 -0
- package/dist/lib/chunk-markdown-extension.mjs +92 -0
- package/dist/lib/chunk-markdown-extension.mjs.map +1 -0
- package/dist/lib/chunk-materialize-target.mjs +36 -0
- package/dist/lib/chunk-materialize-target.mjs.map +1 -0
- package/dist/lib/chunk-operation-handler.mjs +12 -0
- package/dist/lib/chunk-operation-handler.mjs.map +1 -0
- package/dist/lib/chunk-page-action.mjs +22 -0
- package/dist/lib/chunk-page-action.mjs.map +1 -0
- package/dist/lib/chunk-pull-request.mjs +58 -0
- package/dist/lib/chunk-pull-request.mjs.map +1 -0
- package/dist/lib/chunk-pull-request2.mjs +110 -0
- package/dist/lib/chunk-pull-request2.mjs.map +1 -0
- package/dist/lib/chunk-react-surface.mjs +233 -0
- package/dist/lib/chunk-react-surface.mjs.map +1 -0
- package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
- package/dist/lib/chunk-schema.mjs +15 -0
- package/dist/lib/chunk-schema.mjs.map +1 -0
- package/dist/lib/chunk-skill-definition.mjs +10 -0
- package/dist/lib/chunk-skill-definition.mjs.map +1 -0
- package/dist/lib/chunk-submit-pull-request-approval.mjs +56 -0
- package/dist/lib/chunk-submit-pull-request-approval.mjs.map +1 -0
- package/dist/lib/chunk-sync-pull-request.mjs +24 -0
- package/dist/lib/chunk-sync-pull-request.mjs.map +1 -0
- package/dist/lib/chunk-sync.mjs +481 -0
- package/dist/lib/chunk-sync.mjs.map +1 -0
- package/dist/lib/chunk-useOpenObject.mjs +43 -0
- package/dist/lib/chunk-useOpenObject.mjs.map +1 -0
- package/dist/lib/extensions.mjs +132 -0
- package/dist/lib/extensions.mjs.map +1 -0
- package/dist/lib/index.mjs +4 -0
- package/dist/lib/meta.mjs +47 -0
- package/dist/lib/meta.mjs.map +1 -0
- package/dist/lib/ns/Extensions.mjs +18 -0
- package/dist/lib/ns/Extensions.mjs.map +1 -0
- package/dist/lib/operations.mjs +22 -0
- package/dist/lib/operations.mjs.map +1 -0
- package/dist/lib/plugin.mjs +9 -0
- package/dist/lib/plugin.mjs.map +1 -0
- package/dist/lib/skills.mjs +44 -0
- package/dist/lib/skills.mjs.map +1 -0
- package/dist/lib/testing.mjs +189 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/lib/translations.mjs +136 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/lib/types.mjs +5 -0
- package/dist/types/dx.config.d.ts +28 -0
- package/dist/types/dx.config.d.ts.map +1 -0
- package/dist/types/src/Extensions.d.ts +2 -0
- package/dist/types/src/Extensions.d.ts.map +1 -0
- package/dist/types/src/GitHubPlugin.d.ts +37 -0
- package/dist/types/src/GitHubPlugin.d.ts.map +1 -0
- package/dist/types/src/GitHubPlugin.workerd.test.d.ts +2 -0
- package/dist/types/src/GitHubPlugin.workerd.test.d.ts.map +1 -0
- package/dist/types/src/approval.d.ts +21 -0
- package/dist/types/src/approval.d.ts.map +1 -0
- package/dist/types/src/approval.test.d.ts +2 -0
- package/dist/types/src/approval.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +9 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/connector.d.ts +17 -0
- package/dist/types/src/capabilities/connector.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/browser.d.ts +13 -0
- package/dist/types/src/capabilities/gen/browser.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/node.d.ts +13 -0
- package/dist/types/src/capabilities/gen/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/tauri.d.ts +13 -0
- package/dist/types/src/capabilities/gen/tauri.d.ts.map +1 -0
- package/dist/types/src/capabilities/gen/workerd.d.ts +13 -0
- package/dist/types/src/capabilities/gen/workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +13 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/link-resolver.d.ts +10 -0
- package/dist/types/src/capabilities/link-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown-extension.d.ts +14 -0
- package/dist/types/src/capabilities/markdown-extension.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +5 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/page-action.d.ts +5 -0
- package/dist/types/src/capabilities/page-action.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/schema.d.ts +12 -0
- package/dist/types/src/capabilities/schema.d.ts.map +1 -0
- package/dist/types/src/capabilities/skill-definition.d.ts +5 -0
- package/dist/types/src/capabilities/skill-definition.d.ts.map +1 -0
- package/dist/types/src/cards/GitHubCard.d.ts +11 -0
- package/dist/types/src/cards/GitHubCard.d.ts.map +1 -0
- package/dist/types/src/cards/GitHubCard.stories.d.ts +45 -0
- package/dist/types/src/cards/GitHubCard.stories.d.ts.map +1 -0
- package/dist/types/src/cards/PullRequestCard.d.ts +9 -0
- package/dist/types/src/cards/PullRequestCard.d.ts.map +1 -0
- package/dist/types/src/cards/index.d.ts +3 -0
- package/dist/types/src/cards/index.d.ts.map +1 -0
- package/dist/types/src/components/CommentComposer/CommentComposer.d.ts +30 -0
- package/dist/types/src/components/CommentComposer/CommentComposer.d.ts.map +1 -0
- package/dist/types/src/components/CommentComposer/index.d.ts +2 -0
- package/dist/types/src/components/CommentComposer/index.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/DiffStat.d.ts +8 -0
- package/dist/types/src/components/PullRequestFiles/DiffStat.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/FileTree.d.ts +17 -0
- package/dist/types/src/components/PullRequestFiles/FileTree.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/PullRequestFiles.d.ts +23 -0
- package/dist/types/src/components/PullRequestFiles/PullRequestFiles.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/files.d.ts +39 -0
- package/dist/types/src/components/PullRequestFiles/files.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/files.test.d.ts +2 -0
- package/dist/types/src/components/PullRequestFiles/files.test.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestFiles/index.d.ts +5 -0
- package/dist/types/src/components/PullRequestFiles/index.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/ArtifactPill.d.ts +21 -0
- package/dist/types/src/components/PullRequestOverview/ArtifactPill.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/CheckRunList.d.ts +15 -0
- package/dist/types/src/components/PullRequestOverview/CheckRunList.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/PullRequestDetails.d.ts +10 -0
- package/dist/types/src/components/PullRequestOverview/PullRequestDetails.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/PullRequestOverview.d.ts +16 -0
- package/dist/types/src/components/PullRequestOverview/PullRequestOverview.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/RelatedCards.d.ts +28 -0
- package/dist/types/src/components/PullRequestOverview/RelatedCards.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestOverview/index.d.ts +6 -0
- package/dist/types/src/components/PullRequestOverview/index.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestStatus/PullRequestStatus.d.ts +20 -0
- package/dist/types/src/components/PullRequestStatus/PullRequestStatus.d.ts.map +1 -0
- package/dist/types/src/components/PullRequestStatus/index.d.ts +2 -0
- package/dist/types/src/components/PullRequestStatus/index.d.ts.map +1 -0
- package/dist/types/src/components/WalkthroughView/WalkthroughView.d.ts +18 -0
- package/dist/types/src/components/WalkthroughView/WalkthroughView.d.ts.map +1 -0
- package/dist/types/src/components/WalkthroughView/extensions.d.ts +16 -0
- package/dist/types/src/components/WalkthroughView/extensions.d.ts.map +1 -0
- package/dist/types/src/components/WalkthroughView/index.d.ts +3 -0
- package/dist/types/src/components/WalkthroughView/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +5 -8
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +7 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/containers/ImportPullRequestDialog/ImportPullRequestDialog.d.ts +6 -0
- package/dist/types/src/containers/ImportPullRequestDialog/ImportPullRequestDialog.d.ts.map +1 -0
- package/dist/types/src/containers/ImportPullRequestDialog/index.d.ts +3 -0
- package/dist/types/src/containers/ImportPullRequestDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestArticle/PullRequestArticle.d.ts +15 -0
- package/dist/types/src/containers/PullRequestArticle/PullRequestArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestArticle/failure.d.ts +10 -0
- package/dist/types/src/containers/PullRequestArticle/failure.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestArticle/failure.test.d.ts +2 -0
- package/dist/types/src/containers/PullRequestArticle/failure.test.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestArticle/index.d.ts +2 -0
- package/dist/types/src/containers/PullRequestArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestCardMenu/PullRequestCardMenu.d.ts +14 -0
- package/dist/types/src/containers/PullRequestCardMenu/PullRequestCardMenu.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestCardMenu/index.d.ts +2 -0
- package/dist/types/src/containers/PullRequestCardMenu/index.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/PullRequestsArticle.d.ts +13 -0
- package/dist/types/src/containers/PullRequestsArticle/PullRequestsArticle.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/arrange.d.ts +44 -0
- package/dist/types/src/containers/PullRequestsArticle/arrange.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/arrange.test.d.ts +2 -0
- package/dist/types/src/containers/PullRequestsArticle/arrange.test.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/format.d.ts +3 -0
- package/dist/types/src/containers/PullRequestsArticle/format.d.ts.map +1 -0
- package/dist/types/src/containers/PullRequestsArticle/index.d.ts +2 -0
- package/dist/types/src/containers/PullRequestsArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/WalkthroughArticle/WalkthroughArticle.d.ts +13 -0
- package/dist/types/src/containers/WalkthroughArticle/WalkthroughArticle.d.ts.map +1 -0
- package/dist/types/src/containers/WalkthroughArticle/index.d.ts +2 -0
- package/dist/types/src/containers/WalkthroughArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/errors.d.ts +157 -0
- package/dist/types/src/errors.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +3 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/extensions/links.d.ts +21 -0
- package/dist/types/src/extensions/links.d.ts.map +1 -0
- package/dist/types/src/extensions/links.test.d.ts +2 -0
- package/dist/types/src/extensions/links.test.d.ts.map +1 -0
- package/dist/types/src/extensions/references.d.ts +23 -0
- package/dist/types/src/extensions/references.d.ts.map +1 -0
- package/dist/types/src/extensions/references.test.d.ts +2 -0
- package/dist/types/src/extensions/references.test.d.ts.map +1 -0
- package/dist/types/src/github-link.d.ts +29 -0
- package/dist/types/src/github-link.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -2
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useOpenObject.d.ts +9 -0
- package/dist/types/src/hooks/useOpenObject.d.ts.map +1 -0
- package/dist/types/src/hooks/usePullRequestChecks.d.ts +10 -0
- package/dist/types/src/hooks/usePullRequestChecks.d.ts.map +1 -0
- package/dist/types/src/hooks/usePullRequestDiff.d.ts +12 -0
- package/dist/types/src/hooks/usePullRequestDiff.d.ts.map +1 -0
- package/dist/types/src/hooks/usePullRequestFiles.d.ts +22 -0
- package/dist/types/src/hooks/usePullRequestFiles.d.ts.map +1 -0
- package/dist/types/src/hooks/useSyncPullRequest.d.ts +10 -0
- package/dist/types/src/hooks/useSyncPullRequest.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +34 -11
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/add-pull-request-comment.d.ts +5 -0
- package/dist/types/src/operations/add-pull-request-comment.d.ts.map +1 -0
- package/dist/types/src/operations/add-pull-request-review-comment.d.ts +5 -0
- package/dist/types/src/operations/add-pull-request-review-comment.d.ts.map +1 -0
- package/dist/types/src/operations/generate-walkthrough.d.ts +11 -0
- package/dist/types/src/operations/generate-walkthrough.d.ts.map +1 -0
- package/dist/types/src/operations/get-pull-request-diff.d.ts +5 -0
- package/dist/types/src/operations/get-pull-request-diff.d.ts.map +1 -0
- package/dist/types/src/operations/get-pull-request-status.d.ts +5 -0
- package/dist/types/src/operations/get-pull-request-status.d.ts.map +1 -0
- package/dist/types/src/operations/get-repositories.d.ts +13 -0
- package/dist/types/src/operations/get-repositories.d.ts.map +1 -0
- package/dist/types/src/operations/import-pull-request-from-snapshot.d.ts +12 -0
- package/dist/types/src/operations/import-pull-request-from-snapshot.d.ts.map +1 -0
- package/dist/types/src/operations/import-pull-request.d.ts +63 -0
- package/dist/types/src/operations/import-pull-request.d.ts.map +1 -0
- package/dist/types/src/operations/import-pull-request.test.d.ts +2 -0
- package/dist/types/src/operations/import-pull-request.test.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/materialize-target.d.ts +12 -0
- package/dist/types/src/operations/materialize-target.d.ts.map +1 -0
- package/dist/types/src/operations/pull-request.d.ts +48 -0
- package/dist/types/src/operations/pull-request.d.ts.map +1 -0
- package/dist/types/src/operations/pull-request.test.d.ts +2 -0
- package/dist/types/src/operations/pull-request.test.d.ts.map +1 -0
- package/dist/types/src/operations/submit-pull-request-approval.d.ts +5 -0
- package/dist/types/src/operations/submit-pull-request-approval.d.ts.map +1 -0
- package/dist/types/src/operations/sync-pull-request.d.ts +5 -0
- package/dist/types/src/operations/sync-pull-request.d.ts.map +1 -0
- package/dist/types/src/operations/sync.d.ts +123 -0
- package/dist/types/src/operations/sync.d.ts.map +1 -0
- package/dist/types/src/operations/sync.test.d.ts +2 -0
- package/dist/types/src/operations/sync.test.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/plugin.test.d.ts +2 -0
- package/dist/types/src/plugin.test.d.ts.map +1 -0
- package/dist/types/src/pull-request-body.d.ts +37 -0
- package/dist/types/src/pull-request-body.d.ts.map +1 -0
- package/dist/types/src/pull-request-body.test.d.ts +2 -0
- package/dist/types/src/pull-request-body.test.d.ts.map +1 -0
- package/dist/types/src/pull-request.d.ts +28 -0
- package/dist/types/src/pull-request.d.ts.map +1 -0
- package/dist/types/src/pull-request.test.d.ts +2 -0
- package/dist/types/src/pull-request.test.d.ts.map +1 -0
- package/dist/types/src/services/github-api.d.ts +332 -0
- package/dist/types/src/services/github-api.d.ts.map +1 -0
- package/dist/types/src/services/index.d.ts +2 -0
- package/dist/types/src/services/index.d.ts.map +1 -0
- package/dist/types/src/skills/GitHubSkill.d.ts +12 -0
- package/dist/types/src/skills/GitHubSkill.d.ts.map +1 -0
- package/dist/types/src/skills/index.d.ts +2 -0
- package/dist/types/src/skills/index.d.ts.map +1 -0
- package/dist/types/src/stories/Generate.stories.d.ts +27 -0
- package/dist/types/src/stories/Generate.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Links.stories.d.ts +23 -0
- package/dist/types/src/stories/Links.stories.d.ts.map +1 -0
- package/dist/types/src/stories/PullRequestArticle.stories.d.ts +359 -0
- package/dist/types/src/stories/PullRequestArticle.stories.d.ts.map +1 -0
- package/dist/types/src/stories/PullRequestFiles.stories.d.ts +365 -0
- package/dist/types/src/stories/PullRequestFiles.stories.d.ts.map +1 -0
- package/dist/types/src/stories/PullRequestOverview.stories.d.ts +367 -0
- package/dist/types/src/stories/PullRequestOverview.stories.d.ts.map +1 -0
- package/dist/types/src/stories/PullRequestsArticle.stories.d.ts +357 -0
- package/dist/types/src/stories/PullRequestsArticle.stories.d.ts.map +1 -0
- package/dist/types/src/stories/Walkthrough.stories.d.ts +380 -0
- package/dist/types/src/stories/Walkthrough.stories.d.ts.map +1 -0
- package/dist/types/src/stories/github.d.ts +23 -0
- package/dist/types/src/stories/github.d.ts.map +1 -0
- package/dist/types/src/stories/github.test.d.ts +2 -0
- package/dist/types/src/stories/github.test.d.ts.map +1 -0
- package/dist/types/src/stories/walkthrough-fixture.d.ts +8 -0
- package/dist/types/src/stories/walkthrough-fixture.d.ts.map +1 -0
- package/dist/types/src/testing/fixtures.d.ts +14 -0
- package/dist/types/src/testing/fixtures.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +4 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/plugin.d.ts +4 -0
- package/dist/types/src/testing/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/pull-request-13348.d.ts +6 -0
- package/dist/types/src/testing/pull-request-13348.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +339 -53
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/GitHubCapabilities.d.ts +13 -0
- package/dist/types/src/types/GitHubCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/GitHubEvents.d.ts +8 -0
- package/dist/types/src/types/GitHubEvents.d.ts.map +1 -0
- package/dist/types/src/types/GitHubOperation.d.ts +270 -0
- package/dist/types/src/types/GitHubOperation.d.ts.map +1 -0
- package/dist/types/src/types/PullRequestsView.d.ts +35 -0
- package/dist/types/src/types/PullRequestsView.d.ts.map +1 -0
- package/dist/types/src/types/Walkthrough.d.ts +31 -0
- package/dist/types/src/types/Walkthrough.d.ts.map +1 -0
- package/dist/types/src/types/Walkthrough.test.d.ts +2 -0
- package/dist/types/src/types/Walkthrough.test.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/walkthrough/fill.d.ts +28 -0
- package/dist/types/src/walkthrough/fill.d.ts.map +1 -0
- package/dist/types/src/walkthrough/fill.test.d.ts +2 -0
- package/dist/types/src/walkthrough/fill.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/generate.d.ts +67 -0
- package/dist/types/src/walkthrough/generate.d.ts.map +1 -0
- package/dist/types/src/walkthrough/generate.test.d.ts +2 -0
- package/dist/types/src/walkthrough/generate.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/generated.d.ts +20 -0
- package/dist/types/src/walkthrough/generated.d.ts.map +1 -0
- package/dist/types/src/walkthrough/generated.test.d.ts +2 -0
- package/dist/types/src/walkthrough/generated.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/headings.d.ts +8 -0
- package/dist/types/src/walkthrough/headings.d.ts.map +1 -0
- package/dist/types/src/walkthrough/headings.test.d.ts +2 -0
- package/dist/types/src/walkthrough/headings.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/index.d.ts +9 -0
- package/dist/types/src/walkthrough/index.d.ts.map +1 -0
- package/dist/types/src/walkthrough/patch.d.ts +48 -0
- package/dist/types/src/walkthrough/patch.d.ts.map +1 -0
- package/dist/types/src/walkthrough/plan.d.ts +55 -0
- package/dist/types/src/walkthrough/plan.d.ts.map +1 -0
- package/dist/types/src/walkthrough/plan.test.d.ts +2 -0
- package/dist/types/src/walkthrough/plan.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/prompt.d.ts +33 -0
- package/dist/types/src/walkthrough/prompt.d.ts.map +1 -0
- package/dist/types/src/walkthrough/prompt.test.d.ts +2 -0
- package/dist/types/src/walkthrough/prompt.test.d.ts.map +1 -0
- package/dist/types/src/walkthrough/score.d.ts +43 -0
- package/dist/types/src/walkthrough/score.d.ts.map +1 -0
- package/dist/types/src/walkthrough/score.test.d.ts +2 -0
- package/dist/types/src/walkthrough/score.test.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/dx.config.ts +39 -0
- package/package.json +167 -48
- package/src/Extensions.ts +7 -0
- package/src/GitHubPlugin.ts +15 -0
- package/src/GitHubPlugin.workerd.test.ts +23 -0
- package/src/approval.test.ts +40 -0
- package/src/approval.ts +39 -0
- package/src/capabilities/app-graph-builder.ts +47 -0
- package/src/capabilities/connector.ts +95 -0
- package/src/capabilities/gen/browser.ts +82 -0
- package/src/capabilities/gen/node.ts +43 -0
- package/src/capabilities/gen/tauri.ts +82 -0
- package/src/capabilities/gen/workerd.ts +43 -0
- package/src/capabilities/index.ts +71 -0
- package/src/capabilities/link-resolver.ts +137 -0
- package/src/capabilities/markdown-extension.ts +146 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/page-action.ts +32 -0
- package/src/capabilities/react-surface.ts +98 -0
- package/src/capabilities/schema.ts +16 -0
- package/src/capabilities/skill-definition.ts +14 -0
- package/src/cards/GitHubCard.stories.tsx +165 -0
- package/src/cards/GitHubCard.tsx +93 -0
- package/src/cards/PullRequestCard.tsx +23 -0
- package/src/cards/index.ts +6 -0
- package/src/components/CommentComposer/CommentComposer.tsx +109 -0
- package/src/components/CommentComposer/index.ts +5 -0
- package/src/components/PullRequestFiles/DiffStat.tsx +15 -0
- package/src/components/PullRequestFiles/FileTree.tsx +102 -0
- package/src/components/PullRequestFiles/PullRequestFiles.tsx +87 -0
- package/src/components/PullRequestFiles/files.test.ts +59 -0
- package/src/components/PullRequestFiles/files.ts +115 -0
- package/src/components/PullRequestFiles/index.ts +8 -0
- package/src/components/PullRequestOverview/ArtifactPill.tsx +82 -0
- package/src/components/PullRequestOverview/CheckRunList.tsx +120 -0
- package/src/components/PullRequestOverview/PullRequestDetails.tsx +15 -0
- package/src/components/PullRequestOverview/PullRequestOverview.tsx +110 -0
- package/src/components/PullRequestOverview/RelatedCards.tsx +147 -0
- package/src/components/PullRequestOverview/index.ts +9 -0
- package/src/components/PullRequestStatus/PullRequestStatus.tsx +81 -0
- package/src/components/PullRequestStatus/index.ts +5 -0
- package/src/components/WalkthroughView/WalkthroughView.tsx +62 -0
- package/src/components/WalkthroughView/extensions.ts +53 -0
- package/src/components/WalkthroughView/index.ts +6 -0
- package/src/components/index.ts +6 -9
- package/src/constants.ts +12 -0
- package/src/containers/ImportPullRequestDialog/ImportPullRequestDialog.tsx +160 -0
- package/src/containers/ImportPullRequestDialog/index.ts +7 -0
- package/src/containers/PullRequestArticle/PullRequestArticle.tsx +573 -0
- package/src/containers/PullRequestArticle/failure.test.ts +42 -0
- package/src/containers/PullRequestArticle/failure.ts +16 -0
- package/src/containers/PullRequestArticle/index.ts +5 -0
- package/src/containers/PullRequestCardMenu/PullRequestCardMenu.tsx +134 -0
- package/src/containers/PullRequestCardMenu/index.ts +5 -0
- package/src/containers/PullRequestsArticle/PullRequestsArticle.tsx +361 -0
- package/src/containers/PullRequestsArticle/arrange.test.ts +122 -0
- package/src/containers/PullRequestsArticle/arrange.ts +245 -0
- package/src/containers/PullRequestsArticle/format.ts +31 -0
- package/src/containers/PullRequestsArticle/index.ts +5 -0
- package/src/containers/WalkthroughArticle/WalkthroughArticle.tsx +31 -0
- package/src/containers/WalkthroughArticle/index.ts +5 -0
- package/src/containers/index.ts +11 -0
- package/src/errors.ts +61 -0
- package/src/extensions/index.ts +6 -0
- package/src/extensions/links.test.ts +133 -0
- package/src/extensions/links.ts +91 -0
- package/src/extensions/references.test.ts +83 -0
- package/src/extensions/references.ts +100 -0
- package/src/github-link.ts +70 -0
- package/src/hooks/index.ts +6 -3
- package/src/hooks/useOpenObject.ts +48 -0
- package/src/hooks/usePullRequestChecks.ts +81 -0
- package/src/hooks/usePullRequestDiff.ts +57 -0
- package/src/hooks/usePullRequestFiles.ts +98 -0
- package/src/hooks/useSyncPullRequest.ts +51 -0
- package/src/index.ts +4 -6
- package/src/meta.ts +8 -13
- package/src/operations/add-pull-request-comment.ts +31 -0
- package/src/operations/add-pull-request-review-comment.ts +32 -0
- package/src/operations/generate-walkthrough.ts +124 -0
- package/src/operations/get-pull-request-diff.ts +37 -0
- package/src/operations/get-pull-request-status.ts +44 -0
- package/src/operations/get-repositories.ts +53 -0
- package/src/operations/import-pull-request-from-snapshot.ts +48 -0
- package/src/operations/import-pull-request.test.ts +151 -0
- package/src/operations/import-pull-request.ts +141 -0
- package/src/operations/index.ts +29 -0
- package/src/operations/materialize-target.ts +60 -0
- package/src/operations/pull-request.test.ts +120 -0
- package/src/operations/pull-request.ts +141 -0
- package/src/operations/submit-pull-request-approval.ts +41 -0
- package/src/operations/sync-pull-request.ts +37 -0
- package/src/operations/sync.test.ts +453 -0
- package/src/operations/sync.ts +807 -0
- package/src/plugin.test.ts +40 -0
- package/src/plugin.ts +37 -0
- package/src/pull-request-body.test.ts +61 -0
- package/src/pull-request-body.ts +144 -0
- package/src/pull-request.test.ts +67 -0
- package/src/pull-request.ts +80 -0
- package/src/services/github-api.ts +735 -0
- package/src/services/index.ts +5 -0
- package/src/skills/GitHubSkill.ts +46 -0
- package/src/skills/index.ts +5 -0
- package/src/stories/Generate.stories.tsx +152 -0
- package/src/stories/Links.stories.tsx +153 -0
- package/src/stories/PullRequestArticle.stories.tsx +107 -0
- package/src/stories/PullRequestFiles.stories.tsx +69 -0
- package/src/stories/PullRequestOverview.stories.tsx +113 -0
- package/src/stories/PullRequestsArticle.stories.tsx +170 -0
- package/src/stories/Walkthrough.stories.tsx +110 -0
- package/src/stories/github.test.ts +65 -0
- package/src/stories/github.ts +70 -0
- package/src/stories/walkthrough-fixture.ts +115 -0
- package/src/testing/fixtures.ts +99 -0
- package/src/testing/index.ts +7 -0
- package/src/testing/plugin.ts +25 -0
- package/src/testing/pull-request-13348.ts +104 -0
- package/src/testing/pull-request-13363.patch +2981 -0
- package/src/translations.ts +135 -63
- package/src/types/GitHubCapabilities.ts +27 -0
- package/src/types/GitHubEvents.ts +16 -0
- package/src/types/GitHubOperation.ts +371 -0
- package/src/types/PullRequestsView.ts +45 -0
- package/src/types/Walkthrough.test.ts +75 -0
- package/src/types/Walkthrough.ts +66 -0
- package/src/types/index.ts +8 -0
- package/src/vite-env.d.ts +15 -0
- package/src/walkthrough/fill.test.ts +337 -0
- package/src/walkthrough/fill.ts +246 -0
- package/src/walkthrough/generate.test.ts +219 -0
- package/src/walkthrough/generate.ts +248 -0
- package/src/walkthrough/generated.test.ts +70 -0
- package/src/walkthrough/generated.ts +70 -0
- package/src/walkthrough/headings.test.ts +40 -0
- package/src/walkthrough/headings.ts +39 -0
- package/src/walkthrough/index.ts +12 -0
- package/src/walkthrough/patch.ts +154 -0
- package/src/walkthrough/plan.test.ts +178 -0
- package/src/walkthrough/plan.ts +251 -0
- package/src/walkthrough/prompt.test.ts +100 -0
- package/src/walkthrough/prompt.ts +147 -0
- package/src/walkthrough/score.test.ts +272 -0
- package/src/walkthrough/score.ts +430 -0
- package/README.md +0 -15
- package/dist/lib/browser/chunk-S4MPSBA5.mjs +0 -21
- package/dist/lib/browser/chunk-S4MPSBA5.mjs.map +0 -7
- package/dist/lib/browser/index.css +0 -7
- package/dist/lib/browser/index.css.map +0 -7
- package/dist/lib/browser/index.mjs +0 -1535
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/meta.mjs +0 -11
- package/dist/lib/browser/meta.mjs.map +0 -7
- package/dist/types/src/GithubPlugin.d.ts +0 -4
- package/dist/types/src/GithubPlugin.d.ts.map +0 -1
- package/dist/types/src/components/EmbeddedMain/EmbeddedMain.d.ts +0 -4
- package/dist/types/src/components/EmbeddedMain/EmbeddedMain.d.ts.map +0 -1
- package/dist/types/src/components/EmbeddedMain/GfmPreview.d.ts +0 -9
- package/dist/types/src/components/EmbeddedMain/GfmPreview.d.ts.map +0 -1
- package/dist/types/src/components/EmbeddedMain/index.d.ts +0 -2
- package/dist/types/src/components/EmbeddedMain/index.d.ts.map +0 -1
- package/dist/types/src/components/ExportDialog.d.ts +0 -8
- package/dist/types/src/components/ExportDialog.d.ts.map +0 -1
- package/dist/types/src/components/GithubApiProviders/GitHubSettings.d.ts +0 -3
- package/dist/types/src/components/GithubApiProviders/GitHubSettings.d.ts.map +0 -1
- package/dist/types/src/components/GithubApiProviders/OctokitProvider.d.ts +0 -15
- package/dist/types/src/components/GithubApiProviders/OctokitProvider.d.ts.map +0 -1
- package/dist/types/src/components/GithubApiProviders/index.d.ts +0 -3
- package/dist/types/src/components/GithubApiProviders/index.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/DocumentTreeItem.d.ts +0 -6
- package/dist/types/src/components/GithubEchoResolverProviders/DocumentTreeItem.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverContext.d.ts +0 -7
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverContext.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverDialog.d.ts +0 -6
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverDialog.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverProps.d.ts +0 -16
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverProps.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverTree.d.ts +0 -3
- package/dist/types/src/components/GithubEchoResolverProviders/ResolverTree.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/SpacePickerTreeItem.d.ts +0 -11
- package/dist/types/src/components/GithubEchoResolverProviders/SpacePickerTreeItem.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/index.d.ts +0 -3
- package/dist/types/src/components/GithubEchoResolverProviders/index.d.ts.map +0 -1
- package/dist/types/src/components/GithubEchoResolverProviders/spaceResolvers.d.ts +0 -6
- package/dist/types/src/components/GithubEchoResolverProviders/spaceResolvers.d.ts.map +0 -1
- package/dist/types/src/components/ImportDialog.d.ts +0 -7
- package/dist/types/src/components/ImportDialog.d.ts.map +0 -1
- package/dist/types/src/components/Issue.d.ts +0 -5
- package/dist/types/src/components/Issue.d.ts.map +0 -1
- package/dist/types/src/components/Loading/Loading.d.ts +0 -15
- package/dist/types/src/components/Loading/Loading.d.ts.map +0 -1
- package/dist/types/src/components/Loading/Loading.stories.d.ts +0 -40
- package/dist/types/src/components/Loading/Loading.stories.d.ts.map +0 -1
- package/dist/types/src/components/Loading/index.d.ts +0 -2
- package/dist/types/src/components/Loading/index.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownActions.d.ts +0 -7
- package/dist/types/src/components/MarkdownActions.d.ts.map +0 -1
- package/dist/types/src/components/UrlDialog.d.ts +0 -6
- package/dist/types/src/components/UrlDialog.d.ts.map +0 -1
- package/dist/types/src/hooks/useDocGhId.d.ts +0 -6
- package/dist/types/src/hooks/useDocGhId.d.ts.map +0 -1
- package/dist/types/src/hooks/useGhIdFromUrl.d.ts +0 -2
- package/dist/types/src/hooks/useGhIdFromUrl.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -30
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/GithubPlugin.tsx +0 -127
- package/src/components/EmbeddedMain/EmbeddedMain.tsx +0 -294
- package/src/components/EmbeddedMain/GfmPreview.tsx +0 -110
- package/src/components/EmbeddedMain/embedded.css +0 -3
- package/src/components/EmbeddedMain/index.ts +0 -5
- package/src/components/ExportDialog.tsx +0 -157
- package/src/components/GithubApiProviders/GitHubSettings.tsx +0 -72
- package/src/components/GithubApiProviders/OctokitProvider.tsx +0 -60
- package/src/components/GithubApiProviders/index.ts +0 -6
- package/src/components/GithubEchoResolverProviders/DocumentTreeItem.tsx +0 -26
- package/src/components/GithubEchoResolverProviders/ResolverContext.tsx +0 -137
- package/src/components/GithubEchoResolverProviders/ResolverDialog.tsx +0 -34
- package/src/components/GithubEchoResolverProviders/ResolverProps.ts +0 -23
- package/src/components/GithubEchoResolverProviders/ResolverTree.tsx +0 -86
- package/src/components/GithubEchoResolverProviders/SpacePickerTreeItem.tsx +0 -105
- package/src/components/GithubEchoResolverProviders/index.ts +0 -6
- package/src/components/GithubEchoResolverProviders/spaceResolvers.ts +0 -86
- package/src/components/ImportDialog.tsx +0 -72
- package/src/components/Issue.tsx +0 -62
- package/src/components/Loading/Loading.stories.tsx +0 -32
- package/src/components/Loading/Loading.tsx +0 -70
- package/src/components/Loading/index.ts +0 -5
- package/src/components/MarkdownActions.tsx +0 -136
- package/src/components/UrlDialog.tsx +0 -52
- package/src/hooks/useDocGhId.ts +0 -38
- package/src/hooks/useGhIdFromUrl.ts +0 -26
- package/src/types.ts +0 -51
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { r as parsePullRequestReference } from "./chunk-github-link.mjs";
|
|
2
|
+
import { l as fetchPullRequest, t as GitHubCredentials, y as responseStatus } from "./chunk-github-api.mjs";
|
|
3
|
+
import { n as toPullRequestProps } from "./chunk-pull-request.mjs";
|
|
4
|
+
import { i as GitHubRepoInaccessibleError, n as GitHubPullRequestReferenceError } from "./chunk-errors.mjs";
|
|
5
|
+
import { n as githubToken } from "./chunk-pull-request2.mjs";
|
|
6
|
+
import { GitHubOperation } from "#types";
|
|
7
|
+
import * as Operation from "@dxos/compute/Operation";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import { PullRequest } from "@dxos/types";
|
|
10
|
+
import { Database, Filter, Ref } from "@dxos/echo";
|
|
11
|
+
import * as Layer from "effect/Layer";
|
|
12
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
13
|
+
import * as SpaceOperation from "@dxos/plugin-space/SpaceOperation";
|
|
14
|
+
//#region src/operations/import-pull-request.ts
|
|
15
|
+
/**
|
|
16
|
+
* Statuses that may report the token's reach rather than the repository's absence, and so are worth
|
|
17
|
+
* a second, anonymous attempt.
|
|
18
|
+
*
|
|
19
|
+
* 404 is the load-bearing one. GitHub answers 404 rather than 403 wherever a credential lacks access,
|
|
20
|
+
* so as not to confirm what it cannot show, and a GitHub App user-to-server token — what this
|
|
21
|
+
* connector holds — reaches only the repositories the App is installed on. A public repository the
|
|
22
|
+
* App was never installed on therefore reads as absent. (A fine-grained PAT would not behave this
|
|
23
|
+
* way: those carry read access to every public repository regardless of their selection.)
|
|
24
|
+
*
|
|
25
|
+
* Whatever produced it, the rule is the same: a status that a credential could have caused says
|
|
26
|
+
* nothing about what an anonymous reader can see, and only the anonymous request settles it.
|
|
27
|
+
*/
|
|
28
|
+
var MAY_REFLECT_TOKEN_SCOPE = /* @__PURE__ */ new Set([
|
|
29
|
+
401,
|
|
30
|
+
403,
|
|
31
|
+
404
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* The pull request as the space's GitHub connection, falling back to an anonymous read whenever the
|
|
35
|
+
* stored token is what stood in the way.
|
|
36
|
+
*
|
|
37
|
+
* A public pull request must never fail because of a credential. Three separate conditions make one
|
|
38
|
+
* look unreachable — a revoked token (401), a suspended or SSO-blocked one (403), and a repository
|
|
39
|
+
* outside the App installation the token belongs to (404) — and the anonymous retry, which is the
|
|
40
|
+
* same request a space with no connection would make, resolves all three. The cost is one extra
|
|
41
|
+
* request on a pull request that genuinely does not exist.
|
|
42
|
+
*
|
|
43
|
+
* `fetch` is injected so the fallback can be exercised without an HTTP client.
|
|
44
|
+
*/
|
|
45
|
+
var fetchPullRequestWithFallback = ({ owner, repo, number }, token, fetch = fetchPullRequest) => Effect.suspend(() => {
|
|
46
|
+
const fetchAs = (token) => fetch(owner, repo, number).pipe(Effect.provide(Layer.succeed(GitHubCredentials, { token })));
|
|
47
|
+
let tokenStatus;
|
|
48
|
+
return fetchAs(token).pipe(Effect.catchIf((error) => {
|
|
49
|
+
const status = responseStatus(error);
|
|
50
|
+
return token !== "" && status !== void 0 && MAY_REFLECT_TOKEN_SCOPE.has(status);
|
|
51
|
+
}, (error) => {
|
|
52
|
+
tokenStatus = responseStatus(error);
|
|
53
|
+
return fetchAs("");
|
|
54
|
+
}), Effect.catchIf((error) => {
|
|
55
|
+
const status = responseStatus(error);
|
|
56
|
+
return status !== void 0 && MAY_REFLECT_TOKEN_SCOPE.has(status);
|
|
57
|
+
}, (error) => Effect.die(new GitHubRepoInaccessibleError({ context: {
|
|
58
|
+
owner,
|
|
59
|
+
repo,
|
|
60
|
+
number,
|
|
61
|
+
status: responseStatus(error),
|
|
62
|
+
connected: token !== "",
|
|
63
|
+
tokenStatus
|
|
64
|
+
} }))), Effect.orDie);
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Import a pull request the user named, as the space's GitHub connection or anonymously.
|
|
68
|
+
*
|
|
69
|
+
* The object is filed through `SpaceOperation.AddObject` rather than added directly: an imported
|
|
70
|
+
* pull request is something the user went looking for, so it belongs where they can find it again.
|
|
71
|
+
*/
|
|
72
|
+
var handler = GitHubOperation.ImportPullRequest.pipe(Operation.withHandler(Effect.fn(function* ({ reference }) {
|
|
73
|
+
const parsed = parsePullRequestReference(reference);
|
|
74
|
+
if (!parsed) return yield* Effect.die(new GitHubPullRequestReferenceError({ context: { reference } }));
|
|
75
|
+
const { owner, repo, number } = parsed;
|
|
76
|
+
const [existing] = yield* Database.query(Filter.type(PullRequest.PullRequest, {
|
|
77
|
+
owner,
|
|
78
|
+
repo,
|
|
79
|
+
number
|
|
80
|
+
})).run.pipe(Effect.orDie);
|
|
81
|
+
if (existing) return {
|
|
82
|
+
pullRequest: Ref.make(existing),
|
|
83
|
+
imported: false
|
|
84
|
+
};
|
|
85
|
+
const pull = yield* fetchPullRequestWithFallback(parsed, yield* githubToken());
|
|
86
|
+
const { object } = yield* Operation.invoke(SpaceOperation.AddObject, { object: PullRequest.make(toPullRequestProps(parsed, pull)) });
|
|
87
|
+
if (!PullRequest.instanceOf(object)) return yield* Effect.die(new GitHubPullRequestReferenceError({ context: { reference } }));
|
|
88
|
+
return {
|
|
89
|
+
pullRequest: Ref.make(object),
|
|
90
|
+
imported: true
|
|
91
|
+
};
|
|
92
|
+
}, Effect.provide(FetchHttpClient.layer))));
|
|
93
|
+
//#endregion
|
|
94
|
+
export { handler as default, fetchPullRequestWithFallback };
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=chunk-import-pull-request.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-import-pull-request.mjs","names":[],"sources":["../../src/operations/import-pull-request.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as FetchHttpClient from 'effect/http/FetchHttpClient';\nimport * as Layer from 'effect/Layer';\n\nimport * as Operation from '@dxos/compute/Operation';\nimport { Database, Filter, Ref } from '@dxos/echo';\nimport * as SpaceOperation from '@dxos/plugin-space/SpaceOperation';\nimport { PullRequest } from '@dxos/types';\n\nimport { GitHubOperation } from '#types';\n\nimport { GitHubPullRequestReferenceError, GitHubRepoInaccessibleError } from '../errors.ts';\nimport { type PullRequestReference, parsePullRequestReference } from '../github-link.ts';\nimport { toPullRequestProps } from '../pull-request.ts';\nimport { GitHubApi } from '../services/index.ts';\nimport { githubToken } from './pull-request.ts';\n\n/**\n * Statuses that may report the token's reach rather than the repository's absence, and so are worth\n * a second, anonymous attempt.\n *\n * 404 is the load-bearing one. GitHub answers 404 rather than 403 wherever a credential lacks access,\n * so as not to confirm what it cannot show, and a GitHub App user-to-server token — what this\n * connector holds — reaches only the repositories the App is installed on. A public repository the\n * App was never installed on therefore reads as absent. (A fine-grained PAT would not behave this\n * way: those carry read access to every public repository regardless of their selection.)\n *\n * Whatever produced it, the rule is the same: a status that a credential could have caused says\n * nothing about what an anonymous reader can see, and only the anonymous request settles it.\n */\nconst MAY_REFLECT_TOKEN_SCOPE = new Set([401, 403, 404]);\n\n/**\n * The pull request as the space's GitHub connection, falling back to an anonymous read whenever the\n * stored token is what stood in the way.\n *\n * A public pull request must never fail because of a credential. Three separate conditions make one\n * look unreachable — a revoked token (401), a suspended or SSO-blocked one (403), and a repository\n * outside the App installation the token belongs to (404) — and the anonymous retry, which is the\n * same request a space with no connection would make, resolves all three. The cost is one extra\n * request on a pull request that genuinely does not exist.\n *\n * `fetch` is injected so the fallback can be exercised without an HTTP client.\n */\nexport const fetchPullRequestWithFallback = (\n { owner, repo, number }: PullRequestReference,\n token: string,\n fetch: (\n owner: string,\n repo: string,\n number: number,\n ) => GitHubApi.GitHubEffect<GitHubApi.GitHubPull> = GitHubApi.fetchPullRequest,\n) =>\n // Suspended so each run starts with its own `tokenStatus`, which the fallback sets as it runs.\n Effect.suspend(() => {\n const fetchAs = (token: string) =>\n fetch(owner, repo, number).pipe(Effect.provide(Layer.succeed(GitHubApi.GitHubCredentials, { token })));\n\n // What the authenticated attempt answered, kept so a rejected credential (401) can be told from a\n // repository the credential simply does not reach (403/404) once the retry has also failed.\n let tokenStatus: number | undefined;\n\n return fetchAs(token).pipe(\n Effect.catchIf(\n (error) => {\n const status = GitHubApi.responseStatus(error);\n return token !== '' && status !== undefined && MAY_REFLECT_TOKEN_SCOPE.has(status);\n },\n (error) => {\n tokenStatus = GitHubApi.responseStatus(error);\n return fetchAs('');\n },\n ),\n // Out of reach anonymously too (GitHub answers 404 for a private repository seen without\n // credentials): a typed failure lets the dialog name the connection rather than the reference.\n Effect.catchIf(\n (error) => {\n const status = GitHubApi.responseStatus(error);\n return status !== undefined && MAY_REFLECT_TOKEN_SCOPE.has(status);\n },\n (error) =>\n Effect.die(\n new GitHubRepoInaccessibleError({\n context: {\n owner,\n repo,\n number,\n status: GitHubApi.responseStatus(error),\n connected: token !== '',\n tokenStatus,\n },\n }),\n ),\n ),\n Effect.orDie,\n );\n });\n\n/**\n * Import a pull request the user named, as the space's GitHub connection or anonymously.\n *\n * The object is filed through `SpaceOperation.AddObject` rather than added directly: an imported\n * pull request is something the user went looking for, so it belongs where they can find it again.\n */\nconst handler: Operation.WithHandler<typeof GitHubOperation.ImportPullRequest> = GitHubOperation.ImportPullRequest.pipe(\n Operation.withHandler(\n Effect.fn(function* ({ reference }) {\n const parsed = parsePullRequestReference(reference);\n if (!parsed) {\n return yield* Effect.die(new GitHubPullRequestReferenceError({ context: { reference } }));\n }\n\n const { owner, repo, number } = parsed;\n const [existing] = yield* Database.query(Filter.type(PullRequest.PullRequest, { owner, repo, number })).run.pipe(\n Effect.orDie,\n );\n if (existing) {\n return { pullRequest: Ref.make(existing), imported: false };\n }\n\n const pull = yield* fetchPullRequestWithFallback(parsed, yield* githubToken());\n\n const { object } = yield* Operation.invoke(SpaceOperation.AddObject, {\n object: PullRequest.make(toPullRequestProps(parsed, pull)),\n });\n // `AddObject` answers with what it filed, typed as any object; the narrowing is what makes the\n // returned ref a pull request's rather than a cast.\n if (!PullRequest.instanceOf(object)) {\n return yield* Effect.die(new GitHubPullRequestReferenceError({ context: { reference } }));\n }\n\n return { pullRequest: Ref.make(object), imported: true };\n }, Effect.provide(FetchHttpClient.layer)),\n ),\n);\n\nexport default handler;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,IAAM,0CAA0B,IAAI,IAAI;CAAC;CAAK;CAAK;AAAG,CAAC;;;;;;;;;;;;;AAcvD,IAAa,gCACX,EAAE,OAAO,MAAM,UACf,OACA,QAIoD,qBAGpD,OAAO,cAAc;CACnB,MAAM,WAAW,UACf,MAAM,OAAO,MAAM,MAAM,CAAC,CAAC,KAAK,OAAO,QAAQ,MAAM,QAAQ,mBAA6B,EAAE,MAAM,CAAC,CAAC,CAAC;CAIvG,IAAI;CAEJ,OAAO,QAAQ,KAAK,CAAC,CAAC,KACpB,OAAO,SACJ,UAAU;EACT,MAAM,SAAS,eAAyB,KAAK;EAC7C,OAAO,UAAU,MAAM,WAAW,KAAA,KAAa,wBAAwB,IAAI,MAAM;CACnF,IACC,UAAU;EACT,cAAc,eAAyB,KAAK;EAC5C,OAAO,QAAQ,EAAE;CACnB,CACF,GAGA,OAAO,SACJ,UAAU;EACT,MAAM,SAAS,eAAyB,KAAK;EAC7C,OAAO,WAAW,KAAA,KAAa,wBAAwB,IAAI,MAAM;CACnE,IACC,UACC,OAAO,IACL,IAAI,4BAA4B,EAC9B,SAAS;EACP;EACA;EACA;EACA,QAAQ,eAAyB,KAAK;EACtC,WAAW,UAAU;EACrB;CACF,EACF,CAAC,CACH,CACJ,GACA,OAAO,KACT;AACF,CAAC;;;;;;;AAQH,IAAM,UAA2E,gBAAgB,kBAAkB,KACjH,UAAU,YACR,OAAO,GAAG,WAAW,EAAE,aAAa;CAClC,MAAM,SAAS,0BAA0B,SAAS;CAClD,IAAI,CAAC,QACH,OAAO,OAAO,OAAO,IAAI,IAAI,gCAAgC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;CAG1F,MAAM,EAAE,OAAO,MAAM,WAAW;CAChC,MAAM,CAAC,YAAY,OAAO,SAAS,MAAM,OAAO,KAAK,YAAY,aAAa;EAAE;EAAO;EAAM;CAAO,CAAC,CAAC,CAAC,CAAC,IAAI,KAC1G,OAAO,KACT;CACA,IAAI,UACF,OAAO;EAAE,aAAa,IAAI,KAAK,QAAQ;EAAG,UAAU;CAAM;CAG5D,MAAM,OAAO,OAAO,6BAA6B,QAAQ,OAAO,YAAY,CAAC;CAE7E,MAAM,EAAE,WAAW,OAAO,UAAU,OAAO,eAAe,WAAW,EACnE,QAAQ,YAAY,KAAK,mBAAmB,QAAQ,IAAI,CAAC,EAC3D,CAAC;CAGD,IAAI,CAAC,YAAY,WAAW,MAAM,GAChC,OAAO,OAAO,OAAO,IAAI,IAAI,gCAAgC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;CAG1F,OAAO;EAAE,aAAa,IAAI,KAAK,MAAM;EAAG,UAAU;CAAK;AACzD,GAAG,OAAO,QAAQ,gBAAgB,KAAK,CAAC,CAC1C,CACF"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { n as parseGitHubLink } from "./chunk-github-link.mjs";
|
|
2
|
+
import { githubLinkIcon } from "./extensions.mjs";
|
|
3
|
+
import "./chunk-constants.mjs";
|
|
4
|
+
import { d as fetchRepo, l as fetchPullRequest, o as fetchIssue, t as GitHubCredentials } from "./chunk-github-api.mjs";
|
|
5
|
+
import { n as toPullRequestProps } from "./chunk-pull-request.mjs";
|
|
6
|
+
import * as Capability from "@dxos/app-framework/Capability";
|
|
7
|
+
import * as PreviewCapabilities from "@dxos/plugin-preview/PreviewCapabilities";
|
|
8
|
+
import { GitHubCapabilities } from "#types";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
10
|
+
import { Issue, PullRequest, Repo } from "@dxos/types";
|
|
11
|
+
import { Database, Filter } from "@dxos/echo";
|
|
12
|
+
import * as Layer from "effect/Layer";
|
|
13
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
14
|
+
import { Connection } from "@dxos/link";
|
|
15
|
+
import { log } from "@dxos/log";
|
|
16
|
+
//#region src/capabilities/link-resolver.ts
|
|
17
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-github/src/capabilities/link-resolver.ts";
|
|
18
|
+
/**
|
|
19
|
+
* Resolves a GitHub repository, pull-request or issue URL to an in-memory `Repo`, `PullRequest` or
|
|
20
|
+
* `Issue` for the preview popover. The object comes from the contributed `LinkSource` when a host provides one and
|
|
21
|
+
* from the GitHub API otherwise; either way it is built, not stored — a preview is not a sync.
|
|
22
|
+
*/
|
|
23
|
+
var link_resolver_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
24
|
+
const capabilities = yield* Capability.Service;
|
|
25
|
+
return Capability.contribute(PreviewCapabilities.LinkResolver, [{
|
|
26
|
+
match: (url) => parseGitHubLink(url) !== void 0,
|
|
27
|
+
label: (url) => {
|
|
28
|
+
const link = parseGitHubLink(url);
|
|
29
|
+
return link && (link.number !== void 0 ? `#${link.number}` : `${link.owner}/${link.repo}`);
|
|
30
|
+
},
|
|
31
|
+
icon: githubLinkIcon,
|
|
32
|
+
resolve: ({ eid }, context) => Effect.gen(function* () {
|
|
33
|
+
const link = parseGitHubLink(eid);
|
|
34
|
+
if (!link) return;
|
|
35
|
+
const [source = fetchFromGitHub] = capabilities.getAll(GitHubCapabilities.LinkSource);
|
|
36
|
+
const object = yield* source(link, context);
|
|
37
|
+
return object && {
|
|
38
|
+
label: Repo.instanceOf(object) ? Repo.fullName(object) : Issue.reference(object),
|
|
39
|
+
object
|
|
40
|
+
};
|
|
41
|
+
})
|
|
42
|
+
}]);
|
|
43
|
+
}));
|
|
44
|
+
/**
|
|
45
|
+
* The default source: each of the space's GitHub connection tokens in turn — a space can hold
|
|
46
|
+
* several, and only some may reach a private repository — then anonymous, which reaches a public one.
|
|
47
|
+
*/
|
|
48
|
+
var fetchFromGitHub = (link, { db }) => Effect.gen(function* () {
|
|
49
|
+
const tokens = db ? yield* connectionTokens(db) : [];
|
|
50
|
+
for (const token of [...tokens, ""]) {
|
|
51
|
+
const object = yield* fetchLink(link).pipe(Effect.provide(Layer.succeed(GitHubCredentials, { token })), Effect.tapError((error) => Effect.sync(() => log.warn("github link preview failed", {
|
|
52
|
+
url: link.url,
|
|
53
|
+
error
|
|
54
|
+
}, {
|
|
55
|
+
"~LogMeta": "~LogMeta",
|
|
56
|
+
F: __dxlog_file,
|
|
57
|
+
L: 67,
|
|
58
|
+
S: this
|
|
59
|
+
}))), Effect.catch(() => Effect.succeed(void 0)));
|
|
60
|
+
if (object) return object;
|
|
61
|
+
}
|
|
62
|
+
}).pipe(Effect.provide(FetchHttpClient.layer), Effect.catch(() => Effect.succeed(void 0)));
|
|
63
|
+
/** The tokens of the space's GitHub connections, in query order. */
|
|
64
|
+
var connectionTokens = (db) => Effect.gen(function* () {
|
|
65
|
+
const connections = yield* Database.query(Filter.type(Connection.Connection)).run;
|
|
66
|
+
const tokens = [];
|
|
67
|
+
for (const connection of connections) {
|
|
68
|
+
if (connection.connectorId !== "github") continue;
|
|
69
|
+
const accessToken = yield* Database.load(connection.accessToken);
|
|
70
|
+
tokens.push(accessToken.token);
|
|
71
|
+
}
|
|
72
|
+
return tokens;
|
|
73
|
+
}).pipe(Effect.provide(Database.layer(db)));
|
|
74
|
+
var fetchLink = (link) => Effect.gen(function* () {
|
|
75
|
+
const { owner, repo, number } = link;
|
|
76
|
+
if (link.kind === "repo" || number === void 0) return toRepo(link, yield* fetchRepo(owner, repo));
|
|
77
|
+
if (link.kind === "pull") return toPullRequest(link, yield* fetchPullRequest(owner, repo, number));
|
|
78
|
+
const issue = yield* fetchIssue(owner, repo, number);
|
|
79
|
+
if (issue.pull_request) return toPullRequest(link, yield* fetchPullRequest(owner, repo, number));
|
|
80
|
+
return toIssue(link, issue);
|
|
81
|
+
});
|
|
82
|
+
var toRepo = ({ owner, url }, repo) => Repo.make({
|
|
83
|
+
owner,
|
|
84
|
+
name: repo.name,
|
|
85
|
+
url: repo.html_url ?? url,
|
|
86
|
+
description: repo.description ?? void 0,
|
|
87
|
+
defaultBranch: repo.default_branch ?? void 0
|
|
88
|
+
});
|
|
89
|
+
var toIssue = ({ owner, repo, number = 0, url }, issue) => Issue.make({
|
|
90
|
+
owner,
|
|
91
|
+
repo,
|
|
92
|
+
number,
|
|
93
|
+
title: issue.title,
|
|
94
|
+
url: issue.html_url ?? url,
|
|
95
|
+
state: issue.state === "closed" ? "closed" : "open",
|
|
96
|
+
author: issue.user?.login,
|
|
97
|
+
description: issue.body ?? void 0,
|
|
98
|
+
labels: issue.labels?.map((label) => label.name)
|
|
99
|
+
});
|
|
100
|
+
var toPullRequest = ({ owner, repo, number = 0, url }, pull) => PullRequest.make(toPullRequestProps({
|
|
101
|
+
owner,
|
|
102
|
+
repo,
|
|
103
|
+
number,
|
|
104
|
+
url
|
|
105
|
+
}, pull));
|
|
106
|
+
//#endregion
|
|
107
|
+
export { link_resolver_default as default };
|
|
108
|
+
|
|
109
|
+
//# sourceMappingURL=chunk-link-resolver.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-link-resolver.mjs","names":[],"sources":["../../src/capabilities/link-resolver.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as FetchHttpClient from 'effect/http/FetchHttpClient';\nimport * as Layer from 'effect/Layer';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport { Database, Filter } from '@dxos/echo';\nimport { Connection } from '@dxos/link';\nimport { log } from '@dxos/log';\nimport * as PreviewCapabilities from '@dxos/plugin-preview/PreviewCapabilities';\nimport { Issue, PullRequest, Repo } from '@dxos/types';\n\nimport { GitHubCapabilities } from '#types';\n\nimport { GITHUB_PROVIDER_ID } from '../constants.ts';\nimport { type GitHubLink, githubLinkIcon, parseGitHubLink } from '../extensions/index.ts';\nimport { toPullRequestProps } from '../pull-request.ts';\nimport { GitHubApi } from '../services/index.ts';\n\n/**\n * Resolves a GitHub repository, pull-request or issue URL to an in-memory `Repo`, `PullRequest` or\n * `Issue` for the preview popover. The object comes from the contributed `LinkSource` when a host provides one and\n * from the GitHub API otherwise; either way it is built, not stored — a preview is not a sync.\n */\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const capabilities = yield* Capability.Service;\n return Capability.contribute(PreviewCapabilities.LinkResolver, [\n {\n match: (url) => parseGitHubLink(url) !== undefined,\n // How GitHub itself shortens a bare reference: the number, or the repository's full name.\n label: (url) => {\n const link = parseGitHubLink(url);\n return link && (link.number !== undefined ? `#${link.number}` : `${link.owner}/${link.repo}`);\n },\n icon: githubLinkIcon,\n resolve: ({ eid }, context) =>\n Effect.gen(function* () {\n const link = parseGitHubLink(eid);\n if (!link) {\n return undefined;\n }\n const [source = fetchFromGitHub] = capabilities.getAll(GitHubCapabilities.LinkSource);\n const object = yield* source(link, context);\n return (\n object && { label: Repo.instanceOf(object) ? Repo.fullName(object) : Issue.reference(object), object }\n );\n }),\n },\n ]);\n }),\n);\n\n/**\n * The default source: each of the space's GitHub connection tokens in turn — a space can hold\n * several, and only some may reach a private repository — then anonymous, which reaches a public one.\n */\nconst fetchFromGitHub: GitHubCapabilities.GitHubLinkSource = (link, { db }) =>\n Effect.gen(function* () {\n const tokens = db ? yield* connectionTokens(db) : [];\n for (const token of [...tokens, '']) {\n const object = yield* fetchLink(link).pipe(\n Effect.provide(Layer.succeed(GitHubApi.GitHubCredentials, { token })),\n Effect.tapError((error) => Effect.sync(() => log.warn('github link preview failed', { url: link.url, error }))),\n Effect.catch(() => Effect.succeed(undefined)),\n );\n if (object) {\n return object;\n }\n }\n return undefined;\n }).pipe(\n Effect.provide(FetchHttpClient.layer),\n Effect.catch(() => Effect.succeed(undefined)),\n );\n\n/** The tokens of the space's GitHub connections, in query order. */\nconst connectionTokens = (db: NonNullable<PreviewCapabilities.PreviewLinkContext['db']>) =>\n Effect.gen(function* () {\n const connections = yield* Database.query(Filter.type(Connection.Connection)).run;\n const tokens: string[] = [];\n for (const connection of connections) {\n if (connection.connectorId !== GITHUB_PROVIDER_ID) {\n continue;\n }\n const accessToken = yield* Database.load(connection.accessToken);\n tokens.push(accessToken.token);\n }\n return tokens;\n }).pipe(Effect.provide(Database.layer(db)));\n\nconst fetchLink = (link: GitHubLink) =>\n Effect.gen(function* () {\n const { owner, repo, number } = link;\n if (link.kind === 'repo' || number === undefined) {\n return toRepo(link, yield* GitHubApi.fetchRepo(owner, repo));\n }\n if (link.kind === 'pull') {\n return toPullRequest(link, yield* GitHubApi.fetchPullRequest(owner, repo, number));\n }\n const issue = yield* GitHubApi.fetchIssue(owner, repo, number);\n // The issue endpoint answers for a pull request's number too; only the pull endpoint has its diff.\n if (issue.pull_request) {\n return toPullRequest(link, yield* GitHubApi.fetchPullRequest(owner, repo, number));\n }\n return toIssue(link, issue);\n });\n\nconst toRepo = ({ owner, url }: GitHubLink, repo: GitHubApi.GitHubRepo): Repo.Repo =>\n Repo.make({\n owner,\n name: repo.name,\n url: repo.html_url ?? url,\n description: repo.description ?? undefined,\n defaultBranch: repo.default_branch ?? undefined,\n });\n\nconst toIssue = ({ owner, repo, number = 0, url }: GitHubLink, issue: GitHubApi.GitHubIssue): Issue.Issue =>\n Issue.make({\n owner,\n repo,\n number,\n title: issue.title,\n url: issue.html_url ?? url,\n state: issue.state === 'closed' ? 'closed' : 'open',\n author: issue.user?.login,\n description: issue.body ?? undefined,\n labels: issue.labels?.map((label) => label.name),\n });\n\nconst toPullRequest = (\n { owner, repo, number = 0, url }: GitHubLink,\n pull: GitHubApi.GitHubPull,\n): PullRequest.PullRequest => PullRequest.make(toPullRequestProps({ owner, repo, number, url }, pull));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAA,wBAAe,WAAW,WACxB,OAAO,WAAW,aAAa;CAC7B,MAAM,eAAe,OAAO,WAAW;CACvC,OAAO,WAAW,WAAW,oBAAoB,cAAc,CAC7D;EACE,QAAQ,QAAQ,gBAAgB,GAAG,MAAM,KAAA;EAEzC,QAAQ,QAAQ;GACd,MAAM,OAAO,gBAAgB,GAAG;GAChC,OAAO,SAAS,KAAK,WAAW,KAAA,IAAY,IAAI,KAAK,WAAW,GAAG,KAAK,MAAM,GAAG,KAAK;EACxF;EACA,MAAM;EACN,UAAU,EAAE,OAAO,YACjB,OAAO,IAAI,aAAa;GACtB,MAAM,OAAO,gBAAgB,GAAG;GAChC,IAAI,CAAC,MACH;GAEF,MAAM,CAAC,SAAS,mBAAmB,aAAa,OAAO,mBAAmB,UAAU;GACpF,MAAM,SAAS,OAAO,OAAO,MAAM,OAAO;GAC1C,OACE,UAAU;IAAE,OAAO,KAAK,WAAW,MAAM,IAAI,KAAK,SAAS,MAAM,IAAI,MAAM,UAAU,MAAM;IAAG;GAAO;EAEzG,CAAC;CACL,CACF,CAAC;AACH,CAAC,CACH;;;;;AAMA,IAAM,mBAAwD,MAAM,EAAE,SACpE,OAAO,IAAI,aAAa;CACtB,MAAM,SAAS,KAAK,OAAO,iBAAiB,EAAE,IAAI,CAAC;CACnD,KAAK,MAAM,SAAS,CAAC,GAAG,QAAQ,EAAE,GAAG;EACnC,MAAM,SAAS,OAAO,UAAU,IAAI,CAAC,CAAC,KACpC,OAAO,QAAQ,MAAM,QAAQ,mBAA6B,EAAE,MAAM,CAAC,CAAC,GACpE,OAAO,UAAU,UAAU,OAAO,WAAW,IAAI,KAAK,8BAA8B;GAAE,KAAK,KAAK;GAAK;EAAM,GAAA;GAAA,YAAA;GAAA,GAAA;GAAA,GAAA;GAAA,GAAA;EAAA,CAAC,CAAC,CAAC,GAC9G,OAAO,YAAY,OAAO,QAAQ,KAAA,CAAS,CAAC,CAC9C;EACA,IAAI,QACF,OAAO;CAEX;AAEF,CAAC,CAAC,CAAC,KACD,OAAO,QAAQ,gBAAgB,KAAK,GACpC,OAAO,YAAY,OAAO,QAAQ,KAAA,CAAS,CAAC,CAC9C;;AAGF,IAAM,oBAAoB,OACxB,OAAO,IAAI,aAAa;CACtB,MAAM,cAAc,OAAO,SAAS,MAAM,OAAO,KAAK,WAAW,UAAU,CAAC,CAAC,CAAC;CAC9E,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,cAAc,aAAa;EACpC,IAAI,WAAW,gBAAA,UACb;EAEF,MAAM,cAAc,OAAO,SAAS,KAAK,WAAW,WAAW;EAC/D,OAAO,KAAK,YAAY,KAAK;CAC/B;CACA,OAAO;AACT,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,SAAS,MAAM,EAAE,CAAC,CAAC;AAE5C,IAAM,aAAa,SACjB,OAAO,IAAI,aAAa;CACtB,MAAM,EAAE,OAAO,MAAM,WAAW;CAChC,IAAI,KAAK,SAAS,UAAU,WAAW,KAAA,GACrC,OAAO,OAAO,MAAM,OAAO,UAAoB,OAAO,IAAI,CAAC;CAE7D,IAAI,KAAK,SAAS,QAChB,OAAO,cAAc,MAAM,OAAO,iBAA2B,OAAO,MAAM,MAAM,CAAC;CAEnF,MAAM,QAAQ,OAAO,WAAqB,OAAO,MAAM,MAAM;CAE7D,IAAI,MAAM,cACR,OAAO,cAAc,MAAM,OAAO,iBAA2B,OAAO,MAAM,MAAM,CAAC;CAEnF,OAAO,QAAQ,MAAM,KAAK;AAC5B,CAAC;AAEH,IAAM,UAAU,EAAE,OAAO,OAAmB,SAC1C,KAAK,KAAK;CACR;CACA,MAAM,KAAK;CACX,KAAK,KAAK,YAAY;CACtB,aAAa,KAAK,eAAe,KAAA;CACjC,eAAe,KAAK,kBAAkB,KAAA;AACxC,CAAC;AAEH,IAAM,WAAW,EAAE,OAAO,MAAM,SAAS,GAAG,OAAmB,UAC7D,MAAM,KAAK;CACT;CACA;CACA;CACA,OAAO,MAAM;CACb,KAAK,MAAM,YAAY;CACvB,OAAO,MAAM,UAAU,WAAW,WAAW;CAC7C,QAAQ,MAAM,MAAM;CACpB,aAAa,MAAM,QAAQ,KAAA;CAC3B,QAAQ,MAAM,QAAQ,KAAK,UAAU,MAAM,IAAI;AACjD,CAAC;AAEH,IAAM,iBACJ,EAAE,OAAO,MAAM,SAAS,GAAG,OAC3B,SAC4B,YAAY,KAAK,mBAAmB;CAAE;CAAO;CAAM;CAAQ;AAAI,GAAG,IAAI,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { githubLinks, githubReferences, referenceUrl } from "./extensions.mjs";
|
|
2
|
+
import { r as GITHUB_SOURCE } from "./chunk-constants.mjs";
|
|
3
|
+
import * as Capability from "@dxos/app-framework/Capability";
|
|
4
|
+
import * as MarkdownCapabilities from "@dxos/plugin-markdown/MarkdownCapabilities";
|
|
5
|
+
import { ViewPlugin } from "@codemirror/view";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import { Repo, TaskSet } from "@dxos/types";
|
|
8
|
+
import { Filter, Obj, Query } from "@dxos/echo";
|
|
9
|
+
import * as Project from "@dxos/compute/Project";
|
|
10
|
+
//#region src/capabilities/markdown-extension.ts
|
|
11
|
+
/** `owner/repo` — what `sync` writes as the name of the TaskSet mirroring a repository. */
|
|
12
|
+
var REPO_NAME = /^[\w.-]+\/[\w.-]+$/;
|
|
13
|
+
/**
|
|
14
|
+
* `#123` in a document resolves against the repository the document's project names: this plugin
|
|
15
|
+
* owns that knowledge, so the decoration is contributed rather than built into the editor. A full
|
|
16
|
+
* pull-request or issue URL needs no repository and becomes a chip whose popover this plugin's
|
|
17
|
+
* link resolver answers.
|
|
18
|
+
*
|
|
19
|
+
* Ambiguity is answered by declining. A space with several repositories and no project naming one
|
|
20
|
+
* has no single meaning for a bare number, so the reference is left as text rather than guessed at.
|
|
21
|
+
*/
|
|
22
|
+
var markdown_extension_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
23
|
+
return Capability.contribute(MarkdownCapabilities.ExtensionProvider, [({ document: doc, subject, viewMode }) => {
|
|
24
|
+
if (viewMode === "source") return;
|
|
25
|
+
const object = doc ?? subject;
|
|
26
|
+
const db = object && Obj.getDatabase(object);
|
|
27
|
+
if (!object || !db) return [githubLinks()];
|
|
28
|
+
const mirrored = watchMirroredRepos(db);
|
|
29
|
+
return [
|
|
30
|
+
githubLinks(),
|
|
31
|
+
githubReferences({ resolve: (number) => {
|
|
32
|
+
const repo = projectRepo(db, object) ?? mirrored.single();
|
|
33
|
+
return repo ? referenceUrl(repo, number) : void 0;
|
|
34
|
+
} }),
|
|
35
|
+
ViewPlugin.define(() => ({ destroy: mirrored.acquire() }))
|
|
36
|
+
];
|
|
37
|
+
}]);
|
|
38
|
+
}));
|
|
39
|
+
/** The `repo` of the project owning `object`, else the repository its adopted task set mirrors. */
|
|
40
|
+
var projectRepo = (db, object) => {
|
|
41
|
+
const project = owningProject(object);
|
|
42
|
+
if (!project) return;
|
|
43
|
+
const repo = project.repo?.target;
|
|
44
|
+
if (repo && Repo.instanceOf(repo)) return Repo.fullName(repo);
|
|
45
|
+
const taskSet = project.taskSet?.target;
|
|
46
|
+
return taskSet && isMirrored(taskSet) ? repoName(taskSet) : void 0;
|
|
47
|
+
};
|
|
48
|
+
/** Walks the ECHO parent edge: a project's outline, instructions and artifacts all cascade from it. */
|
|
49
|
+
var owningProject = (object) => {
|
|
50
|
+
let current = object;
|
|
51
|
+
for (let depth = 0; current && depth < 8; depth++) {
|
|
52
|
+
if (Obj.instanceOf(Project.Project, current)) return current;
|
|
53
|
+
current = Obj.getParent(current);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* The repositories this space mirrors, as `owner/name`. Read synchronously from a decoration pass,
|
|
58
|
+
* where a fresh `runSync()` would answer with whatever the tab has loaded so far; the subscription
|
|
59
|
+
* brings the set to the complete answer and keeps it there while any editor holds it.
|
|
60
|
+
*/
|
|
61
|
+
var watchMirroredRepos = (db) => {
|
|
62
|
+
const names = /* @__PURE__ */ new Set();
|
|
63
|
+
let holds = 0;
|
|
64
|
+
let stop;
|
|
65
|
+
return {
|
|
66
|
+
/** The one mirrored repository, or undefined when there is none or more than one. */
|
|
67
|
+
single: () => names.size === 1 ? [...names][0] : void 0,
|
|
68
|
+
/** Starts watching on the first hold; the returned release is safe to call more than once. */
|
|
69
|
+
acquire: () => {
|
|
70
|
+
if (holds++ === 0) stop = db.query(Query.select(Filter.type(TaskSet.TaskSet))).subscribe((result) => {
|
|
71
|
+
names.clear();
|
|
72
|
+
for (const name of result.results.filter(isMirrored).map(repoName)) if (name) names.add(name);
|
|
73
|
+
}, { fire: true });
|
|
74
|
+
let released = false;
|
|
75
|
+
return () => {
|
|
76
|
+
if (released) return;
|
|
77
|
+
released = true;
|
|
78
|
+
if (--holds === 0) {
|
|
79
|
+
stop?.();
|
|
80
|
+
stop = void 0;
|
|
81
|
+
names.clear();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
var isMirrored = (taskSet) => Obj.getMeta(taskSet).keys.some(({ source }) => source === GITHUB_SOURCE);
|
|
88
|
+
var repoName = (taskSet) => taskSet.name && REPO_NAME.test(taskSet.name) ? taskSet.name : void 0;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { markdown_extension_default as default };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=chunk-markdown-extension.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-markdown-extension.mjs","names":[],"sources":["../../src/capabilities/markdown-extension.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { ViewPlugin } from '@codemirror/view';\nimport * as Effect from 'effect/Effect';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport * as Project from '@dxos/compute/Project';\nimport { type Database, Filter, Obj, Query } from '@dxos/echo';\nimport * as MarkdownCapabilities from '@dxos/plugin-markdown/MarkdownCapabilities';\nimport { Repo, TaskSet } from '@dxos/types';\n\nimport { GITHUB_SOURCE } from '../constants.ts';\nimport { githubLinks, githubReferences, referenceUrl } from '../extensions/index.ts';\n\n/** `owner/repo` — what `sync` writes as the name of the TaskSet mirroring a repository. */\nconst REPO_NAME = /^[\\w.-]+\\/[\\w.-]+$/;\n\n/**\n * `#123` in a document resolves against the repository the document's project names: this plugin\n * owns that knowledge, so the decoration is contributed rather than built into the editor. A full\n * pull-request or issue URL needs no repository and becomes a chip whose popover this plugin's\n * link resolver answers.\n *\n * Ambiguity is answered by declining. A space with several repositories and no project naming one\n * has no single meaning for a bare number, so the reference is left as text rather than guessed at.\n */\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n return Capability.contribute(MarkdownCapabilities.ExtensionProvider, [\n ({ document: doc, subject, viewMode }) => {\n // Source view shows the document's own text; a decoration there would hide what it is.\n if (viewMode === 'source') {\n return undefined;\n }\n\n // A full URL needs no object: a task's description or an outline gets the chip too. A bare\n // `#123` resolves against the repository of the project owning the edited object, so it\n // needs one — the document, or whatever else the editor edits.\n const object = doc ?? subject;\n const db = object && Obj.getDatabase(object);\n if (!object || !db) {\n return [githubLinks()];\n }\n\n // Nearest binding first: the project that owns the object names its repository explicitly,\n // and only a space with exactly one mirrored repository can answer for an object that\n // belongs to no project.\n const mirrored = watchMirroredRepos(db);\n return [\n githubLinks(),\n githubReferences({\n resolve: (number) => {\n const repo = projectRepo(db, object) ?? mirrored.single();\n return repo ? referenceUrl(repo, number) : undefined;\n },\n }),\n // Held per mounted view: the provider's result can be mounted in several editors or none,\n // so each view acquires its own hold rather than all of them releasing one subscription.\n ViewPlugin.define(() => ({ destroy: mirrored.acquire() })),\n ];\n },\n ]);\n }),\n);\n\n/** The `repo` of the project owning `object`, else the repository its adopted task set mirrors. */\nconst projectRepo = (db: Database.Database, object: Obj.Unknown): string | undefined => {\n const project = owningProject(object);\n if (!project) {\n return undefined;\n }\n\n const repo = project.repo?.target;\n if (repo && Repo.instanceOf(repo)) {\n return Repo.fullName(repo);\n }\n\n // A project mirroring a repository adopts its synced task set, whose name is `owner/repo`.\n const taskSet = project.taskSet?.target;\n return taskSet && isMirrored(taskSet) ? repoName(taskSet) : undefined;\n};\n\n/** Walks the ECHO parent edge: a project's outline, instructions and artifacts all cascade from it. */\nconst owningProject = (object: Obj.Unknown): Project.Project | undefined => {\n let current: Obj.Unknown | undefined = object;\n // Bounded: a malformed parent cycle must not hang the editor's decoration pass.\n for (let depth = 0; current && depth < 8; depth++) {\n if (Obj.instanceOf(Project.Project, current)) {\n return current;\n }\n current = Obj.getParent(current);\n }\n return undefined;\n};\n\n/**\n * The repositories this space mirrors, as `owner/name`. Read synchronously from a decoration pass,\n * where a fresh `runSync()` would answer with whatever the tab has loaded so far; the subscription\n * brings the set to the complete answer and keeps it there while any editor holds it.\n */\nconst watchMirroredRepos = (db: Database.Database) => {\n const names = new Set<string>();\n let holds = 0;\n let stop: (() => void) | undefined;\n return {\n /** The one mirrored repository, or undefined when there is none or more than one. */\n single: () => (names.size === 1 ? [...names][0] : undefined),\n /** Starts watching on the first hold; the returned release is safe to call more than once. */\n acquire: (): (() => void) => {\n if (holds++ === 0) {\n stop = db.query(Query.select(Filter.type(TaskSet.TaskSet))).subscribe(\n (result) => {\n names.clear();\n for (const name of result.results.filter(isMirrored).map(repoName)) {\n if (name) {\n names.add(name);\n }\n }\n },\n { fire: true },\n );\n }\n\n let released = false;\n return () => {\n if (released) {\n return;\n }\n released = true;\n if (--holds === 0) {\n stop?.();\n stop = undefined;\n names.clear();\n }\n };\n },\n };\n};\n\nconst isMirrored = (taskSet: TaskSet.TaskSet): boolean =>\n Obj.getMeta(taskSet).keys.some(({ source }) => source === GITHUB_SOURCE);\n\nconst repoName = (taskSet: TaskSet.TaskSet): string | undefined =>\n taskSet.name && REPO_NAME.test(taskSet.name) ? taskSet.name : undefined;\n"],"mappings":";;;;;;;;;;;AAiBA,IAAM,YAAY;;;;;;;;;;AAWlB,IAAA,6BAAe,WAAW,WACxB,OAAO,WAAW,aAAa;CAC7B,OAAO,WAAW,WAAW,qBAAqB,mBAAmB,EAClE,EAAE,UAAU,KAAK,SAAS,eAAe;EAExC,IAAI,aAAa,UACf;EAMF,MAAM,SAAS,OAAO;EACtB,MAAM,KAAK,UAAU,IAAI,YAAY,MAAM;EAC3C,IAAI,CAAC,UAAU,CAAC,IACd,OAAO,CAAC,YAAY,CAAC;EAMvB,MAAM,WAAW,mBAAmB,EAAE;EACtC,OAAO;GACL,YAAY;GACZ,iBAAiB,EACf,UAAU,WAAW;IACnB,MAAM,OAAO,YAAY,IAAI,MAAM,KAAK,SAAS,OAAO;IACxD,OAAO,OAAO,aAAa,MAAM,MAAM,IAAI,KAAA;GAC7C,EACF,CAAC;GAGD,WAAW,cAAc,EAAE,SAAS,SAAS,QAAQ,EAAE,EAAE;EAC3D;CACF,CACF,CAAC;AACH,CAAC,CACH;;AAGA,IAAM,eAAe,IAAuB,WAA4C;CACtF,MAAM,UAAU,cAAc,MAAM;CACpC,IAAI,CAAC,SACH;CAGF,MAAM,OAAO,QAAQ,MAAM;CAC3B,IAAI,QAAQ,KAAK,WAAW,IAAI,GAC9B,OAAO,KAAK,SAAS,IAAI;CAI3B,MAAM,UAAU,QAAQ,SAAS;CACjC,OAAO,WAAW,WAAW,OAAO,IAAI,SAAS,OAAO,IAAI,KAAA;AAC9D;;AAGA,IAAM,iBAAiB,WAAqD;CAC1E,IAAI,UAAmC;CAEvC,KAAK,IAAI,QAAQ,GAAG,WAAW,QAAQ,GAAG,SAAS;EACjD,IAAI,IAAI,WAAW,QAAQ,SAAS,OAAO,GACzC,OAAO;EAET,UAAU,IAAI,UAAU,OAAO;CACjC;AAEF;;;;;;AAOA,IAAM,sBAAsB,OAA0B;CACpD,MAAM,wBAAQ,IAAI,IAAY;CAC9B,IAAI,QAAQ;CACZ,IAAI;CACJ,OAAO;;EAEL,cAAe,MAAM,SAAS,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,KAAA;;EAElD,eAA6B;GAC3B,IAAI,YAAY,GACd,OAAO,GAAG,MAAM,MAAM,OAAO,OAAO,KAAK,QAAQ,OAAO,CAAC,CAAC,CAAC,CAAC,WACzD,WAAW;IACV,MAAM,MAAM;IACZ,KAAK,MAAM,QAAQ,OAAO,QAAQ,OAAO,UAAU,CAAC,CAAC,IAAI,QAAQ,GAC/D,IAAI,MACF,MAAM,IAAI,IAAI;GAGpB,GACA,EAAE,MAAM,KAAK,CACf;GAGF,IAAI,WAAW;GACf,aAAa;IACX,IAAI,UACF;IAEF,WAAW;IACX,IAAI,EAAE,UAAU,GAAG;KACjB,OAAO;KACP,OAAO,KAAA;KACP,MAAM,MAAM;IACd;GACF;EACF;CACF;AACF;AAEA,IAAM,cAAc,YAClB,IAAI,QAAQ,OAAO,CAAC,CAAC,KAAK,MAAM,EAAE,aAAa,WAAW,aAAa;AAEzE,IAAM,YAAY,YAChB,QAAQ,QAAQ,UAAU,KAAK,QAAQ,IAAI,IAAI,QAAQ,OAAO,KAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { r as GITHUB_SOURCE } from "./chunk-constants.mjs";
|
|
2
|
+
import { GitHubOperation } from "#types";
|
|
3
|
+
import * as Operation from "@dxos/compute/Operation";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { TaskSet } from "@dxos/types";
|
|
6
|
+
import { Database, Filter, Obj, Query, Ref } from "@dxos/echo";
|
|
7
|
+
//#region src/operations/materialize-target.ts
|
|
8
|
+
var fkFor = (id) => ({
|
|
9
|
+
source: GITHUB_SOURCE,
|
|
10
|
+
id
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Find-or-create the empty local root Project for a GitHub repo so a `Cursor`
|
|
14
|
+
* can reference it as its `spec.target`. Idempotent: keyed by the repo's
|
|
15
|
+
* GitHub foreign id (`remoteTarget.id`), it returns the existing Project
|
|
16
|
+
* when one already carries that key. The repo's data is filled in lazily by the
|
|
17
|
+
* sync operation; here we only stamp the foreign key + a display name.
|
|
18
|
+
*/
|
|
19
|
+
var handler = GitHubOperation.MaterializeGitHubTarget.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ connection, remoteTarget }) {
|
|
20
|
+
if (!remoteTarget) return yield* Effect.die(/* @__PURE__ */ new Error("GitHub materializeTarget requires a remoteTarget (repo descriptor)."));
|
|
21
|
+
const db = connection.target ? Obj.getDatabase(connection.target) : void 0;
|
|
22
|
+
if (!db) return yield* Effect.die(/* @__PURE__ */ new Error("No database for connection ref."));
|
|
23
|
+
return yield* Effect.gen(function* () {
|
|
24
|
+
const existing = yield* Database.query(Query.select(Filter.foreignKeys(TaskSet.TaskSet, [fkFor(remoteTarget.id)]))).run;
|
|
25
|
+
if (existing.length > 0) return { target: Ref.make(existing[0]) };
|
|
26
|
+
const created = yield* Database.add(TaskSet.make({
|
|
27
|
+
[Obj.Meta]: { keys: [fkFor(remoteTarget.id)] },
|
|
28
|
+
name: remoteTarget.name
|
|
29
|
+
}));
|
|
30
|
+
return { target: Ref.make(created) };
|
|
31
|
+
}).pipe(Effect.provide(Database.layer(db)));
|
|
32
|
+
})));
|
|
33
|
+
//#endregion
|
|
34
|
+
export { handler as default };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=chunk-materialize-target.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-materialize-target.mjs","names":[],"sources":["../../src/operations/materialize-target.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as Operation from '@dxos/compute/Operation';\nimport { Database, Filter, Obj, Query, Ref } from '@dxos/echo';\nimport { TaskSet } from '@dxos/types';\n\nimport { GitHubOperation } from '#types';\n\nimport { GITHUB_SOURCE } from '../constants.ts';\n\nconst fkFor = (id: string) => ({ source: GITHUB_SOURCE, id });\n\n/**\n * Find-or-create the empty local root Project for a GitHub repo so a `Cursor`\n * can reference it as its `spec.target`. Idempotent: keyed by the repo's\n * GitHub foreign id (`remoteTarget.id`), it returns the existing Project\n * when one already carries that key. The repo's data is filled in lazily by the\n * sync operation; here we only stamp the foreign key + a display name.\n */\nconst handler: Operation.WithHandler<typeof GitHubOperation.MaterializeGitHubTarget> =\n GitHubOperation.MaterializeGitHubTarget.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ connection, remoteTarget }) {\n if (!remoteTarget) {\n return yield* Effect.die(new Error('GitHub materializeTarget requires a remoteTarget (repo descriptor).'));\n }\n // TODO(wittjosiah): the operation should just depend on `Database.Service` and\n // have it provided by the OperationInvoker — composer's invoker is wired\n // without a `databaseResolver`, so we derive the db from the connection ref's\n // target and provide `Database.layer(db)` ourselves.\n const db = connection.target ? Obj.getDatabase(connection.target) : undefined;\n if (!db) {\n return yield* Effect.die(new Error('No database for connection ref.'));\n }\n\n return yield* Effect.gen(function* () {\n const existing = yield* Database.query(\n Query.select(Filter.foreignKeys(TaskSet.TaskSet, [fkFor(remoteTarget.id)])),\n ).run;\n if (existing.length > 0) {\n return { target: Ref.make(existing[0]) };\n }\n\n const created = yield* Database.add(\n TaskSet.make({\n [Obj.Meta]: { keys: [fkFor(remoteTarget.id)] },\n name: remoteTarget.name,\n }),\n );\n return { target: Ref.make(created) };\n }).pipe(Effect.provide(Database.layer(db)));\n }),\n ),\n );\n\nexport default handler;\n"],"mappings":";;;;;;;AAcA,IAAM,SAAS,QAAgB;CAAE,QAAQ;CAAe;AAAG;;;;;;;;AAS3D,IAAM,UACJ,gBAAgB,wBAAwB,KACtC,UAAU,YACR,OAAO,WAAW,WAAW,EAAE,YAAY,gBAAgB;CACzD,IAAI,CAAC,cACH,OAAO,OAAO,OAAO,oBAAI,IAAI,MAAM,qEAAqE,CAAC;CAM3G,MAAM,KAAK,WAAW,SAAS,IAAI,YAAY,WAAW,MAAM,IAAI,KAAA;CACpE,IAAI,CAAC,IACH,OAAO,OAAO,OAAO,oBAAI,IAAI,MAAM,iCAAiC,CAAC;CAGvE,OAAO,OAAO,OAAO,IAAI,aAAa;EACpC,MAAM,WAAW,OAAO,SAAS,MAC/B,MAAM,OAAO,OAAO,YAAY,QAAQ,SAAS,CAAC,MAAM,aAAa,EAAE,CAAC,CAAC,CAAC,CAC5E,CAAC,CAAC;EACF,IAAI,SAAS,SAAS,GACpB,OAAO,EAAE,QAAQ,IAAI,KAAK,SAAS,EAAE,EAAE;EAGzC,MAAM,UAAU,OAAO,SAAS,IAC9B,QAAQ,KAAK;IACV,IAAI,OAAO,EAAE,MAAM,CAAC,MAAM,aAAa,EAAE,CAAC,EAAE;GAC7C,MAAM,aAAa;EACrB,CAAC,CACH;EACA,OAAO,EAAE,QAAQ,IAAI,KAAK,OAAO,EAAE;CACrC,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,SAAS,MAAM,EAAE,CAAC,CAAC;AAC5C,CAAC,CACH,CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as Capability from "@dxos/app-framework/Capability";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Capabilities from "@dxos/app-framework/Capabilities";
|
|
4
|
+
import { GitHubOperationHandlerSet } from "#operations";
|
|
5
|
+
//#region src/capabilities/operation-handler.ts
|
|
6
|
+
var operation_handler_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
7
|
+
return Capability.contribute(Capabilities.OperationHandler, GitHubOperationHandlerSet);
|
|
8
|
+
}));
|
|
9
|
+
//#endregion
|
|
10
|
+
export { operation_handler_default as default };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=chunk-operation-handler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-operation-handler.mjs","names":[],"sources":["../../src/capabilities/operation-handler.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as Capabilities from '@dxos/app-framework/Capabilities';\nimport * as Capability from '@dxos/app-framework/Capability';\n\nimport { GitHubOperationHandlerSet } from '#operations';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n return Capability.contribute(Capabilities.OperationHandler, GitHubOperationHandlerSet);\n }),\n);\n"],"mappings":";;;;;AAWA,IAAA,4BAAe,WAAW,WACxB,OAAO,WAAW,aAAa;CAC7B,OAAO,WAAW,WAAW,aAAa,kBAAkB,yBAAyB;AACvF,CAAC,CACH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as Capability from "@dxos/app-framework/Capability";
|
|
2
|
+
import * as CrxCapabilities from "@dxos/plugin-crx/CrxCapabilities";
|
|
3
|
+
import { meta } from "#meta";
|
|
4
|
+
import { GitHubOperation } from "#types";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
//#region src/capabilities/page-action.ts
|
|
7
|
+
var page_action_default = Capability.makeModule(() => Effect.sync(() => {
|
|
8
|
+
const actions = [{
|
|
9
|
+
id: `${meta.profile.key}/page-action/open-pull-request`,
|
|
10
|
+
label: "Open PR in Composer",
|
|
11
|
+
icon: "ph--git-pull-request--regular",
|
|
12
|
+
urlPatterns: ["https://github.com/*/*/pull/*"],
|
|
13
|
+
extractor: { name: "snapshot" },
|
|
14
|
+
contexts: ["popup", "picker"],
|
|
15
|
+
operation: GitHubOperation.ImportPullRequestFromSnapshot
|
|
16
|
+
}];
|
|
17
|
+
return Capability.contribute(CrxCapabilities.PageAction, actions);
|
|
18
|
+
}));
|
|
19
|
+
//#endregion
|
|
20
|
+
export { page_action_default as default };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=chunk-page-action.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-page-action.mjs","names":[],"sources":["../../src/capabilities/page-action.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport * as CrxCapabilities from '@dxos/plugin-crx/CrxCapabilities';\nimport type * as PageAction from '@dxos/plugin-crx/PageAction';\n\nimport { meta } from '#meta';\nimport { GitHubOperation } from '#types';\n\nexport default Capability.makeModule(() =>\n Effect.sync(() => {\n // Typed array so the contribution is checked against CrxCapabilities.PageAction's value type.\n const actions: PageAction.PageAction[] = [\n {\n id: `${meta.profile.key}/page-action/open-pull-request`,\n label: 'Open PR in Composer',\n icon: 'ph--git-pull-request--regular',\n // `/pull/123` and anything below it (`/files`, `/commits`), which GitHub serves as the same\n // pull request.\n urlPatterns: ['https://github.com/*/*/pull/*'],\n extractor: { name: 'snapshot' },\n contexts: ['popup', 'picker'],\n operation: GitHubOperation.ImportPullRequestFromSnapshot,\n },\n ];\n return Capability.contribute(CrxCapabilities.PageAction, actions);\n }),\n);\n"],"mappings":";;;;;;AAaA,IAAA,sBAAe,WAAW,iBACxB,OAAO,WAAW;CAEhB,MAAM,UAAmC,CACvC;EACE,IAAI,GAAG,KAAK,QAAQ,IAAI;EACxB,OAAO;EACP,MAAM;EAGN,aAAa,CAAC,+BAA+B;EAC7C,WAAW,EAAE,MAAM,WAAW;EAC9B,UAAU,CAAC,SAAS,QAAQ;EAC5B,WAAW,gBAAgB;CAC7B,CACF;CACA,OAAO,WAAW,WAAW,gBAAgB,YAAY,OAAO;AAClE,CAAC,CACH"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/pull-request.ts
|
|
2
|
+
/** Where a pull request lives on github.com, for a reference that carried no URL of its own. */
|
|
3
|
+
var pullRequestUrl = ({ owner, repo, number }) => `https://github.com/${owner}/${repo}/pull/${number}`;
|
|
4
|
+
/**
|
|
5
|
+
* GitHub's pull payload as the fields a local {@link PullRequest.PullRequest} holds.
|
|
6
|
+
*
|
|
7
|
+
* Shared by the link preview and the import command so the two cannot disagree about what a pull
|
|
8
|
+
* request looks like once it is in a space.
|
|
9
|
+
*/
|
|
10
|
+
var toPullRequestProps = (reference, pull) => ({
|
|
11
|
+
owner: reference.owner,
|
|
12
|
+
repo: reference.repo,
|
|
13
|
+
number: reference.number,
|
|
14
|
+
title: pull.title,
|
|
15
|
+
url: pull.html_url ?? reference.url ?? pullRequestUrl(reference),
|
|
16
|
+
state: pull.merged || pull.merged_at ? "merged" : pull.draft ? "draft" : pull.state === "closed" ? "closed" : "open",
|
|
17
|
+
author: pull.user?.login,
|
|
18
|
+
description: pull.body ?? void 0,
|
|
19
|
+
baseBranch: pull.base?.ref,
|
|
20
|
+
headBranch: pull.head?.ref,
|
|
21
|
+
additions: pull.additions,
|
|
22
|
+
deletions: pull.deletions,
|
|
23
|
+
createdAt: pull.created_at ?? void 0,
|
|
24
|
+
updatedAt: pull.updated_at ?? void 0
|
|
25
|
+
});
|
|
26
|
+
/** Fields a re-sync may overwrite; the coordinates and URL name the pull request and never drift. */
|
|
27
|
+
var SYNCED_FIELDS = [
|
|
28
|
+
"title",
|
|
29
|
+
"state",
|
|
30
|
+
"author",
|
|
31
|
+
"description",
|
|
32
|
+
"baseBranch",
|
|
33
|
+
"headBranch",
|
|
34
|
+
"additions",
|
|
35
|
+
"deletions",
|
|
36
|
+
"createdAt",
|
|
37
|
+
"updatedAt"
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* The fields where GitHub's payload differs from the stored pull request, so a re-sync writes only
|
|
41
|
+
* what changed and an unchanged pull request costs no mutation.
|
|
42
|
+
*
|
|
43
|
+
* A field GitHub's payload leaves out is kept rather than cleared: an absent value is unknown, not empty.
|
|
44
|
+
*/
|
|
45
|
+
var pullRequestChanges = (pullRequest, pull) => {
|
|
46
|
+
const next = toPullRequestProps(pullRequest, pull);
|
|
47
|
+
const changes = {};
|
|
48
|
+
const copy = (field) => {
|
|
49
|
+
const value = next[field];
|
|
50
|
+
if (value !== void 0 && value !== pullRequest[field]) changes[field] = value;
|
|
51
|
+
};
|
|
52
|
+
SYNCED_FIELDS.forEach(copy);
|
|
53
|
+
return changes;
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { toPullRequestProps as n, pullRequestChanges as t };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=chunk-pull-request.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-pull-request.mjs","names":[],"sources":["../../src/pull-request.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Obj } from '@dxos/echo';\nimport { PullRequest } from '@dxos/types';\n\nimport { type PullRequestReference } from './github-link.ts';\nimport { type GitHubApi } from './services/index.ts';\n\n/** Where a pull request lives on github.com, for a reference that carried no URL of its own. */\nexport const pullRequestUrl = ({ owner, repo, number }: PullRequestReference): string =>\n `https://github.com/${owner}/${repo}/pull/${number}`;\n\n/**\n * GitHub's pull payload as the fields a local {@link PullRequest.PullRequest} holds.\n *\n * Shared by the link preview and the import command so the two cannot disagree about what a pull\n * request looks like once it is in a space.\n */\nexport const toPullRequestProps = (\n reference: PullRequestReference & { url?: string },\n pull: GitHubApi.GitHubPull,\n): Obj.MakeProps<typeof PullRequest.PullRequest> => ({\n owner: reference.owner,\n repo: reference.repo,\n number: reference.number,\n title: pull.title,\n url: pull.html_url ?? reference.url ?? pullRequestUrl(reference),\n // `merged_at` as well as `merged`: the list endpoints carry only the timestamp.\n state: pull.merged || pull.merged_at ? 'merged' : pull.draft ? 'draft' : pull.state === 'closed' ? 'closed' : 'open',\n author: pull.user?.login,\n description: pull.body ?? undefined,\n baseBranch: pull.base?.ref,\n headBranch: pull.head?.ref,\n additions: pull.additions,\n deletions: pull.deletions,\n createdAt: pull.created_at ?? undefined,\n updatedAt: pull.updated_at ?? undefined,\n});\n\n/** Fields a re-sync may overwrite; the coordinates and URL name the pull request and never drift. */\nconst SYNCED_FIELDS = [\n 'title',\n 'state',\n 'author',\n 'description',\n 'baseBranch',\n 'headBranch',\n 'additions',\n 'deletions',\n 'createdAt',\n 'updatedAt',\n] as const;\n\ntype SyncedField = (typeof SYNCED_FIELDS)[number];\n\nexport type PullRequestChanges = Partial<Pick<PullRequest.PullRequest, SyncedField>>;\n\n/**\n * The fields where GitHub's payload differs from the stored pull request, so a re-sync writes only\n * what changed and an unchanged pull request costs no mutation.\n *\n * A field GitHub's payload leaves out is kept rather than cleared: an absent value is unknown, not empty.\n */\nexport const pullRequestChanges = (\n pullRequest: PullRequest.PullRequest,\n pull: GitHubApi.GitHubPull,\n): PullRequestChanges => {\n const next = toPullRequestProps(pullRequest, pull);\n const changes: PullRequestChanges = {};\n const copy = <Field extends SyncedField>(field: Field) => {\n const value = next[field];\n if (value !== undefined && value !== pullRequest[field]) {\n changes[field] = value;\n }\n };\n SYNCED_FIELDS.forEach(copy);\n return changes;\n};\n"],"mappings":";;AAWA,IAAa,kBAAkB,EAAE,OAAO,MAAM,aAC5C,sBAAsB,MAAM,GAAG,KAAK,QAAQ;;;;;;;AAQ9C,IAAa,sBACX,WACA,UACmD;CACnD,OAAO,UAAU;CACjB,MAAM,UAAU;CAChB,QAAQ,UAAU;CAClB,OAAO,KAAK;CACZ,KAAK,KAAK,YAAY,UAAU,OAAO,eAAe,SAAS;CAE/D,OAAO,KAAK,UAAU,KAAK,YAAY,WAAW,KAAK,QAAQ,UAAU,KAAK,UAAU,WAAW,WAAW;CAC9G,QAAQ,KAAK,MAAM;CACnB,aAAa,KAAK,QAAQ,KAAA;CAC1B,YAAY,KAAK,MAAM;CACvB,YAAY,KAAK,MAAM;CACvB,WAAW,KAAK;CAChB,WAAW,KAAK;CAChB,WAAW,KAAK,cAAc,KAAA;CAC9B,WAAW,KAAK,cAAc,KAAA;AAChC;;AAGA,IAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;AAYA,IAAa,sBACX,aACA,SACuB;CACvB,MAAM,OAAO,mBAAmB,aAAa,IAAI;CACjD,MAAM,UAA8B,CAAC;CACrC,MAAM,QAAmC,UAAiB;EACxD,MAAM,QAAQ,KAAK;EACnB,IAAI,UAAU,KAAA,KAAa,UAAU,YAAY,QAC/C,QAAQ,SAAS;CAErB;CACA,cAAc,QAAQ,IAAI;CAC1B,OAAO;AACT"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import "./chunk-constants.mjs";
|
|
2
|
+
import { t as GitHubCredentials } from "./chunk-github-api.mjs";
|
|
3
|
+
import { r as GitHubPullRequestUnstoredError } from "./chunk-errors.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import { Database, Filter, Obj } from "@dxos/echo";
|
|
6
|
+
import * as Layer from "effect/Layer";
|
|
7
|
+
import { Connection } from "@dxos/link";
|
|
8
|
+
//#region src/operations/pull-request.ts
|
|
9
|
+
/**
|
|
10
|
+
* The GitHub connection whose token requests are sent with: the first one holding a token. Shared by
|
|
11
|
+
* the handlers and by the UI that sends the user to reconnect, so both name the same connection.
|
|
12
|
+
*/
|
|
13
|
+
var githubConnection = () => Effect.gen(function* () {
|
|
14
|
+
const connections = yield* Database.query(Filter.type(Connection.Connection)).run;
|
|
15
|
+
for (const connection of connections) {
|
|
16
|
+
if (connection.connectorId !== "github") continue;
|
|
17
|
+
const accessToken = yield* Database.load(connection.accessToken);
|
|
18
|
+
if (accessToken.token) return {
|
|
19
|
+
connection,
|
|
20
|
+
token: accessToken.token
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* The token of {@link githubConnection}, or empty for anonymous — which reaches any public pull
|
|
26
|
+
* request, and is the only option in a space that has not connected GitHub.
|
|
27
|
+
*/
|
|
28
|
+
var githubToken = () => githubConnection().pipe(Effect.map((selected) => selected?.token ?? ""));
|
|
29
|
+
/**
|
|
30
|
+
* The stored pull request behind an operation's input and credentials for its space.
|
|
31
|
+
*
|
|
32
|
+
* The invoker carries no database resolver, so handlers derive one from the pull request itself; a
|
|
33
|
+
* preview card's in-memory pull request has none and cannot be acted on.
|
|
34
|
+
*/
|
|
35
|
+
var resolvePullRequest = (ref) => Effect.gen(function* () {
|
|
36
|
+
const pullRequest = ref.target;
|
|
37
|
+
const db = pullRequest ? Obj.getDatabase(pullRequest) : void 0;
|
|
38
|
+
if (!pullRequest || !db) return yield* Effect.die(new GitHubPullRequestUnstoredError());
|
|
39
|
+
const token = yield* githubToken().pipe(Effect.provide(Database.layer(db)));
|
|
40
|
+
return {
|
|
41
|
+
pullRequest,
|
|
42
|
+
db,
|
|
43
|
+
credentials: Layer.succeed(GitHubCredentials, { token })
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
var FAILED_CONCLUSIONS = /* @__PURE__ */ new Set([
|
|
47
|
+
"failure",
|
|
48
|
+
"cancelled",
|
|
49
|
+
"timed_out",
|
|
50
|
+
"action_required",
|
|
51
|
+
"startup_failure",
|
|
52
|
+
"stale"
|
|
53
|
+
]);
|
|
54
|
+
/** One check run as the article lists it: its outcome folded the way {@link summarizeCheckRuns} counts it. */
|
|
55
|
+
var toCheckRun = (run) => {
|
|
56
|
+
const outcome = run.status !== "completed" ? "pending" : run.conclusion && FAILED_CONCLUSIONS.has(run.conclusion) ? "failure" : run.conclusion === "skipped" ? "skipped" : run.conclusion === "neutral" ? "neutral" : "success";
|
|
57
|
+
const url = run.details_url ?? run.html_url;
|
|
58
|
+
return {
|
|
59
|
+
name: run.name,
|
|
60
|
+
outcome,
|
|
61
|
+
...run.conclusion ? { conclusion: run.conclusion } : {},
|
|
62
|
+
...url ? { url } : {},
|
|
63
|
+
...run.started_at ? { startedAt: run.started_at } : {},
|
|
64
|
+
...run.completed_at ? { completedAt: run.completed_at } : {}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/** Folds a commit's check runs into one outcome: any failure fails, then any unfinished run is pending. */
|
|
68
|
+
var summarizeCheckRuns = (runs) => {
|
|
69
|
+
const checks = {
|
|
70
|
+
total: runs.length,
|
|
71
|
+
passed: 0,
|
|
72
|
+
failed: 0,
|
|
73
|
+
pending: 0
|
|
74
|
+
};
|
|
75
|
+
for (const run of runs) if (run.status !== "completed") checks.pending++;
|
|
76
|
+
else if (run.conclusion && FAILED_CONCLUSIONS.has(run.conclusion)) checks.failed++;
|
|
77
|
+
else checks.passed++;
|
|
78
|
+
return {
|
|
79
|
+
ci: checks.total === 0 ? "none" : checks.failed > 0 ? "failure" : checks.pending > 0 ? "pending" : "success",
|
|
80
|
+
checks
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/** Review states that set a reviewer's standing verdict; a comment leaves the previous one in place. */
|
|
84
|
+
var VERDICT_STATES = /* @__PURE__ */ new Set([
|
|
85
|
+
"APPROVED",
|
|
86
|
+
"CHANGES_REQUESTED",
|
|
87
|
+
"DISMISSED"
|
|
88
|
+
]);
|
|
89
|
+
/**
|
|
90
|
+
* Folds a pull request's reviews into where they stand, from each reviewer's latest verdict — the
|
|
91
|
+
* way GitHub reads them: a later approval clears that reviewer's request for changes, and a dismissal
|
|
92
|
+
* withdraws whichever verdict it replaced.
|
|
93
|
+
*/
|
|
94
|
+
var summarizeReviews = (reviews) => {
|
|
95
|
+
const verdicts = /* @__PURE__ */ new Map();
|
|
96
|
+
for (const review of reviews) {
|
|
97
|
+
const login = review.user?.login;
|
|
98
|
+
if (login && VERDICT_STATES.has(review.state)) verdicts.set(login, review.state);
|
|
99
|
+
}
|
|
100
|
+
const states = [...verdicts.values()];
|
|
101
|
+
const approvals = states.filter((state) => state === "APPROVED").length;
|
|
102
|
+
return {
|
|
103
|
+
review: states.includes("CHANGES_REQUESTED") ? "changes_requested" : approvals > 0 ? "approved" : "none",
|
|
104
|
+
approvals
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
//#endregion
|
|
108
|
+
export { summarizeReviews as a, summarizeCheckRuns as i, githubToken as n, toCheckRun as o, resolvePullRequest as r, githubConnection as t };
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=chunk-pull-request2.mjs.map
|