@dxos/plugin-automation 0.8.4-main.a4bbb77 → 0.8.4-main.ae835ea
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/AutomationPanel-LBXJDM6Z.mjs +11 -0
- package/dist/lib/browser/{AutomationSettings-6XLG2PCK.mjs → AutomationSettings-IIEI5D2K.mjs} +6 -7
- package/dist/lib/{node-esm/AutomationSettings-4IW7RGMN.mjs.map → browser/AutomationSettings-IIEI5D2K.mjs.map} +1 -1
- package/dist/lib/browser/{FunctionsContainer-BQ6VBDIG.mjs → FunctionsContainer-IZTCGNJZ.mjs} +3 -3
- package/dist/lib/browser/{FunctionsPanel-QBTOFFNU.mjs → FunctionsPanel-HFCK3JRB.mjs} +3 -3
- package/dist/lib/browser/{app-graph-builder-6TP6ZNYG.mjs → app-graph-builder-7VKA2GS3.mjs} +8 -7
- package/dist/lib/browser/app-graph-builder-7VKA2GS3.mjs.map +7 -0
- package/dist/lib/browser/{chunk-M2WQCY2T.mjs → chunk-CVYJM6OO.mjs} +19 -6
- package/dist/lib/browser/chunk-CVYJM6OO.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EAQL33PI.mjs → chunk-FHSN7G4H.mjs} +22 -9
- package/dist/lib/browser/chunk-FHSN7G4H.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZTXBAXUT.mjs → chunk-GCGHLQM2.mjs} +2 -2
- package/dist/lib/browser/chunk-GCGHLQM2.mjs.map +7 -0
- package/dist/lib/browser/{chunk-IN2YC7NY.mjs → chunk-JW7XSPYW.mjs} +57 -20
- package/dist/lib/browser/chunk-JW7XSPYW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LNMCGQC2.mjs → chunk-K5YNWESC.mjs} +60 -20
- package/dist/lib/browser/chunk-K5YNWESC.mjs.map +7 -0
- package/dist/lib/browser/chunk-LZQFZO3B.mjs +17 -0
- package/dist/lib/browser/chunk-LZQFZO3B.mjs.map +7 -0
- package/dist/lib/browser/{chunk-U66KBK53.mjs → chunk-XXZNGORC.mjs} +5 -5
- package/dist/lib/browser/{chunk-F4K5EMWL.mjs → chunk-YBPJCY3F.mjs} +3 -3
- package/dist/lib/browser/chunk-YBPJCY3F.mjs.map +7 -0
- package/dist/lib/browser/{compute-runtime-OFQPXD5I.mjs → compute-runtime-PFYRMGN2.mjs} +27 -71
- package/dist/lib/browser/compute-runtime-PFYRMGN2.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +3 -4
- package/dist/lib/browser/index.mjs +26 -10
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{intent-resolver-JXVWRAAH.mjs → intent-resolver-5HR7M7T6.mjs} +8 -8
- package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-NG3MJCDH.mjs → react-surface-WPMY3EX2.mjs} +5 -6
- package/dist/lib/browser/react-surface-WPMY3EX2.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{AutomationPanel-WMVR3IST.mjs → AutomationPanel-NVEIUIZP.mjs} +4 -4
- package/dist/lib/node-esm/{AutomationSettings-4IW7RGMN.mjs → AutomationSettings-VIIEPI2P.mjs} +6 -7
- package/dist/lib/node-esm/{FunctionsContainer-LHUUOLA5.mjs → FunctionsContainer-KKRCIXGB.mjs} +3 -3
- package/dist/lib/node-esm/{FunctionsPanel-SHTQIMDV.mjs → FunctionsPanel-74ELGR7P.mjs} +3 -3
- package/dist/lib/node-esm/{app-graph-builder-3A2NIPR5.mjs → app-graph-builder-RTOFJNFV.mjs} +8 -7
- package/dist/lib/node-esm/app-graph-builder-RTOFJNFV.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-DSEZPWSO.mjs → chunk-3BJ6BR3E.mjs} +19 -6
- package/dist/lib/node-esm/chunk-3BJ6BR3E.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5MQJPJR2.mjs → chunk-CEVIVRTY.mjs} +6 -2
- package/dist/lib/node-esm/chunk-CEVIVRTY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-CEWZ2CDM.mjs → chunk-ECJKIUBO.mjs} +3 -3
- package/dist/lib/node-esm/chunk-ECJKIUBO.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PBULJE4B.mjs → chunk-JOCKHLFT.mjs} +22 -9
- package/dist/lib/node-esm/chunk-JOCKHLFT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-B6O6UBS7.mjs → chunk-MRYKW5TM.mjs} +2 -2
- package/dist/lib/node-esm/chunk-MRYKW5TM.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2L2X4JMP.mjs → chunk-U5Q2NI7H.mjs} +5 -5
- package/dist/lib/node-esm/{chunk-N7NES6SZ.mjs → chunk-W76WUTZY.mjs} +57 -20
- package/dist/lib/node-esm/chunk-W76WUTZY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MN5S5J4O.mjs → chunk-Y7PJXFCJ.mjs} +60 -20
- package/dist/lib/node-esm/chunk-Y7PJXFCJ.mjs.map +7 -0
- package/dist/lib/node-esm/{compute-runtime-W5UJNSQY.mjs → compute-runtime-IXCSD3W7.mjs} +27 -71
- package/dist/lib/node-esm/compute-runtime-IXCSD3W7.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +3 -4
- package/dist/lib/node-esm/index.mjs +26 -10
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/{intent-resolver-ROEBZXSS.mjs → intent-resolver-KDRYB5BC.mjs} +8 -8
- package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-A4KTYX6Z.mjs → react-surface-Y2BBJV2I.mjs} +5 -6
- package/dist/lib/node-esm/react-surface-Y2BBJV2I.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +3 -2
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +2 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +2 -2
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +7 -5
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +4 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +4 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +2 -2
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +1 -1
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +33 -31
- package/src/AutomationPlugin.tsx +4 -2
- package/src/capabilities/app-graph-builder.ts +7 -6
- package/src/capabilities/capabilities.ts +3 -2
- package/src/capabilities/compute-runtime.ts +7 -5
- package/src/capabilities/intent-resolver.ts +5 -5
- package/src/capabilities/react-surface.tsx +2 -3
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +3 -4
- package/src/components/AutomationPanel/AutomationPanel.tsx +91 -28
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +22 -10
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +10 -4
- package/src/components/TriggerEditor/SpecSelector.tsx +12 -6
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +58 -17
- package/src/components/TriggerEditor/TriggerEditor.tsx +44 -18
- package/src/events.ts +11 -0
- package/src/hooks/useComputeRuntimeCallback.ts +3 -1
- package/src/hooks/useTriggerRuntimeControls.ts +4 -4
- package/src/index.ts +2 -0
- package/src/meta.ts +5 -2
- package/src/testing/test-functions.ts +1 -1
- package/src/translations.ts +1 -0
- package/src/types/schema.ts +1 -1
- package/dist/lib/browser/AutomationPanel-4QA5G3ZY.mjs +0 -11
- package/dist/lib/browser/app-graph-builder-6TP6ZNYG.mjs.map +0 -7
- package/dist/lib/browser/chunk-BDJPBZGC.mjs +0 -14
- package/dist/lib/browser/chunk-BDJPBZGC.mjs.map +0 -7
- package/dist/lib/browser/chunk-EAQL33PI.mjs.map +0 -7
- package/dist/lib/browser/chunk-F4K5EMWL.mjs.map +0 -7
- package/dist/lib/browser/chunk-IN2YC7NY.mjs.map +0 -7
- package/dist/lib/browser/chunk-LNMCGQC2.mjs.map +0 -7
- package/dist/lib/browser/chunk-M2WQCY2T.mjs.map +0 -7
- package/dist/lib/browser/chunk-WWURMV25.mjs +0 -13
- package/dist/lib/browser/chunk-WWURMV25.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZTXBAXUT.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-OFQPXD5I.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-JXVWRAAH.mjs.map +0 -7
- package/dist/lib/browser/react-surface-NG3MJCDH.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-3A2NIPR5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5MQJPJR2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-B6O6UBS7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CEWZ2CDM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DSEZPWSO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MN5S5J4O.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-N7NES6SZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PBULJE4B.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UTZIMYCX.mjs +0 -16
- package/dist/lib/node-esm/chunk-UTZIMYCX.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-W5UJNSQY.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-ROEBZXSS.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-A4KTYX6Z.mjs.map +0 -7
- /package/dist/lib/browser/{AutomationPanel-4QA5G3ZY.mjs.map → AutomationPanel-LBXJDM6Z.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsContainer-BQ6VBDIG.mjs.map → FunctionsContainer-IZTCGNJZ.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-QBTOFFNU.mjs.map → FunctionsPanel-HFCK3JRB.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-U66KBK53.mjs.map → chunk-XXZNGORC.mjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-WMVR3IST.mjs.map → AutomationPanel-NVEIUIZP.mjs.map} +0 -0
- /package/dist/lib/{browser/AutomationSettings-6XLG2PCK.mjs.map → node-esm/AutomationSettings-VIIEPI2P.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsContainer-LHUUOLA5.mjs.map → FunctionsContainer-KKRCIXGB.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-SHTQIMDV.mjs.map → FunctionsPanel-74ELGR7P.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-2L2X4JMP.mjs.map → chunk-U5Q2NI7H.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-automation",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.ae835ea",
|
|
4
4
|
"description": "Prompt chain plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -49,42 +49,44 @@
|
|
|
49
49
|
"@effect/platform-browser": "0.72.0",
|
|
50
50
|
"@preact-signals/safe-react": "^0.9.0",
|
|
51
51
|
"@preact/signals-core": "^1.12.1",
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/async": "0.8.4-main.
|
|
56
|
-
"@dxos/conductor": "0.8.4-main.
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/plugin-client": "0.8.4-main.
|
|
65
|
-
"@dxos/plugin-deck": "0.8.4-main.
|
|
66
|
-
"@dxos/plugin-
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/
|
|
70
|
-
"@dxos/react-ui-
|
|
71
|
-
"@dxos/react-
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/react-ui-
|
|
74
|
-
"@dxos/
|
|
52
|
+
"@dxos/app-framework": "0.8.4-main.ae835ea",
|
|
53
|
+
"@dxos/assistant": "0.8.4-main.ae835ea",
|
|
54
|
+
"@dxos/ai": "0.8.4-main.ae835ea",
|
|
55
|
+
"@dxos/async": "0.8.4-main.ae835ea",
|
|
56
|
+
"@dxos/conductor": "0.8.4-main.ae835ea",
|
|
57
|
+
"@dxos/context": "0.8.4-main.ae835ea",
|
|
58
|
+
"@dxos/echo": "0.8.4-main.ae835ea",
|
|
59
|
+
"@dxos/invariant": "0.8.4-main.ae835ea",
|
|
60
|
+
"@dxos/keys": "0.8.4-main.ae835ea",
|
|
61
|
+
"@dxos/functions": "0.8.4-main.ae835ea",
|
|
62
|
+
"@dxos/live-object": "0.8.4-main.ae835ea",
|
|
63
|
+
"@dxos/log": "0.8.4-main.ae835ea",
|
|
64
|
+
"@dxos/plugin-client": "0.8.4-main.ae835ea",
|
|
65
|
+
"@dxos/plugin-deck": "0.8.4-main.ae835ea",
|
|
66
|
+
"@dxos/plugin-graph": "0.8.4-main.ae835ea",
|
|
67
|
+
"@dxos/plugin-space": "0.8.4-main.ae835ea",
|
|
68
|
+
"@dxos/random": "0.8.4-main.ae835ea",
|
|
69
|
+
"@dxos/react-client": "0.8.4-main.ae835ea",
|
|
70
|
+
"@dxos/react-ui-components": "0.8.4-main.ae835ea",
|
|
71
|
+
"@dxos/react-ui-editor": "0.8.4-main.ae835ea",
|
|
72
|
+
"@dxos/react-ui-form": "0.8.4-main.ae835ea",
|
|
73
|
+
"@dxos/react-ui-list": "0.8.4-main.ae835ea",
|
|
74
|
+
"@dxos/react-ui-stack": "0.8.4-main.ae835ea",
|
|
75
|
+
"@dxos/schema": "0.8.4-main.ae835ea",
|
|
76
|
+
"@dxos/util": "0.8.4-main.ae835ea"
|
|
75
77
|
},
|
|
76
78
|
"devDependencies": {
|
|
77
79
|
"@effect-rx/rx-react": "0.42.4",
|
|
78
80
|
"@effect/platform": "0.92.1",
|
|
79
|
-
"@types/react": "~19.2.
|
|
80
|
-
"@types/react-dom": "~19.2.
|
|
81
|
+
"@types/react": "~19.2.2",
|
|
82
|
+
"@types/react-dom": "~19.2.2",
|
|
81
83
|
"effect": "3.18.3",
|
|
82
84
|
"react": "~19.2.0",
|
|
83
85
|
"react-dom": "~19.2.0",
|
|
84
86
|
"vite": "7.1.9",
|
|
85
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/
|
|
87
|
+
"@dxos/react-ui": "0.8.4-main.ae835ea",
|
|
88
|
+
"@dxos/storybook-utils": "0.8.4-main.ae835ea",
|
|
89
|
+
"@dxos/react-ui-theme": "0.8.4-main.ae835ea"
|
|
88
90
|
},
|
|
89
91
|
"peerDependencies": {
|
|
90
92
|
"@effect-rx/rx-react": "^0.34.1",
|
|
@@ -92,8 +94,8 @@
|
|
|
92
94
|
"effect": "^3.13.3",
|
|
93
95
|
"react": "^19.0.0",
|
|
94
96
|
"react-dom": "^19.0.0",
|
|
95
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
96
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
97
|
+
"@dxos/react-ui": "0.8.4-main.ae835ea",
|
|
98
|
+
"@dxos/react-ui-theme": "0.8.4-main.ae835ea"
|
|
97
99
|
},
|
|
98
100
|
"publishConfig": {
|
|
99
101
|
"access": "public"
|
package/src/AutomationPlugin.tsx
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
|
|
6
|
-
import {
|
|
6
|
+
import { Function, Trigger } from '@dxos/functions';
|
|
7
7
|
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
8
8
|
|
|
9
9
|
import { AppGraphBuilder, ComputeRuntime, IntentResolver, ReactSurface } from './capabilities';
|
|
10
|
+
import { AutomationEvents } from './events';
|
|
10
11
|
import { meta } from './meta';
|
|
11
12
|
import { translations } from './translations';
|
|
12
13
|
|
|
@@ -19,7 +20,7 @@ export const AutomationPlugin = definePlugin(meta, () => [
|
|
|
19
20
|
defineModule({
|
|
20
21
|
id: `${meta.id}/module/schema`,
|
|
21
22
|
activatesOn: ClientEvents.SetupSchema,
|
|
22
|
-
activate: () => contributes(ClientCapabilities.Schema, [
|
|
23
|
+
activate: () => contributes(ClientCapabilities.Schema, [Function.Function, Trigger.Trigger]),
|
|
23
24
|
}),
|
|
24
25
|
defineModule({
|
|
25
26
|
id: `${meta.id}/module/app-graph-builder`,
|
|
@@ -39,6 +40,7 @@ export const AutomationPlugin = definePlugin(meta, () => [
|
|
|
39
40
|
defineModule({
|
|
40
41
|
id: `${meta.id}/module/compute-runtime`,
|
|
41
42
|
activatesOn: ClientEvents.ClientReady,
|
|
43
|
+
activatesAfter: [AutomationEvents.ComputeRuntimeReady],
|
|
42
44
|
activate: ComputeRuntime,
|
|
43
45
|
}),
|
|
44
46
|
]);
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Rx } from '@effect-rx/rx-react';
|
|
6
|
-
import
|
|
6
|
+
import * as Function from 'effect/Function';
|
|
7
|
+
import * as Option from 'effect/Option';
|
|
7
8
|
|
|
8
9
|
import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
|
|
9
10
|
import { Obj } from '@dxos/echo';
|
|
10
|
-
import {
|
|
11
|
+
import { Script } from '@dxos/functions';
|
|
11
12
|
import { ATTENDABLE_PATH_SEPARATOR, PLANK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
|
|
12
13
|
import { createExtension } from '@dxos/plugin-graph';
|
|
13
14
|
import { meta as spaceMeta } from '@dxos/plugin-space';
|
|
@@ -20,7 +21,7 @@ export default (context: PluginContext) =>
|
|
|
20
21
|
id: `${meta.id}/space-settings-automation`,
|
|
21
22
|
connector: (node) =>
|
|
22
23
|
Rx.make((get) =>
|
|
23
|
-
pipe(
|
|
24
|
+
Function.pipe(
|
|
24
25
|
get(node),
|
|
25
26
|
Option.flatMap((node) => (node.type === `${spaceMeta.id}/settings` ? Option.some(node) : Option.none())),
|
|
26
27
|
Option.map((node) => [
|
|
@@ -42,7 +43,7 @@ export default (context: PluginContext) =>
|
|
|
42
43
|
id: `${meta.id}/space-settings-functions`,
|
|
43
44
|
connector: (node) =>
|
|
44
45
|
Rx.make((get) =>
|
|
45
|
-
pipe(
|
|
46
|
+
Function.pipe(
|
|
46
47
|
get(node),
|
|
47
48
|
Option.flatMap((node) => (node.type === `${spaceMeta.id}/settings` ? Option.some(node) : Option.none())),
|
|
48
49
|
Option.map((node) => [
|
|
@@ -64,9 +65,9 @@ export default (context: PluginContext) =>
|
|
|
64
65
|
id: `${meta.id}/script-companion`,
|
|
65
66
|
connector: (node) =>
|
|
66
67
|
Rx.make((get) =>
|
|
67
|
-
pipe(
|
|
68
|
+
Function.pipe(
|
|
68
69
|
get(node),
|
|
69
|
-
Option.flatMap((node) => (Obj.instanceOf(
|
|
70
|
+
Option.flatMap((node) => (Obj.instanceOf(Script.Script, node.data) ? Option.some(node) : Option.none())),
|
|
70
71
|
Option.map((node) => [
|
|
71
72
|
{
|
|
72
73
|
id: [node.id, 'automation'].join(ATTENDABLE_PATH_SEPARATOR),
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import type * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
6
6
|
|
|
7
7
|
import { type AiService, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';
|
|
8
8
|
import { defineCapability } from '@dxos/app-framework';
|
|
@@ -36,8 +36,9 @@ export namespace AutomationCapabilities {
|
|
|
36
36
|
| ToolResolverService
|
|
37
37
|
| ToolExecutionService;
|
|
38
38
|
|
|
39
|
+
export type ComputeRuntime = ManagedRuntime.ManagedRuntime<AutomationCapabilities.ComputeServices, never>;
|
|
39
40
|
export interface ComputeRuntimeProvider {
|
|
40
|
-
getRuntime(spaceId: SpaceId):
|
|
41
|
+
getRuntime(spaceId: SpaceId): ComputeRuntime;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
/**
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
5
|
+
import * as Toolkit from '@effect/ai/Toolkit';
|
|
6
|
+
import * as BrowserKeyValueStore from '@effect/platform-browser/BrowserKeyValueStore';
|
|
7
|
+
import * as Effect from 'effect/Effect';
|
|
8
|
+
import * as Layer from 'effect/Layer';
|
|
9
|
+
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
8
10
|
|
|
9
11
|
import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
|
|
10
12
|
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
|
|
@@ -37,7 +39,7 @@ export default async (context: PluginContext) => {
|
|
|
37
39
|
};
|
|
38
40
|
|
|
39
41
|
class ComputeRuntimeProviderImpl extends Resource implements AutomationCapabilities.ComputeRuntimeProvider {
|
|
40
|
-
readonly #runtimes = new Map<SpaceId,
|
|
42
|
+
readonly #runtimes = new Map<SpaceId, AutomationCapabilities.ComputeRuntime>();
|
|
41
43
|
readonly #context: PluginContext;
|
|
42
44
|
|
|
43
45
|
constructor(context: PluginContext) {
|
|
@@ -52,7 +54,7 @@ class ComputeRuntimeProviderImpl extends Resource implements AutomationCapabilit
|
|
|
52
54
|
this.#runtimes.clear();
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
getRuntime(spaceId: SpaceId):
|
|
57
|
+
getRuntime(spaceId: SpaceId): AutomationCapabilities.ComputeRuntime {
|
|
56
58
|
if (this.#runtimes.has(spaceId)) {
|
|
57
59
|
return this.#runtimes.get(spaceId)!;
|
|
58
60
|
}
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
createIntent,
|
|
11
11
|
createResolver,
|
|
12
12
|
} from '@dxos/app-framework';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { Ref } from '@dxos/echo';
|
|
14
|
+
import { Function, Script, Trigger } from '@dxos/functions';
|
|
15
15
|
import { type DXN } from '@dxos/keys';
|
|
16
16
|
import { ATTENDABLE_PATH_SEPARATOR } from '@dxos/plugin-deck/types';
|
|
17
17
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
@@ -24,17 +24,17 @@ export default (context: PluginContext) =>
|
|
|
24
24
|
createResolver({
|
|
25
25
|
intent: AutomationAction.CreateTriggerFromTemplate,
|
|
26
26
|
resolve: async ({ space, template, enabled = false, scriptName, input }) => {
|
|
27
|
-
const trigger =
|
|
27
|
+
const trigger = Trigger.make({ enabled, input });
|
|
28
28
|
|
|
29
29
|
// TODO(wittjosiah): Factor out function lookup by script name?
|
|
30
30
|
if (scriptName) {
|
|
31
31
|
const {
|
|
32
32
|
objects: [script],
|
|
33
|
-
} = await space.db.query(Filter.type(
|
|
33
|
+
} = await space.db.query(Filter.type(Script.Script, { name: scriptName })).run();
|
|
34
34
|
if (script) {
|
|
35
35
|
const {
|
|
36
36
|
objects: [fn],
|
|
37
|
-
} = await space.db.query(Filter.type(
|
|
37
|
+
} = await space.db.query(Filter.type(Function.Function, { source: Ref.make(script) })).run();
|
|
38
38
|
if (fn) {
|
|
39
39
|
trigger.function = Ref.make(fn);
|
|
40
40
|
}
|
|
@@ -6,7 +6,6 @@ import React from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Capabilities, contributes, createSurface, useLayout } from '@dxos/app-framework';
|
|
8
8
|
import { Obj } from '@dxos/echo';
|
|
9
|
-
import { ScriptType } from '@dxos/functions';
|
|
10
9
|
import { getSpace, parseId, useSpace } from '@dxos/react-client/echo';
|
|
11
10
|
|
|
12
11
|
import { AutomationSettings, FunctionsContainer } from '../components';
|
|
@@ -47,8 +46,8 @@ export default () =>
|
|
|
47
46
|
createSurface({
|
|
48
47
|
id: `${meta.id}/companion/automation`,
|
|
49
48
|
role: 'article',
|
|
50
|
-
filter: (data): data is { companionTo:
|
|
51
|
-
Obj.
|
|
49
|
+
filter: (data): data is { companionTo: Obj.Any; subject: 'automation' } =>
|
|
50
|
+
Obj.isObject(data.companionTo) && data.subject === 'automation',
|
|
52
51
|
component: ({ data }) => {
|
|
53
52
|
return <AutomationSettings space={getSpace(data.companionTo)!} object={data.companionTo} />;
|
|
54
53
|
},
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { FunctionTrigger, FunctionType } from '@dxos/functions';
|
|
8
|
+
import { Function, Trigger } from '@dxos/functions';
|
|
10
9
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
11
10
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
11
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
@@ -36,10 +35,10 @@ const meta = {
|
|
|
36
35
|
withClientProvider({
|
|
37
36
|
createIdentity: true,
|
|
38
37
|
createSpace: true,
|
|
39
|
-
types: [
|
|
38
|
+
types: [Function.Function, Trigger.Trigger],
|
|
40
39
|
onCreateSpace: ({ space }) => {
|
|
41
40
|
for (const fn of functions) {
|
|
42
|
-
space.db.add(
|
|
41
|
+
space.db.add(Function.make(fn));
|
|
43
42
|
}
|
|
44
43
|
},
|
|
45
44
|
}),
|
|
@@ -2,17 +2,22 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
5
|
+
import * as Array from 'effect/Array';
|
|
6
|
+
import * as EFn from 'effect/Function';
|
|
7
|
+
import * as Match from 'effect/Match';
|
|
8
|
+
import * as Schema from 'effect/Schema';
|
|
9
|
+
import React, { useMemo, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
import { Filter, Obj, Tag } from '@dxos/echo';
|
|
12
|
+
import { Function, Script, Trigger } from '@dxos/functions';
|
|
13
|
+
import { useTypeOptions } from '@dxos/plugin-space';
|
|
10
14
|
import { type Client, useClient } from '@dxos/react-client';
|
|
11
15
|
import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
12
16
|
import { Clipboard, IconButton, Input, Separator, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
13
17
|
import { ControlItem, controlItemClasses } from '@dxos/react-ui-form';
|
|
14
18
|
import { List } from '@dxos/react-ui-list';
|
|
15
19
|
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
20
|
+
import { DataType } from '@dxos/schema';
|
|
16
21
|
|
|
17
22
|
import { meta } from '../../meta';
|
|
18
23
|
import { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';
|
|
@@ -22,7 +27,7 @@ const grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';
|
|
|
22
27
|
export type AutomationPanelProps = ThemedClassName<{
|
|
23
28
|
space: Space;
|
|
24
29
|
object?: Obj.Any;
|
|
25
|
-
initialTrigger?:
|
|
30
|
+
initialTrigger?: Trigger.Trigger;
|
|
26
31
|
onDone?: () => void;
|
|
27
32
|
}>;
|
|
28
33
|
|
|
@@ -30,24 +35,28 @@ export type AutomationPanelProps = ThemedClassName<{
|
|
|
30
35
|
export const AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }: AutomationPanelProps) => {
|
|
31
36
|
const { t } = useTranslation(meta.id);
|
|
32
37
|
const client = useClient();
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const functions = useQuery(space, Filter.type(Function.Function));
|
|
39
|
+
const triggers = useQuery(space, Filter.type(Trigger.Trigger));
|
|
40
|
+
const filteredTriggers = useMemo(() => {
|
|
41
|
+
return object ? triggers.filter(triggerMatch(object)) : triggers;
|
|
42
|
+
}, [object, triggers]);
|
|
43
|
+
const tags = useQuery(space, Filter.type(Tag.Tag));
|
|
44
|
+
const types = useTypeOptions({ space, annotation: ['dynamic', 'limited-static', 'object-form'] });
|
|
45
|
+
|
|
46
|
+
const [trigger, setTrigger] = useState<Trigger.Trigger | undefined>(initialTrigger);
|
|
47
|
+
const [selected, setSelected] = useState<Trigger.Trigger>();
|
|
48
|
+
|
|
49
|
+
const handleSelect = (trigger: Trigger.Trigger) => {
|
|
41
50
|
setTrigger(trigger);
|
|
42
51
|
setSelected(trigger);
|
|
43
52
|
};
|
|
44
53
|
|
|
45
54
|
const handleAdd = () => {
|
|
46
|
-
setTrigger(
|
|
55
|
+
setTrigger(Trigger.make({}));
|
|
47
56
|
setSelected(undefined);
|
|
48
57
|
};
|
|
49
58
|
|
|
50
|
-
const handleDelete = (trigger:
|
|
59
|
+
const handleDelete = (trigger: Trigger.Trigger) => {
|
|
51
60
|
space.db.remove(trigger);
|
|
52
61
|
setTrigger(undefined);
|
|
53
62
|
setSelected(undefined);
|
|
@@ -57,7 +66,7 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
57
66
|
if (selected) {
|
|
58
67
|
Object.assign(selected, trigger);
|
|
59
68
|
} else {
|
|
60
|
-
space.db.add(
|
|
69
|
+
space.db.add(Trigger.make(trigger));
|
|
61
70
|
}
|
|
62
71
|
|
|
63
72
|
setTrigger(undefined);
|
|
@@ -73,21 +82,33 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
73
82
|
if (trigger) {
|
|
74
83
|
return (
|
|
75
84
|
<ControlItem title={t('trigger editor title')}>
|
|
76
|
-
<TriggerEditor
|
|
85
|
+
<TriggerEditor
|
|
86
|
+
space={space}
|
|
87
|
+
trigger={trigger}
|
|
88
|
+
readonlySpec={Boolean(object)}
|
|
89
|
+
tags={tags}
|
|
90
|
+
types={types}
|
|
91
|
+
onSave={handleSave}
|
|
92
|
+
onCancel={handleCancel}
|
|
93
|
+
/>
|
|
77
94
|
</ControlItem>
|
|
78
95
|
);
|
|
79
96
|
}
|
|
80
97
|
|
|
81
98
|
return (
|
|
82
99
|
<div className={mx(controlItemClasses, classNames)}>
|
|
83
|
-
{
|
|
84
|
-
<List.Root<
|
|
85
|
-
{
|
|
100
|
+
{filteredTriggers.length > 0 && (
|
|
101
|
+
<List.Root<Trigger.Trigger>
|
|
102
|
+
items={filteredTriggers}
|
|
103
|
+
isItem={Schema.is(Trigger.Trigger)}
|
|
104
|
+
getId={(field) => field.id}
|
|
105
|
+
>
|
|
106
|
+
{({ items: filteredTriggers }) => (
|
|
86
107
|
<div role='list' className='flex flex-col w-full'>
|
|
87
|
-
{
|
|
108
|
+
{filteredTriggers?.map((trigger) => {
|
|
88
109
|
const copyAction = getCopyAction(client, trigger);
|
|
89
110
|
return (
|
|
90
|
-
<List.Item<
|
|
111
|
+
<List.Item<Trigger.Trigger>
|
|
91
112
|
key={trigger.id}
|
|
92
113
|
item={trigger}
|
|
93
114
|
classNames={mx(grid, ghostHover, 'items-center', 'px-2')}
|
|
@@ -104,7 +125,7 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
104
125
|
classNames='px-1 cursor-pointer w-0 shrink truncate'
|
|
105
126
|
onClick={() => handleSelect(trigger)}
|
|
106
127
|
>
|
|
107
|
-
{getFunctionName(
|
|
128
|
+
{getFunctionName(functions, trigger) ?? '∅'}
|
|
108
129
|
</List.ItemTitle>
|
|
109
130
|
|
|
110
131
|
{/* TODO: a better way to expose copy action */}
|
|
@@ -124,13 +145,13 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
124
145
|
)}
|
|
125
146
|
</List.Root>
|
|
126
147
|
)}
|
|
127
|
-
{
|
|
148
|
+
{filteredTriggers.length > 0 && <Separator classNames='mlb-4' />}
|
|
128
149
|
<IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />
|
|
129
150
|
</div>
|
|
130
151
|
);
|
|
131
152
|
};
|
|
132
153
|
|
|
133
|
-
const getCopyAction = (client: Client, trigger:
|
|
154
|
+
const getCopyAction = (client: Client, trigger: Trigger.Trigger | undefined) => {
|
|
134
155
|
if (trigger?.spec?.kind === 'email') {
|
|
135
156
|
return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };
|
|
136
157
|
}
|
|
@@ -142,7 +163,7 @@ const getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) =>
|
|
|
142
163
|
return undefined;
|
|
143
164
|
};
|
|
144
165
|
|
|
145
|
-
const getWebhookUrl = (client: Client, trigger:
|
|
166
|
+
const getWebhookUrl = (client: Client, trigger: Trigger.Trigger) => {
|
|
146
167
|
const spaceId = getSpace(trigger)!.id;
|
|
147
168
|
const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);
|
|
148
169
|
const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');
|
|
@@ -150,10 +171,52 @@ const getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {
|
|
|
150
171
|
return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();
|
|
151
172
|
};
|
|
152
173
|
|
|
153
|
-
const getFunctionName = (
|
|
174
|
+
const getFunctionName = (functions: Function.Function[], trigger: Trigger.Trigger) => {
|
|
154
175
|
// TODO(wittjosiah): Truncation should be done in the UI.
|
|
155
176
|
// Warning that the List component is currently a can of worms.
|
|
156
177
|
const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}…`;
|
|
157
178
|
const functionObject = functions.find((fn) => fn === trigger.function?.target);
|
|
158
179
|
return functionObject?.name ?? shortId;
|
|
159
180
|
};
|
|
181
|
+
|
|
182
|
+
const scriptMatch = (script: Script.Script) => (trigger: Trigger.Trigger) => {
|
|
183
|
+
const fn = trigger.function?.target;
|
|
184
|
+
if (!Obj.instanceOf(Function.Function, fn)) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return fn.source?.target === script;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const projectMatch = (project: DataType.Project) => {
|
|
192
|
+
const viewQueries = EFn.pipe(
|
|
193
|
+
project.collections,
|
|
194
|
+
Array.map((collection) => collection.target),
|
|
195
|
+
Array.filter(Schema.is(DataType.View)),
|
|
196
|
+
Array.map((view) => Obj.getSnapshot(view).query.ast),
|
|
197
|
+
Array.map((ast) => JSON.stringify(ast)),
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
return (trigger: Trigger.Trigger) => {
|
|
201
|
+
const spec = Obj.getSnapshot(trigger).spec;
|
|
202
|
+
if (spec?.kind !== 'subscription') {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// TODO(wittjosiah): Implement better way of comparing query ASTs.
|
|
207
|
+
return viewQueries.some((query) => JSON.stringify(spec.query) === query);
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const triggerMatch = Match.type<Obj.Any>().pipe(
|
|
212
|
+
Match.withReturnType<(trigger: Trigger.Trigger) => boolean>(),
|
|
213
|
+
Match.when(
|
|
214
|
+
(obj) => Obj.instanceOf(Script.Script, obj),
|
|
215
|
+
(obj) => scriptMatch(obj),
|
|
216
|
+
),
|
|
217
|
+
Match.when(
|
|
218
|
+
(obj) => Obj.instanceOf(DataType.Project, obj),
|
|
219
|
+
(obj) => projectMatch(obj),
|
|
220
|
+
),
|
|
221
|
+
Match.orElse((_obj) => () => true),
|
|
222
|
+
);
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
import { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
|
-
import {
|
|
9
|
+
import { Function, Script } from '@dxos/functions';
|
|
10
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
10
11
|
import { Filter, type Space, fullyQualifiedId, useQuery } from '@dxos/react-client/echo';
|
|
11
|
-
import { Button, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Button, IconButton, useTranslation } from '@dxos/react-ui';
|
|
12
13
|
import { controlItemClasses } from '@dxos/react-ui-form';
|
|
13
14
|
import { List } from '@dxos/react-ui-list';
|
|
14
15
|
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
@@ -23,8 +24,8 @@ export type FunctionsPanelProps = {
|
|
|
23
24
|
|
|
24
25
|
export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
25
26
|
const { t } = useTranslation(meta.id);
|
|
26
|
-
const functions = useQuery(space, Filter.type(
|
|
27
|
-
const scripts = useQuery(space, Filter.type(
|
|
27
|
+
const functions = useQuery(space, Filter.type(Function.Function));
|
|
28
|
+
const scripts = useQuery(space, Filter.type(Script.Script));
|
|
28
29
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
29
30
|
|
|
30
31
|
const functionToScriptMap = useMemo(
|
|
@@ -40,13 +41,13 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
40
41
|
}
|
|
41
42
|
return map;
|
|
42
43
|
},
|
|
43
|
-
{} as Record<string,
|
|
44
|
+
{} as Record<string, Script.Script>,
|
|
44
45
|
),
|
|
45
46
|
[functions, scripts],
|
|
46
47
|
);
|
|
47
48
|
|
|
48
49
|
const getScriptName = useCallback(
|
|
49
|
-
(func:
|
|
50
|
+
(func: Function.Function) => {
|
|
50
51
|
const script = functionToScriptMap[func.id];
|
|
51
52
|
return script?.name;
|
|
52
53
|
},
|
|
@@ -54,7 +55,7 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
54
55
|
);
|
|
55
56
|
|
|
56
57
|
const handleGoToScript = useCallback(
|
|
57
|
-
(func:
|
|
58
|
+
(func: Function.Function) => {
|
|
58
59
|
const script = functionToScriptMap[func.id];
|
|
59
60
|
if (script) {
|
|
60
61
|
void dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(script)] }));
|
|
@@ -63,14 +64,19 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
63
64
|
[functionToScriptMap, dispatch],
|
|
64
65
|
);
|
|
65
66
|
|
|
67
|
+
const handleDelete = useCallback(
|
|
68
|
+
(func: Function.Function) => dispatch(createIntent(SpaceAction.RemoveObjects, { objects: [func] })),
|
|
69
|
+
[dispatch],
|
|
70
|
+
);
|
|
71
|
+
|
|
66
72
|
return (
|
|
67
73
|
<div role='none' className={mx(controlItemClasses)}>
|
|
68
74
|
{functions.length > 0 && (
|
|
69
|
-
<List.Root<
|
|
75
|
+
<List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>
|
|
70
76
|
{({ items }) => (
|
|
71
77
|
<div role='list' className='flex flex-col w-full'>
|
|
72
78
|
{items?.map((func) => (
|
|
73
|
-
<List.Item<
|
|
79
|
+
<List.Item<Function.Function>
|
|
74
80
|
key={func.id}
|
|
75
81
|
item={func}
|
|
76
82
|
classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
|
|
@@ -84,6 +90,12 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
84
90
|
{functionToScriptMap[func.id] && (
|
|
85
91
|
<Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>
|
|
86
92
|
)}
|
|
93
|
+
<IconButton
|
|
94
|
+
iconOnly
|
|
95
|
+
icon='ph--trash--regular'
|
|
96
|
+
label={t('delete function button label')}
|
|
97
|
+
onClick={() => handleDelete(func)}
|
|
98
|
+
/>
|
|
87
99
|
</List.Item>
|
|
88
100
|
))}
|
|
89
101
|
</div>
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Ref, Type } from '@dxos/echo';
|
|
8
|
-
import { type JsonPath } from '@dxos/echo
|
|
9
|
-
import { type
|
|
8
|
+
import { type JsonPath } from '@dxos/echo/internal';
|
|
9
|
+
import { type Function } from '@dxos/functions';
|
|
10
10
|
import { useOnTransition } from '@dxos/react-ui';
|
|
11
11
|
import { Form, type FormInputStateProps, type QueryRefOptions, useFormValues } from '@dxos/react-ui-form';
|
|
12
12
|
|
|
13
13
|
export type FunctionInputEditorProps = {
|
|
14
|
-
functions:
|
|
14
|
+
functions: Function.Function[];
|
|
15
15
|
onQueryRefOptions: QueryRefOptions;
|
|
16
16
|
} & FormInputStateProps;
|
|
17
17
|
|
|
@@ -39,7 +39,13 @@ export const FunctionInputEditor = ({
|
|
|
39
39
|
useOnTransition(
|
|
40
40
|
// Clear function parameter input when the function changes.
|
|
41
41
|
selectedFunctionValue,
|
|
42
|
-
(prevValue) =>
|
|
42
|
+
(prevValue) => {
|
|
43
|
+
if (!Ref.isRef(prevValue) || !Ref.isRef(selectedFunctionValue)) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return prevValue.dxn.toString() !== selectedFunctionValue.dxn.toString();
|
|
48
|
+
},
|
|
43
49
|
(currValue) => currValue !== undefined,
|
|
44
50
|
() => onValueChange('object', {}),
|
|
45
51
|
);
|