@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
|
@@ -8,9 +8,9 @@ import { db, schema } from "../db/client.js";
|
|
|
8
8
|
import { currentFeatures } from "../features.js";
|
|
9
9
|
import { getBlob, putBlob } from "../files/blobs.js";
|
|
10
10
|
import { currentTenant } from "../tenants/tenant.js";
|
|
11
|
-
import {
|
|
11
|
+
import { requireWritableSpace, spaceWritable } from "./access.js";
|
|
12
12
|
import { notFound, ServiceError } from "./errors.js";
|
|
13
|
-
import {
|
|
13
|
+
import { ownedSpace } from "./spaces.js";
|
|
14
14
|
const refuse = (server, params) => new ServiceError("invalid", { server, params });
|
|
15
15
|
export async function skillsOn() {
|
|
16
16
|
return featureOn(await currentFeatures(), "skills");
|
|
@@ -83,22 +83,22 @@ export function checkContent(c) {
|
|
|
83
83
|
}
|
|
84
84
|
return out;
|
|
85
85
|
}
|
|
86
|
-
async function nameTaken(
|
|
86
|
+
async function nameTaken(spaceId, name, except) {
|
|
87
87
|
const row = await db.query.spaceSkill.findFirst({
|
|
88
|
-
where: and(eq(schema.spaceSkill.
|
|
88
|
+
where: and(eq(schema.spaceSkill.spaceId, spaceId), eq(schema.spaceSkill.name, name), ...(except ? [ne(schema.spaceSkill.id, except)] : [])),
|
|
89
89
|
columns: { id: true },
|
|
90
90
|
});
|
|
91
91
|
return Boolean(row);
|
|
92
92
|
}
|
|
93
93
|
/** A name not yet taken in the space: the name itself, else with `-2`, `-3` … */
|
|
94
|
-
async function freeName(
|
|
95
|
-
if (!(await nameTaken(
|
|
94
|
+
async function freeName(spaceId, name) {
|
|
95
|
+
if (!(await nameTaken(spaceId, name))) {
|
|
96
96
|
return name;
|
|
97
97
|
}
|
|
98
98
|
for (let n = 2; n < 1000; n++) {
|
|
99
99
|
const suffix = `-${n}`;
|
|
100
100
|
const next = `${name.slice(0, SKILL_LIMITS.name - suffix.length).replace(/-+$/, "")}${suffix}`;
|
|
101
|
-
if (!(await nameTaken(
|
|
101
|
+
if (!(await nameTaken(spaceId, next))) {
|
|
102
102
|
return next;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -110,14 +110,14 @@ async function freeName(projectId, name) {
|
|
|
110
110
|
* At most five skills always on, their instructions 20,000 characters together: each of them
|
|
111
111
|
* is in every AI step of the space.
|
|
112
112
|
*/
|
|
113
|
-
export async function checkAlways(
|
|
113
|
+
export async function checkAlways(spaceId, id, mode, body) {
|
|
114
114
|
if (mode !== "always") {
|
|
115
115
|
return;
|
|
116
116
|
}
|
|
117
117
|
const others = await db
|
|
118
118
|
.select({ id: schema.spaceSkill.id, body: schema.spaceSkill.body })
|
|
119
119
|
.from(schema.spaceSkill)
|
|
120
|
-
.where(and(eq(schema.spaceSkill.
|
|
120
|
+
.where(and(eq(schema.spaceSkill.spaceId, spaceId), eq(schema.spaceSkill.mode, "always")));
|
|
121
121
|
const rest = others.filter((o) => o.id !== id);
|
|
122
122
|
if (rest.length + 1 > SKILL_LIMITS.always) {
|
|
123
123
|
throw refuse("skillsAlwaysCount");
|
|
@@ -152,28 +152,28 @@ export async function skillRow(id) {
|
|
|
152
152
|
}
|
|
153
153
|
return row;
|
|
154
154
|
}
|
|
155
|
-
export async function listSkills(userId,
|
|
155
|
+
export async function listSkills(userId, spaceId) {
|
|
156
156
|
await requireSkills();
|
|
157
|
-
const
|
|
157
|
+
const space = await ownedSpace(userId, spaceId);
|
|
158
158
|
const rows = await db.query.spaceSkill.findMany({
|
|
159
|
-
where: eq(schema.spaceSkill.
|
|
159
|
+
where: eq(schema.spaceSkill.spaceId, space.id),
|
|
160
160
|
orderBy: [asc(schema.spaceSkill.name)],
|
|
161
161
|
});
|
|
162
|
-
return { skills: rows.map(summaryOf), readOnly: !(await
|
|
162
|
+
return { skills: rows.map(summaryOf), readOnly: !(await spaceWritable(space)) };
|
|
163
163
|
}
|
|
164
164
|
export async function getSkill(userId, id) {
|
|
165
165
|
await requireSkills();
|
|
166
166
|
const row = await skillRow(id);
|
|
167
|
-
const
|
|
167
|
+
const space = await ownedSpace(userId, row.spaceId);
|
|
168
168
|
return {
|
|
169
169
|
...summaryOf(row),
|
|
170
|
-
|
|
170
|
+
spaceId: row.spaceId,
|
|
171
171
|
body: row.body,
|
|
172
172
|
meta: row.meta,
|
|
173
173
|
fileList: row.files,
|
|
174
174
|
blobList: row.blobFiles,
|
|
175
175
|
originHash: row.originHash,
|
|
176
|
-
readOnly: !(await
|
|
176
|
+
readOnly: !(await spaceWritable(space)),
|
|
177
177
|
};
|
|
178
178
|
}
|
|
179
179
|
// --- writes ---------------------------------------------------------------------------------
|
|
@@ -196,26 +196,26 @@ export async function keepBlobs(blobs) {
|
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
/** Puts a new skill into the space; its name is the one given, or the next free one. */
|
|
199
|
-
export async function insertSkill(
|
|
199
|
+
export async function insertSkill(spaceId, content, options) {
|
|
200
200
|
const checked = checkContent(content);
|
|
201
201
|
const [{ n }] = await db
|
|
202
202
|
.select({ n: count() })
|
|
203
203
|
.from(schema.spaceSkill)
|
|
204
|
-
.where(eq(schema.spaceSkill.
|
|
204
|
+
.where(eq(schema.spaceSkill.spaceId, spaceId));
|
|
205
205
|
if (n >= SKILL_LIMITS.perSpace) {
|
|
206
206
|
throw refuse("skillsTooMany");
|
|
207
207
|
}
|
|
208
|
-
const name = options.rename ? await freeName(
|
|
209
|
-
if (!options.rename && (await nameTaken(
|
|
208
|
+
const name = options.rename ? await freeName(spaceId, checked.name) : checked.name;
|
|
209
|
+
if (!options.rename && (await nameTaken(spaceId, name))) {
|
|
210
210
|
throw refuse("skillNameTaken", { name });
|
|
211
211
|
}
|
|
212
212
|
const mode = options.mode ?? "demand";
|
|
213
|
-
await checkAlways(
|
|
213
|
+
await checkAlways(spaceId, null, mode, checked.body);
|
|
214
214
|
const id = nanoid(12);
|
|
215
215
|
await db.insert(schema.spaceSkill).values({
|
|
216
216
|
id,
|
|
217
217
|
tenantId: currentTenant(),
|
|
218
|
-
|
|
218
|
+
spaceId,
|
|
219
219
|
name,
|
|
220
220
|
description: checked.description,
|
|
221
221
|
body: checked.body,
|
|
@@ -230,11 +230,11 @@ export async function insertSkill(projectId, content, options) {
|
|
|
230
230
|
return { id, name };
|
|
231
231
|
}
|
|
232
232
|
/** A skill written in the studio: a name, a description and a first heading. */
|
|
233
|
-
export async function createSkill(userId,
|
|
233
|
+
export async function createSkill(userId, spaceId, input) {
|
|
234
234
|
await requireSkills();
|
|
235
|
-
const
|
|
236
|
-
await
|
|
237
|
-
return insertSkill(
|
|
235
|
+
const space = await ownedSpace(userId, spaceId);
|
|
236
|
+
await requireWritableSpace(space.id);
|
|
237
|
+
return insertSkill(space.id, {
|
|
238
238
|
name: input.name,
|
|
239
239
|
description: input.description,
|
|
240
240
|
body: input.body ?? "",
|
|
@@ -250,8 +250,8 @@ export async function createSkill(userId, projectId, input) {
|
|
|
250
250
|
export async function updateSkill(userId, id, patch) {
|
|
251
251
|
await requireSkills();
|
|
252
252
|
const row = await skillRow(id);
|
|
253
|
-
await
|
|
254
|
-
await
|
|
253
|
+
await ownedSpace(userId, row.spaceId);
|
|
254
|
+
await requireWritableSpace(row.spaceId);
|
|
255
255
|
const content = { ...patch };
|
|
256
256
|
if (patch.skillMd !== undefined) {
|
|
257
257
|
Object.assign(content, readSkillMd(patch.skillMd));
|
|
@@ -268,11 +268,11 @@ export async function updateSkill(userId, id, patch) {
|
|
|
268
268
|
files: content.files ?? row.files,
|
|
269
269
|
blobFiles: row.blobFiles,
|
|
270
270
|
});
|
|
271
|
-
if (next.name !== row.name && (await nameTaken(row.
|
|
271
|
+
if (next.name !== row.name && (await nameTaken(row.spaceId, next.name, row.id))) {
|
|
272
272
|
throw refuse("skillNameTaken", { name: next.name });
|
|
273
273
|
}
|
|
274
274
|
const mode = patch.mode ?? row.mode;
|
|
275
|
-
await checkAlways(row.
|
|
275
|
+
await checkAlways(row.spaceId, row.id, mode, next.body);
|
|
276
276
|
await db
|
|
277
277
|
.update(schema.spaceSkill)
|
|
278
278
|
.set({ ...next, mode, runScripts: patch.runScripts ?? row.runScripts, updatedAt: new Date() })
|
|
@@ -282,8 +282,8 @@ export async function updateSkill(userId, id, patch) {
|
|
|
282
282
|
export async function deleteSkill(userId, id) {
|
|
283
283
|
await requireSkills();
|
|
284
284
|
const row = await skillRow(id);
|
|
285
|
-
await
|
|
286
|
-
await
|
|
285
|
+
await ownedSpace(userId, row.spaceId);
|
|
286
|
+
await requireWritableSpace(row.spaceId);
|
|
287
287
|
await db.delete(schema.spaceSkill).where(eq(schema.spaceSkill.id, row.id));
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
@@ -293,9 +293,9 @@ export async function deleteSkill(userId, id) {
|
|
|
293
293
|
export async function copySkill(userId, id) {
|
|
294
294
|
await requireSkills();
|
|
295
295
|
const row = await skillRow(id);
|
|
296
|
-
await
|
|
297
|
-
await
|
|
298
|
-
return insertSkill(row.
|
|
296
|
+
await ownedSpace(userId, row.spaceId);
|
|
297
|
+
await requireWritableSpace(row.spaceId);
|
|
298
|
+
return insertSkill(row.spaceId, {
|
|
299
299
|
name: row.name,
|
|
300
300
|
description: row.description,
|
|
301
301
|
body: row.body,
|
|
@@ -409,10 +409,10 @@ export function unpackSkill(data) {
|
|
|
409
409
|
})));
|
|
410
410
|
}
|
|
411
411
|
/** An uploaded `SKILL.md`, `.zip` or `.skill`, as a skill of the space. */
|
|
412
|
-
export async function uploadSkill(userId,
|
|
412
|
+
export async function uploadSkill(userId, spaceId, file) {
|
|
413
413
|
await requireSkills();
|
|
414
|
-
const
|
|
415
|
-
await
|
|
414
|
+
const space = await ownedSpace(userId, spaceId);
|
|
415
|
+
await requireWritableSpace(space.id);
|
|
416
416
|
const lower = file.name.toLowerCase();
|
|
417
417
|
let read;
|
|
418
418
|
if (lower.endsWith(".zip") || lower.endsWith(".skill")) {
|
|
@@ -429,14 +429,14 @@ export async function uploadSkill(userId, projectId, file) {
|
|
|
429
429
|
throw refuse("skillUploadKind");
|
|
430
430
|
}
|
|
431
431
|
await keepBlobs(read.blobs);
|
|
432
|
-
const made = await insertSkill(
|
|
432
|
+
const made = await insertSkill(space.id, read.content, { source: "upload", rename: true });
|
|
433
433
|
return { ...made, skipped: read.skipped };
|
|
434
434
|
}
|
|
435
435
|
/** A skill as a zip: its folder, named by the skill, as other tools take it. */
|
|
436
436
|
export async function skillZip(userId, id) {
|
|
437
437
|
await requireSkills();
|
|
438
438
|
const row = await skillRow(id);
|
|
439
|
-
await
|
|
439
|
+
await ownedSpace(userId, row.spaceId);
|
|
440
440
|
const enc = new TextEncoder();
|
|
441
441
|
const files = {
|
|
442
442
|
[`${row.name}/SKILL.md`]: enc.encode(skillMd(row)),
|
|
@@ -451,7 +451,7 @@ export async function skillZip(userId, id) {
|
|
|
451
451
|
}
|
|
452
452
|
// --- for steps and Goose ----------------------------------------------------------------------
|
|
453
453
|
/** Every skill of the space, off ones too, by name: what Goose is told the space has. */
|
|
454
|
-
export async function skillList(
|
|
454
|
+
export async function skillList(spaceId) {
|
|
455
455
|
return db
|
|
456
456
|
.select({
|
|
457
457
|
name: schema.spaceSkill.name,
|
|
@@ -459,16 +459,16 @@ export async function skillList(projectId) {
|
|
|
459
459
|
mode: schema.spaceSkill.mode,
|
|
460
460
|
})
|
|
461
461
|
.from(schema.spaceSkill)
|
|
462
|
-
.where(eq(schema.spaceSkill.
|
|
462
|
+
.where(eq(schema.spaceSkill.spaceId, spaceId))
|
|
463
463
|
.orderBy(asc(schema.spaceSkill.name));
|
|
464
464
|
}
|
|
465
465
|
/** The space's skills that count, by mode: none while the switch is off. */
|
|
466
|
-
export async function activeSkills(
|
|
466
|
+
export async function activeSkills(spaceId) {
|
|
467
467
|
if (!(await skillsOn())) {
|
|
468
468
|
return { always: [], demand: [] };
|
|
469
469
|
}
|
|
470
470
|
const rows = await db.query.spaceSkill.findMany({
|
|
471
|
-
where: and(eq(schema.spaceSkill.
|
|
471
|
+
where: and(eq(schema.spaceSkill.spaceId, spaceId), ne(schema.spaceSkill.mode, "off")),
|
|
472
472
|
orderBy: [asc(schema.spaceSkill.name)],
|
|
473
473
|
});
|
|
474
474
|
return {
|
|
@@ -5,9 +5,9 @@ import { and, asc, eq, inArray, isNotNull, or, sql } from "drizzle-orm";
|
|
|
5
5
|
import { nanoid } from "nanoid";
|
|
6
6
|
import { db, schema } from "../db/client.js";
|
|
7
7
|
import { currentTenant } from "../tenants/tenant.js";
|
|
8
|
-
import {
|
|
8
|
+
import { requireWritableSpace } from "./access.js";
|
|
9
9
|
import { notFound, ServiceError } from "./errors.js";
|
|
10
|
-
import { queueIndex } from "./
|
|
10
|
+
import { queueIndex } from "./space-index.js";
|
|
11
11
|
export function itemKey(ref) {
|
|
12
12
|
if ("pageId" in ref) {
|
|
13
13
|
return `p:${ref.pageId}`;
|
|
@@ -129,9 +129,9 @@ function cellOf(row, values) {
|
|
|
129
129
|
return row.text;
|
|
130
130
|
}
|
|
131
131
|
// --- the categories of a space ---------------------------------------------------
|
|
132
|
-
export async function categoryRows(
|
|
132
|
+
export async function categoryRows(spaceId) {
|
|
133
133
|
return db.query.spaceCategory.findMany({
|
|
134
|
-
where: eq(schema.spaceCategory.
|
|
134
|
+
where: eq(schema.spaceCategory.spaceId, spaceId),
|
|
135
135
|
orderBy: [asc(schema.spaceCategory.position), asc(schema.spaceCategory.name)],
|
|
136
136
|
});
|
|
137
137
|
}
|
|
@@ -168,8 +168,8 @@ function alike(a, b) {
|
|
|
168
168
|
x.slice(i + 1) === y.slice(i));
|
|
169
169
|
}
|
|
170
170
|
/** The space's categories with their values, how many items have each, and their ranges. */
|
|
171
|
-
export async function listCategories(
|
|
172
|
-
const rows = await categoryRows(
|
|
171
|
+
export async function listCategories(spaceId) {
|
|
172
|
+
const rows = await categoryRows(spaceId);
|
|
173
173
|
if (!rows.length) {
|
|
174
174
|
return [];
|
|
175
175
|
}
|
|
@@ -289,9 +289,9 @@ async function addValues(categoryId, values) {
|
|
|
289
289
|
* Adds a category, or, by a name the space has already, leaves that one as it is apart from
|
|
290
290
|
* values it does not know yet. `proposed`: shown to be confirmed, never filled before.
|
|
291
291
|
*/
|
|
292
|
-
export async function putCategory(
|
|
292
|
+
export async function putCategory(spaceId, draft, opts = {}) {
|
|
293
293
|
const name = checkDraft(draft);
|
|
294
|
-
const rows = await categoryRows(
|
|
294
|
+
const rows = await categoryRows(spaceId);
|
|
295
295
|
const known = byName(rows, name);
|
|
296
296
|
if (known) {
|
|
297
297
|
if (draft.values?.length && known.type === "choice") {
|
|
@@ -316,7 +316,7 @@ export async function putCategory(projectId, draft, opts = {}) {
|
|
|
316
316
|
.values({
|
|
317
317
|
id,
|
|
318
318
|
tenantId: currentTenant(),
|
|
319
|
-
|
|
319
|
+
spaceId,
|
|
320
320
|
name,
|
|
321
321
|
type: draft.type,
|
|
322
322
|
unit: draft.type === "number" ? (draft.unit?.trim().slice(0, 20) ?? null) : null,
|
|
@@ -382,10 +382,10 @@ async function reindexHolders(categoryId) {
|
|
|
382
382
|
}
|
|
383
383
|
export async function updateCategory(categoryId, patch) {
|
|
384
384
|
const row = await categoryRow(categoryId);
|
|
385
|
-
await
|
|
385
|
+
await requireWritableSpace(row.spaceId);
|
|
386
386
|
const name = patch.name !== undefined ? checkDraft({ name: patch.name, type: row.type }) : row.name;
|
|
387
387
|
if (name !== row.name) {
|
|
388
|
-
const clash = byName(await categoryRows(row.
|
|
388
|
+
const clash = byName(await categoryRows(row.spaceId), name);
|
|
389
389
|
if (clash && clash.id !== row.id) {
|
|
390
390
|
throw new ServiceError("invalid", note("categoryAlreadyExists", { name }));
|
|
391
391
|
}
|
|
@@ -416,7 +416,7 @@ export async function updateCategory(categoryId, patch) {
|
|
|
416
416
|
}
|
|
417
417
|
export async function deleteCategory(categoryId) {
|
|
418
418
|
const row = await categoryRow(categoryId);
|
|
419
|
-
await
|
|
419
|
+
await requireWritableSpace(row.spaceId);
|
|
420
420
|
await reindexHolders(row.id);
|
|
421
421
|
await db.delete(schema.spaceCategory).where(eq(schema.spaceCategory.id, row.id));
|
|
422
422
|
}
|
|
@@ -435,7 +435,7 @@ export async function categoryValue(valueId) {
|
|
|
435
435
|
}
|
|
436
436
|
export async function addCategoryValue(categoryId, value) {
|
|
437
437
|
const category = await categoryRow(categoryId);
|
|
438
|
-
await
|
|
438
|
+
await requireWritableSpace(category.spaceId);
|
|
439
439
|
if (category.type !== "choice") {
|
|
440
440
|
throw new ServiceError("invalid", note("onlyChoiceCategoriesValues"));
|
|
441
441
|
}
|
|
@@ -444,7 +444,7 @@ export async function addCategoryValue(categoryId, value) {
|
|
|
444
444
|
}
|
|
445
445
|
export async function renameCategoryValue(valueId, value) {
|
|
446
446
|
const { value: row, category } = await valueRow(valueId);
|
|
447
|
-
await
|
|
447
|
+
await requireWritableSpace(category.spaceId);
|
|
448
448
|
const next = value.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
449
449
|
if (!next || next === row.value) {
|
|
450
450
|
return;
|
|
@@ -469,7 +469,7 @@ export async function mergeCategoryValues(fromId, intoId) {
|
|
|
469
469
|
if (from.category.id !== into.category.id || fromId === intoId) {
|
|
470
470
|
throw new ServiceError("invalid", note("onlyValuesOneCategory"));
|
|
471
471
|
}
|
|
472
|
-
await
|
|
472
|
+
await requireWritableSpace(from.category.spaceId);
|
|
473
473
|
const t = schema.spaceItemCategory;
|
|
474
474
|
const moving = await db.query.spaceItemCategory.findMany({ where: eq(t.valueId, fromId) });
|
|
475
475
|
const having = new Set((await db.query.spaceItemCategory.findMany({ where: eq(t.valueId, intoId) })).map(keyOfRow));
|
|
@@ -491,13 +491,13 @@ export async function mergeCategoryValues(fromId, intoId) {
|
|
|
491
491
|
}
|
|
492
492
|
export async function deleteCategoryValue(valueId) {
|
|
493
493
|
const { value, category } = await valueRow(valueId);
|
|
494
|
-
await
|
|
494
|
+
await requireWritableSpace(category.spaceId);
|
|
495
495
|
await reindexHolders(category.id);
|
|
496
496
|
await db.delete(schema.spaceCategoryValue).where(eq(schema.spaceCategoryValue.id, value.id));
|
|
497
497
|
}
|
|
498
498
|
export async function orderCategoryValues(categoryId, ids) {
|
|
499
499
|
const category = await categoryRow(categoryId);
|
|
500
|
-
await
|
|
500
|
+
await requireWritableSpace(category.spaceId);
|
|
501
501
|
for (const [position, id] of ids.entries()) {
|
|
502
502
|
await db
|
|
503
503
|
.update(schema.spaceCategoryValue)
|
|
@@ -511,8 +511,8 @@ export async function orderCategoryValues(categoryId, ids) {
|
|
|
511
511
|
* person set stays when an origin or a model writes again. Names the space has no taken
|
|
512
512
|
* category for are skipped and returned. True in `changed` when anything changed.
|
|
513
513
|
*/
|
|
514
|
-
export async function setItemCategories(
|
|
515
|
-
const rows = (await categoryRows(
|
|
514
|
+
export async function setItemCategories(spaceId, ref, input, by) {
|
|
515
|
+
const rows = (await categoryRows(spaceId)).filter((c) => !c.proposed);
|
|
516
516
|
const t = schema.spaceItemCategory;
|
|
517
517
|
const current = await db.query.spaceItemCategory.findMany({ where: refWhere(ref) });
|
|
518
518
|
const unknown = [];
|
|
@@ -556,7 +556,7 @@ export async function setItemCategories(projectId, ref, input, by) {
|
|
|
556
556
|
}
|
|
557
557
|
if (next.length) {
|
|
558
558
|
await db.insert(t).values(next.map((n) => ({
|
|
559
|
-
|
|
559
|
+
spaceId,
|
|
560
560
|
categoryId: category.id,
|
|
561
561
|
...("pageId" in ref ? { pageId: ref.pageId } : {}),
|
|
562
562
|
...("rowId" in ref ? { rowId: ref.rowId } : {}),
|
|
@@ -570,20 +570,20 @@ export async function setItemCategories(projectId, ref, input, by) {
|
|
|
570
570
|
return { changed, unknown };
|
|
571
571
|
}
|
|
572
572
|
/** Whether an item is of the space's own Knowledge. */
|
|
573
|
-
async function
|
|
573
|
+
async function itemInSpace(spaceId, ref) {
|
|
574
574
|
if ("pageId" in ref) {
|
|
575
575
|
const page = await db.query.spacePage.findFirst({
|
|
576
576
|
where: eq(schema.spacePage.id, ref.pageId),
|
|
577
|
-
columns: {
|
|
577
|
+
columns: { spaceId: true, wizardId: true },
|
|
578
578
|
});
|
|
579
|
-
return page?.
|
|
579
|
+
return page?.spaceId === spaceId && !page.wizardId;
|
|
580
580
|
}
|
|
581
581
|
if ("fileId" in ref) {
|
|
582
|
-
const file = await db.query.
|
|
583
|
-
where: eq(schema.
|
|
584
|
-
columns: {
|
|
582
|
+
const file = await db.query.spaceFile.findFirst({
|
|
583
|
+
where: eq(schema.spaceFile.id, ref.fileId),
|
|
584
|
+
columns: { spaceId: true },
|
|
585
585
|
});
|
|
586
|
-
return file?.
|
|
586
|
+
return file?.spaceId === spaceId;
|
|
587
587
|
}
|
|
588
588
|
const tableId = "tableId" in ref
|
|
589
589
|
? ref.tableId
|
|
@@ -594,18 +594,18 @@ async function itemInProject(projectId, ref) {
|
|
|
594
594
|
const table = tableId
|
|
595
595
|
? await db.query.spaceTable.findFirst({
|
|
596
596
|
where: eq(schema.spaceTable.id, tableId),
|
|
597
|
-
columns: {
|
|
597
|
+
columns: { spaceId: true, wizardId: true },
|
|
598
598
|
})
|
|
599
599
|
: undefined;
|
|
600
|
-
return table?.
|
|
600
|
+
return table?.spaceId === spaceId && !table.wizardId;
|
|
601
601
|
}
|
|
602
602
|
/** What a person set from the studio: by the category's id, a list of values or none. */
|
|
603
|
-
export async function setItemCategory(
|
|
603
|
+
export async function setItemCategory(spaceId, ref, categoryId, values) {
|
|
604
604
|
const category = await categoryRow(categoryId);
|
|
605
|
-
if (category.
|
|
605
|
+
if (category.spaceId !== spaceId || !(await itemInSpace(spaceId, ref))) {
|
|
606
606
|
throw notFound();
|
|
607
607
|
}
|
|
608
|
-
const { changed } = await setItemCategories(
|
|
608
|
+
const { changed } = await setItemCategories(spaceId, ref, { [category.name]: values.length ? values : null }, "person");
|
|
609
609
|
return changed;
|
|
610
610
|
}
|
|
611
611
|
/** The categories of items, by `itemKey`. */
|
|
@@ -692,7 +692,7 @@ export async function syncColumnCategory(category, rowIds) {
|
|
|
692
692
|
columns: { id: true, cells: true },
|
|
693
693
|
});
|
|
694
694
|
for (const row of rows) {
|
|
695
|
-
await setItemCategories(category.
|
|
695
|
+
await setItemCategories(category.spaceId, { rowId: row.id }, {
|
|
696
696
|
[category.name]: row.cells[category.columnId] ?? null,
|
|
697
697
|
}, "origin");
|
|
698
698
|
}
|
|
@@ -795,12 +795,12 @@ async function withSubPages(pageIds) {
|
|
|
795
795
|
* belongs to, has every category as asked. Null for no filter. A name the space has no
|
|
796
796
|
* category for is an error that lists the names there are.
|
|
797
797
|
*/
|
|
798
|
-
export async function filterItems(
|
|
798
|
+
export async function filterItems(spaceId, where) {
|
|
799
799
|
const entries = Object.entries(where ?? {});
|
|
800
800
|
if (!entries.length) {
|
|
801
801
|
return null;
|
|
802
802
|
}
|
|
803
|
-
const rows = (await categoryRows(
|
|
803
|
+
const rows = (await categoryRows(spaceId)).filter((c) => !c.proposed);
|
|
804
804
|
let result = null;
|
|
805
805
|
for (const [name, w] of entries) {
|
|
806
806
|
const category = byName(rows, name);
|