@engenty/wizards-runtime 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. package/apps/runtime/dist/agents/architect.js +8 -7
  2. package/apps/runtime/dist/agents/goose-connections.js +82 -0
  3. package/apps/runtime/dist/agents/space-agent.js +9 -2
  4. package/apps/runtime/dist/agents/studio-assistant.js +101 -67
  5. package/apps/runtime/dist/agents/website.js +1 -1
  6. package/apps/runtime/dist/app.js +17 -1
  7. package/apps/runtime/dist/assistant/knows.js +6 -5
  8. package/apps/runtime/dist/authoring/guide.js +25 -5
  9. package/apps/runtime/dist/broker/account.js +166 -0
  10. package/apps/runtime/dist/broker/call.js +417 -0
  11. package/apps/runtime/dist/broker/caller.js +10 -0
  12. package/apps/runtime/dist/broker/grant.js +152 -0
  13. package/apps/runtime/dist/broker/host.js +51 -0
  14. package/apps/runtime/dist/broker/index.js +8 -0
  15. package/apps/runtime/dist/broker/kept.js +31 -0
  16. package/apps/runtime/dist/broker/log.js +240 -0
  17. package/apps/runtime/dist/broker/registry.js +9 -0
  18. package/apps/runtime/dist/broker/rwx.js +367 -0
  19. package/apps/runtime/dist/broker/send.js +189 -0
  20. package/apps/runtime/dist/connectors/builtin.js +1 -1
  21. package/apps/runtime/dist/connectors/external.js +38 -37
  22. package/apps/runtime/dist/connectors/index.js +30 -91
  23. package/apps/runtime/dist/connectors/mail.js +0 -8
  24. package/apps/runtime/dist/connectors/person-sign-ins.js +73 -0
  25. package/apps/runtime/dist/connectors/plugin-connections.js +65 -92
  26. package/apps/runtime/dist/connectors/smtp.js +1 -1
  27. package/apps/runtime/dist/connectors/space-connections.js +436 -0
  28. package/apps/runtime/dist/db/adopt.js +3 -3
  29. package/apps/runtime/dist/db/client.js +9 -0
  30. package/apps/runtime/dist/db/live-triggers.js +65 -23
  31. package/apps/runtime/dist/db/migrations/tenant/0027_work_chats.sql +52 -0
  32. package/apps/runtime/dist/db/migrations/tenant/0028_chat_approvals.sql +17 -0
  33. package/apps/runtime/dist/db/migrations/tenant/0029_work_chats_live.sql +49 -0
  34. package/apps/runtime/dist/db/migrations/tenant/0031_space.sql +624 -0
  35. package/apps/runtime/dist/db/migrations/tenant/0032_rwx_rule.sql +18 -0
  36. package/apps/runtime/dist/db/migrations/tenant/0033_broker_log.sql +23 -0
  37. package/apps/runtime/dist/db/migrations/tenant/0034_space_connection.sql +35 -0
  38. package/apps/runtime/dist/db/migrations/tenant/0035_run_grant.sql +1 -0
  39. package/apps/runtime/dist/db/migrations/tenant/0036_approval_held_for.sql +1 -0
  40. package/apps/runtime/dist/db/migrations/tenant/0037_ways_out.sql +5 -0
  41. package/apps/runtime/dist/db/migrations/tenant/0038_heard.sql +11 -0
  42. package/apps/runtime/dist/db/migrations/tenant/0039_members_studio.sql +1 -0
  43. package/apps/runtime/dist/db/migrations/tenant/meta/0027_snapshot.json +383 -155
  44. package/apps/runtime/dist/db/migrations/tenant/meta/0028_snapshot.json +4468 -0
  45. package/apps/runtime/dist/db/migrations/tenant/meta/0029_snapshot.json +4475 -0
  46. package/apps/runtime/dist/db/migrations/tenant/meta/0030_snapshot.json +4629 -0
  47. package/apps/runtime/dist/db/migrations/tenant/meta/0031_snapshot.json +4629 -0
  48. package/apps/runtime/dist/db/migrations/tenant/meta/0032_snapshot.json +4757 -0
  49. package/apps/runtime/dist/db/migrations/tenant/meta/0033_snapshot.json +5039 -0
  50. package/apps/runtime/dist/db/migrations/tenant/meta/0034_snapshot.json +5022 -0
  51. package/apps/runtime/dist/db/migrations/tenant/meta/0035_snapshot.json +5029 -0
  52. package/apps/runtime/dist/db/migrations/tenant/meta/0036_snapshot.json +5037 -0
  53. package/apps/runtime/dist/db/migrations/tenant/meta/0037_snapshot.json +5076 -0
  54. package/apps/runtime/dist/db/migrations/tenant/meta/0038_snapshot.json +5145 -0
  55. package/apps/runtime/dist/db/migrations/tenant/meta/0039_snapshot.json +5153 -0
  56. package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +86 -2
  57. package/apps/runtime/dist/db/schema.js +295 -72
  58. package/apps/runtime/dist/docs/dev/architecture.md +215 -0
  59. package/apps/runtime/dist/docs/dev/broker.md +298 -0
  60. package/apps/runtime/dist/docs/dev/index.md +5 -1
  61. package/apps/runtime/dist/docs/dev/integration/index.md +2 -0
  62. package/apps/runtime/dist/docs/dev/meta.json +3 -0
  63. package/apps/runtime/dist/docs/dev/plugins/connections.md +8 -5
  64. package/apps/runtime/dist/docs/dev/plugins/events.md +1 -1
  65. package/apps/runtime/dist/docs/dev/plugins/examples.md +1 -0
  66. package/apps/runtime/dist/docs/dev/plugins/index.md +2 -2
  67. package/apps/runtime/dist/docs/dev/plugins/reference.md +3 -2
  68. package/apps/runtime/dist/docs/dev/plugins/space.md +16 -6
  69. package/apps/runtime/dist/docs/dev/plugins/studio.md +2 -2
  70. package/apps/runtime/dist/docs/dev/plugins/tools.md +0 -1
  71. package/apps/runtime/dist/docs/dev/skills.md +16 -9
  72. package/apps/runtime/dist/docs/dev/wizard-format/agent-steps.md +40 -5
  73. package/apps/runtime/dist/docs/dev/wizard-format/lists-and-connections.md +17 -2
  74. package/apps/runtime/dist/docs/dev/wizard-format/templates.md +2 -0
  75. package/apps/runtime/dist/docs/dev/wizard-format/views-and-widgets.md +22 -2
  76. package/apps/runtime/dist/docs/user-guide/capabilities.md +132 -0
  77. package/apps/runtime/dist/docs/user-guide/cloud-sync.md +2 -0
  78. package/apps/runtime/dist/docs/user-guide/command-line.md +1 -0
  79. package/apps/runtime/dist/docs/user-guide/connectors.md +63 -7
  80. package/apps/runtime/dist/docs/user-guide/index.md +10 -1
  81. package/apps/runtime/dist/docs/user-guide/meta.json +6 -1
  82. package/apps/runtime/dist/docs/user-guide/protocol.md +80 -0
  83. package/apps/runtime/dist/docs/user-guide/skills.md +8 -4
  84. package/apps/runtime/dist/docs/user-guide/space.md +5 -4
  85. package/apps/runtime/dist/docs/user-guide/together.md +16 -2
  86. package/apps/runtime/dist/docs/user-guide/troubleshooting.md +2 -2
  87. package/apps/runtime/dist/docs/user-guide/work-mode.md +128 -0
  88. package/apps/runtime/dist/engenty/connections-external/build-connector.js +2 -5
  89. package/apps/runtime/dist/engenty/connections-external/importer/classify.js +72 -0
  90. package/apps/runtime/dist/engenty/connections-google/connectors/gmail.js +1 -1
  91. package/apps/runtime/dist/engenty/connections-microsoft/outlook.js +3 -2
  92. package/apps/runtime/dist/engenty/connections-sdk/types.js +2 -0
  93. package/apps/runtime/dist/engenty/connections-slack/connector.js +2 -1
  94. package/apps/runtime/dist/engine/resources.js +43 -12
  95. package/apps/runtime/dist/engine/runner.js +75 -23
  96. package/apps/runtime/dist/engine/steps.js +30 -12
  97. package/apps/runtime/dist/engine/template.js +18 -1
  98. package/apps/runtime/dist/env.js +9 -4
  99. package/apps/runtime/dist/index.js +18 -2
  100. package/apps/runtime/dist/live/feed.js +2 -2
  101. package/apps/runtime/dist/live/origin.js +2 -2
  102. package/apps/runtime/dist/live/views.js +51 -26
  103. package/apps/runtime/dist/manage.js +7 -0
  104. package/apps/runtime/dist/mcp/flow-app.js +1 -1
  105. package/apps/runtime/dist/mcp/tools.js +75 -34
  106. package/apps/runtime/dist/models.js +1 -1
  107. package/apps/runtime/dist/motion-graphics/project.js +8 -8
  108. package/apps/runtime/dist/motion-graphics/tools.js +1 -1
  109. package/apps/runtime/dist/plugins/events.js +2 -2
  110. package/apps/runtime/dist/plugins/jobs.js +4 -1
  111. package/apps/runtime/dist/plugins/loader.js +2 -2
  112. package/apps/runtime/dist/prompts/architect.md +3 -3
  113. package/apps/runtime/dist/prompts/authoring.md +46 -12
  114. package/apps/runtime/dist/prompts/goose.md +7 -7
  115. package/apps/runtime/dist/prompts/mcp.md +6 -6
  116. package/apps/runtime/dist/prompts/services.md +4 -4
  117. package/apps/runtime/dist/prompts/step.md +2 -2
  118. package/apps/runtime/dist/prompts/tools.md +39 -10
  119. package/apps/runtime/dist/routes/api.js +31 -20
  120. package/apps/runtime/dist/routes/broker.js +316 -0
  121. package/apps/runtime/dist/routes/connections.js +71 -0
  122. package/apps/runtime/dist/routes/delivery.js +25 -0
  123. package/apps/runtime/dist/routes/discover.js +17 -0
  124. package/apps/runtime/dist/routes/live.js +11 -1
  125. package/apps/runtime/dist/routes/person.js +4 -1
  126. package/apps/runtime/dist/routes/plugins.js +3 -1
  127. package/apps/runtime/dist/routes/rules.js +26 -0
  128. package/apps/runtime/dist/routes/runs.js +54 -33
  129. package/apps/runtime/dist/routes/skills.js +6 -6
  130. package/apps/runtime/dist/routes/studio.js +153 -144
  131. package/apps/runtime/dist/routes/work.js +199 -0
  132. package/apps/runtime/dist/sandbox/index.js +27 -0
  133. package/apps/runtime/dist/services/access.js +38 -17
  134. package/apps/runtime/dist/services/api.js +38 -13
  135. package/apps/runtime/dist/services/architect.js +3 -3
  136. package/apps/runtime/dist/services/assistant-chats.js +9 -1
  137. package/apps/runtime/dist/services/brand.js +12 -12
  138. package/apps/runtime/dist/services/broker-bell.js +69 -0
  139. package/apps/runtime/dist/services/broker-notify.js +127 -0
  140. package/apps/runtime/dist/services/client-steps.js +79 -0
  141. package/apps/runtime/dist/services/cloud.js +42 -42
  142. package/apps/runtime/dist/services/command-risk.js +51 -0
  143. package/apps/runtime/dist/services/discover.js +85 -0
  144. package/apps/runtime/dist/services/knowledge-model.js +13 -13
  145. package/apps/runtime/dist/services/knowledge.js +117 -80
  146. package/apps/runtime/dist/services/manage-reports.js +74 -7
  147. package/apps/runtime/dist/services/members-studio.js +165 -0
  148. package/apps/runtime/dist/services/onboarding.js +22 -22
  149. package/apps/runtime/dist/services/package-file.js +1 -1
  150. package/apps/runtime/dist/services/package.js +22 -22
  151. package/apps/runtime/dist/services/pages.js +7 -7
  152. package/apps/runtime/dist/services/runs.js +4 -3
  153. package/apps/runtime/dist/services/seen.js +55 -0
  154. package/apps/runtime/dist/services/shares.js +23 -13
  155. package/apps/runtime/dist/services/site.js +23 -23
  156. package/apps/runtime/dist/services/skills-registry.js +15 -15
  157. package/apps/runtime/dist/services/skills.js +44 -44
  158. package/apps/runtime/dist/services/space-categories.js +35 -35
  159. package/apps/runtime/dist/services/space-data.js +130 -111
  160. package/apps/runtime/dist/services/{project-files.js → space-files.js} +84 -75
  161. package/apps/runtime/dist/services/{project-index.js → space-index.js} +116 -73
  162. package/apps/runtime/dist/services/space-origin.js +19 -11
  163. package/apps/runtime/dist/services/spaces.js +478 -612
  164. package/apps/runtime/dist/services/synced-spaces.js +668 -0
  165. package/apps/runtime/dist/services/themes.js +15 -15
  166. package/apps/runtime/dist/services/widgets.js +6 -6
  167. package/apps/runtime/dist/services/wizards.js +112 -38
  168. package/apps/runtime/dist/services/work-ai.js +257 -0
  169. package/apps/runtime/dist/services/work-approvals.js +104 -0
  170. package/apps/runtime/dist/services/work-chats.js +908 -0
  171. package/apps/runtime/dist/services/work-connections.js +90 -0
  172. package/apps/runtime/dist/services/work-files.js +85 -0
  173. package/apps/runtime/dist/services/work-mastra.js +73 -0
  174. package/apps/runtime/dist/services/work-sandbox.js +42 -0
  175. package/apps/runtime/dist/sharing/files.js +14 -4
  176. package/apps/runtime/dist/sharing/index.js +40 -39
  177. package/apps/runtime/dist/sharing/jobs.js +67 -17
  178. package/apps/runtime/dist/sharing/targets/connector.js +10 -6
  179. package/apps/runtime/dist/sharing/targets/email.js +10 -8
  180. package/apps/runtime/dist/sharing/targets/slack.js +10 -8
  181. package/apps/runtime/dist/sharing/targets/storage.js +6 -4
  182. package/apps/runtime/dist/store/index.js +14 -3
  183. package/apps/runtime/dist/store/shared-lists.js +4 -2
  184. package/apps/runtime/dist/sync/apply.js +2 -2
  185. package/apps/runtime/dist/sync/client.js +113 -113
  186. package/apps/runtime/dist/sync/hub.js +41 -41
  187. package/apps/runtime/dist/sync/log.js +12 -12
  188. package/apps/runtime/dist/sync/records.js +118 -120
  189. package/apps/runtime/dist/texts.js +38 -2
  190. package/apps/runtime/dist/tools/connections.js +112 -0
  191. package/apps/runtime/dist/tools/connector.js +157 -67
  192. package/apps/runtime/dist/tools/index.js +28 -13
  193. package/apps/runtime/dist/tools/mail.js +40 -11
  194. package/apps/runtime/dist/tools/pages.js +11 -5
  195. package/apps/runtime/dist/tools/plugin.js +43 -7
  196. package/apps/runtime/dist/tools/skills.js +1 -1
  197. package/apps/runtime/dist/tools/{project.js → space.js} +30 -25
  198. package/apps/runtime/dist/tools/store.js +3 -2
  199. package/apps/runtime/dist/widgets/step.js +10 -10
  200. package/apps/web/dist/assets/AboutDialog-DgfeipUc.js +1 -0
  201. package/apps/web/dist/assets/CapabilitiesPage-BoYJvgIu.js +2 -0
  202. package/apps/web/dist/assets/{ChangelogDialog-SwyId00t.js → ChangelogDialog-Duab4zTO.js} +1 -1
  203. package/apps/web/dist/assets/{CodeEditor-BwZsk5Al.js → CodeEditor-nxoOt8ge.js} +1 -1
  204. package/apps/web/dist/assets/EditorPage-ZrgGpYMC.js +3 -0
  205. package/apps/web/dist/assets/{FlowPreview-DtSpjVTl.js → FlowPreview-aMfwcPul.js} +1 -1
  206. package/apps/web/dist/assets/LangSwitch-DpD0inR4.js +1 -0
  207. package/apps/web/dist/assets/Marketplace-CpzD9pNQ.js +2 -0
  208. package/apps/web/dist/assets/NewWizardChannels-IB18afWN.js +1 -0
  209. package/apps/web/dist/assets/NewWizardPage-rYbcmPGG.js +7 -0
  210. package/apps/web/dist/assets/OnboardingPage-ztHT01ah.js +1 -0
  211. package/apps/web/dist/assets/PreviewPane-DviWTLfi.js +9 -0
  212. package/apps/web/dist/assets/PublicRunner-C2geZhhM.js +1 -0
  213. package/apps/web/dist/assets/ReadOnly-kSb_Kbdm.js +1 -0
  214. package/apps/web/dist/assets/SettingsPage-DM2h8N0J.js +2 -0
  215. package/apps/web/dist/assets/SetupPage-Wfyz6xH4.js +1 -0
  216. package/apps/web/dist/assets/SharePage-CyWQorWB.js +1 -0
  217. package/apps/web/dist/assets/SkillEditor-CqQMg2MC.js +1 -0
  218. package/apps/web/dist/assets/Skills-CnhpgoOA.js +9 -0
  219. package/apps/web/dist/assets/SpacePage-q4Bk3N7k.js +2 -0
  220. package/apps/web/dist/assets/UpdateCheck-C2CE6CC3.js +2 -0
  221. package/apps/web/dist/assets/changelog-B6hN1Cp7.js +1 -0
  222. package/apps/web/dist/assets/circle-alert-C8Ma-bPY.js +1 -0
  223. package/apps/web/dist/assets/circle-check-Bu9Z3mlJ.js +1 -0
  224. package/apps/web/dist/assets/code-editor-CfTGqOpp.js +2 -0
  225. package/apps/web/dist/assets/{code-xml-TwKzzMtA.js → code-xml-B4kLFZSj.js} +1 -1
  226. package/apps/web/dist/assets/connection-sign-in-CIiv0t2p.js +1 -0
  227. package/apps/web/dist/assets/esm-Xwn4GtqG.js +7 -0
  228. package/apps/web/dist/assets/{eye-Brd-xPUJ.js → eye-BpoKpIdt.js} +1 -1
  229. package/apps/web/dist/assets/host-BrP-ENHg.css +1 -0
  230. package/apps/web/dist/assets/host-DJ7-p0Sc.js +118 -0
  231. package/apps/web/dist/assets/i18n-BJ7Ld6O6.js +55 -0
  232. package/apps/web/dist/assets/index-D18DvnxX.css +1 -0
  233. package/apps/web/dist/assets/index-D2akynS-.js +10 -0
  234. package/apps/web/dist/assets/logo-BpnjXTRy.js +1 -0
  235. package/apps/web/dist/assets/oss-credits-IdX5bc71.js +1 -0
  236. package/apps/web/dist/assets/{phone-DhkHteoJ.js → phone-Ctvf-Am-.js} +1 -1
  237. package/apps/web/dist/assets/read-aloud-Da_RSm2S.js +1 -0
  238. package/apps/web/dist/assets/{runners-G-XYaDgR.js → runners-CyIvJIHr.js} +1 -1
  239. package/apps/web/dist/assets/scroll-text-ChrjRu9Y.js +1 -0
  240. package/apps/web/dist/assets/session-SXPtTWRK.js +2 -0
  241. package/apps/web/dist/assets/theme-CbTcTFWy.js +11 -0
  242. package/apps/web/dist/assets/ui-Uqnx1UpK.js +82 -0
  243. package/apps/web/dist/assets/{upload-BYZTwJTD.js → upload-BchUnQGV.js} +1 -1
  244. package/apps/web/dist/assets/{useMutation-D0QP_k2-.js → useMutation-DEkZhp5c.js} +1 -1
  245. package/apps/web/dist/assets/{volume-2-CVHoxdGM.js → volume-2-CU_oy81Z.js} +1 -1
  246. package/apps/web/dist/assets/with-selector-CoMyWBAX.js +1 -0
  247. package/apps/web/dist/index.html +17 -10
  248. package/apps/web/dist/mcp/flow.html +119 -64
  249. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +20 -10
  250. package/node_modules/@engenty/wizards-shared/dist/assistant.d.ts +6 -1
  251. package/node_modules/@engenty/wizards-shared/dist/assistant.js +6 -1
  252. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +236 -2
  253. package/node_modules/@engenty/wizards-shared/dist/connectors.js +52 -2
  254. package/node_modules/@engenty/wizards-shared/dist/definition.d.ts +150 -8
  255. package/node_modules/@engenty/wizards-shared/dist/definition.js +46 -11
  256. package/node_modules/@engenty/wizards-shared/dist/discover.d.ts +21 -0
  257. package/node_modules/@engenty/wizards-shared/dist/discover.js +1 -0
  258. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +26 -2
  259. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +26 -2
  260. package/node_modules/@engenty/wizards-shared/dist/fit.js +1 -1
  261. package/node_modules/@engenty/wizards-shared/dist/json-schema.d.ts +1 -1
  262. package/node_modules/@engenty/wizards-shared/dist/json-schema.js +1 -1
  263. package/node_modules/@engenty/wizards-shared/dist/live.d.ts +2 -2
  264. package/node_modules/@engenty/wizards-shared/dist/live.js +1 -1
  265. package/node_modules/@engenty/wizards-shared/dist/marketplace.js +3 -1
  266. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +54 -6
  267. package/node_modules/@engenty/wizards-shared/dist/run.js +85 -0
  268. package/node_modules/@engenty/wizards-shared/dist/runner-texts.d.ts +15 -1
  269. package/node_modules/@engenty/wizards-shared/dist/runner-texts.js +14 -0
  270. package/node_modules/@engenty/wizards-shared/dist/rwx.d.ts +42 -0
  271. package/node_modules/@engenty/wizards-shared/dist/rwx.js +29 -0
  272. package/node_modules/@engenty/wizards-shared/dist/skills.d.ts +1 -1
  273. package/node_modules/@engenty/wizards-shared/dist/space-data.d.ts +2 -2
  274. package/node_modules/@engenty/wizards-shared/dist/{projects.d.ts → spaces.d.ts} +39 -15
  275. package/node_modules/@engenty/wizards-shared/dist/{projects.js → spaces.js} +16 -9
  276. package/node_modules/@engenty/wizards-shared/dist/store.d.ts +7 -2
  277. package/node_modules/@engenty/wizards-shared/dist/surface.d.ts +35 -4
  278. package/node_modules/@engenty/wizards-shared/dist/surface.js +121 -3
  279. package/node_modules/@engenty/wizards-shared/dist/sync.d.ts +1 -1
  280. package/node_modules/@engenty/wizards-shared/dist/theme-look.js +1 -1
  281. package/node_modules/@engenty/wizards-shared/dist/wizard-package.d.ts +2 -2
  282. package/node_modules/@engenty/wizards-shared/dist/wizard-package.js +3 -3
  283. package/package.json +4 -1
  284. package/plugin/.claude-plugin/plugin.json +1 -1
  285. package/plugin/plugin.json +1 -1
  286. package/plugin/skills/build-wizard/SKILL.md +1 -1
  287. package/apps/runtime/dist/services/projects.js +0 -473
  288. package/apps/web/dist/assets/AboutDialog-B-JxkELB.js +0 -1
  289. package/apps/web/dist/assets/EditorPage-DQ_2FOzI.js +0 -3
  290. package/apps/web/dist/assets/Marketplace-DoH4YO3D.js +0 -2
  291. package/apps/web/dist/assets/NewWizardChannels-Tgoexgj4.js +0 -1
  292. package/apps/web/dist/assets/NewWizardPage-B24AF482.js +0 -7
  293. package/apps/web/dist/assets/OnboardingPage-BEvq4slJ.js +0 -1
  294. package/apps/web/dist/assets/PreviewPane-B_v7Y8R7.js +0 -10
  295. package/apps/web/dist/assets/ProjectPage-ClRuhFJo.js +0 -10
  296. package/apps/web/dist/assets/PublicRunner-MicrpVsv.js +0 -1
  297. package/apps/web/dist/assets/ReadOnly-BXjv-MSv.js +0 -1
  298. package/apps/web/dist/assets/SettingsPage-DY8O1r43.js +0 -2
  299. package/apps/web/dist/assets/SetupPage-BOVkVpMu.js +0 -1
  300. package/apps/web/dist/assets/SharePage-DXGzJSnR.js +0 -1
  301. package/apps/web/dist/assets/SkillEditor-BzzTDeaU.js +0 -1
  302. package/apps/web/dist/assets/changelog-BLdS-0Bj.js +0 -1
  303. package/apps/web/dist/assets/esm-BdxDT9Km.js +0 -7
  304. package/apps/web/dist/assets/i18n-8-Sw11tB.js +0 -55
  305. package/apps/web/dist/assets/index-OsdQFHmh.js +0 -49
  306. package/apps/web/dist/assets/index-QPipX5Fi.css +0 -1
  307. package/apps/web/dist/assets/lock-C0uxcOlq.js +0 -1
  308. package/apps/web/dist/assets/logo-CGNoptDg.js +0 -1
  309. package/apps/web/dist/assets/oss-credits-DpRWUPjD.js +0 -1
  310. package/apps/web/dist/assets/session-BWI-KENJ.js +0 -2
  311. package/apps/web/dist/assets/theme-D7krsx0_.js +0 -11
  312. package/apps/web/dist/assets/ui-DSXG3f49.js +0 -83
  313. /package/apps/runtime/dist/db/migrations/tenant/{0027_space_skill.sql → 0030_space_skill.sql} +0 -0
@@ -14,9 +14,9 @@ import { asSync } from "../services/access.js";
14
14
  import { emitDraftChanged } from "../services/draft-events.js";
15
15
  import { forgetWizardLinks } from "../services/links.js";
16
16
  import { pushPages } from "../services/pages.js";
17
- import { removeProjectFile } from "../services/project-files.js";
18
- import { dropIndex, queueIndex } from "../services/project-index.js";
19
- import { removeProject } from "../services/projects.js";
17
+ import { removeSpaceFile } from "../services/space-files.js";
18
+ import { dropIndex, queueIndex } from "../services/space-index.js";
19
+ import { removeSpace } from "../services/spaces.js";
20
20
  import { parseDraft } from "../services/wizards.js";
21
21
  import { putLink } from "../tenants/control.js";
22
22
  import { currentTenant } from "../tenants/tenant.js";
@@ -43,14 +43,14 @@ async function categoriesOf(column, id) {
43
43
  by: r.by,
44
44
  }));
45
45
  }
46
- async function writeCategories(projectId, column, id, list) {
46
+ async function writeCategories(spaceId, column, id, list) {
47
47
  await db.delete(schema.spaceItemCategory).where(eq(schema.spaceItemCategory[column], id));
48
48
  const rows = arr(list).filter((a) => str(a.categoryId));
49
49
  if (!rows.length) {
50
50
  return;
51
51
  }
52
52
  await db.insert(schema.spaceItemCategory).values(rows.map((a) => ({
53
- projectId,
53
+ spaceId,
54
54
  categoryId: a.categoryId,
55
55
  pageId: column === "pageId" ? id : null,
56
56
  rowId: column === "rowId" ? id : null,
@@ -65,7 +65,7 @@ async function writeCategories(projectId, column, id, list) {
65
65
  })));
66
66
  }
67
67
  /** An item a plugin wrote under a key: another one under the same key here gives way to it. */
68
- async function clearOrigin(table, projectId, id, record) {
68
+ async function clearOrigin(table, spaceId, id, record) {
69
69
  const origin = str(record.origin);
70
70
  const key = str(record.originKey);
71
71
  if (!origin || !key) {
@@ -73,19 +73,19 @@ async function clearOrigin(table, projectId, id, record) {
73
73
  }
74
74
  await db
75
75
  .delete(table)
76
- .where(and(eq(table.projectId, projectId), eq(table.origin, origin), eq(table.originKey, key), ne(table.id, id)));
76
+ .where(and(eq(table.spaceId, spaceId), eq(table.origin, origin), eq(table.originKey, key), ne(table.id, id)));
77
77
  }
78
78
  // --- the kinds ----------------------------------------------------------------------------
79
79
  const space = {
80
80
  async read(id) {
81
- const p = await db.query.project.findFirst({
82
- where: and(eq(schema.project.id, id), eq(schema.project.tenantId, currentTenant())),
81
+ const p = await db.query.space.findFirst({
82
+ where: and(eq(schema.space.id, id), eq(schema.space.tenantId, currentTenant())),
83
83
  });
84
84
  if (!p) {
85
85
  return null;
86
86
  }
87
87
  return {
88
- projectId: p.id,
88
+ spaceId: p.id,
89
89
  record: {
90
90
  name: p.name,
91
91
  brand: p.brand,
@@ -96,7 +96,7 @@ const space = {
96
96
  };
97
97
  },
98
98
  async write(id, _item, r) {
99
- const before = await db.query.project.findFirst({ where: eq(schema.project.id, id) });
99
+ const before = await db.query.space.findFirst({ where: eq(schema.space.id, id) });
100
100
  const values = {
101
101
  name: str(r.name) ?? before?.name ?? "Space",
102
102
  brand: obj(r.brand),
@@ -106,12 +106,12 @@ const space = {
106
106
  };
107
107
  if (before) {
108
108
  await db
109
- .update(schema.project)
109
+ .update(schema.space)
110
110
  .set({ ...values, updatedAt: new Date() })
111
- .where(eq(schema.project.id, id));
111
+ .where(eq(schema.space.id, id));
112
112
  }
113
113
  else {
114
- await db.insert(schema.project).values({ id, tenantId: currentTenant(), ...values });
114
+ await db.insert(schema.space).values({ id, tenantId: currentTenant(), ...values });
115
115
  }
116
116
  return () => {
117
117
  spaceChanged(before ? "space.updated" : "space.created", id);
@@ -119,10 +119,10 @@ const space = {
119
119
  };
120
120
  },
121
121
  async remove(id) {
122
- await asSync(() => removeProject(id));
122
+ await asSync(() => removeSpace(id));
123
123
  return undefined;
124
124
  },
125
- list: async (projectId) => [projectId],
125
+ list: async (spaceId) => [spaceId],
126
126
  title: (r, item) => str(r?.name) ?? item,
127
127
  check(merged) {
128
128
  const issues = [];
@@ -145,9 +145,9 @@ const wizard = {
145
145
  orderBy: [asc(schema.wizardFile.path)],
146
146
  });
147
147
  return {
148
- projectId: w.projectId,
148
+ spaceId: w.spaceId,
149
149
  record: {
150
- projectId: w.projectId,
150
+ spaceId: w.spaceId,
151
151
  // The title is the draft's: it travels once, in the draft.
152
152
  draft: w.draft,
153
153
  shareEnabled: w.shareEnabled,
@@ -167,12 +167,12 @@ const wizard = {
167
167
  },
168
168
  };
169
169
  },
170
- async write(projectId, id, r) {
170
+ async write(spaceId, id, r) {
171
171
  const files = arr(r.files).filter((f) => str(f.path) && str(f.hash));
172
172
  const { draft } = parseDraft(r.draft, files.map((f) => f.path));
173
173
  const before = await db.query.wizard.findFirst({ where: eq(schema.wizard.id, id) });
174
174
  const values = {
175
- projectId,
175
+ spaceId,
176
176
  title: draft.title,
177
177
  draft,
178
178
  shareEnabled: bool(r.shareEnabled, true),
@@ -225,18 +225,18 @@ const wizard = {
225
225
  });
226
226
  };
227
227
  },
228
- async remove(_projectId, id) {
228
+ async remove(_spaceId, id) {
229
229
  await forgetWizardLinks(id);
230
230
  await db
231
231
  .delete(schema.wizard)
232
232
  .where(and(eq(schema.wizard.id, id), eq(schema.wizard.tenantId, currentTenant())));
233
233
  return () => pushPages();
234
234
  },
235
- async list(projectId) {
235
+ async list(spaceId) {
236
236
  const rows = await db
237
237
  .select({ id: schema.wizard.id })
238
238
  .from(schema.wizard)
239
- .where(eq(schema.wizard.projectId, projectId));
239
+ .where(eq(schema.wizard.spaceId, spaceId));
240
240
  return rows.map((r) => r.id);
241
241
  },
242
242
  title: (r, item) => str(obj(r?.draft).title) ?? item,
@@ -276,14 +276,12 @@ const translation = {
276
276
  const w = row
277
277
  ? await db.query.wizard.findFirst({
278
278
  where: eq(schema.wizard.id, wizardId),
279
- columns: { projectId: true },
279
+ columns: { spaceId: true },
280
280
  })
281
281
  : null;
282
- return row && w
283
- ? { projectId: w.projectId, record: { wizardId, lang, texts: row.texts } }
284
- : null;
282
+ return row && w ? { spaceId: w.spaceId, record: { wizardId, lang, texts: row.texts } } : null;
285
283
  },
286
- async write(_projectId, item, r) {
284
+ async write(_spaceId, item, r) {
287
285
  const [wizardId, lang] = splitTwo(item);
288
286
  const texts = obj(r.texts);
289
287
  await db
@@ -295,19 +293,19 @@ const translation = {
295
293
  });
296
294
  return undefined;
297
295
  },
298
- async remove(_projectId, item) {
296
+ async remove(_spaceId, item) {
299
297
  const [wizardId, lang] = splitTwo(item);
300
298
  await db
301
299
  .delete(schema.wizardTranslation)
302
300
  .where(and(eq(schema.wizardTranslation.wizardId, wizardId), eq(schema.wizardTranslation.lang, lang)));
303
301
  return undefined;
304
302
  },
305
- async list(projectId) {
303
+ async list(spaceId) {
306
304
  const rows = await db
307
305
  .select({ wizardId: schema.wizardTranslation.wizardId, lang: schema.wizardTranslation.lang })
308
306
  .from(schema.wizardTranslation)
309
307
  .innerJoin(schema.wizard, eq(schema.wizard.id, schema.wizardTranslation.wizardId))
310
- .where(eq(schema.wizard.projectId, projectId));
308
+ .where(eq(schema.wizard.spaceId, spaceId));
311
309
  return rows.map((r) => `${r.wizardId}:${r.lang}`);
312
310
  },
313
311
  title: (_r, item) => splitTwo(item)[1],
@@ -318,14 +316,14 @@ const message = {
318
316
  const w = m
319
317
  ? await db.query.wizard.findFirst({
320
318
  where: eq(schema.wizard.id, m.wizardId),
321
- columns: { projectId: true },
319
+ columns: { spaceId: true },
322
320
  })
323
321
  : null;
324
322
  if (!m || !w) {
325
323
  return null;
326
324
  }
327
325
  return {
328
- projectId: w.projectId,
326
+ spaceId: w.spaceId,
329
327
  record: {
330
328
  wizardId: m.wizardId,
331
329
  role: m.role,
@@ -337,7 +335,7 @@ const message = {
337
335
  },
338
336
  };
339
337
  },
340
- async write(_projectId, id, r) {
338
+ async write(_spaceId, id, r) {
341
339
  const values = {
342
340
  wizardId: String(r.wizardId),
343
341
  role: (r.role === "assistant" ? "assistant" : "user"),
@@ -353,16 +351,16 @@ const message = {
353
351
  .onConflictDoUpdate({ target: schema.wizardMessage.id, set: values });
354
352
  return undefined;
355
353
  },
356
- async remove(_projectId, id) {
354
+ async remove(_spaceId, id) {
357
355
  await db.delete(schema.wizardMessage).where(eq(schema.wizardMessage.id, id));
358
356
  return undefined;
359
357
  },
360
- async list(projectId) {
358
+ async list(spaceId) {
361
359
  const rows = await db
362
360
  .select({ id: schema.wizardMessage.id })
363
361
  .from(schema.wizardMessage)
364
362
  .innerJoin(schema.wizard, eq(schema.wizard.id, schema.wizardMessage.wizardId))
365
- .where(eq(schema.wizard.projectId, projectId));
363
+ .where(eq(schema.wizard.spaceId, spaceId));
366
364
  return rows.map((r) => r.id);
367
365
  },
368
366
  title: (r) => (str(r?.content) ?? "").slice(0, 60),
@@ -380,9 +378,9 @@ const page = {
380
378
  return "skip";
381
379
  }
382
380
  return {
383
- projectId: p.projectId,
381
+ spaceId: p.spaceId,
384
382
  record: {
385
- projectId: p.projectId,
383
+ spaceId: p.spaceId,
386
384
  title: p.title,
387
385
  slug: p.slug,
388
386
  markdown: p.markdown,
@@ -398,10 +396,10 @@ const page = {
398
396
  },
399
397
  };
400
398
  },
401
- async write(projectId, id, r) {
402
- await clearOrigin(schema.spacePage, projectId, id, r);
399
+ async write(spaceId, id, r) {
400
+ await clearOrigin(schema.spacePage, spaceId, id, r);
403
401
  const values = {
404
- projectId,
402
+ spaceId,
405
403
  title: str(r.title) ?? "",
406
404
  slug: str(r.slug),
407
405
  markdown: str(r.markdown) ?? "",
@@ -421,18 +419,18 @@ const page = {
421
419
  target: schema.spacePage.id,
422
420
  set: { ...values, updatedAt: new Date() },
423
421
  });
424
- await writeCategories(projectId, "pageId", id, r.categories);
422
+ await writeCategories(spaceId, "pageId", id, r.categories);
425
423
  return () => queueIndex(`P:${id}`);
426
424
  },
427
- async remove(_projectId, id) {
425
+ async remove(_spaceId, id) {
428
426
  await db.delete(schema.spacePage).where(eq(schema.spacePage.id, id));
429
427
  return undefined;
430
428
  },
431
- async list(projectId) {
429
+ async list(spaceId) {
432
430
  const rows = await db
433
431
  .select({ id: schema.spacePage.id })
434
432
  .from(schema.spacePage)
435
- .where(and(eq(schema.spacePage.projectId, projectId), isNull(schema.spacePage.wizardId)));
433
+ .where(and(eq(schema.spacePage.spaceId, spaceId), isNull(schema.spacePage.wizardId)));
436
434
  return rows.map((r) => r.id);
437
435
  },
438
436
  title: (r, item) => str(r?.title) ?? item,
@@ -449,9 +447,9 @@ const table = {
449
447
  return "skip";
450
448
  }
451
449
  return {
452
- projectId: t.projectId,
450
+ spaceId: t.spaceId,
453
451
  record: {
454
- projectId: t.projectId,
452
+ spaceId: t.spaceId,
455
453
  title: t.title,
456
454
  slug: t.slug,
457
455
  format: t.format,
@@ -466,10 +464,10 @@ const table = {
466
464
  },
467
465
  };
468
466
  },
469
- async write(projectId, id, r) {
470
- await clearOrigin(schema.spaceTable, projectId, id, r);
467
+ async write(spaceId, id, r) {
468
+ await clearOrigin(schema.spaceTable, spaceId, id, r);
471
469
  const values = {
472
- projectId,
470
+ spaceId,
473
471
  title: str(r.title) ?? "",
474
472
  slug: str(r.slug),
475
473
  format: (r.format === "faq" ? "faq" : null),
@@ -488,18 +486,18 @@ const table = {
488
486
  target: schema.spaceTable.id,
489
487
  set: { ...values, updatedAt: new Date() },
490
488
  });
491
- await writeCategories(projectId, "tableId", id, r.categories);
489
+ await writeCategories(spaceId, "tableId", id, r.categories);
492
490
  return () => queueIndex(`t:${id}`);
493
491
  },
494
- async remove(_projectId, id) {
492
+ async remove(_spaceId, id) {
495
493
  await db.delete(schema.spaceTable).where(eq(schema.spaceTable.id, id));
496
494
  return undefined;
497
495
  },
498
- async list(projectId) {
496
+ async list(spaceId) {
499
497
  const rows = await db
500
498
  .select({ id: schema.spaceTable.id })
501
499
  .from(schema.spaceTable)
502
- .where(and(eq(schema.spaceTable.projectId, projectId), isNull(schema.spaceTable.wizardId)));
500
+ .where(and(eq(schema.spaceTable.spaceId, spaceId), isNull(schema.spaceTable.wizardId)));
503
501
  return rows.map((r) => r.id);
504
502
  },
505
503
  title: (r, item) => str(r?.title) ?? item,
@@ -513,7 +511,7 @@ const row = {
513
511
  const t = r
514
512
  ? await db.query.spaceTable.findFirst({
515
513
  where: and(eq(schema.spaceTable.id, r.tableId), eq(schema.spaceTable.tenantId, currentTenant())),
516
- columns: { projectId: true, wizardId: true },
514
+ columns: { spaceId: true, wizardId: true },
517
515
  })
518
516
  : null;
519
517
  if (!r || !t) {
@@ -523,9 +521,9 @@ const row = {
523
521
  return "skip";
524
522
  }
525
523
  return {
526
- projectId: t.projectId,
524
+ spaceId: t.spaceId,
527
525
  record: {
528
- projectId: t.projectId,
526
+ spaceId: t.spaceId,
529
527
  tableId: r.tableId,
530
528
  key: r.key,
531
529
  cells: r.cells,
@@ -534,7 +532,7 @@ const row = {
534
532
  },
535
533
  };
536
534
  },
537
- async write(projectId, id, r) {
535
+ async write(spaceId, id, r) {
538
536
  const values = {
539
537
  tableId: String(r.tableId),
540
538
  key: str(r.key),
@@ -548,19 +546,19 @@ const row = {
548
546
  target: schema.spaceTableRow.id,
549
547
  set: { ...values, updatedAt: new Date() },
550
548
  });
551
- await writeCategories(projectId, "rowId", id, r.categories);
549
+ await writeCategories(spaceId, "rowId", id, r.categories);
552
550
  return () => queueIndex(`r:${id}`);
553
551
  },
554
- async remove(_projectId, id) {
552
+ async remove(_spaceId, id) {
555
553
  await db.delete(schema.spaceTableRow).where(eq(schema.spaceTableRow.id, id));
556
554
  return undefined;
557
555
  },
558
- async list(projectId) {
556
+ async list(spaceId) {
559
557
  const rows = await db
560
558
  .select({ id: schema.spaceTableRow.id })
561
559
  .from(schema.spaceTableRow)
562
560
  .innerJoin(schema.spaceTable, eq(schema.spaceTable.id, schema.spaceTableRow.tableId))
563
- .where(and(eq(schema.spaceTable.projectId, projectId), isNull(schema.spaceTable.wizardId)));
561
+ .where(and(eq(schema.spaceTable.spaceId, spaceId), isNull(schema.spaceTable.wizardId)));
564
562
  return rows.map((r) => r.id);
565
563
  },
566
564
  title(r, item) {
@@ -593,9 +591,9 @@ async function rekeyValue(from, to) {
593
591
  .set({ valueId: to })
594
592
  .where(eq(schema.spaceItemCategory.valueId, from));
595
593
  await db
596
- .update(schema.projectChunk)
594
+ .update(schema.spaceChunk)
597
595
  .set({ valueId: to })
598
- .where(eq(schema.projectChunk.valueId, from));
596
+ .where(eq(schema.spaceChunk.valueId, from));
599
597
  }
600
598
  const category = {
601
599
  async read(id) {
@@ -610,9 +608,9 @@ const category = {
610
608
  orderBy: [asc(schema.spaceCategoryValue.position), asc(schema.spaceCategoryValue.id)],
611
609
  });
612
610
  return {
613
- projectId: c.projectId,
611
+ spaceId: c.spaceId,
614
612
  record: {
615
- projectId: c.projectId,
613
+ spaceId: c.spaceId,
616
614
  name: c.name,
617
615
  type: c.type,
618
616
  unit: c.unit,
@@ -633,10 +631,10 @@ const category = {
633
631
  },
634
632
  };
635
633
  },
636
- async write(projectId, id, r) {
634
+ async write(spaceId, id, r) {
637
635
  const name = str(r.name) ?? "";
638
636
  const same = await db.query.spaceCategory.findFirst({
639
- where: and(eq(schema.spaceCategory.projectId, projectId), eq(schema.spaceCategory.name, name), ne(schema.spaceCategory.id, id)),
637
+ where: and(eq(schema.spaceCategory.spaceId, spaceId), eq(schema.spaceCategory.name, name), ne(schema.spaceCategory.id, id)),
640
638
  columns: { id: true },
641
639
  });
642
640
  if (same) {
@@ -645,7 +643,7 @@ const category = {
645
643
  }
646
644
  const type = r.type ?? "text";
647
645
  const values = {
648
- projectId,
646
+ spaceId,
649
647
  name,
650
648
  type: (["choice", "date", "number", "text", "boolean"].includes(type) ? type : "text"),
651
649
  unit: str(r.unit),
@@ -709,15 +707,15 @@ const category = {
709
707
  }
710
708
  };
711
709
  },
712
- async remove(_projectId, id) {
710
+ async remove(_spaceId, id) {
713
711
  await db.delete(schema.spaceCategory).where(eq(schema.spaceCategory.id, id));
714
712
  return undefined;
715
713
  },
716
- async list(projectId) {
714
+ async list(spaceId) {
717
715
  const rows = await db
718
716
  .select({ id: schema.spaceCategory.id })
719
717
  .from(schema.spaceCategory)
720
- .where(eq(schema.spaceCategory.projectId, projectId));
718
+ .where(eq(schema.spaceCategory.spaceId, spaceId));
721
719
  return rows.map((r) => r.id);
722
720
  },
723
721
  title: (r, item) => str(r?.name) ?? item,
@@ -725,10 +723,10 @@ const category = {
725
723
  const assetKey = (path) => `assets/${path}`;
726
724
  const file = {
727
725
  async read(id) {
728
- const f = await db.query.projectFile.findFirst({ where: eq(schema.projectFile.id, id) });
726
+ const f = await db.query.spaceFile.findFirst({ where: eq(schema.spaceFile.id, id) });
729
727
  const p = f
730
- ? await db.query.project.findFirst({
731
- where: and(eq(schema.project.id, f.projectId), eq(schema.project.tenantId, currentTenant())),
728
+ ? await db.query.space.findFirst({
729
+ where: and(eq(schema.space.id, f.spaceId), eq(schema.space.tenantId, currentTenant())),
732
730
  columns: { id: true },
733
731
  })
734
732
  : null;
@@ -745,9 +743,9 @@ const file = {
745
743
  return "skip";
746
744
  }
747
745
  return {
748
- projectId: f.projectId,
746
+ spaceId: f.spaceId,
749
747
  record: {
750
- projectId: f.projectId,
748
+ spaceId: f.spaceId,
751
749
  kind: f.kind,
752
750
  name: f.name,
753
751
  mime: f.mime,
@@ -766,8 +764,8 @@ const file = {
766
764
  },
767
765
  };
768
766
  },
769
- async write(projectId, id, r) {
770
- await clearOrigin(schema.projectFile, projectId, id, r);
767
+ async write(spaceId, id, r) {
768
+ await clearOrigin(schema.spaceFile, spaceId, id, r);
771
769
  const mime = str(r.mime) ?? "application/octet-stream";
772
770
  const name = str(r.name) ?? "file";
773
771
  const kind = (["logo", "asset", "document", "pattern"].includes(r.kind) ? r.kind : "asset");
@@ -776,7 +774,7 @@ const file = {
776
774
  const path = `${id}-${nanoid(6)}.${extFor(mime)}`;
777
775
  await objects.put(assetKey(path), bytes);
778
776
  const assetValues = {
779
- kind: kind === "logo" ? "logo" : "project",
777
+ kind: kind === "logo" ? "logo" : "space",
780
778
  mime,
781
779
  name,
782
780
  path,
@@ -787,7 +785,7 @@ const file = {
787
785
  .values({ id, tenantId: currentTenant(), ...assetValues })
788
786
  .onConflictDoUpdate({ target: schema.asset.id, set: assetValues });
789
787
  const values = {
790
- projectId,
788
+ spaceId,
791
789
  kind,
792
790
  name,
793
791
  mime,
@@ -805,13 +803,13 @@ const file = {
805
803
  originLabel: str(r.originLabel),
806
804
  };
807
805
  await db
808
- .insert(schema.projectFile)
806
+ .insert(schema.spaceFile)
809
807
  .values({ id, ...values })
810
808
  .onConflictDoUpdate({
811
- target: schema.projectFile.id,
809
+ target: schema.spaceFile.id,
812
810
  set: { ...values, updatedAt: new Date() },
813
811
  });
814
- await writeCategories(projectId, "fileId", id, r.categories);
812
+ await writeCategories(spaceId, "fileId", id, r.categories);
815
813
  return async () => {
816
814
  if (before && before.path !== path) {
817
815
  await objects.remove(assetKey(before.path));
@@ -828,15 +826,15 @@ const file = {
828
826
  }
829
827
  };
830
828
  },
831
- async remove(projectId, id) {
832
- await asSync(() => removeProjectFile(projectId, id)).catch(() => undefined);
829
+ async remove(spaceId, id) {
830
+ await asSync(() => removeSpaceFile(spaceId, id)).catch(() => undefined);
833
831
  return undefined;
834
832
  },
835
- async list(projectId) {
833
+ async list(spaceId) {
836
834
  const rows = await db
837
- .select({ id: schema.projectFile.id })
838
- .from(schema.projectFile)
839
- .where(and(eq(schema.projectFile.projectId, projectId), eq(schema.projectFile.status, "ready")));
835
+ .select({ id: schema.spaceFile.id })
836
+ .from(schema.spaceFile)
837
+ .where(and(eq(schema.spaceFile.spaceId, spaceId), eq(schema.spaceFile.status, "ready")));
840
838
  return rows.map((r) => r.id);
841
839
  },
842
840
  title: (r, item) => str(r?.name) ?? item,
@@ -844,43 +842,43 @@ const file = {
844
842
  };
845
843
  const connector = {
846
844
  async read(item) {
847
- const [projectId, id] = splitTwo(item);
848
- const c = await db.query.projectConnector.findFirst({
849
- where: and(eq(schema.projectConnector.projectId, projectId), eq(schema.projectConnector.id, id)),
845
+ const [spaceId, id] = splitTwo(item);
846
+ const c = await db.query.spaceConnector.findFirst({
847
+ where: and(eq(schema.spaceConnector.spaceId, spaceId), eq(schema.spaceConnector.id, id)),
850
848
  });
851
849
  const p = c
852
- ? await db.query.project.findFirst({
853
- where: and(eq(schema.project.id, projectId), eq(schema.project.tenantId, currentTenant())),
850
+ ? await db.query.space.findFirst({
851
+ where: and(eq(schema.space.id, spaceId), eq(schema.space.tenantId, currentTenant())),
854
852
  columns: { id: true },
855
853
  })
856
854
  : null;
857
- return c && p ? { projectId, record: { projectId, record: c.record } } : null;
855
+ return c && p ? { spaceId, record: { spaceId, record: c.record } } : null;
858
856
  },
859
- async write(projectId, item, r) {
857
+ async write(spaceId, item, r) {
860
858
  const [, id] = splitTwo(item);
861
859
  const record = obj(r.record);
862
860
  await db
863
- .insert(schema.projectConnector)
864
- .values({ projectId, id, record })
861
+ .insert(schema.spaceConnector)
862
+ .values({ spaceId, id, record })
865
863
  .onConflictDoUpdate({
866
- target: [schema.projectConnector.projectId, schema.projectConnector.id],
864
+ target: [schema.spaceConnector.spaceId, schema.spaceConnector.id],
867
865
  set: { record, updatedAt: new Date() },
868
866
  });
869
867
  return undefined;
870
868
  },
871
- async remove(projectId, item) {
869
+ async remove(spaceId, item) {
872
870
  const [, id] = splitTwo(item);
873
871
  await db
874
- .delete(schema.projectConnector)
875
- .where(and(eq(schema.projectConnector.projectId, projectId), eq(schema.projectConnector.id, id)));
872
+ .delete(schema.spaceConnector)
873
+ .where(and(eq(schema.spaceConnector.spaceId, spaceId), eq(schema.spaceConnector.id, id)));
876
874
  return undefined;
877
875
  },
878
- async list(projectId) {
876
+ async list(spaceId) {
879
877
  const rows = await db
880
- .select({ id: schema.projectConnector.id })
881
- .from(schema.projectConnector)
882
- .where(eq(schema.projectConnector.projectId, projectId));
883
- return rows.map((r) => `${projectId}:${r.id}`);
878
+ .select({ id: schema.spaceConnector.id })
879
+ .from(schema.spaceConnector)
880
+ .where(eq(schema.spaceConnector.spaceId, spaceId));
881
+ return rows.map((r) => `${spaceId}:${r.id}`);
884
882
  },
885
883
  title: (r, item) => str(obj(r?.record).name) ?? splitTwo(item)[1],
886
884
  };
@@ -893,9 +891,9 @@ const skill = {
893
891
  return null;
894
892
  }
895
893
  return {
896
- projectId: k.projectId,
894
+ spaceId: k.spaceId,
897
895
  record: {
898
- projectId: k.projectId,
896
+ spaceId: k.spaceId,
899
897
  name: k.name,
900
898
  description: k.description,
901
899
  body: k.body,
@@ -910,11 +908,11 @@ const skill = {
910
908
  },
911
909
  };
912
910
  },
913
- async write(projectId, id, r) {
911
+ async write(spaceId, id, r) {
914
912
  const mode = SKILL_MODES.find((m) => m === r.mode) ?? "demand";
915
913
  const source = SKILL_SOURCES.find((m) => m === r.source) ?? "own";
916
914
  const values = {
917
- projectId,
915
+ spaceId,
918
916
  name: str(r.name) ?? id.toLowerCase(),
919
917
  description: str(r.description) ?? "",
920
918
  body: str(r.body) ?? "",
@@ -931,7 +929,7 @@ const skill = {
931
929
  };
932
930
  // Two sides named a skill alike: the one arriving takes the name with its id behind it.
933
931
  const clash = await db.query.spaceSkill.findFirst({
934
- where: and(eq(schema.spaceSkill.projectId, projectId), eq(schema.spaceSkill.name, values.name), ne(schema.spaceSkill.id, id)),
932
+ where: and(eq(schema.spaceSkill.spaceId, spaceId), eq(schema.spaceSkill.name, values.name), ne(schema.spaceSkill.id, id)),
935
933
  columns: { id: true },
936
934
  });
937
935
  if (clash) {
@@ -947,15 +945,15 @@ const skill = {
947
945
  });
948
946
  return undefined;
949
947
  },
950
- async remove(_projectId, id) {
948
+ async remove(_spaceId, id) {
951
949
  await db.delete(schema.spaceSkill).where(eq(schema.spaceSkill.id, id));
952
950
  return undefined;
953
951
  },
954
- async list(projectId) {
952
+ async list(spaceId) {
955
953
  const rows = await db
956
954
  .select({ id: schema.spaceSkill.id })
957
955
  .from(schema.spaceSkill)
958
- .where(eq(schema.spaceSkill.projectId, projectId));
956
+ .where(eq(schema.spaceSkill.spaceId, spaceId));
959
957
  return rows.map((r) => r.id);
960
958
  },
961
959
  title: (r, item) => str(r?.name) ?? item,
@@ -1004,10 +1002,10 @@ export function canonical(record) {
1004
1002
  */
1005
1003
  export async function letDanglingGo() {
1006
1004
  await db.run(sql `UPDATE space_page SET parent_id = NULL WHERE parent_id IS NOT NULL AND parent_id NOT IN (SELECT id FROM space_page)`);
1007
- await db.run(sql `UPDATE space_page SET file_id = NULL WHERE file_id IS NOT NULL AND file_id NOT IN (SELECT id FROM project_file)`);
1008
- await db.run(sql `UPDATE space_table SET file_id = NULL WHERE file_id IS NOT NULL AND file_id NOT IN (SELECT id FROM project_file)`);
1005
+ await db.run(sql `UPDATE space_page SET file_id = NULL WHERE file_id IS NOT NULL AND file_id NOT IN (SELECT id FROM space_file)`);
1006
+ await db.run(sql `UPDATE space_table SET file_id = NULL WHERE file_id IS NOT NULL AND file_id NOT IN (SELECT id FROM space_file)`);
1009
1007
  await db.run(sql `UPDATE space_category SET table_id = NULL, column_id = NULL WHERE table_id IS NOT NULL AND table_id NOT IN (SELECT id FROM space_table)`);
1010
- await db.run(sql `DELETE FROM space_item_category WHERE category_id NOT IN (SELECT id FROM space_category) OR (value_id IS NOT NULL AND value_id NOT IN (SELECT id FROM space_category_value)) OR (page_id IS NOT NULL AND page_id NOT IN (SELECT id FROM space_page)) OR (row_id IS NOT NULL AND row_id NOT IN (SELECT id FROM space_table_row)) OR (table_id IS NOT NULL AND table_id NOT IN (SELECT id FROM space_table)) OR (file_id IS NOT NULL AND file_id NOT IN (SELECT id FROM project_file))`);
1008
+ await db.run(sql `DELETE FROM space_item_category WHERE category_id NOT IN (SELECT id FROM space_category) OR (value_id IS NOT NULL AND value_id NOT IN (SELECT id FROM space_category_value)) OR (page_id IS NOT NULL AND page_id NOT IN (SELECT id FROM space_page)) OR (row_id IS NOT NULL AND row_id NOT IN (SELECT id FROM space_table_row)) OR (table_id IS NOT NULL AND table_id NOT IN (SELECT id FROM space_table)) OR (file_id IS NOT NULL AND file_id NOT IN (SELECT id FROM space_file))`);
1011
1009
  await db.run(sql `DELETE FROM space_table_row WHERE table_id NOT IN (SELECT id FROM space_table)`);
1012
1010
  await db.run(sql `DELETE FROM wizard_translation WHERE wizard_id NOT IN (SELECT id FROM wizard)`);
1013
1011
  await db.run(sql `DELETE FROM wizard_message WHERE wizard_id NOT IN (SELECT id FROM wizard)`);