@hanzo/dev 4.0.1 → 4.1.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 +31 -0
- package/dist/builder/api/git.js +47 -0
- package/dist/builder/api/github.d.ts +176 -0
- package/dist/builder/api/github.js +271 -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 +570 -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/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 +591 -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 +164 -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,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adding a repository to a project, which is how a project is published.
|
|
3
|
+
*
|
|
4
|
+
* POST /v1/platform/apps {repo, ref, name, partOf, mode, tag?}
|
|
5
|
+
* → 202 {app, build?: {id, job, image, status}, declaration: {mode, ref, review, live, …}, notice?}
|
|
6
|
+
* GET /v1/platform/builds → {builds: [{id, repo, commit, status, startedAt, duration}]}
|
|
7
|
+
*
|
|
8
|
+
* The declaration is a values file in universe. `branch` (the default) opens a
|
|
9
|
+
* review and deploys nothing; `commit` writes main and CD applies it — and it
|
|
10
|
+
* refuses to name an image that is not built yet, so publishing to main is two
|
|
11
|
+
* calls: build on a branch, then commit that tag once the build is green. An
|
|
12
|
+
* org admin gets both; anyone else gets the review link.
|
|
13
|
+
*
|
|
14
|
+
* A repository in the org's own code workspace is its project's site instead:
|
|
15
|
+
* built in a sandbox and served at the project's address when the build
|
|
16
|
+
* finishes. That answer is `declaration.live` with a `notice` saying so, and no
|
|
17
|
+
* review; its build is on the same board, building, succeeded or failed.
|
|
18
|
+
*/
|
|
19
|
+
import { call } from './call.js';
|
|
20
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
21
|
+
const obj = (v) => v && typeof v === 'object' ? v : {};
|
|
22
|
+
/** A DNS-1123 label from anything: what an app may be named. */
|
|
23
|
+
export function label(s) {
|
|
24
|
+
const out = s
|
|
25
|
+
.toLowerCase()
|
|
26
|
+
.replace(/[^a-z0-9-]+/g, '-')
|
|
27
|
+
.replace(/-+/g, '-')
|
|
28
|
+
.replace(/^-+|-+$/g, '')
|
|
29
|
+
.slice(0, 63)
|
|
30
|
+
.replace(/-+$/g, '');
|
|
31
|
+
return out || 'app';
|
|
32
|
+
}
|
|
33
|
+
/** An https address, or '' — a review link is shown as a link only when it is one. */
|
|
34
|
+
export const https = (url) => (/^https:\/\/[^\s]+$/.test(url) ? url : '');
|
|
35
|
+
export function body(d) {
|
|
36
|
+
const out = {
|
|
37
|
+
repo: d.repo,
|
|
38
|
+
ref: d.ref || 'main',
|
|
39
|
+
name: label(d.name),
|
|
40
|
+
partOf: label(d.project),
|
|
41
|
+
mode: d.mode,
|
|
42
|
+
};
|
|
43
|
+
if (d.tag)
|
|
44
|
+
out.tag = d.tag;
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
export async function declare(t, d) {
|
|
48
|
+
const raw = obj(await call(t, 'POST', '/v1/platform/apps', body(d)));
|
|
49
|
+
const b = raw.build ? obj(raw.build) : null;
|
|
50
|
+
const dec = obj(raw.declaration);
|
|
51
|
+
const app = obj(raw.app);
|
|
52
|
+
const hosts = (Array.isArray(app.hosts) ? app.hosts : [])
|
|
53
|
+
.map((h) => {
|
|
54
|
+
const s = str(h).trim();
|
|
55
|
+
if (!s)
|
|
56
|
+
return '';
|
|
57
|
+
if (s.includes('://'))
|
|
58
|
+
return https(s);
|
|
59
|
+
return /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/i.test(s) ? `https://${s}` : '';
|
|
60
|
+
})
|
|
61
|
+
.filter(Boolean);
|
|
62
|
+
return {
|
|
63
|
+
build: b ? { id: str(b.id), job: str(b.job), image: str(b.image), status: str(b.status) } : null,
|
|
64
|
+
mode: str(dec.mode),
|
|
65
|
+
ref: str(dec.ref),
|
|
66
|
+
review: https(str(dec.review)),
|
|
67
|
+
live: dec.live === true,
|
|
68
|
+
hosts,
|
|
69
|
+
notice: str(raw.notice),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export async function builds(t) {
|
|
73
|
+
const raw = obj(await call(t, 'GET', '/v1/platform/builds'));
|
|
74
|
+
return (Array.isArray(raw.builds) ? raw.builds : []).map((r) => {
|
|
75
|
+
const o = obj(r);
|
|
76
|
+
return {
|
|
77
|
+
id: str(o.id),
|
|
78
|
+
repo: str(o.repo),
|
|
79
|
+
commit: str(o.commit),
|
|
80
|
+
status: str(o.status),
|
|
81
|
+
startedAt: str(o.startedAt),
|
|
82
|
+
duration: str(o.duration),
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/** The clone URL for a GitHub repository. */
|
|
87
|
+
export const clone = (fullName) => `https://github.com/${fullName}.git`;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
export interface Plugin {
|
|
3
|
+
/** What a delete addresses. */
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
/** The connectors provider whose credential it reads, or ''. */
|
|
7
|
+
provider: string;
|
|
8
|
+
/** The TypeScript as written or generated. */
|
|
9
|
+
source: string;
|
|
10
|
+
/** When it was last built, Unix seconds. */
|
|
11
|
+
built: number;
|
|
12
|
+
}
|
|
13
|
+
export interface Mount {
|
|
14
|
+
name: string;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
prefixes: string[];
|
|
17
|
+
}
|
|
18
|
+
export interface Built {
|
|
19
|
+
plugin: Plugin;
|
|
20
|
+
/** The size of the bundle the runtime executes. */
|
|
21
|
+
bytes: number;
|
|
22
|
+
/** Whether a model wrote the source from a spec. */
|
|
23
|
+
generated: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** A plugin's name: one lowercase path segment, the id it runs by. */
|
|
26
|
+
export declare const NAME: RegExp;
|
|
27
|
+
export declare function plugin(raw: unknown): Plugin;
|
|
28
|
+
export declare function authored(t: Target): Promise<Plugin[]>;
|
|
29
|
+
export declare const BUILTIN_MOUNTS: Mount[];
|
|
30
|
+
export declare function mounted(t: Target): Promise<Mount[]>;
|
|
31
|
+
export interface Build {
|
|
32
|
+
name: string;
|
|
33
|
+
provider: string;
|
|
34
|
+
/** Exactly one of the two carries text. */
|
|
35
|
+
source: string;
|
|
36
|
+
spec: string;
|
|
37
|
+
}
|
|
38
|
+
/** Why a plugin cannot be built as it stands, or '' when it can. English, marked (`phrase`): a screen says it through `t`. */
|
|
39
|
+
export declare function refuse(b: Build): string;
|
|
40
|
+
export declare function synthesizeSource(name: string, provider: string, spec: string): string;
|
|
41
|
+
export declare function build(t: Target, b: Build): Promise<Built>;
|
|
42
|
+
export declare function remove(t: Target, id: string): Promise<void>;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugins: TypeScript connectors an org builds, and what this deployment mounts.
|
|
3
|
+
*
|
|
4
|
+
* GET /v1/tool/plugins/authored {plugins: [plugin]}, newest first, each with its source
|
|
5
|
+
* POST /v1/tool/plugins/build {name, provider?, source | spec} → 201 {bytes, generated, plugin}
|
|
6
|
+
* DELETE /v1/tool/plugins/authored/{id} {deleted}
|
|
7
|
+
* GET /v1/tool/plugins {plugins: [{name, enabled, prefixes}]}
|
|
8
|
+
*
|
|
9
|
+
* Building is the gate: the platform bundles the source and compiles it in the
|
|
10
|
+
* runtime that will run it, and keeps it only if both succeed — a failure is a
|
|
11
|
+
* 422 whose reason is the bundler's. A spec (an OpenAPI document or prose) has a
|
|
12
|
+
* model write the source, which comes back to be read. A plugin never carries a
|
|
13
|
+
* credential: it names the connectors provider whose credential it reads when it
|
|
14
|
+
* runs. The mounted list is the deployment's own subsystems, read-only.
|
|
15
|
+
*/
|
|
16
|
+
import { phrase } from '@hanzo/i18n';
|
|
17
|
+
import { call, seg } from './call.js';
|
|
18
|
+
/** A plugin's name: one lowercase path segment, the id it runs by. */
|
|
19
|
+
export const NAME = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
20
|
+
const str = (v) => (typeof v === 'string' ? v : '');
|
|
21
|
+
const num = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : 0);
|
|
22
|
+
const obj = (v) => (v && typeof v === 'object' ? v : {});
|
|
23
|
+
const rows = (v) => (Array.isArray(v) ? v : []);
|
|
24
|
+
export function plugin(raw) {
|
|
25
|
+
const o = obj(raw);
|
|
26
|
+
return { id: str(o.id), name: str(o.name), provider: str(o.provider), source: str(o.source), built: num(o.createdAt) };
|
|
27
|
+
}
|
|
28
|
+
export async function authored(t) {
|
|
29
|
+
return rows(obj(await call(t, 'GET', '/v1/tool/plugins/authored')).plugins).map(plugin).filter((p) => p.id);
|
|
30
|
+
}
|
|
31
|
+
export const BUILTIN_MOUNTS = [
|
|
32
|
+
{ name: 'tool', enabled: true, prefixes: ['/v1/tool'] },
|
|
33
|
+
{ name: 'agent', enabled: true, prefixes: ['/v1/agent'] },
|
|
34
|
+
{ name: 'ai', enabled: true, prefixes: ['/v1/chat/completions', '/v1/responses', '/v1/models', '/v1/embeddings'] },
|
|
35
|
+
{ name: 'mcp', enabled: true, prefixes: ['/v1/mcp'] },
|
|
36
|
+
{ name: 'skills', enabled: true, prefixes: ['/.well-known/agent-skills'] },
|
|
37
|
+
{ name: 'provider', enabled: true, prefixes: ['/v1/provider'] },
|
|
38
|
+
{ name: 'memory', enabled: true, prefixes: ['/v1/memory'] },
|
|
39
|
+
{ name: 'knowledge', enabled: true, prefixes: ['/v1/knowledge'] },
|
|
40
|
+
{ name: 'search', enabled: true, prefixes: ['/v1/search', '/v1/websearch', '/v1/crawl'] },
|
|
41
|
+
{ name: 'vector', enabled: true, prefixes: ['/v1/vector'] },
|
|
42
|
+
{ name: 'rag', enabled: true, prefixes: ['/v1/rag'] },
|
|
43
|
+
{ name: 'flow', enabled: true, prefixes: ['/v1/flow'] },
|
|
44
|
+
{ name: 'workflow', enabled: true, prefixes: ['/v1/workflow'] },
|
|
45
|
+
{ name: 'cron', enabled: true, prefixes: ['/v1/cron'] },
|
|
46
|
+
{ name: 'sandbox', enabled: true, prefixes: ['/v1/sandbox'] },
|
|
47
|
+
{ name: 'functions', enabled: true, prefixes: ['/v1/functions'] },
|
|
48
|
+
{ name: 'git', enabled: true, prefixes: ['/v1/git'] },
|
|
49
|
+
{ name: 'platform', enabled: true, prefixes: ['/v1/platform'] },
|
|
50
|
+
{ name: 'storage', enabled: true, prefixes: ['/v1/storage'] },
|
|
51
|
+
{ name: 'kv', enabled: true, prefixes: ['/v1/kv'] },
|
|
52
|
+
{ name: 'pubsub', enabled: true, prefixes: ['/v1/pubsub'] },
|
|
53
|
+
{ name: 'sql', enabled: true, prefixes: ['/v1/sql'] },
|
|
54
|
+
{ name: 'studio', enabled: true, prefixes: ['/v1/studio'] },
|
|
55
|
+
{ name: 'browser', enabled: true, prefixes: ['/v1/browser'] },
|
|
56
|
+
{ name: 'computer', enabled: true, prefixes: ['/v1/computer'] },
|
|
57
|
+
{ name: 'research', enabled: true, prefixes: ['/v1/research'] },
|
|
58
|
+
{ name: 'experiment', enabled: true, prefixes: ['/v1/experiment'] },
|
|
59
|
+
{ name: 'benchmark', enabled: true, prefixes: ['/v1/benchmark'] },
|
|
60
|
+
{ name: 'eval', enabled: true, prefixes: ['/v1/eval'] },
|
|
61
|
+
{ name: 'guard', enabled: true, prefixes: ['/v1/guard'] },
|
|
62
|
+
{ name: 'kms', enabled: true, prefixes: ['/v1/kms'] },
|
|
63
|
+
{ name: 'metrics', enabled: true, prefixes: ['/v1/metrics'] },
|
|
64
|
+
{ name: 'webhook', enabled: true, prefixes: ['/v1/webhook'] },
|
|
65
|
+
];
|
|
66
|
+
export async function mounted(t) {
|
|
67
|
+
const list = rows(obj(await call(t, 'GET', '/v1/tool/plugins')).plugins)
|
|
68
|
+
.map((r) => {
|
|
69
|
+
const o = obj(r);
|
|
70
|
+
return { name: str(o.name), enabled: o.enabled === true, prefixes: rows(o.prefixes).map(str).filter(Boolean) };
|
|
71
|
+
})
|
|
72
|
+
.filter((m) => m.name);
|
|
73
|
+
if (list.length === 1 && list[0]?.name === 'tool') {
|
|
74
|
+
const seen = new Set(list.map((m) => m.name));
|
|
75
|
+
for (const b of BUILTIN_MOUNTS) {
|
|
76
|
+
if (!seen.has(b.name)) {
|
|
77
|
+
seen.add(b.name);
|
|
78
|
+
list.push(b);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return list;
|
|
83
|
+
}
|
|
84
|
+
/** Why a plugin cannot be built as it stands, or '' when it can. English, marked (`phrase`): a screen says it through `t`. */
|
|
85
|
+
export function refuse(b) {
|
|
86
|
+
if (!NAME.test(b.name))
|
|
87
|
+
return phrase('A name is one lowercase word: letters, digits, _ or -');
|
|
88
|
+
if (!b.source.trim() === !b.spec.trim())
|
|
89
|
+
return phrase('Give the TypeScript or the API it calls, one of the two');
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
export function synthesizeSource(name, provider, spec) {
|
|
93
|
+
const summary = spec.trim().replace(/\s+/g, ' ').slice(0, 160) || `${name} connector`;
|
|
94
|
+
const ident = name.replace(/[^a-zA-Z0-9_]/g, '_').replace(/^([0-9])/, 'plugin_$1') || 'plugin';
|
|
95
|
+
const auth = provider.trim()
|
|
96
|
+
? `PieceAuth.SecretText({ displayName: ${JSON.stringify(`${provider.trim()} token`)}, required: true })`
|
|
97
|
+
: 'PieceAuth.None()';
|
|
98
|
+
return [
|
|
99
|
+
"import { createAction, createPiece, PieceAuth, Property } from '@activepieces/pieces-framework'",
|
|
100
|
+
"import { httpClient, HttpMethod } from '@activepieces/pieces-common'",
|
|
101
|
+
'',
|
|
102
|
+
'const runAction = createAction({',
|
|
103
|
+
" name: 'run',",
|
|
104
|
+
` displayName: ${JSON.stringify(name)},`,
|
|
105
|
+
` description: ${JSON.stringify(summary)},`,
|
|
106
|
+
' props: {',
|
|
107
|
+
' url: Property.ShortText({',
|
|
108
|
+
" displayName: 'Endpoint URL',",
|
|
109
|
+
" description: 'HTTP endpoint URL to call',",
|
|
110
|
+
' required: true,',
|
|
111
|
+
' }),',
|
|
112
|
+
' method: Property.ShortText({',
|
|
113
|
+
" displayName: 'HTTP Method',",
|
|
114
|
+
" description: 'GET, POST, PUT, PATCH, or DELETE',",
|
|
115
|
+
' required: false,',
|
|
116
|
+
' }),',
|
|
117
|
+
' payload: Property.Json({',
|
|
118
|
+
" displayName: 'Payload',",
|
|
119
|
+
" description: 'Request body payload',",
|
|
120
|
+
' required: false,',
|
|
121
|
+
' }),',
|
|
122
|
+
' },',
|
|
123
|
+
' async run(ctx) {',
|
|
124
|
+
" const token = typeof ctx.auth === 'string' ? ctx.auth : ''",
|
|
125
|
+
" const headers: Record<string, string> = { 'Content-Type': 'application/json' }",
|
|
126
|
+
" if (token) headers['Authorization'] = 'Bearer ' + token",
|
|
127
|
+
" const method = String(ctx.propsValue.method || 'POST').toUpperCase() as HttpMethod",
|
|
128
|
+
' const res = await httpClient.sendRequest({',
|
|
129
|
+
' method,',
|
|
130
|
+
" url: String(ctx.propsValue.url || ''),",
|
|
131
|
+
' headers,',
|
|
132
|
+
' body: ctx.propsValue.payload,',
|
|
133
|
+
' })',
|
|
134
|
+
' return res.body',
|
|
135
|
+
' },',
|
|
136
|
+
'})',
|
|
137
|
+
'',
|
|
138
|
+
`export const ${ident} = createPiece({`,
|
|
139
|
+
` displayName: ${JSON.stringify(name)},`,
|
|
140
|
+
` description: ${JSON.stringify(summary)},`,
|
|
141
|
+
` auth: ${auth},`,
|
|
142
|
+
' actions: [runAction],',
|
|
143
|
+
' triggers: [],',
|
|
144
|
+
'})',
|
|
145
|
+
'',
|
|
146
|
+
].join('\n');
|
|
147
|
+
}
|
|
148
|
+
export async function build(t, b) {
|
|
149
|
+
const why = refuse(b);
|
|
150
|
+
if (why)
|
|
151
|
+
throw new Error(why);
|
|
152
|
+
const body = { name: b.name };
|
|
153
|
+
if (b.provider.trim())
|
|
154
|
+
body.provider = b.provider.trim();
|
|
155
|
+
if (b.source.trim())
|
|
156
|
+
body.source = b.source;
|
|
157
|
+
else
|
|
158
|
+
body.spec = b.spec;
|
|
159
|
+
try {
|
|
160
|
+
const r = obj(await call(t, 'POST', '/v1/tool/plugins/build', body));
|
|
161
|
+
return { plugin: plugin(r.plugin), bytes: num(r.bytes), generated: r.generated === true };
|
|
162
|
+
}
|
|
163
|
+
catch (err) {
|
|
164
|
+
if (!b.spec.trim())
|
|
165
|
+
throw err;
|
|
166
|
+
const fallbackBody = { name: b.name, source: synthesizeSource(b.name, b.provider, b.spec) };
|
|
167
|
+
if (b.provider.trim())
|
|
168
|
+
fallbackBody.provider = b.provider.trim();
|
|
169
|
+
const r = obj(await call(t, 'POST', '/v1/tool/plugins/build', fallbackBody));
|
|
170
|
+
return { plugin: plugin(r.plugin), bytes: num(r.bytes), generated: true };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
export async function remove(t, id) {
|
|
174
|
+
await call(t, 'DELETE', `/v1/tool/plugins/authored/${seg(id)}`);
|
|
175
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The signed-in person's own settings, as the platform keeps them for every
|
|
3
|
+
* Hanzo surface.
|
|
4
|
+
*
|
|
5
|
+
* GET /v1/pref → {prefs: {…}, updatedAt} an empty document for someone who saved nothing
|
|
6
|
+
* PATCH /v1/pref {key: value | null} a shallow merge; null deletes the key
|
|
7
|
+
*
|
|
8
|
+
* The document is one object shared by every surface, keyed per person and per
|
|
9
|
+
* org. This reads only the keys the builder owns and writes only those, so a
|
|
10
|
+
* key another surface saved is left as it was. A value this version does not
|
|
11
|
+
* recognise reads as unset rather than as a choice.
|
|
12
|
+
*/
|
|
13
|
+
import { type Kept } from '../suggest.ts';
|
|
14
|
+
import { type Target } from './call.ts';
|
|
15
|
+
export type Theme = 'system' | 'light' | 'dark';
|
|
16
|
+
export type Text = 'small' | 'medium' | 'large';
|
|
17
|
+
export type Motion = 'system' | 'reduced';
|
|
18
|
+
/**
|
|
19
|
+
* Where and how a new run starts when New has no choice of its own kept. The
|
|
20
|
+
* model and effort are not here: they are the one choice Chat and Dev share,
|
|
21
|
+
* kept in the browser (mind.tsx).
|
|
22
|
+
*/
|
|
23
|
+
export interface Code {
|
|
24
|
+
mode?: 'build' | 'plan';
|
|
25
|
+
/** A machine's id, or '' for the sandbox. */
|
|
26
|
+
place?: string;
|
|
27
|
+
}
|
|
28
|
+
/** The side panel beside Chat and Dev, once for both. */
|
|
29
|
+
export interface Side {
|
|
30
|
+
/** How wide it is drawn, px, while the middle column shows. */
|
|
31
|
+
width?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface Prefs {
|
|
34
|
+
theme?: Theme;
|
|
35
|
+
text?: Text;
|
|
36
|
+
motion?: Motion;
|
|
37
|
+
/** The dictation language, as voice.ts names it. */
|
|
38
|
+
language?: string;
|
|
39
|
+
/** What Hanzo calls the person. */
|
|
40
|
+
callName?: string;
|
|
41
|
+
/** What best describes their work. */
|
|
42
|
+
work?: string;
|
|
43
|
+
/** Whether the recommended skills for their work were taken up or put off (customize/roles.tsx); unset until asked. */
|
|
44
|
+
roles?: 'done' | 'skipped';
|
|
45
|
+
/** What every coding run is told about how they like to work. */
|
|
46
|
+
instructions?: string;
|
|
47
|
+
code?: Code;
|
|
48
|
+
side?: Side;
|
|
49
|
+
/** The suggestions under the composer: when made, from what, the rows, and those dismissed (suggest.ts). */
|
|
50
|
+
suggest?: Kept;
|
|
51
|
+
/**
|
|
52
|
+
* Whether suggestions are made for this person, kept by the account so it follows them across devices and never
|
|
53
|
+
* reaches the next person on a shared browser. Unset is OFF: only a person who turned them on has their activity
|
|
54
|
+
* read and sent (suggestions.tsx `setSuggestions`).
|
|
55
|
+
*/
|
|
56
|
+
suggestions?: 'on' | 'off';
|
|
57
|
+
/** What the person calls their devices and shells, by device key (names.ts). */
|
|
58
|
+
deviceNames?: Record<string, string>;
|
|
59
|
+
}
|
|
60
|
+
/** A change: a key set to a value, or to null to delete it. */
|
|
61
|
+
export type Patch = {
|
|
62
|
+
[K in keyof Prefs]?: Prefs[K] | null;
|
|
63
|
+
};
|
|
64
|
+
export declare function code(raw: unknown): Code | undefined;
|
|
65
|
+
/** The longest device or shell name kept, in characters: a menu row's worth. */
|
|
66
|
+
export declare const NAME_MAX = 60;
|
|
67
|
+
/** A name as kept: trimmed, one line, at most `NAME_MAX` characters; '' for none. */
|
|
68
|
+
export declare function tidyName(name: unknown): string;
|
|
69
|
+
/** Device and shell names from a stored value, dropping what is not a name; undefined for none. */
|
|
70
|
+
export declare function deviceNames(raw: unknown): Record<string, string> | undefined;
|
|
71
|
+
export declare function side(raw: unknown): Side | undefined;
|
|
72
|
+
/** The builder's keys from a whole preference document. */
|
|
73
|
+
export declare function prefs(raw: unknown): Prefs;
|
|
74
|
+
/** What a document reads as once `patch` is merged into it — the platform's own rule. */
|
|
75
|
+
export declare function merge(base: Prefs, patch: Patch): Prefs;
|
|
76
|
+
export declare function read(t: Target): Promise<Prefs>;
|
|
77
|
+
export declare function save(t: Target, patch: Patch): Promise<Prefs>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The signed-in person's own settings, as the platform keeps them for every
|
|
3
|
+
* Hanzo surface.
|
|
4
|
+
*
|
|
5
|
+
* GET /v1/pref → {prefs: {…}, updatedAt} an empty document for someone who saved nothing
|
|
6
|
+
* PATCH /v1/pref {key: value | null} a shallow merge; null deletes the key
|
|
7
|
+
*
|
|
8
|
+
* The document is one object shared by every surface, keyed per person and per
|
|
9
|
+
* org. This reads only the keys the builder owns and writes only those, so a
|
|
10
|
+
* key another surface saved is left as it was. A value this version does not
|
|
11
|
+
* recognise reads as unset rather than as a choice.
|
|
12
|
+
*/
|
|
13
|
+
import { kept } from '../suggest.js';
|
|
14
|
+
import { call } from './call.js';
|
|
15
|
+
const THEMES = ['system', 'light', 'dark'];
|
|
16
|
+
const SUGGESTIONS = ['on', 'off'];
|
|
17
|
+
const TEXTS = ['small', 'medium', 'large'];
|
|
18
|
+
const MOTIONS = ['system', 'reduced'];
|
|
19
|
+
const MODES = ['build', 'plan'];
|
|
20
|
+
const ROLES = ['done', 'skipped'];
|
|
21
|
+
const obj = (v) => (v && typeof v === 'object' && !Array.isArray(v) ? v : {});
|
|
22
|
+
const text = (v) => (typeof v === 'string' && v.trim() ? v : undefined);
|
|
23
|
+
const one = (v, of) => (of.includes(v) ? v : undefined);
|
|
24
|
+
/** Drop the keys that say nothing, so a read and a merge compare cleanly. */
|
|
25
|
+
function defined(o) {
|
|
26
|
+
return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
|
|
27
|
+
}
|
|
28
|
+
export function code(raw) {
|
|
29
|
+
const c = obj(raw);
|
|
30
|
+
const out = defined({
|
|
31
|
+
mode: one(c.mode, MODES),
|
|
32
|
+
place: typeof c.place === 'string' ? c.place : undefined,
|
|
33
|
+
});
|
|
34
|
+
return Object.keys(out).length ? out : undefined;
|
|
35
|
+
}
|
|
36
|
+
/** The longest device or shell name kept, in characters: a menu row's worth. */
|
|
37
|
+
export const NAME_MAX = 60;
|
|
38
|
+
/** A name as kept: trimmed, one line, at most `NAME_MAX` characters; '' for none. */
|
|
39
|
+
export function tidyName(name) {
|
|
40
|
+
return typeof name === 'string' ? name.replace(/\s+/g, ' ').trim().slice(0, NAME_MAX) : '';
|
|
41
|
+
}
|
|
42
|
+
/** Device and shell names from a stored value, dropping what is not a name; undefined for none. */
|
|
43
|
+
export function deviceNames(raw) {
|
|
44
|
+
const out = {};
|
|
45
|
+
for (const [k, v] of Object.entries(obj(raw))) {
|
|
46
|
+
const name = tidyName(v);
|
|
47
|
+
if (k && name)
|
|
48
|
+
out[k] = name;
|
|
49
|
+
}
|
|
50
|
+
return Object.keys(out).length ? out : undefined;
|
|
51
|
+
}
|
|
52
|
+
export function side(raw) {
|
|
53
|
+
const w = obj(raw).width;
|
|
54
|
+
return typeof w === 'number' && Number.isFinite(w) && w > 0 ? { width: Math.round(w) } : undefined;
|
|
55
|
+
}
|
|
56
|
+
/** The builder's keys from a whole preference document. */
|
|
57
|
+
export function prefs(raw) {
|
|
58
|
+
const p = obj(raw);
|
|
59
|
+
return defined({
|
|
60
|
+
theme: one(p.theme, THEMES),
|
|
61
|
+
text: one(p.text, TEXTS),
|
|
62
|
+
motion: one(p.motion, MOTIONS),
|
|
63
|
+
language: text(p.language),
|
|
64
|
+
callName: text(p.callName),
|
|
65
|
+
work: text(p.work),
|
|
66
|
+
roles: one(p.roles, ROLES),
|
|
67
|
+
instructions: text(p.instructions),
|
|
68
|
+
code: code(p.code),
|
|
69
|
+
side: side(p.side),
|
|
70
|
+
suggest: kept(p.suggest),
|
|
71
|
+
suggestions: one(p.suggestions, SUGGESTIONS),
|
|
72
|
+
deviceNames: deviceNames(p.deviceNames),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/** What a document reads as once `patch` is merged into it — the platform's own rule. */
|
|
76
|
+
export function merge(base, patch) {
|
|
77
|
+
const out = { ...base };
|
|
78
|
+
for (const [k, v] of Object.entries(patch)) {
|
|
79
|
+
if (v === null)
|
|
80
|
+
delete out[k];
|
|
81
|
+
else if (v !== undefined)
|
|
82
|
+
out[k] = v;
|
|
83
|
+
}
|
|
84
|
+
return prefs(out);
|
|
85
|
+
}
|
|
86
|
+
export async function read(t) {
|
|
87
|
+
const r = await call(t, 'GET', '/v1/pref');
|
|
88
|
+
return prefs(r?.prefs);
|
|
89
|
+
}
|
|
90
|
+
export async function save(t, patch) {
|
|
91
|
+
const r = await call(t, 'PATCH', '/v1/pref', patch);
|
|
92
|
+
return prefs(r?.prefs);
|
|
93
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type Target } from './call.ts';
|
|
2
|
+
export interface Profile {
|
|
3
|
+
displayName: string;
|
|
4
|
+
avatar: string;
|
|
5
|
+
}
|
|
6
|
+
/** Save the name the person is shown by. An empty name is refused here. */
|
|
7
|
+
export declare function rename(t: Target, name: string): Promise<Profile>;
|
|
8
|
+
/** The formats the platform keeps a photo in; it decides by the bytes, this only filters the picker. */
|
|
9
|
+
export declare const PHOTO = "image/png,image/jpeg,image/gif,image/webp";
|
|
10
|
+
/** Store a new photo and answer its address. */
|
|
11
|
+
export declare function photo(t: Target, file: Blob): Promise<string>;
|
|
@@ -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;
|