@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,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The signed-in person's own profile on Hanzo IAM: the name they are shown by
|
|
3
|
+
* and their photo.
|
|
4
|
+
*
|
|
5
|
+
* PUT /v1/iam/account {displayName} → {status, data: {owner, name, displayName, avatar, …}}
|
|
6
|
+
* POST /v1/account/avatar multipart `file` → {avatar} the photo, also written to IAM
|
|
7
|
+
*
|
|
8
|
+
* Both act on the caller alone: neither request names a person. The email is a
|
|
9
|
+
* sign-in identifier and changes only through IAM's verification, never here.
|
|
10
|
+
*/
|
|
11
|
+
import { phrase } from '@hanzo/i18n';
|
|
12
|
+
import { call, headers, reason, Refusal, unwrap } from './call.js';
|
|
13
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
14
|
+
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
15
|
+
/** Save the name the person is shown by. An empty name is refused here. */
|
|
16
|
+
export async function rename(t, name) {
|
|
17
|
+
const displayName = name.trim();
|
|
18
|
+
if (!displayName)
|
|
19
|
+
throw new Error(phrase('A name cannot be empty'));
|
|
20
|
+
const p = obj(unwrap(await call(t, 'PUT', '/v1/iam/account', { displayName })));
|
|
21
|
+
return { displayName: str(p.displayName), avatar: str(p.avatar) };
|
|
22
|
+
}
|
|
23
|
+
/** The formats the platform keeps a photo in; it decides by the bytes, this only filters the picker. */
|
|
24
|
+
export const PHOTO = 'image/png,image/jpeg,image/gif,image/webp';
|
|
25
|
+
const LIMIT = 8 << 20;
|
|
26
|
+
/** Store a new photo and answer its address. */
|
|
27
|
+
export async function photo(t, file) {
|
|
28
|
+
if (!file.size)
|
|
29
|
+
throw new Error(phrase('That file is empty'));
|
|
30
|
+
if (file.size > LIMIT)
|
|
31
|
+
throw new Error(phrase('A photo is at most 8 MB'));
|
|
32
|
+
const form = new FormData();
|
|
33
|
+
form.append('file', file);
|
|
34
|
+
const res = await fetch(`${t.api}/v1/account/avatar`, { method: 'POST', headers: headers(t), body: form, cache: 'no-store' });
|
|
35
|
+
if (!res.ok)
|
|
36
|
+
throw new Refusal(res.status, (await reason(res)) || `POST /v1/account/avatar answered ${res.status}`);
|
|
37
|
+
const url = str(obj(await res.json()).avatar);
|
|
38
|
+
if (!url.startsWith('https://'))
|
|
39
|
+
throw new Refusal(502, phrase('The photo was stored without an address this page can show'));
|
|
40
|
+
return url;
|
|
41
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
export interface Project {
|
|
3
|
+
slug: string;
|
|
4
|
+
name: string;
|
|
5
|
+
/** The clone URL, or '' for a project with no repository. */
|
|
6
|
+
repo: string;
|
|
7
|
+
/** The branch pushes to which rebuild it, or ''. */
|
|
8
|
+
branch: string;
|
|
9
|
+
/**
|
|
10
|
+
* Where it stands: `building` while a project that has never served is being
|
|
11
|
+
* published, `live` once it serves, `error` when its build failed. A live
|
|
12
|
+
* project stays `live` while it is built again.
|
|
13
|
+
*/
|
|
14
|
+
status: string;
|
|
15
|
+
/** The deployed address, or '' when nothing has shipped. */
|
|
16
|
+
live: string;
|
|
17
|
+
/** `public` or `private`, or '' when the platform did not say. */
|
|
18
|
+
visibility: '' | Visibility;
|
|
19
|
+
/** The catalog template's slug, or `<org>/<slug>` of the published project, this was taken from; '' for neither. */
|
|
20
|
+
forked: string;
|
|
21
|
+
/** Unix seconds; 0 when unknown. A deploy does not move `updated`. */
|
|
22
|
+
created: number;
|
|
23
|
+
updated: number;
|
|
24
|
+
}
|
|
25
|
+
export type Visibility = 'public' | 'private';
|
|
26
|
+
/** An address the preview may frame: https, or http on loopback when the builder is local too. */
|
|
27
|
+
export declare function safe(url: string, local?: boolean): string;
|
|
28
|
+
export declare function project(raw: unknown): Project;
|
|
29
|
+
export declare function projects(t: Target): Promise<Project[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Change a project's name, who can see it, or the repository it builds from;
|
|
32
|
+
* what is not sent is left as it is.
|
|
33
|
+
*
|
|
34
|
+
* `repo` is the repository's address as a person gives it (../address.ts) and
|
|
35
|
+
* the branch whose pushes rebuild it — left out, the platform takes `main`. It
|
|
36
|
+
* is a GitHub repository, by any address GitHub hands out, and goes as its https
|
|
37
|
+
* clone address; any other is refused before anything is sent. The platform may
|
|
38
|
+
* still refuse to move a site that a repository in another account would serve
|
|
39
|
+
* from elsewhere (409), and says why.
|
|
40
|
+
*/
|
|
41
|
+
export declare function change(t: Target, slug: string, what: {
|
|
42
|
+
name?: string;
|
|
43
|
+
visibility?: Visibility;
|
|
44
|
+
repo?: {
|
|
45
|
+
url: string;
|
|
46
|
+
branch?: string;
|
|
47
|
+
};
|
|
48
|
+
}): Promise<Project>;
|
|
49
|
+
/** Delete a project. Its site stops answering and its slug is free again. */
|
|
50
|
+
export declare function remove(t: Target, slug: string): Promise<void>;
|
|
51
|
+
/** One attempt to put a project on its address, as the platform recorded it. */
|
|
52
|
+
export interface Deployment {
|
|
53
|
+
id: string;
|
|
54
|
+
/** Counts the project's deployments from 1. */
|
|
55
|
+
version: number;
|
|
56
|
+
/** `building`, `live` or `error`, as the platform said. */
|
|
57
|
+
status: string;
|
|
58
|
+
/** The revision that was built, or ''. */
|
|
59
|
+
commit: string;
|
|
60
|
+
/** What happened, in words: the build's own note, or on a failure why it failed. */
|
|
61
|
+
message: string;
|
|
62
|
+
/** Unix seconds; 0 when unknown. */
|
|
63
|
+
created: number;
|
|
64
|
+
updated: number;
|
|
65
|
+
}
|
|
66
|
+
export declare function deployment(raw: unknown): Deployment;
|
|
67
|
+
/** A project's deployments, newest first: the first says how its latest build went. */
|
|
68
|
+
export declare function deployments(t: Target, slug: string): Promise<Deployment[]>;
|
|
69
|
+
/** The repository name a project's clone URL names — the last path segment, without `.git`. */
|
|
70
|
+
export declare function name(clone: string): string;
|
|
71
|
+
/** A starter from the public catalog. */
|
|
72
|
+
export interface Template {
|
|
73
|
+
slug: string;
|
|
74
|
+
title: string;
|
|
75
|
+
category: string;
|
|
76
|
+
description: string;
|
|
77
|
+
framework: string;
|
|
78
|
+
/** The repository the starter is cut from. */
|
|
79
|
+
source: string;
|
|
80
|
+
/** The starter's own live page, or '' when it has none the preview may frame. */
|
|
81
|
+
demo: string;
|
|
82
|
+
}
|
|
83
|
+
/** The public catalog. It is reference content: no bearer, no org. */
|
|
84
|
+
export declare function templates(t: Target): Promise<Template[]>;
|
|
85
|
+
/**
|
|
86
|
+
* Take a copy of a starter: a project whose repository is the starter's own,
|
|
87
|
+
* so what opens is that template rather than a model's imitation of it. In an
|
|
88
|
+
* org whose code is in a workspace the platform made, the copy is published at
|
|
89
|
+
* once, and answers `building` until it is `live` or its build failed.
|
|
90
|
+
*/
|
|
91
|
+
export declare function fork(t: Target, slug: string): Promise<Project>;
|
|
92
|
+
/** `owner/name` from a clone URL — its last two path segments, without `.git`. */
|
|
93
|
+
export declare function address(clone: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Whether a run worked on this project's repository. A run's record can be
|
|
96
|
+
* moved into any project of the org, so a project shows only the runs on its
|
|
97
|
+
* own code — their branch is what Files, Code and Publish read.
|
|
98
|
+
*/
|
|
99
|
+
export declare function ours(runRepo: string, projectClone: string): boolean;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The org's projects: what it has built, and where each one is served.
|
|
3
|
+
*
|
|
4
|
+
* GET /v1/project → Project[]
|
|
5
|
+
* PATCH /v1/project/{slug} rename it, make it public or private, or change its repository
|
|
6
|
+
* DELETE /v1/project/{slug} delete it and take its site down
|
|
7
|
+
* GET /v1/project/{slug}/deployments → Deployment[], newest first
|
|
8
|
+
*
|
|
9
|
+
* `slug` is the one key every surface shares — the address under /dev, the
|
|
10
|
+
* site's name, the `project` a run is tagged with. A project belongs to the org,
|
|
11
|
+
* not to a person: the record names no author, so any member lists, changes and
|
|
12
|
+
* deletes it. Private is paid, and an unfunded org is refused rather than left
|
|
13
|
+
* public without being told.
|
|
14
|
+
*/
|
|
15
|
+
import { phrase } from '@hanzo/i18n';
|
|
16
|
+
import { ADDRESS, clone, onGitHub } from '../address.js';
|
|
17
|
+
import { call, seg } from './call.js';
|
|
18
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
19
|
+
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
|
|
20
|
+
const loopback = (host) => host === 'localhost' || host === '127.0.0.1';
|
|
21
|
+
/** Whether this page itself is served from loopback — local work. */
|
|
22
|
+
const here = () => typeof window !== 'undefined' && loopback(window.location.hostname);
|
|
23
|
+
/** An address the preview may frame: https, or http on loopback when the builder is local too. */
|
|
24
|
+
export function safe(url, local = here()) {
|
|
25
|
+
try {
|
|
26
|
+
const u = new URL(url);
|
|
27
|
+
if (u.protocol === 'https:')
|
|
28
|
+
return u.toString();
|
|
29
|
+
// Loopback only for a builder that is itself on loopback: a published row
|
|
30
|
+
// must not point colleagues' browsers at their own local services.
|
|
31
|
+
if (local && u.protocol === 'http:' && loopback(u.hostname))
|
|
32
|
+
return u.toString();
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
/* not an address */
|
|
36
|
+
}
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
export function project(raw) {
|
|
40
|
+
const p = (raw && typeof raw === 'object' ? raw : {});
|
|
41
|
+
const repo = (p.repo && typeof p.repo === 'object' ? p.repo : {});
|
|
42
|
+
return {
|
|
43
|
+
slug: str(p.slug),
|
|
44
|
+
name: str(p.name) || str(p.slug),
|
|
45
|
+
repo: str(repo.url),
|
|
46
|
+
branch: str(repo.branch),
|
|
47
|
+
status: str(p.status),
|
|
48
|
+
live: safe(str(p.liveUrl)),
|
|
49
|
+
visibility: p.visibility === 'public' || p.visibility === 'private' ? p.visibility : '',
|
|
50
|
+
forked: str(p.forkedFrom),
|
|
51
|
+
created: num(p.createdAt),
|
|
52
|
+
updated: num(p.updatedAt),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export async function projects(t) {
|
|
56
|
+
const raw = await call(t, 'GET', '/v1/project');
|
|
57
|
+
const rows = Array.isArray(raw) ? raw : Array.isArray(raw?.data) ? raw.data : [];
|
|
58
|
+
return rows
|
|
59
|
+
.map(project)
|
|
60
|
+
.filter((p) => p.slug)
|
|
61
|
+
.sort((a, b) => b.updated - a.updated);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Change a project's name, who can see it, or the repository it builds from;
|
|
65
|
+
* what is not sent is left as it is.
|
|
66
|
+
*
|
|
67
|
+
* `repo` is the repository's address as a person gives it (../address.ts) and
|
|
68
|
+
* the branch whose pushes rebuild it — left out, the platform takes `main`. It
|
|
69
|
+
* is a GitHub repository, by any address GitHub hands out, and goes as its https
|
|
70
|
+
* clone address; any other is refused before anything is sent. The platform may
|
|
71
|
+
* still refuse to move a site that a repository in another account would serve
|
|
72
|
+
* from elsewhere (409), and says why.
|
|
73
|
+
*/
|
|
74
|
+
export async function change(t, slug, what) {
|
|
75
|
+
const body = {};
|
|
76
|
+
if (what.name !== undefined) {
|
|
77
|
+
const n = what.name.trim();
|
|
78
|
+
if (!n)
|
|
79
|
+
throw new Error(phrase('A project needs a name'));
|
|
80
|
+
body.name = n;
|
|
81
|
+
}
|
|
82
|
+
if (what.visibility !== undefined)
|
|
83
|
+
body.visibility = what.visibility;
|
|
84
|
+
if (what.repo !== undefined) {
|
|
85
|
+
const at = onGitHub(what.repo.url);
|
|
86
|
+
if (!at)
|
|
87
|
+
throw new Error(ADDRESS);
|
|
88
|
+
const branch = what.repo.branch?.trim();
|
|
89
|
+
body.repo = branch ? { url: clone(at), branch } : { url: clone(at) };
|
|
90
|
+
}
|
|
91
|
+
return project(await call(t, 'PATCH', `/v1/project/${seg(slug)}`, body));
|
|
92
|
+
}
|
|
93
|
+
/** Delete a project. Its site stops answering and its slug is free again. */
|
|
94
|
+
export async function remove(t, slug) {
|
|
95
|
+
await call(t, 'DELETE', `/v1/project/${seg(slug)}`);
|
|
96
|
+
}
|
|
97
|
+
export function deployment(raw) {
|
|
98
|
+
const d = (raw && typeof raw === 'object' ? raw : {});
|
|
99
|
+
return {
|
|
100
|
+
id: str(d.id),
|
|
101
|
+
version: num(d.version),
|
|
102
|
+
status: str(d.status),
|
|
103
|
+
commit: str(d.commit),
|
|
104
|
+
message: str(d.message),
|
|
105
|
+
created: num(d.createdAt),
|
|
106
|
+
updated: num(d.updatedAt),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/** A project's deployments, newest first: the first says how its latest build went. */
|
|
110
|
+
export async function deployments(t, slug) {
|
|
111
|
+
const raw = await call(t, 'GET', `/v1/project/${seg(slug)}/deployments`);
|
|
112
|
+
return (Array.isArray(raw) ? raw : [])
|
|
113
|
+
.map(deployment)
|
|
114
|
+
.filter((d) => d.id)
|
|
115
|
+
.sort((a, b) => b.version - a.version);
|
|
116
|
+
}
|
|
117
|
+
/** The repository name a project's clone URL names — the last path segment, without `.git`. */
|
|
118
|
+
export function name(clone) {
|
|
119
|
+
const cut = clone.replace(/\.git$/, '').replace(/\/+$/, '');
|
|
120
|
+
return cut.slice(cut.lastIndexOf('/') + 1);
|
|
121
|
+
}
|
|
122
|
+
/** The public catalog. It is reference content: no bearer, no org. */
|
|
123
|
+
export async function templates(t) {
|
|
124
|
+
const raw = await call({ api: t.api, token: () => null, org: null }, 'GET', '/v1/templates');
|
|
125
|
+
const rows = Array.isArray(raw?.data) ? raw.data : [];
|
|
126
|
+
return rows
|
|
127
|
+
.map((r) => {
|
|
128
|
+
const o = (r && typeof r === 'object' ? r : {});
|
|
129
|
+
return {
|
|
130
|
+
slug: str(o.slug),
|
|
131
|
+
title: str(o.title) || str(o.slug),
|
|
132
|
+
category: str(o.category),
|
|
133
|
+
description: str(o.description),
|
|
134
|
+
framework: str(o.framework),
|
|
135
|
+
source: str(o.source),
|
|
136
|
+
demo: safe(str(o.demo)),
|
|
137
|
+
};
|
|
138
|
+
})
|
|
139
|
+
.filter((x) => x.slug);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Take a copy of a starter: a project whose repository is the starter's own,
|
|
143
|
+
* so what opens is that template rather than a model's imitation of it. In an
|
|
144
|
+
* org whose code is in a workspace the platform made, the copy is published at
|
|
145
|
+
* once, and answers `building` until it is `live` or its build failed.
|
|
146
|
+
*/
|
|
147
|
+
export async function fork(t, slug) {
|
|
148
|
+
return project(await call(t, 'POST', '/v1/project/fork', { slug }));
|
|
149
|
+
}
|
|
150
|
+
/** `owner/name` from a clone URL — its last two path segments, without `.git`. */
|
|
151
|
+
export function address(clone) {
|
|
152
|
+
const parts = clone.replace(/\.git$/, '').replace(/\/+$/, '').split('/');
|
|
153
|
+
return parts.length >= 2 ? `${parts[parts.length - 2]}/${parts[parts.length - 1]}` : '';
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Whether a run worked on this project's repository. A run's record can be
|
|
157
|
+
* moved into any project of the org, so a project shows only the runs on its
|
|
158
|
+
* own code — their branch is what Files, Code and Publish read.
|
|
159
|
+
*/
|
|
160
|
+
export function ours(runRepo, projectClone) {
|
|
161
|
+
if (!projectClone)
|
|
162
|
+
return true;
|
|
163
|
+
const want = address(projectClone).toLowerCase();
|
|
164
|
+
const have = runRepo.toLowerCase();
|
|
165
|
+
return have === want || (!have.includes('/') && have === want.split('/')[1]);
|
|
166
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
export interface Connector {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
/** Whether this deployment can connect it at all. */
|
|
6
|
+
available: boolean;
|
|
7
|
+
connected: boolean;
|
|
8
|
+
/** The connected account's own name: the Slack workspace, the GitHub login. */
|
|
9
|
+
account: string;
|
|
10
|
+
since: string;
|
|
11
|
+
/** Why it cannot be connected here, when it cannot. */
|
|
12
|
+
note: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function connector(raw: unknown, id?: string): Connector;
|
|
15
|
+
export declare function read(t: Target, id: string): Promise<Connector>;
|
|
16
|
+
/**
|
|
17
|
+
* The social accounts an organization connects. An automation posts text to
|
|
18
|
+
* the ones that take it; Instagram and TikTok take only images and video, and
|
|
19
|
+
* say so. `needs` is what connecting waits on while Hanzo's app with the
|
|
20
|
+
* platform is not set up. Its sentences are English and marked (`phrase`):
|
|
21
|
+
* a screen draws them through `t`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const SOCIAL: readonly {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
posts: boolean;
|
|
27
|
+
needs: string;
|
|
28
|
+
takes?: string;
|
|
29
|
+
}[];
|
|
30
|
+
/** The provider's consent page for this org; its return lands on `back` when that is a Hanzo app page. */
|
|
31
|
+
export declare function authorize(t: Target, id: string, back?: string): Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* Forget the org's connection to a provider: every account, or the one `account`
|
|
34
|
+
* names (a GitHub login). For GitHub the platform also removes its App from an
|
|
35
|
+
* account no other org uses, so connecting that account again is a fresh install.
|
|
36
|
+
*/
|
|
37
|
+
export declare function disconnect(t: Target, id: string, account?: string): Promise<void>;
|
|
38
|
+
export interface Channel {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
private: boolean;
|
|
42
|
+
/** Whether Hanzo has joined it. */
|
|
43
|
+
member: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface Channels {
|
|
46
|
+
channels: Channel[];
|
|
47
|
+
next: string;
|
|
48
|
+
}
|
|
49
|
+
export declare function channels(t: Target, cursor?: string): Promise<Channels>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The organization's connectors: a Slack workspace, the GitHub accounts the
|
|
3
|
+
* platform's GitHub App is installed on, and the social accounts automations
|
|
4
|
+
* post to.
|
|
5
|
+
*
|
|
6
|
+
* GET /v1/provider/{id} one connector and this org's connection to it
|
|
7
|
+
* POST /v1/provider/{id}/connect {return} → {authorizeUrl}: the provider's own consent page (org admin)
|
|
8
|
+
* POST /v1/provider/{id}/disconnect {account?} → forget the org's connection, or one account of it (org admin)
|
|
9
|
+
* GET /v1/provider/slack/channels the connected workspace's channels, a page at a time
|
|
10
|
+
*
|
|
11
|
+
* Connecting leaves this page once, for the provider's consent screen, and only
|
|
12
|
+
* for that provider's own host.
|
|
13
|
+
*/
|
|
14
|
+
import { phrase } from '@hanzo/i18n';
|
|
15
|
+
import { call, query, seg, Sentence } from './call.js';
|
|
16
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
17
|
+
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
18
|
+
const arr = (v) => (Array.isArray(v) ? v : []);
|
|
19
|
+
export function connector(raw, id = '') {
|
|
20
|
+
const p = obj(raw);
|
|
21
|
+
const c = obj(p.connection);
|
|
22
|
+
return {
|
|
23
|
+
id: str(p.id) || id,
|
|
24
|
+
name: str(p.name) || id,
|
|
25
|
+
available: p.available === true,
|
|
26
|
+
connected: p.connected === true,
|
|
27
|
+
account: str(c.account),
|
|
28
|
+
since: str(c.connectedAt),
|
|
29
|
+
note: str(p.note),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export async function read(t, id) {
|
|
33
|
+
return connector(await call(t, 'GET', `/v1/provider/${seg(id)}`), id);
|
|
34
|
+
}
|
|
35
|
+
/** Where each provider's consent lives. An authorize address anywhere else is refused. */
|
|
36
|
+
const CONSENT = {
|
|
37
|
+
slack: /^https:\/\/slack\.com\//,
|
|
38
|
+
github: /^https:\/\/github\.com\//,
|
|
39
|
+
x: /^https:\/\/(twitter|x)\.com\//,
|
|
40
|
+
linkedin: /^https:\/\/www\.linkedin\.com\//,
|
|
41
|
+
facebook: /^https:\/\/www\.facebook\.com\//,
|
|
42
|
+
instagram: /^https:\/\/www\.facebook\.com\//,
|
|
43
|
+
tiktok: /^https:\/\/www\.tiktok\.com\//,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The social accounts an organization connects. An automation posts text to
|
|
47
|
+
* the ones that take it; Instagram and TikTok take only images and video, and
|
|
48
|
+
* say so. `needs` is what connecting waits on while Hanzo's app with the
|
|
49
|
+
* platform is not set up. Its sentences are English and marked (`phrase`):
|
|
50
|
+
* a screen draws them through `t`.
|
|
51
|
+
*/
|
|
52
|
+
export const SOCIAL = [
|
|
53
|
+
{ id: 'x', name: 'X', posts: true, needs: phrase('X posting needs Hanzo’s X developer app with paid API access; it is not set up yet.') },
|
|
54
|
+
{ id: 'linkedin', name: 'LinkedIn', posts: true, needs: phrase('LinkedIn posting needs Hanzo’s LinkedIn app with Share on LinkedIn; it is not set up yet.') },
|
|
55
|
+
{ id: 'facebook', name: 'Facebook', posts: true, needs: phrase('Facebook Page posting needs Hanzo’s Meta app, approved by Meta App Review to publish to Pages; it is not set up yet.') },
|
|
56
|
+
{
|
|
57
|
+
id: 'instagram',
|
|
58
|
+
name: 'Instagram',
|
|
59
|
+
posts: false,
|
|
60
|
+
needs: phrase('Instagram posting needs Hanzo’s Meta app, approved by Meta App Review; it is not set up yet.'),
|
|
61
|
+
takes: phrase('Instagram takes photos and reels, not text, so automations do not post to it.'),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'tiktok',
|
|
65
|
+
name: 'TikTok',
|
|
66
|
+
posts: false,
|
|
67
|
+
needs: phrase('TikTok posting needs TikTok’s audit of Hanzo’s app; it is not set up yet.'),
|
|
68
|
+
takes: phrase('TikTok takes videos and photos, not text, so automations do not post to it.'),
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
/** The provider's consent page for this org; its return lands on `back` when that is a Hanzo app page. */
|
|
72
|
+
export async function authorize(t, id, back) {
|
|
73
|
+
const url = str(obj(await call(t, 'POST', `/v1/provider/${seg(id)}/connect`, back ? { return: back } : {})).authorizeUrl);
|
|
74
|
+
const host = CONSENT[id];
|
|
75
|
+
if (!host || !host.test(url))
|
|
76
|
+
throw new Sentence(phrase('The platform did not name a {provider} address to connect at'), { provider: id });
|
|
77
|
+
return url;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Forget the org's connection to a provider: every account, or the one `account`
|
|
81
|
+
* names (a GitHub login). For GitHub the platform also removes its App from an
|
|
82
|
+
* account no other org uses, so connecting that account again is a fresh install.
|
|
83
|
+
*/
|
|
84
|
+
export async function disconnect(t, id, account) {
|
|
85
|
+
await call(t, 'POST', `/v1/provider/${seg(id)}/disconnect`, account ? { account } : {});
|
|
86
|
+
}
|
|
87
|
+
export async function channels(t, cursor = '') {
|
|
88
|
+
const raw = obj(await call(t, 'GET', `/v1/provider/slack/channels${query({ cursor })}`));
|
|
89
|
+
return {
|
|
90
|
+
channels: arr(raw.channels)
|
|
91
|
+
.map(obj)
|
|
92
|
+
.map((c) => ({ id: str(c.id), name: str(c.name), private: c.is_private === true, member: c.is_member === true }))
|
|
93
|
+
.filter((c) => c.id),
|
|
94
|
+
next: str(raw.next_cursor),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
export type Door = 'screen' | 'terminal';
|
|
3
|
+
/** Where a sandbox is in its life. */
|
|
4
|
+
export type State = 'pending' | 'running' | 'parked' | 'error' | 'gone';
|
|
5
|
+
export interface Box {
|
|
6
|
+
id: string;
|
|
7
|
+
state: State;
|
|
8
|
+
/** When its lease ends, or a parked sandbox is retired; 0 when unknown. Unix ms. */
|
|
9
|
+
ends: number;
|
|
10
|
+
/** Why it could not come up, with state `error`. */
|
|
11
|
+
error: string;
|
|
12
|
+
}
|
|
13
|
+
/** The sandbox as it stands. One the caller no longer holds is gone. */
|
|
14
|
+
export declare function sandbox(t: Target, id: string): Promise<Box>;
|
|
15
|
+
/** Park it: its pod stops, its disk and working tree stay. */
|
|
16
|
+
export declare function park(t: Target, id: string): Promise<Box>;
|
|
17
|
+
/** Give it a pod again, under the same id and tree. */
|
|
18
|
+
export declare function wake(t: Target, id: string): Promise<Box>;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the person agrees to wake a suspended sandbox, which bills its cloud
|
|
21
|
+
* computer again: the UI's spend question (spend.tsx `useWake`). Nothing here
|
|
22
|
+
* wakes one without it.
|
|
23
|
+
*/
|
|
24
|
+
export type Wake = () => Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* What the page passes where nobody pressed anything (a door or a preview opening as the page loads, or reopening
|
|
27
|
+
* after the sandbox stopped): it never wakes one, so a remembered yes cannot wake a workspace by a page being open.
|
|
28
|
+
* The suspended state says so, beside its Wake.
|
|
29
|
+
*/
|
|
30
|
+
export declare const stay: Wake;
|
|
31
|
+
/** A shell's tmux session name: the sandbox reattaches to it when the door opens again. */
|
|
32
|
+
export declare const NAME: RegExp;
|
|
33
|
+
/** Where to frame one door, with a fresh ticket in its address. */
|
|
34
|
+
export declare function door(t: Target, id: string, which: Door, agree: Wake, session?: string): Promise<string>;
|
|
35
|
+
export interface Port {
|
|
36
|
+
port: number;
|
|
37
|
+
host: string;
|
|
38
|
+
}
|
|
39
|
+
/** What listens in the sandbox, ascending. */
|
|
40
|
+
export declare function ports(t: Target, id: string): Promise<Port[]>;
|
|
41
|
+
/**
|
|
42
|
+
* An address that opens one port in a browser: its own origin, with a single-use
|
|
43
|
+
* ticket that sets the preview's cookie and lands on its root.
|
|
44
|
+
*/
|
|
45
|
+
export declare function preview(t: Target, id: string, port: number, agree: Wake): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* Where a server started from the Preview keeps its process group and its output:
|
|
48
|
+
* under /tmp, as a run keeps its own files out of the checkout it commits.
|
|
49
|
+
*/
|
|
50
|
+
export declare const SERVE_DIR = "/tmp/hanzo-preview";
|
|
51
|
+
/**
|
|
52
|
+
* The shell that starts the app's server for the Preview, detached in a session of
|
|
53
|
+
* its own so it outlives the one command that started it. A server a run starts
|
|
54
|
+
* ends with the run (the agent's harness takes it down), so the Preview starts one
|
|
55
|
+
* again. It runs the codebase's start command when its environment names one ($1),
|
|
56
|
+
* else the package's `dev` script, or `start`, by the package manager its lockfile
|
|
57
|
+
* names, with the environment's secrets sourced as a run sources them (cloud
|
|
58
|
+
* apps/coding envPath). A server this started before is stopped first, its whole
|
|
59
|
+
* group. It prints what it started, or exits 3 saying why nothing could be.
|
|
60
|
+
*/
|
|
61
|
+
export declare const SERVE: string;
|
|
62
|
+
/** Whether the server the Preview started still runs (`up` or `down`), then its output's last lines. */
|
|
63
|
+
export declare const SERVED: string;
|
|
64
|
+
/**
|
|
65
|
+
* Start the app's server in the sandbox, detached, and answer the command it runs:
|
|
66
|
+
* `start` when the codebase's environment names one, else its package's dev script.
|
|
67
|
+
* A parked sandbox is resumed first, on the person's yes.
|
|
68
|
+
*/
|
|
69
|
+
export declare function serve(t: Target, id: string, agree: Wake, start?: string): Promise<string>;
|
|
70
|
+
export interface Served {
|
|
71
|
+
/** Whether the server the Preview started still runs. */
|
|
72
|
+
up: boolean;
|
|
73
|
+
/** The last lines it wrote. */
|
|
74
|
+
log: string;
|
|
75
|
+
}
|
|
76
|
+
/** Whether the server the Preview started still runs, and what it last wrote. */
|
|
77
|
+
export declare function served(t: Target, id: string): Promise<Served>;
|
|
78
|
+
export interface Node {
|
|
79
|
+
/** The resolved path inside the sandbox. */
|
|
80
|
+
path: string;
|
|
81
|
+
dir: boolean;
|
|
82
|
+
/** A directory's entries, bare names, sorted. */
|
|
83
|
+
names: string[];
|
|
84
|
+
/** A file's text, or '' when it is binary or past the view cap. */
|
|
85
|
+
text: string;
|
|
86
|
+
binary: boolean;
|
|
87
|
+
truncated: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** One path in the sandbox, relative to its working directory. */
|
|
90
|
+
export declare function read(t: Target, sandbox: string, path: string): Promise<Node>;
|