@dxos/plugin-script 0.8.4-main.2e9d522 → 0.8.4-main.548089c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/DeploymentDialog-MZX4T77L.mjs +14 -0
- package/dist/lib/browser/NotebookContainer-S6GUYCUE.mjs +817 -0
- package/dist/lib/browser/NotebookContainer-S6GUYCUE.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-3JQSTDFZ.mjs +147 -0
- package/dist/lib/browser/ScriptContainer-3JQSTDFZ.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-HLQ7K3BT.mjs → app-graph-builder-2WR2ATTJ.mjs} +12 -10
- package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +30 -0
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +7 -0
- package/dist/lib/browser/chunk-2G2NA6DQ.mjs +88 -0
- package/dist/lib/browser/chunk-2G2NA6DQ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-P4HQKUCP.mjs → chunk-3IJASGG5.mjs} +23 -21
- package/dist/lib/browser/chunk-3IJASGG5.mjs.map +7 -0
- package/dist/lib/browser/chunk-5JSNQYZZ.mjs +517 -0
- package/dist/lib/browser/chunk-5JSNQYZZ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EB6AXFXO.mjs} +8 -5
- package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/{chunk-FIM2MVNJ.mjs → chunk-JRF6FHYQ.mjs} +179 -88
- package/dist/lib/browser/chunk-JRF6FHYQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-LNNCD2H4.mjs +102 -0
- package/dist/lib/browser/chunk-LNNCD2H4.mjs.map +7 -0
- package/dist/lib/browser/chunk-M6KJPUJK.mjs +111 -0
- package/dist/lib/browser/chunk-M6KJPUJK.mjs.map +7 -0
- package/dist/lib/browser/chunk-RXLF2X2R.mjs +304 -0
- package/dist/lib/browser/chunk-RXLF2X2R.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-UOQ6NCH3.mjs} +2 -2
- package/dist/lib/browser/{compiler-CXCUA4UQ.mjs → compiler-4KHRSX7J.mjs} +10 -6
- package/dist/lib/browser/compiler-4KHRSX7J.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +108 -44
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-7B77IG3N.mjs → intent-resolver-PUMSYKVB.mjs} +39 -26
- package/dist/lib/browser/intent-resolver-PUMSYKVB.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FYYXZA7C.mjs → react-surface-DLRMWFTN.mjs} +45 -21
- package/dist/lib/browser/react-surface-DLRMWFTN.mjs.map +7 -0
- package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-LNLSTZM4.mjs} +10 -8
- package/dist/lib/browser/settings-LNLSTZM4.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +2 -1
- package/dist/lib/browser/types/index.mjs +8 -4
- package/dist/lib/node-esm/DeploymentDialog-GL5AUWMR.mjs +15 -0
- package/dist/lib/node-esm/DeploymentDialog-GL5AUWMR.mjs.map +7 -0
- package/dist/lib/node-esm/NotebookContainer-RTUHQN25.mjs +818 -0
- package/dist/lib/node-esm/NotebookContainer-RTUHQN25.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-SSLISMLS.mjs +148 -0
- package/dist/lib/node-esm/ScriptContainer-SSLISMLS.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-7EYIHWH4.mjs → app-graph-builder-NCVLUL5R.mjs} +12 -10
- package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +31 -0
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-55JZVM6K.mjs} +2 -2
- package/dist/lib/node-esm/chunk-57JA6XL5.mjs +90 -0
- package/dist/lib/node-esm/chunk-57JA6XL5.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7NMI4CEU.mjs → chunk-ASPYIAYG.mjs} +179 -88
- package/dist/lib/node-esm/chunk-ASPYIAYG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HDKR5WCD.mjs +113 -0
- package/dist/lib/node-esm/chunk-HDKR5WCD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-IBV2DR36.mjs} +8 -5
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IQTBVH4L.mjs +518 -0
- package/dist/lib/node-esm/chunk-IQTBVH4L.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NNHWLRHT.mjs +103 -0
- package/dist/lib/node-esm/chunk-NNHWLRHT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Q5XB7DD4.mjs +305 -0
- package/dist/lib/node-esm/chunk-Q5XB7DD4.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QKK3NDHW.mjs → chunk-RIE676OW.mjs} +23 -21
- package/dist/lib/node-esm/chunk-RIE676OW.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-EPFKQXPE.mjs → compiler-DU5NQISX.mjs} +10 -6
- package/dist/lib/node-esm/compiler-DU5NQISX.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +108 -44
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-FRZGS4TB.mjs → intent-resolver-JK7J6JQB.mjs} +39 -26
- package/dist/lib/node-esm/intent-resolver-JK7J6JQB.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-V32NWHKN.mjs → react-surface-BPQLLTT4.mjs} +45 -21
- package/dist/lib/node-esm/react-surface-BPQLLTT4.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-IUFMOCXY.mjs} +10 -8
- package/dist/lib/node-esm/settings-IUFMOCXY.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +2 -1
- package/dist/lib/node-esm/types/index.mjs +8 -4
- package/dist/types/src/ScriptPlugin.d.ts +1 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +1 -1
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +4 -4
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +243 -13
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +10 -0
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts +251 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +15 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +9 -0
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +14 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +245 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/index.d.ts +3 -0
- package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptContainer.d.ts +4 -4
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +5 -6
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +242 -10
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +2 -2
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +2 -2
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +2 -2
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +11 -4
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/hooks/deploy.d.ts +18 -16
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -2
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +4 -14
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +45 -0
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts +2 -0
- package/dist/types/src/notebook/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/notebook/eval.d.ts +13 -0
- package/dist/types/src/notebook/eval.d.ts.map +1 -0
- package/dist/types/src/notebook/index.d.ts +2 -0
- package/dist/types/src/notebook/index.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
- package/dist/types/src/templates/chess.d.ts.map +1 -1
- package/dist/types/src/templates/data-generator.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts.map +1 -1
- package/dist/types/src/templates/gmail.d.ts.map +1 -1
- package/dist/types/src/templates/index.d.ts +43 -1
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/{echo.d.ts → ping.d.ts} +1 -1
- package/dist/types/src/templates/ping.d.ts.map +1 -0
- package/dist/types/src/testing/data.d.ts +3 -0
- package/dist/types/src/testing/data.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +30 -5
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +31 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/actions.d.ts +54 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +6 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +7 -7
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +6 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +82 -70
- package/src/ScriptPlugin.tsx +90 -71
- package/src/capabilities/app-graph-builder.ts +12 -11
- package/src/capabilities/artifact-definition.ts +8 -13
- package/src/capabilities/blueprint-definition.ts +30 -0
- package/src/capabilities/compiler.ts +3 -2
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +21 -15
- package/src/capabilities/react-surface.tsx +33 -19
- package/src/capabilities/settings.ts +3 -3
- package/src/compiler/compiler.ts +1 -1
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +39 -20
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +45 -34
- package/src/components/DeploymentDialog/index.ts +1 -1
- package/src/components/FrameContainer/FrameContainer.tsx +4 -3
- package/src/components/NotebookContainer.stories.tsx +83 -0
- package/src/components/NotebookContainer.tsx +263 -0
- package/src/components/NotebookStack/NotebookCell.tsx +214 -0
- package/src/components/NotebookStack/NotebookMenu.tsx +47 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +54 -0
- package/src/components/NotebookStack/NotebookStack.tsx +86 -0
- package/src/components/NotebookStack/index.ts +6 -0
- package/src/components/ScriptContainer.tsx +7 -6
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +34 -17
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +36 -29
- package/src/components/Settings/ScriptObjectSettings.tsx +127 -36
- package/src/components/Settings/ScriptPluginSettings.tsx +37 -47
- package/src/components/TestPanel/TestContainer.tsx +4 -3
- package/src/components/TestPanel/TestPanel.tsx +42 -19
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +79 -31
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +37 -35
- package/src/components/index.ts +3 -0
- package/src/events.ts +2 -2
- package/src/hooks/deploy.ts +23 -24
- package/src/hooks/format.ts +4 -4
- package/src/hooks/template.ts +6 -15
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +11 -6
- package/src/index.ts +1 -0
- package/src/meta.ts +7 -5
- package/src/notebook/compute-graph.test.ts +70 -0
- package/src/notebook/compute-graph.ts +206 -0
- package/src/notebook/eval.ts +105 -0
- package/src/notebook/index.ts +5 -0
- package/src/notebook/vfs-parser.test.ts +149 -0
- package/src/notebook/vfs-parser.ts +451 -0
- package/src/templates/chess.ts +3 -1
- package/src/templates/data-generator.ts +9 -3
- package/src/templates/discord.ts +12 -4
- package/src/templates/forex-effect.ts +7 -3
- package/src/templates/forex.ts +3 -1
- package/src/templates/gmail.ts +34 -64
- package/src/templates/index.ts +6 -6
- package/src/testing/data.ts +72 -0
- package/src/testing/index.ts +5 -0
- package/src/translations.ts +33 -7
- package/src/types/Notebook.ts +41 -0
- package/src/types/actions.ts +53 -0
- package/src/types/index.ts +3 -1
- package/src/types/types.ts +15 -0
- package/src/util/deploy.ts +29 -46
- package/src/util/functions.ts +37 -7
- package/dist/lib/browser/DeploymentDialog-M4QIHTDR.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs +0 -262
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-24Q3IHOU.mjs +0 -249
- package/dist/lib/browser/artifact-definition-24Q3IHOU.mjs.map +0 -7
- package/dist/lib/browser/chunk-3U6DTUH3.mjs +0 -283
- package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
- package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMDXKOP7.mjs +0 -233
- package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
- package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
- package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
- package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
- package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
- package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
- package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
- package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-7B77IG3N.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
- package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
- package/dist/lib/node-esm/DeploymentDialog-3KPRWFE7.mjs +0 -13
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs +0 -263
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-WAJFALUI.mjs +0 -250
- package/dist/lib/node-esm/artifact-definition-WAJFALUI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RT43MACC.mjs +0 -284
- package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XJPK3IYI.mjs +0 -234
- package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-FRZGS4TB.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
- package/dist/lib/node-esm/settings-DXZ334A3.mjs.map +0 -7
- package/dist/types/src/templates/echo.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -38
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/types/schema.ts +0 -37
- /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-MZX4T77L.mjs.map} +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-3KPRWFE7.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-UOQ6NCH3.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-55JZVM6K.mjs.map} +0 -0
- /package/src/templates/{echo.ts → ping.ts} +0 -0
package/src/templates/gmail.ts
CHANGED
|
@@ -3,20 +3,32 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
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.
|
|
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
|
|
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 &&
|
|
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
|
-
|
|
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
|
|
149
|
-
const
|
|
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
|
//
|
|
@@ -163,8 +175,7 @@ const parseEmailString = (emailString: string): { name?: string; email: string }
|
|
|
163
175
|
// TODO(wittjosiah): These schemas should be imported from @dxos/schema.
|
|
164
176
|
//
|
|
165
177
|
|
|
166
|
-
const
|
|
167
|
-
const ActorRole = S.Literal(...ActorRoles);
|
|
178
|
+
const ActorRole = S.Literal('user', 'assistant');
|
|
168
179
|
type ActorRole = S.Schema.Type<typeof ActorRole>;
|
|
169
180
|
|
|
170
181
|
const ActorSchema = S.Struct({
|
|
@@ -174,57 +185,16 @@ const ActorSchema = S.Struct({
|
|
|
174
185
|
role: S.optional(ActorRole),
|
|
175
186
|
});
|
|
176
187
|
|
|
177
|
-
const
|
|
188
|
+
const Base = S.Struct({
|
|
178
189
|
pending: S.optional(S.Boolean),
|
|
179
190
|
});
|
|
180
|
-
type
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
S.
|
|
184
|
-
|
|
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,
|
|
191
|
+
type Base = S.Schema.Type<typeof Base>;
|
|
192
|
+
const Text = S.TaggedStruct('text', {
|
|
193
|
+
mimeType: S.optional(S.String),
|
|
194
|
+
text: S.String,
|
|
195
|
+
...Base.fields,
|
|
203
196
|
}).pipe(S.mutable);
|
|
204
|
-
|
|
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);
|
|
197
|
+
interface Text extends S.Schema.Type<typeof Text> {}
|
|
228
198
|
|
|
229
199
|
const MessageType = S.Struct({
|
|
230
200
|
id: ObjectId,
|
|
@@ -234,7 +204,7 @@ const MessageType = S.Struct({
|
|
|
234
204
|
sender: ActorSchema.annotations({
|
|
235
205
|
description: 'Identity of the message sender.',
|
|
236
206
|
}),
|
|
237
|
-
blocks: S.Array(
|
|
207
|
+
blocks: S.Array(Text).annotations({
|
|
238
208
|
description: 'Contents of the message.',
|
|
239
209
|
}),
|
|
240
210
|
properties: S.optional(
|
package/src/templates/index.ts
CHANGED
|
@@ -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
|
|
26
|
+
export const templates = [
|
|
27
27
|
{
|
|
28
|
-
id: 'dxos.org/script/
|
|
29
|
-
name: '
|
|
30
|
-
source: removeHeader(
|
|
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 { Text } 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(Text.make('c = a() + b'))),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: PublicKey.random().toString(),
|
|
26
|
+
type: 'script',
|
|
27
|
+
source: Ref.make(createObject(Text.make('a = () => 100'))),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: PublicKey.random().toString(),
|
|
31
|
+
type: 'script',
|
|
32
|
+
source: Ref.make(createObject(Text.make('b = 200'))),
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: PublicKey.random().toString(),
|
|
36
|
+
type: 'script',
|
|
37
|
+
source: Ref.make(createObject(Text.make('d = a() * 2'))),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: PublicKey.random().toString(),
|
|
41
|
+
type: 'script',
|
|
42
|
+
source: Ref.make(createObject(Text.make('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(Text.make(`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
|
+
});
|
package/src/translations.ts
CHANGED
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
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
|
-
[
|
|
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
|
|
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 { Text, View } 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(Text.Text)),
|
|
21
|
+
prompt: Schema.optional(Type.Ref(Prompt.Prompt)),
|
|
22
|
+
view: Schema.optional(Type.Ref(View.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
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -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>;
|
package/src/util/deploy.ts
CHANGED
|
@@ -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
|
-
|
|
9
|
-
|
|
10
|
-
getUserFunctionUrlInMetadata,
|
|
11
|
-
makeFunctionUrl,
|
|
12
|
-
setUserFunctionUrlInMetadata,
|
|
13
|
-
} from '@dxos/functions';
|
|
14
|
-
import { Bundler } from '@dxos/functions/bundler';
|
|
15
|
-
import { incrementSemverPatch, uploadWorkerFunction } from '@dxos/functions/edge';
|
|
7
|
+
import { Function, type Script, getUserFunctionIdInMetadata, setUserFunctionIdInMetadata } from '@dxos/functions';
|
|
8
|
+
import { Bundler } from '@dxos/functions-runtime/bundler';
|
|
9
|
+
import { incrementSemverPatch, uploadWorkerFunction } from '@dxos/functions-runtime/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:
|
|
22
|
-
const
|
|
23
|
-
return Boolean(
|
|
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:
|
|
22
|
+
script: Script.Script;
|
|
28
23
|
client: Client;
|
|
29
24
|
space: Space;
|
|
30
|
-
fn?:
|
|
31
|
-
|
|
25
|
+
fn?: Function.Function;
|
|
26
|
+
existingFunctionId?: string;
|
|
32
27
|
};
|
|
33
28
|
|
|
34
|
-
type DeployScriptResult = { success: boolean; error?: Error;
|
|
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
|
-
|
|
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
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
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
|
-
|
|
76
|
-
setUserFunctionUrlInMetadata(Obj.getMeta(storedFunction), functionUrl);
|
|
70
|
+
setUserFunctionIdInMetadata(Obj.getMeta(storedFunction), functionId);
|
|
77
71
|
|
|
78
|
-
return { success: true,
|
|
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:
|
|
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:
|
|
113
|
-
script:
|
|
91
|
+
fn: Function.Function | undefined,
|
|
92
|
+
script: Script.Script,
|
|
114
93
|
functionId: string,
|
|
115
94
|
version: string,
|
|
116
|
-
):
|
|
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
|
-
|
|
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
|
};
|