@dxos/plugin-script 0.8.4-main.c1de068 → 0.8.4-main.c4373fc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/DeploymentDialog-7FNPALCV.mjs +12 -0
- package/dist/lib/browser/NotebookContainer-ZSXYRRZB.mjs +578 -0
- package/dist/lib/browser/NotebookContainer-ZSXYRRZB.mjs.map +7 -0
- package/dist/lib/browser/ScriptContainer-24LLLTLB.mjs +149 -0
- package/dist/lib/browser/ScriptContainer-24LLLTLB.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-HLQ7K3BT.mjs → app-graph-builder-DPYULSME.mjs} +9 -8
- package/dist/lib/browser/app-graph-builder-DPYULSME.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs +28 -0
- package/dist/lib/browser/blueprint-definition-ET5KZ46I.mjs.map +7 -0
- package/dist/lib/browser/{chunk-3U6DTUH3.mjs → chunk-DXWTBOND.mjs} +26 -27
- package/dist/lib/browser/chunk-DXWTBOND.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FMDXKOP7.mjs → chunk-ETFBQURU.mjs} +71 -50
- package/dist/lib/browser/chunk-ETFBQURU.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QYAREHGH.mjs → chunk-EZVXV6DA.mjs} +3 -5
- package/dist/lib/browser/chunk-EZVXV6DA.mjs.map +7 -0
- package/dist/lib/browser/chunk-I3THDIT5.mjs +90 -0
- package/dist/lib/browser/chunk-I3THDIT5.mjs.map +7 -0
- package/dist/lib/browser/chunk-N6M34EUC.mjs +112 -0
- package/dist/lib/browser/chunk-N6M34EUC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-P4HQKUCP.mjs → chunk-NNYSARXK.mjs} +15 -15
- package/dist/lib/browser/chunk-NNYSARXK.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5TVBECWH.mjs → chunk-OKXN2N7M.mjs} +2 -2
- package/dist/lib/browser/{chunk-FIM2MVNJ.mjs → chunk-SRSEZWDY.mjs} +159 -68
- package/dist/lib/browser/chunk-SRSEZWDY.mjs.map +7 -0
- package/dist/lib/browser/chunk-SWBZUZDX.mjs +80 -0
- package/dist/lib/browser/chunk-SWBZUZDX.mjs.map +7 -0
- package/dist/lib/browser/chunk-VFJJA4WR.mjs +88 -0
- package/dist/lib/browser/chunk-VFJJA4WR.mjs.map +7 -0
- package/dist/lib/browser/{compiler-CXCUA4UQ.mjs → compiler-G2N2CG63.mjs} +24 -8
- package/dist/lib/browser/compiler-G2N2CG63.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +96 -39
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-7B77IG3N.mjs → intent-resolver-FYZRLYNT.mjs} +30 -16
- package/dist/lib/browser/intent-resolver-FYZRLYNT.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FYYXZA7C.mjs → react-surface-CFRYAL2P.mjs} +36 -13
- package/dist/lib/browser/react-surface-CFRYAL2P.mjs.map +7 -0
- package/dist/lib/browser/{settings-KCTBK5TY.mjs → settings-L3HCZRBP.mjs} +8 -8
- package/dist/lib/browser/settings-L3HCZRBP.mjs.map +7 -0
- package/dist/lib/browser/templates/index.mjs +1 -1
- package/dist/lib/browser/types/index.mjs +6 -4
- package/dist/lib/node-esm/{DeploymentDialog-3KPRWFE7.mjs → DeploymentDialog-AKAGR37W.mjs} +5 -5
- package/dist/lib/node-esm/NotebookContainer-2O3N3XPE.mjs +579 -0
- package/dist/lib/node-esm/NotebookContainer-2O3N3XPE.mjs.map +7 -0
- package/dist/lib/node-esm/ScriptContainer-IKOB6FHQ.mjs +150 -0
- package/dist/lib/node-esm/ScriptContainer-IKOB6FHQ.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-7EYIHWH4.mjs → app-graph-builder-UXJGHXSL.mjs} +9 -8
- package/dist/lib/node-esm/app-graph-builder-UXJGHXSL.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs +30 -0
- package/dist/lib/node-esm/blueprint-definition-AIYFOT7Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QKK3NDHW.mjs → chunk-5IKGUOMI.mjs} +15 -15
- package/dist/lib/node-esm/chunk-5IKGUOMI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-RT43MACC.mjs → chunk-7MR2L4T3.mjs} +26 -27
- package/dist/lib/node-esm/chunk-7MR2L4T3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-C33FKUSC.mjs +91 -0
- package/dist/lib/node-esm/chunk-C33FKUSC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-35M3CHYE.mjs → chunk-NUXZQQ6P.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-AHXJ6NQU.mjs → chunk-OG2SIKHE.mjs} +3 -5
- package/dist/lib/node-esm/chunk-OG2SIKHE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-OQGBKNYU.mjs +90 -0
- package/dist/lib/node-esm/chunk-OQGBKNYU.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-7NMI4CEU.mjs → chunk-PMQ3D535.mjs} +159 -68
- package/dist/lib/node-esm/chunk-PMQ3D535.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-XJPK3IYI.mjs → chunk-U4CZGISN.mjs} +71 -50
- package/dist/lib/node-esm/chunk-U4CZGISN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs +114 -0
- package/dist/lib/node-esm/chunk-VRSDE4CI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-ZF5ULKED.mjs +81 -0
- package/dist/lib/node-esm/chunk-ZF5ULKED.mjs.map +7 -0
- package/dist/lib/node-esm/{compiler-EPFKQXPE.mjs → compiler-PLDAZ5GJ.mjs} +24 -8
- package/dist/lib/node-esm/compiler-PLDAZ5GJ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +96 -39
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-FRZGS4TB.mjs → intent-resolver-6J3CFL5T.mjs} +30 -16
- package/dist/lib/node-esm/intent-resolver-6J3CFL5T.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-V32NWHKN.mjs → react-surface-NPKEO7SA.mjs} +36 -13
- package/dist/lib/node-esm/react-surface-NPKEO7SA.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-DXZ334A3.mjs → settings-YWGZP4EW.mjs} +8 -8
- package/dist/lib/node-esm/settings-YWGZP4EW.mjs.map +7 -0
- package/dist/lib/node-esm/templates/index.mjs +1 -1
- package/dist/lib/node-esm/types/index.mjs +6 -4
- package/dist/types/src/ScriptPlugin.d.ts +1 -1
- package/dist/types/src/ScriptPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts +1 -1
- package/dist/types/src/capabilities/artifact-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/compiler.d.ts +1 -1
- package/dist/types/src/capabilities/compiler.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/compiler/compiler.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts +2 -2
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts +225 -13
- package/dist/types/src/components/DeploymentDialog/DeploymentDialog.stories.d.ts.map +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts +1 -1
- package/dist/types/src/components/DeploymentDialog/index.d.ts.map +1 -1
- package/dist/types/src/components/FrameContainer/FrameContainer.d.ts.map +1 -1
- package/dist/types/src/components/NotebookContainer.d.ts +10 -0
- package/dist/types/src/components/NotebookContainer.d.ts.map +1 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts +231 -0
- package/dist/types/src/components/NotebookContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts +16 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts +231 -0
- package/dist/types/src/components/NotebookStack/NotebookStack.stories.d.ts.map +1 -0
- package/dist/types/src/components/NotebookStack/index.d.ts +2 -0
- package/dist/types/src/components/NotebookStack/index.d.ts.map +1 -0
- package/dist/types/src/components/ScriptContainer.d.ts +2 -2
- package/dist/types/src/components/ScriptContainer.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.d.ts.map +1 -1
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts +227 -10
- package/dist/types/src/components/ScriptToolbar/ScriptToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptObjectSettings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts +2 -2
- package/dist/types/src/components/Settings/ScriptPluginSettings.d.ts.map +1 -1
- package/dist/types/src/components/TestPanel/TestContainer.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts +4 -2
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.d.ts.map +1 -1
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts +17 -4
- package/dist/types/src/components/TypescriptEditor/TypescriptEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/hooks/deploy.d.ts +11 -10
- package/dist/types/src/hooks/deploy.d.ts.map +1 -1
- package/dist/types/src/hooks/template.d.ts.map +1 -1
- package/dist/types/src/hooks/useCreateAndDeployScriptTemplates.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/notebook/index.d.ts +2 -0
- package/dist/types/src/notebook/index.d.ts.map +1 -0
- package/dist/types/src/notebook/notebook.d.ts +39 -0
- package/dist/types/src/notebook/notebook.d.ts.map +1 -0
- package/dist/types/src/notebook/notebook.test.d.ts +2 -0
- package/dist/types/src/notebook/notebook.test.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.d.ts +74 -0
- package/dist/types/src/notebook/vfs-parser.d.ts.map +1 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts +2 -0
- package/dist/types/src/notebook/vfs-parser.test.d.ts.map +1 -0
- package/dist/types/src/templates/chess.d.ts.map +1 -1
- package/dist/types/src/templates/data-generator.d.ts.map +1 -1
- package/dist/types/src/templates/discord.d.ts.map +1 -1
- package/dist/types/src/templates/forex-effect.d.ts.map +1 -1
- package/dist/types/src/templates/forex.d.ts.map +1 -1
- package/dist/types/src/templates/gmail.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +10 -0
- package/dist/types/src/testing/data.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +21 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/actions.d.ts +58 -0
- package/dist/types/src/types/actions.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +29 -32
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util/deploy.d.ts +3 -3
- package/dist/types/src/util/deploy.d.ts.map +1 -1
- package/dist/types/src/util/functions.d.ts +5 -2
- package/dist/types/src/util/functions.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +73 -69
- package/src/ScriptPlugin.tsx +91 -69
- package/src/capabilities/app-graph-builder.ts +6 -5
- package/src/capabilities/artifact-definition.ts +8 -12
- package/src/capabilities/blueprint-definition.ts +30 -0
- package/src/capabilities/compiler.ts +2 -1
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/intent-resolver.ts +15 -8
- package/src/capabilities/react-surface.tsx +20 -7
- package/src/capabilities/settings.ts +3 -3
- package/src/compiler/compiler.ts +1 -1
- package/src/components/DeploymentDialog/DeploymentDialog.stories.tsx +34 -20
- package/src/components/DeploymentDialog/DeploymentDialog.tsx +16 -22
- package/src/components/DeploymentDialog/index.ts +1 -1
- package/src/components/FrameContainer/FrameContainer.tsx +3 -2
- package/src/components/NotebookContainer.stories.tsx +36 -0
- package/src/components/NotebookContainer.tsx +82 -0
- package/src/components/NotebookStack/NotebookStack.stories.tsx +36 -0
- package/src/components/NotebookStack/NotebookStack.tsx +113 -0
- package/src/components/NotebookStack/index.ts +5 -0
- package/src/components/ScriptContainer.tsx +4 -3
- package/src/components/ScriptToolbar/ScriptToolbar.stories.tsx +33 -17
- package/src/components/ScriptToolbar/ScriptToolbar.tsx +30 -23
- package/src/components/Settings/ScriptObjectSettings.tsx +111 -31
- package/src/components/Settings/ScriptPluginSettings.tsx +37 -47
- package/src/components/TestPanel/TestContainer.tsx +2 -1
- package/src/components/TestPanel/TestPanel.tsx +6 -6
- package/src/components/TypescriptEditor/TypescriptEditor.stories.tsx +84 -30
- package/src/components/TypescriptEditor/TypescriptEditor.tsx +32 -25
- package/src/components/index.ts +3 -0
- package/src/events.ts +2 -2
- package/src/hooks/deploy.ts +18 -19
- package/src/hooks/format.ts +2 -2
- package/src/hooks/template.ts +4 -3
- package/src/hooks/useCreateAndDeployScriptTemplates.ts +4 -3
- package/src/index.ts +1 -0
- package/src/meta.ts +2 -4
- package/src/notebook/index.ts +5 -0
- package/src/notebook/notebook.test.ts +38 -0
- package/src/notebook/notebook.ts +188 -0
- package/src/notebook/vfs-parser.test.ts +149 -0
- package/src/notebook/vfs-parser.ts +490 -0
- package/src/templates/chess.ts +3 -1
- package/src/templates/data-generator.ts +9 -3
- package/src/templates/discord.ts +12 -4
- package/src/templates/forex-effect.ts +7 -3
- package/src/templates/forex.ts +3 -1
- package/src/templates/gmail.ts +33 -62
- package/src/testing/data.ts +37 -0
- package/src/testing/index.ts +5 -0
- package/src/translations.ts +24 -4
- package/src/types/actions.ts +49 -0
- package/src/types/index.ts +1 -0
- package/src/types/schema.ts +24 -19
- package/src/util/deploy.ts +20 -33
- package/src/util/functions.ts +35 -6
- package/dist/lib/browser/DeploymentDialog-M4QIHTDR.mjs +0 -12
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs +0 -262
- package/dist/lib/browser/ScriptContainer-Z6SIGRRC.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-HLQ7K3BT.mjs.map +0 -7
- package/dist/lib/browser/artifact-definition-24Q3IHOU.mjs +0 -249
- package/dist/lib/browser/artifact-definition-24Q3IHOU.mjs.map +0 -7
- package/dist/lib/browser/chunk-3U6DTUH3.mjs.map +0 -7
- package/dist/lib/browser/chunk-FIM2MVNJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FMDXKOP7.mjs.map +0 -7
- package/dist/lib/browser/chunk-IS4OG2UW.mjs +0 -39
- package/dist/lib/browser/chunk-IS4OG2UW.mjs.map +0 -7
- package/dist/lib/browser/chunk-P4HQKUCP.mjs.map +0 -7
- package/dist/lib/browser/chunk-QYAREHGH.mjs.map +0 -7
- package/dist/lib/browser/chunk-R4R7VOFY.mjs +0 -88
- package/dist/lib/browser/chunk-R4R7VOFY.mjs.map +0 -7
- package/dist/lib/browser/compiler-CXCUA4UQ.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-7B77IG3N.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FYYXZA7C.mjs.map +0 -7
- package/dist/lib/browser/settings-KCTBK5TY.mjs.map +0 -7
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs +0 -263
- package/dist/lib/node-esm/ScriptContainer-KPU75HHI.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-7EYIHWH4.mjs.map +0 -7
- package/dist/lib/node-esm/artifact-definition-WAJFALUI.mjs +0 -250
- package/dist/lib/node-esm/artifact-definition-WAJFALUI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7NMI4CEU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AHXJ6NQU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs +0 -90
- package/dist/lib/node-esm/chunk-F5GFJ3PY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs +0 -40
- package/dist/lib/node-esm/chunk-JIPFLBYA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QKK3NDHW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RT43MACC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XJPK3IYI.mjs.map +0 -7
- package/dist/lib/node-esm/compiler-EPFKQXPE.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-FRZGS4TB.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-V32NWHKN.mjs.map +0 -7
- package/dist/lib/node-esm/settings-DXZ334A3.mjs.map +0 -7
- /package/dist/lib/browser/{DeploymentDialog-M4QIHTDR.mjs.map → DeploymentDialog-7FNPALCV.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-5TVBECWH.mjs.map → chunk-OKXN2N7M.mjs.map} +0 -0
- /package/dist/lib/node-esm/{DeploymentDialog-3KPRWFE7.mjs.map → DeploymentDialog-AKAGR37W.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-35M3CHYE.mjs.map → chunk-NUXZQQ6P.mjs.map} +0 -0
package/src/templates/gmail.ts
CHANGED
|
@@ -3,20 +3,32 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import {
|
|
6
|
+
import { EchoObject, Filter, ObjectId, S, create, defineFunction } from 'dxos:functions';
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
import {
|
|
9
|
+
FetchHttpClient,
|
|
9
10
|
HttpClient,
|
|
10
11
|
HttpClientRequest,
|
|
11
|
-
FetchHttpClient,
|
|
12
12
|
// @ts-ignore
|
|
13
|
-
} from 'https://esm.sh/@effect/platform@0.
|
|
13
|
+
} from 'https://esm.sh/@effect/platform@0.89.0?deps=effect@3.17.0&bundle=false';
|
|
14
14
|
// @ts-ignore
|
|
15
15
|
import { format, subDays } from 'https://esm.sh/date-fns@3.3.1?bundle=false';
|
|
16
16
|
// @ts-ignore
|
|
17
|
-
import
|
|
17
|
+
import * as Chunk from 'https://esm.sh/effect@3.17.0/Chunk?bundle=false';
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
import * as Effect from 'https://esm.sh/effect@3.17.0/Effect?bundle=false';
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
import * as Function from 'https://esm.sh/effect@3.17.0/Function?bundle=false';
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
import * as Ref from 'https://esm.sh/effect@3.17.0/Ref?bundle=false';
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
import * as Schedule from 'https://esm.sh/effect@3.17.0/Schedule?bundle=false';
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
import * as Stream from 'https://esm.sh/effect@3.17.0/Stream?bundle=false';
|
|
18
28
|
|
|
19
29
|
export default defineFunction({
|
|
30
|
+
key: 'dxos.org/script/gmail',
|
|
31
|
+
name: 'Gmail',
|
|
20
32
|
inputSchema: S.Struct({
|
|
21
33
|
mailboxId: S.String,
|
|
22
34
|
userId: S.optional(S.String).pipe(S.withDecodingDefault(() => 'me')),
|
|
@@ -41,7 +53,7 @@ export default defineFunction({
|
|
|
41
53
|
|
|
42
54
|
// NOTE: Google API bundles size is v. large and caused runtime issues.
|
|
43
55
|
const makeRequest = (url: string) =>
|
|
44
|
-
pipe(
|
|
56
|
+
Function.pipe(
|
|
45
57
|
url,
|
|
46
58
|
HttpClientRequest.get,
|
|
47
59
|
HttpClientRequest.setHeaders({ Authorization: `Bearer ${token}`, Accept: 'application/json' }),
|
|
@@ -80,7 +92,7 @@ export default defineFunction({
|
|
|
80
92
|
const messageDetails = yield* getMessage(userId, message.id);
|
|
81
93
|
const created = new Date(parseInt(messageDetails.internalDate)).toISOString();
|
|
82
94
|
const from = messageDetails.payload.headers.find((h: any) => h.name === 'From');
|
|
83
|
-
const sender = from &&
|
|
95
|
+
const sender = from && parseFromHeader(from.value);
|
|
84
96
|
// TODO(wittjosiah): Improve parsing of email contents.
|
|
85
97
|
const content =
|
|
86
98
|
messageDetails.payload.body?.data ??
|
|
@@ -98,7 +110,7 @@ export default defineFunction({
|
|
|
98
110
|
sender,
|
|
99
111
|
blocks: [
|
|
100
112
|
{
|
|
101
|
-
|
|
113
|
+
_tag: 'text',
|
|
102
114
|
text: Buffer.from(content, 'base64').toString('utf-8'),
|
|
103
115
|
},
|
|
104
116
|
],
|
|
@@ -114,7 +126,7 @@ export default defineFunction({
|
|
|
114
126
|
|
|
115
127
|
const queueMessages = yield* Ref.get(newMessages);
|
|
116
128
|
if (queueMessages.length > 0) {
|
|
117
|
-
yield* pipe(
|
|
129
|
+
yield* Function.pipe(
|
|
118
130
|
queueMessages,
|
|
119
131
|
Stream.fromIterable,
|
|
120
132
|
Stream.grouped(10),
|
|
@@ -145,17 +157,17 @@ const getUrl = (userId: string, messageId?: string, params?: Record<string, any>
|
|
|
145
157
|
/**
|
|
146
158
|
* Parses an email string in the format "Name <email@example.com>" into separate name and email components.
|
|
147
159
|
*/
|
|
148
|
-
const
|
|
149
|
-
const
|
|
160
|
+
const parseFromHeader = (value: string): { name?: string; email: string } | undefined => {
|
|
161
|
+
const EMAIL_REGEX = /^([^<]+?)\s*<([^>]+@[^>]+)>$/;
|
|
162
|
+
const removeOuterQuotes = (str: string) => str.replace(/^['"]|['"]$/g, '');
|
|
163
|
+
const match = value.match(EMAIL_REGEX);
|
|
150
164
|
if (match) {
|
|
151
165
|
const [, name, email] = match;
|
|
152
166
|
return {
|
|
153
|
-
name: name.trim(),
|
|
167
|
+
name: removeOuterQuotes(name.trim()),
|
|
154
168
|
email: email.trim(),
|
|
155
169
|
};
|
|
156
170
|
}
|
|
157
|
-
|
|
158
|
-
return undefined;
|
|
159
171
|
};
|
|
160
172
|
|
|
161
173
|
//
|
|
@@ -174,57 +186,16 @@ const ActorSchema = S.Struct({
|
|
|
174
186
|
role: S.optional(ActorRole),
|
|
175
187
|
});
|
|
176
188
|
|
|
177
|
-
const
|
|
189
|
+
const Base = S.Struct({
|
|
178
190
|
pending: S.optional(S.Boolean),
|
|
179
191
|
});
|
|
180
|
-
type
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
S.
|
|
184
|
-
|
|
185
|
-
disposition: S.optional(S.String),
|
|
186
|
-
text: S.String,
|
|
187
|
-
}),
|
|
188
|
-
).pipe(S.mutable);
|
|
189
|
-
type TextContentBlock = S.Schema.Type<typeof TextContentBlock>;
|
|
190
|
-
const JsonContentBlock = S.extend(
|
|
191
|
-
AbstractContentBlock,
|
|
192
|
-
S.Struct({
|
|
193
|
-
type: S.Literal('json'),
|
|
194
|
-
disposition: S.optional(S.String),
|
|
195
|
-
data: S.String,
|
|
196
|
-
}),
|
|
197
|
-
).pipe(S.mutable);
|
|
198
|
-
type JsonContentBlock = S.Schema.Type<typeof JsonContentBlock>;
|
|
199
|
-
const Base64ImageSource = S.Struct({
|
|
200
|
-
type: S.Literal('base64'),
|
|
201
|
-
mediaType: S.String,
|
|
202
|
-
data: S.String,
|
|
192
|
+
type Base = S.Schema.Type<typeof Base>;
|
|
193
|
+
const Text = S.TaggedStruct('text', {
|
|
194
|
+
mimeType: S.optional(S.String),
|
|
195
|
+
text: S.String,
|
|
196
|
+
...Base.fields,
|
|
203
197
|
}).pipe(S.mutable);
|
|
204
|
-
|
|
205
|
-
type: S.Literal('http'),
|
|
206
|
-
url: S.String,
|
|
207
|
-
}).pipe(S.mutable);
|
|
208
|
-
const ImageSource = S.Union(Base64ImageSource, HttpImageSource);
|
|
209
|
-
type ImageSource = S.Schema.Type<typeof ImageSource>;
|
|
210
|
-
const ImageContentBlock = S.extend(
|
|
211
|
-
AbstractContentBlock,
|
|
212
|
-
S.Struct({
|
|
213
|
-
type: S.Literal('image'),
|
|
214
|
-
id: S.optional(S.String),
|
|
215
|
-
source: S.optional(ImageSource),
|
|
216
|
-
}),
|
|
217
|
-
).pipe(S.mutable);
|
|
218
|
-
type ImageContentBlock = S.Schema.Type<typeof ImageContentBlock>;
|
|
219
|
-
const ReferenceContentBlock = S.extend(
|
|
220
|
-
AbstractContentBlock,
|
|
221
|
-
S.Struct({
|
|
222
|
-
type: S.Literal('reference'),
|
|
223
|
-
reference: S.Any,
|
|
224
|
-
}),
|
|
225
|
-
).pipe(S.mutable);
|
|
226
|
-
type ReferenceContentBlock = S.Schema.Type<typeof ReferenceContentBlock>;
|
|
227
|
-
const MessageContentBlock = S.Union(TextContentBlock, JsonContentBlock, ImageContentBlock, ReferenceContentBlock);
|
|
198
|
+
interface Text extends S.Schema.Type<typeof Text> {}
|
|
228
199
|
|
|
229
200
|
const MessageType = S.Struct({
|
|
230
201
|
id: ObjectId,
|
|
@@ -234,7 +205,7 @@ const MessageType = S.Struct({
|
|
|
234
205
|
sender: ActorSchema.annotations({
|
|
235
206
|
description: 'Identity of the message sender.',
|
|
236
207
|
}),
|
|
237
|
-
blocks: S.Array(
|
|
208
|
+
blocks: S.Array(Text).annotations({
|
|
238
209
|
description: 'Contents of the message.',
|
|
239
210
|
}),
|
|
240
211
|
properties: S.optional(
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Ref } from '@dxos/echo';
|
|
6
|
+
import { createObject } from '@dxos/echo-db';
|
|
7
|
+
import { PublicKey } from '@dxos/keys';
|
|
8
|
+
import { DataType } from '@dxos/schema';
|
|
9
|
+
|
|
10
|
+
import { Notebook } from '../types';
|
|
11
|
+
|
|
12
|
+
// NOTE: createObject(DataType.makeText is required to make codemirror work.
|
|
13
|
+
export const createNotebook = () =>
|
|
14
|
+
Notebook.make({
|
|
15
|
+
cells: [
|
|
16
|
+
{
|
|
17
|
+
id: PublicKey.random().toString(),
|
|
18
|
+
script: Ref.make(createObject(DataType.makeText(['c = a() + b', '', ''].join('\n')))),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: PublicKey.random().toString(),
|
|
22
|
+
script: Ref.make(createObject(DataType.makeText(['a = () => 100', ''].join('\n')))),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: PublicKey.random().toString(),
|
|
26
|
+
script: Ref.make(createObject(DataType.makeText(['b = 200'].join('\n')))),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: PublicKey.random().toString(),
|
|
30
|
+
script: Ref.make(createObject(DataType.makeText(['d = a() * 2'].join('\n')))),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: PublicKey.random().toString(),
|
|
34
|
+
script: Ref.make(createObject(DataType.makeText(['c + d', '', '', ''].join('\n')))),
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
});
|
package/src/translations.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { ScriptType } from '@dxos/functions';
|
|
|
6
6
|
import { type Resource } from '@dxos/react-ui';
|
|
7
7
|
|
|
8
8
|
import { meta } from './meta';
|
|
9
|
+
import { Notebook } from './types';
|
|
9
10
|
|
|
10
11
|
export const translations = [
|
|
11
12
|
{
|
|
@@ -19,8 +20,18 @@ export const translations = [
|
|
|
19
20
|
'rename object label': 'Rename script',
|
|
20
21
|
'delete object label': 'Delete script',
|
|
21
22
|
},
|
|
23
|
+
[Notebook.Notebook.typename]: {
|
|
24
|
+
'typename label': 'Notebook',
|
|
25
|
+
'typename label_zero': 'Notebooks',
|
|
26
|
+
'typename label_one': 'Notebook',
|
|
27
|
+
'typename label_other': 'Notebooks',
|
|
28
|
+
'object name placeholder': 'New notebook',
|
|
29
|
+
'rename object label': 'Rename notebook',
|
|
30
|
+
'delete object label': 'Delete notebook',
|
|
31
|
+
},
|
|
22
32
|
[meta.id]: {
|
|
23
33
|
'plugin name': 'Scripts',
|
|
34
|
+
'settings title': 'Scripts plugin settings',
|
|
24
35
|
'description label': 'Description',
|
|
25
36
|
'description placeholder': 'Enter description',
|
|
26
37
|
'binding placeholder': 'Function name',
|
|
@@ -44,6 +55,12 @@ export const translations = [
|
|
|
44
55
|
'open token manager label': 'Open Token Manager',
|
|
45
56
|
'publish label': 'Publish',
|
|
46
57
|
'publishing label': 'Publishing',
|
|
58
|
+
'blueprint editor label': 'Blueprint',
|
|
59
|
+
'blueprint editor description': 'Create a blueprint that exposes this script as a tool.',
|
|
60
|
+
'blueprint instructions label': 'Instructions',
|
|
61
|
+
'blueprint instructions placeholder': 'Describe how this tool should be used.',
|
|
62
|
+
'create blueprint label': 'Create blueprint',
|
|
63
|
+
'creating label': 'Creating…',
|
|
47
64
|
'editor input mode label': 'Editor input mode',
|
|
48
65
|
'select editor input mode placeholder': 'Select editor input mode…',
|
|
49
66
|
'settings editor input mode default label': 'Default',
|
|
@@ -53,16 +70,15 @@ export const translations = [
|
|
|
53
70
|
'function panel label': 'Debug Function',
|
|
54
71
|
'script test label': 'Test',
|
|
55
72
|
'script logs label': 'Logs',
|
|
73
|
+
|
|
56
74
|
'deployment dialog title': 'Default Scripts',
|
|
57
|
-
'deployment dialog scripts found
|
|
58
|
-
'We found the following script template for your new integration:',
|
|
59
|
-
'deployment dialog scripts found message_other':
|
|
60
|
-
'We found the following script templates for your new integration:',
|
|
75
|
+
'deployment dialog scripts found message': 'Script templates:',
|
|
61
76
|
'deployment dialog deploy functions button label_one': 'Create and deploy script',
|
|
62
77
|
'deployment dialog deploy functions button label_other': 'Create and deploy scripts',
|
|
63
78
|
'deployment dialog deploy functions pending button label_one': 'Deploying script',
|
|
64
79
|
'deployment dialog deploy functions pending button label_other': 'Deploying scripts',
|
|
65
80
|
'deployment dialog skip button label': 'Skip',
|
|
81
|
+
|
|
66
82
|
'script deployment toast label_one': 'Script deployed',
|
|
67
83
|
'script deployment toast label_other': 'Scripts deployed',
|
|
68
84
|
'script deployment toast description_one': 'Your script has been deployed successfully.',
|
|
@@ -75,6 +91,10 @@ export const translations = [
|
|
|
75
91
|
'script deployment error toast description_other': 'There was an error deploying your scripts.',
|
|
76
92
|
'script deployment error toast close label_one': 'Close',
|
|
77
93
|
'script deployment error toast close label_other': 'Close',
|
|
94
|
+
|
|
95
|
+
'notebook cell placeholder': 'Enter script',
|
|
96
|
+
'notebook cell delete label': 'Delete cell',
|
|
97
|
+
'notebook cell insert label': 'Insert cell',
|
|
78
98
|
},
|
|
79
99
|
},
|
|
80
100
|
},
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { SpaceSchema } from '@dxos/client/echo';
|
|
8
|
+
import { ScriptType } from '@dxos/functions';
|
|
9
|
+
|
|
10
|
+
import { meta } from '../meta';
|
|
11
|
+
|
|
12
|
+
import { Notebook } from './schema';
|
|
13
|
+
|
|
14
|
+
export namespace ScriptAction {
|
|
15
|
+
export const ScriptProps = Schema.Struct({
|
|
16
|
+
name: Schema.optional(Schema.String),
|
|
17
|
+
// TODO(wittjosiah): Placeholder annotation?
|
|
18
|
+
gistUrl: Schema.optional(Schema.String.annotations({ title: 'Import from Gist (url)' })),
|
|
19
|
+
initialTemplateId: Schema.optional(Schema.String),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export class CreateScript extends Schema.TaggedClass<CreateScript>()(`${meta.id}/action/create-script`, {
|
|
23
|
+
input: Schema.extend(
|
|
24
|
+
ScriptProps,
|
|
25
|
+
Schema.Struct({
|
|
26
|
+
space: SpaceSchema,
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
output: Schema.Struct({
|
|
30
|
+
object: ScriptType,
|
|
31
|
+
}),
|
|
32
|
+
}) {}
|
|
33
|
+
|
|
34
|
+
export const NotebookProps = Schema.Struct({
|
|
35
|
+
name: Schema.optional(Schema.String),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export class CreateNotebook extends Schema.TaggedClass<CreateNotebook>()(`${meta.id}/action/create-notebook`, {
|
|
39
|
+
input: Schema.extend(
|
|
40
|
+
NotebookProps,
|
|
41
|
+
Schema.Struct({
|
|
42
|
+
space: SpaceSchema,
|
|
43
|
+
}),
|
|
44
|
+
),
|
|
45
|
+
output: Schema.Struct({
|
|
46
|
+
object: Notebook.Notebook,
|
|
47
|
+
}),
|
|
48
|
+
}) {}
|
|
49
|
+
}
|
package/src/types/index.ts
CHANGED
package/src/types/schema.ts
CHANGED
|
@@ -2,36 +2,41 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { Obj, Type } from '@dxos/echo';
|
|
8
|
+
import { LabelAnnotation } from '@dxos/echo/internal';
|
|
9
9
|
import { EditorInputMode } from '@dxos/react-ui-editor';
|
|
10
|
+
import { DataType } from '@dxos/schema';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
name: Schema.optional(Schema.String),
|
|
16
|
-
// TODO(wittjosiah): Placeholder annotation?
|
|
17
|
-
gistUrl: Schema.optional(Schema.String.annotations({ title: 'Import from Gist (url)' })),
|
|
18
|
-
initialTemplateId: Schema.optional(Schema.String),
|
|
12
|
+
export namespace Notebook {
|
|
13
|
+
export const Cell = Schema.Struct({
|
|
14
|
+
id: Schema.String,
|
|
15
|
+
script: Type.Ref(DataType.Text),
|
|
19
16
|
});
|
|
20
17
|
|
|
21
|
-
export type
|
|
18
|
+
export type Cell = Schema.Schema.Type<typeof Cell>;
|
|
22
19
|
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
export const Notebook = Schema.Struct({
|
|
21
|
+
name: Schema.optional(Schema.String),
|
|
22
|
+
cells: Schema.mutable(Schema.Array(Cell)),
|
|
23
|
+
}).pipe(
|
|
24
|
+
Type.Obj({
|
|
25
|
+
typename: 'dxos.org/type/Notebook',
|
|
26
|
+
version: '0.1.0',
|
|
27
27
|
}),
|
|
28
|
-
|
|
28
|
+
LabelAnnotation.set(['name']),
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export type Notebook = Schema.Schema.Type<typeof Notebook>;
|
|
32
|
+
|
|
33
|
+
export const make = (props: Obj.MakeProps<typeof Notebook> = { cells: [] }) => Obj.make(Notebook, props);
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
export const
|
|
36
|
+
export const ScriptSettings = Schema.mutable(
|
|
32
37
|
Schema.Struct({
|
|
33
38
|
editorInputMode: EditorInputMode,
|
|
34
39
|
}),
|
|
35
40
|
);
|
|
36
41
|
|
|
37
|
-
export type
|
|
42
|
+
export type ScriptSettings = Schema.Schema.Type<typeof ScriptSettings>;
|
package/src/util/deploy.ts
CHANGED
|
@@ -7,9 +7,8 @@ import { Obj, Ref } from '@dxos/echo';
|
|
|
7
7
|
import {
|
|
8
8
|
FunctionType,
|
|
9
9
|
type ScriptType,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
setUserFunctionUrlInMetadata,
|
|
10
|
+
getUserFunctionIdInMetadata,
|
|
11
|
+
setUserFunctionIdInMetadata,
|
|
13
12
|
} from '@dxos/functions';
|
|
14
13
|
import { Bundler } from '@dxos/functions/bundler';
|
|
15
14
|
import { incrementSemverPatch, uploadWorkerFunction } from '@dxos/functions/edge';
|
|
@@ -19,8 +18,8 @@ import { type Space } from '@dxos/react-client/echo';
|
|
|
19
18
|
import { updateFunctionMetadata } from './functions';
|
|
20
19
|
|
|
21
20
|
export const isScriptDeployed = ({ script, fn }: { script: ScriptType; fn: any }): boolean => {
|
|
22
|
-
const
|
|
23
|
-
return Boolean(
|
|
21
|
+
const existingFunctionId = fn && getUserFunctionIdInMetadata(Obj.getMeta(fn));
|
|
22
|
+
return Boolean(existingFunctionId) && !script.changed;
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
type DeployScriptProps = {
|
|
@@ -28,10 +27,10 @@ type DeployScriptProps = {
|
|
|
28
27
|
client: Client;
|
|
29
28
|
space: Space;
|
|
30
29
|
fn?: FunctionType;
|
|
31
|
-
|
|
30
|
+
existingFunctionId?: string;
|
|
32
31
|
};
|
|
33
32
|
|
|
34
|
-
type DeployScriptResult = { success: boolean; error?: Error;
|
|
33
|
+
type DeployScriptResult = { success: boolean; error?: Error; functionId?: string };
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
* Deploy a script to a space, handling bundling and uploading to the FaaS infrastructure.
|
|
@@ -41,7 +40,7 @@ export const deployScript = async ({
|
|
|
41
40
|
client,
|
|
42
41
|
space,
|
|
43
42
|
fn,
|
|
44
|
-
|
|
43
|
+
existingFunctionId,
|
|
45
44
|
}: DeployScriptProps): Promise<DeployScriptResult> => {
|
|
46
45
|
const validationError = validateDeployInputs(script, space);
|
|
47
46
|
if (validationError) {
|
|
@@ -49,11 +48,10 @@ export const deployScript = async ({
|
|
|
49
48
|
}
|
|
50
49
|
|
|
51
50
|
try {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
throw error || new Error('Bundle creation failed');
|
|
51
|
+
const bundler = new Bundler({ platform: 'browser', sandboxedModules: [], remoteModules: {} });
|
|
52
|
+
const buildResult = await bundler.bundle({ source: script.source!.target!.content });
|
|
53
|
+
if ('error' in buildResult) {
|
|
54
|
+
throw buildResult.error || new Error('Bundle creation failed');
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
const { functionId, version, meta } = await uploadWorkerFunction({
|
|
@@ -61,7 +59,8 @@ export const deployScript = async ({
|
|
|
61
59
|
ownerPublicKey: space.key,
|
|
62
60
|
version: fn ? incrementSemverPatch(fn.version) : '0.0.1',
|
|
63
61
|
functionId: existingFunctionId,
|
|
64
|
-
|
|
62
|
+
entryPoint: buildResult.entryPoint,
|
|
63
|
+
assets: { [buildResult.entryPoint]: buildResult.asset },
|
|
65
64
|
});
|
|
66
65
|
|
|
67
66
|
if (functionId === undefined || version === undefined) {
|
|
@@ -72,10 +71,9 @@ export const deployScript = async ({
|
|
|
72
71
|
script.changed = false;
|
|
73
72
|
updateFunctionMetadata(script, storedFunction, meta, functionId);
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
setUserFunctionUrlInMetadata(Obj.getMeta(storedFunction), functionUrl);
|
|
74
|
+
setUserFunctionIdInMetadata(Obj.getMeta(storedFunction), functionId);
|
|
77
75
|
|
|
78
|
-
return { success: true,
|
|
76
|
+
return { success: true, functionId };
|
|
79
77
|
} catch (err: any) {
|
|
80
78
|
log.catch(err);
|
|
81
79
|
return { success: false, error: err };
|
|
@@ -92,21 +90,6 @@ const validateDeployInputs = (script: ScriptType, space: Space): Error | null =>
|
|
|
92
90
|
return null;
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
const extractFunctionId = (functionUrl?: string): string | undefined => {
|
|
96
|
-
return functionUrl?.split('/').at(-1);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const bundleScript = async (source: string): Promise<{ bundle?: string; error?: Error }> => {
|
|
100
|
-
const bundler = new Bundler({ platform: 'browser', sandboxedModules: [], remoteModules: {} });
|
|
101
|
-
const buildResult = await bundler.bundle({ source });
|
|
102
|
-
|
|
103
|
-
if (buildResult.error || !buildResult.bundle) {
|
|
104
|
-
return { error: buildResult.error || new Error('Bundle creation failed') };
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return { bundle: buildResult.bundle };
|
|
108
|
-
};
|
|
109
|
-
|
|
110
93
|
const createOrUpdateFunctionInSpace = (
|
|
111
94
|
space: Space,
|
|
112
95
|
fn: FunctionType | undefined,
|
|
@@ -115,9 +98,13 @@ const createOrUpdateFunctionInSpace = (
|
|
|
115
98
|
version: string,
|
|
116
99
|
): FunctionType => {
|
|
117
100
|
if (fn) {
|
|
101
|
+
fn.name = script.name ?? 'New Function';
|
|
118
102
|
fn.version = version;
|
|
119
103
|
return fn;
|
|
120
104
|
} else {
|
|
121
|
-
|
|
105
|
+
const fn = Obj.make(FunctionType, { name: script.name ?? 'New Function', version, source: Ref.make(script) });
|
|
106
|
+
space.db.add(fn);
|
|
107
|
+
setUserFunctionIdInMetadata(Obj.getMeta(fn), functionId);
|
|
108
|
+
return fn;
|
|
122
109
|
}
|
|
123
110
|
};
|
package/src/util/functions.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type ScriptType, getInvocationUrl,
|
|
5
|
+
import { type FunctionType, type ScriptType, getInvocationUrl, getUserFunctionIdInMetadata } from '@dxos/functions';
|
|
6
|
+
import { type PublicKey } from '@dxos/keys';
|
|
6
7
|
import { log } from '@dxos/log';
|
|
8
|
+
import { type Credential } from '@dxos/protocols/proto/dxos/halo/credentials';
|
|
7
9
|
import { getMeta, getSpace } from '@dxos/react-client/echo';
|
|
8
|
-
|
|
9
10
|
/**
|
|
10
11
|
* Get the function URL for a given script and client configuration
|
|
11
12
|
*/
|
|
@@ -19,18 +20,23 @@ export const getFunctionUrl = ({
|
|
|
19
20
|
edgeUrl: string;
|
|
20
21
|
}): string | undefined => {
|
|
21
22
|
const space = getSpace(script);
|
|
22
|
-
const
|
|
23
|
+
const existingFunctionId = fn && getUserFunctionIdInMetadata(getMeta(fn));
|
|
23
24
|
|
|
24
|
-
if (!
|
|
25
|
+
if (!existingFunctionId) {
|
|
25
26
|
return undefined;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
return getInvocationUrl(
|
|
29
|
+
return getInvocationUrl(existingFunctionId, edgeUrl, {
|
|
29
30
|
spaceId: space?.id,
|
|
30
31
|
});
|
|
31
32
|
};
|
|
32
33
|
|
|
33
|
-
export const updateFunctionMetadata = (
|
|
34
|
+
export const updateFunctionMetadata = (
|
|
35
|
+
script: ScriptType,
|
|
36
|
+
storedFunction: FunctionType,
|
|
37
|
+
meta: any,
|
|
38
|
+
functionId: string,
|
|
39
|
+
) => {
|
|
34
40
|
if (script.description !== undefined && script.description.trim() !== '') {
|
|
35
41
|
storedFunction.description = script.description;
|
|
36
42
|
} else if (meta.description) {
|
|
@@ -50,4 +56,27 @@ export const updateFunctionMetadata = (script: ScriptType, storedFunction: any,
|
|
|
50
56
|
} else {
|
|
51
57
|
log.verbose('no output schema in function metadata', { functionId });
|
|
52
58
|
}
|
|
59
|
+
|
|
60
|
+
if (meta.key) {
|
|
61
|
+
storedFunction.key = meta.key;
|
|
62
|
+
} else {
|
|
63
|
+
log.verbose('no key in function metadata', { functionId });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const getAccessCredential = (identityKey: PublicKey): Credential => {
|
|
68
|
+
return {
|
|
69
|
+
issuer: identityKey,
|
|
70
|
+
issuanceDate: new Date(),
|
|
71
|
+
subject: {
|
|
72
|
+
id: identityKey,
|
|
73
|
+
assertion: {
|
|
74
|
+
'@type': 'dxos.halo.credentials.ServiceAccess',
|
|
75
|
+
serverName: 'hub.dxos.network',
|
|
76
|
+
serverKey: identityKey,
|
|
77
|
+
identityKey,
|
|
78
|
+
capabilities: ['composer:beta'],
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
53
82
|
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEPLOYMENT_DIALOG,
|
|
3
|
-
DeploymentDialog_default
|
|
4
|
-
} from "./chunk-P4HQKUCP.mjs";
|
|
5
|
-
import "./chunk-FMDXKOP7.mjs";
|
|
6
|
-
import "./chunk-IS4OG2UW.mjs";
|
|
7
|
-
import "./chunk-QYAREHGH.mjs";
|
|
8
|
-
export {
|
|
9
|
-
DEPLOYMENT_DIALOG,
|
|
10
|
-
DeploymentDialog_default as default
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=DeploymentDialog-M4QIHTDR.mjs.map
|