@dxos/plugin-script 0.8.4-main.406dc2a → 0.8.4-main.43cb759274
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/LICENSE +102 -5
- package/PLUGIN.mdl +515 -0
- package/README.md +15 -13
- package/dist/lib/neutral/DeploymentDialog-M3AFYQHC.mjs +114 -0
- package/dist/lib/neutral/DeploymentDialog-M3AFYQHC.mjs.map +7 -0
- package/dist/lib/{browser/NotebookContainer-LVGRPFY3.mjs → neutral/NotebookArticle-NV4AHOOS.mjs} +313 -233
- package/dist/lib/neutral/NotebookArticle-NV4AHOOS.mjs.map +7 -0
- package/dist/lib/neutral/ScriptArticle-UBT27SB6.mjs +79 -0
- package/dist/lib/neutral/ScriptArticle-UBT27SB6.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.mjs +51 -0
- package/dist/lib/neutral/ScriptPlugin.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.node.mjs +27 -0
- package/dist/lib/neutral/ScriptPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs +21 -0
- package/dist/lib/neutral/ScriptPlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPluginSettings-T4JMUSHN.mjs +31 -0
- package/dist/lib/neutral/ScriptPluginSettings-T4JMUSHN.mjs.map +7 -0
- package/dist/lib/neutral/ScriptProperties-RLXNAN3N.mjs +297 -0
- package/dist/lib/neutral/ScriptProperties-RLXNAN3N.mjs.map +7 -0
- package/dist/lib/neutral/TestContainer-AFVTBYSJ.mjs +44 -0
- package/dist/lib/neutral/TestContainer-AFVTBYSJ.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-7AWFCEQF.mjs +52 -0
- package/dist/lib/neutral/app-graph-builder-7AWFCEQF.mjs.map +7 -0
- package/dist/lib/neutral/blueprint-definition-T33SBPP2.mjs +15 -0
- package/dist/lib/neutral/blueprint-definition-T33SBPP2.mjs.map +7 -0
- package/dist/lib/neutral/blueprints/index.mjs +10 -0
- package/dist/lib/neutral/capabilities/index.mjs +21 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/node.mjs +17 -0
- package/dist/lib/neutral/capabilities/node.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2REUEDUA.mjs +56 -0
- package/dist/lib/neutral/chunk-2REUEDUA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BDHDBPVM.mjs +52 -0
- package/dist/lib/neutral/chunk-BDHDBPVM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-C4O7EV6M.mjs +123 -0
- package/dist/lib/neutral/chunk-C4O7EV6M.mjs.map +7 -0
- package/dist/lib/neutral/chunk-H2BRWQMY.mjs +96 -0
- package/dist/lib/neutral/chunk-H2BRWQMY.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-LHEJXJEL.mjs +8 -0
- package/dist/lib/neutral/chunk-LHEJXJEL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-NQOIENTU.mjs +8 -0
- package/dist/lib/neutral/chunk-NQOIENTU.mjs.map +7 -0
- package/dist/lib/neutral/chunk-TRKXIP2Q.mjs +345 -0
- package/dist/lib/neutral/chunk-TRKXIP2Q.mjs.map +7 -0
- package/dist/lib/neutral/chunk-UA3BWOCZ.mjs +38 -0
- package/dist/lib/neutral/chunk-UA3BWOCZ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-VXDJH6OL.mjs +150 -0
- package/dist/lib/neutral/chunk-VXDJH6OL.mjs.map +7 -0
- package/dist/lib/neutral/compiler-ODK4UA2N.mjs +101 -0
- package/dist/lib/neutral/compiler-ODK4UA2N.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +664 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +17 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-WQJXMOUE.mjs +46 -0
- package/dist/lib/neutral/create-WQJXMOUE.mjs.map +7 -0
- package/dist/lib/neutral/create-object-FZM5ASWM.mjs +45 -0
- package/dist/lib/neutral/create-object-FZM5ASWM.mjs.map +7 -0
- package/dist/lib/neutral/create-script-66DO3UJO.mjs +45 -0
- package/dist/lib/neutral/create-script-66DO3UJO.mjs.map +7 -0
- package/dist/lib/neutral/delete-HCQIQFVP.mjs +21 -0
- package/dist/lib/neutral/delete-HCQIQFVP.mjs.map +7 -0
- package/dist/lib/neutral/deploy-7JVMMHSH.mjs +63 -0
- package/dist/lib/neutral/deploy-7JVMMHSH.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +369 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +41 -0
- package/dist/lib/neutral/inspect-invocations-6MW73SDV.mjs +59 -0
- package/dist/lib/neutral/inspect-invocations-6MW73SDV.mjs.map +7 -0
- package/dist/lib/neutral/install-function-FJIE2JAI.mjs +49 -0
- package/dist/lib/neutral/install-function-FJIE2JAI.mjs.map +7 -0
- package/dist/lib/neutral/invoke-3HVWY2KF.mjs +32 -0
- package/dist/lib/neutral/invoke-3HVWY2KF.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +10 -0
- package/dist/lib/neutral/operation-handler-X44IGZXS.mjs +18 -0
- package/dist/lib/neutral/operation-handler-X44IGZXS.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/query-deployed-functions-F4FHJNWO.mjs +34 -0
- package/dist/lib/neutral/query-deployed-functions-F4FHJNWO.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-ACNZ35FV.mjs +121 -0
- package/dist/lib/neutral/react-surface-ACNZ35FV.mjs.map +7 -0
- package/dist/lib/neutral/read-RQESBAQI.mjs +26 -0
- package/dist/lib/neutral/read-RQESBAQI.mjs.map +7 -0
- package/dist/lib/neutral/settings-VJBW4OMK.mjs +30 -0
- package/dist/lib/neutral/settings-VJBW4OMK.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/templates/index.mjs +2 -1
- package/dist/lib/neutral/translations.mjs +105 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +17 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/lib/neutral/update-JZUNJYZM.mjs +63 -0
- package/dist/lib/neutral/update-JZUNJYZM.mjs.map +7 -0
- package/dist/types/src/ScriptPlugin.d.ts +3 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/ScriptPlugin.node.d.ts +4 -0
- package/dist/types/src/ScriptPlugin.node.d.ts.map +1 -0
- package/dist/types/src/ScriptPlugin.test.d.ts +2 -0
- package/dist/types/src/ScriptPlugin.test.d.ts.map +1 -0
- package/dist/types/src/ScriptPlugin.workerd.d.ts +4 -0
- package/dist/types/src/ScriptPlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/create.d.ts +11 -0
- package/dist/types/src/blueprints/functions/create.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/definitions.d.ts +135 -0
- package/dist/types/src/blueprints/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/delete.d.ts +17 -0
- package/dist/types/src/blueprints/functions/delete.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/deploy.d.ts +21 -0
- package/dist/types/src/blueprints/functions/deploy.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/index.d.ts +4 -0
- package/dist/types/src/blueprints/functions/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/inspect-invocations.d.ts +28 -0
- package/dist/types/src/blueprints/functions/inspect-invocations.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/install-function.d.ts +11 -0
- package/dist/types/src/blueprints/functions/install-function.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/invoke.d.ts +21 -0
- package/dist/types/src/blueprints/functions/invoke.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/query-deployed-functions.d.ts +13 -0
- package/dist/types/src/blueprints/functions/query-deployed-functions.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/read.d.ts +21 -0
- package/dist/types/src/blueprints/functions/read.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/update.d.ts +26 -0
- package/dist/types/src/blueprints/functions/update.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +2 -0
- package/dist/types/src/blueprints/index.d.ts.map +1 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts +4 -0
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -4
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/compiler.d.ts +3 -1
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
- package/dist/types/src/capabilities/create-object.d.ts +16 -0
- package/dist/types/src/capabilities/create-object.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +19 -7
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +18 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +5 -2
- package/dist/types/src/capabilities/settings.d.ts.map +1 -1
- package/dist/types/src/compiler/compiler.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +5 -4
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts +1 -1
- package/dist/types/src/components/NotebookStack/NotebookMenu.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +5 -3
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +221 -229
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts +5 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts +13 -0
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/QueryEditor/index.d.ts +2 -0
- package/dist/types/src/components/QueryEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.d.ts +8 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.d.ts.map +1 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts +241 -0
- package/dist/types/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.d.ts.map +1 -0
- package/dist/types/src/components/ScriptPluginSettings/index.d.ts +2 -0
- package/dist/types/src/components/ScriptPluginSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts +10 -9
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +221 -229
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestPanel.d.ts +4 -2
- package/dist/types/src/components/TestPanel/TestPanel.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/index.d.ts +0 -1
- package/dist/types/src/components/TestPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +6 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +3 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +3 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/DeploymentDialog/DeploymentDialog.d.ts +2 -4
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.d.ts.map +1 -0
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts +240 -0
- package/dist/types/src/containers/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -0
- package/dist/types/src/containers/DeploymentDialog/index.d.ts +2 -0
- package/dist/types/src/containers/DeploymentDialog/index.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts +7 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts +7 -0
- package/dist/types/src/containers/NotebookArticle/NotebookArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookArticle/index.d.ts +2 -0
- package/dist/types/src/containers/NotebookArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts +10 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts +242 -0
- package/dist/types/src/containers/ScriptArticle/ScriptArticle.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptArticle/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptArticle/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/BlueprintEditor.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/FunctionBinding.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/FunctionBinding.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/FunctionPublishing.d.ts +7 -0
- package/dist/types/src/containers/ScriptProperties/FunctionPublishing.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts +6 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts +242 -0
- package/dist/types/src/containers/ScriptProperties/ScriptProperties.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptProperties/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptProperties/index.d.ts.map +1 -0
- package/dist/types/src/containers/TestContainer/TestContainer.d.ts +8 -0
- package/dist/types/src/containers/TestContainer/TestContainer.d.ts.map +1 -0
- package/dist/types/src/containers/TestContainer/index.d.ts +2 -0
- package/dist/types/src/containers/TestContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/e2e/ai.test.d.ts +2 -0
- package/dist/types/src/e2e/ai.test.d.ts.map +1 -0
- package/dist/types/src/e2e/deploy.test.d.ts +2 -0
- package/dist/types/src/e2e/deploy.test.d.ts.map +1 -0
- package/dist/types/src/hooks/deploy.d.ts +27 -30
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +5 -4
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +7 -16
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompiler.d.ts +7 -0
- package/dist/types/src/hooks/useCompiler.d.ts.map +1 -0
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/hooks/useToolbarState.d.ts +8 -1
- package/dist/types/src/hooks/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts +58 -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 +1 -1
- package/dist/types/src/notebook/eval.d.ts.map +1 -1
- package/dist/types/src/notebook/index.d.ts +1 -1
- package/dist/types/src/notebook/index.d.ts.map +1 -1
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -1
- package/dist/types/src/operations/create-script.d.ts +5 -0
- package/dist/types/src/operations/create-script.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/templates/anthropic.d.ts +7 -0
- package/dist/types/src/templates/anthropic.d.ts.map +1 -0
- package/dist/types/src/templates/chess-bot.d.ts +14 -0
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -0
- package/dist/types/src/templates/commentary.d.ts +15 -0
- package/dist/types/src/templates/commentary.d.ts.map +1 -0
- 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/email.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts +5 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts +5 -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 +28 -24
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +2 -4
- package/dist/types/src/templates/ping.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/simulator.test.d.ts +2 -0
- package/dist/types/src/testing/simulator.test.d.ts.map +1 -0
- package/dist/types/src/testing/test-notebook.d.ts +3 -0
- package/dist/types/src/testing/test-notebook.d.ts.map +1 -0
- package/dist/types/src/testing/test-script.d.ts +7 -0
- package/dist/types/src/testing/test-script.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +222 -91
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +101 -0
- package/dist/types/src/types/Notebook.d.ts.map +1 -0
- package/dist/types/src/types/ScriptCapabilities.d.ts +6 -0
- package/dist/types/src/types/ScriptCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/ScriptEvents.d.ts +3 -0
- package/dist/types/src/types/ScriptEvents.d.ts.map +1 -0
- package/dist/types/src/types/ScriptOperation.d.ts +29 -0
- package/dist/types/src/types/ScriptOperation.d.ts.map +1 -0
- package/dist/types/src/types/Settings.d.ts +7 -0
- package/dist/types/src/types/Settings.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/util/deploy.d.ts +4 -4
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +3 -3
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +186 -105
- package/src/ScriptPlugin.node.ts +21 -0
- package/src/ScriptPlugin.test.ts +31 -0
- package/src/ScriptPlugin.tsx +29 -97
- package/src/ScriptPlugin.workerd.ts +18 -0
- package/src/blueprints/functions/create.ts +47 -0
- package/src/blueprints/functions/definitions.ts +332 -0
- package/src/blueprints/functions/delete.ts +23 -0
- package/src/blueprints/functions/deploy.ts +71 -0
- package/src/blueprints/functions/index.ts +19 -0
- package/src/blueprints/functions/inspect-invocations.ts +56 -0
- package/src/blueprints/functions/install-function.ts +56 -0
- package/src/blueprints/functions/invoke.ts +34 -0
- package/src/blueprints/functions/query-deployed-functions.ts +35 -0
- package/src/blueprints/functions/read.ts +29 -0
- package/src/blueprints/functions/update.ts +68 -0
- package/src/blueprints/index.ts +5 -0
- package/src/blueprints/script-blueprint.ts +55 -0
- package/src/capabilities/app-graph-builder.ts +40 -58
- package/src/capabilities/blueprint-definition.ts +13 -24
- package/src/capabilities/compiler.ts +100 -23
- package/src/capabilities/create-object.ts +49 -0
- package/src/capabilities/index.ts +13 -9
- package/src/capabilities/node.ts +16 -0
- package/src/capabilities/operation-handler.ts +21 -0
- package/src/capabilities/react-surface.tsx +120 -92
- package/src/capabilities/settings.ts +26 -14
- package/src/compiler/compiler.ts +21 -3
- package/src/components/NotebookStack/NotebookCell.tsx +100 -91
- package/src/components/NotebookStack/NotebookMenu.tsx +7 -7
- package/src/components/NotebookStack/NotebookStack.stories.tsx +34 -13
- package/src/components/NotebookStack/NotebookStack.tsx +40 -22
- package/src/components/QueryEditor/QueryEditor.stories.tsx +96 -0
- package/src/components/QueryEditor/QueryEditor.tsx +49 -0
- package/src/components/QueryEditor/index.ts +5 -0
- package/src/components/ScriptPluginSettings/ScriptPluginSettings.stories.tsx +32 -0
- package/src/components/ScriptPluginSettings/ScriptPluginSettings.tsx +42 -0
- package/src/components/ScriptPluginSettings/index.ts +5 -0
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +44 -22
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +43 -48
- package/src/components/TestPanel/TestPanel.tsx +125 -185
- package/src/components/TestPanel/index.ts +0 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +26 -19
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +74 -71
- package/src/components/index.ts +5 -7
- package/src/constants.ts +9 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.stories.tsx +63 -0
- package/src/containers/DeploymentDialog/DeploymentDialog.tsx +99 -0
- package/src/containers/DeploymentDialog/index.ts +5 -0
- package/src/containers/NotebookArticle/NotebookArticle.stories.tsx +85 -0
- package/src/containers/NotebookArticle/NotebookArticle.tsx +255 -0
- package/src/containers/NotebookArticle/index.ts +5 -0
- package/src/containers/ScriptArticle/ScriptArticle.stories.tsx +107 -0
- package/src/containers/ScriptArticle/ScriptArticle.tsx +85 -0
- package/src/containers/ScriptArticle/index.ts +5 -0
- package/src/containers/ScriptProperties/BlueprintEditor.tsx +102 -0
- package/src/containers/ScriptProperties/FunctionBinding.tsx +83 -0
- package/src/containers/ScriptProperties/FunctionPublishing.tsx +121 -0
- package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +76 -0
- package/src/containers/ScriptProperties/ScriptProperties.tsx +24 -0
- package/src/containers/ScriptProperties/index.ts +5 -0
- package/src/containers/TestContainer/TestContainer.tsx +44 -0
- package/src/containers/TestContainer/index.ts +5 -0
- package/src/containers/index.ts +11 -0
- package/src/e2e/ai.test.ts +93 -0
- package/src/e2e/deploy.test.ts +66 -0
- package/src/hooks/deploy.ts +47 -37
- package/src/hooks/format.ts +10 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +23 -26
- package/src/hooks/useCompiler.ts +25 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +15 -16
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +2 -4
- package/src/meta.ts +17 -7
- package/src/notebook/compute-graph.test.ts +82 -0
- package/src/notebook/{notebook.ts → compute-graph.ts} +66 -19
- package/src/notebook/eval.ts +1 -1
- package/src/notebook/index.ts +1 -1
- package/src/notebook/vfs-parser.ts +10 -3
- package/src/operations/create-script.ts +46 -0
- package/src/operations/index.ts +7 -0
- package/src/plugin.ts +11 -0
- package/src/templates/anthropic.ts +50 -0
- package/src/templates/chess-bot.ts +63 -0
- package/src/templates/commentary.ts +251 -0
- package/src/templates/data-generator.ts +2 -2
- package/src/templates/discord.ts +8 -8
- package/src/templates/forex-effect.ts +36 -29
- package/src/templates/forex.ts +28 -17
- package/src/templates/gmail.ts +10 -11
- package/src/templates/index.ts +29 -23
- package/src/templates/ping.ts +23 -5
- package/src/testing/index.ts +2 -1
- package/src/testing/simulator.test.ts +39 -0
- package/src/testing/test-notebook.ts +71 -0
- package/src/testing/test-script.ts +28 -0
- package/src/translations.ts +89 -88
- package/src/types/Notebook.ts +39 -0
- package/src/types/ScriptCapabilities.ts +18 -0
- package/src/types/ScriptEvents.ts +11 -0
- package/src/types/ScriptOperation.ts +42 -0
- package/src/types/Settings.ts +20 -0
- package/src/types/index.ts +6 -2
- package/src/types/types.ts +5 -0
- package/src/util/deploy.ts +33 -41
- package/src/util/functions.ts +35 -30
- package/src/vite-env.d.ts +7 -0
- package/dist/lib/browser/DeploymentDialog-65TWT6S5.mjs +0 -13
- package/dist/lib/browser/NotebookContainer-LVGRPFY3.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs +0 -149
- package/dist/lib/browser/ScriptContainer-LRTRN7JW.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs +0 -65
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +0 -28
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +0 -7
- package/dist/lib/browser/chunk-5CYLWXRH.mjs +0 -89
- package/dist/lib/browser/chunk-5CYLWXRH.mjs.map +0 -7
- package/dist/lib/browser/chunk-75LH4EUR.mjs +0 -326
- package/dist/lib/browser/chunk-75LH4EUR.mjs.map +0 -7
- package/dist/lib/browser/chunk-E7DXDICD.mjs +0 -282
- package/dist/lib/browser/chunk-E7DXDICD.mjs.map +0 -7
- package/dist/lib/browser/chunk-EZVXV6DA.mjs +0 -26
- package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +0 -7
- package/dist/lib/browser/chunk-I3QSGUFJ.mjs +0 -646
- package/dist/lib/browser/chunk-I3QSGUFJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-JO2O7W6J.mjs +0 -254
- package/dist/lib/browser/chunk-JO2O7W6J.mjs.map +0 -7
- package/dist/lib/browser/chunk-N6M34EUC.mjs +0 -112
- package/dist/lib/browser/chunk-N6M34EUC.mjs.map +0 -7
- package/dist/lib/browser/chunk-NM4WQS4F.mjs +0 -153
- package/dist/lib/browser/chunk-NM4WQS4F.mjs.map +0 -7
- package/dist/lib/browser/chunk-OKXN2N7M.mjs +0 -15
- package/dist/lib/browser/chunk-OKXN2N7M.mjs.map +0 -7
- package/dist/lib/browser/chunk-ST3ACVUC.mjs +0 -88
- package/dist/lib/browser/chunk-ST3ACVUC.mjs.map +0 -7
- package/dist/lib/browser/compiler-G2N2CG63.mjs +0 -98
- package/dist/lib/browser/compiler-G2N2CG63.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -279
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs +0 -105
- package/dist/lib/browser/intent-resolver-JLU7DVLQ.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-76SDTUYG.mjs +0 -127
- package/dist/lib/browser/react-surface-76SDTUYG.mjs.map +0 -7
- package/dist/lib/browser/settings-ERFKVNUK.mjs +0 -25
- package/dist/lib/browser/settings-ERFKVNUK.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -13
- package/dist/lib/node-esm/DeploymentDialog-I63ZC2HH.mjs +0 -14
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs +0 -684
- package/dist/lib/node-esm/NotebookContainer-QY5NJGJI.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs +0 -150
- package/dist/lib/node-esm/ScriptContainer-SVXCSLNH.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs +0 -66
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +0 -30
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs +0 -90
- package/dist/lib/node-esm/chunk-2GVTWESW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4X375PGY.mjs +0 -90
- package/dist/lib/node-esm/chunk-4X375PGY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs +0 -327
- package/dist/lib/node-esm/chunk-67OVZHI3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-C2ORIPKH.mjs +0 -154
- package/dist/lib/node-esm/chunk-C2ORIPKH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs +0 -16
- package/dist/lib/node-esm/chunk-NUXZQQ6P.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OG2SIKHE.mjs +0 -28
- package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SMFPSKQT.mjs +0 -647
- package/dist/lib/node-esm/chunk-SMFPSKQT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs +0 -114
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs +0 -283
- package/dist/lib/node-esm/chunk-VZAFGLD7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs +0 -255
- package/dist/lib/node-esm/chunk-YW36TZ7K.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs +0 -99
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -280
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs +0 -106
- package/dist/lib/node-esm/intent-resolver-SFGTIFOG.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs +0 -128
- package/dist/lib/node-esm/react-surface-SHEBNW4R.mjs.map +0 -7
- package/dist/lib/node-esm/settings-5TYXQ42N.mjs +0 -26
- package/dist/lib/node-esm/settings-5TYXQ42N.mjs.map +0 -7
- package/dist/lib/node-esm/templates/index.mjs +0 -10
- package/dist/lib/node-esm/types/index.mjs +0 -14
- package/dist/types/src/capabilities/artifact-definition.d.ts +0 -11
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +0 -251
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +0 -4
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts +0 -12
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/frame.d.ts +0 -2
- package/dist/types/src/components/FrameContainer/frame.d.ts.map +0 -1
- package/dist/types/src/components/FrameContainer/index.d.ts +0 -2
- package/dist/types/src/components/FrameContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/NotebookContainer.d.ts +0 -10
- package/dist/types/src/components/NotebookContainer.d.ts.map +0 -1
- package/dist/types/src/components/NotebookContainer.stories.d.ts +0 -248
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptContainer.d.ts +0 -12
- package/dist/types/src/components/ScriptContainer.d.ts.map +0 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts +0 -8
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +0 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +0 -6
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +0 -1
- package/dist/types/src/components/Settings/index.d.ts +0 -3
- package/dist/types/src/components/Settings/index.d.ts.map +0 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts +0 -8
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/notebook/notebook.d.ts +0 -35
- package/dist/types/src/notebook/notebook.d.ts.map +0 -1
- package/dist/types/src/notebook/notebook.test.d.ts +0 -2
- package/dist/types/src/notebook/notebook.test.d.ts.map +0 -1
- package/dist/types/src/templates/chat.d.ts +0 -6
- package/dist/types/src/templates/chat.d.ts.map +0 -1
- package/dist/types/src/templates/chess.d.ts +0 -3
- package/dist/types/src/templates/chess.d.ts.map +0 -1
- package/dist/types/src/testing/data.d.ts +0 -19
- package/dist/types/src/testing/data.d.ts.map +0 -1
- package/dist/types/src/types/actions.d.ts +0 -66
- package/dist/types/src/types/actions.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -61
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/artifact-definition.ts +0 -225
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -87
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +0 -53
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +0 -106
- package/src/components/DeploymentDialog/index.ts +0 -9
- package/src/components/FrameContainer/FrameContainer.tsx +0 -84
- package/src/components/FrameContainer/frame.html +0 -25
- package/src/components/FrameContainer/frame.tsx +0 -51
- package/src/components/FrameContainer/index.ts +0 -5
- package/src/components/NotebookContainer.stories.tsx +0 -32
- package/src/components/NotebookContainer.tsx +0 -124
- package/src/components/ScriptContainer.tsx +0 -69
- package/src/components/Settings/ScriptObjectSettings.tsx +0 -286
- package/src/components/Settings/ScriptPluginSettings.tsx +0 -61
- package/src/components/Settings/index.ts +0 -6
- package/src/components/TestPanel/TestContainer.tsx +0 -27
- package/src/events.ts +0 -11
- package/src/notebook/notebook.test.ts +0 -70
- package/src/templates/chat.ts +0 -96
- package/src/templates/chess.ts +0 -49
- package/src/testing/data.ts +0 -47
- package/src/types/actions.ts +0 -53
- package/src/types/schema.ts +0 -48
- /package/dist/lib/{browser/templates → neutral/blueprints}/index.mjs.map +0 -0
- /package/dist/lib/{browser/DeploymentDialog-65TWT6S5.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{browser/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/DeploymentDialog-I63ZC2HH.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{node-esm/templates → neutral/operations}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/types → neutral/templates}/index.mjs.map +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { type Script } from '@dxos/compute';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { createDocAccessor } from '@dxos/echo-db';
|
|
11
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
12
|
+
import { useIdentity } from '@dxos/react-client/halo';
|
|
13
|
+
import { Panel } from '@dxos/react-ui';
|
|
14
|
+
import { createDataExtensions, listener, editorClassNames } from '@dxos/ui-editor';
|
|
15
|
+
|
|
16
|
+
import { ScriptToolbar, TypescriptEditor, type TypescriptEditorProps } from '#components';
|
|
17
|
+
import { useDeployState, useToolbarState } from '#hooks';
|
|
18
|
+
import { type Settings } from '#types';
|
|
19
|
+
|
|
20
|
+
export type ScriptEditorProps = AppSurface.ObjectArticleProps<
|
|
21
|
+
Script.Script,
|
|
22
|
+
{
|
|
23
|
+
settings?: Settings.Settings;
|
|
24
|
+
} & Pick<TypescriptEditorProps, 'env'>
|
|
25
|
+
>;
|
|
26
|
+
|
|
27
|
+
export const ScriptArticle = ({
|
|
28
|
+
role,
|
|
29
|
+
attendableId,
|
|
30
|
+
subject: script,
|
|
31
|
+
settings = { editorInputMode: 'vscode' },
|
|
32
|
+
env,
|
|
33
|
+
}: ScriptEditorProps) => {
|
|
34
|
+
const identity = useIdentity();
|
|
35
|
+
const space = getSpace(script);
|
|
36
|
+
const state = useToolbarState();
|
|
37
|
+
useDeployState({ script, state });
|
|
38
|
+
|
|
39
|
+
const extensions = useMemo(() => {
|
|
40
|
+
if (!script.source.target) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return [
|
|
45
|
+
createDataExtensions({
|
|
46
|
+
id: script.id,
|
|
47
|
+
text: createDocAccessor(script.source.target, ['content']),
|
|
48
|
+
messenger: space,
|
|
49
|
+
identity,
|
|
50
|
+
}),
|
|
51
|
+
listener({
|
|
52
|
+
onChange: ({ text }) => {
|
|
53
|
+
if (script.source.target?.content !== text) {
|
|
54
|
+
Obj.update(script, (script) => {
|
|
55
|
+
script.changed = true;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
}),
|
|
60
|
+
];
|
|
61
|
+
}, [identity, space, script, script.source.target]);
|
|
62
|
+
|
|
63
|
+
if (!extensions.length) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Panel.Root role={role}>
|
|
69
|
+
<Panel.Toolbar asChild>
|
|
70
|
+
<ScriptToolbar script={script} attendableId={attendableId} state={state} role={role} />
|
|
71
|
+
</Panel.Toolbar>
|
|
72
|
+
<Panel.Content asChild>
|
|
73
|
+
<TypescriptEditor
|
|
74
|
+
classNames={editorClassNames(role)}
|
|
75
|
+
id={script.id}
|
|
76
|
+
env={env}
|
|
77
|
+
initialValue={script.source?.target?.content}
|
|
78
|
+
extensions={extensions}
|
|
79
|
+
inputMode={settings.editorInputMode}
|
|
80
|
+
toolbar
|
|
81
|
+
/>
|
|
82
|
+
</Panel.Content>
|
|
83
|
+
</Panel.Root>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { ToolId } from '@dxos/ai';
|
|
8
|
+
import { Blueprint, Template } from '@dxos/compute';
|
|
9
|
+
import { type Script } from '@dxos/compute';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
12
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
13
|
+
import { Button, Input, useAsyncEffect, useTranslation } from '@dxos/react-ui';
|
|
14
|
+
import { Form } from '@dxos/react-ui-form';
|
|
15
|
+
import { kebabize } from '@dxos/util';
|
|
16
|
+
|
|
17
|
+
import { meta } from '#meta';
|
|
18
|
+
|
|
19
|
+
export type BlueprintEditorProps = { object: Script.Script };
|
|
20
|
+
|
|
21
|
+
export const BlueprintEditor = ({ object }: BlueprintEditorProps) => {
|
|
22
|
+
const { t } = useTranslation(meta.id);
|
|
23
|
+
const db = Obj.getDatabase(object);
|
|
24
|
+
const [fn] = useQuery(db, Filter.type(Operation.PersistentOperation, { source: Ref.make(object) }));
|
|
25
|
+
const blueprints = useQuery(db, Filter.type(Blueprint.Blueprint));
|
|
26
|
+
|
|
27
|
+
const [creating, setCreating] = useState(false);
|
|
28
|
+
// TODO(burdon): Remove?
|
|
29
|
+
const [instructions, setInstructions] = useState<string>(`You can run the script "${object.name ?? 'script'}".`);
|
|
30
|
+
const blueprintKey = `org.dxos.blueprint.${kebabize(object.name ?? 'script')}`;
|
|
31
|
+
const existingBlueprint = blueprints.find((bp) => Obj.getMeta(bp).key === blueprintKey);
|
|
32
|
+
const fnKey = fn ? Obj.getMeta(fn).key : undefined;
|
|
33
|
+
|
|
34
|
+
useAsyncEffect(async () => {
|
|
35
|
+
if (!existingBlueprint) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const source = await existingBlueprint.instructions.source.load();
|
|
40
|
+
setInstructions(source.content ?? '');
|
|
41
|
+
}, [existingBlueprint]);
|
|
42
|
+
|
|
43
|
+
const handleSave = useCallback(async () => {
|
|
44
|
+
if (!db) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setCreating(true);
|
|
49
|
+
try {
|
|
50
|
+
if (existingBlueprint) {
|
|
51
|
+
const text = await existingBlueprint.instructions.source.load();
|
|
52
|
+
Obj.update(text, (text) => {
|
|
53
|
+
text.content = instructions;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (fnKey) {
|
|
57
|
+
const toolId = ToolId.make(fnKey);
|
|
58
|
+
if (!existingBlueprint.tools?.includes(toolId)) {
|
|
59
|
+
Obj.update(existingBlueprint, (existingBlueprint) => {
|
|
60
|
+
existingBlueprint.tools = [...(existingBlueprint.tools ?? []), toolId];
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
} else if (fnKey) {
|
|
65
|
+
db.add(
|
|
66
|
+
Blueprint.make({
|
|
67
|
+
key: blueprintKey,
|
|
68
|
+
name: object.name ?? 'Script',
|
|
69
|
+
instructions: Template.make({ source: instructions }),
|
|
70
|
+
tools: [ToolId.make(fnKey)],
|
|
71
|
+
}),
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
await db.flush();
|
|
75
|
+
} finally {
|
|
76
|
+
setCreating(false);
|
|
77
|
+
}
|
|
78
|
+
}, [db, existingBlueprint, fnKey, blueprintKey, object.name, instructions]);
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<div className='flex flex-col'>
|
|
82
|
+
<Form.Section label={t('blueprint-editor.label')} description={t('blueprint-editor.description')} />
|
|
83
|
+
|
|
84
|
+
<Input.Root>
|
|
85
|
+
<Input.Label>{t('blueprint-instructions.label')}</Input.Label>
|
|
86
|
+
<Input.TextArea
|
|
87
|
+
placeholder={t('blueprint-instructions.placeholder')}
|
|
88
|
+
rows={6}
|
|
89
|
+
value={instructions}
|
|
90
|
+
onChange={(event) => setInstructions(event.target.value)}
|
|
91
|
+
classNames='resize-y'
|
|
92
|
+
/>
|
|
93
|
+
</Input.Root>
|
|
94
|
+
|
|
95
|
+
<div className='pt-2'>
|
|
96
|
+
<Button disabled={(!existingBlueprint && !fnKey) || creating} onClick={handleSave}>
|
|
97
|
+
{t(existingBlueprint ? 'update-blueprint.label' : 'create-blueprint.label')}
|
|
98
|
+
</Button>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type ChangeEvent, useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Script } from '@dxos/compute';
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
9
|
+
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
10
|
+
import { getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
11
|
+
import { getInvocationUrl } from '@dxos/functions-runtime';
|
|
12
|
+
import { useClient } from '@dxos/react-client';
|
|
13
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
14
|
+
import { Clipboard, Input, useControlledState, useTranslation } from '@dxos/react-ui';
|
|
15
|
+
import { Form } from '@dxos/react-ui-form';
|
|
16
|
+
|
|
17
|
+
import { meta } from '#meta';
|
|
18
|
+
|
|
19
|
+
export type FunctionBindingProps = { object: Script.Script };
|
|
20
|
+
|
|
21
|
+
export const FunctionBinding = ({ object }: FunctionBindingProps) => {
|
|
22
|
+
const { t } = useTranslation(meta.id);
|
|
23
|
+
const client = useClient();
|
|
24
|
+
const db = Obj.getDatabase(object);
|
|
25
|
+
|
|
26
|
+
const [fn] = useQuery(db, Filter.type(Operation.PersistentOperation, { source: Ref.make(object) }));
|
|
27
|
+
const functionId = fn && getUserFunctionIdInMetadata(Obj.getMeta(fn));
|
|
28
|
+
const functionUrl =
|
|
29
|
+
functionId &&
|
|
30
|
+
getInvocationUrl(functionId, client.config.values.runtime?.services?.edge?.url ?? '', {
|
|
31
|
+
spaceId: db?.spaceId,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const [binding, setBinding] = useControlledState(fn?.binding ?? '');
|
|
35
|
+
const handleBindingChange = useCallback(
|
|
36
|
+
(event: ChangeEvent<HTMLInputElement>) => setBinding(event.target.value),
|
|
37
|
+
[setBinding],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const handleBindingBlur = useCallback(() => {
|
|
41
|
+
if (fn) {
|
|
42
|
+
Obj.update(fn, (fn) => {
|
|
43
|
+
fn.binding = binding;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}, [fn, binding]);
|
|
47
|
+
|
|
48
|
+
if (!fn) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className='flex flex-col'>
|
|
54
|
+
<Form.Section label={t('remote-function-settings.heading')} />
|
|
55
|
+
|
|
56
|
+
{functionUrl && (
|
|
57
|
+
<Input.Root>
|
|
58
|
+
<Input.Label>{t('function-url.label')}</Input.Label>
|
|
59
|
+
<Input.TextInput
|
|
60
|
+
disabled
|
|
61
|
+
value={functionUrl}
|
|
62
|
+
onChange={(event) => {
|
|
63
|
+
Obj.update(fn, (fn) => {
|
|
64
|
+
fn.name = event.target.value;
|
|
65
|
+
});
|
|
66
|
+
}}
|
|
67
|
+
/>
|
|
68
|
+
<Clipboard.IconButton value={functionUrl} />
|
|
69
|
+
</Input.Root>
|
|
70
|
+
)}
|
|
71
|
+
|
|
72
|
+
<Input.Root>
|
|
73
|
+
<Input.Label>{t('function-binding.label')}</Input.Label>
|
|
74
|
+
<Input.TextInput
|
|
75
|
+
placeholder={t('function-binding.placeholder')}
|
|
76
|
+
value={binding}
|
|
77
|
+
onChange={handleBindingChange}
|
|
78
|
+
onBlur={handleBindingBlur}
|
|
79
|
+
/>
|
|
80
|
+
</Input.Root>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Octokit } from '@octokit/core';
|
|
6
|
+
import React, { useCallback, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
9
|
+
import { SettingsOperation } from '@dxos/app-toolkit';
|
|
10
|
+
import { type Script } from '@dxos/compute';
|
|
11
|
+
import { Filter, Obj } from '@dxos/echo';
|
|
12
|
+
import { log } from '@dxos/log';
|
|
13
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
14
|
+
import { Button, Clipboard, Message, useAsyncEffect, useTranslation } from '@dxos/react-ui';
|
|
15
|
+
import { Form } from '@dxos/react-ui-form';
|
|
16
|
+
import { AccessToken } from '@dxos/types';
|
|
17
|
+
import { kebabize } from '@dxos/util';
|
|
18
|
+
|
|
19
|
+
import { meta } from '#meta';
|
|
20
|
+
|
|
21
|
+
export type FunctionPublishingProps = { object: Script.Script };
|
|
22
|
+
|
|
23
|
+
// TODO(burdon): Move to separate tab?
|
|
24
|
+
export const FunctionPublishing = ({ object }: FunctionPublishingProps) => {
|
|
25
|
+
const { t } = useTranslation(meta.id);
|
|
26
|
+
const { invokePromise } = useOperationInvoker();
|
|
27
|
+
const db = Obj.getDatabase(object);
|
|
28
|
+
|
|
29
|
+
const [githubToken] = useQuery(db, Filter.type(AccessToken.AccessToken, { source: 'github.com' }));
|
|
30
|
+
const gistKey = Obj.getMeta(object).keys.find(({ source }) => source === 'github.com');
|
|
31
|
+
const [gistUrl, setGistUrl] = useState<string | undefined>();
|
|
32
|
+
|
|
33
|
+
useAsyncEffect(async () => {
|
|
34
|
+
const token = githubToken?.token;
|
|
35
|
+
const gistId = gistKey?.id;
|
|
36
|
+
if (!token || !gistId) {
|
|
37
|
+
setGistUrl(undefined);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
const octokit = new Octokit({ auth: githubToken.token });
|
|
43
|
+
const response = await octokit.request('GET /gists/{gist_id}', {
|
|
44
|
+
gist_id: gistId,
|
|
45
|
+
});
|
|
46
|
+
setGistUrl(response.data.html_url);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
log.catch(err);
|
|
49
|
+
setGistUrl(undefined);
|
|
50
|
+
}
|
|
51
|
+
}, [githubToken, gistKey]);
|
|
52
|
+
|
|
53
|
+
const handleOpenTokenManager = useCallback(
|
|
54
|
+
() =>
|
|
55
|
+
invokePromise(SettingsOperation.Open, {
|
|
56
|
+
plugin: 'org.dxos.plugin.token-manager',
|
|
57
|
+
}),
|
|
58
|
+
[invokePromise],
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const [publishing, setPublishing] = useState(false);
|
|
62
|
+
const handlePublish = useCallback(async () => {
|
|
63
|
+
setPublishing(true);
|
|
64
|
+
const octokit = new Octokit({ auth: githubToken.token });
|
|
65
|
+
const source = await object.source.load();
|
|
66
|
+
const filename = object.name ? kebabize(object.name) : 'composer-script';
|
|
67
|
+
const files = { [`${filename}.ts`]: { content: source.content } };
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
// TODO(wittjosiah): Factor out to intent.
|
|
71
|
+
const meta = Obj.getMeta(object);
|
|
72
|
+
const githubKey = meta.keys.find(({ source }) => source === 'github.com');
|
|
73
|
+
const gistId = githubKey?.id;
|
|
74
|
+
if (gistId) {
|
|
75
|
+
await octokit.request('PATCH /gists/{gist_id}', {
|
|
76
|
+
gist_id: gistId,
|
|
77
|
+
files,
|
|
78
|
+
});
|
|
79
|
+
} else {
|
|
80
|
+
const response = await octokit.request('POST /gists', {
|
|
81
|
+
public: true,
|
|
82
|
+
files,
|
|
83
|
+
});
|
|
84
|
+
const gistId = response.data.id;
|
|
85
|
+
if (gistId) {
|
|
86
|
+
Obj.update(object, (object) => {
|
|
87
|
+
Obj.getMeta(object).keys.push({ source: 'github.com', id: gistId });
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
} finally {
|
|
92
|
+
setPublishing(false);
|
|
93
|
+
}
|
|
94
|
+
}, [object, githubToken]);
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div className='flex flex-col'>
|
|
98
|
+
<Form.Section label={t('script-publish-settings.label')} description={t('script-publish-settings.description')} />
|
|
99
|
+
|
|
100
|
+
{!githubToken && (
|
|
101
|
+
<div className='flex flex-col py-form-gap'>
|
|
102
|
+
<Message.Root valence='info'>
|
|
103
|
+
<Message.Title>{t('no-github-token.label')}</Message.Title>
|
|
104
|
+
</Message.Root>
|
|
105
|
+
<div className='flex pt-form-gap'>
|
|
106
|
+
<Button onClick={handleOpenTokenManager}>{t('open-token-manager.label')}</Button>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
)}
|
|
110
|
+
|
|
111
|
+
{githubToken && (
|
|
112
|
+
<div className='flex justify-end gap-2'>
|
|
113
|
+
{gistUrl && <Clipboard.IconButton value={gistUrl} />}
|
|
114
|
+
<Button disabled={publishing} onClick={handlePublish}>
|
|
115
|
+
{t('publish.label')}
|
|
116
|
+
</Button>
|
|
117
|
+
</div>
|
|
118
|
+
)}
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2026 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { Blueprint } from '@dxos/compute';
|
|
11
|
+
import { Script } from '@dxos/compute';
|
|
12
|
+
import { Operation } from '@dxos/compute';
|
|
13
|
+
import { Filter } from '@dxos/echo';
|
|
14
|
+
import { ClientPlugin } from '@dxos/plugin-client/testing';
|
|
15
|
+
import { initializeIdentity } from '@dxos/plugin-client/testing';
|
|
16
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
17
|
+
import { useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
18
|
+
import { ObjectProperties } from '@dxos/react-ui-form';
|
|
19
|
+
import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
20
|
+
import { Text } from '@dxos/schema';
|
|
21
|
+
|
|
22
|
+
import { createScript } from '#testing';
|
|
23
|
+
import { translations } from '#translations';
|
|
24
|
+
|
|
25
|
+
import { ScriptProperties } from './ScriptProperties';
|
|
26
|
+
|
|
27
|
+
type DefaultStoryProps = {};
|
|
28
|
+
|
|
29
|
+
const DefaultStory = (_: DefaultStoryProps) => {
|
|
30
|
+
const [space] = useSpaces();
|
|
31
|
+
const [script] = useQuery(space?.db, Filter.type(Script.Script));
|
|
32
|
+
if (!script) {
|
|
33
|
+
return <Loading />;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<ObjectProperties object={script}>
|
|
38
|
+
<ScriptProperties role='object-properties' subject={script} />
|
|
39
|
+
</ObjectProperties>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const meta = {
|
|
44
|
+
title: 'plugins/plugin-script/containers/ScriptProperties',
|
|
45
|
+
render: DefaultStory,
|
|
46
|
+
decorators: [
|
|
47
|
+
withTheme(),
|
|
48
|
+
withLayout({ layout: 'column' }),
|
|
49
|
+
withPluginManager({
|
|
50
|
+
plugins: [
|
|
51
|
+
...corePlugins(),
|
|
52
|
+
ClientPlugin({
|
|
53
|
+
types: [Script.Script, Operation.PersistentOperation, Blueprint.Blueprint, Text.Text],
|
|
54
|
+
onClientInitialized: ({ client }) =>
|
|
55
|
+
Effect.gen(function* () {
|
|
56
|
+
yield* initializeIdentity(client);
|
|
57
|
+
const [space] = client.spaces.get();
|
|
58
|
+
yield* Effect.promise(() => space.waitUntilReady());
|
|
59
|
+
createScript(space);
|
|
60
|
+
}),
|
|
61
|
+
}),
|
|
62
|
+
StorybookPlugin({}),
|
|
63
|
+
],
|
|
64
|
+
}),
|
|
65
|
+
],
|
|
66
|
+
parameters: {
|
|
67
|
+
layout: 'fullscreen',
|
|
68
|
+
translations,
|
|
69
|
+
},
|
|
70
|
+
} satisfies Meta<DefaultStoryProps>;
|
|
71
|
+
|
|
72
|
+
export default meta;
|
|
73
|
+
|
|
74
|
+
type Story = StoryObj<typeof meta>;
|
|
75
|
+
|
|
76
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2024 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { type Script } from '@dxos/compute';
|
|
9
|
+
|
|
10
|
+
import { BlueprintEditor } from './BlueprintEditor';
|
|
11
|
+
import { FunctionBinding } from './FunctionBinding';
|
|
12
|
+
import { FunctionPublishing } from './FunctionPublishing';
|
|
13
|
+
|
|
14
|
+
export type ScriptPropertiesProps = AppSurface.ObjectPropertiesProps<Script.Script>;
|
|
15
|
+
|
|
16
|
+
export const ScriptProperties = ({ subject: object }: ScriptPropertiesProps) => {
|
|
17
|
+
return (
|
|
18
|
+
<div className='flex flex-col py-form-gap gap-form-section-gap'>
|
|
19
|
+
<FunctionBinding object={object} />
|
|
20
|
+
<BlueprintEditor object={object} />
|
|
21
|
+
<FunctionPublishing object={object} />
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Script } from '@dxos/compute';
|
|
8
|
+
import { Context } from '@dxos/context';
|
|
9
|
+
import { Obj } from '@dxos/echo';
|
|
10
|
+
import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
|
|
11
|
+
import { Panel } from '@dxos/react-ui';
|
|
12
|
+
|
|
13
|
+
import { TestPanel } from '#components';
|
|
14
|
+
import { useDeployDeps } from '#hooks';
|
|
15
|
+
|
|
16
|
+
export type TestContainerProps = {
|
|
17
|
+
role: string;
|
|
18
|
+
script: Script.Script;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const TestContainer = ({ role, script }: TestContainerProps) => {
|
|
22
|
+
const { client, fn, existingFunctionId } = useDeployDeps({ script });
|
|
23
|
+
const spaceId = Obj.getDatabase(script)?.spaceId;
|
|
24
|
+
|
|
25
|
+
const functionsClient = useMemo(() => FunctionsServiceClient.fromClient(client), [client]);
|
|
26
|
+
|
|
27
|
+
const handleInvoke = useCallback(
|
|
28
|
+
async (input: unknown) => {
|
|
29
|
+
if (!fn) {
|
|
30
|
+
throw new Error('Function not deployed');
|
|
31
|
+
}
|
|
32
|
+
return functionsClient.invoke(Context.default(), fn, input, { spaceId });
|
|
33
|
+
},
|
|
34
|
+
[fn, functionsClient, spaceId],
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<Panel.Root role={role} className='dx-document'>
|
|
39
|
+
<Panel.Content asChild>
|
|
40
|
+
<TestPanel onInvoke={existingFunctionId ? handleInvoke : undefined} />
|
|
41
|
+
</Panel.Content>
|
|
42
|
+
</Panel.Root>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ComponentType, lazy } from 'react';
|
|
6
|
+
|
|
7
|
+
export const DeploymentDialog: ComponentType<any> = lazy(() => import('./DeploymentDialog'));
|
|
8
|
+
export const NotebookArticle: ComponentType<any> = lazy(() => import('./NotebookArticle'));
|
|
9
|
+
export const ScriptArticle: ComponentType<any> = lazy(() => import('./ScriptArticle'));
|
|
10
|
+
export const ScriptProperties: ComponentType<any> = lazy(() => import('./ScriptProperties'));
|
|
11
|
+
export const TestContainer: ComponentType<any> = lazy(() => import('./TestContainer'));
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe } from '@effect/vitest';
|
|
6
|
+
import { test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { Client } from '@dxos/client';
|
|
9
|
+
import { type Space } from '@dxos/client-protocol';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
11
|
+
import { configPreset } from '@dxos/config';
|
|
12
|
+
import { Context } from '@dxos/context';
|
|
13
|
+
import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
|
|
14
|
+
import { bundleFunction } from '@dxos/functions-runtime/native';
|
|
15
|
+
import { FunctionRuntimeKind } from '@dxos/protocols';
|
|
16
|
+
import { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
17
|
+
|
|
18
|
+
// To heavy to run in CI.
|
|
19
|
+
describe.skip('Function', { tags: ['functions-e2e'] }, () => {
|
|
20
|
+
const config = configPreset({ edge: 'local' });
|
|
21
|
+
|
|
22
|
+
test('bundle anthropic function', { timeout: 120_000 }, async () => {
|
|
23
|
+
await bundleFunction({
|
|
24
|
+
entryPoint: new URL('../templates/anthropic.ts', import.meta.url).pathname,
|
|
25
|
+
verbose: true,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('deploy empty function', { timeout: 120_000 }, async () => {
|
|
30
|
+
const { space, functionsServiceClient } = await setup();
|
|
31
|
+
|
|
32
|
+
await sync(space);
|
|
33
|
+
const func = await deployFunction(
|
|
34
|
+
space,
|
|
35
|
+
functionsServiceClient,
|
|
36
|
+
new URL('../templates/ping.ts', import.meta.url).pathname,
|
|
37
|
+
);
|
|
38
|
+
console.log(func);
|
|
39
|
+
throw new Error('test');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('deploy and invoke anthropic function', { timeout: 120_000 }, async () => {
|
|
43
|
+
const { space, functionsServiceClient } = await setup();
|
|
44
|
+
await sync(space);
|
|
45
|
+
const func = await deployFunction(
|
|
46
|
+
space,
|
|
47
|
+
functionsServiceClient,
|
|
48
|
+
new URL('../templates/anthropic.ts', import.meta.url).pathname,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const result = await functionsServiceClient.invoke(Context.default(), func, {
|
|
52
|
+
message: 'Hello, world!',
|
|
53
|
+
});
|
|
54
|
+
console.log(result);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const setup = async () => {
|
|
58
|
+
const client = await new Client({ config, types: [Operation.PersistentOperation] }).initialize();
|
|
59
|
+
await client.halo.createIdentity();
|
|
60
|
+
|
|
61
|
+
const space = await client.spaces.create();
|
|
62
|
+
await space.waitUntilReady();
|
|
63
|
+
await space.internal.setEdgeReplicationPreference(EdgeReplicationSetting.ENABLED);
|
|
64
|
+
|
|
65
|
+
const functionsServiceClient = FunctionsServiceClient.fromClient(client);
|
|
66
|
+
return { client, space, functionsServiceClient };
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const sync = async (space: Space) => {
|
|
70
|
+
await space.db.flush();
|
|
71
|
+
await space.internal.syncToEdge({
|
|
72
|
+
onProgress: (state) =>
|
|
73
|
+
console.log(state ? `${state.unsyncedDocumentCount} documents syncing...` : 'connecting to edge...'),
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const deployFunction = async (space: Space, functionsServiceClient: FunctionsServiceClient, entryPoint: string) => {
|
|
78
|
+
const artifact = await bundleFunction({
|
|
79
|
+
entryPoint,
|
|
80
|
+
verbose: true,
|
|
81
|
+
});
|
|
82
|
+
const func = await functionsServiceClient.deploy(Context.default(), {
|
|
83
|
+
version: '0.0.1',
|
|
84
|
+
ownerPublicKey: space.key,
|
|
85
|
+
entryPoint: artifact.entryPoint,
|
|
86
|
+
assets: artifact.assets,
|
|
87
|
+
runtime: FunctionRuntimeKind.enums.WORKER_LOADER,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
space.db.add(func);
|
|
91
|
+
return func;
|
|
92
|
+
};
|
|
93
|
+
});
|