@engenty/wizards-runtime 0.13.0 → 0.14.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/apps/runtime/dist/agents/architect.js +8 -7
- package/apps/runtime/dist/agents/goose-connections.js +82 -0
- package/apps/runtime/dist/agents/space-agent.js +9 -2
- package/apps/runtime/dist/agents/studio-assistant.js +101 -67
- package/apps/runtime/dist/agents/website.js +1 -1
- package/apps/runtime/dist/app.js +17 -1
- package/apps/runtime/dist/assistant/knows.js +6 -5
- package/apps/runtime/dist/authoring/guide.js +25 -5
- package/apps/runtime/dist/broker/account.js +166 -0
- package/apps/runtime/dist/broker/call.js +417 -0
- package/apps/runtime/dist/broker/caller.js +10 -0
- package/apps/runtime/dist/broker/grant.js +152 -0
- package/apps/runtime/dist/broker/host.js +51 -0
- package/apps/runtime/dist/broker/index.js +8 -0
- package/apps/runtime/dist/broker/kept.js +31 -0
- package/apps/runtime/dist/broker/log.js +240 -0
- package/apps/runtime/dist/broker/registry.js +9 -0
- package/apps/runtime/dist/broker/rwx.js +367 -0
- package/apps/runtime/dist/broker/send.js +189 -0
- package/apps/runtime/dist/connectors/builtin.js +1 -1
- package/apps/runtime/dist/connectors/external.js +38 -37
- package/apps/runtime/dist/connectors/index.js +30 -91
- package/apps/runtime/dist/connectors/mail.js +0 -8
- package/apps/runtime/dist/connectors/person-sign-ins.js +73 -0
- package/apps/runtime/dist/connectors/plugin-connections.js +65 -92
- package/apps/runtime/dist/connectors/smtp.js +1 -1
- package/apps/runtime/dist/connectors/space-connections.js +436 -0
- package/apps/runtime/dist/db/adopt.js +3 -3
- package/apps/runtime/dist/db/client.js +9 -0
- package/apps/runtime/dist/db/live-triggers.js +65 -23
- package/apps/runtime/dist/db/migrations/tenant/0027_work_chats.sql +52 -0
- package/apps/runtime/dist/db/migrations/tenant/0028_chat_approvals.sql +17 -0
- package/apps/runtime/dist/db/migrations/tenant/0029_work_chats_live.sql +49 -0
- package/apps/runtime/dist/db/migrations/tenant/0031_space.sql +624 -0
- package/apps/runtime/dist/db/migrations/tenant/0032_rwx_rule.sql +18 -0
- package/apps/runtime/dist/db/migrations/tenant/0033_broker_log.sql +23 -0
- package/apps/runtime/dist/db/migrations/tenant/0034_space_connection.sql +35 -0
- package/apps/runtime/dist/db/migrations/tenant/0035_run_grant.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0036_approval_held_for.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/0037_ways_out.sql +5 -0
- package/apps/runtime/dist/db/migrations/tenant/0038_heard.sql +11 -0
- package/apps/runtime/dist/db/migrations/tenant/0039_members_studio.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +383 -155
- package/apps/runtime/dist/db/migrations/tenant/meta/0028_snapshot.json +4468 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0029_snapshot.json +4475 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0030_snapshot.json +4629 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0031_snapshot.json +4629 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0032_snapshot.json +4757 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0033_snapshot.json +5039 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0034_snapshot.json +5022 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0035_snapshot.json +5029 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0036_snapshot.json +5037 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0037_snapshot.json +5076 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0038_snapshot.json +5145 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0039_snapshot.json +5153 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +86 -2
- package/apps/runtime/dist/db/schema.js +295 -72
- package/apps/runtime/dist/docs/dev/architecture.md +215 -0
- package/apps/runtime/dist/docs/dev/broker.md +298 -0
- package/apps/runtime/dist/docs/dev/index.md +5 -1
- package/apps/runtime/dist/docs/dev/integration/index.md +2 -0
- package/apps/runtime/dist/docs/dev/meta.json +3 -0
- package/apps/runtime/dist/docs/dev/plugins/connections.md +8 -5
- package/apps/runtime/dist/docs/dev/plugins/events.md +1 -1
- package/apps/runtime/dist/docs/dev/plugins/examples.md +1 -0
- package/apps/runtime/dist/docs/dev/plugins/index.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/reference.md +3 -2
- package/apps/runtime/dist/docs/dev/plugins/space.md +16 -6
- package/apps/runtime/dist/docs/dev/plugins/studio.md +2 -2
- package/apps/runtime/dist/docs/dev/plugins/tools.md +0 -1
- package/apps/runtime/dist/docs/dev/skills.md +16 -9
- package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +40 -5
- package/apps/runtime/dist/docs/dev/wizard-format/lists-and-connections.md +17 -2
- package/apps/runtime/dist/docs/dev/wizard-format/templates.md +2 -0
- package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +22 -2
- package/apps/runtime/dist/docs/user-guide/capabilities.md +132 -0
- package/apps/runtime/dist/docs/user-guide/cloud-sync.md +2 -0
- package/apps/runtime/dist/docs/user-guide/command-line.md +1 -0
- package/apps/runtime/dist/docs/user-guide/connectors.md +63 -7
- package/apps/runtime/dist/docs/user-guide/index.md +10 -1
- package/apps/runtime/dist/docs/user-guide/meta.json +6 -1
- package/apps/runtime/dist/docs/user-guide/protocol.md +80 -0
- package/apps/runtime/dist/docs/user-guide/skills.md +8 -4
- package/apps/runtime/dist/docs/user-guide/space.md +5 -4
- package/apps/runtime/dist/docs/user-guide/together.md +16 -2
- package/apps/runtime/dist/docs/user-guide/troubleshooting.md +2 -2
- package/apps/runtime/dist/docs/user-guide/work-mode.md +128 -0
- package/apps/runtime/dist/engenty/connections-external/build-connector.js +2 -5
- package/apps/runtime/dist/engenty/connections-external/importer/classify.js +72 -0
- package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +1 -1
- package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +3 -2
- package/apps/runtime/dist/engenty/connections-sdk/types.js +2 -0
- package/apps/runtime/dist/engenty/connections-slack/connector.js +2 -1
- package/apps/runtime/dist/engine/resources.js +43 -12
- package/apps/runtime/dist/engine/runner.js +75 -23
- package/apps/runtime/dist/engine/steps.js +30 -12
- package/apps/runtime/dist/engine/template.js +18 -1
- package/apps/runtime/dist/env.js +9 -4
- package/apps/runtime/dist/index.js +18 -2
- package/apps/runtime/dist/live/feed.js +2 -2
- package/apps/runtime/dist/live/origin.js +2 -2
- package/apps/runtime/dist/live/views.js +51 -26
- package/apps/runtime/dist/manage.js +7 -0
- package/apps/runtime/dist/mcp/flow-app.js +1 -1
- package/apps/runtime/dist/mcp/tools.js +75 -34
- package/apps/runtime/dist/models.js +1 -1
- package/apps/runtime/dist/motion-graphics/project.js +8 -8
- package/apps/runtime/dist/motion-graphics/tools.js +1 -1
- package/apps/runtime/dist/plugins/events.js +2 -2
- package/apps/runtime/dist/plugins/jobs.js +4 -1
- package/apps/runtime/dist/plugins/loader.js +2 -2
- package/apps/runtime/dist/prompts/architect.md +3 -3
- package/apps/runtime/dist/prompts/authoring.md +46 -12
- package/apps/runtime/dist/prompts/goose.md +7 -7
- package/apps/runtime/dist/prompts/mcp.md +6 -6
- package/apps/runtime/dist/prompts/services.md +4 -4
- package/apps/runtime/dist/prompts/step.md +2 -2
- package/apps/runtime/dist/prompts/tools.md +39 -10
- package/apps/runtime/dist/routes/api.js +31 -20
- package/apps/runtime/dist/routes/broker.js +316 -0
- package/apps/runtime/dist/routes/connections.js +71 -0
- package/apps/runtime/dist/routes/delivery.js +25 -0
- package/apps/runtime/dist/routes/discover.js +17 -0
- package/apps/runtime/dist/routes/live.js +11 -1
- package/apps/runtime/dist/routes/person.js +4 -1
- package/apps/runtime/dist/routes/plugins.js +3 -1
- package/apps/runtime/dist/routes/rules.js +26 -0
- package/apps/runtime/dist/routes/runs.js +54 -33
- package/apps/runtime/dist/routes/skills.js +6 -6
- package/apps/runtime/dist/routes/studio.js +153 -144
- package/apps/runtime/dist/routes/work.js +199 -0
- package/apps/runtime/dist/sandbox/index.js +27 -0
- package/apps/runtime/dist/services/access.js +38 -17
- package/apps/runtime/dist/services/api.js +38 -13
- package/apps/runtime/dist/services/architect.js +3 -3
- package/apps/runtime/dist/services/assistant-chats.js +9 -1
- package/apps/runtime/dist/services/brand.js +12 -12
- package/apps/runtime/dist/services/broker-bell.js +69 -0
- package/apps/runtime/dist/services/broker-notify.js +127 -0
- package/apps/runtime/dist/services/client-steps.js +79 -0
- package/apps/runtime/dist/services/cloud.js +42 -42
- package/apps/runtime/dist/services/command-risk.js +51 -0
- package/apps/runtime/dist/services/discover.js +85 -0
- package/apps/runtime/dist/services/knowledge-model.js +13 -13
- package/apps/runtime/dist/services/knowledge.js +117 -80
- package/apps/runtime/dist/services/manage-reports.js +74 -7
- package/apps/runtime/dist/services/members-studio.js +165 -0
- package/apps/runtime/dist/services/onboarding.js +22 -22
- package/apps/runtime/dist/services/package-file.js +1 -1
- package/apps/runtime/dist/services/package.js +22 -22
- package/apps/runtime/dist/services/pages.js +7 -7
- package/apps/runtime/dist/services/runs.js +4 -3
- package/apps/runtime/dist/services/seen.js +55 -0
- package/apps/runtime/dist/services/shares.js +23 -13
- package/apps/runtime/dist/services/site.js +23 -23
- package/apps/runtime/dist/services/skills-registry.js +15 -15
- package/apps/runtime/dist/services/skills.js +44 -44
- package/apps/runtime/dist/services/space-categories.js +35 -35
- package/apps/runtime/dist/services/space-data.js +130 -111
- package/apps/runtime/dist/services/{project-files.js → space-files.js} +84 -75
- package/apps/runtime/dist/services/{project-index.js → space-index.js} +116 -73
- package/apps/runtime/dist/services/space-origin.js +19 -11
- package/apps/runtime/dist/services/spaces.js +478 -612
- package/apps/runtime/dist/services/synced-spaces.js +668 -0
- package/apps/runtime/dist/services/themes.js +15 -15
- package/apps/runtime/dist/services/widgets.js +6 -6
- package/apps/runtime/dist/services/wizards.js +112 -38
- package/apps/runtime/dist/services/work-ai.js +257 -0
- package/apps/runtime/dist/services/work-approvals.js +104 -0
- package/apps/runtime/dist/services/work-chats.js +908 -0
- package/apps/runtime/dist/services/work-connections.js +90 -0
- package/apps/runtime/dist/services/work-files.js +85 -0
- package/apps/runtime/dist/services/work-mastra.js +73 -0
- package/apps/runtime/dist/services/work-sandbox.js +42 -0
- package/apps/runtime/dist/sharing/files.js +14 -4
- package/apps/runtime/dist/sharing/index.js +40 -39
- package/apps/runtime/dist/sharing/jobs.js +67 -17
- package/apps/runtime/dist/sharing/targets/connector.js +10 -6
- package/apps/runtime/dist/sharing/targets/email.js +10 -8
- package/apps/runtime/dist/sharing/targets/slack.js +10 -8
- package/apps/runtime/dist/sharing/targets/storage.js +6 -4
- package/apps/runtime/dist/store/index.js +14 -3
- package/apps/runtime/dist/store/shared-lists.js +4 -2
- package/apps/runtime/dist/sync/apply.js +2 -2
- package/apps/runtime/dist/sync/client.js +113 -113
- package/apps/runtime/dist/sync/hub.js +41 -41
- package/apps/runtime/dist/sync/log.js +12 -12
- package/apps/runtime/dist/sync/records.js +118 -120
- package/apps/runtime/dist/texts.js +38 -2
- package/apps/runtime/dist/tools/connections.js +112 -0
- package/apps/runtime/dist/tools/connector.js +157 -67
- package/apps/runtime/dist/tools/index.js +28 -13
- package/apps/runtime/dist/tools/mail.js +40 -11
- package/apps/runtime/dist/tools/pages.js +11 -5
- package/apps/runtime/dist/tools/plugin.js +43 -7
- package/apps/runtime/dist/tools/skills.js +1 -1
- package/apps/runtime/dist/tools/{project.js → space.js} +30 -25
- package/apps/runtime/dist/tools/store.js +3 -2
- package/apps/runtime/dist/widgets/step.js +10 -10
- package/apps/web/dist/assets/AboutDialog-DgfeipUc.js +1 -0
- package/apps/web/dist/assets/CapabilitiesPage-BoYJvgIu.js +2 -0
- package/apps/web/dist/assets/{ChangelogDialog-SwyId00t.js → ChangelogDialog-Duab4zTO.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-BwZsk5Al.js → CodeEditor-nxoOt8ge.js} +1 -1
- package/apps/web/dist/assets/EditorPage-ZrgGpYMC.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-DtSpjVTl.js → FlowPreview-aMfwcPul.js} +1 -1
- package/apps/web/dist/assets/LangSwitch-DpD0inR4.js +1 -0
- package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +2 -0
- package/apps/web/dist/assets/NewWizardChannels-IB18afWN.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-rYbcmPGG.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +1 -0
- package/apps/web/dist/assets/PreviewPane-DviWTLfi.js +9 -0
- package/apps/web/dist/assets/PublicRunner-C2geZhhM.js +1 -0
- package/apps/web/dist/assets/ReadOnly-kSb_Kbdm.js +1 -0
- package/apps/web/dist/assets/SettingsPage-DM2h8N0J.js +2 -0
- package/apps/web/dist/assets/SetupPage-Wfyz6xH4.js +1 -0
- package/apps/web/dist/assets/SharePage-CyWQorWB.js +1 -0
- package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +1 -0
- package/apps/web/dist/assets/Skills-CnhpgoOA.js +9 -0
- package/apps/web/dist/assets/SpacePage-q4Bk3N7k.js +2 -0
- package/apps/web/dist/assets/UpdateCheck-C2CE6CC3.js +2 -0
- package/apps/web/dist/assets/changelog-B6hN1Cp7.js +1 -0
- package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +1 -0
- package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +1 -0
- package/apps/web/dist/assets/code-editor-CfTGqOpp.js +2 -0
- package/apps/web/dist/assets/{code-xml-TwKzzMtA.js → code-xml-B4kLFZSj.js} +1 -1
- package/apps/web/dist/assets/connection-sign-in-CIiv0t2p.js +1 -0
- package/apps/web/dist/assets/esm-Xwn4GtqG.js +7 -0
- package/apps/web/dist/assets/{eye-Brd-xPUJ.js → eye-BpoKpIdt.js} +1 -1
- package/apps/web/dist/assets/host-BrP-ENHg.css +1 -0
- package/apps/web/dist/assets/host-DJ7-p0Sc.js +118 -0
- package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +55 -0
- package/apps/web/dist/assets/index-D18DvnxX.css +1 -0
- package/apps/web/dist/assets/index-D2akynS-.js +10 -0
- package/apps/web/dist/assets/logo-BpnjXTRy.js +1 -0
- package/apps/web/dist/assets/oss-credits-IdX5bc71.js +1 -0
- package/apps/web/dist/assets/{phone-DhkHteoJ.js → phone-Ctvf-Am-.js} +1 -1
- package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +1 -0
- package/apps/web/dist/assets/{runners-G-XYaDgR.js → runners-CyIvJIHr.js} +1 -1
- package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +1 -0
- package/apps/web/dist/assets/session-SXPtTWRK.js +2 -0
- package/apps/web/dist/assets/theme-CbTcTFWy.js +11 -0
- package/apps/web/dist/assets/ui-Uqnx1UpK.js +82 -0
- package/apps/web/dist/assets/{upload-BYZTwJTD.js → upload-BchUnQGV.js} +1 -1
- package/apps/web/dist/assets/{useMutation-D0QP_k2-.js → useMutation-DEkZhp5c.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CVHoxdGM.js → volume-2-CU_oy81Z.js} +1 -1
- package/apps/web/dist/assets/with-selector-CoMyWBAX.js +1 -0
- package/apps/web/dist/index.html +17 -10
- package/apps/web/dist/mcp/flow.html +119 -64
- package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +20 -10
- package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +6 -1
- package/node_modules/@engenty/wizards-shared/dist/assistant.js +6 -1
- package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +236 -2
- package/node_modules/@engenty/wizards-shared/dist/connectors.js +52 -2
- package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +150 -8
- package/node_modules/@engenty/wizards-shared/dist/definition.js +46 -11
- package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +21 -0
- package/node_modules/@engenty/wizards-shared/dist/discover.js +1 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +26 -2
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +26 -2
- package/node_modules/@engenty/wizards-shared/dist/fit.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/json-schema.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/json-schema.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/live.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/live.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/marketplace.js +3 -1
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +54 -6
- package/node_modules/@engenty/wizards-shared/dist/run.js +85 -0
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +15 -1
- package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +14 -0
- package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +42 -0
- package/node_modules/@engenty/wizards-shared/dist/rwx.js +29 -0
- package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/space-data.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/{projects.d.ts → spaces.d.ts} +39 -15
- package/node_modules/@engenty/wizards-shared/dist/{projects.js → spaces.js} +16 -9
- package/node_modules/@engenty/wizards-shared/dist/store.d.ts +7 -2
- package/node_modules/@engenty/wizards-shared/dist/surface.d.ts +35 -4
- package/node_modules/@engenty/wizards-shared/dist/surface.js +121 -3
- package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +1 -1
- package/node_modules/@engenty/wizards-shared/dist/theme-look.js +1 -1
- package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +2 -2
- package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +3 -3
- package/package.json +4 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/plugin/skills/build-wizard/SKILL.md +1 -1
- package/apps/runtime/dist/services/projects.js +0 -473
- package/apps/web/dist/assets/AboutDialog-B-JxkELB.js +0 -1
- package/apps/web/dist/assets/EditorPage-DQ_2FOzI.js +0 -3
- package/apps/web/dist/assets/Marketplace-DoH4YO3D.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-Tgoexgj4.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-B24AF482.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-BEvq4slJ.js +0 -1
- package/apps/web/dist/assets/PreviewPane-B_v7Y8R7.js +0 -10
- package/apps/web/dist/assets/ProjectPage-ClRuhFJo.js +0 -10
- package/apps/web/dist/assets/PublicRunner-MicrpVsv.js +0 -1
- package/apps/web/dist/assets/ReadOnly-BXjv-MSv.js +0 -1
- package/apps/web/dist/assets/SettingsPage-DY8O1r43.js +0 -2
- package/apps/web/dist/assets/SetupPage-BOVkVpMu.js +0 -1
- package/apps/web/dist/assets/SharePage-DXGzJSnR.js +0 -1
- package/apps/web/dist/assets/SkillEditor-BzzTDeaU.js +0 -1
- package/apps/web/dist/assets/changelog-BLdS-0Bj.js +0 -1
- package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
- package/apps/web/dist/assets/i18n-8-Sw11tB.js +0 -55
- package/apps/web/dist/assets/index-OsdQFHmh.js +0 -49
- package/apps/web/dist/assets/index-QPipX5Fi.css +0 -1
- package/apps/web/dist/assets/lock-C0uxcOlq.js +0 -1
- package/apps/web/dist/assets/logo-CGNoptDg.js +0 -1
- package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +0 -1
- package/apps/web/dist/assets/session-BWI-KENJ.js +0 -2
- package/apps/web/dist/assets/theme-D7krsx0_.js +0 -11
- package/apps/web/dist/assets/ui-DSXG3f49.js +0 -83
- /package/apps/runtime/dist/db/migrations/tenant/{0027_space_skill.sql → 0030_space_skill.sql} +0 -0
|
@@ -5,7 +5,7 @@ import { getBlob, hasBlob, putBlobOf } from "../files/blobs.js";
|
|
|
5
5
|
import { managed, tenantInfo } from "../manage.js";
|
|
6
6
|
import { currentRole, isAdminRole, MEMBERS_EDIT_ONLY, mayBuild } from "../services/access.js";
|
|
7
7
|
import { ServiceError } from "../services/errors.js";
|
|
8
|
-
import {
|
|
8
|
+
import { spaceLimit } from "../services/spaces.js";
|
|
9
9
|
import { publishWizard, rotateShareLink, shareUrl } from "../services/wizards.js";
|
|
10
10
|
import { codeOf } from "../tenants/control.js";
|
|
11
11
|
import { currentTenant } from "../tenants/tenant.js";
|
|
@@ -28,19 +28,19 @@ function requireSchema(theirs) {
|
|
|
28
28
|
}
|
|
29
29
|
/** The organization as an install meets it: its schema, its number of spaces, its spaces. */
|
|
30
30
|
export async function syncOverview() {
|
|
31
|
-
const spaces = await db.query.
|
|
32
|
-
where: eq(schema.
|
|
31
|
+
const spaces = await db.query.space.findMany({
|
|
32
|
+
where: eq(schema.space.tenantId, currentTenant()),
|
|
33
33
|
columns: { id: true, name: true, origin: true },
|
|
34
|
-
orderBy: [schema.
|
|
34
|
+
orderBy: [schema.space.createdAt],
|
|
35
35
|
});
|
|
36
36
|
const info = managed ? await tenantInfo(currentTenant()).catch(() => null) : null;
|
|
37
|
-
const limit = await
|
|
37
|
+
const limit = await spaceLimit();
|
|
38
38
|
return {
|
|
39
39
|
tenantId: currentTenant(),
|
|
40
40
|
schema: tenantSchemaVersion,
|
|
41
41
|
role: currentRole(),
|
|
42
42
|
limits: {
|
|
43
|
-
|
|
43
|
+
spaces: info?.limits.projects === null || !Number.isFinite(limit) ? null : limit,
|
|
44
44
|
},
|
|
45
45
|
spaces: await Promise.all(spaces.map(async (s) => ({ id: s.id, name: s.name, seq: await spaceSeq(s.id) }))),
|
|
46
46
|
};
|
|
@@ -49,9 +49,9 @@ export async function syncOverview() {
|
|
|
49
49
|
* What changed in a space after `since`. From 0 it is every item of the space, a page at a
|
|
50
50
|
* time (`cursor`); `next` then is the number the log stood at when the listing began.
|
|
51
51
|
*/
|
|
52
|
-
export async function pullChanges(
|
|
52
|
+
export async function pullChanges(spaceId, since, cursor) {
|
|
53
53
|
if (since > 0) {
|
|
54
|
-
const logged = await changedSince(
|
|
54
|
+
const logged = await changedSince(spaceId, since, PAGE);
|
|
55
55
|
const changes = [];
|
|
56
56
|
for (const x of logged) {
|
|
57
57
|
const def = KINDS[x.kind];
|
|
@@ -72,17 +72,17 @@ export async function pullChanges(projectId, since, cursor) {
|
|
|
72
72
|
}
|
|
73
73
|
const [offsetText, topText] = (cursor ?? "").split(".");
|
|
74
74
|
const offset = Number.parseInt(offsetText ?? "", 10) || 0;
|
|
75
|
-
const top = cursor ? Number.parseInt(topText ?? "", 10) || 0 : await spaceSeq(
|
|
76
|
-
const
|
|
77
|
-
where: eq(schema.
|
|
75
|
+
const top = cursor ? Number.parseInt(topText ?? "", 10) || 0 : await spaceSeq(spaceId);
|
|
76
|
+
const space = await db.query.space.findFirst({
|
|
77
|
+
where: eq(schema.space.id, spaceId),
|
|
78
78
|
columns: { tenantId: true },
|
|
79
79
|
});
|
|
80
|
-
if (!
|
|
80
|
+
if (!space || space.tenantId !== currentTenant()) {
|
|
81
81
|
throw new ServiceError("not_found", note("syncSpaceNotInCloud"));
|
|
82
82
|
}
|
|
83
83
|
const all = [];
|
|
84
84
|
for (const kind of KIND_ORDER) {
|
|
85
|
-
for (const item of await KINDS[kind].list(
|
|
85
|
+
for (const item of await KINDS[kind].list(spaceId)) {
|
|
86
86
|
all.push({ kind, item });
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -119,9 +119,9 @@ function mayChange(x, exists) {
|
|
|
119
119
|
async function requireRoomForSpace() {
|
|
120
120
|
const [{ n }] = await db
|
|
121
121
|
.select({ n: count() })
|
|
122
|
-
.from(schema.
|
|
123
|
-
.where(eq(schema.
|
|
124
|
-
const limit = await
|
|
122
|
+
.from(schema.space)
|
|
123
|
+
.where(eq(schema.space.tenantId, currentTenant()));
|
|
124
|
+
const limit = await spaceLimit();
|
|
125
125
|
if (n >= limit) {
|
|
126
126
|
throw new ServiceError("refused", limit === 1 ? note("onlyOneSpaceAllowed") : note("mostSpaces", { count: limit }), { reason: "space_limit", limit });
|
|
127
127
|
}
|
|
@@ -138,20 +138,20 @@ const refused = (x, reason, message) => ({
|
|
|
138
138
|
* not changed after the one the install changed (`base`); else the answer is the cloud's
|
|
139
139
|
* version, to merge with. What is taken is written in one transaction, and gets its number.
|
|
140
140
|
*/
|
|
141
|
-
export async function pushChanges(
|
|
141
|
+
export async function pushChanges(spaceId, input) {
|
|
142
142
|
requireSchema(input.schema);
|
|
143
143
|
if (!(await mayBuild())) {
|
|
144
144
|
throw new ServiceError("read_only", note("wizardsRunOncePublished"), { reason: "read_only" });
|
|
145
145
|
}
|
|
146
|
-
const
|
|
147
|
-
where: eq(schema.
|
|
146
|
+
const space = await db.query.space.findFirst({
|
|
147
|
+
where: eq(schema.space.id, spaceId),
|
|
148
148
|
columns: { tenantId: true },
|
|
149
149
|
});
|
|
150
|
-
if (
|
|
150
|
+
if (space && space.tenantId !== currentTenant()) {
|
|
151
151
|
throw new ServiceError("refused", note("spaceIdAlreadyExists"), { reason: "id_taken" });
|
|
152
152
|
}
|
|
153
|
-
const makesSpace = input.items.some((x) => x.kind === "space" && x.item ===
|
|
154
|
-
if (!
|
|
153
|
+
const makesSpace = input.items.some((x) => x.kind === "space" && x.item === spaceId && x.record !== null);
|
|
154
|
+
if (!space && !makesSpace) {
|
|
155
155
|
throw new ServiceError("not_found", note("syncSpaceNotInCloud"), { reason: "not_found" });
|
|
156
156
|
}
|
|
157
157
|
const seqs = await lastSeqs(input.items);
|
|
@@ -165,11 +165,11 @@ export async function pushChanges(projectId, input) {
|
|
|
165
165
|
results.push(refused(x, "not_synced", "This item does not sync."));
|
|
166
166
|
continue;
|
|
167
167
|
}
|
|
168
|
-
if (current && current.
|
|
168
|
+
if (current && current.spaceId !== spaceId) {
|
|
169
169
|
results.push(refused(x, "id_taken", "In the cloud this belongs to another space."));
|
|
170
170
|
continue;
|
|
171
171
|
}
|
|
172
|
-
if (x.record && x.kind !== "space" && x.record.
|
|
172
|
+
if (x.record && x.kind !== "space" && x.record.spaceId !== spaceId) {
|
|
173
173
|
results.push(refused(x, "invalid", "The item names another space."));
|
|
174
174
|
continue;
|
|
175
175
|
}
|
|
@@ -213,7 +213,7 @@ export async function pushChanges(projectId, input) {
|
|
|
213
213
|
continue;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
taking.push({ x, apply: { kind: x.kind, item: x.item,
|
|
216
|
+
taking.push({ x, apply: { kind: x.kind, item: x.item, spaceId, record: x.record } });
|
|
217
217
|
}
|
|
218
218
|
const taken = await applyEach(taking.map((t) => t.apply));
|
|
219
219
|
const after = await lastSeqs(taking.map((t) => t.x));
|
|
@@ -228,8 +228,8 @@ export async function pushChanges(projectId, input) {
|
|
|
228
228
|
seq: after.get(seqKey(x.kind, x.item)) ?? 0,
|
|
229
229
|
});
|
|
230
230
|
}
|
|
231
|
-
await compactLog(
|
|
232
|
-
return { results, seq: await spaceSeq(
|
|
231
|
+
await compactLog(spaceId);
|
|
232
|
+
return { results, seq: await spaceSeq(spaceId) };
|
|
233
233
|
}
|
|
234
234
|
/**
|
|
235
235
|
* Writes the batch in one transaction; when it fails, item by item, so one bad item does not
|
|
@@ -266,18 +266,18 @@ export async function missingBlobs(hashes) {
|
|
|
266
266
|
export const takeBlob = putBlobOf;
|
|
267
267
|
export const blobBytes = getBlob;
|
|
268
268
|
// --- publishing and links ------------------------------------------------------------------
|
|
269
|
-
async function wizardInSpace(
|
|
269
|
+
async function wizardInSpace(spaceId, wizardId) {
|
|
270
270
|
const w = await db.query.wizard.findFirst({
|
|
271
271
|
where: eq(schema.wizard.id, wizardId),
|
|
272
|
-
columns: {
|
|
272
|
+
columns: { spaceId: true, tenantId: true },
|
|
273
273
|
});
|
|
274
|
-
if (!w || w.
|
|
274
|
+
if (!w || w.spaceId !== spaceId || w.tenantId !== currentTenant()) {
|
|
275
275
|
throw new ServiceError("not_found", note("syncSpaceNotInCloud"));
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
/** Publishes the cloud's draft of a wizard, which the install pushed before it asked. */
|
|
279
|
-
export async function publishSynced(userId,
|
|
280
|
-
await wizardInSpace(
|
|
279
|
+
export async function publishSynced(userId, spaceId, wizardId) {
|
|
280
|
+
await wizardInSpace(spaceId, wizardId);
|
|
281
281
|
const published = await publishWizard(userId, wizardId);
|
|
282
282
|
const w = await db.query.wizard.findFirst({ where: eq(schema.wizard.id, wizardId) });
|
|
283
283
|
if (!w) {
|
|
@@ -294,8 +294,8 @@ export async function publishSynced(userId, projectId, wizardId) {
|
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
296
|
/** A new link for the cloud's copy of a wizard; the old one stops answering. */
|
|
297
|
-
export async function rotateSynced(userId,
|
|
298
|
-
await wizardInSpace(
|
|
297
|
+
export async function rotateSynced(userId, spaceId, wizardId) {
|
|
298
|
+
await wizardInSpace(spaceId, wizardId);
|
|
299
299
|
const { shareToken } = await rotateShareLink(userId, wizardId);
|
|
300
300
|
return { shareUrl: shareUrl(shareToken), code: await codeOf(shareToken) };
|
|
301
301
|
}
|
|
@@ -303,22 +303,22 @@ export async function rotateSynced(userId, projectId, wizardId) {
|
|
|
303
303
|
* A space a local install synced one way (`origin = "local"`) becomes a space of the cloud's
|
|
304
304
|
* own, which the studio here edits: from now on it syncs both ways.
|
|
305
305
|
*/
|
|
306
|
-
export async function adoptSpace(
|
|
306
|
+
export async function adoptSpace(spaceId) {
|
|
307
307
|
if (managed && !isAdminRole(currentRole())) {
|
|
308
308
|
throw new ServiceError("forbidden", MEMBERS_EDIT_ONLY);
|
|
309
309
|
}
|
|
310
|
-
const
|
|
311
|
-
where: eq(schema.
|
|
310
|
+
const space = await db.query.space.findFirst({
|
|
311
|
+
where: eq(schema.space.id, spaceId),
|
|
312
312
|
columns: { tenantId: true, origin: true },
|
|
313
313
|
});
|
|
314
|
-
if (!
|
|
314
|
+
if (!space || space.tenantId !== currentTenant()) {
|
|
315
315
|
return { adopted: false };
|
|
316
316
|
}
|
|
317
|
-
if (
|
|
317
|
+
if (space.origin === "local") {
|
|
318
318
|
await db
|
|
319
|
-
.update(schema.
|
|
319
|
+
.update(schema.space)
|
|
320
320
|
.set({ origin: null, syncedAt: new Date() })
|
|
321
|
-
.where(eq(schema.
|
|
321
|
+
.where(eq(schema.space.id, spaceId));
|
|
322
322
|
}
|
|
323
323
|
return { adopted: true };
|
|
324
324
|
}
|
|
@@ -22,45 +22,45 @@ export async function lastSeqs(items) {
|
|
|
22
22
|
}
|
|
23
23
|
export const seqKey = (kind, item) => `${kind}|${item}`;
|
|
24
24
|
/** The last number of the space's log; 0 when nothing of it changed yet. */
|
|
25
|
-
export async function spaceSeq(
|
|
25
|
+
export async function spaceSeq(spaceId) {
|
|
26
26
|
const [row] = await db
|
|
27
27
|
.select({ seq: max(schema.syncChange.seq) })
|
|
28
28
|
.from(schema.syncChange)
|
|
29
|
-
.where(eq(schema.syncChange.
|
|
29
|
+
.where(eq(schema.syncChange.spaceId, spaceId));
|
|
30
30
|
return row?.seq ?? 0;
|
|
31
31
|
}
|
|
32
32
|
/** The items of a space that changed after `since`, by their last change, oldest first. */
|
|
33
|
-
export async function changedSince(
|
|
33
|
+
export async function changedSince(spaceId, since, limit) {
|
|
34
34
|
const seq = max(schema.syncChange.seq);
|
|
35
35
|
const rows = await db
|
|
36
36
|
.select({ kind: schema.syncChange.kind, item: schema.syncChange.item, seq })
|
|
37
37
|
.from(schema.syncChange)
|
|
38
|
-
.where(and(eq(schema.syncChange.
|
|
38
|
+
.where(and(eq(schema.syncChange.spaceId, spaceId), gt(schema.syncChange.seq, since)))
|
|
39
39
|
.groupBy(schema.syncChange.kind, schema.syncChange.item)
|
|
40
40
|
.orderBy(seq)
|
|
41
41
|
.limit(limit);
|
|
42
42
|
return rows.map((r) => ({
|
|
43
43
|
kind: r.kind,
|
|
44
44
|
item: r.item,
|
|
45
|
-
|
|
45
|
+
spaceId,
|
|
46
46
|
seq: r.seq ?? 0,
|
|
47
47
|
}));
|
|
48
48
|
}
|
|
49
49
|
/** Keeps only each item's last change: what a pull or a push needs. */
|
|
50
|
-
export async function compactLog(
|
|
51
|
-
await db.run(
|
|
52
|
-
? sql `DELETE FROM sync_change WHERE
|
|
50
|
+
export async function compactLog(spaceId) {
|
|
51
|
+
await db.run(spaceId
|
|
52
|
+
? sql `DELETE FROM sync_change WHERE space_id = ${spaceId} AND seq NOT IN (SELECT MAX(seq) FROM sync_change WHERE space_id = ${spaceId} GROUP BY kind, item)`
|
|
53
53
|
: sql `DELETE FROM sync_change WHERE seq NOT IN (SELECT MAX(seq) FROM sync_change GROUP BY kind, item)`);
|
|
54
54
|
}
|
|
55
55
|
/** Drops what was pushed: changes of the space up to `seq`. */
|
|
56
|
-
export async function dropPushed(
|
|
56
|
+
export async function dropPushed(spaceId, seq) {
|
|
57
57
|
await db
|
|
58
58
|
.delete(schema.syncChange)
|
|
59
|
-
.where(and(eq(schema.syncChange.
|
|
59
|
+
.where(and(eq(schema.syncChange.spaceId, spaceId), sql `${schema.syncChange.seq} <= ${seq}`));
|
|
60
60
|
}
|
|
61
61
|
/** Notes an item as changed here, though no write did: a version kept by the person's choice. */
|
|
62
|
-
export async function notePending(
|
|
63
|
-
await db.insert(schema.syncChange).values({
|
|
62
|
+
export async function notePending(spaceId, kind, item) {
|
|
63
|
+
await db.insert(schema.syncChange).values({ spaceId, kind, item });
|
|
64
64
|
}
|
|
65
65
|
/** Runs `fn` with the triggers quiet: what it writes is not noted as a change of this side. */
|
|
66
66
|
export async function quietly(fn) {
|