@dxos/plugin-script 0.8.4-main.67995b8 → 0.8.4-main.ae835ea

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 (304) hide show
  1. package/dist/lib/browser/DeploymentDialog-E5NXT4UQ.mjs +14 -0
  2. package/dist/lib/browser/NotebookContainer-C36N7AFF.mjs +817 -0
  3. package/dist/lib/browser/NotebookContainer-C36N7AFF.mjs.map +7 -0
  4. package/dist/lib/browser/ScriptContainer-4YPRUM3C.mjs +148 -0
  5. package/dist/lib/browser/ScriptContainer-4YPRUM3C.mjs.map +7 -0
  6. package/dist/lib/browser/{app-graph-builder-HLQ7K3BT.mjs → app-graph-builder-LEOPGBJD.mjs} +11 -9
  7. package/dist/lib/browser/app-graph-builder-LEOPGBJD.mjs.map +7 -0
  8. package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +30 -0
  9. package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +7 -0
  10. package/dist/lib/browser/chunk-5S5YQNJZ.mjs +304 -0
  11. package/dist/lib/browser/chunk-5S5YQNJZ.mjs.map +7 -0
  12. package/dist/lib/browser/{chunk-3U6DTUH3.mjs → chunk-A5K3TXYA.mjs} +29 -43
  13. package/dist/lib/browser/chunk-A5K3TXYA.mjs.map +7 -0
  14. package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EB6AXFXO.mjs} +8 -5
  15. package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +7 -0
  16. package/dist/lib/browser/chunk-HCURXADW.mjs +102 -0
  17. package/dist/lib/browser/chunk-HCURXADW.mjs.map +7 -0
  18. package/dist/lib/browser/{chunk-FIM2MVNJ.mjs → chunk-HHTOAI2J.mjs} +161 -72
  19. package/dist/lib/browser/chunk-HHTOAI2J.mjs.map +7 -0
  20. package/dist/lib/browser/{chunk-P4HQKUCP.mjs → chunk-IQMYIWHG.mjs} +15 -15
  21. package/dist/lib/browser/chunk-IQMYIWHG.mjs.map +7 -0
  22. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  23. package/dist/lib/browser/chunk-LI4P25M5.mjs +111 -0
  24. package/dist/lib/browser/chunk-LI4P25M5.mjs.map +7 -0
  25. package/dist/lib/browser/{chunk-FMDXKOP7.mjs → chunk-Q2DGRQRN.mjs} +75 -53
  26. package/dist/lib/browser/chunk-Q2DGRQRN.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-ST3ACVUC.mjs +88 -0
  28. package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +7 -0
  29. package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-UOQ6NCH3.mjs} +2 -2
  30. package/dist/lib/browser/{compiler-CXCUA4UQ.mjs → compiler-Q4UY2COU.mjs} +9 -5
  31. package/dist/lib/browser/compiler-Q4UY2COU.mjs.map +7 -0
  32. package/dist/lib/browser/index.mjs +109 -44
  33. package/dist/lib/browser/index.mjs.map +3 -3
  34. package/dist/lib/browser/{intent-resolver-S3H2SMUY.mjs → intent-resolver-AMMHATM7.mjs} +40 -24
  35. package/dist/lib/browser/intent-resolver-AMMHATM7.mjs.map +7 -0
  36. package/dist/lib/browser/meta.json +1 -1
  37. package/dist/lib/browser/{react-surface-FYYXZA7C.mjs → react-surface-X4NATU6B.mjs} +43 -19
  38. package/dist/lib/browser/react-surface-X4NATU6B.mjs.map +7 -0
  39. package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-6UXY7F7D.mjs} +10 -8
  40. package/dist/lib/browser/settings-6UXY7F7D.mjs.map +7 -0
  41. package/dist/lib/browser/templates/index.mjs +2 -1
  42. package/dist/lib/browser/types/index.mjs +8 -4
  43. package/dist/lib/node-esm/DeploymentDialog-OSHHSEBH.mjs +15 -0
  44. package/dist/lib/node-esm/DeploymentDialog-OSHHSEBH.mjs.map +7 -0
  45. package/dist/lib/node-esm/NotebookContainer-FOVFGJQR.mjs +818 -0
  46. package/dist/lib/node-esm/NotebookContainer-FOVFGJQR.mjs.map +7 -0
  47. package/dist/lib/node-esm/ScriptContainer-EW24D5II.mjs +149 -0
  48. package/dist/lib/node-esm/ScriptContainer-EW24D5II.mjs.map +7 -0
  49. package/dist/lib/node-esm/{app-graph-builder-7EYIHWH4.mjs → app-graph-builder-XJ3MY5BM.mjs} +11 -9
  50. package/dist/lib/node-esm/app-graph-builder-XJ3MY5BM.mjs.map +7 -0
  51. package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +31 -0
  52. package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +7 -0
  53. package/dist/lib/node-esm/chunk-2GVTWESW.mjs +90 -0
  54. package/dist/lib/node-esm/chunk-2GVTWESW.mjs.map +7 -0
  55. package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-55JZVM6K.mjs} +2 -2
  56. package/dist/lib/node-esm/chunk-EJLYOSD7.mjs +113 -0
  57. package/dist/lib/node-esm/chunk-EJLYOSD7.mjs.map +7 -0
  58. package/dist/lib/node-esm/{chunk-RT43MACC.mjs → chunk-GA27XSEY.mjs} +29 -43
  59. package/dist/lib/node-esm/chunk-GA27XSEY.mjs.map +7 -0
  60. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  61. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  62. package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-IBV2DR36.mjs} +8 -5
  63. package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-N2XLVOFB.mjs +103 -0
  65. package/dist/lib/node-esm/chunk-N2XLVOFB.mjs.map +7 -0
  66. package/dist/lib/node-esm/{chunk-XJPK3IYI.mjs → chunk-O7HXE72S.mjs} +75 -53
  67. package/dist/lib/node-esm/chunk-O7HXE72S.mjs.map +7 -0
  68. package/dist/lib/node-esm/{chunk-7NMI4CEU.mjs → chunk-OZ6LCME4.mjs} +161 -72
  69. package/dist/lib/node-esm/chunk-OZ6LCME4.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-TUGLYZDT.mjs +305 -0
  71. package/dist/lib/node-esm/chunk-TUGLYZDT.mjs.map +7 -0
  72. package/dist/lib/node-esm/{chunk-QKK3NDHW.mjs → chunk-UEGPBCSF.mjs} +15 -15
  73. package/dist/lib/node-esm/chunk-UEGPBCSF.mjs.map +7 -0
  74. package/dist/lib/node-esm/{compiler-EPFKQXPE.mjs → compiler-I6A4KE6E.mjs} +9 -5
  75. package/dist/lib/node-esm/compiler-I6A4KE6E.mjs.map +7 -0
  76. package/dist/lib/node-esm/index.mjs +109 -44
  77. package/dist/lib/node-esm/index.mjs.map +3 -3
  78. package/dist/lib/node-esm/{intent-resolver-OHKNJFCC.mjs → intent-resolver-YKLZQR7U.mjs} +40 -24
  79. package/dist/lib/node-esm/intent-resolver-YKLZQR7U.mjs.map +7 -0
  80. package/dist/lib/node-esm/meta.json +1 -1
  81. package/dist/lib/node-esm/{react-surface-V32NWHKN.mjs → react-surface-LVGLBSTE.mjs} +43 -19
  82. package/dist/lib/node-esm/react-surface-LVGLBSTE.mjs.map +7 -0
  83. package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-O4EZPUE3.mjs} +10 -8
  84. package/dist/lib/node-esm/settings-O4EZPUE3.mjs.map +7 -0
  85. package/dist/lib/node-esm/templates/index.mjs +2 -1
  86. package/dist/lib/node-esm/types/index.mjs +8 -4
  87. package/dist/types/src/ScriptPlugin.d.ts +1 -1
  88. package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
  89. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  90. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  91. package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
  92. package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
  93. package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
  94. package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
  95. package/dist/types/src/capabilities/compiler.d.ts +1 -1
  96. package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
  97. package/dist/types/src/capabilities/index.d.ts +6 -6
  98. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  99. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  100. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  101. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  102. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  103. package/dist/types/src/capabilities/settings.d.ts +1 -1
  104. package/dist/types/src/compiler/compiler.d.ts.map +1 -1
  105. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +2 -2
  106. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
  107. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +243 -13
  108. package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
  109. package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
  110. package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
  111. package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
  112. package/dist/types/src/components/NotebookContainer.d.ts +10 -0
  113. package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
  114. package/dist/types/src/components/NotebookContainer.stories.d.ts +251 -0
  115. package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
  116. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
  117. package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
  118. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
  119. package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
  120. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
  121. package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
  122. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +245 -0
  123. package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
  124. package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
  125. package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
  126. package/dist/types/src/components/ScriptContainer.d.ts +4 -4
  127. package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
  128. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +5 -6
  129. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
  130. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +242 -10
  131. package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
  132. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
  133. package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
  134. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +2 -2
  135. package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
  136. package/dist/types/src/components/TestPanel/TestContainer.d.ts +2 -2
  137. package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
  138. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -2
  139. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
  140. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +11 -4
  141. package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
  142. package/dist/types/src/components/index.d.ts +3 -4
  143. package/dist/types/src/components/index.d.ts.map +1 -1
  144. package/dist/types/src/events.d.ts.map +1 -1
  145. package/dist/types/src/hooks/deploy.d.ts +17 -16
  146. package/dist/types/src/hooks/deploy.d.ts.map +1 -1
  147. package/dist/types/src/hooks/format.d.ts +2 -2
  148. package/dist/types/src/hooks/format.d.ts.map +1 -1
  149. package/dist/types/src/hooks/template.d.ts +4 -14
  150. package/dist/types/src/hooks/template.d.ts.map +1 -1
  151. package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
  152. package/dist/types/src/index.d.ts +1 -0
  153. package/dist/types/src/index.d.ts.map +1 -1
  154. package/dist/types/src/meta.d.ts +0 -1
  155. package/dist/types/src/meta.d.ts.map +1 -1
  156. package/dist/types/src/notebook/compute-graph.d.ts +45 -0
  157. package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
  158. package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
  159. package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
  160. package/dist/types/src/notebook/eval.d.ts +13 -0
  161. package/dist/types/src/notebook/eval.d.ts.map +1 -0
  162. package/dist/types/src/notebook/index.d.ts +2 -0
  163. package/dist/types/src/notebook/index.d.ts.map +1 -0
  164. package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
  165. package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
  166. package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
  167. package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
  168. package/dist/types/src/templates/chess.d.ts.map +1 -1
  169. package/dist/types/src/templates/data-generator.d.ts.map +1 -1
  170. package/dist/types/src/templates/discord.d.ts.map +1 -1
  171. package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
  172. package/dist/types/src/templates/forex.d.ts.map +1 -1
  173. package/dist/types/src/templates/gmail.d.ts.map +1 -1
  174. package/dist/types/src/templates/index.d.ts +43 -1
  175. package/dist/types/src/templates/index.d.ts.map +1 -1
  176. package/dist/types/src/templates/{echo.d.ts → ping.d.ts} +1 -1
  177. package/dist/types/src/templates/ping.d.ts.map +1 -0
  178. package/dist/types/src/testing/data.d.ts +3 -0
  179. package/dist/types/src/testing/data.d.ts.map +1 -0
  180. package/dist/types/src/testing/index.d.ts +2 -0
  181. package/dist/types/src/testing/index.d.ts.map +1 -0
  182. package/dist/types/src/translations.d.ts +30 -5
  183. package/dist/types/src/translations.d.ts.map +1 -1
  184. package/dist/types/src/types/Notebook.d.ts +31 -0
  185. package/dist/types/src/types/Notebook.d.ts.map +1 -0
  186. package/dist/types/src/types/actions.d.ts +54 -0
  187. package/dist/types/src/types/actions.d.ts.map +1 -0
  188. package/dist/types/src/types/index.d.ts +3 -1
  189. package/dist/types/src/types/index.d.ts.map +1 -1
  190. package/dist/types/src/types/types.d.ts +6 -0
  191. package/dist/types/src/types/types.d.ts.map +1 -0
  192. package/dist/types/src/util/deploy.d.ts +7 -7
  193. package/dist/types/src/util/deploy.d.ts.map +1 -1
  194. package/dist/types/src/util/functions.d.ts +6 -3
  195. package/dist/types/src/util/functions.d.ts.map +1 -1
  196. package/dist/types/tsconfig.tsbuildinfo +1 -1
  197. package/package.json +82 -75
  198. package/src/ScriptPlugin.tsx +90 -71
  199. package/src/capabilities/app-graph-builder.ts +9 -8
  200. package/src/capabilities/artifact-definition.ts +7 -4
  201. package/src/capabilities/blueprint-definition.ts +30 -0
  202. package/src/capabilities/compiler.ts +2 -1
  203. package/src/capabilities/index.ts +1 -1
  204. package/src/capabilities/intent-resolver.ts +21 -12
  205. package/src/capabilities/react-surface.tsx +28 -15
  206. package/src/capabilities/settings.ts +3 -3
  207. package/src/compiler/compiler.ts +1 -1
  208. package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +39 -20
  209. package/src/components/DeploymentDialog/DeploymentDialog.tsx +16 -22
  210. package/src/components/DeploymentDialog/index.ts +1 -1
  211. package/src/components/FrameContainer/FrameContainer.tsx +3 -2
  212. package/src/components/NotebookContainer.stories.tsx +83 -0
  213. package/src/components/NotebookContainer.tsx +263 -0
  214. package/src/components/NotebookStack/NotebookCell.tsx +208 -0
  215. package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
  216. package/src/components/NotebookStack/NotebookStack.stories.tsx +54 -0
  217. package/src/components/NotebookStack/NotebookStack.tsx +86 -0
  218. package/src/components/NotebookStack/index.ts +6 -0
  219. package/src/components/ScriptContainer.tsx +7 -6
  220. package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +34 -17
  221. package/src/components/ScriptToolbar/ScriptToolbar.tsx +33 -26
  222. package/src/components/Settings/ScriptObjectSettings.tsx +113 -33
  223. package/src/components/Settings/ScriptPluginSettings.tsx +37 -47
  224. package/src/components/TestPanel/TestContainer.tsx +4 -3
  225. package/src/components/TestPanel/TestPanel.tsx +7 -7
  226. package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +79 -31
  227. package/src/components/TypescriptEditor/TypescriptEditor.tsx +37 -34
  228. package/src/components/index.ts +3 -0
  229. package/src/events.ts +2 -2
  230. package/src/hooks/deploy.ts +23 -24
  231. package/src/hooks/format.ts +4 -4
  232. package/src/hooks/template.ts +6 -15
  233. package/src/hooks/useCreateAndDeployScriptTemplates.ts +6 -5
  234. package/src/index.ts +1 -0
  235. package/src/meta.ts +7 -5
  236. package/src/notebook/compute-graph.test.ts +70 -0
  237. package/src/notebook/compute-graph.ts +206 -0
  238. package/src/notebook/eval.ts +105 -0
  239. package/src/notebook/index.ts +5 -0
  240. package/src/notebook/vfs-parser.test.ts +149 -0
  241. package/src/notebook/vfs-parser.ts +451 -0
  242. package/src/templates/chess.ts +3 -1
  243. package/src/templates/data-generator.ts +9 -3
  244. package/src/templates/discord.ts +12 -4
  245. package/src/templates/forex-effect.ts +7 -3
  246. package/src/templates/forex.ts +3 -1
  247. package/src/templates/gmail.ts +33 -62
  248. package/src/templates/index.ts +6 -6
  249. package/src/testing/data.ts +72 -0
  250. package/src/testing/index.ts +5 -0
  251. package/src/translations.ts +33 -7
  252. package/src/types/Notebook.ts +41 -0
  253. package/src/types/actions.ts +53 -0
  254. package/src/types/index.ts +3 -1
  255. package/src/types/types.ts +15 -0
  256. package/src/util/deploy.ts +27 -44
  257. package/src/util/functions.ts +36 -7
  258. package/dist/lib/browser/DeploymentDialog-M4QIHTDR.mjs +0 -12
  259. package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs +0 -262
  260. package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
  261. package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs.map +0 -7
  262. package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs +0 -247
  263. package/dist/lib/browser/artifact-definition-CK3BIBSI.mjs.map +0 -7
  264. package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
  265. package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
  266. package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
  267. package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
  268. package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
  269. package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
  270. package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
  271. package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
  272. package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
  273. package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
  274. package/dist/lib/browser/intent-resolver-S3H2SMUY.mjs.map +0 -7
  275. package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
  276. package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
  277. package/dist/lib/node-esm/DeploymentDialog-3KPRWFE7.mjs +0 -13
  278. package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs +0 -263
  279. package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
  280. package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs.map +0 -7
  281. package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs +0 -248
  282. package/dist/lib/node-esm/artifact-definition-YCBV4YX2.mjs.map +0 -7
  283. package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
  284. package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
  285. package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
  286. package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
  287. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
  288. package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
  289. package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
  290. package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
  291. package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
  292. package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
  293. package/dist/lib/node-esm/intent-resolver-OHKNJFCC.mjs.map +0 -7
  294. package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
  295. package/dist/lib/node-esm/settings-DXZ334A3.mjs.map +0 -7
  296. package/dist/types/src/templates/echo.d.ts.map +0 -1
  297. package/dist/types/src/types/schema.d.ts +0 -38
  298. package/dist/types/src/types/schema.d.ts.map +0 -1
  299. package/src/types/schema.ts +0 -37
  300. /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-E5NXT4UQ.mjs.map} +0 -0
  301. /package/dist/lib/{node-esm/DeploymentDialog-3KPRWFE7.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
  302. /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-UOQ6NCH3.mjs.map} +0 -0
  303. /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-55JZVM6K.mjs.map} +0 -0
  304. /package/src/templates/{echo.ts → ping.ts} +0 -0
@@ -5,15 +5,19 @@
5
5
  // @ts-ignore
6
6
  import { S, defineFunction } from 'dxos:functions';
7
7
  import {
8
+ FetchHttpClient,
8
9
  HttpClient,
9
10
  HttpClientRequest,
10
- FetchHttpClient,
11
11
  // @ts-ignore
12
- } from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.14.21&bundle=false';
12
+ } from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
13
+ // @ts-ignore
14
+ import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
13
15
  // @ts-ignore
14
- import { Effect, Schedule } from 'https://esm.sh/effect@3.14.21?bundle=false';
16
+ import * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?bundle=false';
15
17
 
16
18
  export default defineFunction({
19
+ key: 'dxos.org/script/forex-effect',
20
+ name: 'Forex Effect',
17
21
  description: 'Returns the exchange rate between two currencies.',
18
22
 
19
23
  inputSchema: S.Struct({
@@ -3,9 +3,11 @@
3
3
  //
4
4
 
5
5
  // @ts-ignore
6
- import { defineFunction, S } from 'dxos:functions';
6
+ import { S, defineFunction } from 'dxos:functions';
7
7
 
8
8
  export default defineFunction({
9
+ key: 'dxos.org/script/forex',
10
+ name: 'Forex',
9
11
  description: 'Returns the exchange rate between two currencies.',
10
12
 
11
13
  inputSchema: S.Struct({
@@ -3,20 +3,32 @@
3
3
  //
4
4
 
5
5
  // @ts-ignore
6
- import { create, defineFunction, EchoObject, Filter, ObjectId, S } from 'dxos:functions';
6
+ import { EchoObject, Filter, ObjectId, S, create, defineFunction } from 'dxos:functions';
7
7
  // @ts-ignore
8
8
  import {
9
+ FetchHttpClient,
9
10
  HttpClient,
10
11
  HttpClientRequest,
11
- FetchHttpClient,
12
12
  // @ts-ignore
13
- } from 'https://esm.sh/@effect/platform@0.77.2?deps=effect@3.14.21&bundle=false';
13
+ } from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
14
14
  // @ts-ignore
15
15
  import { format, subDays } from 'https://esm.sh/date-fns@3.3.1?bundle=false';
16
16
  // @ts-ignore
17
- import { pipe, Chunk, Effect, Ref, Schedule, Stream } from 'https://esm.sh/effect@3.14.21?bundle=false';
17
+ import * as Chunk from 'https://esm.sh/effect@3.17.0/Chunk?bundle=false';
18
+ // @ts-ignore
19
+ import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
20
+ // @ts-ignore
21
+ import * as Function from 'https://esm.sh/effect@3.17.0/Function?bundle=false';
22
+ // @ts-ignore
23
+ import * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';
24
+ // @ts-ignore
25
+ import * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?bundle=false';
26
+ // @ts-ignore
27
+ import * as Stream from 'https://esm.sh/effect@3.17.0/Stream?bundle=false';
18
28
 
19
29
  export default defineFunction({
30
+ key: 'dxos.org/script/gmail',
31
+ name: 'Gmail',
20
32
  inputSchema: S.Struct({
21
33
  mailboxId: S.String,
22
34
  userId: S.optional(S.String).pipe(S.withDecodingDefault(() => 'me')),
@@ -41,7 +53,7 @@ export default defineFunction({
41
53
 
42
54
  // NOTE: Google API bundles size is v. large and caused runtime issues.
43
55
  const makeRequest = (url: string) =>
44
- pipe(
56
+ Function.pipe(
45
57
  url,
46
58
  HttpClientRequest.get,
47
59
  HttpClientRequest.setHeaders({ Authorization: `Bearer ${token}`, Accept: 'application/json' }),
@@ -80,7 +92,7 @@ export default defineFunction({
80
92
  const messageDetails = yield* getMessage(userId, message.id);
81
93
  const created = new Date(parseInt(messageDetails.internalDate)).toISOString();
82
94
  const from = messageDetails.payload.headers.find((h: any) => h.name === 'From');
83
- const sender = from && parseEmailString(from.value);
95
+ const sender = from && parseFromHeader(from.value);
84
96
  // TODO(wittjosiah): Improve parsing of email contents.
85
97
  const content =
86
98
  messageDetails.payload.body?.data ??
@@ -98,7 +110,7 @@ export default defineFunction({
98
110
  sender,
99
111
  blocks: [
100
112
  {
101
- type: 'text',
113
+ _tag: 'text',
102
114
  text: Buffer.from(content, 'base64').toString('utf-8'),
103
115
  },
104
116
  ],
@@ -114,7 +126,7 @@ export default defineFunction({
114
126
 
115
127
  const queueMessages = yield* Ref.get(newMessages);
116
128
  if (queueMessages.length > 0) {
117
- yield* pipe(
129
+ yield* Function.pipe(
118
130
  queueMessages,
119
131
  Stream.fromIterable,
120
132
  Stream.grouped(10),
@@ -145,17 +157,17 @@ const getUrl = (userId: string, messageId?: string, params?: Record<string, any>
145
157
  /**
146
158
  * Parses an email string in the format "Name <email@example.com>" into separate name and email components.
147
159
  */
148
- const parseEmailString = (emailString: string): { name?: string; email: string } | undefined => {
149
- const match = emailString.match(/^([^<]+?)\s*<([^>]+@[^>]+)>$/);
160
+ const parseFromHeader = (value: string): { name?: string; email: string } | undefined => {
161
+ const EMAIL_REGEX = /^([^<]+?)\s*<([^>]+@[^>]+)>$/;
162
+ const removeOuterQuotes = (str: string) => str.replace(/^['"]|['"]$/g, '');
163
+ const match = value.match(EMAIL_REGEX);
150
164
  if (match) {
151
165
  const [, name, email] = match;
152
166
  return {
153
- name: name.trim(),
167
+ name: removeOuterQuotes(name.trim()),
154
168
  email: email.trim(),
155
169
  };
156
170
  }
157
-
158
- return undefined;
159
171
  };
160
172
 
161
173
  //
@@ -174,57 +186,16 @@ const ActorSchema = S.Struct({
174
186
  role: S.optional(ActorRole),
175
187
  });
176
188
 
177
- const AbstractContentBlock = S.Struct({
189
+ const Base = S.Struct({
178
190
  pending: S.optional(S.Boolean),
179
191
  });
180
- type AbstractContentBlock = S.Schema.Type<typeof AbstractContentBlock>;
181
- const TextContentBlock = S.extend(
182
- AbstractContentBlock,
183
- S.Struct({
184
- type: S.Literal('text'),
185
- disposition: S.optional(S.String),
186
- text: S.String,
187
- }),
188
- ).pipe(S.mutable);
189
- type TextContentBlock = S.Schema.Type<typeof TextContentBlock>;
190
- const JsonContentBlock = S.extend(
191
- AbstractContentBlock,
192
- S.Struct({
193
- type: S.Literal('json'),
194
- disposition: S.optional(S.String),
195
- data: S.String,
196
- }),
197
- ).pipe(S.mutable);
198
- type JsonContentBlock = S.Schema.Type<typeof JsonContentBlock>;
199
- const Base64ImageSource = S.Struct({
200
- type: S.Literal('base64'),
201
- mediaType: S.String,
202
- data: S.String,
192
+ type Base = S.Schema.Type<typeof Base>;
193
+ const Text = S.TaggedStruct('text', {
194
+ mimeType: S.optional(S.String),
195
+ text: S.String,
196
+ ...Base.fields,
203
197
  }).pipe(S.mutable);
204
- const HttpImageSource = S.Struct({
205
- type: S.Literal('http'),
206
- url: S.String,
207
- }).pipe(S.mutable);
208
- const ImageSource = S.Union(Base64ImageSource, HttpImageSource);
209
- type ImageSource = S.Schema.Type<typeof ImageSource>;
210
- const ImageContentBlock = S.extend(
211
- AbstractContentBlock,
212
- S.Struct({
213
- type: S.Literal('image'),
214
- id: S.optional(S.String),
215
- source: S.optional(ImageSource),
216
- }),
217
- ).pipe(S.mutable);
218
- type ImageContentBlock = S.Schema.Type<typeof ImageContentBlock>;
219
- const ReferenceContentBlock = S.extend(
220
- AbstractContentBlock,
221
- S.Struct({
222
- type: S.Literal('reference'),
223
- reference: S.Any,
224
- }),
225
- ).pipe(S.mutable);
226
- type ReferenceContentBlock = S.Schema.Type<typeof ReferenceContentBlock>;
227
- const MessageContentBlock = S.Union(TextContentBlock, JsonContentBlock, ImageContentBlock, ReferenceContentBlock);
198
+ interface Text extends S.Schema.Type<typeof Text> {}
228
199
 
229
200
  const MessageType = S.Struct({
230
201
  id: ObjectId,
@@ -234,7 +205,7 @@ const MessageType = S.Struct({
234
205
  sender: ActorSchema.annotations({
235
206
  description: 'Identity of the message sender.',
236
207
  }),
237
- blocks: S.Array(MessageContentBlock).annotations({
208
+ blocks: S.Array(Text).annotations({
238
209
  description: 'Contents of the message.',
239
210
  }),
240
211
  properties: S.optional(
@@ -6,11 +6,11 @@ import chat from './chat.ts?raw';
6
6
  import chess from './chess.ts?raw';
7
7
  import dataGenerator from './data-generator.ts?raw';
8
8
  import discord from './discord.ts?raw';
9
- import echo from './echo.ts?raw';
10
9
  import email from './email.ts?raw';
11
10
  import forexEffect from './forex-effect.ts?raw';
12
11
  import forex from './forex.ts?raw';
13
12
  import gmail from './gmail.ts?raw';
13
+ import ping from './ping.ts?raw';
14
14
 
15
15
  const removeHeader = (str: string) => str.split('\n').slice(4).join('\n');
16
16
 
@@ -23,11 +23,11 @@ export type Template = {
23
23
  presetId?: string;
24
24
  };
25
25
 
26
- export const templates: Template[] = [
26
+ export const templates = [
27
27
  {
28
- id: 'dxos.org/script/echo',
29
- name: 'Echo',
30
- source: removeHeader(echo),
28
+ id: 'dxos.org/script/ping',
29
+ name: 'Ping',
30
+ source: removeHeader(ping),
31
31
  },
32
32
  {
33
33
  id: 'dxos.org/script/forex',
@@ -75,4 +75,4 @@ export const templates: Template[] = [
75
75
  source: removeHeader(dataGenerator),
76
76
  presetId: 'dxos.org/function/data-generator',
77
77
  },
78
- ];
78
+ ] as const;
@@ -0,0 +1,72 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Prompt } from '@dxos/blueprints';
6
+ import { Ref } from '@dxos/echo';
7
+ import { createObject } from '@dxos/echo-db';
8
+ import { PublicKey } from '@dxos/keys';
9
+ import { Markdown } from '@dxos/plugin-markdown/types';
10
+ import { DataType } from '@dxos/schema';
11
+
12
+ import { Notebook } from '../types';
13
+
14
+ // TODO(burdon): NOTE: createObject is required for tests.
15
+
16
+ export const createNotebook = (): Notebook.Notebook =>
17
+ Notebook.make({
18
+ cells: [
19
+ {
20
+ id: PublicKey.random().toString(),
21
+ type: 'script',
22
+ source: Ref.make(createObject(DataType.makeText('c = a() + b'))),
23
+ },
24
+ {
25
+ id: PublicKey.random().toString(),
26
+ type: 'script',
27
+ source: Ref.make(createObject(DataType.makeText('a = () => 100'))),
28
+ },
29
+ {
30
+ id: PublicKey.random().toString(),
31
+ type: 'script',
32
+ source: Ref.make(createObject(DataType.makeText('b = 200'))),
33
+ },
34
+ {
35
+ id: PublicKey.random().toString(),
36
+ type: 'script',
37
+ source: Ref.make(createObject(DataType.makeText('d = a() * 2'))),
38
+ },
39
+ {
40
+ id: PublicKey.random().toString(),
41
+ type: 'script',
42
+ source: Ref.make(createObject(DataType.makeText('c + d'))),
43
+ },
44
+ {
45
+ id: PublicKey.random().toString(),
46
+ type: 'prompt',
47
+ prompt: Ref.make(
48
+ createObject(
49
+ Prompt.make({
50
+ instructions: 'Very briefly, what colors are associated with the numbers {{a}} and {{b}}.',
51
+ }),
52
+ ),
53
+ ),
54
+ },
55
+ {
56
+ id: PublicKey.random().toString(),
57
+ type: 'query',
58
+ source: Ref.make(createObject(DataType.makeText(`docs = (type: ${Markdown.Document.typename})`))),
59
+ },
60
+ {
61
+ id: PublicKey.random().toString(),
62
+ type: 'prompt',
63
+ prompt: Ref.make(
64
+ createObject(
65
+ Prompt.make({
66
+ instructions: 'Very briefly, summarize the documents: {{docs}}',
67
+ }),
68
+ ),
69
+ ),
70
+ },
71
+ ],
72
+ });
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './data';
@@ -2,15 +2,16 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { ScriptType } from '@dxos/functions';
5
+ import { Script } from '@dxos/functions';
6
6
  import { type Resource } from '@dxos/react-ui';
7
7
 
8
8
  import { meta } from './meta';
9
+ import { Notebook } from './types';
9
10
 
10
11
  export const translations = [
11
12
  {
12
13
  'en-US': {
13
- [ScriptType.typename]: {
14
+ [Script.Script.typename]: {
14
15
  'typename label': 'Script',
15
16
  'typename label_zero': 'Scripts',
16
17
  'typename label_one': 'Script',
@@ -19,8 +20,18 @@ export const translations = [
19
20
  'rename object label': 'Rename script',
20
21
  'delete object label': 'Delete script',
21
22
  },
23
+ [Notebook.Notebook.typename]: {
24
+ 'typename label': 'Notebook',
25
+ 'typename label_zero': 'Notebooks',
26
+ 'typename label_one': 'Notebook',
27
+ 'typename label_other': 'Notebooks',
28
+ 'object name placeholder': 'New notebook',
29
+ 'rename object label': 'Rename notebook',
30
+ 'delete object label': 'Delete notebook',
31
+ },
22
32
  [meta.id]: {
23
33
  'plugin name': 'Scripts',
34
+ 'settings title': 'Scripts plugin settings',
24
35
  'description label': 'Description',
25
36
  'description placeholder': 'Enter description',
26
37
  'binding placeholder': 'Function name',
@@ -44,25 +55,29 @@ export const translations = [
44
55
  'open token manager label': 'Open Token Manager',
45
56
  'publish label': 'Publish',
46
57
  'publishing label': 'Publishing',
58
+ 'blueprint editor label': 'Blueprint',
59
+ 'blueprint editor description': 'Create a blueprint that exposes this script as a tool.',
60
+ 'blueprint instructions label': 'Instructions',
61
+ 'blueprint instructions placeholder': 'Describe how this tool should be used.',
62
+ 'create blueprint label': 'Create blueprint',
63
+ 'creating label': 'Creating…',
47
64
  'editor input mode label': 'Editor input mode',
48
65
  'select editor input mode placeholder': 'Select editor input mode…',
49
66
  'settings editor input mode default label': 'Default',
50
67
  'settings editor input mode vim label': 'Vim',
51
68
  'settings editor input mode vscode label': 'VS Code',
52
- 'template select group label': 'Select template',
53
69
  'function panel label': 'Debug Function',
54
70
  'script test label': 'Test',
55
71
  'script logs label': 'Logs',
72
+
56
73
  'deployment dialog title': 'Default Scripts',
57
- 'deployment dialog scripts found message_one':
58
- 'We found the following script template for your new integration:',
59
- 'deployment dialog scripts found message_other':
60
- 'We found the following script templates for your new integration:',
74
+ 'deployment dialog scripts found message': 'Script templates:',
61
75
  'deployment dialog deploy functions button label_one': 'Create and deploy script',
62
76
  'deployment dialog deploy functions button label_other': 'Create and deploy scripts',
63
77
  'deployment dialog deploy functions pending button label_one': 'Deploying script',
64
78
  'deployment dialog deploy functions pending button label_other': 'Deploying scripts',
65
79
  'deployment dialog skip button label': 'Skip',
80
+
66
81
  'script deployment toast label_one': 'Script deployed',
67
82
  'script deployment toast label_other': 'Scripts deployed',
68
83
  'script deployment toast description_one': 'Your script has been deployed successfully.',
@@ -75,6 +90,17 @@ export const translations = [
75
90
  'script deployment error toast description_other': 'There was an error deploying your scripts.',
76
91
  'script deployment error toast close label_one': 'Close',
77
92
  'script deployment error toast close label_other': 'Close',
93
+
94
+ 'notebook cell placeholder': 'Enter script',
95
+ 'notebook cell delete label': 'Delete cell',
96
+ 'notebook cell prompt run label': 'Run',
97
+ 'notebook cell insert markdown label': 'Insert Markdown',
98
+ 'notebook cell insert script label': 'Insert Script',
99
+ 'notebook cell insert prompt label': 'Insert Prompt',
100
+ 'notebook cell insert query label': 'Insert Query',
101
+ 'notebook markdown placeholder': 'Enter Markdown',
102
+ 'notebook prompt placeholder': 'Enter prompt',
103
+ 'notebook cell insert label': 'Insert cell',
78
104
  },
79
105
  },
80
106
  },
@@ -0,0 +1,41 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { Prompt } from '@dxos/blueprints';
8
+ import { Obj, Type } from '@dxos/echo';
9
+ import { FormAnnotation } from '@dxos/echo/internal';
10
+ import { LabelAnnotation } from '@dxos/echo/internal';
11
+ import { DataType } from '@dxos/schema';
12
+
13
+ export type CellType = 'markdown' | 'script' | 'query' | 'prompt' | 'view';
14
+
15
+ const Cell_ = Schema.Struct({
16
+ id: Schema.String,
17
+ type: Schema.String,
18
+ name: Schema.optional(Schema.String),
19
+ // TODO(burdon): Union type.
20
+ source: Schema.optional(Type.Ref(DataType.Text)),
21
+ prompt: Schema.optional(Type.Ref(Prompt.Prompt)),
22
+ view: Schema.optional(Type.Ref(DataType.View)),
23
+ }).pipe(Schema.mutable);
24
+ export interface Cell extends Schema.Schema.Type<typeof Cell_> {}
25
+ export interface Cell_Encoded extends Schema.Schema.Encoded<typeof Cell_> {}
26
+ export const Cell: Schema.Schema<Cell, Cell_Encoded> = Cell_;
27
+
28
+ export const Notebook = Schema.Struct({
29
+ name: Schema.String.pipe(Schema.optional),
30
+ cells: Cell.pipe(Schema.Array, Schema.mutable, FormAnnotation.set(false)),
31
+ }).pipe(
32
+ Type.Obj({
33
+ typename: 'dxos.org/type/Notebook',
34
+ version: '0.1.0',
35
+ }),
36
+ LabelAnnotation.set(['name']),
37
+ );
38
+
39
+ export type Notebook = Schema.Schema.Type<typeof Notebook>;
40
+
41
+ export const make = (props: Obj.MakeProps<typeof Notebook> = { cells: [] }) => Obj.make(Notebook, props);
@@ -0,0 +1,53 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { SpaceSchema } from '@dxos/client/echo';
8
+ import { Script } from '@dxos/functions';
9
+
10
+ import { meta } from '../meta';
11
+ import { templates } from '../templates';
12
+
13
+ import * as Notebook from './Notebook';
14
+
15
+ export namespace ScriptAction {
16
+ export const ScriptProps = Schema.Struct({
17
+ name: Schema.optional(Schema.String),
18
+ // TODO(wittjosiah): Placeholder annotation?
19
+ gistUrl: Schema.optional(Schema.String.annotations({ title: 'Import from Gist (url)' })),
20
+ initialTemplateId: Schema.Literal(...templates.map(({ id }) => id)).pipe(
21
+ Schema.annotations({ title: 'Template' }),
22
+ Schema.optional,
23
+ ),
24
+ });
25
+
26
+ export class CreateScript extends Schema.TaggedClass<CreateScript>()(`${meta.id}/action/create-script`, {
27
+ input: Schema.extend(
28
+ ScriptProps,
29
+ Schema.Struct({
30
+ space: SpaceSchema,
31
+ }),
32
+ ),
33
+ output: Schema.Struct({
34
+ object: Script.Script,
35
+ }),
36
+ }) {}
37
+
38
+ export const NotebookProps = Schema.Struct({
39
+ name: Schema.optional(Schema.String),
40
+ });
41
+
42
+ export class CreateNotebook extends Schema.TaggedClass<CreateNotebook>()(`${meta.id}/action/create-notebook`, {
43
+ input: Schema.extend(
44
+ NotebookProps,
45
+ Schema.Struct({
46
+ space: SpaceSchema,
47
+ }),
48
+ ),
49
+ output: Schema.Struct({
50
+ object: Notebook.Notebook,
51
+ }),
52
+ }) {}
53
+ }
@@ -2,4 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './schema';
5
+ export * from './actions';
6
+ export * as Notebook from './Notebook';
7
+ export * from './types';
@@ -0,0 +1,15 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import * as Schema from 'effect/Schema';
6
+
7
+ import { EditorInputMode } from '@dxos/react-ui-editor';
8
+
9
+ export const ScriptSettings = Schema.mutable(
10
+ Schema.Struct({
11
+ editorInputMode: EditorInputMode,
12
+ }),
13
+ );
14
+
15
+ export type ScriptSettings = Schema.Schema.Type<typeof ScriptSettings>;
@@ -4,34 +4,29 @@
4
4
 
5
5
  import { type Client } from '@dxos/client';
6
6
  import { Obj, Ref } from '@dxos/echo';
7
- import {
8
- FunctionType,
9
- type ScriptType,
10
- getUserFunctionUrlInMetadata,
11
- makeFunctionUrl,
12
- setUserFunctionUrlInMetadata,
13
- } from '@dxos/functions';
7
+ import { Function, type Script, getUserFunctionIdInMetadata, setUserFunctionIdInMetadata } from '@dxos/functions';
14
8
  import { Bundler } from '@dxos/functions/bundler';
15
9
  import { incrementSemverPatch, uploadWorkerFunction } from '@dxos/functions/edge';
16
10
  import { log } from '@dxos/log';
17
11
  import { type Space } from '@dxos/react-client/echo';
12
+ import { isNode } from '@dxos/util';
18
13
 
19
14
  import { updateFunctionMetadata } from './functions';
20
15
 
21
- export const isScriptDeployed = ({ script, fn }: { script: ScriptType; fn: any }): boolean => {
22
- const existingFunctionUrl = fn && getUserFunctionUrlInMetadata(Obj.getMeta(fn));
23
- return Boolean(existingFunctionUrl) && !script.changed;
16
+ export const isScriptDeployed = ({ script, fn }: { script: Script.Script; fn: any }): boolean => {
17
+ const existingFunctionId = fn && getUserFunctionIdInMetadata(Obj.getMeta(fn));
18
+ return Boolean(existingFunctionId) && !script.changed;
24
19
  };
25
20
 
26
21
  type DeployScriptProps = {
27
- script: ScriptType;
22
+ script: Script.Script;
28
23
  client: Client;
29
24
  space: Space;
30
- fn?: FunctionType;
31
- existingFunctionUrl?: string;
25
+ fn?: Function.Function;
26
+ existingFunctionId?: string;
32
27
  };
33
28
 
34
- type DeployScriptResult = { success: boolean; error?: Error; functionUrl?: string };
29
+ type DeployScriptResult = { success: boolean; error?: Error; functionId?: string };
35
30
 
36
31
  /**
37
32
  * Deploy a script to a space, handling bundling and uploading to the FaaS infrastructure.
@@ -41,7 +36,7 @@ export const deployScript = async ({
41
36
  client,
42
37
  space,
43
38
  fn,
44
- existingFunctionUrl,
39
+ existingFunctionId,
45
40
  }: DeployScriptProps): Promise<DeployScriptResult> => {
46
41
  const validationError = validateDeployInputs(script, space);
47
42
  if (validationError) {
@@ -49,11 +44,10 @@ export const deployScript = async ({
49
44
  }
50
45
 
51
46
  try {
52
- const existingFunctionId = extractFunctionId(existingFunctionUrl);
53
-
54
- const { bundle, error } = await bundleScript(script.source!.target!.content);
55
- if (error || !bundle) {
56
- throw error || new Error('Bundle creation failed');
47
+ const bundler = new Bundler({ platform: isNode() ? 'node' : 'browser', sandboxedModules: [], remoteModules: {} });
48
+ const buildResult = await bundler.bundle({ source: script.source!.target!.content });
49
+ if ('error' in buildResult) {
50
+ throw buildResult.error || new Error('Bundle creation failed');
57
51
  }
58
52
 
59
53
  const { functionId, version, meta } = await uploadWorkerFunction({
@@ -61,7 +55,8 @@ export const deployScript = async ({
61
55
  ownerPublicKey: space.key,
62
56
  version: fn ? incrementSemverPatch(fn.version) : '0.0.1',
63
57
  functionId: existingFunctionId,
64
- source: bundle,
58
+ entryPoint: buildResult.entryPoint,
59
+ assets: { [buildResult.entryPoint]: buildResult.asset },
65
60
  });
66
61
 
67
62
  if (functionId === undefined || version === undefined) {
@@ -72,10 +67,9 @@ export const deployScript = async ({
72
67
  script.changed = false;
73
68
  updateFunctionMetadata(script, storedFunction, meta, functionId);
74
69
 
75
- const functionUrl = makeFunctionUrl({ functionId });
76
- setUserFunctionUrlInMetadata(Obj.getMeta(storedFunction), functionUrl);
70
+ setUserFunctionIdInMetadata(Obj.getMeta(storedFunction), functionId);
77
71
 
78
- return { success: true, functionUrl };
72
+ return { success: true, functionId };
79
73
  } catch (err: any) {
80
74
  log.catch(err);
81
75
  return { success: false, error: err };
@@ -85,39 +79,28 @@ export const deployScript = async ({
85
79
  /**
86
80
  * Validate inputs for script deployment.
87
81
  */
88
- const validateDeployInputs = (script: ScriptType, space: Space): Error | null => {
82
+ const validateDeployInputs = (script: Script.Script, space: Space): Error | null => {
89
83
  if (!script.source || !space) {
90
84
  return new Error('Script source or space not available');
91
85
  }
92
86
  return null;
93
87
  };
94
88
 
95
- const extractFunctionId = (functionUrl?: string): string | undefined => {
96
- return functionUrl?.split('/').at(-1);
97
- };
98
-
99
- const bundleScript = async (source: string): Promise<{ bundle?: string; error?: Error }> => {
100
- const bundler = new Bundler({ platform: 'browser', sandboxedModules: [], remoteModules: {} });
101
- const buildResult = await bundler.bundle({ source });
102
-
103
- if (buildResult.error || !buildResult.bundle) {
104
- return { error: buildResult.error || new Error('Bundle creation failed') };
105
- }
106
-
107
- return { bundle: buildResult.bundle };
108
- };
109
-
110
89
  const createOrUpdateFunctionInSpace = (
111
90
  space: Space,
112
- fn: FunctionType | undefined,
113
- script: ScriptType,
91
+ fn: Function.Function | undefined,
92
+ script: Script.Script,
114
93
  functionId: string,
115
94
  version: string,
116
- ): FunctionType => {
95
+ ): Function.Function => {
117
96
  if (fn) {
97
+ fn.name = script.name ?? 'New Function';
118
98
  fn.version = version;
119
99
  return fn;
120
100
  } else {
121
- return space.db.add(Obj.make(FunctionType, { name: functionId, version, source: Ref.make(script) }));
101
+ const fn = Function.make({ name: script.name ?? 'New Function', version, source: Ref.make(script) });
102
+ space.db.add(fn);
103
+ setUserFunctionIdInMetadata(Obj.getMeta(fn), functionId);
104
+ return fn;
122
105
  }
123
106
  };