@engenty/wizards-runtime 0.12.2 → 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 +126 -71
- package/apps/runtime/dist/agents/website.js +1 -1
- package/apps/runtime/dist/app.js +28 -3
- 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/credits/estimate.js +3 -3
- 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 +59 -6
- 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/models.md +105 -30
- 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 +29 -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/decide.js +1 -1
- package/apps/runtime/dist/engine/requirements.js +139 -11
- package/apps/runtime/dist/engine/resources.js +43 -12
- package/apps/runtime/dist/engine/runner.js +121 -27
- package/apps/runtime/dist/engine/steps.js +42 -16
- package/apps/runtime/dist/engine/template.js +35 -1
- package/apps/runtime/dist/env.js +9 -4
- package/apps/runtime/dist/index.js +18 -2
- package/apps/runtime/dist/link-preview.js +9 -0
- 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 +32 -0
- package/apps/runtime/dist/mcp/flow-app.js +1 -1
- package/apps/runtime/dist/mcp/handler.js +55 -1
- package/apps/runtime/dist/mcp/seen.js +47 -0
- package/apps/runtime/dist/mcp/tools.js +75 -34
- package/apps/runtime/dist/models.js +203 -12
- package/apps/runtime/dist/motion-graphics/project.js +8 -8
- package/apps/runtime/dist/motion-graphics/step.js +2 -2
- 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 +14 -13
- package/apps/runtime/dist/prompts/mcp.md +6 -6
- package/apps/runtime/dist/prompts/safety.md +18 -0
- package/apps/runtime/dist/prompts/services.md +4 -4
- package/apps/runtime/dist/prompts/step.md +3 -3
- 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/marketplace.js +3 -3
- 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 +59 -33
- package/apps/runtime/dist/routes/skills.js +6 -6
- package/apps/runtime/dist/routes/studio.js +256 -148
- package/apps/runtime/dist/routes/work.js +199 -0
- package/apps/runtime/dist/safety.js +60 -18
- 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 +77 -7
- package/apps/runtime/dist/services/marketplace.js +7 -31
- 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 +13 -9
- 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 +28 -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 -598
- 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 +44 -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 +31 -15
- 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-CKLgFL6r.js → ChangelogDialog-Duab4zTO.js} +1 -1
- package/apps/web/dist/assets/{CodeEditor-B3nto_26.js → CodeEditor-nxoOt8ge.js} +1 -1
- package/apps/web/dist/assets/EditorPage-ZrgGpYMC.js +3 -0
- package/apps/web/dist/assets/{FlowPreview-zJCtixSi.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-Hx7YxCg0.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-BkMFLnYu.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-DMfwuh9V.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-D5qz6b_s.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-DQJwLSGj.js → upload-BchUnQGV.js} +1 -1
- package/apps/web/dist/assets/{useMutation-C20c2EH3.js → useMutation-DEkZhp5c.js} +1 -1
- package/apps/web/dist/assets/{volume-2-CC5qamYT.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 +7 -1
- package/node_modules/@engenty/wizards-shared/dist/assistant.js +11 -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 +257 -8
- package/node_modules/@engenty/wizards-shared/dist/definition.js +113 -15
- 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 +38 -2
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +38 -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.d.ts +0 -5
- package/node_modules/@engenty/wizards-shared/dist/marketplace.js +3 -1
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +115 -6
- package/node_modules/@engenty/wizards-shared/dist/run.js +135 -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/tiers.d.ts +195 -0
- package/node_modules/@engenty/wizards-shared/dist/tiers.js +98 -0
- 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-CLgnoYTI.js +0 -1
- package/apps/web/dist/assets/EditorPage-D9JDdAAI.js +0 -3
- package/apps/web/dist/assets/Marketplace-D4e0Oac9.js +0 -2
- package/apps/web/dist/assets/NewWizardChannels-B4N7GIYh.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-Dpt0Mzk8.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-CDoYVjRC.js +0 -1
- package/apps/web/dist/assets/PreviewPane-DPB5nEd5.js +0 -10
- package/apps/web/dist/assets/ProjectPage-408YOoNa.js +0 -10
- package/apps/web/dist/assets/PublicRunner-BZ66xdRX.js +0 -1
- package/apps/web/dist/assets/ReadOnly-C9oGMkUB.js +0 -1
- package/apps/web/dist/assets/SettingsPage-Dq3AZwJS.js +0 -2
- package/apps/web/dist/assets/SetupPage-CP3lbyZc.js +0 -1
- package/apps/web/dist/assets/SharePage-DdMm1Y8K.js +0 -1
- package/apps/web/dist/assets/SkillEditor-b5NMFB90.js +0 -1
- package/apps/web/dist/assets/changelog-82-DHogQ.js +0 -1
- package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
- package/apps/web/dist/assets/i18n-CKKh3Pn0.js +0 -55
- package/apps/web/dist/assets/index-Cy2NHzAx.js +0 -49
- package/apps/web/dist/assets/index-wR_-1hfN.css +0 -1
- package/apps/web/dist/assets/lock-CGXM95Mi.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-DRy0k0nh.js +0 -2
- package/apps/web/dist/assets/theme-DNPm6r4e.js +0 -11
- package/apps/web/dist/assets/ui-CwFQAfE-.js +0 -83
- /package/apps/runtime/dist/db/migrations/tenant/{0027_space_skill.sql → 0030_space_skill.sql} +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { noteText } from "@engenty/wizards-shared/run";
|
|
2
|
-
import {
|
|
2
|
+
import { brokerCall, brokerConnected, brokerSend, GUEST_MAILS_PER_RUN, whereOfRun, whoOf, } from "../broker/index.js";
|
|
3
3
|
import { askPerson } from "../engine/asks.js";
|
|
4
4
|
import { signalChanged } from "../engine/events.js";
|
|
5
5
|
import { releaseResources } from "../engine/resources.js";
|
|
6
|
-
import {
|
|
6
|
+
import { loadSpace, makeContext, spaceIdOf } from "../engine/runner.js";
|
|
7
7
|
import { env } from "../env.js";
|
|
8
8
|
import { errorText } from "../model-errors.js";
|
|
9
9
|
import { ServiceError } from "../services/errors.js";
|
|
10
10
|
import { shareRun } from "../services/shares.js";
|
|
11
|
-
import { scopeOf } from "../store/index.js";
|
|
11
|
+
import { holderOf, scopeOf } from "../store/index.js";
|
|
12
12
|
import { serverText } from "../texts.js";
|
|
13
13
|
import { SHARE_STEP } from "./agent.js";
|
|
14
14
|
import { shareFiles } from "./files.js";
|
|
15
15
|
import { offeredTargets, targetScope } from "./index.js";
|
|
16
16
|
import { addJobEvent, createJob, finishJob, jobCount, sentCount, setWorking, workingJob, } from "./state.js";
|
|
17
17
|
import { parseRecipients } from "./targets/email.js";
|
|
18
|
-
import { ShareError, sayIn } from "./types.js";
|
|
18
|
+
import { line, ShareError, sayIn } from "./types.js";
|
|
19
19
|
/** What the person filled in does not do: per field, what is wrong. `_files` and `_account` name the other steps. */
|
|
20
20
|
export class ShareInputError extends Error {
|
|
21
21
|
fields;
|
|
@@ -35,7 +35,9 @@ function publicOrigin() {
|
|
|
35
35
|
host === "127.0.0.1" ||
|
|
36
36
|
host === "[::1]");
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
/** A share target's account, held by the run's store like a wizard's connections. */
|
|
39
|
+
const heldBy = (run, def, spaceId) => ({ kind: "store_secret", def, scope: scopeOf(run), spaceId });
|
|
40
|
+
function contextOf(run, spaceId, entry, who, job) {
|
|
39
41
|
const connection = entry.target.connection?.() ?? null;
|
|
40
42
|
const signal = job?.signal ?? new AbortController().signal;
|
|
41
43
|
const emit = (message) => job ? addJobEvent(run.id, job.id, sayIn(who.lang, message)) : Promise.resolve();
|
|
@@ -43,23 +45,71 @@ function contextOf(run, projectId, entry, who, job) {
|
|
|
43
45
|
? Promise.resolve(null)
|
|
44
46
|
: askPerson(run.id, { ...question, stepId: SHARE_STEP }, signal);
|
|
45
47
|
return {
|
|
46
|
-
...targetScope(run,
|
|
48
|
+
...targetScope(run, spaceId, who.lang),
|
|
47
49
|
signal,
|
|
48
50
|
member: who.member,
|
|
49
51
|
sentBefore: job?.sentBefore ?? 0,
|
|
50
52
|
emit,
|
|
51
53
|
ask,
|
|
52
|
-
|
|
54
|
+
connected: () => connection ? brokerConnected(heldBy(run, connection, spaceId)) : Promise.resolve(null),
|
|
55
|
+
call: async (action, input, handler) => {
|
|
56
|
+
const name = sayIn(who.lang, entry.target.name);
|
|
57
|
+
if (!connection) {
|
|
58
|
+
throw new ShareError(line("shareConnectFirst", { name }));
|
|
59
|
+
}
|
|
60
|
+
// The person filled the form and sent it: a write is theirs, nothing asks again.
|
|
61
|
+
const out = await brokerCall({
|
|
62
|
+
who: whoOf(holderOf(run)),
|
|
63
|
+
where: whereOfRun(run, holderOf(run), spaceId),
|
|
64
|
+
connection: heldBy(run, connection, spaceId),
|
|
65
|
+
action,
|
|
66
|
+
input,
|
|
67
|
+
ctx: { ask, confirmed: true },
|
|
68
|
+
handler,
|
|
69
|
+
});
|
|
70
|
+
if (!out.ok) {
|
|
71
|
+
throw new ShareError(out.refused === "not_connected"
|
|
72
|
+
? line("shareConnectFirst", { name })
|
|
73
|
+
: (refusalLine(out.refused) ?? out.reason));
|
|
74
|
+
}
|
|
75
|
+
return out.result;
|
|
76
|
+
},
|
|
77
|
+
sendFromServer: async (recipients, input, handler) => {
|
|
78
|
+
const out = await brokerSend({
|
|
79
|
+
who: whoOf(holderOf(run)),
|
|
80
|
+
where: whereOfRun(run, holderOf(run), spaceId),
|
|
81
|
+
recipients,
|
|
82
|
+
input,
|
|
83
|
+
handler,
|
|
84
|
+
});
|
|
85
|
+
if (!out.ok) {
|
|
86
|
+
throw new ShareError(refusalLine(out.refused) ?? out.reason);
|
|
87
|
+
}
|
|
88
|
+
return out.result;
|
|
89
|
+
},
|
|
53
90
|
link: async () => (publicOrigin() ? (await shareRun(run)).url : null),
|
|
54
|
-
step: async () => makeContext(run, await
|
|
91
|
+
step: async () => makeContext(run, await loadSpace(run), structuredClone(run.state), signal, {
|
|
55
92
|
stepId: SHARE_STEP,
|
|
56
93
|
emit: (_type, message) => emit(typeof message === "string" ? message : noteText(message, who.lang)),
|
|
57
94
|
ask,
|
|
58
95
|
}),
|
|
59
96
|
};
|
|
60
97
|
}
|
|
61
|
-
|
|
62
|
-
|
|
98
|
+
/** What the person reads when the broker refuses a guest's send; null for the other refusals. */
|
|
99
|
+
function refusalLine(refused) {
|
|
100
|
+
switch (refused) {
|
|
101
|
+
case "not_allowed_recipient":
|
|
102
|
+
return line("shareGuestRecipient");
|
|
103
|
+
case "run_limit":
|
|
104
|
+
return line("shareGuestRunMails", { mails: GUEST_MAILS_PER_RUN });
|
|
105
|
+
case "day_limit":
|
|
106
|
+
return line("shareGuestDayMails");
|
|
107
|
+
default:
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
async function entryOf(run, spaceId, key, member) {
|
|
112
|
+
const entry = (await offeredTargets(run, spaceId, member)).find((e) => e.key === key);
|
|
63
113
|
if (!entry) {
|
|
64
114
|
throw new ServiceError("not_found", { server: "shareTargetUnknown" });
|
|
65
115
|
}
|
|
@@ -81,8 +131,8 @@ export async function startShare(run, request, who) {
|
|
|
81
131
|
throw new ServiceError("refused", { server: "shareTooOften" });
|
|
82
132
|
}
|
|
83
133
|
const lang = request.lang ?? "en";
|
|
84
|
-
const
|
|
85
|
-
const entry = await entryOf(run,
|
|
134
|
+
const spaceId = await spaceIdOf(run);
|
|
135
|
+
const entry = await entryOf(run, spaceId, request.target, who.member);
|
|
86
136
|
const { target } = entry;
|
|
87
137
|
const values = {};
|
|
88
138
|
const errors = {};
|
|
@@ -114,7 +164,7 @@ export async function startShare(run, request, who) {
|
|
|
114
164
|
errors._files = serverText(lang, "sharePickFile");
|
|
115
165
|
}
|
|
116
166
|
const connection = target.connection?.() ?? null;
|
|
117
|
-
if (connection && !(await
|
|
167
|
+
if (connection && !(await brokerConnected(heldBy(run, connection, spaceId)))) {
|
|
118
168
|
errors._account = serverText(lang, "shareConnectAccount");
|
|
119
169
|
}
|
|
120
170
|
if (Object.keys(errors).length) {
|
|
@@ -129,7 +179,7 @@ export async function startShare(run, request, who) {
|
|
|
129
179
|
});
|
|
130
180
|
const abort = new AbortController();
|
|
131
181
|
setWorking(run.id, { jobId: job.id, abort });
|
|
132
|
-
const ctx = contextOf(run,
|
|
182
|
+
const ctx = contextOf(run, spaceId, entry, { member: who.member, lang }, { id: job.id, signal: abort.signal, sentBefore: await sentCount(run.id, target.id) });
|
|
133
183
|
void (async () => {
|
|
134
184
|
try {
|
|
135
185
|
if (items.length) {
|
|
@@ -177,10 +227,10 @@ export async function cancelShare(runId, jobId) {
|
|
|
177
227
|
}
|
|
178
228
|
/** The choices of a form field that come from the connected account (Slack's channels). */
|
|
179
229
|
export async function shareChoices(run, key, field, who) {
|
|
180
|
-
const
|
|
181
|
-
const entry = await entryOf(run,
|
|
230
|
+
const spaceId = await spaceIdOf(run);
|
|
231
|
+
const entry = await entryOf(run, spaceId, key, who.member);
|
|
182
232
|
if (!entry.target.choices) {
|
|
183
233
|
return [];
|
|
184
234
|
}
|
|
185
|
-
return entry.target.choices(field, contextOf(run,
|
|
235
|
+
return entry.target.choices(field, contextOf(run, spaceId, entry, who, null));
|
|
186
236
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reachesOutside } from "../../broker/index.js";
|
|
1
2
|
import { refreshConnector, resolveConnector } from "../../connectors/external.js";
|
|
2
3
|
import { toolsOf } from "../../tools/connector.js";
|
|
3
4
|
import { runShareAgent } from "../agent.js";
|
|
@@ -8,12 +9,14 @@ const RULES = [
|
|
|
8
9
|
"To send a file, give `file:<name>` with the file's name as listed, where an action's input asks for `*_base64`.",
|
|
9
10
|
].join("\n");
|
|
10
11
|
/**
|
|
11
|
-
* The result through any connector that can write: one the product ships, or one the
|
|
12
|
+
* The result through any connector that can write: one the product ships, or one the space
|
|
12
13
|
* imported from the integrations registry (Notion, WordPress, an ads account …). The person
|
|
13
14
|
* says in their words what should happen; an agent does it with the connector's actions.
|
|
14
15
|
*/
|
|
15
16
|
export function connectorTarget(connector, imported) {
|
|
16
17
|
const id = `connector:${connector.id}`;
|
|
18
|
+
// Its actions go through the connector tools of the agent step; this is the tool list's refresh.
|
|
19
|
+
reachesOutside(id, { connection: `share:${id}`, action: "list_tools", kind: "read" });
|
|
17
20
|
const connection = (actions) => ({
|
|
18
21
|
id: `share:${id}`,
|
|
19
22
|
connector: connector.id,
|
|
@@ -27,7 +30,7 @@ export function connectorTarget(connector, imported) {
|
|
|
27
30
|
icon: "plug",
|
|
28
31
|
takes: "files",
|
|
29
32
|
agent: true,
|
|
30
|
-
// What the
|
|
33
|
+
// What the space imported it wants to use; what ships with the product is named by the wizard.
|
|
31
34
|
byDefault: imported,
|
|
32
35
|
connection: () => connection(connector.actions.map((a) => a.id)),
|
|
33
36
|
fields: [
|
|
@@ -40,15 +43,16 @@ export function connectorTarget(connector, imported) {
|
|
|
40
43
|
},
|
|
41
44
|
],
|
|
42
45
|
async send(input, ctx) {
|
|
43
|
-
|
|
44
|
-
if (!account) {
|
|
46
|
+
if (!(await ctx.connected())) {
|
|
45
47
|
throw new ShareError(line("shareConnectFirst", { name: connector.name }));
|
|
46
48
|
}
|
|
47
49
|
// An MCP server that lists its tools only to a signed-in account: ask it now.
|
|
48
50
|
if (imported && !connector.actions.length) {
|
|
49
|
-
await
|
|
51
|
+
await ctx
|
|
52
|
+
.call({ id: "list_tools", kind: "read" }, {}, (account) => refreshConnector(ctx.spaceId, connector.id, account.ctx.accessToken))
|
|
53
|
+
.catch(() => undefined);
|
|
50
54
|
}
|
|
51
|
-
const current = (await resolveConnector(ctx.
|
|
55
|
+
const current = (await resolveConnector(ctx.spaceId, connector.id))?.connector ?? connector;
|
|
52
56
|
return runShareAgent(ctx, input, {
|
|
53
57
|
task: `In ${connector.name}: ${input.values.instructions}`,
|
|
54
58
|
rules: RULES,
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { reachesOutside } from "../../broker/index.js";
|
|
1
2
|
import { MAIL_SENDERS, MailTooLarge, sendAsAccount, sendFromServer, serverSender, } from "../../connectors/smtp.js";
|
|
2
3
|
import { megabytes } from "../files.js";
|
|
3
4
|
import { line, ShareError } from "../types.js";
|
|
4
5
|
/** What mail providers take in one message, with room for the encoding. */
|
|
5
6
|
const ATTACH_LIMIT = 18_000_000;
|
|
6
|
-
/** From the server's own address,
|
|
7
|
-
const VISITOR_MAILS = 3;
|
|
7
|
+
/** From the server's own address, one of a visitor's mails goes to this many addresses at most. */
|
|
8
8
|
const VISITOR_RECIPIENTS = 3;
|
|
9
9
|
const RECIPIENTS = 20;
|
|
10
10
|
const ADDRESS = /^[^\s@<>,;]+@[^\s@<>,;]+\.[^\s@<>,;]+$/;
|
|
11
|
+
reachesOutside("share:email", { connection: "share:email", action: "send_message", kind: "send" });
|
|
11
12
|
/** "a@b.at, c@d.at; e@f.at" → the addresses; throws on one that is none. */
|
|
12
13
|
export function parseRecipients(raw) {
|
|
13
14
|
const list = raw
|
|
@@ -69,11 +70,11 @@ export const emailTarget = {
|
|
|
69
70
|
text: (values.message ?? "").trim(),
|
|
70
71
|
attachments: files.map((f) => ({ name: f.name, mime: f.mime, data: f.data })),
|
|
71
72
|
};
|
|
72
|
-
const account = await ctx.
|
|
73
|
+
const account = await ctx.connected();
|
|
73
74
|
if (account) {
|
|
74
75
|
await ctx.emit(line("shareSendingFrom", { account: account.label }));
|
|
75
76
|
try {
|
|
76
|
-
await sendAsAccount(
|
|
77
|
+
await ctx.call({ id: "send_message", kind: "send" }, { to: message.to, subject: message.subject, attachments: message.attachments.length }, (held) => sendAsAccount(held.connector, held.ctx, message));
|
|
77
78
|
}
|
|
78
79
|
catch (err) {
|
|
79
80
|
if (err instanceof MailTooLarge) {
|
|
@@ -83,12 +84,13 @@ export const emailTarget = {
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
else if (serverSender()) {
|
|
86
|
-
// The server's address is everyone's to send from
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
// The server's address is everyone's to send from. A visitor's mail goes to a few addresses,
|
|
88
|
+
// and the broker holds a guest's run to its own address or the space's, a few per run and day.
|
|
89
|
+
if (!ctx.member && to.length > VISITOR_RECIPIENTS) {
|
|
90
|
+
throw new ShareError(line("shareVisitorRecipients", { recipients: VISITOR_RECIPIENTS }));
|
|
89
91
|
}
|
|
90
92
|
await ctx.emit(line("shareSendingFrom", { account: serverSender() ?? "" }));
|
|
91
|
-
await sendFromServer(message);
|
|
93
|
+
await ctx.sendFromServer(to, { to: message.to, subject: message.subject, attachments: message.attachments.length }, () => sendFromServer(message));
|
|
92
94
|
}
|
|
93
95
|
else {
|
|
94
96
|
throw new ShareError(line("shareConnectMailbox"));
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { reachesOutside } from "../../broker/index.js";
|
|
1
2
|
import { line, ShareError } from "../types.js";
|
|
3
|
+
reachesOutside("share:slack", [
|
|
4
|
+
{ connection: "share:slack", action: "list_channels", kind: "read" },
|
|
5
|
+
{ connection: "share:slack", action: "post_message", kind: "send" },
|
|
6
|
+
]);
|
|
2
7
|
/**
|
|
3
8
|
* A message in a Slack channel, as the person: their text and the link to the result page.
|
|
4
9
|
* The connector posts text only, so files travel as the link.
|
|
@@ -29,26 +34,23 @@ export const slackTarget = {
|
|
|
29
34
|
message: [scope.title, scope.text?.slice(0, 2500)].filter(Boolean).join("\n\n"),
|
|
30
35
|
}),
|
|
31
36
|
async choices(field, ctx) {
|
|
32
|
-
|
|
33
|
-
const list = account?.connector.actions.find((a) => a.id === "list_channels");
|
|
34
|
-
if (!account || !list) {
|
|
37
|
+
if (field !== "channel" || !(await ctx.connected())) {
|
|
35
38
|
return [];
|
|
36
39
|
}
|
|
37
|
-
const { channels } =
|
|
40
|
+
const { channels } = await ctx.call({ id: "list_channels", kind: "read" }, { limit: 50 });
|
|
38
41
|
return channels
|
|
39
42
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
40
43
|
.map((c) => ({ value: c.id, label: `${c.is_private ? "🔒 " : "#"}${c.name}` }));
|
|
41
44
|
},
|
|
42
45
|
async send({ values }, ctx) {
|
|
43
|
-
const account = await ctx.
|
|
44
|
-
|
|
45
|
-
if (!account || !post) {
|
|
46
|
+
const account = await ctx.connected();
|
|
47
|
+
if (!account?.connector.actions.some((a) => a.id === "post_message")) {
|
|
46
48
|
throw new ShareError(line("shareConnectFirst", { name: "Slack" }));
|
|
47
49
|
}
|
|
48
50
|
const link = await ctx.link();
|
|
49
51
|
const text = [values.message?.trim(), link].filter(Boolean).join("\n\n");
|
|
50
52
|
await ctx.emit(line("sharePostingAs", { account: account.label }));
|
|
51
|
-
await
|
|
53
|
+
await ctx.call({ id: "post_message", kind: "send" }, { channel: values.channel, text });
|
|
52
54
|
return { summary: line("sharePostedSlack") };
|
|
53
55
|
},
|
|
54
56
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { reachesOutside } from "../../broker/index.js";
|
|
1
2
|
import { BUILTIN_CONNECTORS } from "../../connectors/builtin.js";
|
|
2
3
|
import { line, ShareError } from "../types.js";
|
|
3
4
|
async function call(ctx, url, init = {}) {
|
|
@@ -127,6 +128,8 @@ export function storageTarget(connector) {
|
|
|
127
128
|
return null;
|
|
128
129
|
}
|
|
129
130
|
const id = `storage:${connector.id}`;
|
|
131
|
+
const action = UPLOAD_ACTION[connector.id] ?? "files_write";
|
|
132
|
+
reachesOutside(id, { connection: `share:${id}`, action, kind: "write" });
|
|
130
133
|
return {
|
|
131
134
|
id,
|
|
132
135
|
name: connector.name,
|
|
@@ -137,7 +140,7 @@ export function storageTarget(connector) {
|
|
|
137
140
|
connection: () => ({
|
|
138
141
|
id: `share:${id}`,
|
|
139
142
|
target: { connectors: [connector.id] },
|
|
140
|
-
actions:
|
|
143
|
+
actions: [action],
|
|
141
144
|
title: connector.name,
|
|
142
145
|
}),
|
|
143
146
|
fields: [
|
|
@@ -151,12 +154,11 @@ export function storageTarget(connector) {
|
|
|
151
154
|
],
|
|
152
155
|
defaults: (scope) => ({ folder: scope.run.definition.title.replace(/\//g, "-") }),
|
|
153
156
|
async send({ values, files }, ctx) {
|
|
154
|
-
|
|
155
|
-
if (!account) {
|
|
157
|
+
if (!(await ctx.connected())) {
|
|
156
158
|
throw new ShareError(line("shareConnectFirst", { name: connector.name }));
|
|
157
159
|
}
|
|
158
160
|
const folder = (values.folder ?? "").trim();
|
|
159
|
-
const link = await upload(account.ctx, folder, files, (file) => ctx.emit(line("shareUploading", { name: file.name })));
|
|
161
|
+
const link = await ctx.call({ id: action, kind: "write" }, { folder, files: files.map((f) => f.name) }, (account) => upload(account.ctx, folder, files, (file) => ctx.emit(line("shareUploading", { name: file.name }))));
|
|
160
162
|
const where = [connector.name, folder].filter(Boolean).join(" › ");
|
|
161
163
|
return { summary: line("shareSavedFiles", { count: files.length, where }), url: link };
|
|
162
164
|
},
|
|
@@ -35,10 +35,13 @@ const inList = (scope, list) => and(eq(schema.storeRow.wizardId, scope.wizardId)
|
|
|
35
35
|
function toRow(r) {
|
|
36
36
|
return { id: r.id, cells: r.cells, updatedAt: r.updatedAt.toISOString() };
|
|
37
37
|
}
|
|
38
|
-
/**
|
|
39
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The rows of a list: the person's, or every run's where the list is shared. A shared list is a
|
|
40
|
+
* table of the space, read as `who` may read it (broker/rwx.ts); a person's own rows are theirs.
|
|
41
|
+
*/
|
|
42
|
+
export async function listRows(scope, def, who = []) {
|
|
40
43
|
if (def.shared) {
|
|
41
|
-
return sharedRows(scope.wizardId, def);
|
|
44
|
+
return sharedRows(scope.wizardId, def, who);
|
|
42
45
|
}
|
|
43
46
|
const rows = await db.query.storeRow.findMany({
|
|
44
47
|
where: inList(scope, def.id),
|
|
@@ -249,6 +252,14 @@ export async function getSecret(scope, slot) {
|
|
|
249
252
|
? { provider: row.provider, label: row.label, data, createdAt: row.createdAt }
|
|
250
253
|
: null;
|
|
251
254
|
}
|
|
255
|
+
/** What a secret is, without the secret: who it is for and since when. For a connection's view. */
|
|
256
|
+
export async function peekSecret(scope, slot) {
|
|
257
|
+
const row = await db.query.storeSecret.findFirst({
|
|
258
|
+
where: and(ownSecrets(scope), eq(schema.storeSecret.slot, slot)),
|
|
259
|
+
columns: { provider: true, label: true, createdAt: true },
|
|
260
|
+
});
|
|
261
|
+
return row ?? null;
|
|
262
|
+
}
|
|
252
263
|
export async function putSecret(scope, slot, provider, label, data) {
|
|
253
264
|
const sealed = seal(data);
|
|
254
265
|
await db
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { firstRowAt, newCells, patchCells, rowKey, STORE_LIMITS, } from "@engenty/wizards-shared/store";
|
|
2
2
|
import { and, asc, eq, inArray } from "drizzle-orm";
|
|
3
3
|
import { nanoid } from "nanoid";
|
|
4
|
+
import { assertRwx } from "../broker/rwx.js";
|
|
4
5
|
import { db, schema } from "../db/client.js";
|
|
5
6
|
import { StoreError } from "./errors.js";
|
|
6
7
|
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
@@ -23,7 +24,7 @@ export async function sharedTable(wizardId, def) {
|
|
|
23
24
|
}
|
|
24
25
|
const wizard = await db.query.wizard.findFirst({
|
|
25
26
|
where: eq(schema.wizard.id, wizardId),
|
|
26
|
-
columns: {
|
|
27
|
+
columns: { spaceId: true, tenantId: true },
|
|
27
28
|
});
|
|
28
29
|
if (!wizard) {
|
|
29
30
|
throw new StoreError("The wizard is gone.");
|
|
@@ -48,8 +49,9 @@ async function touch(tableId) {
|
|
|
48
49
|
function toRow(r) {
|
|
49
50
|
return { id: r.id, cells: r.cells, updatedAt: r.updatedAt.toISOString() };
|
|
50
51
|
}
|
|
51
|
-
export async function sharedRows(wizardId, def) {
|
|
52
|
+
export async function sharedRows(wizardId, def, who) {
|
|
52
53
|
const table = await sharedTable(wizardId, def);
|
|
54
|
+
await assertRwx(table.spaceId, who, { kind: "table", id: table.id }, "r");
|
|
53
55
|
const rows = await db.query.spaceTableRow.findMany({
|
|
54
56
|
where: eq(schema.spaceTableRow.tableId, table.id),
|
|
55
57
|
orderBy: [asc(schema.spaceTableRow.createdAt), asc(schema.spaceTableRow.id)],
|
|
@@ -24,8 +24,8 @@ export async function applyItems(items, options) {
|
|
|
24
24
|
for (const x of sorted) {
|
|
25
25
|
const def = KINDS[x.kind];
|
|
26
26
|
const after = x.record
|
|
27
|
-
? await def.write(x.
|
|
28
|
-
: await def.remove(x.
|
|
27
|
+
? await def.write(x.spaceId, x.item, x.record)
|
|
28
|
+
: await def.remove(x.spaceId, x.item);
|
|
29
29
|
if (after) {
|
|
30
30
|
done.push(after);
|
|
31
31
|
}
|