@dxos/plugin-script 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b
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/README.md +15 -13
- package/dist/lib/{browser/chunk-BU6CGVU2.mjs → neutral/DeploymentDialog-6DBF3V6C.mjs} +25 -50
- package/dist/lib/neutral/DeploymentDialog-6DBF3V6C.mjs.map +7 -0
- package/dist/lib/{browser/NotebookContainer-UQ4I24R6.mjs → neutral/NotebookContainer-FIAQI3A2.mjs} +60 -145
- package/dist/lib/neutral/NotebookContainer-FIAQI3A2.mjs.map +7 -0
- package/dist/lib/neutral/ScriptContainer-2OPBAXFB.mjs +79 -0
- package/dist/lib/neutral/ScriptContainer-2OPBAXFB.mjs.map +7 -0
- package/dist/lib/neutral/ScriptPlugin.mjs +39 -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/ScriptPluginSettings-T4JMUSHN.mjs +31 -0
- package/dist/lib/neutral/ScriptPluginSettings-T4JMUSHN.mjs.map +7 -0
- package/dist/lib/neutral/ScriptProperties-F6NE6M4H.mjs +296 -0
- package/dist/lib/neutral/ScriptProperties-F6NE6M4H.mjs.map +7 -0
- package/dist/lib/neutral/TestContainer-JNFPLAJX.mjs +44 -0
- package/dist/lib/neutral/TestContainer-JNFPLAJX.mjs.map +7 -0
- package/dist/lib/neutral/access-token-created-ENMCEGVU.mjs +34 -0
- package/dist/lib/neutral/access-token-created-ENMCEGVU.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-2DMPFVUM.mjs +8 -0
- package/dist/lib/neutral/chunk-2DMPFVUM.mjs.map +7 -0
- package/dist/lib/neutral/chunk-4RJALG6K.mjs +151 -0
- package/dist/lib/neutral/chunk-4RJALG6K.mjs.map +7 -0
- package/dist/lib/neutral/chunk-B4FVQEHV.mjs +8 -0
- package/dist/lib/neutral/chunk-B4FVQEHV.mjs.map +7 -0
- package/dist/lib/neutral/chunk-BDRB6ZX2.mjs +52 -0
- package/dist/lib/neutral/chunk-BDRB6ZX2.mjs.map +7 -0
- package/dist/lib/{browser/chunk-4N5TLXEJ.mjs → neutral/chunk-BUKQITZT.mjs} +29 -29
- package/dist/lib/neutral/chunk-BUKQITZT.mjs.map +7 -0
- package/dist/lib/neutral/chunk-D7DFASAE.mjs +52 -0
- package/dist/lib/neutral/chunk-D7DFASAE.mjs.map +7 -0
- package/dist/lib/neutral/chunk-MI6X5CTJ.mjs +336 -0
- package/dist/lib/neutral/chunk-MI6X5CTJ.mjs.map +7 -0
- package/dist/lib/neutral/chunk-P2F3STZN.mjs +8 -0
- package/dist/lib/neutral/chunk-P2F3STZN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-PDB6UOSB.mjs +125 -0
- package/dist/lib/neutral/chunk-PDB6UOSB.mjs.map +7 -0
- package/dist/lib/{browser/chunk-WYR4QHPE.mjs → neutral/chunk-UYR3YH4Q.mjs} +3 -3
- package/dist/lib/{browser/chunk-WYR4QHPE.mjs.map → neutral/chunk-UYR3YH4Q.mjs.map} +3 -3
- package/dist/lib/{browser/compiler-VPUVTFQD.mjs → neutral/compiler-SMVIP5UN.mjs} +27 -87
- package/dist/lib/neutral/compiler-SMVIP5UN.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +719 -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-OZRIZ7RN.mjs +44 -0
- package/dist/lib/neutral/create-OZRIZ7RN.mjs.map +7 -0
- package/dist/lib/neutral/create-object-F2NWICFV.mjs +44 -0
- package/dist/lib/neutral/create-object-F2NWICFV.mjs.map +7 -0
- package/dist/lib/neutral/create-script-VBA3SLSU.mjs +45 -0
- package/dist/lib/neutral/create-script-VBA3SLSU.mjs.map +7 -0
- package/dist/lib/neutral/delete-PAUWA2QM.mjs +21 -0
- package/dist/lib/neutral/delete-PAUWA2QM.mjs.map +7 -0
- package/dist/lib/neutral/deploy-CXVW54JJ.mjs +62 -0
- package/dist/lib/neutral/deploy-CXVW54JJ.mjs.map +7 -0
- package/dist/lib/{browser/chunk-WWCDIB6Z.mjs → neutral/hooks/index.mjs} +110 -298
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +41 -0
- package/dist/lib/neutral/inspect-invocations-LEOEP5I2.mjs +59 -0
- package/dist/lib/neutral/inspect-invocations-LEOEP5I2.mjs.map +7 -0
- package/dist/lib/neutral/install-function-5N24Q45W.mjs +51 -0
- package/dist/lib/neutral/install-function-5N24Q45W.mjs.map +7 -0
- package/dist/lib/neutral/invoke-5QVEZ3X5.mjs +33 -0
- package/dist/lib/neutral/invoke-5QVEZ3X5.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-OTCWYDFI.mjs +18 -0
- package/dist/lib/neutral/operation-handler-OTCWYDFI.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-FVD7NYPA.mjs +30 -0
- package/dist/lib/neutral/query-deployed-functions-FVD7NYPA.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-JH2AOK7V.mjs +117 -0
- package/dist/lib/neutral/react-surface-JH2AOK7V.mjs.map +7 -0
- package/dist/lib/neutral/read-FFOSK6A3.mjs +26 -0
- package/dist/lib/neutral/read-FFOSK6A3.mjs.map +7 -0
- package/dist/lib/{browser/settings-5SF77MRH.mjs → neutral/settings-VJBW4OMK.mjs} +6 -12
- package/dist/lib/neutral/settings-VJBW4OMK.mjs.map +7 -0
- package/dist/lib/{browser → neutral}/templates/index.mjs +1 -1
- package/dist/lib/neutral/translations.mjs +104 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +17 -0
- package/dist/lib/neutral/update-PJS5GG3Y.mjs +63 -0
- package/dist/lib/neutral/update-PJS5GG3Y.mjs.map +7 -0
- package/dist/types/src/ScriptPlugin.d.ts +1 -0
- 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/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 +141 -0
- package/dist/types/src/blueprints/functions/definitions.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/delete.d.ts +18 -0
- package/dist/types/src/blueprints/functions/delete.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/deploy.d.ts +22 -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 +29 -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 +22 -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 +22 -0
- package/dist/types/src/blueprints/functions/read.d.ts.map +1 -0
- package/dist/types/src/blueprints/functions/update.d.ts +27 -0
- package/dist/types/src/blueprints/functions/update.d.ts.map +1 -0
- package/dist/types/src/blueprints/index.d.ts +1 -1
- package/dist/types/src/blueprints/index.d.ts.map +1 -1
- package/dist/types/src/blueprints/script-blueprint.d.ts +3 -21
- package/dist/types/src/blueprints/script-blueprint.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/{artifact-definition/artifact-definition.d.ts → artifact-definition.d.ts} +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts +6 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +6 -0
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -0
- 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 -6
- 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 +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +7 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/{FrameContainer/FrameContainer.d.ts → FramePanel/FramePanel.d.ts} +3 -3
- package/dist/types/src/components/FramePanel/FramePanel.d.ts.map +1 -0
- package/dist/types/src/components/FramePanel/index.d.ts +2 -0
- package/dist/types/src/components/FramePanel/index.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookCell.d.ts +1 -1
- 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 +4 -2
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -1
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +219 -228
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -1
- package/dist/types/src/components/QueryEditor/QueryEditor.d.ts.map +1 -1
- package/dist/types/src/components/QueryEditor/QueryEditor.stories.d.ts.map +1 -1
- 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 +7 -5
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +219 -228
- 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 +5 -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 +6 -5
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/constants.d.ts +2 -0
- package/dist/types/src/constants.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/DeploymentDialog/DeploymentDialog.d.ts +0 -2
- 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/{components → containers}/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- 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/NotebookContainer/NotebookContainer.d.ts +7 -0
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookContainer/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/NotebookContainer/index.d.ts +2 -0
- package/dist/types/src/containers/NotebookContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.d.ts +10 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.stories.d.ts +242 -0
- package/dist/types/src/containers/ScriptContainer/ScriptContainer.stories.d.ts.map +1 -0
- package/dist/types/src/containers/ScriptContainer/index.d.ts +2 -0
- package/dist/types/src/containers/ScriptContainer/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/{components/TestPanel → containers/TestContainer}/TestContainer.d.ts +1 -1
- 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/hooks/deploy.d.ts +18 -5
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +2 -1
- package/dist/types/src/hooks/format.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts +2 -1
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCompiler.d.ts.map +1 -1
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -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/notebook/compute-graph.d.ts +1 -1
- package/dist/types/src/notebook/compute-graph.d.ts.map +1 -1
- package/dist/types/src/notebook/eval.d.ts.map +1 -1
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -1
- package/dist/types/src/operations/access-token-created.d.ts +5 -0
- package/dist/types/src/operations/access-token-created.d.ts.map +1 -0
- 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 +4 -5
- package/dist/types/src/templates/anthropic.d.ts.map +1 -1
- package/dist/types/src/templates/chat.d.ts.map +1 -1
- package/dist/types/src/templates/chess-bot.d.ts +8 -12
- package/dist/types/src/templates/chess-bot.d.ts.map +1 -1
- package/dist/types/src/templates/commentary.d.ts +8 -11
- package/dist/types/src/templates/commentary.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/email.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts +3 -2
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts +3 -2
- 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 +29 -29
- package/dist/types/src/templates/index.d.ts.map +1 -1
- package/dist/types/src/templates/ping.d.ts +2 -1
- 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/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 -92
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +47 -27
- package/dist/types/src/types/Notebook.d.ts.map +1 -1
- 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 +4 -4
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +1 -5
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts +2 -2
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +2 -2
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +154 -105
- package/src/ScriptPlugin.node.ts +21 -0
- package/src/ScriptPlugin.test.ts +31 -0
- package/src/ScriptPlugin.tsx +11 -43
- package/src/blueprints/functions/create.ts +47 -0
- package/src/blueprints/functions/definitions.ts +323 -0
- package/src/blueprints/functions/delete.ts +23 -0
- package/src/blueprints/functions/deploy.ts +70 -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 +35 -0
- package/src/blueprints/functions/query-deployed-functions.ts +31 -0
- package/src/blueprints/functions/read.ts +29 -0
- package/src/blueprints/functions/update.ts +68 -0
- package/src/blueprints/index.ts +1 -1
- package/src/blueprints/script-blueprint.ts +40 -9
- package/src/capabilities/app-graph-builder.ts +47 -0
- package/src/capabilities/{artifact-definition/artifact-definition.ts → artifact-definition.ts} +4 -5
- package/src/capabilities/blueprint-definition.ts +19 -0
- package/src/capabilities/{compiler/compiler.ts → compiler.ts} +17 -9
- package/src/capabilities/create-object.ts +48 -0
- package/src/capabilities/index.ts +14 -6
- package/src/capabilities/node.ts +16 -0
- package/src/capabilities/operation-handler.ts +21 -0
- package/src/capabilities/react-surface.tsx +130 -0
- package/src/capabilities/{settings/settings.ts → settings.ts} +4 -4
- package/src/compiler/compiler.ts +8 -1
- package/src/components/{FrameContainer/FrameContainer.tsx → FramePanel/FramePanel.tsx} +4 -5
- package/src/components/{FrameContainer → FramePanel}/index.ts +1 -1
- package/src/components/NotebookStack/NotebookCell.tsx +30 -21
- package/src/components/NotebookStack/NotebookMenu.tsx +7 -7
- package/src/components/NotebookStack/NotebookStack.stories.tsx +9 -11
- package/src/components/NotebookStack/NotebookStack.tsx +27 -16
- package/src/components/QueryEditor/QueryEditor.stories.tsx +18 -22
- 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 +8 -9
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +24 -26
- package/src/components/TestPanel/TestPanel.tsx +95 -181
- package/src/components/TestPanel/index.ts +0 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +17 -15
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +26 -19
- package/src/components/index.ts +6 -7
- package/src/constants.ts +7 -0
- package/src/{components → containers}/DeploymentDialog/DeploymentDialog.stories.tsx +8 -7
- package/src/{components → containers}/DeploymentDialog/DeploymentDialog.tsx +27 -31
- package/src/containers/DeploymentDialog/index.ts +5 -0
- package/src/{components → containers/NotebookContainer}/NotebookContainer.stories.tsx +22 -24
- package/src/{components → containers/NotebookContainer}/NotebookContainer.tsx +60 -77
- package/src/containers/NotebookContainer/index.ts +5 -0
- package/src/containers/ScriptContainer/ScriptContainer.stories.tsx +106 -0
- package/src/{components → containers/ScriptContainer}/ScriptContainer.tsx +28 -27
- package/src/containers/ScriptContainer/index.ts +5 -0
- package/src/containers/ScriptProperties/BlueprintEditor.tsx +101 -0
- package/src/containers/ScriptProperties/FunctionBinding.tsx +83 -0
- package/src/containers/ScriptProperties/FunctionPublishing.tsx +121 -0
- package/src/containers/ScriptProperties/ScriptProperties.stories.tsx +75 -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 +7 -6
- package/src/e2e/deploy.test.ts +7 -5
- package/src/hooks/deploy.ts +15 -13
- package/src/hooks/format.ts +6 -5
- package/src/hooks/template.ts +9 -8
- package/src/hooks/useCompiler.ts +3 -2
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +4 -3
- package/src/index.ts +2 -4
- package/src/meta.ts +2 -2
- package/src/notebook/compute-graph.test.ts +7 -7
- package/src/notebook/compute-graph.ts +1 -1
- package/src/notebook/vfs-parser.ts +10 -3
- package/src/operations/access-token-created.ts +37 -0
- package/src/operations/create-script.ts +46 -0
- package/src/operations/index.ts +10 -0
- package/src/plugin.ts +11 -0
- package/src/templates/anthropic.ts +19 -12
- package/src/templates/chat.ts +1 -1
- package/src/templates/chess-bot.ts +42 -37
- package/src/templates/commentary.ts +182 -163
- package/src/templates/data-generator.ts +1 -1
- package/src/templates/discord.ts +3 -3
- package/src/templates/forex-effect.ts +30 -19
- package/src/templates/forex.ts +24 -15
- package/src/templates/gmail.ts +4 -4
- package/src/templates/index.ts +18 -18
- package/src/templates/ping.ts +16 -8
- package/src/testing/index.ts +2 -1
- package/src/testing/simulator.test.ts +3 -4
- package/src/testing/{data.ts → test-notebook.ts} +11 -12
- package/src/testing/test-script.ts +29 -0
- package/src/translations.ts +86 -87
- package/src/types/Notebook.ts +11 -7
- 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 +5 -4
- package/src/types/types.ts +1 -11
- package/src/util/deploy.ts +13 -11
- package/src/util/functions.ts +9 -8
- package/dist/lib/browser/DeploymentDialog-XUAFCNI7.mjs +0 -14
- package/dist/lib/browser/NotebookContainer-UQ4I24R6.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-NB76645V.mjs +0 -149
- package/dist/lib/browser/ScriptContainer-NB76645V.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs +0 -69
- package/dist/lib/browser/app-graph-builder-66ZDI72K.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs +0 -18
- package/dist/lib/browser/blueprint-definition-5RFKE7VK.mjs.map +0 -7
- package/dist/lib/browser/blueprints/index.mjs +0 -8
- package/dist/lib/browser/chunk-3BSF5BIA.mjs +0 -113
- package/dist/lib/browser/chunk-3BSF5BIA.mjs.map +0 -7
- package/dist/lib/browser/chunk-4N5TLXEJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-BKGEAUUH.mjs +0 -270
- package/dist/lib/browser/chunk-BKGEAUUH.mjs.map +0 -7
- package/dist/lib/browser/chunk-BU6CGVU2.mjs.map +0 -7
- package/dist/lib/browser/chunk-F3QKSKSF.mjs +0 -35
- package/dist/lib/browser/chunk-F3QKSKSF.mjs.map +0 -7
- package/dist/lib/browser/chunk-I7CSE6T3.mjs +0 -110
- package/dist/lib/browser/chunk-I7CSE6T3.mjs.map +0 -7
- package/dist/lib/browser/chunk-LYMPME7J.mjs +0 -609
- package/dist/lib/browser/chunk-LYMPME7J.mjs.map +0 -7
- package/dist/lib/browser/chunk-WWCDIB6Z.mjs.map +0 -7
- package/dist/lib/browser/compiler-VPUVTFQD.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -245
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs +0 -83
- package/dist/lib/browser/operation-resolver-NYDY7GDT.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FYOQSC6S.mjs +0 -140
- package/dist/lib/browser/react-surface-FYOQSC6S.mjs.map +0 -7
- package/dist/lib/browser/settings-5SF77MRH.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -18
- package/dist/lib/node-esm/DeploymentDialog-GGWDQMEB.mjs +0 -15
- package/dist/lib/node-esm/DeploymentDialog-GGWDQMEB.mjs.map +0 -7
- package/dist/lib/node-esm/NotebookContainer-DQGZ6QHI.mjs +0 -846
- package/dist/lib/node-esm/NotebookContainer-DQGZ6QHI.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs +0 -150
- package/dist/lib/node-esm/ScriptContainer-PCNJFUWX.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs +0 -70
- package/dist/lib/node-esm/app-graph-builder-IGAZTJ45.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs +0 -19
- package/dist/lib/node-esm/blueprint-definition-EYL5GNDC.mjs.map +0 -7
- package/dist/lib/node-esm/blueprints/index.mjs +0 -9
- package/dist/lib/node-esm/chunk-3CKQUF55.mjs +0 -610
- package/dist/lib/node-esm/chunk-3CKQUF55.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3QBXN6QC.mjs +0 -271
- package/dist/lib/node-esm/chunk-3QBXN6QC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5HSJPAK7.mjs +0 -33
- package/dist/lib/node-esm/chunk-5HSJPAK7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ECRSTVR6.mjs +0 -558
- package/dist/lib/node-esm/chunk-ECRSTVR6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KRVL7UYI.mjs +0 -114
- package/dist/lib/node-esm/chunk-KRVL7UYI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs +0 -112
- package/dist/lib/node-esm/chunk-SLU3KRV3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U6PXM2HT.mjs +0 -138
- package/dist/lib/node-esm/chunk-U6PXM2HT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-V37R7KB5.mjs +0 -107
- package/dist/lib/node-esm/chunk-V37R7KB5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs +0 -36
- package/dist/lib/node-esm/chunk-Y3G5NCTP.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-WUOSY6MS.mjs +0 -162
- package/dist/lib/node-esm/compiler-WUOSY6MS.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -246
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs +0 -84
- package/dist/lib/node-esm/operation-resolver-AJNJXGCE.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-LREMOVNJ.mjs +0 -141
- package/dist/lib/node-esm/react-surface-LREMOVNJ.mjs.map +0 -7
- package/dist/lib/node-esm/settings-ILI762CY.mjs +0 -37
- package/dist/lib/node-esm/settings-ILI762CY.mjs.map +0 -7
- package/dist/lib/node-esm/templates/index.mjs +0 -11
- package/dist/lib/node-esm/types/index.mjs +0 -19
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition/artifact-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/artifact-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/artifact-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts +0 -10
- package/dist/types/src/capabilities/blueprint-definition/blueprint-definition.d.ts.map +0 -1
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts +0 -3
- package/dist/types/src/capabilities/blueprint-definition/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/compiler/compiler.d.ts +0 -6
- package/dist/types/src/capabilities/compiler/compiler.d.ts.map +0 -1
- package/dist/types/src/capabilities/compiler/index.d.ts +0 -3
- package/dist/types/src/capabilities/compiler/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/index.d.ts +0 -7
- package/dist/types/src/capabilities/settings/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/settings/settings.d.ts +0 -10
- package/dist/types/src/capabilities/settings/settings.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 -249
- 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.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 -8
- package/dist/types/src/components/NotebookContainer.d.ts.map +0 -1
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/ScriptContainer.d.ts +0 -11
- 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 -8
- 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.map +0 -1
- package/dist/types/src/testing/data.d.ts +0 -3
- package/dist/types/src/testing/data.d.ts.map +0 -1
- package/dist/types/src/types/actions.d.ts +0 -40
- package/dist/types/src/types/actions.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -12
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/dist/types/src/types/events.d.ts +0 -5
- package/dist/types/src/types/events.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -56
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/artifact-definition/index.ts +0 -7
- package/src/capabilities/blueprint-definition/blueprint-definition.ts +0 -24
- package/src/capabilities/blueprint-definition/index.ts +0 -7
- package/src/capabilities/compiler/index.ts +0 -7
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -75
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -119
- package/src/capabilities/settings/index.ts +0 -7
- package/src/components/DeploymentDialog/index.ts +0 -9
- package/src/components/FrameContainer/frame.html +0 -25
- package/src/components/FrameContainer/frame.tsx +0 -51
- package/src/components/Settings/ScriptObjectSettings.tsx +0 -309
- package/src/components/Settings/ScriptPluginSettings.tsx +0 -66
- package/src/components/Settings/index.ts +0 -6
- package/src/components/TestPanel/TestContainer.tsx +0 -27
- package/src/types/actions.ts +0 -45
- package/src/types/capabilities.ts +0 -17
- package/src/types/events.ts +0 -11
- /package/dist/lib/{browser → neutral}/blueprints/index.mjs.map +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs.map +0 -0
- /package/dist/lib/{browser/templates → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{browser/DeploymentDialog-XUAFCNI7.mjs.map → neutral/meta.mjs.map} +0 -0
- /package/dist/lib/{browser/types → neutral/operations}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/blueprints → neutral/templates}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/templates → neutral/types}/index.mjs.map +0 -0
- /package/dist/types/src/{components → containers/NotebookContainer}/NotebookContainer.stories.d.ts +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
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) => bp.key === blueprintKey);
|
|
32
|
+
|
|
33
|
+
useAsyncEffect(async () => {
|
|
34
|
+
if (!existingBlueprint) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const source = await existingBlueprint.instructions.source.load();
|
|
39
|
+
setInstructions(source.content ?? '');
|
|
40
|
+
}, [existingBlueprint]);
|
|
41
|
+
|
|
42
|
+
const handleSave = useCallback(async () => {
|
|
43
|
+
if (!db) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setCreating(true);
|
|
48
|
+
try {
|
|
49
|
+
if (existingBlueprint) {
|
|
50
|
+
const text = await existingBlueprint.instructions.source.load();
|
|
51
|
+
Obj.update(text, (text) => {
|
|
52
|
+
text.content = instructions;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
if (fn?.key) {
|
|
56
|
+
const toolId = ToolId.make(fn.key);
|
|
57
|
+
if (!existingBlueprint.tools?.includes(toolId)) {
|
|
58
|
+
Obj.update(existingBlueprint, (existingBlueprint) => {
|
|
59
|
+
existingBlueprint.tools = [...(existingBlueprint.tools ?? []), toolId];
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} else if (fn?.key) {
|
|
64
|
+
db.add(
|
|
65
|
+
Blueprint.make({
|
|
66
|
+
key: blueprintKey,
|
|
67
|
+
name: object.name ?? 'Script',
|
|
68
|
+
instructions: Template.make({ source: instructions }),
|
|
69
|
+
tools: [ToolId.make(fn.key)],
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
await db.flush();
|
|
74
|
+
} finally {
|
|
75
|
+
setCreating(false);
|
|
76
|
+
}
|
|
77
|
+
}, [db, existingBlueprint, fn, blueprintKey, object.name, instructions]);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div className='flex flex-col'>
|
|
81
|
+
<Form.Section label={t('blueprint-editor.label')} description={t('blueprint-editor.description')} />
|
|
82
|
+
|
|
83
|
+
<Input.Root>
|
|
84
|
+
<Input.Label>{t('blueprint-instructions.label')}</Input.Label>
|
|
85
|
+
<Input.TextArea
|
|
86
|
+
placeholder={t('blueprint-instructions.placeholder')}
|
|
87
|
+
rows={6}
|
|
88
|
+
value={instructions}
|
|
89
|
+
onChange={(event) => setInstructions(event.target.value)}
|
|
90
|
+
classNames='resize-y'
|
|
91
|
+
/>
|
|
92
|
+
</Input.Root>
|
|
93
|
+
|
|
94
|
+
<div className='pt-2'>
|
|
95
|
+
<Button disabled={(!existingBlueprint && !fn?.key) || creating} onClick={handleSave}>
|
|
96
|
+
{t(existingBlueprint ? 'update-blueprint.label' : 'create-blueprint.label')}
|
|
97
|
+
</Button>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
@@ -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,75 @@
|
|
|
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 { ClientPlugin } from '@dxos/plugin-client/plugin';
|
|
14
|
+
import { initializeIdentity } from '@dxos/plugin-client/testing';
|
|
15
|
+
import { StorybookPlugin, corePlugins } from '@dxos/plugin-testing';
|
|
16
|
+
import { Filter, useQuery, useSpaces } from '@dxos/react-client/echo';
|
|
17
|
+
import { ObjectProperties } from '@dxos/react-ui-form';
|
|
18
|
+
import { Loading, withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
19
|
+
import { Text } from '@dxos/schema';
|
|
20
|
+
|
|
21
|
+
import { createScript } from '#testing';
|
|
22
|
+
import { translations } from '#translations';
|
|
23
|
+
|
|
24
|
+
import { ScriptProperties } from './ScriptProperties';
|
|
25
|
+
|
|
26
|
+
type DefaultStoryProps = {};
|
|
27
|
+
|
|
28
|
+
const DefaultStory = (_: DefaultStoryProps) => {
|
|
29
|
+
const [space] = useSpaces();
|
|
30
|
+
const [script] = useQuery(space?.db, Filter.type(Script.Script));
|
|
31
|
+
if (!script) {
|
|
32
|
+
return <Loading />;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<ObjectProperties object={script}>
|
|
37
|
+
<ScriptProperties role='object-properties' subject={script} />
|
|
38
|
+
</ObjectProperties>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const meta = {
|
|
43
|
+
title: 'plugins/plugin-script/containers/ScriptProperties',
|
|
44
|
+
render: DefaultStory,
|
|
45
|
+
decorators: [
|
|
46
|
+
withTheme(),
|
|
47
|
+
withLayout({ layout: 'column' }),
|
|
48
|
+
withPluginManager({
|
|
49
|
+
plugins: [
|
|
50
|
+
...corePlugins(),
|
|
51
|
+
ClientPlugin({
|
|
52
|
+
types: [Script.Script, Operation.PersistentOperation, Blueprint.Blueprint, Text.Text],
|
|
53
|
+
onClientInitialized: ({ client }) =>
|
|
54
|
+
Effect.gen(function* () {
|
|
55
|
+
yield* initializeIdentity(client);
|
|
56
|
+
const [space] = client.spaces.get();
|
|
57
|
+
yield* Effect.promise(() => space.waitUntilReady());
|
|
58
|
+
createScript(space);
|
|
59
|
+
}),
|
|
60
|
+
}),
|
|
61
|
+
StorybookPlugin({}),
|
|
62
|
+
],
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
parameters: {
|
|
66
|
+
layout: 'fullscreen',
|
|
67
|
+
translations,
|
|
68
|
+
},
|
|
69
|
+
} satisfies Meta<DefaultStoryProps>;
|
|
70
|
+
|
|
71
|
+
export default meta;
|
|
72
|
+
|
|
73
|
+
type Story = StoryObj<typeof meta>;
|
|
74
|
+
|
|
75
|
+
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 { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
|
|
10
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
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 space = getSpace(script);
|
|
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: space?.id });
|
|
33
|
+
},
|
|
34
|
+
[fn, functionsClient, space?.id],
|
|
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 NotebookContainer: ComponentType<any> = lazy(() => import('./NotebookContainer'));
|
|
9
|
+
export const ScriptContainer: ComponentType<any> = lazy(() => import('./ScriptContainer'));
|
|
10
|
+
export const ScriptProperties: ComponentType<any> = lazy(() => import('./ScriptProperties'));
|
|
11
|
+
export const TestContainer: ComponentType<any> = lazy(() => import('./TestContainer'));
|
package/src/e2e/ai.test.ts
CHANGED
|
@@ -7,15 +7,16 @@ import { test } from 'vitest';
|
|
|
7
7
|
|
|
8
8
|
import { Client } from '@dxos/client';
|
|
9
9
|
import { type Space } from '@dxos/client-protocol';
|
|
10
|
+
import { Operation } from '@dxos/compute';
|
|
10
11
|
import { configPreset } from '@dxos/config';
|
|
11
|
-
import {
|
|
12
|
+
import { Context } from '@dxos/context';
|
|
12
13
|
import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
|
|
13
14
|
import { bundleFunction } from '@dxos/functions-runtime/native';
|
|
14
15
|
import { FunctionRuntimeKind } from '@dxos/protocols';
|
|
15
16
|
import { EdgeReplicationSetting } from '@dxos/protocols/proto/dxos/echo/metadata';
|
|
16
17
|
|
|
17
18
|
// To heavy to run in CI.
|
|
18
|
-
describe.
|
|
19
|
+
describe.skip('Function', { tags: ['functions-e2e'] }, () => {
|
|
19
20
|
const config = configPreset({ edge: 'local' });
|
|
20
21
|
|
|
21
22
|
test('bundle anthropic function', { timeout: 120_000 }, async () => {
|
|
@@ -47,14 +48,14 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e')).skip('Functi
|
|
|
47
48
|
new URL('../templates/anthropic.ts', import.meta.url).pathname,
|
|
48
49
|
);
|
|
49
50
|
|
|
50
|
-
const result = await functionsServiceClient.invoke(func, {
|
|
51
|
+
const result = await functionsServiceClient.invoke(Context.default(), func, {
|
|
51
52
|
message: 'Hello, world!',
|
|
52
53
|
});
|
|
53
54
|
console.log(result);
|
|
54
55
|
});
|
|
55
56
|
|
|
56
57
|
const setup = async () => {
|
|
57
|
-
const client = await new Client({ config, types: [
|
|
58
|
+
const client = await new Client({ config, types: [Operation.PersistentOperation] }).initialize();
|
|
58
59
|
await client.halo.createIdentity();
|
|
59
60
|
|
|
60
61
|
const space = await client.spaces.create();
|
|
@@ -66,7 +67,7 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e')).skip('Functi
|
|
|
66
67
|
};
|
|
67
68
|
|
|
68
69
|
const sync = async (space: Space) => {
|
|
69
|
-
await space.db.flush(
|
|
70
|
+
await space.db.flush();
|
|
70
71
|
await space.internal.syncToEdge({
|
|
71
72
|
onProgress: (state) =>
|
|
72
73
|
console.log(state ? `${state.unsyncedDocumentCount} documents syncing...` : 'connecting to edge...'),
|
|
@@ -78,7 +79,7 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e')).skip('Functi
|
|
|
78
79
|
entryPoint,
|
|
79
80
|
verbose: true,
|
|
80
81
|
});
|
|
81
|
-
const func = await functionsServiceClient.deploy({
|
|
82
|
+
const func = await functionsServiceClient.deploy(Context.default(), {
|
|
82
83
|
version: '0.0.1',
|
|
83
84
|
ownerPublicKey: space.key,
|
|
84
85
|
entryPoint: artifact.entryPoint,
|
package/src/e2e/deploy.test.ts
CHANGED
|
@@ -3,18 +3,20 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { readFile } from 'node:fs/promises';
|
|
6
|
-
|
|
7
6
|
import { describe, expect, test } from 'vitest';
|
|
8
7
|
|
|
9
8
|
import { Client, type Config } from '@dxos/client';
|
|
10
9
|
import { createEdgeIdentity } from '@dxos/client/edge';
|
|
11
10
|
import { configPreset } from '@dxos/config';
|
|
11
|
+
import { Context } from '@dxos/context';
|
|
12
12
|
import { bundleFunction } from '@dxos/functions-runtime/bundler';
|
|
13
13
|
import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
|
|
14
14
|
import { invariant } from '@dxos/invariant';
|
|
15
15
|
import { log } from '@dxos/log';
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// TODO(wittjosiah): Re-enable once @dxos/compute.js is available at the R2 dev bucket
|
|
18
|
+
// (https://pub-5745ae82e450484aa28f75fc6a175935.r2.dev/dev/@dxos/compute.js currently 404s).
|
|
19
|
+
describe.skip('Functions deployment', { tags: ['functions-e2e'] }, () => {
|
|
18
20
|
test('deploys FOREX (effect) function and invokes it via EDGE (main)', { timeout: 120_000 }, async () => {
|
|
19
21
|
const config = configPreset({ edge: 'main' });
|
|
20
22
|
await testDeploy(config);
|
|
@@ -42,7 +44,7 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('Functions d
|
|
|
42
44
|
}
|
|
43
45
|
const functionsServiceClient = FunctionsServiceClient.fromClient(client);
|
|
44
46
|
|
|
45
|
-
const func = await functionsServiceClient.deploy({
|
|
47
|
+
const func = await functionsServiceClient.deploy(Context.default(), {
|
|
46
48
|
ownerPublicKey: space.key,
|
|
47
49
|
version: '0.0.1',
|
|
48
50
|
entryPoint: buildResult.entryPoint,
|
|
@@ -50,12 +52,12 @@ describe.runIf(process.env.DX_TEST_TAGS?.includes('functions-e2e'))('Functions d
|
|
|
50
52
|
});
|
|
51
53
|
|
|
52
54
|
// Invoke deployed function via EDGE directly.
|
|
53
|
-
const edgeClient = client.edge;
|
|
55
|
+
const edgeClient = client.edge.http;
|
|
54
56
|
invariant(edgeClient, 'edgeClient is required');
|
|
55
57
|
edgeClient.setIdentity(createEdgeIdentity(client));
|
|
56
58
|
|
|
57
59
|
const input = { from: 'USD', to: 'EUR' };
|
|
58
|
-
const result = await functionsServiceClient.invoke(func, input);
|
|
60
|
+
const result = await functionsServiceClient.invoke(Context.default(), func, input);
|
|
59
61
|
log.info('>>> result', { result, func });
|
|
60
62
|
const resultNumber = Number(result);
|
|
61
63
|
expect(resultNumber).toBeGreaterThan(0);
|
package/src/hooks/deploy.ts
CHANGED
|
@@ -4,16 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
+
import { Script, Operation } from '@dxos/compute';
|
|
7
8
|
import { Obj, Query, Ref } from '@dxos/echo';
|
|
8
|
-
import {
|
|
9
|
+
import { getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
9
10
|
import { log } from '@dxos/log';
|
|
10
11
|
import { type Client, useClient } from '@dxos/react-client';
|
|
11
12
|
import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
12
13
|
import { type TFunction } from '@dxos/react-ui';
|
|
13
14
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
14
|
-
import {
|
|
15
|
+
import { messageValence } from '@dxos/ui-theme';
|
|
16
|
+
|
|
17
|
+
import { meta } from '#meta';
|
|
15
18
|
|
|
16
|
-
import { meta } from '../meta';
|
|
17
19
|
import { deployScript, getFunctionUrl, isScriptDeployed } from '../util';
|
|
18
20
|
|
|
19
21
|
export type DeployActionProperties = { type: 'deploy' } | { type: 'copy' };
|
|
@@ -30,7 +32,7 @@ import { type ScriptToolbarStateStore } from './useToolbarState';
|
|
|
30
32
|
export type CreateDeployOptions = {
|
|
31
33
|
state: ScriptToolbarStateStore;
|
|
32
34
|
script: Script.Script;
|
|
33
|
-
fn:
|
|
35
|
+
fn: Operation.PersistentOperation;
|
|
34
36
|
space?: Space;
|
|
35
37
|
existingFunctionId?: string;
|
|
36
38
|
client: Client;
|
|
@@ -42,10 +44,10 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
42
44
|
|
|
43
45
|
// TODO(wittjosiah): Should this be an action?
|
|
44
46
|
const errorItem = createMenuAction('error', () => {}, {
|
|
45
|
-
label: value.error ?? ['no
|
|
47
|
+
label: value.error ?? ['no-error.label', { ns: meta.id }],
|
|
46
48
|
icon: 'ph--warning-circle--regular',
|
|
47
49
|
hidden: !value.error,
|
|
48
|
-
classNames: value.error &&
|
|
50
|
+
classNames: value.error && messageValence('error'),
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
const deployAction = createMenuAction<DeployActionProperties>(
|
|
@@ -62,14 +64,14 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
62
64
|
|
|
63
65
|
if (!result.success) {
|
|
64
66
|
log.catch(result.error);
|
|
65
|
-
state.set('error', t('upload
|
|
67
|
+
state.set('error', t('upload-failed.label'));
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
state.set('deploying', false);
|
|
69
71
|
},
|
|
70
72
|
{
|
|
71
73
|
type: 'deploy',
|
|
72
|
-
label: [value.deploying ? 'publishing
|
|
74
|
+
label: [value.deploying ? 'publishing.label' : 'deploy.label', { ns: meta.id }],
|
|
73
75
|
icon: value.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
|
|
74
76
|
disabled: value.deploying,
|
|
75
77
|
classNames: value.deploying ? '[&_svg]:animate-spin' : '',
|
|
@@ -85,7 +87,7 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
85
87
|
},
|
|
86
88
|
{
|
|
87
89
|
type: 'copy',
|
|
88
|
-
label: ['copy
|
|
90
|
+
label: ['copy-link.label', { ns: meta.id }],
|
|
89
91
|
icon: 'ph--link--regular',
|
|
90
92
|
disabled: !value.functionUrl,
|
|
91
93
|
},
|
|
@@ -94,9 +96,9 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
94
96
|
return {
|
|
95
97
|
nodes: [errorItem, deployAction, copyAction],
|
|
96
98
|
edges: [
|
|
97
|
-
{ source: 'root', target: 'error' },
|
|
98
|
-
{ source: 'root', target: 'deploy' },
|
|
99
|
-
{ source: 'root', target: 'copy' },
|
|
99
|
+
{ source: 'root', target: 'error', relation: 'child' },
|
|
100
|
+
{ source: 'root', target: 'deploy', relation: 'child' },
|
|
101
|
+
{ source: 'root', target: 'copy', relation: 'child' },
|
|
100
102
|
],
|
|
101
103
|
};
|
|
102
104
|
};
|
|
@@ -126,7 +128,7 @@ export const useDeployState = ({ state, script }: { state: ScriptToolbarStateSto
|
|
|
126
128
|
export const useDeployDeps = ({ script }: { script: Script.Script }) => {
|
|
127
129
|
const client = useClient();
|
|
128
130
|
const space = getSpace(script);
|
|
129
|
-
const [fn] = useQuery(space?.db, Query.type(
|
|
131
|
+
const [fn] = useQuery(space?.db, Query.type(Operation.PersistentOperation, { source: Ref.make(script) }));
|
|
130
132
|
const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(Obj.getMeta(fn)), [fn]);
|
|
131
133
|
return { client, space, fn, existingFunctionId };
|
|
132
134
|
};
|