@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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { featureOn } from "@engenty/wizards-shared/features";
|
|
2
|
+
import { eq } from "drizzle-orm";
|
|
3
|
+
import { searchRegistry } from "../connectors/external.js";
|
|
4
|
+
import { db, schema } from "../db/client.js";
|
|
5
|
+
import { currentFeatures } from "../features.js";
|
|
6
|
+
import { notFound } from "./errors.js";
|
|
7
|
+
import { skillsOn } from "./skills.js";
|
|
8
|
+
import { searchSkills } from "./skills-registry.js";
|
|
9
|
+
import { ownedSpace } from "./spaces.js";
|
|
10
|
+
/**
|
|
11
|
+
* Fähigkeiten › Entdecken (docs/plans/capabilities.md, part B6): one search over skills.sh and
|
|
12
|
+
* integrations.sh. Both are asked at once, each with its own time to answer; one that fails or
|
|
13
|
+
* takes too long leaves its list empty and says so, and the other still shows what it found.
|
|
14
|
+
*/
|
|
15
|
+
/** How long one directory may take before the search goes on without it. */
|
|
16
|
+
const WAIT_MS = 10_000;
|
|
17
|
+
function within(work) {
|
|
18
|
+
let timer;
|
|
19
|
+
const late = new Promise((_, reject) => {
|
|
20
|
+
timer = setTimeout(() => reject(new Error("too late")), WAIT_MS);
|
|
21
|
+
});
|
|
22
|
+
return Promise.race([work, late]).finally(() => clearTimeout(timer));
|
|
23
|
+
}
|
|
24
|
+
/** `www.Notion.so` and `notion.so` are one service. */
|
|
25
|
+
const plainDomain = (domain) => domain
|
|
26
|
+
.trim()
|
|
27
|
+
.toLowerCase()
|
|
28
|
+
.replace(/^www\./, "");
|
|
29
|
+
/**
|
|
30
|
+
* The services the space has: the domains of the definitions it imported, and the built-in
|
|
31
|
+
* connectors it has a connection to (a built-in's id is its service's name: `hubspot`, `github`).
|
|
32
|
+
*/
|
|
33
|
+
async function spaceServices(spaceId) {
|
|
34
|
+
const [imported, connections] = await Promise.all([
|
|
35
|
+
db.query.spaceConnector.findMany({
|
|
36
|
+
where: eq(schema.spaceConnector.spaceId, spaceId),
|
|
37
|
+
columns: { record: true },
|
|
38
|
+
}),
|
|
39
|
+
db
|
|
40
|
+
.select({ connectorId: schema.spaceConnection.connectorId })
|
|
41
|
+
.from(schema.spaceConnection)
|
|
42
|
+
.where(eq(schema.spaceConnection.spaceId, spaceId)),
|
|
43
|
+
]);
|
|
44
|
+
return {
|
|
45
|
+
domains: new Set(imported.map((r) => plainDomain(r.record.domain ?? ""))),
|
|
46
|
+
connected: new Set(connections.map((c) => c.connectorId)),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async function markSetUp(spaceId, hits) {
|
|
50
|
+
const has = await spaceServices(spaceId);
|
|
51
|
+
return hits.map((hit) => {
|
|
52
|
+
const domain = plainDomain(hit.domain);
|
|
53
|
+
const name = domain.split(".")[0] ?? "";
|
|
54
|
+
return { ...hit, setUp: has.domains.has(domain) || has.connected.has(name) };
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Skills and connectors for a few words, what the space has marked. */
|
|
58
|
+
export async function discover(userId, spaceId, query) {
|
|
59
|
+
// Part of Fähigkeiten: not there while its switch is off.
|
|
60
|
+
if (!featureOn(await currentFeatures(), "capabilities")) {
|
|
61
|
+
throw notFound();
|
|
62
|
+
}
|
|
63
|
+
const space = await ownedSpace(userId, spaceId);
|
|
64
|
+
const q = query.trim().slice(0, 100);
|
|
65
|
+
if (q.length < 2) {
|
|
66
|
+
return { skills: [], connectors: [], errors: {} };
|
|
67
|
+
}
|
|
68
|
+
const [skills, connectors] = await Promise.allSettled([
|
|
69
|
+
// Skills stay out while their own switch is off.
|
|
70
|
+
skillsOn().then(async (on) => on ? (await within(searchSkills(userId, space.id, q))).hits : []),
|
|
71
|
+
within(searchRegistry(q)).then((hits) => markSetUp(space.id, hits)),
|
|
72
|
+
]);
|
|
73
|
+
const errors = {};
|
|
74
|
+
if (skills.status === "rejected") {
|
|
75
|
+
errors.skills = "skillsRegistryDown";
|
|
76
|
+
}
|
|
77
|
+
if (connectors.status === "rejected") {
|
|
78
|
+
errors.connectors = "connectorsRegistryDown";
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
skills: skills.status === "fulfilled" ? skills.value : [],
|
|
82
|
+
connectors: connectors.status === "fulfilled" ? connectors.value : [],
|
|
83
|
+
errors,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -14,8 +14,8 @@ import { prompt } from "../prompts.js";
|
|
|
14
14
|
import { currentTenant } from "../tenants/tenant.js";
|
|
15
15
|
import { ServiceError } from "./errors.js";
|
|
16
16
|
import { freeSlug, pageTree } from "./knowledge.js";
|
|
17
|
-
import { keepText, queueIndex } from "./project-index.js";
|
|
18
17
|
import { categoryRow, categoryRows, numberOf, setItemCategories, } from "./space-categories.js";
|
|
18
|
+
import { keepText, queueIndex } from "./space-index.js";
|
|
19
19
|
const XLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
20
20
|
// --- tables from sheets ------------------------------------------------------------------
|
|
21
21
|
const NUMBER = /^-?[\d\s.,']+\s*(€|eur|%|kg|t|h|mm|cm|m|km|stk\.?|stück)?$/i;
|
|
@@ -233,11 +233,11 @@ async function insertPage(file, input) {
|
|
|
233
233
|
await db.insert(schema.spacePage).values({
|
|
234
234
|
id,
|
|
235
235
|
tenantId: currentTenant(),
|
|
236
|
-
|
|
236
|
+
spaceId: file.spaceId,
|
|
237
237
|
parentId: input.parentId,
|
|
238
238
|
position: input.position,
|
|
239
239
|
title: input.title,
|
|
240
|
-
slug: await freeSlug(file.
|
|
240
|
+
slug: await freeSlug(file.spaceId, input.title, { parentId: input.parentId }),
|
|
241
241
|
markdown: input.markdown.slice(0, 200_000),
|
|
242
242
|
fileId: file.id,
|
|
243
243
|
origin: file.origin,
|
|
@@ -278,9 +278,9 @@ export async function convertDocument(file, data) {
|
|
|
278
278
|
await db.insert(schema.spaceTable).values({
|
|
279
279
|
id,
|
|
280
280
|
tenantId: currentTenant(),
|
|
281
|
-
|
|
281
|
+
spaceId: file.spaceId,
|
|
282
282
|
title,
|
|
283
|
-
slug: await freeSlug(file.
|
|
283
|
+
slug: await freeSlug(file.spaceId, title, "table"),
|
|
284
284
|
columns,
|
|
285
285
|
fileId: file.id,
|
|
286
286
|
origin: file.origin,
|
|
@@ -351,7 +351,7 @@ export async function convertDocument(file, data) {
|
|
|
351
351
|
}));
|
|
352
352
|
}
|
|
353
353
|
// References to other parts become links, now that each part has its path.
|
|
354
|
-
const tree = await pageTree(file.
|
|
354
|
+
const tree = await pageTree(file.spaceId);
|
|
355
355
|
const targets = new Map();
|
|
356
356
|
ids.forEach((id, k) => {
|
|
357
357
|
const ref = referenceKey(split.parts[k].title);
|
|
@@ -392,9 +392,9 @@ export async function convertDocument(file, data) {
|
|
|
392
392
|
* Fills the space's categories of an item from its text, where the space has any and nothing
|
|
393
393
|
* set them yet. Values a person set are never touched. True when anything was set.
|
|
394
394
|
*/
|
|
395
|
-
export async function fillCategories(
|
|
395
|
+
export async function fillCategories(spaceId, ref, text, name) {
|
|
396
396
|
// A column's category comes from its cells, not from a model.
|
|
397
|
-
const categories = (await categoryRows(
|
|
397
|
+
const categories = (await categoryRows(spaceId)).filter((c) => !(c.proposed || c.tableId));
|
|
398
398
|
if (!(categories.length && text.trim())) {
|
|
399
399
|
return false;
|
|
400
400
|
}
|
|
@@ -447,7 +447,7 @@ export async function fillCategories(projectId, ref, text, name) {
|
|
|
447
447
|
if (!Object.keys(input).length) {
|
|
448
448
|
return false;
|
|
449
449
|
}
|
|
450
|
-
const { changed } = await setItemCategories(
|
|
450
|
+
const { changed } = await setItemCategories(spaceId, ref, input, "model");
|
|
451
451
|
return changed;
|
|
452
452
|
}
|
|
453
453
|
// --- the summary of a value -----------------------------------------------------------------
|
|
@@ -492,8 +492,8 @@ async function itemsOfValue(valueId) {
|
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
else if (r.fileId) {
|
|
495
|
-
const file = await db.query.
|
|
496
|
-
where: eq(schema.
|
|
495
|
+
const file = await db.query.spaceFile.findFirst({
|
|
496
|
+
where: eq(schema.spaceFile.id, r.fileId),
|
|
497
497
|
});
|
|
498
498
|
if (file) {
|
|
499
499
|
out.push({ title: file.name, text: file.description });
|
|
@@ -540,8 +540,8 @@ export async function writeSummary(valueId) {
|
|
|
540
540
|
return summary;
|
|
541
541
|
}
|
|
542
542
|
/** After a source wrote: the values it filled that have three items or more get their summary. */
|
|
543
|
-
export async function summarizeValues(
|
|
544
|
-
const categories = (await categoryRows(
|
|
543
|
+
export async function summarizeValues(spaceId, categoryName, value) {
|
|
544
|
+
const categories = (await categoryRows(spaceId)).filter((c) => c.type === "choice" &&
|
|
545
545
|
!c.proposed &&
|
|
546
546
|
(!categoryName || c.name.toLowerCase() === categoryName.trim().toLowerCase()));
|
|
547
547
|
let written = 0;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { formatTableCell } from "@engenty/wizards-shared/engenty/data-tables";
|
|
2
2
|
import { slugOf, } from "@engenty/wizards-shared/knowledge";
|
|
3
3
|
import { and, asc, count, eq, inArray, isNotNull, isNull } from "drizzle-orm";
|
|
4
|
+
import { assertRwx, pageResources, readable, tableResources } from "../broker/rwx.js";
|
|
4
5
|
import { db, schema } from "../db/client.js";
|
|
5
6
|
import { embeddingModel, systemOneAccess } from "../models.js";
|
|
6
7
|
import { prompt } from "../prompts.js";
|
|
7
8
|
import { notFound, ServiceError } from "./errors.js";
|
|
8
|
-
import { ownedProject } from "./projects.js";
|
|
9
9
|
import { categoryLines, categoryRows, dateOf, filterItems, itemCategoriesOf, listCategories, numberOf, } from "./space-categories.js";
|
|
10
|
+
import { ownedSpace } from "./spaces.js";
|
|
10
11
|
/** Gives each item without a slug one, unique among its siblings, and keeps it. */
|
|
11
12
|
async function slugsFor(rows, siblingsOf, save) {
|
|
12
13
|
const taken = new Map();
|
|
@@ -37,14 +38,14 @@ async function slugsFor(rows, siblingsOf, save) {
|
|
|
37
38
|
return out;
|
|
38
39
|
}
|
|
39
40
|
/** A slug for a new page among its siblings, or a new table among the space's tables. */
|
|
40
|
-
export async function freeSlug(
|
|
41
|
+
export async function freeSlug(spaceId, title, of, except) {
|
|
41
42
|
const rows = of === "table"
|
|
42
43
|
? await db.query.spaceTable.findMany({
|
|
43
|
-
where: and(eq(schema.spaceTable.
|
|
44
|
+
where: and(eq(schema.spaceTable.spaceId, spaceId), isNull(schema.spaceTable.wizardId)),
|
|
44
45
|
columns: { id: true, slug: true },
|
|
45
46
|
})
|
|
46
47
|
: await db.query.spacePage.findMany({
|
|
47
|
-
where: and(eq(schema.spacePage.
|
|
48
|
+
where: and(eq(schema.spacePage.spaceId, spaceId), isNull(schema.spacePage.wizardId), of.parentId
|
|
48
49
|
? eq(schema.spacePage.parentId, of.parentId)
|
|
49
50
|
: isNull(schema.spacePage.parentId)),
|
|
50
51
|
columns: { id: true, slug: true },
|
|
@@ -58,9 +59,9 @@ export async function freeSlug(projectId, title, of, except) {
|
|
|
58
59
|
return slug;
|
|
59
60
|
}
|
|
60
61
|
/** The space's own pages with their paths, by id. */
|
|
61
|
-
export async function pageTree(
|
|
62
|
+
export async function pageTree(spaceId) {
|
|
62
63
|
const rows = await db.query.spacePage.findMany({
|
|
63
|
-
where: and(eq(schema.spacePage.
|
|
64
|
+
where: and(eq(schema.spacePage.spaceId, spaceId), isNull(schema.spacePage.wizardId)),
|
|
64
65
|
columns: { id: true, parentId: true, title: true, slug: true, position: true },
|
|
65
66
|
orderBy: [asc(schema.spacePage.position), asc(schema.spacePage.title)],
|
|
66
67
|
});
|
|
@@ -97,9 +98,9 @@ export async function pageTree(projectId) {
|
|
|
97
98
|
return out;
|
|
98
99
|
}
|
|
99
100
|
/** The space's own tables with their paths, by id. */
|
|
100
|
-
export async function tablePaths(
|
|
101
|
+
export async function tablePaths(spaceId) {
|
|
101
102
|
const rows = await db.query.spaceTable.findMany({
|
|
102
|
-
where: and(eq(schema.spaceTable.
|
|
103
|
+
where: and(eq(schema.spaceTable.spaceId, spaceId), isNull(schema.spaceTable.wizardId)),
|
|
103
104
|
columns: { id: true, slug: true, title: true },
|
|
104
105
|
orderBy: [asc(schema.spaceTable.createdAt)],
|
|
105
106
|
});
|
|
@@ -107,11 +108,11 @@ export async function tablePaths(projectId) {
|
|
|
107
108
|
return new Map(rows.map((r) => [r.id, `tables/${slugs.get(r.id)}`]));
|
|
108
109
|
}
|
|
109
110
|
/** The space's documents with their paths, by id: their names, made unique. */
|
|
110
|
-
export async function filePaths(
|
|
111
|
-
const rows = await db.query.
|
|
112
|
-
where: and(eq(schema.
|
|
111
|
+
export async function filePaths(spaceId) {
|
|
112
|
+
const rows = await db.query.spaceFile.findMany({
|
|
113
|
+
where: and(eq(schema.spaceFile.spaceId, spaceId), eq(schema.spaceFile.kind, "document")),
|
|
113
114
|
columns: { id: true, name: true },
|
|
114
|
-
orderBy: [asc(schema.
|
|
115
|
+
orderBy: [asc(schema.spaceFile.createdAt)],
|
|
115
116
|
});
|
|
116
117
|
const taken = new Set();
|
|
117
118
|
const out = new Map();
|
|
@@ -133,24 +134,24 @@ const cleanPath = (path) => path
|
|
|
133
134
|
.replace(/\.(md|csv)$/i, "")
|
|
134
135
|
.toLowerCase();
|
|
135
136
|
/** What a path names; null when nothing in the space has it. */
|
|
136
|
-
export async function resolvePath(
|
|
137
|
+
export async function resolvePath(spaceId, path) {
|
|
137
138
|
const want = cleanPath(path);
|
|
138
139
|
if (want.startsWith("pages/")) {
|
|
139
|
-
for (const node of (await pageTree(
|
|
140
|
+
for (const node of (await pageTree(spaceId)).values()) {
|
|
140
141
|
if (node.path === want) {
|
|
141
142
|
return { kind: "page", id: node.id, path: node.path };
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
else if (want.startsWith("tables/")) {
|
|
146
|
-
for (const [id, p] of await tablePaths(
|
|
147
|
+
for (const [id, p] of await tablePaths(spaceId)) {
|
|
147
148
|
if (p === want) {
|
|
148
149
|
return { kind: "table", id, path: p };
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
else if (want.startsWith("files/")) {
|
|
153
|
-
for (const [id, p] of await filePaths(
|
|
154
|
+
for (const [id, p] of await filePaths(spaceId)) {
|
|
154
155
|
if (p.toLowerCase() === want) {
|
|
155
156
|
return { kind: "file", id, path: p };
|
|
156
157
|
}
|
|
@@ -160,38 +161,48 @@ export async function resolvePath(projectId, path) {
|
|
|
160
161
|
}
|
|
161
162
|
// --- what the studio lists ---------------------------------------------------------
|
|
162
163
|
/** Files a page or a table was read from: they stand behind it, not on their own. */
|
|
163
|
-
async function convertedFiles(
|
|
164
|
+
async function convertedFiles(spaceId) {
|
|
164
165
|
const [pages, tables] = await Promise.all([
|
|
165
166
|
db
|
|
166
167
|
.selectDistinct({ id: schema.spacePage.fileId })
|
|
167
168
|
.from(schema.spacePage)
|
|
168
|
-
.where(and(eq(schema.spacePage.
|
|
169
|
+
.where(and(eq(schema.spacePage.spaceId, spaceId), isNotNull(schema.spacePage.fileId))),
|
|
169
170
|
db
|
|
170
171
|
.selectDistinct({ id: schema.spaceTable.fileId })
|
|
171
172
|
.from(schema.spaceTable)
|
|
172
|
-
.where(and(eq(schema.spaceTable.
|
|
173
|
+
.where(and(eq(schema.spaceTable.spaceId, spaceId), isNotNull(schema.spaceTable.fileId))),
|
|
173
174
|
]);
|
|
174
175
|
return new Set([...pages, ...tables].map((r) => r.id));
|
|
175
176
|
}
|
|
176
|
-
/**
|
|
177
|
-
|
|
178
|
-
const
|
|
177
|
+
/** The items among these the subjects may read, each with the document it was made from. */
|
|
178
|
+
async function readableItems(spaceId, who, items) {
|
|
179
|
+
const ok = await readable(spaceId, who, items.map((i) => i.kind === "file"
|
|
180
|
+
? { kind: "document", id: i.id }
|
|
181
|
+
: { kind: i.kind, id: i.id, fileId: i.fileId }));
|
|
182
|
+
return items.filter((i) => ok.has(i.id));
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Everything Knowledge holds that `who` may read: pages (sub-pages counted under them), tables,
|
|
186
|
+
* files, categories.
|
|
187
|
+
*/
|
|
188
|
+
export async function listKnowledge(userId, spaceId, who) {
|
|
189
|
+
const space = await ownedSpace(userId, spaceId);
|
|
179
190
|
const [tree, tables, rowCounts, files, converted, categories, embeddings, checker] = await Promise.all([
|
|
180
|
-
pageTree(
|
|
191
|
+
pageTree(space.id),
|
|
181
192
|
db.query.spaceTable.findMany({
|
|
182
|
-
where: and(eq(schema.spaceTable.
|
|
193
|
+
where: and(eq(schema.spaceTable.spaceId, space.id), isNull(schema.spaceTable.wizardId)),
|
|
183
194
|
}),
|
|
184
195
|
db
|
|
185
196
|
.select({ tableId: schema.spaceTableRow.tableId, n: count() })
|
|
186
197
|
.from(schema.spaceTableRow)
|
|
187
198
|
.innerJoin(schema.spaceTable, eq(schema.spaceTable.id, schema.spaceTableRow.tableId))
|
|
188
|
-
.where(and(eq(schema.spaceTable.
|
|
199
|
+
.where(and(eq(schema.spaceTable.spaceId, space.id), isNull(schema.spaceTable.wizardId)))
|
|
189
200
|
.groupBy(schema.spaceTableRow.tableId),
|
|
190
|
-
db.query.
|
|
191
|
-
where: and(eq(schema.
|
|
201
|
+
db.query.spaceFile.findMany({
|
|
202
|
+
where: and(eq(schema.spaceFile.spaceId, space.id), eq(schema.spaceFile.kind, "document")),
|
|
192
203
|
}),
|
|
193
|
-
convertedFiles(
|
|
194
|
-
listCategories(
|
|
204
|
+
convertedFiles(space.id),
|
|
205
|
+
listCategories(space.id),
|
|
195
206
|
embeddingModel()
|
|
196
207
|
.then(Boolean)
|
|
197
208
|
.catch(() => false),
|
|
@@ -199,10 +210,10 @@ export async function listKnowledge(userId, projectId) {
|
|
|
199
210
|
.then(Boolean)
|
|
200
211
|
.catch(() => false),
|
|
201
212
|
]);
|
|
202
|
-
const tPaths = await tablePaths(
|
|
203
|
-
const fPaths = await filePaths(
|
|
213
|
+
const tPaths = await tablePaths(space.id);
|
|
214
|
+
const fPaths = await filePaths(space.id);
|
|
204
215
|
const pages = await db.query.spacePage.findMany({
|
|
205
|
-
where: and(eq(schema.spacePage.
|
|
216
|
+
where: and(eq(schema.spacePage.spaceId, space.id), isNull(schema.spacePage.wizardId), isNull(schema.spacePage.parentId)),
|
|
206
217
|
columns: { markdown: false },
|
|
207
218
|
});
|
|
208
219
|
const children = new Map();
|
|
@@ -276,10 +287,15 @@ export async function listKnowledge(userId, projectId) {
|
|
|
276
287
|
})),
|
|
277
288
|
];
|
|
278
289
|
items.sort((a, b) => a.title.localeCompare(b.title, "de"));
|
|
279
|
-
return {
|
|
290
|
+
return {
|
|
291
|
+
items: await readableItems(space.id, who, items),
|
|
292
|
+
categories,
|
|
293
|
+
embeddings,
|
|
294
|
+
checked: checker,
|
|
295
|
+
};
|
|
280
296
|
}
|
|
281
297
|
/** A value opened in the studio: its summary, and the items and rows that have it. */
|
|
282
|
-
export async function valueContents(userId, valueId) {
|
|
298
|
+
export async function valueContents(userId, valueId, who) {
|
|
283
299
|
const value = await db.query.spaceCategoryValue.findFirst({
|
|
284
300
|
where: eq(schema.spaceCategoryValue.id, valueId),
|
|
285
301
|
});
|
|
@@ -291,7 +307,7 @@ export async function valueContents(userId, valueId) {
|
|
|
291
307
|
if (!(value && category)) {
|
|
292
308
|
throw notFound();
|
|
293
309
|
}
|
|
294
|
-
const
|
|
310
|
+
const space = await ownedSpace(userId, category.spaceId);
|
|
295
311
|
const having = await db.query.spaceItemCategory.findMany({
|
|
296
312
|
where: eq(schema.spaceItemCategory.valueId, value.id),
|
|
297
313
|
});
|
|
@@ -301,32 +317,35 @@ export async function valueContents(userId, valueId) {
|
|
|
301
317
|
category: { id: category.id, name: category.name },
|
|
302
318
|
summary: value.summary,
|
|
303
319
|
summaryAt: value.summaryAt?.toISOString() ?? null,
|
|
304
|
-
...(await itemsHaving(userId,
|
|
320
|
+
...(await itemsHaving(userId, space.id, having, who)),
|
|
305
321
|
};
|
|
306
322
|
}
|
|
307
323
|
/** Everything that has a category, whatever its value: what the category's page lists. */
|
|
308
|
-
export async function categoryContents(userId, categoryId) {
|
|
324
|
+
export async function categoryContents(userId, categoryId, who) {
|
|
309
325
|
const category = await db.query.spaceCategory.findFirst({
|
|
310
326
|
where: eq(schema.spaceCategory.id, categoryId),
|
|
311
327
|
});
|
|
312
328
|
if (!category) {
|
|
313
329
|
throw notFound();
|
|
314
330
|
}
|
|
315
|
-
const
|
|
331
|
+
const space = await ownedSpace(userId, category.spaceId);
|
|
316
332
|
const having = await db.query.spaceItemCategory.findMany({
|
|
317
333
|
where: eq(schema.spaceItemCategory.categoryId, category.id),
|
|
318
334
|
});
|
|
319
|
-
return itemsHaving(userId,
|
|
335
|
+
return itemsHaving(userId, space.id, having, who);
|
|
320
336
|
}
|
|
321
|
-
/**
|
|
322
|
-
|
|
323
|
-
|
|
337
|
+
/**
|
|
338
|
+
* The items rows of `space_item_category` name, as the studio lists them, and rows by table;
|
|
339
|
+
* only what `who` may read.
|
|
340
|
+
*/
|
|
341
|
+
async function itemsHaving(userId, spaceId, having, who) {
|
|
342
|
+
const space = { id: spaceId };
|
|
324
343
|
const pageIds = having.flatMap((h) => (h.pageId ? [h.pageId] : []));
|
|
325
344
|
const tableIds = having.flatMap((h) => (h.tableId ? [h.tableId] : []));
|
|
326
345
|
const fileIds = having.flatMap((h) => (h.fileId ? [h.fileId] : []));
|
|
327
346
|
const rowIds = having.flatMap((h) => (h.rowId ? [h.rowId] : []));
|
|
328
|
-
const all = await listKnowledge(userId,
|
|
329
|
-
const tree = await pageTree(
|
|
347
|
+
const all = await listKnowledge(userId, space.id, who);
|
|
348
|
+
const tree = await pageTree(space.id);
|
|
330
349
|
const subPages = pageIds.filter((id) => !all.items.some((i) => i.key === `p:${id}`));
|
|
331
350
|
const subItems = [];
|
|
332
351
|
if (subPages.length) {
|
|
@@ -364,12 +383,19 @@ async function itemsHaving(userId, projectId, having) {
|
|
|
364
383
|
rowTables.set(r.tableId, (rowTables.get(r.tableId) ?? 0) + 1);
|
|
365
384
|
}
|
|
366
385
|
}
|
|
386
|
+
// A row is read as its table is.
|
|
387
|
+
const readTables = await readable(space.id, who, await tableResources([...rowTables.keys()]));
|
|
388
|
+
for (const tableId of [...rowTables.keys()]) {
|
|
389
|
+
if (!readTables.has(tableId)) {
|
|
390
|
+
rowTables.delete(tableId);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
367
393
|
return {
|
|
368
394
|
items: [
|
|
369
395
|
...all.items.filter((i) => (i.kind === "page" && pageIds.includes(i.id)) ||
|
|
370
396
|
(i.kind === "table" && tableIds.includes(i.id)) ||
|
|
371
397
|
(i.kind === "file" && fileIds.includes(i.id))),
|
|
372
|
-
...subItems,
|
|
398
|
+
...(await readableItems(space.id, who, subItems)),
|
|
373
399
|
],
|
|
374
400
|
rows: [...rowTables].map(([tableId, n]) => ({
|
|
375
401
|
tableId,
|
|
@@ -380,7 +406,7 @@ async function itemsHaving(userId, projectId, having) {
|
|
|
380
406
|
}
|
|
381
407
|
/** What the studio shows around a page of Knowledge: where it stands, its sub-pages, its origin. */
|
|
382
408
|
export async function knowledgePage(page) {
|
|
383
|
-
const tree = await pageTree(page.
|
|
409
|
+
const tree = await pageTree(page.spaceId);
|
|
384
410
|
const node = tree.get(page.id);
|
|
385
411
|
const parents = [];
|
|
386
412
|
for (let at = node?.parentId ? tree.get(node.parentId) : undefined; at;) {
|
|
@@ -392,8 +418,8 @@ export async function knowledgePage(page) {
|
|
|
392
418
|
.sort((a, b) => a.position - b.position || a.title.localeCompare(b.title, "de"))
|
|
393
419
|
.map((n) => ({ id: n.id, title: n.title, path: n.path }));
|
|
394
420
|
const file = page.fileId
|
|
395
|
-
? await db.query.
|
|
396
|
-
where: eq(schema.
|
|
421
|
+
? await db.query.spaceFile.findFirst({
|
|
422
|
+
where: eq(schema.spaceFile.id, page.fileId),
|
|
397
423
|
columns: { id: true, name: true, mime: true },
|
|
398
424
|
})
|
|
399
425
|
: undefined;
|
|
@@ -448,24 +474,25 @@ function sectionOf(markdown, wanted) {
|
|
|
448
474
|
* original, its parent and sub-pages) and its Markdown, or one section of it. Long pages come in
|
|
449
475
|
* parts: `from` continues where the last part ended.
|
|
450
476
|
*/
|
|
451
|
-
export async function readPage(
|
|
452
|
-
const found = await resolvePath(
|
|
477
|
+
export async function readPage(spaceId, path, opts, who) {
|
|
478
|
+
const found = await resolvePath(spaceId, path);
|
|
453
479
|
if (found?.kind !== "page") {
|
|
454
|
-
throw new ServiceError("not_found", `No page "${path}".
|
|
480
|
+
throw new ServiceError("not_found", `No page "${path}". space_list or space_search name the pages there are.`);
|
|
455
481
|
}
|
|
456
482
|
const page = await db.query.spacePage.findFirst({ where: eq(schema.spacePage.id, found.id) });
|
|
457
483
|
if (!page) {
|
|
458
484
|
throw notFound();
|
|
459
485
|
}
|
|
460
|
-
|
|
486
|
+
await assertRwx(spaceId, who, { kind: "page", id: page.id, fileId: page.fileId }, "r");
|
|
487
|
+
const tree = await pageTree(spaceId);
|
|
461
488
|
const node = tree.get(page.id);
|
|
462
|
-
const categories = await categoryRows(
|
|
489
|
+
const categories = await categoryRows(spaceId);
|
|
463
490
|
const lines = categoryLines(categories, (await itemCategoriesOf([{ pageId: page.id }])).get(`p:${page.id}`));
|
|
464
491
|
const children = [...tree.values()]
|
|
465
492
|
.filter((n) => n.parentId === page.id)
|
|
466
493
|
.sort((a, b) => a.position - b.position)
|
|
467
494
|
.map((n) => n.path);
|
|
468
|
-
const original = page.fileId ? (await filePaths(
|
|
495
|
+
const original = page.fileId ? (await filePaths(spaceId)).get(page.fileId) : undefined;
|
|
469
496
|
const front = [
|
|
470
497
|
"---",
|
|
471
498
|
`title: ${yamlValue(page.title)}`,
|
|
@@ -480,7 +507,7 @@ export async function readPage(projectId, path, opts = {}) {
|
|
|
480
507
|
...(page.originLabel ? [`source: ${yamlValue(page.originLabel)}`] : []),
|
|
481
508
|
...(original ? [`original: ${original}`] : []),
|
|
482
509
|
...(children.length ? ["sub-pages:", ...children.slice(0, 200).map((c) => ` - ${c}`)] : []),
|
|
483
|
-
...(children.length > 200 ? [` # … ${children.length - 200} more, see
|
|
510
|
+
...(children.length > 200 ? [` # … ${children.length - 200} more, see space_list`] : []),
|
|
484
511
|
"---",
|
|
485
512
|
].join("\n");
|
|
486
513
|
let text = page.markdown;
|
|
@@ -538,15 +565,16 @@ const csvCell = (value) => /[",\n;]/.test(value) ? `"${value.replace(/"/g, '""')
|
|
|
538
565
|
* A table as a step reads it: its rows as CSV, filtered by its columns (by their names), a few
|
|
539
566
|
* hundred at a time.
|
|
540
567
|
*/
|
|
541
|
-
export async function readTable(
|
|
542
|
-
const found = await resolvePath(
|
|
568
|
+
export async function readTable(spaceId, path, opts, who) {
|
|
569
|
+
const found = await resolvePath(spaceId, path);
|
|
543
570
|
if (found?.kind !== "table") {
|
|
544
|
-
throw new ServiceError("not_found", `No table "${path}".
|
|
571
|
+
throw new ServiceError("not_found", `No table "${path}". space_list or space_search name the tables there are.`);
|
|
545
572
|
}
|
|
546
573
|
const table = await db.query.spaceTable.findFirst({ where: eq(schema.spaceTable.id, found.id) });
|
|
547
574
|
if (!table) {
|
|
548
575
|
throw notFound();
|
|
549
576
|
}
|
|
577
|
+
await assertRwx(spaceId, who, { kind: "table", id: table.id, fileId: table.fileId }, "r");
|
|
550
578
|
const byName = (name) => table.columns.find((c) => c.name.toLowerCase() === name.trim().toLowerCase() || c.id === name.trim());
|
|
551
579
|
const filters = Object.entries(opts.where ?? {}).map(([name, w]) => {
|
|
552
580
|
const column = byName(name);
|
|
@@ -587,11 +615,11 @@ export async function readTable(projectId, path, opts = {}) {
|
|
|
587
615
|
};
|
|
588
616
|
}
|
|
589
617
|
/**
|
|
590
|
-
* For
|
|
591
|
-
* has; with one, the items it leaves, with their paths and categories.
|
|
618
|
+
* For space_list: without a filter, the categories with their values and how many items each
|
|
619
|
+
* has; with one, the items it leaves that `who` may read, with their paths and categories.
|
|
592
620
|
*/
|
|
593
|
-
export async function listForStep(
|
|
594
|
-
const categories = await listCategories(
|
|
621
|
+
export async function listForStep(spaceId, where, who) {
|
|
622
|
+
const categories = await listCategories(spaceId);
|
|
595
623
|
const taken = categories.filter((c) => !c.proposed);
|
|
596
624
|
if (!Object.keys(where ?? {}).length) {
|
|
597
625
|
return {
|
|
@@ -608,16 +636,20 @@ export async function listForStep(projectId, where) {
|
|
|
608
636
|
hint: 'Pass `where` to list the items of values, e.g. { "Baustelle": "Graz Süd" }.',
|
|
609
637
|
};
|
|
610
638
|
}
|
|
611
|
-
const filtered = await filterItems(
|
|
639
|
+
const filtered = await filterItems(spaceId, where);
|
|
612
640
|
const [tree, tPaths, fPaths] = await Promise.all([
|
|
613
|
-
pageTree(
|
|
614
|
-
tablePaths(
|
|
615
|
-
filePaths(
|
|
641
|
+
pageTree(spaceId),
|
|
642
|
+
tablePaths(spaceId),
|
|
643
|
+
filePaths(spaceId),
|
|
616
644
|
]);
|
|
645
|
+
const okPages = await readable(spaceId, who, await pageResources([...(filtered?.pages ?? [])]));
|
|
646
|
+
const okFiles = await readable(spaceId, who, [...(filtered?.files ?? [])].map((id) => ({ kind: "document", id })));
|
|
647
|
+
const pages = [...(filtered?.pages ?? [])].filter((id) => okPages.has(id));
|
|
648
|
+
const files = [...(filtered?.files ?? [])].filter((id) => okFiles.has(id));
|
|
617
649
|
const refs = [
|
|
618
|
-
...
|
|
650
|
+
...pages.map((pageId) => ({ pageId })),
|
|
619
651
|
...[...(filtered?.tables ?? [])].map((tableId) => ({ tableId })),
|
|
620
|
-
...
|
|
652
|
+
...files.map((fileId) => ({ fileId })),
|
|
621
653
|
];
|
|
622
654
|
const cats = await itemCategoriesOf(refs);
|
|
623
655
|
// Rows whose table is not left as a whole: by their table, with how many.
|
|
@@ -633,8 +665,11 @@ export async function listForStep(projectId, where) {
|
|
|
633
665
|
}
|
|
634
666
|
}
|
|
635
667
|
}
|
|
668
|
+
// A table, and the rows of one, as its holder may read it.
|
|
669
|
+
const okTables = await readable(spaceId, who, await tableResources([...(filtered?.tables ?? []), ...rowTables.keys()]));
|
|
670
|
+
const tables = [...(filtered?.tables ?? [])].filter((id) => okTables.has(id));
|
|
636
671
|
const items = [
|
|
637
|
-
...
|
|
672
|
+
...pages
|
|
638
673
|
.map((id) => tree.get(id))
|
|
639
674
|
.filter((n) => Boolean(n))
|
|
640
675
|
.sort((a, b) => a.path.localeCompare(b.path))
|
|
@@ -643,17 +678,19 @@ export async function listForStep(projectId, where) {
|
|
|
643
678
|
title: n.title,
|
|
644
679
|
categories: categoryLines(taken, cats.get(`p:${n.id}`)),
|
|
645
680
|
})),
|
|
646
|
-
...
|
|
681
|
+
...tables.map((id) => ({
|
|
647
682
|
path: tPaths.get(id) ?? "",
|
|
648
683
|
title: "",
|
|
649
684
|
categories: categoryLines(taken, cats.get(`t:${id}`)),
|
|
650
685
|
})),
|
|
651
|
-
...[...rowTables]
|
|
686
|
+
...[...rowTables]
|
|
687
|
+
.filter(([id]) => okTables.has(id))
|
|
688
|
+
.map(([id, n]) => ({
|
|
652
689
|
path: tPaths.get(id) ?? "",
|
|
653
690
|
title: `${n} rows match: read them with table_read and the same values as its columns`,
|
|
654
691
|
categories: [],
|
|
655
692
|
})),
|
|
656
|
-
...
|
|
693
|
+
...files.map((id) => ({
|
|
657
694
|
path: fPaths.get(id) ?? "",
|
|
658
695
|
title: "",
|
|
659
696
|
categories: categoryLines(taken, cats.get(`f:${id}`)),
|
|
@@ -662,20 +699,20 @@ export async function listForStep(projectId, where) {
|
|
|
662
699
|
return { items: items.slice(0, 200), total: items.length };
|
|
663
700
|
}
|
|
664
701
|
/** How much Knowledge a space holds: what the block of the steps' instructions says. */
|
|
665
|
-
export async function knowledgeCounts(
|
|
702
|
+
export async function knowledgeCounts(spaceId) {
|
|
666
703
|
const [pages, tables, files] = await Promise.all([
|
|
667
704
|
db
|
|
668
705
|
.select({ n: count() })
|
|
669
706
|
.from(schema.spacePage)
|
|
670
|
-
.where(and(eq(schema.spacePage.
|
|
707
|
+
.where(and(eq(schema.spacePage.spaceId, spaceId), isNull(schema.spacePage.wizardId))),
|
|
671
708
|
db
|
|
672
709
|
.select({ n: count() })
|
|
673
710
|
.from(schema.spaceTable)
|
|
674
|
-
.where(and(eq(schema.spaceTable.
|
|
711
|
+
.where(and(eq(schema.spaceTable.spaceId, spaceId), isNull(schema.spaceTable.wizardId))),
|
|
675
712
|
db
|
|
676
713
|
.select({ n: count() })
|
|
677
|
-
.from(schema.
|
|
678
|
-
.where(and(eq(schema.
|
|
714
|
+
.from(schema.spaceFile)
|
|
715
|
+
.where(and(eq(schema.spaceFile.spaceId, spaceId), eq(schema.spaceFile.kind, "document"))),
|
|
679
716
|
]);
|
|
680
717
|
return { pages: pages[0].n, tables: tables[0].n, files: files[0].n };
|
|
681
718
|
}
|
|
@@ -683,12 +720,12 @@ export async function knowledgeCounts(projectId) {
|
|
|
683
720
|
* What every step of the space is told about Knowledge: how much there is, the categories to filter
|
|
684
721
|
* by, the tools to find and read. Empty when Knowledge is.
|
|
685
722
|
*/
|
|
686
|
-
export async function knowledgeBlock(
|
|
687
|
-
const counts = await knowledgeCounts(
|
|
723
|
+
export async function knowledgeBlock(spaceId) {
|
|
724
|
+
const counts = await knowledgeCounts(spaceId);
|
|
688
725
|
if (!(counts.pages || counts.tables || counts.files)) {
|
|
689
726
|
return "";
|
|
690
727
|
}
|
|
691
|
-
const categories = (await listCategories(
|
|
728
|
+
const categories = (await listCategories(spaceId)).filter((c) => !c.proposed && c.count);
|
|
692
729
|
const what = [
|
|
693
730
|
counts.pages ? `${counts.pages} pages` : "",
|
|
694
731
|
counts.tables ? `${counts.tables} tables` : "",
|