@hanzo/dev 4.0.1 → 4.2.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 +21 -0
- package/dist/{BinaryViewer-qn8xfPZp.js → BinaryViewer-CmFUK4zZ.js} +2 -2
- package/dist/{ChatMarkdown-Cyujn3JJ.js → ChatMarkdown-nvEI7iCv.js} +4 -4
- package/dist/{DiffCommentAnnotation-BZu1TP6E.js → DiffCommentAnnotation-BPTN_2a6.js} +1 -1
- package/dist/{DiffFileTree-CcJ91zOM.js → DiffFileTree-B_br90vY.js} +2 -2
- package/dist/{DiffPanel-BXC88NMs.js → DiffPanel-V5R5TPuK.js} +5 -5
- package/dist/{ExpandedImageDialog-BZnGRBJR.js → ExpandedImageDialog-CAorLacL.js} +1 -1
- package/dist/{FileExplorerPane-vBJS6V75.js → FileExplorerPane-CeHulcPz.js} +1 -1
- package/dist/{FilePreviewPanel-jJHWsMzm.js → FilePreviewPanel-BVNLvWOc.js} +8 -8
- package/dist/{MermaidDiagram-paNwQY33.js → MermaidDiagram-CTolIzQD.js} +1 -1
- package/dist/{MermaidFilePreview-B9KxfnIN.js → MermaidFilePreview-CP2zP4FU.js} +1 -1
- package/dist/{MermaidViewer-CAEGpLyD.js → MermaidViewer-BDfYkS9E.js} +2 -2
- package/dist/{NotebookPreview-D01mMCpR.js → NotebookPreview-Cybs5uM0.js} +1 -1
- package/dist/{OfficeFilePreview-DWaRgfQU.js → OfficeFilePreview-7JsmSoKU.js} +1 -1
- package/dist/{OfficeViewer-BudrZbBA.js → OfficeViewer-CJoojlJK.js} +1 -1
- package/dist/{OpenInPicker-Dd3ifHa1.js → OpenInPicker-BIMWUxBP.js} +7 -7
- package/dist/{OpenXmlOfficeViewer-CXcKdq7k.js → OpenXmlOfficeViewer-C24Kj8DM.js} +1 -1
- package/dist/{PreviewImage-C4Ku4z7v.js → PreviewImage-oY5YnuTr.js} +1 -1
- package/dist/{PreviewImageContent-BwOB9Lyd.js → PreviewImageContent-n6eLzY99.js} +1 -1
- package/dist/{PullRequestCodeTab-BcwyMk7d.js → PullRequestCodeTab-Dv_0kVad.js} +7 -7
- package/dist/{PullRequestReviewAnnotation-BU5t_1fC.js → PullRequestReviewAnnotation-LeuwO-iH.js} +4 -4
- package/dist/builder/activity.d.ts +16 -0
- package/dist/builder/activity.js +51 -0
- package/dist/builder/address.d.ts +11 -0
- package/dist/builder/address.js +50 -0
- package/dist/builder/ago.d.ts +2 -0
- package/dist/builder/ago.js +18 -0
- package/dist/builder/api/agents.d.ts +139 -0
- package/dist/builder/api/agents.js +253 -0
- package/dist/builder/api/auto.d.ts +166 -0
- package/dist/builder/api/auto.js +300 -0
- package/dist/builder/api/billing.d.ts +263 -0
- package/dist/builder/api/billing.js +401 -0
- package/dist/builder/api/call.d.ts +53 -0
- package/dist/builder/api/call.js +123 -0
- package/dist/builder/api/capabilities.d.ts +14 -0
- package/dist/builder/api/capabilities.js +41 -0
- package/dist/builder/api/changes.d.ts +74 -0
- package/dist/builder/api/changes.js +75 -0
- package/dist/builder/api/chat.d.ts +12 -0
- package/dist/builder/api/chat.js +28 -0
- package/dist/builder/api/cli.d.ts +59 -0
- package/dist/builder/api/cli.js +133 -0
- package/dist/builder/api/codebases.d.ts +46 -0
- package/dist/builder/api/codebases.js +100 -0
- package/dist/builder/api/coding.d.ts +117 -0
- package/dist/builder/api/coding.js +222 -0
- package/dist/builder/api/connectors.d.ts +76 -0
- package/dist/builder/api/connectors.js +111 -0
- package/dist/builder/api/consent.d.ts +22 -0
- package/dist/builder/api/consent.js +28 -0
- package/dist/builder/api/conversations.d.ts +20 -0
- package/dist/builder/api/conversations.js +23 -0
- package/dist/builder/api/draft.d.ts +38 -0
- package/dist/builder/api/draft.js +87 -0
- package/dist/builder/api/environment.d.ts +55 -0
- package/dist/builder/api/environment.js +126 -0
- package/dist/builder/api/gallery.d.ts +32 -0
- package/dist/builder/api/gallery.js +85 -0
- package/dist/builder/api/git.d.ts +59 -0
- package/dist/builder/api/git.js +117 -0
- package/dist/builder/api/github.d.ts +230 -0
- package/dist/builder/api/github.js +373 -0
- package/dist/builder/api/keys.d.ts +35 -0
- package/dist/builder/api/keys.js +72 -0
- package/dist/builder/api/library.d.ts +116 -0
- package/dist/builder/api/library.js +214 -0
- package/dist/builder/api/limits.d.ts +69 -0
- package/dist/builder/api/limits.js +86 -0
- package/dist/builder/api/links.d.ts +51 -0
- package/dist/builder/api/links.js +75 -0
- package/dist/builder/api/machines.d.ts +122 -0
- package/dist/builder/api/machines.js +238 -0
- package/dist/builder/api/mcp.d.ts +10 -0
- package/dist/builder/api/mcp.js +47 -0
- package/dist/builder/api/members.d.ts +35 -0
- package/dist/builder/api/members.js +95 -0
- package/dist/builder/api/memory.d.ts +14 -0
- package/dist/builder/api/memory.js +35 -0
- package/dist/builder/api/models.d.ts +17 -0
- package/dist/builder/api/models.js +20 -0
- package/dist/builder/api/places.d.ts +32 -0
- package/dist/builder/api/places.js +29 -0
- package/dist/builder/api/platform.d.ts +68 -0
- package/dist/builder/api/platform.js +87 -0
- package/dist/builder/api/plugins.d.ts +42 -0
- package/dist/builder/api/plugins.js +175 -0
- package/dist/builder/api/pref.d.ts +77 -0
- package/dist/builder/api/pref.js +93 -0
- package/dist/builder/api/profile.d.ts +11 -0
- package/dist/builder/api/profile.js +41 -0
- package/dist/builder/api/projects.d.ts +99 -0
- package/dist/builder/api/projects.js +166 -0
- package/dist/builder/api/provider.d.ts +49 -0
- package/dist/builder/api/provider.js +96 -0
- package/dist/builder/api/sandbox.d.ts +90 -0
- package/dist/builder/api/sandbox.js +223 -0
- package/dist/builder/api/sessions.d.ts +123 -0
- package/dist/builder/api/sessions.js +255 -0
- package/dist/builder/api/skills.d.ts +82 -0
- package/dist/builder/api/skills.js +117 -0
- package/dist/builder/api/sse.d.ts +24 -0
- package/dist/builder/api/sse.js +68 -0
- package/dist/builder/api/studio.d.ts +59 -0
- package/dist/builder/api/studio.js +91 -0
- package/dist/builder/api/talk.d.ts +48 -0
- package/dist/builder/api/talk.js +81 -0
- package/dist/builder/api/tools.d.ts +34 -0
- package/dist/builder/api/tools.js +37 -0
- package/dist/builder/api/turn.d.ts +202 -0
- package/dist/builder/api/turn.js +772 -0
- package/dist/builder/api/verdict.d.ts +3 -0
- package/dist/builder/api/verdict.js +21 -0
- package/dist/builder/api/webhooks.d.ts +47 -0
- package/dist/builder/api/webhooks.js +82 -0
- package/dist/builder/api/work.d.ts +110 -0
- package/dist/builder/api/work.js +218 -0
- package/dist/builder/ask.d.ts +51 -0
- package/dist/builder/ask.js +147 -0
- package/dist/builder/automations.d.ts +33 -0
- package/dist/builder/automations.js +453 -0
- package/dist/builder/awake.d.ts +24 -0
- package/dist/builder/awake.js +68 -0
- package/dist/builder/back.d.ts +30 -0
- package/dist/builder/back.js +105 -0
- package/dist/builder/builder.d.ts +12 -0
- package/dist/builder/builder.js +162 -0
- package/dist/builder/carry.d.ts +48 -0
- package/dist/builder/carry.js +278 -0
- package/dist/builder/choice.d.ts +134 -0
- package/dist/builder/choice.js +152 -0
- package/dist/builder/claims.d.ts +13 -0
- package/dist/builder/claims.js +35 -0
- package/dist/builder/clipboard.d.ts +2 -0
- package/dist/builder/clipboard.js +10 -0
- package/dist/builder/customize/agents.d.ts +11 -0
- package/dist/builder/customize/agents.js +513 -0
- package/dist/builder/customize/connectors.d.ts +2 -0
- package/dist/builder/customize/connectors.js +319 -0
- package/dist/builder/customize/drafted.d.ts +4 -0
- package/dist/builder/customize/drafted.js +92 -0
- package/dist/builder/customize/index.d.ts +8 -0
- package/dist/builder/customize/index.js +127 -0
- package/dist/builder/customize/inventory.d.ts +14 -0
- package/dist/builder/customize/inventory.js +127 -0
- package/dist/builder/customize/load.d.ts +9 -0
- package/dist/builder/customize/load.js +22 -0
- package/dist/builder/customize/ocean.d.ts +41 -0
- package/dist/builder/customize/ocean.js +332 -0
- package/dist/builder/customize/plugins.d.ts +2 -0
- package/dist/builder/customize/plugins.js +136 -0
- package/dist/builder/customize/roles.d.ts +4 -0
- package/dist/builder/customize/roles.js +105 -0
- package/dist/builder/customize/say.d.ts +13 -0
- package/dist/builder/customize/say.js +32 -0
- package/dist/builder/customize/skills.d.ts +2 -0
- package/dist/builder/customize/skills.js +208 -0
- package/dist/builder/customize/ui.d.ts +152 -0
- package/dist/builder/customize/ui.js +208 -0
- package/dist/builder/data.d.ts +57 -0
- package/dist/builder/data.js +322 -0
- package/dist/builder/design.d.ts +140 -0
- package/dist/builder/design.js +175 -0
- package/dist/builder/desk.d.ts +48 -0
- package/dist/builder/desk.js +449 -0
- package/dist/builder/dev-mode.d.ts +43 -0
- package/dist/builder/dev-mode.js +120 -0
- package/dist/builder/door.d.ts +11 -0
- package/dist/builder/door.js +126 -0
- package/dist/builder/environment.d.ts +23 -0
- package/dist/builder/environment.js +193 -0
- package/dist/builder/files.d.ts +23 -0
- package/dist/builder/files.js +175 -0
- package/dist/builder/find.d.ts +7 -0
- package/dist/builder/find.js +80 -0
- package/dist/builder/foot.d.ts +30 -0
- package/dist/builder/foot.js +79 -0
- package/dist/builder/forge.d.ts +4 -0
- package/dist/builder/forge.js +639 -0
- package/dist/builder/gear.d.ts +60 -0
- package/dist/builder/gear.js +180 -0
- package/dist/builder/git.d.ts +21 -0
- package/dist/builder/git.js +118 -0
- package/dist/builder/github-sync.d.ts +70 -0
- package/dist/builder/github-sync.js +435 -0
- package/dist/builder/gutter.d.ts +17 -0
- package/dist/builder/gutter.js +25 -0
- package/dist/builder/handoff.d.ts +8 -0
- package/dist/builder/handoff.js +22 -0
- package/dist/builder/host.d.ts +189 -0
- package/dist/builder/host.js +46 -0
- package/dist/builder/index.d.ts +108 -0
- package/dist/builder/index.js +99 -0
- package/dist/builder/landing.d.ts +34 -0
- package/dist/builder/landing.js +725 -0
- package/dist/builder/library.d.ts +21 -0
- package/dist/builder/library.js +526 -0
- package/dist/builder/local.d.ts +80 -0
- package/dist/builder/local.js +124 -0
- package/dist/builder/make.d.ts +10 -0
- package/dist/builder/make.js +120 -0
- package/dist/builder/markdown.d.ts +49 -0
- package/dist/builder/markdown.js +125 -0
- package/dist/builder/marks.d.ts +15 -0
- package/dist/builder/marks.js +18 -0
- package/dist/builder/merge.d.ts +223 -0
- package/dist/builder/merge.js +380 -0
- package/dist/builder/meter.d.ts +31 -0
- package/dist/builder/meter.js +54 -0
- package/dist/builder/mind.d.ts +107 -0
- package/dist/builder/mind.js +335 -0
- package/dist/builder/names.d.ts +40 -0
- package/dist/builder/names.js +189 -0
- package/dist/builder/nav.d.ts +28 -0
- package/dist/builder/nav.js +218 -0
- package/dist/builder/out.d.ts +16 -0
- package/dist/builder/out.js +24 -0
- package/dist/builder/page.d.ts +55 -0
- package/dist/builder/page.js +217 -0
- package/dist/builder/pane.d.ts +30 -0
- package/dist/builder/pane.js +21 -0
- package/dist/builder/panel.d.ts +101 -0
- package/dist/builder/panel.js +408 -0
- package/dist/builder/pdf.d.ts +139 -0
- package/dist/builder/pdf.js +847 -0
- package/dist/builder/pick.d.ts +10 -0
- package/dist/builder/pick.js +38 -0
- package/dist/builder/plain.d.ts +59 -0
- package/dist/builder/plain.js +209 -0
- package/dist/builder/plan.d.ts +63 -0
- package/dist/builder/plan.js +155 -0
- package/dist/builder/plans.d.ts +1 -0
- package/dist/builder/plans.js +157 -0
- package/dist/builder/plugin.d.ts +60 -0
- package/dist/builder/plugin.js +1 -0
- package/dist/builder/plugins/design.d.ts +8 -0
- package/dist/builder/plugins/design.js +71 -0
- package/dist/builder/plugins/index.d.ts +46 -0
- package/dist/builder/plugins/index.js +117 -0
- package/dist/builder/plugins/pdf.d.ts +18 -0
- package/dist/builder/plugins/pdf.js +83 -0
- package/dist/builder/plugins/project.d.ts +5 -0
- package/dist/builder/plugins/project.js +68 -0
- package/dist/builder/plugins/research.d.ts +24 -0
- package/dist/builder/plugins/research.js +147 -0
- package/dist/builder/plugins/sketch.d.ts +9 -0
- package/dist/builder/plugins/sketch.js +101 -0
- package/dist/builder/plugins/slides.d.ts +14 -0
- package/dist/builder/plugins/slides.js +55 -0
- package/dist/builder/plugins/template.d.ts +13 -0
- package/dist/builder/plugins/template.js +95 -0
- package/dist/builder/prefs.d.ts +29 -0
- package/dist/builder/prefs.js +91 -0
- package/dist/builder/preview-url.d.ts +47 -0
- package/dist/builder/preview-url.js +107 -0
- package/dist/builder/project.d.ts +18 -0
- package/dist/builder/project.js +604 -0
- package/dist/builder/prose.d.ts +4 -0
- package/dist/builder/prose.js +57 -0
- package/dist/builder/publish.d.ts +18 -0
- package/dist/builder/publish.js +141 -0
- package/dist/builder/question.d.ts +33 -0
- package/dist/builder/question.js +64 -0
- package/dist/builder/redesign.d.ts +32 -0
- package/dist/builder/redesign.js +117 -0
- package/dist/builder/removal.d.ts +71 -0
- package/dist/builder/removal.js +73 -0
- package/dist/builder/reply.d.ts +50 -0
- package/dist/builder/reply.js +196 -0
- package/dist/builder/roles.d.ts +10 -0
- package/dist/builder/roles.js +28 -0
- package/dist/builder/route.d.ts +85 -0
- package/dist/builder/route.js +126 -0
- package/dist/builder/run.d.ts +4 -0
- package/dist/builder/run.js +804 -0
- package/dist/builder/runmeta.d.ts +16 -0
- package/dist/builder/runmeta.js +69 -0
- package/dist/builder/say.d.ts +2 -0
- package/dist/builder/say.js +7 -0
- package/dist/builder/scheduled.d.ts +3 -0
- package/dist/builder/scheduled.js +328 -0
- package/dist/builder/section.d.ts +27 -0
- package/dist/builder/section.js +60 -0
- package/dist/builder/settings/account.d.ts +1 -0
- package/dist/builder/settings/account.js +111 -0
- package/dist/builder/settings/billing.d.ts +1 -0
- package/dist/builder/settings/billing.js +210 -0
- package/dist/builder/settings/capabilities.d.ts +1 -0
- package/dist/builder/settings/capabilities.js +66 -0
- package/dist/builder/settings/card.d.ts +31 -0
- package/dist/builder/settings/card.js +140 -0
- package/dist/builder/settings/code.d.ts +1 -0
- package/dist/builder/settings/code.js +70 -0
- package/dist/builder/settings/credits.d.ts +10 -0
- package/dist/builder/settings/credits.js +123 -0
- package/dist/builder/settings/environments.d.ts +1 -0
- package/dist/builder/settings/environments.js +60 -0
- package/dist/builder/settings/general.d.ts +1 -0
- package/dist/builder/settings/general.js +58 -0
- package/dist/builder/settings/index.d.ts +4 -0
- package/dist/builder/settings/index.js +25 -0
- package/dist/builder/settings/integrations.d.ts +8 -0
- package/dist/builder/settings/integrations.js +138 -0
- package/dist/builder/settings/keys.d.ts +1 -0
- package/dist/builder/settings/keys.js +114 -0
- package/dist/builder/settings/list.d.ts +10 -0
- package/dist/builder/settings/list.js +28 -0
- package/dist/builder/settings/machines.d.ts +4 -0
- package/dist/builder/settings/machines.js +243 -0
- package/dist/builder/settings/members.d.ts +1 -0
- package/dist/builder/settings/members.js +77 -0
- package/dist/builder/settings/memory.d.ts +1 -0
- package/dist/builder/settings/memory.js +62 -0
- package/dist/builder/settings/notifications.d.ts +1 -0
- package/dist/builder/settings/notifications.js +111 -0
- package/dist/builder/settings/plan.d.ts +17 -0
- package/dist/builder/settings/plan.js +131 -0
- package/dist/builder/settings/privacy.d.ts +1 -0
- package/dist/builder/settings/privacy.js +76 -0
- package/dist/builder/settings/sections.d.ts +16 -0
- package/dist/builder/settings/sections.js +34 -0
- package/dist/builder/settings/shared.d.ts +6 -0
- package/dist/builder/settings/shared.js +58 -0
- package/dist/builder/settings/ui.d.ts +50 -0
- package/dist/builder/settings/ui.js +53 -0
- package/dist/builder/settings/usage.d.ts +1 -0
- package/dist/builder/settings/usage.js +24 -0
- package/dist/builder/shared.d.ts +26 -0
- package/dist/builder/shared.js +15 -0
- package/dist/builder/shelf.d.ts +16 -0
- package/dist/builder/shelf.js +219 -0
- package/dist/builder/side.d.ts +40 -0
- package/dist/builder/side.js +208 -0
- package/dist/builder/site.d.ts +75 -0
- package/dist/builder/site.js +138 -0
- package/dist/builder/spend.d.ts +21 -0
- package/dist/builder/spend.js +80 -0
- package/dist/builder/standing.d.ts +36 -0
- package/dist/builder/standing.js +66 -0
- package/dist/builder/suggest.d.ts +238 -0
- package/dist/builder/suggest.js +463 -0
- package/dist/builder/suggestions.d.ts +49 -0
- package/dist/builder/suggestions.js +260 -0
- package/dist/builder/summary.d.ts +60 -0
- package/dist/builder/summary.js +81 -0
- package/dist/builder/sync.d.ts +1 -0
- package/dist/builder/sync.js +187 -0
- package/dist/builder/tabs.d.ts +85 -0
- package/dist/builder/tabs.js +288 -0
- package/dist/builder/talk.d.ts +5 -0
- package/dist/builder/talk.js +108 -0
- package/dist/builder/thread.d.ts +60 -0
- package/dist/builder/thread.js +302 -0
- package/dist/builder/tools.d.ts +22 -0
- package/dist/builder/tools.js +52 -0
- package/dist/builder/transcript.d.ts +47 -0
- package/dist/builder/transcript.js +108 -0
- package/dist/builder/voice.d.ts +8 -0
- package/dist/builder/voice.js +24 -0
- package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
- package/dist/core.js +1 -0
- package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
- package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -1
- package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
- package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
- package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
- package/package.json +101 -11
- /package/{index.d.ts → dist/core.d.ts} +0 -0
- /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
import { attachGitHubMirror, linkGitHubRepo, listGitTargets, parseGitHubRepo, type GitTarget } from './git.ts';
|
|
3
|
+
export { attachGitHubMirror, linkGitHubRepo, listGitTargets, parseGitHubRepo, type GitTarget };
|
|
4
|
+
export interface Repo {
|
|
5
|
+
owner: string;
|
|
6
|
+
name: string;
|
|
7
|
+
/** `owner/name`. */
|
|
8
|
+
full_name: string;
|
|
9
|
+
private: boolean;
|
|
10
|
+
default_branch: string;
|
|
11
|
+
/** RFC 3339, or '' when GitHub did not say. */
|
|
12
|
+
pushed_at: string;
|
|
13
|
+
/** The App installation that grants access, or 0 for the person's own grant. */
|
|
14
|
+
installation_id: number;
|
|
15
|
+
/** The name it takes on the forge once brought there: `owner_name`, folded. */
|
|
16
|
+
codebase: string;
|
|
17
|
+
}
|
|
18
|
+
export interface Repos {
|
|
19
|
+
repos: Repo[];
|
|
20
|
+
next: string;
|
|
21
|
+
/** How many repositories match, across every page. */
|
|
22
|
+
total: number;
|
|
23
|
+
/** The installations that could not be read: a short list is then not the whole one. */
|
|
24
|
+
unread: string[];
|
|
25
|
+
/** Whether this answer is the person's OWN GitHub. */
|
|
26
|
+
connected: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface Branch {
|
|
29
|
+
name: string;
|
|
30
|
+
/** The sha it points at, or ''. */
|
|
31
|
+
commit: string;
|
|
32
|
+
default: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface Branches {
|
|
35
|
+
branches: Branch[];
|
|
36
|
+
next: string;
|
|
37
|
+
total: number;
|
|
38
|
+
}
|
|
39
|
+
export interface Connection {
|
|
40
|
+
/** Whether this deployment can connect anyone at all. */
|
|
41
|
+
configured: boolean;
|
|
42
|
+
connected: boolean;
|
|
43
|
+
/** The GitHub login, when connected. */
|
|
44
|
+
login: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function repo(raw: unknown): Repo;
|
|
47
|
+
export declare function branch(raw: unknown): Branch;
|
|
48
|
+
export interface RepoQuery {
|
|
49
|
+
q?: string;
|
|
50
|
+
owner?: string;
|
|
51
|
+
limit?: number;
|
|
52
|
+
after?: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function repos(t: Target, p?: RepoQuery, signal?: AbortSignal): Promise<Repos>;
|
|
55
|
+
export interface BranchQuery {
|
|
56
|
+
q?: string;
|
|
57
|
+
limit?: number;
|
|
58
|
+
after?: string;
|
|
59
|
+
}
|
|
60
|
+
export declare function branches(t: Target, owner: string, name: string, p?: BranchQuery, signal?: AbortSignal): Promise<Branches>;
|
|
61
|
+
export declare function connection(t: Target): Promise<Connection>;
|
|
62
|
+
/**
|
|
63
|
+
* Where to send the person to authorize the platform's GitHub App — github.com
|
|
64
|
+
* only. `back` is the page GitHub's return lands on; the platform keeps it only
|
|
65
|
+
* when it is a Hanzo app page.
|
|
66
|
+
*/
|
|
67
|
+
export declare function connect(t: Target, back?: string): Promise<string>;
|
|
68
|
+
/** Finish the connect GitHub's return handed this page as `grant`. */
|
|
69
|
+
export declare function complete(t: Target, grant: string): Promise<Connection>;
|
|
70
|
+
export declare function disconnect(t: Target): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Said on the window when this page changes the GitHub connection (a connect
|
|
73
|
+
* finished, a link or an App account let go), so every surface showing it
|
|
74
|
+
* reads it again: Projects' line, Settings' Integrations, and the Hanzo app's
|
|
75
|
+
* Quick setup (@hanzo/app Setup), which says it too. A name the two packages
|
|
76
|
+
* agree on, so neither imports the other.
|
|
77
|
+
*/
|
|
78
|
+
export declare const CHANGED = "hanzo:github";
|
|
79
|
+
/** Say the GitHub connection changed. */
|
|
80
|
+
export declare function changed(): void;
|
|
81
|
+
/** Run `again` each time the GitHub connection changed; the answer stops it. */
|
|
82
|
+
export declare function heard(again: () => void): () => void;
|
|
83
|
+
/** A GitHub account the platform's App is installed on, as this org sees it. */
|
|
84
|
+
export interface Installation {
|
|
85
|
+
login: string;
|
|
86
|
+
/** `Organization` or `User`. */
|
|
87
|
+
type: string;
|
|
88
|
+
/** `all` or `selected` repositories. */
|
|
89
|
+
grant: string;
|
|
90
|
+
/** This org has bound it, and GitHub still has the App installed there. */
|
|
91
|
+
connected: boolean;
|
|
92
|
+
}
|
|
93
|
+
/** The accounts this org has bound the App on. An org admin adds one through `/v1/provider/github/connect`. */
|
|
94
|
+
export declare function installations(t: Target): Promise<Installation[]>;
|
|
95
|
+
/**
|
|
96
|
+
* Whether this page reaches GitHub at all, and as whom: the person's own
|
|
97
|
+
* connection first, else the accounts the org has bound the App on. An org that
|
|
98
|
+
* installed the App (onboarding's Connect GitHub) has its repositories to sync
|
|
99
|
+
* without the person connecting their own, so it reads as connected too.
|
|
100
|
+
*/
|
|
101
|
+
export declare function linked(me: Connection, installed: Installation[]): Connection;
|
|
102
|
+
/** One repository the GitHub connection grants this organization. */
|
|
103
|
+
export interface Grant {
|
|
104
|
+
owner: string;
|
|
105
|
+
name: string;
|
|
106
|
+
/** `owner/name`, the selector the importer accepts. */
|
|
107
|
+
fullName: string;
|
|
108
|
+
private: boolean;
|
|
109
|
+
branch: string;
|
|
110
|
+
/** The name it takes on the forge once brought there. */
|
|
111
|
+
codebase: string;
|
|
112
|
+
/** On the forge: linked and landed, or held there under its codebase name. */
|
|
113
|
+
imported: boolean;
|
|
114
|
+
/** `synced`, `conflict`, `pending`, `paused`, or '' while it is not linked. */
|
|
115
|
+
status: string;
|
|
116
|
+
}
|
|
117
|
+
export interface Grants {
|
|
118
|
+
repos: Grant[];
|
|
119
|
+
/** Accounts the connection could not read. */
|
|
120
|
+
unread: string[];
|
|
121
|
+
/** The accounts the organization added (`added`), each listed even before any of its repositories is. */
|
|
122
|
+
added?: string[];
|
|
123
|
+
}
|
|
124
|
+
export interface Account {
|
|
125
|
+
name: string;
|
|
126
|
+
count: number;
|
|
127
|
+
/** Named as unread and carrying no repositories. */
|
|
128
|
+
blocked: boolean;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* One row of GET /v1/provider/github/repos (apps/provider github_index.go
|
|
132
|
+
* repoView): `owner`, `name`, `full_name`, `private`, `default_branch`,
|
|
133
|
+
* `pushed_at`, `installation_id`, `codebase`. Whether it is on the forge is not
|
|
134
|
+
* in the row — `codebase` is the name it would take, not a sign it has — so
|
|
135
|
+
* `imported` is decided by `grants` from the links and the forge.
|
|
136
|
+
*/
|
|
137
|
+
export declare function grant(raw: unknown): Grant | null;
|
|
138
|
+
/** Accounts the grant names, plus any account that could not be read or that the organization added. */
|
|
139
|
+
export declare function accounts(g: Grants): Account[];
|
|
140
|
+
/**
|
|
141
|
+
* Every repository the GitHub connection grants, every page, with whether the
|
|
142
|
+
* forge already has it: a link that has landed (GET /v1/sync, its `native`
|
|
143
|
+
* state), or a forge repository under its codebase name (GET /v1/git/repos).
|
|
144
|
+
*/
|
|
145
|
+
export declare function grants(t: Target, signal?: AbortSignal): Promise<Grants>;
|
|
146
|
+
/**
|
|
147
|
+
* The repositories this organization can bring in: `grants`, narrowed to the
|
|
148
|
+
* accounts the organization has added (`installations`, `connected`). The list
|
|
149
|
+
* is the person's own GitHub, which reaches accounts another Hanzo workspace
|
|
150
|
+
* added; the import goes through this organization's own, so it refuses every
|
|
151
|
+
* repository of those. With the organization's accounts unreadable, `grants` as
|
|
152
|
+
* it is: the import still says which it refuses.
|
|
153
|
+
*/
|
|
154
|
+
export declare function added(t: Target, signal?: AbortSignal): Promise<Grants>;
|
|
155
|
+
/** What an import queued: how many, and the name each takes on the forge, by `owner/name`. */
|
|
156
|
+
export interface Queued {
|
|
157
|
+
queued: number;
|
|
158
|
+
codebases: Record<string, string>;
|
|
159
|
+
}
|
|
160
|
+
/** Queue a mirror of the named repositories onto the forge. The names are `owner/name`. */
|
|
161
|
+
export declare function bring(t: Target, repos: string[]): Promise<Queued>;
|
|
162
|
+
/** What one issue sync did. */
|
|
163
|
+
export interface Synced {
|
|
164
|
+
repos: number;
|
|
165
|
+
issues: number;
|
|
166
|
+
created: number;
|
|
167
|
+
updated: number;
|
|
168
|
+
failed: number;
|
|
169
|
+
/** The pass stopped at its budget; syncing again continues where it stopped. */
|
|
170
|
+
truncated: boolean;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Mirror GitHub issues onto the board — open and closed, so a closed one reads as
|
|
174
|
+
* closed here too. `repo` (`name` or `owner/name`) syncs one project; empty syncs
|
|
175
|
+
* every repository the connection grants. Idempotent: a second sync updates and
|
|
176
|
+
* never duplicates, and the App's webhook keeps them live afterwards.
|
|
177
|
+
*/
|
|
178
|
+
export declare function syncIssues(t: Target, repo?: string): Promise<Synced>;
|
|
179
|
+
/** A repository created or forked on GitHub through the platform. */
|
|
180
|
+
export interface CreatedRepo {
|
|
181
|
+
full_name: string;
|
|
182
|
+
html_url: string;
|
|
183
|
+
clone_url: string;
|
|
184
|
+
default_branch: string;
|
|
185
|
+
private: boolean;
|
|
186
|
+
existing: boolean;
|
|
187
|
+
}
|
|
188
|
+
export interface CreateRepoInput {
|
|
189
|
+
name: string;
|
|
190
|
+
description?: string;
|
|
191
|
+
private?: boolean;
|
|
192
|
+
org?: string;
|
|
193
|
+
linkRepo?: string;
|
|
194
|
+
}
|
|
195
|
+
export interface ForkRepoInput {
|
|
196
|
+
/** `owner/repo`, GitHub URL, or bare repo name. */
|
|
197
|
+
repo: string;
|
|
198
|
+
org?: string;
|
|
199
|
+
name?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Create a GitHub repository via `POST /v1/provider/github/repos`.
|
|
203
|
+
* When `linkRepo` is provided, the platform also links and syncs that Hanzo Git repo to it.
|
|
204
|
+
* May throw `Refusal` with status 412 or 409 when personal GitHub user OAuth is required.
|
|
205
|
+
*/
|
|
206
|
+
export declare function createGitHubRepo(t: Target, input: CreateRepoInput): Promise<CreatedRepo>;
|
|
207
|
+
/**
|
|
208
|
+
* Fork a GitHub repository via `POST /v1/provider/github/fork`.
|
|
209
|
+
* Accepts `owner/repo`, a full GitHub URL (normalized to `owner/repo`), or a bare repo name.
|
|
210
|
+
* May throw `Refusal` with status 412 or 409 when personal GitHub user OAuth is required.
|
|
211
|
+
*/
|
|
212
|
+
export declare function forkGitHubRepo(t: Target, input: ForkRepoInput): Promise<CreatedRepo>;
|
|
213
|
+
/**
|
|
214
|
+
* True when creating or forking a GitHub repository failed because the user's
|
|
215
|
+
* personal GitHub account requires user OAuth authorization (HTTP 412 or 409).
|
|
216
|
+
*/
|
|
217
|
+
export declare function isGitHubUserOAuthRequired(err: unknown): boolean;
|
|
218
|
+
/** Resolved GitHub identity for a project backed directly by GitHub or via an outbound mirror target. */
|
|
219
|
+
export interface GitHubRepoBadgeInfo {
|
|
220
|
+
owner: string;
|
|
221
|
+
name: string;
|
|
222
|
+
fullName: string;
|
|
223
|
+
htmlUrl: string;
|
|
224
|
+
source: 'repo' | 'target' | 'link';
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Resolve a project's GitHub repository from its primary clone URL or outbound mirror targets.
|
|
228
|
+
* Returns null if the project is Hanzo Git only and not yet synced to GitHub.
|
|
229
|
+
*/
|
|
230
|
+
export declare function githubRepoFrom(repoUrl: string, targets?: readonly GitTarget[]): GitHubRepoBadgeInfo | null;
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GitHub, as the platform's GitHub App sees it for the signed-in person.
|
|
3
|
+
*
|
|
4
|
+
* GET /v1/provider/github/repos?q=&owner=&limit=&after= most recently pushed first
|
|
5
|
+
* GET /v1/provider/github/repos/{owner}/{repo}/branches?q=&limit=&after= default first
|
|
6
|
+
* GET /v1/provider/github/user the person's own connection
|
|
7
|
+
* POST /v1/provider/github/user/connect {return} → {authorizeUrl}
|
|
8
|
+
* POST /v1/provider/github/user/complete {grant} → the connection
|
|
9
|
+
* POST /v1/provider/github/user/disconnect
|
|
10
|
+
* GET /v1/provider/github/installations the accounts this org has bound the App on (`added` narrows to them)
|
|
11
|
+
* POST /v1/provider/github/issues/backfill {state, repo?} → mirror GitHub issues onto the board
|
|
12
|
+
*
|
|
13
|
+
* Paged by an opaque `after` cursor; `next` is the cursor for the page after
|
|
14
|
+
* this one, or empty on the last. Rows are read defensively: a field the
|
|
15
|
+
* platform left out is an empty value here, never `undefined` in a label.
|
|
16
|
+
*
|
|
17
|
+
* `connected` false with repositories is an org admin seeing the org's
|
|
18
|
+
* installations; false with none is the cue to connect. GitHub returns a
|
|
19
|
+
* connecting person to the page the connect named as its return (a Hanzo app
|
|
20
|
+
* page; the console's /connectors otherwise) with `?complete=github&grant=<id>`,
|
|
21
|
+
* and that page completes it (`complete`, and `landed` in ../back.ts).
|
|
22
|
+
*/
|
|
23
|
+
import { phrase } from '@hanzo/i18n';
|
|
24
|
+
import { onGitHub } from '../address.js';
|
|
25
|
+
import { call, query, Refusal, seg } from './call.js';
|
|
26
|
+
import { codebases } from './codebases.js';
|
|
27
|
+
import { attachGitHubMirror, linkGitHubRepo, listGitTargets, parseGitHubRepo } from './git.js';
|
|
28
|
+
import { links } from './links.js';
|
|
29
|
+
export { attachGitHubMirror, linkGitHubRepo, listGitTargets, parseGitHubRepo };
|
|
30
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
31
|
+
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
|
|
32
|
+
const obj = (v) => v && typeof v === 'object' ? v : {};
|
|
33
|
+
export function repo(raw) {
|
|
34
|
+
const r = obj(raw);
|
|
35
|
+
const owner = str(r.owner);
|
|
36
|
+
const name = str(r.name);
|
|
37
|
+
return {
|
|
38
|
+
owner,
|
|
39
|
+
name,
|
|
40
|
+
full_name: str(r.full_name) || (owner && name ? `${owner}/${name}` : name),
|
|
41
|
+
private: r.private === true,
|
|
42
|
+
default_branch: str(r.default_branch),
|
|
43
|
+
pushed_at: str(r.pushed_at),
|
|
44
|
+
installation_id: num(r.installation_id),
|
|
45
|
+
codebase: str(r.codebase),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function branch(raw) {
|
|
49
|
+
const b = obj(raw);
|
|
50
|
+
return { name: str(b.name), commit: str(b.commit), default: b.default === true };
|
|
51
|
+
}
|
|
52
|
+
export async function repos(t, p = {}, signal) {
|
|
53
|
+
const raw = obj(await call(t, 'GET', `/v1/provider/github/repos${query({ q: p.q?.trim(), owner: p.owner, limit: p.limit ?? 50, after: p.after })}`, undefined, { signal }));
|
|
54
|
+
return {
|
|
55
|
+
repos: (Array.isArray(raw.repos) ? raw.repos : []).map(repo).filter((r) => r.name),
|
|
56
|
+
next: str(raw.next),
|
|
57
|
+
total: num(raw.total),
|
|
58
|
+
unread: (Array.isArray(raw.unread) ? raw.unread : []).filter((x) => typeof x === 'string'),
|
|
59
|
+
connected: raw.connected === true,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export async function branches(t, owner, name, p = {}, signal) {
|
|
63
|
+
const raw = obj(await call(t, 'GET', `/v1/provider/github/repos/${seg(owner)}/${seg(name)}/branches${query({ q: p.q?.trim(), limit: p.limit ?? 50, after: p.after })}`, undefined, { signal }));
|
|
64
|
+
return {
|
|
65
|
+
branches: (Array.isArray(raw.branches) ? raw.branches : []).map(branch).filter((b) => b.name),
|
|
66
|
+
next: str(raw.next),
|
|
67
|
+
total: num(raw.total),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function own(raw) {
|
|
71
|
+
const c = obj(raw);
|
|
72
|
+
return { configured: c.configured === true, connected: c.connected === true, login: str(c.login) };
|
|
73
|
+
}
|
|
74
|
+
export async function connection(t) {
|
|
75
|
+
return own(await call(t, 'GET', '/v1/provider/github/user'));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Where to send the person to authorize the platform's GitHub App — github.com
|
|
79
|
+
* only. `back` is the page GitHub's return lands on; the platform keeps it only
|
|
80
|
+
* when it is a Hanzo app page.
|
|
81
|
+
*/
|
|
82
|
+
export async function connect(t, back) {
|
|
83
|
+
const raw = obj(await call(t, 'POST', '/v1/provider/github/user/connect', back ? { return: back } : undefined));
|
|
84
|
+
const url = str(raw.authorizeUrl);
|
|
85
|
+
if (!/^https:\/\/github\.com\//.test(url))
|
|
86
|
+
throw new Error(phrase('The platform did not name a GitHub address to connect at'));
|
|
87
|
+
return url;
|
|
88
|
+
}
|
|
89
|
+
/** Finish the connect GitHub's return handed this page as `grant`. */
|
|
90
|
+
export async function complete(t, grant) {
|
|
91
|
+
return own(await call(t, 'POST', '/v1/provider/github/user/complete', { grant }));
|
|
92
|
+
}
|
|
93
|
+
export async function disconnect(t) {
|
|
94
|
+
await call(t, 'POST', '/v1/provider/github/user/disconnect');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Said on the window when this page changes the GitHub connection (a connect
|
|
98
|
+
* finished, a link or an App account let go), so every surface showing it
|
|
99
|
+
* reads it again: Projects' line, Settings' Integrations, and the Hanzo app's
|
|
100
|
+
* Quick setup (@hanzo/app Setup), which says it too. A name the two packages
|
|
101
|
+
* agree on, so neither imports the other.
|
|
102
|
+
*/
|
|
103
|
+
export const CHANGED = 'hanzo:github';
|
|
104
|
+
/** Say the GitHub connection changed. */
|
|
105
|
+
export function changed() {
|
|
106
|
+
if (typeof window !== 'undefined')
|
|
107
|
+
window.dispatchEvent(new Event(CHANGED));
|
|
108
|
+
}
|
|
109
|
+
/** Run `again` each time the GitHub connection changed; the answer stops it. */
|
|
110
|
+
export function heard(again) {
|
|
111
|
+
window.addEventListener(CHANGED, again);
|
|
112
|
+
return () => window.removeEventListener(CHANGED, again);
|
|
113
|
+
}
|
|
114
|
+
/** The accounts this org has bound the App on. An org admin adds one through `/v1/provider/github/connect`. */
|
|
115
|
+
export async function installations(t) {
|
|
116
|
+
const raw = obj(await call(t, 'GET', '/v1/provider/github/installations'));
|
|
117
|
+
return (Array.isArray(raw.installations) ? raw.installations : [])
|
|
118
|
+
.map(obj)
|
|
119
|
+
.map((i) => ({ login: str(i.login), type: str(i.type), grant: str(i.grant), connected: i.connected === true }))
|
|
120
|
+
.filter((i) => i.login);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether this page reaches GitHub at all, and as whom: the person's own
|
|
124
|
+
* connection first, else the accounts the org has bound the App on. An org that
|
|
125
|
+
* installed the App (onboarding's Connect GitHub) has its repositories to sync
|
|
126
|
+
* without the person connecting their own, so it reads as connected too.
|
|
127
|
+
*/
|
|
128
|
+
export function linked(me, installed) {
|
|
129
|
+
if (me.connected)
|
|
130
|
+
return me;
|
|
131
|
+
const bound = installed.filter((i) => i.connected).map((i) => i.login);
|
|
132
|
+
return bound.length ? { configured: me.configured, connected: true, login: bound.join(', @') } : me;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* One row of GET /v1/provider/github/repos (apps/provider github_index.go
|
|
136
|
+
* repoView): `owner`, `name`, `full_name`, `private`, `default_branch`,
|
|
137
|
+
* `pushed_at`, `installation_id`, `codebase`. Whether it is on the forge is not
|
|
138
|
+
* in the row — `codebase` is the name it would take, not a sign it has — so
|
|
139
|
+
* `imported` is decided by `grants` from the links and the forge.
|
|
140
|
+
*/
|
|
141
|
+
export function grant(raw) {
|
|
142
|
+
const r = repo(raw);
|
|
143
|
+
if (!r.name)
|
|
144
|
+
return null;
|
|
145
|
+
const full = r.full_name;
|
|
146
|
+
const owner = r.owner || (full.includes('/') ? full.slice(0, full.indexOf('/')) : '');
|
|
147
|
+
return {
|
|
148
|
+
owner,
|
|
149
|
+
name: r.name,
|
|
150
|
+
fullName: full || (owner ? `${owner}/${r.name}` : r.name),
|
|
151
|
+
private: r.private,
|
|
152
|
+
branch: r.default_branch || 'main',
|
|
153
|
+
codebase: r.codebase,
|
|
154
|
+
imported: false,
|
|
155
|
+
status: '',
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/** Accounts the grant names, plus any account that could not be read or that the organization added. */
|
|
159
|
+
export function accounts(g) {
|
|
160
|
+
const counts = new Map();
|
|
161
|
+
for (const r of g.repos) {
|
|
162
|
+
if (!r.owner)
|
|
163
|
+
continue;
|
|
164
|
+
counts.set(r.owner, (counts.get(r.owner) ?? 0) + 1);
|
|
165
|
+
}
|
|
166
|
+
const unread = new Set(g.unread.filter(Boolean));
|
|
167
|
+
const names = new Set([...counts.keys(), ...unread]);
|
|
168
|
+
// GitHub's logins are case-blind: an added account is named once, as its repositories spell it.
|
|
169
|
+
const seen = new Set([...names].map((n) => n.toLowerCase()));
|
|
170
|
+
for (const n of g.added ?? []) {
|
|
171
|
+
if (!n || seen.has(n.toLowerCase()))
|
|
172
|
+
continue;
|
|
173
|
+
names.add(n);
|
|
174
|
+
seen.add(n.toLowerCase());
|
|
175
|
+
}
|
|
176
|
+
return [...names]
|
|
177
|
+
.sort((a, b) => a.localeCompare(b))
|
|
178
|
+
.map((name) => {
|
|
179
|
+
const count = counts.get(name) ?? 0;
|
|
180
|
+
return { name, count, blocked: unread.has(name) && count === 0 };
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* How many of the platform's pages a full read takes at most: a hundred rows
|
|
185
|
+
* each, so the twenty thousand one view holds (apps/provider github_index.go
|
|
186
|
+
* maxViewRepos). The listing is most-recently-pushed first, so a smaller bound
|
|
187
|
+
* drops whole accounts whose newest push is older than the rest: twenty pages
|
|
188
|
+
* left out a person's own account behind their organizations' 2,000 newer
|
|
189
|
+
* repositories, whatever they granted it on GitHub.
|
|
190
|
+
*/
|
|
191
|
+
const PAGES = 200;
|
|
192
|
+
/**
|
|
193
|
+
* Every repository the GitHub connection grants, every page, with whether the
|
|
194
|
+
* forge already has it: a link that has landed (GET /v1/sync, its `native`
|
|
195
|
+
* state), or a forge repository under its codebase name (GET /v1/git/repos).
|
|
196
|
+
*/
|
|
197
|
+
export async function grants(t, signal) {
|
|
198
|
+
const rows = [];
|
|
199
|
+
let unread = [];
|
|
200
|
+
let after = '';
|
|
201
|
+
for (let n = 0; n < PAGES; n++) {
|
|
202
|
+
const page = await repos(t, { limit: 100, after }, signal);
|
|
203
|
+
rows.push(...page.repos);
|
|
204
|
+
unread = page.unread;
|
|
205
|
+
if (!page.next)
|
|
206
|
+
break;
|
|
207
|
+
after = page.next;
|
|
208
|
+
}
|
|
209
|
+
const [linked, held] = await Promise.all([links(t, signal).catch(() => []), codebases(t).catch(() => [])]);
|
|
210
|
+
const state = new Map(linked.map((l) => [`${l.owner}/${l.name}`.toLowerCase(), l.status]));
|
|
211
|
+
const names = new Set(held.map((c) => c.name.toLowerCase()));
|
|
212
|
+
return {
|
|
213
|
+
repos: rows
|
|
214
|
+
.map(grant)
|
|
215
|
+
.filter((r) => r !== null)
|
|
216
|
+
.map((r) => {
|
|
217
|
+
// A link's state, '' when the forge could not be read for it; absent with no link.
|
|
218
|
+
const said = state.get(r.fullName.toLowerCase());
|
|
219
|
+
const there = names.has(r.codebase.toLowerCase());
|
|
220
|
+
return { ...r, imported: there || said === 'synced' || said === 'conflict' || said === 'paused', status: said || (there ? 'synced' : '') };
|
|
221
|
+
}),
|
|
222
|
+
unread: unread.filter(Boolean),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* The repositories this organization can bring in: `grants`, narrowed to the
|
|
227
|
+
* accounts the organization has added (`installations`, `connected`). The list
|
|
228
|
+
* is the person's own GitHub, which reaches accounts another Hanzo workspace
|
|
229
|
+
* added; the import goes through this organization's own, so it refuses every
|
|
230
|
+
* repository of those. With the organization's accounts unreadable, `grants` as
|
|
231
|
+
* it is: the import still says which it refuses.
|
|
232
|
+
*/
|
|
233
|
+
export async function added(t, signal) {
|
|
234
|
+
const [g, mine] = await Promise.all([grants(t, signal), installations(t).catch(() => null)]);
|
|
235
|
+
if (!mine)
|
|
236
|
+
return g;
|
|
237
|
+
const logins = mine.filter((i) => i.connected).map((i) => i.login);
|
|
238
|
+
const held = new Set(logins.map((l) => l.toLowerCase()));
|
|
239
|
+
const ours = (name) => held.has(name.toLowerCase());
|
|
240
|
+
return { repos: g.repos.filter((r) => ours(r.owner)), unread: g.unread.filter(ours), added: logins };
|
|
241
|
+
}
|
|
242
|
+
/** Queue a mirror of the named repositories onto the forge. The names are `owner/name`. */
|
|
243
|
+
export async function bring(t, repos) {
|
|
244
|
+
const names = repos.map((n) => n.trim()).filter(Boolean);
|
|
245
|
+
if (names.length === 0)
|
|
246
|
+
throw new Error(phrase('Choose a repository first'));
|
|
247
|
+
const raw = obj(await call(t, 'POST', '/v1/provider/github/repos/import', { repos: names }));
|
|
248
|
+
const said = Array.isArray(raw.repos) ? raw.repos : [];
|
|
249
|
+
const made = Array.isArray(raw.codebases) ? raw.codebases : [];
|
|
250
|
+
const codebases = {};
|
|
251
|
+
said.forEach((r, i) => {
|
|
252
|
+
if (typeof r === 'string' && typeof made[i] === 'string' && made[i])
|
|
253
|
+
codebases[r.toLowerCase()] = made[i];
|
|
254
|
+
});
|
|
255
|
+
return { queued: num(raw.queued), codebases };
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Mirror GitHub issues onto the board — open and closed, so a closed one reads as
|
|
259
|
+
* closed here too. `repo` (`name` or `owner/name`) syncs one project; empty syncs
|
|
260
|
+
* every repository the connection grants. Idempotent: a second sync updates and
|
|
261
|
+
* never duplicates, and the App's webhook keeps them live afterwards.
|
|
262
|
+
*/
|
|
263
|
+
export async function syncIssues(t, repo = '') {
|
|
264
|
+
const name = repo.trim();
|
|
265
|
+
const raw = obj(await call(t, 'POST', '/v1/provider/github/issues/backfill', name ? { state: 'all', repo: name } : { state: 'all' }));
|
|
266
|
+
return {
|
|
267
|
+
repos: num(raw.repos),
|
|
268
|
+
issues: num(raw.issues),
|
|
269
|
+
created: num(raw.created),
|
|
270
|
+
updated: num(raw.updated),
|
|
271
|
+
failed: num(raw.failed),
|
|
272
|
+
truncated: raw.truncated === true,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function createdRepo(raw) {
|
|
276
|
+
const r = obj(raw);
|
|
277
|
+
const full = str(r.full_name);
|
|
278
|
+
const html = str(r.html_url) || (full ? `https://github.com/${full}` : '');
|
|
279
|
+
const cloneUrl = str(r.clone_url) || (full ? `https://github.com/${full}.git` : '');
|
|
280
|
+
return {
|
|
281
|
+
full_name: full,
|
|
282
|
+
html_url: html,
|
|
283
|
+
clone_url: cloneUrl,
|
|
284
|
+
default_branch: str(r.default_branch) || 'main',
|
|
285
|
+
private: r.private === true,
|
|
286
|
+
existing: r.existing === true,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Create a GitHub repository via `POST /v1/provider/github/repos`.
|
|
291
|
+
* When `linkRepo` is provided, the platform also links and syncs that Hanzo Git repo to it.
|
|
292
|
+
* May throw `Refusal` with status 412 or 409 when personal GitHub user OAuth is required.
|
|
293
|
+
*/
|
|
294
|
+
export async function createGitHubRepo(t, input) {
|
|
295
|
+
const name = input.name.trim();
|
|
296
|
+
if (!name)
|
|
297
|
+
throw new Error(phrase('Enter a repository name'));
|
|
298
|
+
const body = { name };
|
|
299
|
+
const desc = input.description?.trim();
|
|
300
|
+
if (desc)
|
|
301
|
+
body.description = desc;
|
|
302
|
+
if (input.private !== undefined)
|
|
303
|
+
body.private = input.private;
|
|
304
|
+
const org = input.org?.trim();
|
|
305
|
+
if (org)
|
|
306
|
+
body.org = org;
|
|
307
|
+
const linkRepo = input.linkRepo?.trim();
|
|
308
|
+
if (linkRepo)
|
|
309
|
+
body.linkRepo = linkRepo;
|
|
310
|
+
return createdRepo(await call(t, 'POST', '/v1/provider/github/repos', body));
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Fork a GitHub repository via `POST /v1/provider/github/fork`.
|
|
314
|
+
* Accepts `owner/repo`, a full GitHub URL (normalized to `owner/repo`), or a bare repo name.
|
|
315
|
+
* May throw `Refusal` with status 412 or 409 when personal GitHub user OAuth is required.
|
|
316
|
+
*/
|
|
317
|
+
export async function forkGitHubRepo(t, input) {
|
|
318
|
+
const rawRepo = input.repo.trim();
|
|
319
|
+
if (!rawRepo)
|
|
320
|
+
throw new Error(phrase('Enter a GitHub repository to fork (owner/repo)'));
|
|
321
|
+
const parsed = onGitHub(rawRepo);
|
|
322
|
+
const repo = parsed ? `${parsed.owner}/${parsed.name}` : rawRepo.replace(/^\/+|\/+$/g, '').replace(/\.git$/i, '');
|
|
323
|
+
const body = { repo };
|
|
324
|
+
const org = input.org?.trim();
|
|
325
|
+
if (org)
|
|
326
|
+
body.org = org;
|
|
327
|
+
const name = input.name?.trim();
|
|
328
|
+
if (name)
|
|
329
|
+
body.name = name;
|
|
330
|
+
return createdRepo(await call(t, 'POST', '/v1/provider/github/fork', body));
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* True when creating or forking a GitHub repository failed because the user's
|
|
334
|
+
* personal GitHub account requires user OAuth authorization (HTTP 412 or 409).
|
|
335
|
+
*/
|
|
336
|
+
export function isGitHubUserOAuthRequired(err) {
|
|
337
|
+
if (err instanceof Refusal)
|
|
338
|
+
return err.status === 412 || err.status === 409;
|
|
339
|
+
if (err && typeof err === 'object' && 'status' in err) {
|
|
340
|
+
const status = err.status;
|
|
341
|
+
return status === 412 || status === 409;
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Resolve a project's GitHub repository from its primary clone URL or outbound mirror targets.
|
|
347
|
+
* Returns null if the project is Hanzo Git only and not yet synced to GitHub.
|
|
348
|
+
*/
|
|
349
|
+
export function githubRepoFrom(repoUrl, targets) {
|
|
350
|
+
const direct = repoUrl ? onGitHub(repoUrl) : null;
|
|
351
|
+
if (direct) {
|
|
352
|
+
return {
|
|
353
|
+
owner: direct.owner,
|
|
354
|
+
name: direct.name,
|
|
355
|
+
fullName: `${direct.owner}/${direct.name}`,
|
|
356
|
+
htmlUrl: `https://github.com/${direct.owner}/${direct.name}`,
|
|
357
|
+
source: 'repo',
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
for (const t of targets ?? []) {
|
|
361
|
+
const at = parseGitHubRepo(t.url);
|
|
362
|
+
if (at) {
|
|
363
|
+
return {
|
|
364
|
+
owner: at.owner,
|
|
365
|
+
name: at.name,
|
|
366
|
+
fullName: `${at.owner}/${at.name}`,
|
|
367
|
+
htmlUrl: `https://github.com/${at.owner}/${at.name}`,
|
|
368
|
+
source: 'target',
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
export declare const KINDS: readonly ['secret', 'publishable'];
|
|
3
|
+
export type Kind = (typeof KINDS)[number];
|
|
4
|
+
export interface Key {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
type: Kind;
|
|
8
|
+
/** The recognizable head, never enough to use the key. */
|
|
9
|
+
prefix: string;
|
|
10
|
+
/** The whole key: a publishable key's only. */
|
|
11
|
+
key: string;
|
|
12
|
+
/** active, expired, revoked or disabled. */
|
|
13
|
+
status: string;
|
|
14
|
+
/** `kind:name` entries; none reaches whatever its holder does. */
|
|
15
|
+
limit: string[];
|
|
16
|
+
/** When it was made, as IAM records it. */
|
|
17
|
+
created: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Minted {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
type: Kind;
|
|
23
|
+
/** The key itself. A secret one is never readable again. */
|
|
24
|
+
key: string;
|
|
25
|
+
limit: string[];
|
|
26
|
+
}
|
|
27
|
+
export declare function keys(t: Target): Promise<Key[]>;
|
|
28
|
+
/** A `kind:name` limit: a lowercase kind, a colon, and a name or `*`. */
|
|
29
|
+
export declare const LIMIT: RegExp;
|
|
30
|
+
/** The limits a person typed, split on commas and spaces; throws on the first that is not one. */
|
|
31
|
+
export declare function limits(raw: string): string[];
|
|
32
|
+
/** Create a new key beside the ones held. The answer is the only time a secret key is shown. */
|
|
33
|
+
export declare function mint(t: Target, type: Kind, name?: string, limit?: string[]): Promise<Minted>;
|
|
34
|
+
/** Revoke exactly one key, by id. Every other key keeps working. */
|
|
35
|
+
export declare function revoke(t: Target, id: string): Promise<void>;
|