@dxos/plugin-script 0.12.0-next-73daef452f1464b62efdbca75fb0067c1066f264 → 0.13.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 (329) hide show
  1. package/PLUGIN.mdl +93 -17
  2. package/README.md +1 -1
  3. package/dist/lib/Notebook.mjs +4 -5
  4. package/dist/lib/Notebook.mjs.map +1 -1
  5. package/dist/lib/ScriptCapabilities.mjs.map +1 -1
  6. package/dist/lib/ScriptOperation.mjs +1 -1
  7. package/dist/lib/ScriptOperation.mjs.map +1 -1
  8. package/dist/lib/ScriptOperationHandlerSet.mjs.map +1 -1
  9. package/dist/lib/ScriptSkill.mjs +1 -1
  10. package/dist/lib/ScriptSkill.mjs.map +1 -1
  11. package/dist/lib/capabilities.browser.mjs +51 -0
  12. package/dist/lib/capabilities.browser.mjs.map +1 -0
  13. package/dist/lib/capabilities.mjs +17 -7
  14. package/dist/lib/capabilities.mjs.map +1 -1
  15. package/dist/lib/capabilities.node.mjs +16 -4
  16. package/dist/lib/capabilities.node.mjs.map +1 -1
  17. package/dist/lib/capabilities.tauri.mjs +51 -0
  18. package/dist/lib/capabilities.tauri.mjs.map +1 -0
  19. package/dist/lib/capabilities.workerd.mjs +1 -1
  20. package/dist/lib/capabilities.workerd.mjs.map +1 -1
  21. package/dist/lib/chunk-DeploymentDialog.mjs +12 -9
  22. package/dist/lib/chunk-DeploymentDialog.mjs.map +1 -1
  23. package/dist/lib/chunk-NotebookArticle.mjs +37 -36
  24. package/dist/lib/chunk-NotebookArticle.mjs.map +1 -1
  25. package/dist/lib/chunk-PLUGIN.mjs +6 -0
  26. package/dist/lib/chunk-PLUGIN.mjs.map +1 -0
  27. package/dist/lib/chunk-ScriptArticle.mjs +14 -15
  28. package/dist/lib/chunk-ScriptArticle.mjs.map +1 -1
  29. package/dist/lib/chunk-ScriptProperties.mjs +91 -94
  30. package/dist/lib/chunk-ScriptProperties.mjs.map +1 -1
  31. package/dist/lib/chunk-ScriptSettings.mjs +11 -8
  32. package/dist/lib/chunk-ScriptSettings.mjs.map +1 -1
  33. package/dist/lib/chunk-TestContainer.mjs +5 -5
  34. package/dist/lib/chunk-TestContainer.mjs.map +1 -1
  35. package/dist/lib/chunk-app-graph-builder.mjs +2 -0
  36. package/dist/lib/chunk-app-graph-builder.mjs.map +1 -1
  37. package/dist/lib/chunk-compiler.mjs +87 -4
  38. package/dist/lib/chunk-compiler.mjs.map +1 -1
  39. package/dist/lib/chunk-create-object.mjs +1 -1
  40. package/dist/lib/chunk-create-script.mjs.map +1 -1
  41. package/dist/lib/chunk-create.mjs +4 -4
  42. package/dist/lib/chunk-create.mjs.map +1 -1
  43. package/dist/lib/chunk-definitions.mjs +246 -0
  44. package/dist/lib/chunk-definitions.mjs.map +1 -0
  45. package/dist/lib/chunk-delete.mjs +2 -2
  46. package/dist/lib/chunk-delete.mjs.map +1 -1
  47. package/dist/lib/chunk-deploy.mjs +16 -12
  48. package/dist/lib/chunk-deploy.mjs.map +1 -1
  49. package/dist/lib/chunk-errors.mjs +8 -0
  50. package/dist/lib/chunk-errors.mjs.map +1 -0
  51. package/dist/lib/chunk-functions.mjs +66 -246
  52. package/dist/lib/chunk-functions.mjs.map +1 -1
  53. package/dist/lib/chunk-inspect-invocations.mjs +3 -3
  54. package/dist/lib/chunk-inspect-invocations.mjs.map +1 -1
  55. package/dist/lib/chunk-install-function.mjs +11 -11
  56. package/dist/lib/chunk-install-function.mjs.map +1 -1
  57. package/dist/lib/chunk-invoke.mjs +6 -6
  58. package/dist/lib/chunk-invoke.mjs.map +1 -1
  59. package/dist/lib/chunk-operation-handler.mjs +16 -2
  60. package/dist/lib/chunk-operation-handler.mjs.map +1 -1
  61. package/dist/lib/chunk-query-deployed-functions.mjs +5 -6
  62. package/dist/lib/chunk-query-deployed-functions.mjs.map +1 -1
  63. package/dist/lib/chunk-react-surface.mjs +14 -10
  64. package/dist/lib/chunk-react-surface.mjs.map +1 -1
  65. package/dist/lib/chunk-read.mjs +4 -3
  66. package/dist/lib/chunk-read.mjs.map +1 -1
  67. package/dist/lib/chunk-settings.mjs +2 -2
  68. package/dist/lib/chunk-settings.mjs.map +1 -1
  69. package/dist/lib/chunk-skill-definition.mjs +1 -1
  70. package/dist/lib/chunk-templates.mjs +3 -3
  71. package/dist/lib/chunk-update.mjs +4 -3
  72. package/dist/lib/chunk-update.mjs.map +1 -1
  73. package/dist/lib/components.mjs +114 -123
  74. package/dist/lib/components.mjs.map +1 -1
  75. package/dist/lib/containers.mjs.map +1 -1
  76. package/dist/lib/hooks.mjs +96 -16
  77. package/dist/lib/hooks.mjs.map +1 -1
  78. package/dist/lib/index.mjs +5 -3
  79. package/dist/lib/meta.mjs.map +1 -1
  80. package/dist/lib/ns/ScriptFunction.mjs +12 -0
  81. package/dist/lib/ns/ScriptFunction.mjs.map +1 -0
  82. package/dist/lib/ns/Templates.mjs +11 -0
  83. package/dist/lib/ns/Templates.mjs.map +1 -0
  84. package/dist/lib/testing.mjs +1 -1
  85. package/dist/lib/translations.mjs +2 -1
  86. package/dist/lib/translations.mjs.map +1 -1
  87. package/dist/types/src/ScriptFunction.d.ts +2 -0
  88. package/dist/types/src/ScriptFunction.d.ts.map +1 -0
  89. package/dist/types/src/Templates.d.ts +2 -0
  90. package/dist/types/src/Templates.d.ts.map +1 -0
  91. package/dist/types/src/capabilities/ScriptSurfaces.d.ts.map +1 -1
  92. package/dist/types/src/capabilities/compiler.d.ts +2 -1
  93. package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
  94. package/dist/types/src/capabilities/errors.d.ts +33 -0
  95. package/dist/types/src/capabilities/errors.d.ts.map +1 -0
  96. package/dist/types/src/capabilities/gen/browser.d.ts +12 -0
  97. package/dist/types/src/capabilities/gen/browser.d.ts.map +1 -0
  98. package/dist/types/src/capabilities/gen/node.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/gen/tauri.d.ts +12 -0
  100. package/dist/types/src/capabilities/gen/tauri.d.ts.map +1 -0
  101. package/dist/types/src/capabilities/gen/workerd.d.ts.map +1 -1
  102. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  103. package/dist/types/src/compiler/index.d.ts +1 -1
  104. package/dist/types/src/compiler/index.d.ts.map +1 -1
  105. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +3 -3
  106. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
  107. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -1
  108. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +4 -4
  109. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
  110. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +10 -0
  111. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
  112. package/dist/types/src/components/NotebookStack/index.d.ts +2 -2
  113. package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -1
  114. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +2 -2
  115. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  116. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +10 -0
  117. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  118. package/dist/types/src/components/ScriptToolbar/index.d.ts +1 -1
  119. package/dist/types/src/components/ScriptToolbar/index.d.ts.map +1 -1
  120. package/dist/types/src/components/TestPanel/TestPanel.d.ts +2 -2
  121. package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
  122. package/dist/types/src/components/TestPanel/index.d.ts +1 -1
  123. package/dist/types/src/components/TestPanel/index.d.ts.map +1 -1
  124. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +2 -2
  125. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  126. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +1 -1
  127. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  128. package/dist/types/src/components/TypescriptEditor/index.d.ts +1 -1
  129. package/dist/types/src/components/TypescriptEditor/index.d.ts.map +1 -1
  130. package/dist/types/src/components/index.d.ts +4 -5
  131. package/dist/types/src/components/index.d.ts.map +1 -1
  132. package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.d.ts +1 -1
  133. package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  134. package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts +10 -0
  135. package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  136. package/dist/types/src/containers/DeploymentDialog/index.d.ts +1 -1
  137. package/dist/types/src/containers/DeploymentDialog/index.d.ts.map +1 -1
  138. package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts +1 -1
  139. package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts.map +1 -1
  140. package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts +1 -1
  141. package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts.map +1 -1
  142. package/dist/types/src/containers/NotebookArticle/index.d.ts +1 -1
  143. package/dist/types/src/containers/NotebookArticle/index.d.ts.map +1 -1
  144. package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts +1 -1
  145. package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts.map +1 -1
  146. package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts +10 -0
  147. package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts.map +1 -1
  148. package/dist/types/src/containers/ScriptArticle/index.d.ts +1 -1
  149. package/dist/types/src/containers/ScriptArticle/index.d.ts.map +1 -1
  150. package/dist/types/src/containers/ScriptProperties/FunctionBinding.d.ts.map +1 -1
  151. package/dist/types/src/containers/ScriptProperties/FunctionPublishing.d.ts.map +1 -1
  152. package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts +1 -1
  153. package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts.map +1 -1
  154. package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts +10 -0
  155. package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts.map +1 -1
  156. package/dist/types/src/containers/ScriptProperties/SkillEditor.d.ts.map +1 -1
  157. package/dist/types/src/containers/ScriptProperties/index.d.ts +1 -1
  158. package/dist/types/src/containers/ScriptProperties/index.d.ts.map +1 -1
  159. package/dist/types/src/containers/ScriptSettings/ScriptSettings.d.ts +2 -2
  160. package/dist/types/src/containers/ScriptSettings/ScriptSettings.d.ts.map +1 -1
  161. package/dist/types/src/containers/ScriptSettings/ScriptSettings.stories.d.ts +11 -1
  162. package/dist/types/src/containers/ScriptSettings/ScriptSettings.stories.d.ts.map +1 -1
  163. package/dist/types/src/containers/ScriptSettings/index.d.ts +1 -1
  164. package/dist/types/src/containers/ScriptSettings/index.d.ts.map +1 -1
  165. package/dist/types/src/containers/TestContainer/index.d.ts +1 -1
  166. package/dist/types/src/containers/TestContainer/index.d.ts.map +1 -1
  167. package/dist/types/src/containers/index.d.ts.map +1 -1
  168. package/dist/types/src/hooks/deploy.d.ts +3 -3
  169. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  170. package/dist/types/src/hooks/index.d.ts +6 -6
  171. package/dist/types/src/hooks/index.d.ts.map +1 -1
  172. package/dist/types/src/hooks/useCompiler.d.ts +1 -1
  173. package/dist/types/src/hooks/useCompiler.d.ts.map +1 -1
  174. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts +1 -1
  175. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  176. package/dist/types/src/hooks/useToolbarState.d.ts +2 -2
  177. package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
  178. package/dist/types/src/index.d.ts +5 -3
  179. package/dist/types/src/index.d.ts.map +1 -1
  180. package/dist/types/src/notebook/compute-graph.d.ts +3 -3
  181. package/dist/types/src/notebook/compute-graph.d.ts.map +1 -1
  182. package/dist/types/src/notebook/index.d.ts +1 -1
  183. package/dist/types/src/notebook/index.d.ts.map +1 -1
  184. package/dist/types/src/operations/ScriptOperationHandlerSet.d.ts.map +1 -1
  185. package/dist/types/src/operations/index.d.ts +1 -1
  186. package/dist/types/src/operations/index.d.ts.map +1 -1
  187. package/dist/types/src/skills/ScriptSkill.d.ts.map +1 -1
  188. package/dist/types/src/skills/functions/definitions.d.ts +8 -6
  189. package/dist/types/src/skills/functions/definitions.d.ts.map +1 -1
  190. package/dist/types/src/skills/functions/deploy.d.ts +4 -2
  191. package/dist/types/src/skills/functions/deploy.d.ts.map +1 -1
  192. package/dist/types/src/skills/functions/errors.d.ts +33 -0
  193. package/dist/types/src/skills/functions/errors.d.ts.map +1 -0
  194. package/dist/types/src/skills/functions/index.d.ts +1 -1
  195. package/dist/types/src/skills/functions/index.d.ts.map +1 -1
  196. package/dist/types/src/skills/functions/install-function.d.ts +3 -2
  197. package/dist/types/src/skills/functions/install-function.d.ts.map +1 -1
  198. package/dist/types/src/skills/functions/invoke.d.ts +2 -2
  199. package/dist/types/src/skills/functions/invoke.d.ts.map +1 -1
  200. package/dist/types/src/skills/functions/query-deployed-functions.d.ts +2 -2
  201. package/dist/types/src/skills/functions/query-deployed-functions.d.ts.map +1 -1
  202. package/dist/types/src/skills/index.d.ts +1 -1
  203. package/dist/types/src/skills/index.d.ts.map +1 -1
  204. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  205. package/dist/types/src/testing/index.d.ts +2 -2
  206. package/dist/types/src/testing/index.d.ts.map +1 -1
  207. package/dist/types/src/translations.d.ts +10 -0
  208. package/dist/types/src/translations.d.ts.map +1 -1
  209. package/dist/types/src/types/Notebook.d.ts.map +1 -1
  210. package/dist/types/src/types/ScriptCapabilities.d.ts +3 -3
  211. package/dist/types/src/types/ScriptCapabilities.d.ts.map +1 -1
  212. package/dist/types/src/types/index.d.ts +5 -5
  213. package/dist/types/src/types/index.d.ts.map +1 -1
  214. package/dist/types/src/util/deploy.d.ts +6 -3
  215. package/dist/types/src/util/deploy.d.ts.map +1 -1
  216. package/dist/types/src/util/functions.d.ts +1 -1
  217. package/dist/types/src/util/functions.d.ts.map +1 -1
  218. package/dist/types/src/util/index.d.ts +2 -2
  219. package/dist/types/src/util/index.d.ts.map +1 -1
  220. package/dist/types/tsconfig.tsbuildinfo +1 -1
  221. package/package.json +106 -96
  222. package/src/ScriptFunction.ts +7 -0
  223. package/src/Templates.ts +7 -0
  224. package/src/capabilities/ScriptSurfaces.tsx +19 -10
  225. package/src/capabilities/app-graph-builder.ts +2 -0
  226. package/src/capabilities/compiler.ts +6 -5
  227. package/src/capabilities/errors.ts +8 -0
  228. package/src/capabilities/gen/browser.ts +62 -0
  229. package/src/capabilities/gen/node.ts +10 -10
  230. package/src/capabilities/gen/tauri.ts +62 -0
  231. package/src/capabilities/gen/workerd.ts +4 -4
  232. package/src/capabilities/index.ts +11 -11
  233. package/src/capabilities/operation-handler.ts +1 -1
  234. package/src/capabilities/react-surface.ts +4 -4
  235. package/src/capabilities/settings.ts +2 -2
  236. package/src/compiler/compiler.browser.test.ts +1 -1
  237. package/src/compiler/index.ts +1 -1
  238. package/src/components/NotebookStack/NotebookCell.tsx +35 -29
  239. package/src/components/NotebookStack/NotebookMenu.tsx +27 -26
  240. package/src/components/NotebookStack/NotebookStack.stories.tsx +3 -3
  241. package/src/components/NotebookStack/NotebookStack.tsx +20 -17
  242. package/src/components/NotebookStack/index.ts +2 -2
  243. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +5 -5
  244. package/src/components/ScriptToolbar/ScriptToolbar.tsx +14 -15
  245. package/src/components/ScriptToolbar/index.ts +1 -1
  246. package/src/components/TestPanel/TestPanel.tsx +29 -23
  247. package/src/components/TestPanel/index.ts +1 -1
  248. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +10 -8
  249. package/src/components/TypescriptEditor/TypescriptEditor.tsx +11 -7
  250. package/src/components/TypescriptEditor/index.ts +1 -1
  251. package/src/components/index.ts +4 -5
  252. package/src/containers/DeploymentDialog/DeploymentDialog.stories.tsx +5 -7
  253. package/src/containers/DeploymentDialog/DeploymentDialog.tsx +18 -15
  254. package/src/containers/DeploymentDialog/index.ts +1 -1
  255. package/src/containers/NotebookArticle/NotebookArticle.stories.tsx +6 -6
  256. package/src/containers/NotebookArticle/NotebookArticle.tsx +25 -21
  257. package/src/containers/NotebookArticle/index.ts +1 -1
  258. package/src/containers/ScriptArticle/ScriptArticle.stories.tsx +3 -3
  259. package/src/containers/ScriptArticle/ScriptArticle.tsx +13 -11
  260. package/src/containers/ScriptArticle/index.ts +1 -1
  261. package/src/containers/ScriptProperties/FunctionBinding.tsx +18 -18
  262. package/src/containers/ScriptProperties/FunctionPublishing.tsx +22 -22
  263. package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +3 -3
  264. package/src/containers/ScriptProperties/ScriptProperties.tsx +10 -10
  265. package/src/containers/ScriptProperties/SkillEditor.tsx +16 -14
  266. package/src/containers/ScriptProperties/index.ts +1 -1
  267. package/src/containers/ScriptSettings/ScriptSettings.stories.tsx +1 -1
  268. package/src/containers/ScriptSettings/ScriptSettings.tsx +16 -11
  269. package/src/containers/ScriptSettings/index.ts +1 -1
  270. package/src/containers/TestContainer/TestContainer.tsx +4 -4
  271. package/src/containers/TestContainer/index.ts +1 -1
  272. package/src/containers/index.ts +6 -6
  273. package/src/e2e/ai.test.ts +1 -1
  274. package/src/hooks/deploy.ts +12 -5
  275. package/src/hooks/index.ts +6 -6
  276. package/src/hooks/template.ts +1 -1
  277. package/src/hooks/useCompiler.ts +8 -7
  278. package/src/hooks/useCreateAndDeployScriptTemplates.ts +10 -5
  279. package/src/hooks/useToolbarState.ts +4 -4
  280. package/src/index.ts +5 -3
  281. package/src/meta.ts +1 -1
  282. package/src/notebook/compute-graph.test.ts +2 -2
  283. package/src/notebook/compute-graph.ts +4 -4
  284. package/src/notebook/index.ts +1 -1
  285. package/src/notebook/vfs-parser.test.ts +1 -1
  286. package/src/notebook/vfs-parser.ts +1 -1
  287. package/src/operations/ScriptOperationHandlerSet.ts +3 -1
  288. package/src/operations/create-script.ts +1 -1
  289. package/src/operations/index.ts +1 -1
  290. package/src/plugin.test.ts +2 -2
  291. package/src/skills/ScriptSkill.ts +3 -1
  292. package/src/skills/functions/create.ts +4 -4
  293. package/src/skills/functions/definitions.ts +8 -6
  294. package/src/skills/functions/delete.ts +1 -1
  295. package/src/skills/functions/deploy.ts +13 -9
  296. package/src/skills/functions/errors.ts +8 -0
  297. package/src/skills/functions/index.ts +11 -11
  298. package/src/skills/functions/inspect-invocations.ts +1 -1
  299. package/src/skills/functions/install-function.ts +11 -14
  300. package/src/skills/functions/invoke.ts +5 -5
  301. package/src/skills/functions/query-deployed-functions.ts +3 -4
  302. package/src/skills/functions/read.ts +3 -2
  303. package/src/skills/functions/update.ts +3 -2
  304. package/src/skills/index.ts +1 -1
  305. package/src/templates/anthropic.ts +2 -2
  306. package/src/templates/commentary.ts +1 -1
  307. package/src/templates/forex-effect.ts +7 -4
  308. package/src/testing/index.ts +2 -2
  309. package/src/translations.ts +4 -2
  310. package/src/types/Notebook.ts +6 -4
  311. package/src/types/ScriptCapabilities.ts +3 -3
  312. package/src/types/ScriptOperation.ts +1 -1
  313. package/src/types/index.ts +5 -5
  314. package/src/util/deploy.ts +10 -7
  315. package/src/util/functions.ts +24 -15
  316. package/src/util/index.ts +2 -2
  317. package/dist/lib/chunk-compiler2.mjs +0 -76
  318. package/dist/lib/chunk-compiler2.mjs.map +0 -1
  319. package/dist/lib/chunk-util.mjs +0 -146
  320. package/dist/lib/chunk-util.mjs.map +0 -1
  321. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +0 -5
  322. package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +0 -1
  323. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +0 -14
  324. package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +0 -1
  325. package/dist/types/src/components/QueryEditor/index.d.ts +0 -2
  326. package/dist/types/src/components/QueryEditor/index.d.ts.map +0 -1
  327. package/src/components/QueryEditor/QueryEditor.stories.tsx +0 -91
  328. package/src/components/QueryEditor/QueryEditor.tsx +0 -50
  329. package/src/components/QueryEditor/index.ts +0 -5
@@ -4,17 +4,17 @@
4
4
 
5
5
  // @import-as-namespace
6
6
 
7
- import type * as Atom from 'effect/unstable/reactivity/Atom';
7
+ import type * as Atom from 'effect/reactivity/Atom';
8
8
 
9
9
  import * as Capability from '@dxos/app-framework/Capability';
10
10
 
11
11
  import { meta } from '#meta';
12
12
 
13
- import { type Compiler as CompilerType } from '../compiler';
13
+ import { type Compiler as CompilerType } from '../compiler/index.ts';
14
14
 
15
15
  // Inline import to avoid `Settings` namespace alias colliding with the
16
16
  // `Settings` capability export below.
17
- export const Settings = Capability.makeSingleton<Atom.Writable<import('./Settings').Settings>>()(
17
+ export const Settings = Capability.makeSingleton<Atom.Writable<import('./Settings.ts').Settings>>()(
18
18
  `${meta.profile.key}.capability.settings`,
19
19
  );
20
20
  export const Compiler = Capability.makeSingleton<CompilerType>()(`${meta.profile.key}.capability.compiler`);
@@ -11,7 +11,7 @@ import * as Operation from '@dxos/compute/Operation';
11
11
  import * as Script from '@dxos/compute/Script';
12
12
  import { Database, DXN, Type } from '@dxos/echo';
13
13
 
14
- import { templates } from '../templates';
14
+ import { templates } from '../templates/index.ts';
15
15
 
16
16
  export const ScriptProps = Schema.Struct({
17
17
  name: Schema.optional(Schema.String),
@@ -2,8 +2,8 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- export * as Notebook from './Notebook';
6
- export * as ScriptCapabilities from './ScriptCapabilities';
7
- export * as ScriptEvents from './ScriptEvents';
8
- export * as ScriptOperation from './ScriptOperation';
9
- export * as Settings from './Settings';
5
+ export * as Notebook from './Notebook.ts';
6
+ export * as ScriptCapabilities from './ScriptCapabilities.ts';
7
+ export * as ScriptEvents from './ScriptEvents.ts';
8
+ export * as ScriptOperation from './ScriptOperation.ts';
9
+ export * as Settings from './Settings.ts';
@@ -2,12 +2,12 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type Client } from '@dxos/client';
6
5
  import { getUserFunctionIdInMetadata } from '@dxos/compute-runtime';
7
6
  import * as Operation from '@dxos/compute/Operation';
8
7
  import * as Script from '@dxos/compute/Script';
9
8
  import { Context } from '@dxos/context';
10
9
  import { type Database, Obj, Ref } from '@dxos/echo';
10
+ import { type EdgeHttpClient } from '@dxos/edge-client';
11
11
  import { FunctionsServiceClient, incrementSemverPatch } from '@dxos/edge-compute';
12
12
  import { bundleFunction } from '@dxos/edge-compute/bundler';
13
13
  import { log } from '@dxos/log';
@@ -20,7 +20,10 @@ export const isScriptDeployed = ({ script, fn }: { script: Script.Script; fn: an
20
20
 
21
21
  type DeployScriptProps = {
22
22
  script: Script.Script;
23
- client: Client;
23
+ /** Identity-bound EDGE HTTP client, read inside the deploy so a missing EDGE URL fails it rather than throwing. */
24
+ getEdgeHttpClient: () => EdgeHttpClient;
25
+ /** Owner identity DID (`did:halo:…`); deployment fails without one. */
26
+ ownerDid?: string;
24
27
  db: Database.Database;
25
28
  fn?: Operation.PersistentOperation;
26
29
  existingFunctionId?: string;
@@ -33,7 +36,8 @@ type DeployScriptResult = { success: boolean; error?: Error; functionId?: string
33
36
  */
34
37
  export const deployScript = async ({
35
38
  script,
36
- client,
39
+ getEdgeHttpClient,
40
+ ownerDid,
37
41
  db,
38
42
  fn,
39
43
  existingFunctionId,
@@ -43,8 +47,7 @@ export const deployScript = async ({
43
47
  return { success: false, error: validationError };
44
48
  }
45
49
 
46
- const identity = client.halo.identity.get();
47
- if (!identity) {
50
+ if (!ownerDid) {
48
51
  return { success: false, error: new Error('Identity not available.') };
49
52
  }
50
53
 
@@ -56,9 +59,9 @@ export const deployScript = async ({
56
59
  throw buildResult.error || new Error('Bundle creation failed');
57
60
  }
58
61
 
59
- const functionsServiceClient = FunctionsServiceClient.fromClient(client);
62
+ const functionsServiceClient = new FunctionsServiceClient(getEdgeHttpClient());
60
63
  const newFunction = await functionsServiceClient.deploy(Context.default(), {
61
- ownerUri: identity.did,
64
+ ownerUri: ownerDid,
62
65
  version: fn ? incrementSemverPatch(Obj.getMeta(fn).version ?? '0.0.0') : '0.0.1',
63
66
  functionId: existingFunctionId,
64
67
  entryPoint: buildResult.entryPoint,
@@ -9,7 +9,13 @@ import * as Script from '@dxos/compute/Script';
9
9
  import { Obj } from '@dxos/echo';
10
10
  import { type PublicKey } from '@dxos/keys';
11
11
  import { log } from '@dxos/log';
12
- import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
12
+ import { bufWkt, createBuf, fromDate, fromPublicKey } from '@dxos/protocols/buf';
13
+ import {
14
+ ClaimSchema,
15
+ type Credential,
16
+ CredentialSchema,
17
+ ServiceAccessSchema,
18
+ } from '@dxos/protocols/buf/dxos/halo/credentials_pb';
13
19
 
14
20
  /**
15
21
  * Get the function URL for a given script and client configuration
@@ -71,18 +77,21 @@ export const updateFunctionMetadata = (
71
77
  };
72
78
 
73
79
  export const getAccessCredential = (identityKey: PublicKey): Credential => {
74
- return {
75
- issuer: identityKey,
76
- issuanceDate: new Date(),
77
- subject: {
78
- id: identityKey,
79
- assertion: {
80
- '@type': 'dxos.halo.credentials.ServiceAccess',
81
- 'serverName': 'hub.dxos.network',
82
- 'serverKey': identityKey,
83
- identityKey,
84
- 'capabilities': ['composer:beta'],
85
- },
86
- },
87
- };
80
+ const key = fromPublicKey(identityKey);
81
+ return createBuf(CredentialSchema, {
82
+ issuer: key,
83
+ issuanceDate: fromDate(new Date()),
84
+ subject: createBuf(ClaimSchema, {
85
+ id: key,
86
+ assertion: bufWkt.anyPack(
87
+ ServiceAccessSchema,
88
+ createBuf(ServiceAccessSchema, {
89
+ serverName: 'hub.dxos.network',
90
+ serverKey: key,
91
+ identityKey: key,
92
+ capabilities: ['composer:beta'],
93
+ }),
94
+ ),
95
+ }),
96
+ });
88
97
  };
package/src/util/index.ts CHANGED
@@ -2,5 +2,5 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './deploy';
6
- export * from './functions';
5
+ export * from './deploy.ts';
6
+ export * from './functions.ts';
@@ -1,76 +0,0 @@
1
- import { t as Compiler } from "./chunk-compiler.mjs";
2
- import * as Capability from "@dxos/app-framework/Capability";
3
- import { ScriptCapabilities } from "#types";
4
- import { trim } from "@dxos/util";
5
- import * as Schema from "effect/Schema";
6
- import { initializeBundler } from "@dxos/edge-compute/bundler";
7
- import { log } from "@dxos/log";
8
- import * as ts$1 from "@typescript/typescript6";
9
- import * as Effect from "effect/Effect";
10
- import * as Schedule from "effect/Schedule";
11
- import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
12
- import * as HttpClient from "effect/unstable/http/HttpClient";
13
- import wasmUrl from "esbuild-wasm/esbuild.wasm?url";
14
- //#region src/capabilities/compiler.ts
15
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-script/src/capabilities/compiler.ts";
16
- var SCRIPT_PACKAGES_BUCKET = "https://pub-5745ae82e450484aa28f75fc6a175935.r2.dev/dev/";
17
- var DECLARATION_EXTS = [".d.ts", ".d.mts"];
18
- var compiler_default = Capability.makeModule(() => Effect.gen(function* () {
19
- yield* Effect.tryPromise({
20
- try: () => initializeBundler({ wasmUrl }),
21
- catch: (error) => /* @__PURE__ */ new Error(`Failed to initialize bundler: ${error}`)
22
- });
23
- const runtimeModules = yield* fetchRuntimeModules().pipe(Effect.provide(FetchHttpClient.layer));
24
- const compiler = new Compiler({
25
- target: ts$1.ScriptTarget.ES2022,
26
- lib: ["lib.es2022.d.ts", "lib.dom.d.ts"],
27
- skipLibCheck: true,
28
- moduleResolution: ts$1.ModuleResolutionKind.Bundler,
29
- allowImportingTsExtensions: true,
30
- noEmit: true,
31
- strict: true,
32
- esModuleInterop: true,
33
- paths: Object.fromEntries(runtimeModules.map((mod) => [mod.moduleName, [`./src/${mod.filename}`]]))
34
- });
35
- yield* Effect.tryPromise({
36
- try: () => compiler.initialize(trim`
37
- declare module 'https://*';
38
- ${""}
39
- `),
40
- catch: (error) => /* @__PURE__ */ new Error(`Failed to initialize compiler: ${error}`)
41
- });
42
- return Capability.contribute(ScriptCapabilities.Compiler, compiler);
43
- }));
44
- var fetchRuntimeModules = Effect.fnUntraced(function* () {
45
- const manifest = yield* HttpClient.get(new URL("manifest.json", SCRIPT_PACKAGES_BUCKET)).pipe(Effect.flatMap((_) => _.json), Effect.flatMap(Schema.decodeUnknownEffect(Schema.Struct({ files: Schema.Array(Schema.Struct({ key: Schema.String })) }))), Effect.map((manifest) => ({
46
- ...manifest,
47
- files: manifest.files.map((f) => f.key)
48
- })));
49
- const declarationFiles = manifest.files.filter((file) => DECLARATION_EXTS.some((ext) => file.endsWith(ext)));
50
- let fetched = 0;
51
- const modules = yield* Effect.forEach(declarationFiles, Effect.fnUntraced(function* (filename) {
52
- const content = yield* (yield* HttpClient.get(new URL(filename, SCRIPT_PACKAGES_BUCKET)).pipe(Effect.retry(Schedule.exponential(1e3).pipe(Schedule.upTo({ times: 3 }))))).text;
53
- const moduleName = filename.replace(/\.d\.(ts|mts)$/, "");
54
- fetched++;
55
- return {
56
- moduleName,
57
- filename,
58
- content
59
- };
60
- }, Effect.retry(Schedule.exponential(1e3).pipe(Schedule.upTo({ times: 3 })))), { concurrency: 20 });
61
- log.info("runtime modules", {
62
- manifest: manifest.files.length,
63
- files: declarationFiles.length,
64
- fetched
65
- }, {
66
- "~LogMeta": "~LogMeta",
67
- F: __dxlog_file,
68
- L: 109,
69
- S: this
70
- });
71
- return modules;
72
- });
73
- //#endregion
74
- export { compiler_default as default };
75
-
76
- //# sourceMappingURL=chunk-compiler2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunk-compiler2.mjs","names":[],"sources":["../../src/capabilities/compiler.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as ts from '@typescript/typescript6';\nimport * as Effect from 'effect/Effect';\nimport * as Schedule from 'effect/Schedule';\nimport * as Schema from 'effect/Schema';\nimport * as FetchHttpClient from 'effect/unstable/http/FetchHttpClient';\nimport * as HttpClient from 'effect/unstable/http/HttpClient';\nimport wasmUrl from 'esbuild-wasm/esbuild.wasm?url';\n\nimport * as Capability from '@dxos/app-framework/Capability';\nimport { initializeBundler } from '@dxos/edge-compute/bundler';\nimport { log } from '@dxos/log';\nimport { trim } from '@dxos/util';\n\nimport { ScriptCapabilities } from '#types';\n\nimport { Compiler } from '../compiler';\n\n// TODO(burdon): Document.\nconst SCRIPT_PACKAGES_BUCKET = 'https://pub-5745ae82e450484aa28f75fc6a175935.r2.dev/dev/';\nconst DECLARATION_EXTS = ['.d.ts', '.d.mts'];\nconst NO_TYPES = true; // Types temopararly disabled due to compiler erorrs.\n\nexport default Capability.makeModule(() =>\n Effect.gen(function* () {\n yield* Effect.tryPromise({\n try: () => initializeBundler({ wasmUrl }),\n catch: (error) => new Error(`Failed to initialize bundler: ${error}`),\n });\n\n const runtimeModules = yield* fetchRuntimeModules().pipe(Effect.provide(FetchHttpClient.layer));\n\n const compiler = new Compiler({\n target: ts.ScriptTarget.ES2022,\n lib: ['lib.es2022.d.ts', 'lib.dom.d.ts'],\n skipLibCheck: true,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n allowImportingTsExtensions: true,\n noEmit: true,\n strict: true,\n esModuleInterop: true,\n paths: Object.fromEntries(runtimeModules.map((mod: any) => [mod.moduleName, [`./src/${mod.filename}`]])),\n });\n\n yield* Effect.tryPromise({\n try: () =>\n compiler.initialize(trim`\n declare module 'https://*';\n ${NO_TYPES ? '' : 'declare module \"*\";'}\n `),\n catch: (error) => new Error(`Failed to initialize compiler: ${error}`),\n });\n if (!NO_TYPES) {\n for (const mod of runtimeModules) {\n compiler.setFile(`/src/${mod.filename}`, mod.content);\n }\n }\n\n return Capability.contribute(ScriptCapabilities.Compiler, compiler);\n }),\n);\n\nconst fetchRuntimeModules = Effect.fnUntraced(function* () {\n // { key, size, contentType }\n const manifest = yield* HttpClient.get(new URL('manifest.json', SCRIPT_PACKAGES_BUCKET)).pipe(\n Effect.flatMap((_) => _.json),\n Effect.flatMap(\n Schema.decodeUnknownEffect(\n Schema.Struct({\n files: Schema.Array(\n Schema.Struct({\n key: Schema.String,\n }),\n ),\n }),\n ),\n ),\n Effect.map((manifest) => ({ ...manifest, files: manifest.files.map((f) => f.key) })),\n );\n\n const declarationFiles = manifest.files.filter((file) => DECLARATION_EXTS.some((ext) => file.endsWith(ext)));\n\n let fetched = 0;\n const modules = yield* Effect.forEach(\n declarationFiles,\n Effect.fnUntraced(\n function* (filename) {\n const response = yield* HttpClient.get(new URL(filename, SCRIPT_PACKAGES_BUCKET)).pipe(\n Effect.retry(Schedule.exponential(1_000).pipe(Schedule.upTo({ times: 3 }))),\n );\n const content = yield* response.text;\n const moduleName = filename.replace(/\\.d\\.(ts|mts)$/, '');\n fetched++;\n\n return {\n moduleName,\n filename,\n content,\n };\n },\n Effect.retry(Schedule.exponential(1_000).pipe(Schedule.upTo({ times: 3 }))),\n ),\n { concurrency: 20 },\n );\n\n log.info('runtime modules', { manifest: manifest.files.length, files: declarationFiles.length, fetched });\n return modules;\n});\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,IAAM,yBAAyB;AAC/B,IAAM,mBAAmB,CAAC,SAAS,QAAQ;AAG3C,IAAA,mBAAe,WAAW,iBACxB,OAAO,IAAI,aAAa;CACtB,OAAO,OAAO,WAAW;EACvB,WAAW,kBAAkB,EAAE,QAAQ,CAAC;EACxC,QAAQ,0BAAU,IAAI,MAAM,iCAAiC,OAAO;CACtE,CAAC;CAED,MAAM,iBAAiB,OAAO,oBAAoB,CAAC,CAAC,KAAK,OAAO,QAAQ,gBAAgB,KAAK,CAAC;CAE9F,MAAM,WAAW,IAAI,SAAS;EAC5B,QAAQ,KAAG,aAAa;EACxB,KAAK,CAAC,mBAAmB,cAAc;EACvC,cAAc;EACd,kBAAkB,KAAG,qBAAqB;EAC1C,4BAA4B;EAC5B,QAAQ;EACR,QAAQ;EACR,iBAAiB;EACjB,OAAO,OAAO,YAAY,eAAe,KAAK,QAAa,CAAC,IAAI,YAAY,CAAC,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC;CACzG,CAAC;CAED,OAAO,OAAO,WAAW;EACvB,WACE,SAAS,WAAW,IAAI;;UAEX,GAA0B;OACxC;EACD,QAAQ,0BAAU,IAAI,MAAM,kCAAkC,OAAO;CACvE,CAAC;CAOD,OAAO,WAAW,WAAW,mBAAmB,UAAU,QAAQ;AACpE,CAAC,CACH;AAEA,IAAM,sBAAsB,OAAO,WAAW,aAAa;CAEzD,MAAM,WAAW,OAAO,WAAW,IAAI,IAAI,IAAI,iBAAiB,sBAAsB,CAAC,CAAC,CAAC,KACvF,OAAO,SAAS,MAAM,EAAE,IAAI,GAC5B,OAAO,QACL,OAAO,oBACL,OAAO,OAAO,EACZ,OAAO,OAAO,MACZ,OAAO,OAAO,EACZ,KAAK,OAAO,OACd,CAAC,CACH,EACF,CAAC,CACH,CACF,GACA,OAAO,KAAK,cAAc;EAAE,GAAG;EAAU,OAAO,SAAS,MAAM,KAAK,MAAM,EAAE,GAAG;CAAE,EAAE,CACrF;CAEA,MAAM,mBAAmB,SAAS,MAAM,QAAQ,SAAS,iBAAiB,MAAM,QAAQ,KAAK,SAAS,GAAG,CAAC,CAAC;CAE3G,IAAI,UAAU;CACd,MAAM,UAAU,OAAO,OAAO,QAC5B,kBACA,OAAO,WACL,WAAW,UAAU;EAInB,MAAM,UAAU,QAAO,OAHC,WAAW,IAAI,IAAI,IAAI,UAAU,sBAAsB,CAAC,CAAC,CAAC,KAChF,OAAO,MAAM,SAAS,YAAY,GAAK,CAAC,CAAC,KAAK,SAAS,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAC5E,EAAA,CACgC;EAChC,MAAM,aAAa,SAAS,QAAQ,kBAAkB,EAAE;EACxD;EAEA,OAAO;GACL;GACA;GACA;EACF;CACF,GACA,OAAO,MAAM,SAAS,YAAY,GAAK,CAAC,CAAC,KAAK,SAAS,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAC5E,GACA,EAAE,aAAa,GAAG,CACpB;CAEA,IAAI,KAAK,mBAAmB;EAAE,UAAU,SAAS,MAAM;EAAQ,OAAO,iBAAiB;EAAQ;CAAQ,GAAA;EAAA,YAAA;EAAA,GAAA;EAAA,GAAA;EAAA,GAAA;CAAA,CAAC;CACxG,OAAO;AACT,CAAC"}
@@ -1,146 +0,0 @@
1
- import * as Operation from "@dxos/compute/Operation";
2
- import { Obj, Ref } from "@dxos/echo";
3
- import { getInvocationUrl, getUserFunctionIdInMetadata } from "@dxos/compute-runtime";
4
- import { Context } from "@dxos/context";
5
- import { FunctionsServiceClient, incrementSemverPatch } from "@dxos/edge-compute";
6
- import { bundleFunction } from "@dxos/edge-compute/bundler";
7
- import { log } from "@dxos/log";
8
- import { FunctionRuntimeKind } from "@dxos/protocols";
9
- //#region src/util/deploy.ts
10
- var __dxlog_file$1 = "/__w/dxos/dxos/packages/plugins/plugin-script/src/util/deploy.ts";
11
- var isScriptDeployed = ({ script, fn }) => {
12
- const existingFunctionId = fn && getUserFunctionIdInMetadata(Obj.getMeta(fn));
13
- return Boolean(existingFunctionId) && !script.changed;
14
- };
15
- /**
16
- * Deploy a script to a space, handling bundling and uploading to the FaaS infrastructure.
17
- */
18
- var deployScript = async ({ script, client, db, fn, existingFunctionId }) => {
19
- const validationError = validateDeployInputs(script, db);
20
- if (validationError) return {
21
- success: false,
22
- error: validationError
23
- };
24
- const identity = client.halo.identity.get();
25
- if (!identity) return {
26
- success: false,
27
- error: /* @__PURE__ */ new Error("Identity not available.")
28
- };
29
- try {
30
- const buildResult = await bundleFunction({ source: script.source.target.content });
31
- if ("error" in buildResult) throw buildResult.error || /* @__PURE__ */ new Error("Bundle creation failed");
32
- const storedFunction = createOrUpdateFunction(db, fn, script, await FunctionsServiceClient.fromClient(client).deploy(Context.default(void 0, {
33
- "~LogMeta": "~LogMeta",
34
- F: __dxlog_file$1,
35
- L: 60
36
- }), {
37
- ownerUri: identity.did,
38
- version: fn ? incrementSemverPatch(Obj.getMeta(fn).version ?? "0.0.0") : "0.0.1",
39
- functionId: existingFunctionId,
40
- entryPoint: buildResult.entryPoint,
41
- assets: buildResult.assets,
42
- runtime: FunctionRuntimeKind.enums.WORKER_LOADER
43
- }));
44
- Obj.update(script, (script) => {
45
- script.changed = false;
46
- });
47
- return {
48
- success: true,
49
- functionId: getUserFunctionIdInMetadata(Obj.getMeta(storedFunction))
50
- };
51
- } catch (err) {
52
- log.catch(err, void 0, {
53
- "~LogMeta": "~LogMeta",
54
- F: __dxlog_file$1,
55
- L: 76,
56
- S: void 0
57
- });
58
- return {
59
- success: false,
60
- error: err
61
- };
62
- }
63
- };
64
- /**
65
- * Validate inputs for script deployment.
66
- */
67
- var validateDeployInputs = (script, db) => {
68
- if (!script.source || !db) return /* @__PURE__ */ new Error("Script source or database not available");
69
- return null;
70
- };
71
- var createOrUpdateFunction = (db, fn, script, newFunction) => {
72
- if (fn) {
73
- Operation.setFrom(fn, newFunction);
74
- return fn;
75
- } else {
76
- Obj.update(newFunction, (newFunction) => {
77
- newFunction.source = Ref.make(script);
78
- });
79
- return db.add(newFunction);
80
- }
81
- };
82
- //#endregion
83
- //#region src/util/functions.ts
84
- var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-script/src/util/functions.ts";
85
- /**
86
- * Get the function URL for a given script and client configuration
87
- */
88
- var getFunctionUrl = ({ script, fn, edgeUrl }) => {
89
- const spaceId = Obj.getDatabase(script)?.spaceId;
90
- const existingFunctionId = fn && getUserFunctionIdInMetadata(Obj.getMeta(fn));
91
- if (!existingFunctionId) return;
92
- return getInvocationUrl(existingFunctionId, edgeUrl, { spaceId });
93
- };
94
- var updateFunctionMetadata = (script, storedFunction, meta, functionId) => {
95
- Obj.update(storedFunction, (storedFunction) => {
96
- if (script.description !== void 0 && script.description.trim() !== "") storedFunction.description = script.description;
97
- else if (meta.description) storedFunction.description = meta.description;
98
- else log.verbose("no description in function metadata", { functionId }, {
99
- "~LogMeta": "~LogMeta",
100
- F: __dxlog_file,
101
- L: 50,
102
- S: void 0
103
- });
104
- if (meta.inputSchema) storedFunction.inputSchema = meta.inputSchema;
105
- else log.verbose("no input schema in function metadata", { functionId }, {
106
- "~LogMeta": "~LogMeta",
107
- F: __dxlog_file,
108
- L: 56,
109
- S: void 0
110
- });
111
- if (meta.outputSchema) storedFunction.outputSchema = meta.outputSchema;
112
- else log.verbose("no output schema in function metadata", { functionId }, {
113
- "~LogMeta": "~LogMeta",
114
- F: __dxlog_file,
115
- L: 62,
116
- S: void 0
117
- });
118
- if (meta.key) Obj.getMeta(storedFunction).key = meta.key;
119
- else log.verbose("no key in function metadata", { functionId }, {
120
- "~LogMeta": "~LogMeta",
121
- F: __dxlog_file,
122
- L: 68,
123
- S: void 0
124
- });
125
- });
126
- };
127
- var getAccessCredential = (identityKey) => {
128
- return {
129
- issuer: identityKey,
130
- issuanceDate: /* @__PURE__ */ new Date(),
131
- subject: {
132
- id: identityKey,
133
- assertion: {
134
- "@type": "dxos.halo.credentials.ServiceAccess",
135
- "serverName": "hub.dxos.network",
136
- "serverKey": identityKey,
137
- identityKey,
138
- "capabilities": ["composer:beta"]
139
- }
140
- }
141
- };
142
- };
143
- //#endregion
144
- export { isScriptDeployed as a, deployScript as i, getFunctionUrl as n, updateFunctionMetadata as r, getAccessCredential as t };
145
-
146
- //# sourceMappingURL=chunk-util.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunk-util.mjs","names":[],"sources":["../../src/util/deploy.ts","../../src/util/functions.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Client } from '@dxos/client';\nimport { getUserFunctionIdInMetadata } from '@dxos/compute-runtime';\nimport * as Operation from '@dxos/compute/Operation';\nimport * as Script from '@dxos/compute/Script';\nimport { Context } from '@dxos/context';\nimport { type Database, Obj, Ref } from '@dxos/echo';\nimport { FunctionsServiceClient, incrementSemverPatch } from '@dxos/edge-compute';\nimport { bundleFunction } from '@dxos/edge-compute/bundler';\nimport { log } from '@dxos/log';\nimport { FunctionRuntimeKind } from '@dxos/protocols';\n\nexport const isScriptDeployed = ({ script, fn }: { script: Script.Script; fn: any }): boolean => {\n const existingFunctionId = fn && getUserFunctionIdInMetadata(Obj.getMeta(fn));\n return Boolean(existingFunctionId) && !script.changed;\n};\n\ntype DeployScriptProps = {\n script: Script.Script;\n client: Client;\n db: Database.Database;\n fn?: Operation.PersistentOperation;\n existingFunctionId?: string;\n};\n\ntype DeployScriptResult = { success: boolean; error?: Error; functionId?: string };\n\n/**\n * Deploy a script to a space, handling bundling and uploading to the FaaS infrastructure.\n */\nexport const deployScript = async ({\n script,\n client,\n db,\n fn,\n existingFunctionId,\n}: DeployScriptProps): Promise<DeployScriptResult> => {\n const validationError = validateDeployInputs(script, db);\n if (validationError) {\n return { success: false, error: validationError };\n }\n\n const identity = client.halo.identity.get();\n if (!identity) {\n return { success: false, error: new Error('Identity not available.') };\n }\n\n try {\n const buildResult = await bundleFunction({\n source: script.source!.target!.content,\n });\n if ('error' in buildResult) {\n throw buildResult.error || new Error('Bundle creation failed');\n }\n\n const functionsServiceClient = FunctionsServiceClient.fromClient(client);\n const newFunction = await functionsServiceClient.deploy(Context.default(), {\n ownerUri: identity.did,\n version: fn ? incrementSemverPatch(Obj.getMeta(fn).version ?? '0.0.0') : '0.0.1',\n functionId: existingFunctionId,\n entryPoint: buildResult.entryPoint,\n assets: buildResult.assets,\n runtime: FunctionRuntimeKind.enums.WORKER_LOADER,\n });\n\n const storedFunction = createOrUpdateFunction(db, fn, script, newFunction);\n Obj.update(script, (script) => {\n script.changed = false;\n });\n\n return { success: true, functionId: getUserFunctionIdInMetadata(Obj.getMeta(storedFunction)) };\n } catch (err: any) {\n log.catch(err);\n return { success: false, error: err };\n }\n};\n\n/**\n * Validate inputs for script deployment.\n */\nconst validateDeployInputs = (script: Script.Script, db: Database.Database): Error | null => {\n if (!script.source || !db) {\n return new Error('Script source or database not available');\n }\n return null;\n};\n\nconst createOrUpdateFunction = (\n db: Database.Database,\n fn: Operation.PersistentOperation | undefined,\n script: Script.Script,\n newFunction: Operation.PersistentOperation,\n): Operation.PersistentOperation => {\n if (fn) {\n Operation.setFrom(fn, newFunction);\n return fn;\n } else {\n Obj.update(newFunction, (newFunction) => {\n newFunction.source = Ref.make(script);\n });\n return db.add(newFunction);\n }\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { getUserFunctionIdInMetadata } from '@dxos/compute-runtime';\nimport { getInvocationUrl } from '@dxos/compute-runtime';\nimport type * as Operation from '@dxos/compute/Operation';\nimport * as Script from '@dxos/compute/Script';\nimport { Obj } from '@dxos/echo';\nimport { type PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';\n\n/**\n * Get the function URL for a given script and client configuration\n */\nexport const getFunctionUrl = ({\n script,\n fn,\n edgeUrl,\n}: {\n script: Script.Script;\n fn: any;\n edgeUrl: string;\n}): string | undefined => {\n const spaceId = Obj.getDatabase(script)?.spaceId;\n const existingFunctionId = fn && getUserFunctionIdInMetadata(Obj.getMeta(fn));\n\n if (!existingFunctionId) {\n return undefined;\n }\n\n return getInvocationUrl(existingFunctionId, edgeUrl, {\n spaceId,\n });\n};\n\nexport const updateFunctionMetadata = (\n script: Script.Script,\n storedFunction: Operation.PersistentOperation,\n meta: any,\n functionId: string,\n) => {\n Obj.update(storedFunction, (storedFunction) => {\n if (script.description !== undefined && script.description.trim() !== '') {\n storedFunction.description = script.description;\n } else if (meta.description) {\n storedFunction.description = meta.description;\n } else {\n log.verbose('no description in function metadata', { functionId });\n }\n\n if (meta.inputSchema) {\n storedFunction.inputSchema = meta.inputSchema;\n } else {\n log.verbose('no input schema in function metadata', { functionId });\n }\n\n if (meta.outputSchema) {\n storedFunction.outputSchema = meta.outputSchema;\n } else {\n log.verbose('no output schema in function metadata', { functionId });\n }\n\n if (meta.key) {\n Obj.getMeta(storedFunction).key = meta.key;\n } else {\n log.verbose('no key in function metadata', { functionId });\n }\n });\n};\n\nexport const getAccessCredential = (identityKey: PublicKey): Credential => {\n return {\n issuer: identityKey,\n issuanceDate: new Date(),\n subject: {\n id: identityKey,\n assertion: {\n '@type': 'dxos.halo.credentials.ServiceAccess',\n 'serverName': 'hub.dxos.network',\n 'serverKey': identityKey,\n identityKey,\n 'capabilities': ['composer:beta'],\n },\n },\n };\n};\n"],"mappings":"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"}
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import { type TypescriptEditorProps } from '../TypescriptEditor';
3
- export type QueryEditorProps = Omit<TypescriptEditorProps, 'env'>;
4
- export declare const QueryEditor: (props: QueryEditorProps) => React.JSX.Element | null;
5
- //# sourceMappingURL=QueryEditor.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryEditor.d.ts","sourceRoot":"","sources":["../../../../../src/components/QueryEditor/QueryEditor.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAOxC,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAgBnF,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;AAElE,eAAO,MAAM,WAAW,UAAW,gBAAgB,6BAmBlD,CAAC"}
@@ -1,14 +0,0 @@
1
- import { type StoryObj } from '@storybook/react-vite';
2
- import React from 'react';
3
- import { QueryEditor, type QueryEditorProps } from './QueryEditor';
4
- declare const DefaultStory: (props: QueryEditorProps) => React.JSX.Element;
5
- declare const meta: {
6
- title: string;
7
- component: typeof QueryEditor;
8
- render: typeof DefaultStory;
9
- decorators: import("@storybook/react").Decorator[];
10
- };
11
- export default meta;
12
- type Story = StoryObj<typeof meta>;
13
- export declare const Default: Story;
14
- //# sourceMappingURL=QueryEditor.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"QueryEditor.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/QueryEditor/QueryEditor.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAyC,MAAM,OAAO,CAAC;AAW9D,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMnE,QAAA,MAAM,YAAY,UAAW,gBAAgB,sBAmD5C,CAAC;AAEF,QAAA,MAAM,IAAI;;;;;CAK2B,CAAC;eAEvB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAIrB,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './QueryEditor';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/QueryEditor/index.ts"],"names":[],"mappings":"AAIA,cAAc,eAAe,CAAC"}
@@ -1,91 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React, { useCallback, useMemo, useState } from 'react';
7
-
8
- import { Doc } from '@dxos/echo-doc';
9
- import { QuerySandbox } from '@dxos/echo-query/sandbox';
10
- import { createObject } from '@dxos/react-client/echo';
11
- import { Panel, Toolbar, useAsyncEffect } from '@dxos/react-ui';
12
- import { JsonHighlighter } from '@dxos/react-ui-syntax-highlighter';
13
- import { withLayout, withTheme } from '@dxos/react-ui/testing';
14
- import { createDataExtensions } from '@dxos/ui-editor';
15
- import { trim } from '@dxos/util';
16
-
17
- import { QueryEditor, type QueryEditorProps } from './QueryEditor';
18
-
19
- const SCRIPT = trim`
20
- Query.select(Filter.type('org.dxos.type.person'))
21
- `;
22
-
23
- const DefaultStory = (props: QueryEditorProps) => {
24
- const object = useMemo(() => createObject({ content: SCRIPT }), []);
25
- const [result, setResult] = useState<object | undefined>({});
26
- const [sandbox, setSandbox] = useState<QuerySandbox>();
27
-
28
- useAsyncEffect(async () => {
29
- const sandbox = new QuerySandbox();
30
- await sandbox.open();
31
- setSandbox(sandbox);
32
-
33
- return () => {
34
- void sandbox.close();
35
- };
36
- }, []);
37
-
38
- const extensions = useMemo(
39
- () => [createDataExtensions({ id: object.id, text: Doc.createAccessor(object, ['content']) })],
40
- [],
41
- );
42
-
43
- const handleRun = useCallback(async () => {
44
- try {
45
- const result = sandbox?.eval(object.content);
46
-
47
- setResult({
48
- timestamp: Date.now(),
49
- result,
50
- });
51
- } catch (err) {
52
- setResult({
53
- timestamp: Date.now(),
54
- error: String(err),
55
- });
56
- }
57
- }, [object, sandbox]);
58
-
59
- return (
60
- <Panel.Root>
61
- <Panel.Toolbar asChild>
62
- <Toolbar.Root>
63
- <Toolbar.Button onClick={handleRun}>Run</Toolbar.Button>
64
- </Toolbar.Root>
65
- </Panel.Toolbar>
66
- <Panel.Content>
67
- <div className='grid grid-rows-[1fr_min-content] h-full overflow-hidden text-sm'>
68
- <QueryEditor {...props} initialValue={object.content} extensions={extensions} />
69
- <JsonHighlighter data={result} classNames='shrink-0 p-2 border-y border-subdued-separator' />
70
- </div>
71
- </Panel.Content>
72
- </Panel.Root>
73
- );
74
- };
75
-
76
- const meta = {
77
- title: 'plugins/plugin-script/components/QueryEditor',
78
- component: QueryEditor,
79
- render: DefaultStory,
80
- decorators: [withTheme(), withLayout({ layout: 'column', classNames: 'w-document-max-width' })],
81
- } satisfies Meta<typeof DefaultStory>;
82
-
83
- export default meta;
84
-
85
- type Story = StoryObj<typeof meta>;
86
-
87
- export const Default: Story = {
88
- args: {
89
- id: 'test',
90
- },
91
- };
@@ -1,50 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { ModuleResolutionKind, ScriptTarget } from '@typescript/typescript6';
6
- import React, { useState } from 'react';
7
-
8
- // TODO(burdon): Document.
9
- import queryApi from '@dxos/echo-query/api.d.ts?raw';
10
- import { useAsyncEffect } from '@dxos/react-ui';
11
-
12
- import { Compiler } from '../../compiler';
13
- import { TypescriptEditor, type TypescriptEditorProps } from '../TypescriptEditor';
14
-
15
- const GLOBALS = `
16
- namespace QueryAPI {
17
- ${queryApi}
18
- }
19
-
20
- declare global {
21
- const Query: typeof QueryAPI.Query;
22
- const Filter: typeof QueryAPI.Filter;
23
- const Order: typeof QueryAPI.Order;
24
- }
25
-
26
- export {};
27
- `;
28
-
29
- export type QueryEditorProps = Omit<TypescriptEditorProps, 'env'>;
30
-
31
- export const QueryEditor = (props: QueryEditorProps) => {
32
- const [compiler, setCompiler] = useState<Compiler>();
33
-
34
- useAsyncEffect(async () => {
35
- const compiler = new Compiler({
36
- lib: ['ES5'],
37
- target: ScriptTarget.ES2022,
38
- // Avoid `@typescript/vfs`'s deprecated `node10` default (rejected by TS 6).
39
- moduleResolution: ModuleResolutionKind.Bundler,
40
- });
41
- await compiler.initialize(GLOBALS);
42
- setCompiler(compiler);
43
- }, []);
44
-
45
- if (!compiler) {
46
- return null;
47
- }
48
-
49
- return <TypescriptEditor {...props} env={compiler.environment} />;
50
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- export * from './QueryEditor';