@dxos/plugin-script 0.8.4-main.e8ec1fe → 0.8.4-main.effb148878
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/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-RTESC4OV.mjs → neutral/NotebookArticle-NV4AHOOS.mjs} +245 -299
- 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 +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/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-4H6UOE5J.mjs +123 -0
- package/dist/lib/neutral/chunk-4H6UOE5J.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6XGGYOY2.mjs +36 -0
- package/dist/lib/neutral/chunk-6XGGYOY2.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GD5SNDAA.mjs +8 -0
- package/dist/lib/neutral/chunk-GD5SNDAA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GYQPDUTK.mjs +105 -0
- package/dist/lib/neutral/chunk-GYQPDUTK.mjs.map +7 -0
- package/dist/lib/neutral/chunk-HJ4BY42S.mjs +8 -0
- package/dist/lib/neutral/chunk-HJ4BY42S.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/chunk-WEIU4BCS.mjs +52 -0
- package/dist/lib/neutral/chunk-WEIU4BCS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-Y3O3YZSE.mjs +345 -0
- package/dist/lib/neutral/chunk-Y3O3YZSE.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 +722 -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-32MZYUAA.mjs +46 -0
- package/dist/lib/neutral/create-32MZYUAA.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-6HWJMXMD.mjs +45 -0
- package/dist/lib/neutral/create-script-6HWJMXMD.mjs.map +7 -0
- package/dist/lib/neutral/delete-475DHFZO.mjs +21 -0
- package/dist/lib/neutral/delete-475DHFZO.mjs.map +7 -0
- package/dist/lib/neutral/deploy-VMPGXUR2.mjs +63 -0
- package/dist/lib/neutral/deploy-VMPGXUR2.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-IHZDHE27.mjs +59 -0
- package/dist/lib/neutral/inspect-invocations-IHZDHE27.mjs.map +7 -0
- package/dist/lib/neutral/install-function-UJWJMTZY.mjs +49 -0
- package/dist/lib/neutral/install-function-UJWJMTZY.mjs.map +7 -0
- package/dist/lib/neutral/invoke-M7J6LRZB.mjs +32 -0
- package/dist/lib/neutral/invoke-M7J6LRZB.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-MOATB7ZI.mjs +18 -0
- package/dist/lib/neutral/operation-handler-MOATB7ZI.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-MZUBGLJG.mjs +34 -0
- package/dist/lib/neutral/query-deployed-functions-MZUBGLJG.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-DPK6XU2Y.mjs +120 -0
- package/dist/lib/neutral/react-surface-DPK6XU2Y.mjs.map +7 -0
- package/dist/lib/neutral/read-LWLI7RB2.mjs +26 -0
- package/dist/lib/neutral/read-LWLI7RB2.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 +1 -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/update-HTFIQY2Z.mjs +63 -0
- package/dist/lib/neutral/update-HTFIQY2Z.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/artifact-definition.d.ts +3 -2
- package/dist/types/src/capabilities/artifact-definition.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/{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 +4 -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 -226
- 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 +8 -6
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +221 -226
- 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 +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/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 +24 -29
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/format.d.ts +4 -3
- 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 +4 -3
- 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 +25 -12
- 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/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/chat.d.ts.map +1 -1
- 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 +33 -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 -90
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Notebook.d.ts +110 -24
- 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 -2
- 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 +185 -107
- package/src/ScriptPlugin.node.ts +21 -0
- package/src/ScriptPlugin.test.ts +31 -0
- package/src/ScriptPlugin.tsx +24 -94
- 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/artifact-definition.ts +99 -97
- package/src/capabilities/blueprint-definition.ts +13 -24
- package/src/capabilities/compiler.ts +99 -22
- 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 -93
- package/src/capabilities/settings.ts +26 -14
- package/src/compiler/compiler.ts +21 -3
- package/src/components/{FrameContainer/FrameContainer.tsx → FramePanel/FramePanel.tsx} +7 -6
- package/src/components/{FrameContainer → FramePanel}/index.ts +1 -1
- package/src/components/NotebookStack/NotebookCell.tsx +45 -33
- package/src/components/NotebookStack/NotebookMenu.tsx +7 -7
- package/src/components/NotebookStack/NotebookStack.stories.tsx +24 -25
- package/src/components/NotebookStack/NotebookStack.tsx +31 -20
- 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 +42 -20
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +38 -43
- package/src/components/TestPanel/TestPanel.tsx +111 -194
- package/src/components/TestPanel/index.ts +0 -1
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +25 -18
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +74 -66
- package/src/components/index.ts +6 -7
- package/src/constants.ts +7 -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 +45 -35
- package/src/hooks/format.ts +9 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/template.ts +19 -12
- package/src/hooks/useCompiler.ts +25 -0
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +15 -20
- package/src/hooks/useToolbarState.ts +29 -4
- package/src/index.ts +2 -4
- package/src/meta.ts +11 -6
- package/src/notebook/compute-graph.test.ts +21 -9
- package/src/notebook/compute-graph.ts +46 -22
- 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 +49 -0
- package/src/templates/chat.ts +1 -1
- package/src/templates/chess-bot.ts +63 -0
- package/src/templates/commentary.ts +248 -0
- package/src/templates/data-generator.ts +2 -2
- package/src/templates/discord.ts +5 -5
- package/src/templates/forex-effect.ts +35 -29
- package/src/templates/forex.ts +27 -17
- package/src/templates/gmail.ts +6 -6
- package/src/templates/index.ts +31 -18
- package/src/templates/ping.ts +22 -5
- package/src/testing/index.ts +2 -1
- package/src/testing/simulator.test.ts +39 -0
- package/src/testing/{data.ts → test-notebook.ts} +12 -13
- package/src/testing/test-script.ts +28 -0
- package/src/translations.ts +89 -87
- package/src/types/Notebook.ts +20 -19
- 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 -2
- package/src/types/types.ts +1 -11
- package/src/util/deploy.ts +29 -33
- package/src/util/functions.ts +32 -28
- package/src/vite-env.d.ts +2 -0
- package/dist/lib/browser/DeploymentDialog-MZX4T77L.mjs +0 -14
- package/dist/lib/browser/NotebookContainer-RTESC4OV.mjs.map +0 -7
- package/dist/lib/browser/ScriptContainer-T2BAZDJ4.mjs +0 -147
- package/dist/lib/browser/ScriptContainer-T2BAZDJ4.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs +0 -66
- package/dist/lib/browser/app-graph-builder-2WR2ATTJ.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs +0 -30
- package/dist/lib/browser/blueprint-definition-6PZWZM2Y.mjs.map +0 -7
- package/dist/lib/browser/chunk-2G2NA6DQ.mjs +0 -88
- package/dist/lib/browser/chunk-2G2NA6DQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-3IJASGG5.mjs +0 -155
- package/dist/lib/browser/chunk-3IJASGG5.mjs.map +0 -7
- package/dist/lib/browser/chunk-4M7U2WVT.mjs +0 -304
- package/dist/lib/browser/chunk-4M7U2WVT.mjs.map +0 -7
- package/dist/lib/browser/chunk-5JSNQYZZ.mjs +0 -517
- package/dist/lib/browser/chunk-5JSNQYZZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-EB6AXFXO.mjs +0 -31
- package/dist/lib/browser/chunk-EB6AXFXO.mjs.map +0 -7
- package/dist/lib/browser/chunk-GAFCKEII.mjs +0 -646
- package/dist/lib/browser/chunk-GAFCKEII.mjs.map +0 -7
- package/dist/lib/browser/chunk-LNNCD2H4.mjs +0 -102
- package/dist/lib/browser/chunk-LNNCD2H4.mjs.map +0 -7
- package/dist/lib/browser/chunk-M6KJPUJK.mjs +0 -111
- package/dist/lib/browser/chunk-M6KJPUJK.mjs.map +0 -7
- package/dist/lib/browser/chunk-UOQ6NCH3.mjs +0 -15
- package/dist/lib/browser/chunk-UOQ6NCH3.mjs.map +0 -7
- package/dist/lib/browser/compiler-4KHRSX7J.mjs +0 -86
- package/dist/lib/browser/compiler-4KHRSX7J.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -273
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-AFJ575VK.mjs +0 -104
- package/dist/lib/browser/intent-resolver-AFJ575VK.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-QEQ3QUQA.mjs +0 -128
- package/dist/lib/browser/react-surface-QEQ3QUQA.mjs.map +0 -7
- package/dist/lib/browser/settings-LNLSTZM4.mjs +0 -26
- package/dist/lib/browser/settings-LNLSTZM4.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -14
- package/dist/lib/node-esm/DeploymentDialog-GL5AUWMR.mjs +0 -15
- package/dist/lib/node-esm/NotebookContainer-SVD3A3D6.mjs +0 -818
- package/dist/lib/node-esm/NotebookContainer-SVD3A3D6.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-2CE3H3JJ.mjs +0 -148
- package/dist/lib/node-esm/ScriptContainer-2CE3H3JJ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs +0 -67
- package/dist/lib/node-esm/app-graph-builder-NCVLUL5R.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs +0 -31
- package/dist/lib/node-esm/blueprint-definition-5R6YCSZZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-55JZVM6K.mjs +0 -16
- package/dist/lib/node-esm/chunk-55JZVM6K.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-57JA6XL5.mjs +0 -90
- package/dist/lib/node-esm/chunk-57JA6XL5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HDKR5WCD.mjs +0 -113
- package/dist/lib/node-esm/chunk-HDKR5WCD.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-IBV2DR36.mjs +0 -33
- package/dist/lib/node-esm/chunk-IBV2DR36.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IQTBVH4L.mjs +0 -518
- package/dist/lib/node-esm/chunk-IQTBVH4L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KJKZ4KNO.mjs +0 -647
- package/dist/lib/node-esm/chunk-KJKZ4KNO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NNHWLRHT.mjs +0 -103
- package/dist/lib/node-esm/chunk-NNHWLRHT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RIE676OW.mjs +0 -156
- package/dist/lib/node-esm/chunk-RIE676OW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YRTA4EHU.mjs +0 -305
- package/dist/lib/node-esm/chunk-YRTA4EHU.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-DU5NQISX.mjs +0 -87
- package/dist/lib/node-esm/compiler-DU5NQISX.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -274
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-A5VVK746.mjs +0 -105
- package/dist/lib/node-esm/intent-resolver-A5VVK746.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-U77YT7VF.mjs +0 -129
- package/dist/lib/node-esm/react-surface-U77YT7VF.mjs.map +0 -7
- package/dist/lib/node-esm/settings-IUFMOCXY.mjs +0 -27
- package/dist/lib/node-esm/settings-IUFMOCXY.mjs.map +0 -7
- package/dist/lib/node-esm/templates/index.mjs +0 -11
- package/dist/lib/node-esm/types/index.mjs +0 -15
- 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 -248
- 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.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 -251
- 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/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 -3
- package/dist/types/src/testing/data.d.ts.map +0 -1
- package/dist/types/src/types/actions.d.ts +0 -54
- package/dist/types/src/types/actions.d.ts.map +0 -1
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -86
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +0 -58
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +0 -123
- 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/NotebookContainer.stories.tsx +0 -83
- package/src/components/NotebookContainer.tsx +0 -263
- package/src/components/ScriptContainer.tsx +0 -69
- package/src/components/Settings/ScriptObjectSettings.tsx +0 -297
- 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/templates/chess.ts +0 -49
- package/src/types/actions.ts +0 -53
- /package/dist/lib/{browser/templates → 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/types → neutral}/index.mjs.map +0 -0
- /package/dist/lib/{browser/DeploymentDialog-MZX4T77L.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
- /package/dist/lib/{node-esm/DeploymentDialog-GL5AUWMR.mjs.map → neutral/types/index.mjs.map} +0 -0
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { readFile } from 'node:fs/promises';
|
|
6
|
+
import { describe, expect, test } from 'vitest';
|
|
7
|
+
|
|
8
|
+
import { Client, type Config } from '@dxos/client';
|
|
9
|
+
import { createEdgeIdentity } from '@dxos/client/edge';
|
|
10
|
+
import { configPreset } from '@dxos/config';
|
|
11
|
+
import { Context } from '@dxos/context';
|
|
12
|
+
import { bundleFunction } from '@dxos/functions-runtime/bundler';
|
|
13
|
+
import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
|
|
14
|
+
import { invariant } from '@dxos/invariant';
|
|
15
|
+
import { log } from '@dxos/log';
|
|
16
|
+
|
|
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'] }, () => {
|
|
20
|
+
test('deploys FOREX (effect) function and invokes it via EDGE (main)', { timeout: 120_000 }, async () => {
|
|
21
|
+
const config = configPreset({ edge: 'main' });
|
|
22
|
+
await testDeploy(config);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('deploys FOREX (effect) function and invokes it via EDGE (production)', { timeout: 120_000 }, async () => {
|
|
26
|
+
const config = configPreset({ edge: 'production' });
|
|
27
|
+
await testDeploy(config);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const testDeploy = async (config: Config) => {
|
|
31
|
+
await using client = await new Client({ config }).initialize();
|
|
32
|
+
await client.halo.createIdentity();
|
|
33
|
+
|
|
34
|
+
const space = await client.spaces.create();
|
|
35
|
+
await space.waitUntilReady();
|
|
36
|
+
|
|
37
|
+
// Inline echo function source.
|
|
38
|
+
const source = await readFile(new URL('../templates/forex-effect.ts', import.meta.url), 'utf-8');
|
|
39
|
+
|
|
40
|
+
// Bundle and upload.
|
|
41
|
+
const buildResult = await bundleFunction({ source });
|
|
42
|
+
if ('error' in buildResult) {
|
|
43
|
+
throw buildResult.error ?? new Error('Bundle creation failed');
|
|
44
|
+
}
|
|
45
|
+
const functionsServiceClient = FunctionsServiceClient.fromClient(client);
|
|
46
|
+
|
|
47
|
+
const func = await functionsServiceClient.deploy(Context.default(), {
|
|
48
|
+
ownerPublicKey: space.key,
|
|
49
|
+
version: '0.0.1',
|
|
50
|
+
entryPoint: buildResult.entryPoint,
|
|
51
|
+
assets: buildResult.assets,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Invoke deployed function via EDGE directly.
|
|
55
|
+
const edgeClient = client.edge.http;
|
|
56
|
+
invariant(edgeClient, 'edgeClient is required');
|
|
57
|
+
edgeClient.setIdentity(createEdgeIdentity(client));
|
|
58
|
+
|
|
59
|
+
const input = { from: 'USD', to: 'EUR' };
|
|
60
|
+
const result = await functionsServiceClient.invoke(Context.default(), func, input);
|
|
61
|
+
log.info('>>> result', { result, func });
|
|
62
|
+
const resultNumber = Number(result);
|
|
63
|
+
expect(resultNumber).toBeGreaterThan(0);
|
|
64
|
+
expect(resultNumber).toBeLessThan(100);
|
|
65
|
+
};
|
|
66
|
+
});
|
package/src/hooks/deploy.ts
CHANGED
|
@@ -4,15 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Script, Operation } from '@dxos/compute';
|
|
8
|
+
import { Obj, Query, Ref } from '@dxos/echo';
|
|
9
|
+
import { getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
8
10
|
import { log } from '@dxos/log';
|
|
9
11
|
import { type Client, useClient } from '@dxos/react-client';
|
|
10
|
-
import {
|
|
12
|
+
import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
11
13
|
import { type TFunction } from '@dxos/react-ui';
|
|
12
14
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
13
|
-
import {
|
|
15
|
+
import { messageValence } from '@dxos/ui-theme';
|
|
16
|
+
|
|
17
|
+
import { meta } from '#meta';
|
|
14
18
|
|
|
15
|
-
import { meta } from '../meta';
|
|
16
19
|
import { deployScript, getFunctionUrl, isScriptDeployed } from '../util';
|
|
17
20
|
|
|
18
21
|
export type DeployActionProperties = { type: 'deploy' } | { type: 'copy' };
|
|
@@ -24,10 +27,12 @@ export type DeployState = {
|
|
|
24
27
|
error: string;
|
|
25
28
|
};
|
|
26
29
|
|
|
30
|
+
import { type ScriptToolbarStateStore } from './useToolbarState';
|
|
31
|
+
|
|
27
32
|
export type CreateDeployOptions = {
|
|
28
|
-
state:
|
|
33
|
+
state: ScriptToolbarStateStore;
|
|
29
34
|
script: Script.Script;
|
|
30
|
-
fn:
|
|
35
|
+
fn: Operation.PersistentOperation;
|
|
31
36
|
space?: Space;
|
|
32
37
|
existingFunctionId?: string;
|
|
33
38
|
client: Client;
|
|
@@ -35,12 +40,14 @@ export type CreateDeployOptions = {
|
|
|
35
40
|
};
|
|
36
41
|
|
|
37
42
|
export const createDeploy = ({ state, script, space, fn, client, existingFunctionId, t }: CreateDeployOptions) => {
|
|
43
|
+
const { value } = state;
|
|
44
|
+
|
|
38
45
|
// TODO(wittjosiah): Should this be an action?
|
|
39
46
|
const errorItem = createMenuAction('error', () => {}, {
|
|
40
|
-
label:
|
|
47
|
+
label: value.error ?? ['no-error.label', { ns: meta.id }],
|
|
41
48
|
icon: 'ph--warning-circle--regular',
|
|
42
|
-
hidden: !
|
|
43
|
-
classNames:
|
|
49
|
+
hidden: !value.error,
|
|
50
|
+
classNames: value.error && messageValence('error'),
|
|
44
51
|
});
|
|
45
52
|
|
|
46
53
|
const deployAction = createMenuAction<DeployActionProperties>(
|
|
@@ -50,75 +57,78 @@ export const createDeploy = ({ state, script, space, fn, client, existingFunctio
|
|
|
50
57
|
return;
|
|
51
58
|
}
|
|
52
59
|
|
|
53
|
-
state.error
|
|
54
|
-
state.deploying
|
|
60
|
+
state.set('error', undefined);
|
|
61
|
+
state.set('deploying', true);
|
|
55
62
|
|
|
56
63
|
const result = await deployScript({ script, client, space, fn, existingFunctionId });
|
|
57
64
|
|
|
58
65
|
if (!result.success) {
|
|
59
66
|
log.catch(result.error);
|
|
60
|
-
state.error
|
|
67
|
+
state.set('error', t('upload-failed.label'));
|
|
61
68
|
}
|
|
62
69
|
|
|
63
|
-
state.deploying
|
|
70
|
+
state.set('deploying', false);
|
|
64
71
|
},
|
|
65
72
|
{
|
|
66
73
|
type: 'deploy',
|
|
67
|
-
label: [
|
|
68
|
-
icon:
|
|
69
|
-
disabled:
|
|
70
|
-
classNames:
|
|
74
|
+
label: [value.deploying ? 'publishing.label' : 'deploy.label', { ns: meta.id }],
|
|
75
|
+
icon: value.deploying ? 'ph--spinner-gap--regular' : 'ph--cloud-arrow-up--regular',
|
|
76
|
+
disabled: value.deploying,
|
|
77
|
+
classNames: value.deploying ? '[&_svg]:animate-spin' : '',
|
|
71
78
|
},
|
|
72
79
|
);
|
|
73
80
|
|
|
74
81
|
const copyAction = createMenuAction<DeployActionProperties>(
|
|
75
82
|
'copy',
|
|
76
83
|
async () => {
|
|
77
|
-
if (
|
|
78
|
-
await navigator.clipboard.writeText(
|
|
84
|
+
if (value.functionUrl) {
|
|
85
|
+
await navigator.clipboard.writeText(value.functionUrl);
|
|
79
86
|
}
|
|
80
87
|
},
|
|
81
88
|
{
|
|
82
89
|
type: 'copy',
|
|
83
|
-
label: ['copy
|
|
90
|
+
label: ['copy-link.label', { ns: meta.id }],
|
|
84
91
|
icon: 'ph--link--regular',
|
|
85
|
-
disabled: !
|
|
92
|
+
disabled: !value.functionUrl,
|
|
86
93
|
},
|
|
87
94
|
);
|
|
88
95
|
|
|
89
96
|
return {
|
|
90
97
|
nodes: [errorItem, deployAction, copyAction],
|
|
91
98
|
edges: [
|
|
92
|
-
{ source: 'root', target: 'error' },
|
|
93
|
-
{ source: 'root', target: 'deploy' },
|
|
94
|
-
{ 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' },
|
|
95
102
|
],
|
|
96
103
|
};
|
|
97
104
|
};
|
|
98
105
|
|
|
99
|
-
export const useDeployState = ({ state, script }: { state:
|
|
106
|
+
export const useDeployState = ({ state, script }: { state: ScriptToolbarStateStore; script: Script.Script }) => {
|
|
100
107
|
const { space, client, fn, existingFunctionId } = useDeployDeps({ script });
|
|
101
108
|
useEffect(() => {
|
|
102
109
|
if (!existingFunctionId) {
|
|
103
110
|
return;
|
|
104
111
|
}
|
|
105
112
|
|
|
106
|
-
state.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
state.set(
|
|
114
|
+
'functionUrl',
|
|
115
|
+
getFunctionUrl({
|
|
116
|
+
script,
|
|
117
|
+
fn,
|
|
118
|
+
edgeUrl: client.config.values.runtime?.services?.edge?.url ?? '',
|
|
119
|
+
}),
|
|
120
|
+
);
|
|
121
|
+
}, [existingFunctionId, space, fn, script, client.config.values.runtime?.services?.edge?.url, state]);
|
|
112
122
|
|
|
113
123
|
useEffect(() => {
|
|
114
|
-
state.deployed
|
|
115
|
-
}, [script.changed, existingFunctionId, fn, script]);
|
|
124
|
+
state.set('deployed', isScriptDeployed({ script, fn }));
|
|
125
|
+
}, [script.changed, existingFunctionId, fn, script, state]);
|
|
116
126
|
};
|
|
117
127
|
|
|
118
128
|
export const useDeployDeps = ({ script }: { script: Script.Script }) => {
|
|
119
129
|
const client = useClient();
|
|
120
130
|
const space = getSpace(script);
|
|
121
|
-
const [fn] = useQuery(space, Query.type(
|
|
122
|
-
const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(getMeta(fn)), [fn]);
|
|
131
|
+
const [fn] = useQuery(space?.db, Query.type(Operation.PersistentOperation, { source: Ref.make(script) }));
|
|
132
|
+
const existingFunctionId = useMemo(() => fn && getUserFunctionIdInMetadata(Obj.getMeta(fn)), [fn]);
|
|
123
133
|
return { client, space, fn, existingFunctionId };
|
|
124
134
|
};
|
package/src/hooks/format.ts
CHANGED
|
@@ -6,11 +6,12 @@ import { format } from 'prettier';
|
|
|
6
6
|
import prettierPluginEstree from 'prettier/plugins/estree';
|
|
7
7
|
import prettierPluginTypescript from 'prettier/plugins/typescript';
|
|
8
8
|
|
|
9
|
-
import { type Script } from '@dxos/
|
|
9
|
+
import { type Script } from '@dxos/compute';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
import { createMenuAction } from '@dxos/react-ui-menu';
|
|
12
13
|
|
|
13
|
-
import { meta } from '
|
|
14
|
+
import { meta } from '#meta';
|
|
14
15
|
|
|
15
16
|
export type FormatActionProperties = { type: 'format' };
|
|
16
17
|
|
|
@@ -23,19 +24,22 @@ export const createFormat = (script: Script.Script) => {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
try {
|
|
26
|
-
|
|
27
|
+
const formatted = await format(script.source.target!.content, {
|
|
27
28
|
parser: 'typescript',
|
|
28
29
|
plugins: [prettierPluginEstree, prettierPluginTypescript],
|
|
29
30
|
semi: true,
|
|
30
31
|
singleQuote: true,
|
|
31
32
|
});
|
|
33
|
+
Obj.update(script.source.target!, (obj) => {
|
|
34
|
+
obj.content = formatted;
|
|
35
|
+
});
|
|
32
36
|
} catch (err: any) {
|
|
33
37
|
// TODO(wittjosiah): Show error in UI.
|
|
34
38
|
log.catch(err);
|
|
35
39
|
}
|
|
36
40
|
},
|
|
37
41
|
{
|
|
38
|
-
label: ['format
|
|
42
|
+
label: ['format.label', { ns: meta.id }],
|
|
39
43
|
icon: 'ph--magic-wand--regular',
|
|
40
44
|
},
|
|
41
45
|
);
|
|
@@ -46,6 +50,7 @@ export const createFormat = (script: Script.Script) => {
|
|
|
46
50
|
{
|
|
47
51
|
source: 'root',
|
|
48
52
|
target: 'format',
|
|
53
|
+
relation: 'child',
|
|
49
54
|
},
|
|
50
55
|
],
|
|
51
56
|
};
|
package/src/hooks/index.ts
CHANGED