@dxos/plugin-automation 0.8.4-main.c1de068 → 0.8.4-main.dedc0f3
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/{AutomationContainer-VZNV2ZQF.mjs → AutomationContainer-BRV5AJZ3.mjs} +6 -9
- package/dist/lib/browser/AutomationContainer-BRV5AJZ3.mjs.map +7 -0
- package/dist/lib/browser/{AutomationPanel-ZWA6GOFY.mjs → AutomationPanel-N5HFJJXW.mjs} +3 -3
- package/dist/lib/browser/{FunctionsContainer-IOB333TX.mjs → FunctionsContainer-U4HASI4P.mjs} +4 -7
- package/dist/lib/browser/FunctionsContainer-U4HASI4P.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-56ZKRVM5.mjs → FunctionsPanel-I443Y6KB.mjs} +2 -2
- package/dist/lib/browser/{app-graph-builder-ZTAUTFI4.mjs → app-graph-builder-4OFKIRAI.mjs} +2 -2
- package/dist/lib/{node-esm/app-graph-builder-3FP63ZSG.mjs.map → browser/app-graph-builder-4OFKIRAI.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-ERTIGJYE.mjs → chunk-4TWQV33E.mjs} +11 -15
- package/dist/lib/browser/chunk-4TWQV33E.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ECSTS2UI.mjs → chunk-EIY2EUWC.mjs} +5 -5
- package/dist/lib/browser/{chunk-FSJZXTS2.mjs → chunk-S4SM663I.mjs} +15 -15
- package/dist/lib/browser/chunk-S4SM663I.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LYJVTIVD.mjs → chunk-Z5DT4MHW.mjs} +2 -2
- package/dist/lib/{node-esm/chunk-ZGPUV5VS.mjs.map → browser/chunk-Z5DT4MHW.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +7 -7
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-U3ZAQEFW.mjs → intent-resolver-4PSYSQQG.mjs} +7 -6
- package/dist/lib/browser/intent-resolver-4PSYSQQG.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-4DFSM7OX.mjs → react-surface-M52XGLXY.mjs} +3 -3
- package/dist/lib/node-esm/{AutomationContainer-WMIH3F4V.mjs → AutomationContainer-FYRDTERM.mjs} +6 -9
- package/dist/lib/node-esm/AutomationContainer-FYRDTERM.mjs.map +7 -0
- package/dist/lib/node-esm/{AutomationPanel-YYUMSK2W.mjs → AutomationPanel-MKOLA2FE.mjs} +3 -3
- package/dist/lib/node-esm/{FunctionsContainer-DJWB6WFH.mjs → FunctionsContainer-VZIVURH6.mjs} +4 -7
- package/dist/lib/node-esm/FunctionsContainer-VZIVURH6.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-KGIOZSPZ.mjs → FunctionsPanel-ELINCXPW.mjs} +2 -2
- package/dist/lib/node-esm/{app-graph-builder-3FP63ZSG.mjs → app-graph-builder-555IHYOB.mjs} +2 -2
- package/dist/lib/{browser/app-graph-builder-ZTAUTFI4.mjs.map → node-esm/app-graph-builder-555IHYOB.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-HIMYPGHF.mjs → chunk-AONUBWBE.mjs} +11 -15
- package/dist/lib/node-esm/chunk-AONUBWBE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-SGZPTJ47.mjs → chunk-CICQ73ZT.mjs} +5 -5
- package/dist/lib/node-esm/{chunk-ZGPUV5VS.mjs → chunk-CX2AILIS.mjs} +2 -2
- package/dist/lib/{browser/chunk-LYJVTIVD.mjs.map → node-esm/chunk-CX2AILIS.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-AZH66CED.mjs → chunk-ZOJVKPCA.mjs} +15 -15
- package/dist/lib/node-esm/chunk-ZOJVKPCA.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +7 -7
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-3QWXEBPX.mjs → intent-resolver-6ZGBUILG.mjs} +7 -6
- package/dist/lib/node-esm/intent-resolver-6ZGBUILG.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-3PNW7NDW.mjs → react-surface-Y6AOXM75.mjs} +3 -3
- 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/index.d.ts +3 -3
- 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/components/AutomationContainer.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +6 -5
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +43 -3
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.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 +2 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +43 -3
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +30 -28
- package/src/AutomationPlugin.tsx +2 -2
- package/src/capabilities/app-graph-builder.ts +2 -2
- package/src/capabilities/intent-resolver.ts +7 -7
- package/src/components/AutomationContainer.tsx +11 -13
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +10 -7
- package/src/components/AutomationPanel/AutomationPanel.tsx +15 -27
- package/src/components/FunctionsContainer.tsx +10 -12
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +2 -2
- package/src/components/TriggerEditor/SpecSelector.tsx +14 -14
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +11 -8
- package/src/components/TriggerEditor/TriggerEditor.tsx +6 -12
- package/dist/lib/browser/AutomationContainer-VZNV2ZQF.mjs.map +0 -7
- package/dist/lib/browser/FunctionsContainer-IOB333TX.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERTIGJYE.mjs.map +0 -7
- package/dist/lib/browser/chunk-FSJZXTS2.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-U3ZAQEFW.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationContainer-WMIH3F4V.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-DJWB6WFH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AZH66CED.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HIMYPGHF.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-3QWXEBPX.mjs.map +0 -7
- /package/dist/lib/browser/{AutomationPanel-ZWA6GOFY.mjs.map → AutomationPanel-N5HFJJXW.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-56ZKRVM5.mjs.map → FunctionsPanel-I443Y6KB.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-ECSTS2UI.mjs.map → chunk-EIY2EUWC.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-4DFSM7OX.mjs.map → react-surface-M52XGLXY.mjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-YYUMSK2W.mjs.map → AutomationPanel-MKOLA2FE.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-KGIOZSPZ.mjs.map → FunctionsPanel-ELINCXPW.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-SGZPTJ47.mjs.map → chunk-CICQ73ZT.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-3PNW7NDW.mjs.map → react-surface-Y6AOXM75.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.dedc0f3",
|
|
4
4
|
"description": "Prompt chain plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
+
"source": "./src/index.ts",
|
|
13
14
|
"types": "./dist/types/src/index.d.ts",
|
|
14
15
|
"browser": "./dist/lib/browser/index.mjs",
|
|
15
16
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
16
17
|
},
|
|
17
18
|
"./types": {
|
|
19
|
+
"source": "./src/types/index.ts",
|
|
18
20
|
"types": "./dist/types/src/types/index.d.ts",
|
|
19
21
|
"browser": "./dist/lib/browser/types/index.mjs",
|
|
20
22
|
"node": "./dist/lib/node-esm/types/index.mjs"
|
|
@@ -32,38 +34,38 @@
|
|
|
32
34
|
"dependencies": {
|
|
33
35
|
"@preact-signals/safe-react": "^0.9.0",
|
|
34
36
|
"@preact/signals-core": "^1.9.0",
|
|
35
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/echo": "0.8.4-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/live-object": "0.8.4-main.
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/plugin-
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/plugin-deck": "0.8.4-main.
|
|
46
|
-
"@dxos/plugin-
|
|
47
|
-
"@dxos/random": "0.8.4-main.
|
|
48
|
-
"@dxos/react-client": "0.8.4-main.
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/react-ui-
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
37
|
+
"@dxos/app-framework": "0.8.4-main.dedc0f3",
|
|
38
|
+
"@dxos/conductor": "0.8.4-main.dedc0f3",
|
|
39
|
+
"@dxos/async": "0.8.4-main.dedc0f3",
|
|
40
|
+
"@dxos/echo": "0.8.4-main.dedc0f3",
|
|
41
|
+
"@dxos/functions": "0.8.4-main.dedc0f3",
|
|
42
|
+
"@dxos/echo-schema": "0.8.4-main.dedc0f3",
|
|
43
|
+
"@dxos/live-object": "0.8.4-main.dedc0f3",
|
|
44
|
+
"@dxos/log": "0.8.4-main.dedc0f3",
|
|
45
|
+
"@dxos/plugin-graph": "0.8.4-main.dedc0f3",
|
|
46
|
+
"@dxos/plugin-client": "0.8.4-main.dedc0f3",
|
|
47
|
+
"@dxos/plugin-deck": "0.8.4-main.dedc0f3",
|
|
48
|
+
"@dxos/plugin-space": "0.8.4-main.dedc0f3",
|
|
49
|
+
"@dxos/random": "0.8.4-main.dedc0f3",
|
|
50
|
+
"@dxos/react-client": "0.8.4-main.dedc0f3",
|
|
51
|
+
"@dxos/react-ui-form": "0.8.4-main.dedc0f3",
|
|
52
|
+
"@dxos/invariant": "0.8.4-main.dedc0f3",
|
|
53
|
+
"@dxos/react-ui-list": "0.8.4-main.dedc0f3",
|
|
54
|
+
"@dxos/react-ui-stack": "0.8.4-main.dedc0f3",
|
|
55
|
+
"@dxos/util": "0.8.4-main.dedc0f3"
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
58
|
"@effect-rx/rx-react": "0.38.0",
|
|
57
|
-
"@effect/platform": "0.
|
|
59
|
+
"@effect/platform": "0.90.2",
|
|
58
60
|
"@types/react": "~18.2.0",
|
|
59
61
|
"@types/react-dom": "~18.2.0",
|
|
60
|
-
"effect": "3.17.
|
|
62
|
+
"effect": "3.17.7",
|
|
61
63
|
"react": "~18.2.0",
|
|
62
64
|
"react-dom": "~18.2.0",
|
|
63
|
-
"vite": "
|
|
64
|
-
"@dxos/react-ui
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
65
|
+
"vite": "7.1.1",
|
|
66
|
+
"@dxos/react-ui": "0.8.4-main.dedc0f3",
|
|
67
|
+
"@dxos/react-ui-theme": "0.8.4-main.dedc0f3",
|
|
68
|
+
"@dxos/storybook-utils": "0.8.4-main.dedc0f3"
|
|
67
69
|
},
|
|
68
70
|
"peerDependencies": {
|
|
69
71
|
"@effect-rx/rx-react": "^0.34.1",
|
|
@@ -71,8 +73,8 @@
|
|
|
71
73
|
"effect": "^3.13.3",
|
|
72
74
|
"react": "~18.2.0",
|
|
73
75
|
"react-dom": "~18.2.0",
|
|
74
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
75
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
76
|
+
"@dxos/react-ui": "0.8.4-main.dedc0f3",
|
|
77
|
+
"@dxos/react-ui-theme": "0.8.4-main.dedc0f3"
|
|
76
78
|
},
|
|
77
79
|
"publishConfig": {
|
|
78
80
|
"access": "public"
|
package/src/AutomationPlugin.tsx
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Capabilities, contributes, defineModule, definePlugin
|
|
6
|
-
import {
|
|
5
|
+
import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
|
|
6
|
+
import { FunctionTrigger, FunctionType } from '@dxos/functions';
|
|
7
7
|
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
8
8
|
|
|
9
9
|
import { AppGraphBuilder, IntentResolver, ReactSurface } from './capabilities';
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import { Rx } from '@effect-rx/rx-react';
|
|
6
6
|
import { Option, pipe } from 'effect';
|
|
7
7
|
|
|
8
|
-
import { Capabilities,
|
|
8
|
+
import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
|
|
9
9
|
import { Obj } from '@dxos/echo';
|
|
10
10
|
import { ScriptType } from '@dxos/functions';
|
|
11
|
-
import {
|
|
11
|
+
import { ATTENDABLE_PATH_SEPARATOR, PLANK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
|
|
12
12
|
import { createExtension } from '@dxos/plugin-graph';
|
|
13
13
|
import { SPACE_PLUGIN } from '@dxos/plugin-space';
|
|
14
14
|
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
contributes,
|
|
7
6
|
Capabilities,
|
|
8
|
-
|
|
7
|
+
LayoutAction,
|
|
9
8
|
type PluginContext,
|
|
9
|
+
contributes,
|
|
10
10
|
createIntent,
|
|
11
|
-
|
|
11
|
+
createResolver,
|
|
12
12
|
} from '@dxos/app-framework';
|
|
13
13
|
import { Obj, Ref } from '@dxos/echo';
|
|
14
|
-
import { FunctionTrigger, FunctionType, ScriptType
|
|
14
|
+
import { FunctionTrigger, FunctionType, ScriptType } 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';
|
|
@@ -43,11 +43,11 @@ export default (context: PluginContext) =>
|
|
|
43
43
|
|
|
44
44
|
switch (template.type) {
|
|
45
45
|
case 'timer': {
|
|
46
|
-
trigger.spec = { kind:
|
|
46
|
+
trigger.spec = { kind: 'timer', cron: template.cron };
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
case 'queue': {
|
|
50
|
-
trigger.spec = { kind:
|
|
50
|
+
trigger.spec = { kind: 'queue', queue: (template.queueDXN as DXN).toString() };
|
|
51
51
|
break;
|
|
52
52
|
}
|
|
53
53
|
default: {
|
|
@@ -57,7 +57,7 @@ export default (context: PluginContext) =>
|
|
|
57
57
|
|
|
58
58
|
return {
|
|
59
59
|
intents: [
|
|
60
|
-
createIntent(SpaceAction.AddObject, { object: trigger, target: space }),
|
|
60
|
+
createIntent(SpaceAction.AddObject, { object: trigger, target: space, hidden: true }),
|
|
61
61
|
createIntent(LayoutAction.Open, {
|
|
62
62
|
part: 'main',
|
|
63
63
|
subject: [`automation-settings${ATTENDABLE_PATH_SEPARATOR}${space.id}`],
|
|
@@ -5,25 +5,23 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { useTranslation } from '@dxos/react-ui';
|
|
8
|
-
import {
|
|
9
|
-
import { StackItem } from '@dxos/react-ui-stack';
|
|
8
|
+
import { ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
10
9
|
|
|
11
|
-
import { AutomationPanel, type AutomationPanelProps } from './AutomationPanel';
|
|
12
10
|
import { AUTOMATION_PLUGIN } from '../meta';
|
|
13
11
|
|
|
12
|
+
import { AutomationPanel, type AutomationPanelProps } from './AutomationPanel';
|
|
13
|
+
|
|
14
14
|
export const AutomationContainer = (props: AutomationPanelProps) => {
|
|
15
15
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
16
16
|
return (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
</ControlPage>
|
|
26
|
-
</StackItem.Content>
|
|
17
|
+
<ControlPage>
|
|
18
|
+
<ControlSection
|
|
19
|
+
title={t('automation verbose label', { ns: AUTOMATION_PLUGIN })}
|
|
20
|
+
description={t('automation description', { ns: AUTOMATION_PLUGIN })}
|
|
21
|
+
>
|
|
22
|
+
<AutomationPanel {...props} />
|
|
23
|
+
</ControlSection>
|
|
24
|
+
</ControlPage>
|
|
27
25
|
);
|
|
28
26
|
};
|
|
29
27
|
|
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
|
|
10
10
|
import { Obj } from '@dxos/echo';
|
|
11
|
-
import {
|
|
11
|
+
import { FunctionTrigger, FunctionType } from '@dxos/functions';
|
|
12
12
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
13
13
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
14
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
15
15
|
|
|
16
|
-
import { AutomationPanel } from './AutomationPanel';
|
|
17
16
|
import { functions } from '../../testing';
|
|
18
17
|
import { translations } from '../../translations';
|
|
19
18
|
|
|
19
|
+
import { AutomationPanel } from './AutomationPanel';
|
|
20
|
+
|
|
20
21
|
const DefaultStory = () => {
|
|
21
22
|
const spaces = useSpaces();
|
|
22
23
|
const space = spaces[1];
|
|
@@ -28,9 +29,9 @@ const DefaultStory = () => {
|
|
|
28
29
|
);
|
|
29
30
|
};
|
|
30
31
|
|
|
31
|
-
const meta
|
|
32
|
+
const meta = {
|
|
32
33
|
title: 'plugins/plugin-automation/AutomationPanel',
|
|
33
|
-
component: AutomationPanel,
|
|
34
|
+
component: AutomationPanel as any,
|
|
34
35
|
render: DefaultStory,
|
|
35
36
|
decorators: [
|
|
36
37
|
withClientProvider({
|
|
@@ -50,8 +51,10 @@ const meta: Meta = {
|
|
|
50
51
|
layout: 'centered',
|
|
51
52
|
translations,
|
|
52
53
|
},
|
|
53
|
-
}
|
|
54
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
54
55
|
|
|
55
56
|
export default meta;
|
|
56
57
|
|
|
57
|
-
|
|
58
|
+
type Story = StoryObj<typeof meta>;
|
|
59
|
+
|
|
60
|
+
export const Default: Story = {};
|
|
@@ -6,17 +6,10 @@ import { Schema } from 'effect';
|
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Filter, Obj } from '@dxos/echo';
|
|
9
|
-
import {
|
|
10
|
-
FunctionType,
|
|
11
|
-
FunctionTrigger,
|
|
12
|
-
FunctionTriggerSchema,
|
|
13
|
-
type FunctionTriggerType,
|
|
14
|
-
ScriptType,
|
|
15
|
-
TriggerKind,
|
|
16
|
-
} from '@dxos/functions';
|
|
9
|
+
import { FunctionTrigger, FunctionType, ScriptType } from '@dxos/functions';
|
|
17
10
|
import { type Client, useClient } from '@dxos/react-client';
|
|
18
|
-
import {
|
|
19
|
-
import { Clipboard, IconButton, Input, Separator, useTranslation } from '@dxos/react-ui';
|
|
11
|
+
import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
12
|
+
import { Clipboard, IconButton, Input, Separator, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
20
13
|
import { ControlItem, controlItemClasses } from '@dxos/react-ui-form';
|
|
21
14
|
import { List } from '@dxos/react-ui-list';
|
|
22
15
|
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
@@ -26,32 +19,31 @@ import { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';
|
|
|
26
19
|
|
|
27
20
|
const grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';
|
|
28
21
|
|
|
29
|
-
export type AutomationPanelProps = {
|
|
22
|
+
export type AutomationPanelProps = ThemedClassName<{
|
|
30
23
|
space: Space;
|
|
31
24
|
object?: Obj.Any;
|
|
32
|
-
initialTrigger?:
|
|
25
|
+
initialTrigger?: FunctionTrigger;
|
|
33
26
|
onDone?: () => void;
|
|
34
|
-
}
|
|
27
|
+
}>;
|
|
35
28
|
|
|
36
29
|
// TODO(burdon): Factor out common layout with ViewEditor.
|
|
37
|
-
export const AutomationPanel = ({ space, object, initialTrigger, onDone }: AutomationPanelProps) => {
|
|
30
|
+
export const AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }: AutomationPanelProps) => {
|
|
38
31
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
39
32
|
const client = useClient();
|
|
40
33
|
const triggers = useQuery(space, Filter.type(FunctionTrigger));
|
|
41
34
|
const functions = useQuery(space, Filter.type(FunctionType));
|
|
42
35
|
const scripts = useQuery(space, Filter.type(ScriptType));
|
|
43
36
|
|
|
44
|
-
const [trigger, setTrigger] = useState<
|
|
37
|
+
const [trigger, setTrigger] = useState<FunctionTrigger | undefined>(initialTrigger);
|
|
45
38
|
const [selected, setSelected] = useState<FunctionTrigger>();
|
|
46
39
|
|
|
47
40
|
const handleSelect = (trigger: FunctionTrigger) => {
|
|
48
|
-
|
|
49
|
-
setTrigger(values);
|
|
41
|
+
setTrigger(trigger);
|
|
50
42
|
setSelected(trigger);
|
|
51
43
|
};
|
|
52
44
|
|
|
53
45
|
const handleAdd = () => {
|
|
54
|
-
setTrigger(Obj.make(
|
|
46
|
+
setTrigger(Obj.make(FunctionTrigger, {}));
|
|
55
47
|
setSelected(undefined);
|
|
56
48
|
};
|
|
57
49
|
|
|
@@ -87,7 +79,7 @@ export const AutomationPanel = ({ space, object, initialTrigger, onDone }: Autom
|
|
|
87
79
|
}
|
|
88
80
|
|
|
89
81
|
return (
|
|
90
|
-
<div className={controlItemClasses}>
|
|
82
|
+
<div className={mx(controlItemClasses, classNames)}>
|
|
91
83
|
{triggers.length > 0 && (
|
|
92
84
|
<List.Root<FunctionTrigger> items={triggers} isItem={Schema.is(FunctionTrigger)} getId={(field) => field.id}>
|
|
93
85
|
{({ items: triggers }) => (
|
|
@@ -139,11 +131,11 @@ export const AutomationPanel = ({ space, object, initialTrigger, onDone }: Autom
|
|
|
139
131
|
};
|
|
140
132
|
|
|
141
133
|
const getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) => {
|
|
142
|
-
if (trigger?.spec?.kind ===
|
|
134
|
+
if (trigger?.spec?.kind === 'email') {
|
|
143
135
|
return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };
|
|
144
136
|
}
|
|
145
137
|
|
|
146
|
-
if (trigger?.spec?.kind ===
|
|
138
|
+
if (trigger?.spec?.kind === 'webhook') {
|
|
147
139
|
return { translationKey: 'trigger copy url', contentProvider: () => getWebhookUrl(client, trigger) };
|
|
148
140
|
}
|
|
149
141
|
|
|
@@ -158,14 +150,10 @@ const getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {
|
|
|
158
150
|
return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();
|
|
159
151
|
};
|
|
160
152
|
|
|
161
|
-
const getFunctionName = (scripts: ScriptType[], functions: FunctionType[], trigger:
|
|
153
|
+
const getFunctionName = (scripts: ScriptType[], functions: FunctionType[], trigger: FunctionTrigger) => {
|
|
162
154
|
// TODO(wittjosiah): Truncation should be done in the UI.
|
|
163
155
|
// Warning that the List component is currently a can of worms.
|
|
164
156
|
const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}…`;
|
|
165
157
|
const functionObject = functions.find((fn) => fn === trigger.function?.target);
|
|
166
|
-
|
|
167
|
-
return shortId;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return scripts.find((s) => functionObject.source?.target?.id === s.id)?.name ?? shortId;
|
|
158
|
+
return functionObject?.name ?? shortId;
|
|
171
159
|
};
|
|
@@ -7,24 +7,22 @@ import React from 'react';
|
|
|
7
7
|
import { type Space } from '@dxos/react-client/echo';
|
|
8
8
|
import { useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
10
|
-
import { StackItem } from '@dxos/react-ui-stack';
|
|
11
10
|
|
|
12
|
-
import { FunctionsPanel } from './FunctionsPanel';
|
|
13
11
|
import { AUTOMATION_PLUGIN } from '../meta';
|
|
14
12
|
|
|
13
|
+
import { FunctionsPanel } from './FunctionsPanel';
|
|
14
|
+
|
|
15
15
|
export const FunctionsContainer = ({ space }: { space: Space }) => {
|
|
16
16
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
17
17
|
return (
|
|
18
|
-
<
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
</ControlPage>
|
|
27
|
-
</StackItem.Content>
|
|
18
|
+
<ControlPage>
|
|
19
|
+
<ControlSection
|
|
20
|
+
title={t('functions verbose label', { ns: AUTOMATION_PLUGIN })}
|
|
21
|
+
description={t('functions description', { ns: AUTOMATION_PLUGIN })}
|
|
22
|
+
>
|
|
23
|
+
<FunctionsPanel space={space} />
|
|
24
|
+
</ControlSection>
|
|
25
|
+
</ControlPage>
|
|
28
26
|
);
|
|
29
27
|
};
|
|
30
28
|
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import { Schema } from 'effect';
|
|
6
6
|
import React, { useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
9
9
|
import { FunctionType, ScriptType } from '@dxos/functions';
|
|
10
|
-
import { Filter, fullyQualifiedId, useQuery
|
|
10
|
+
import { Filter, type Space, fullyQualifiedId, useQuery } from '@dxos/react-client/echo';
|
|
11
11
|
import { Button, useTranslation } from '@dxos/react-ui';
|
|
12
12
|
import { controlItemClasses } from '@dxos/react-ui-form';
|
|
13
13
|
import { List } from '@dxos/react-ui-list';
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type FunctionTrigger, TriggerKinds, type TriggerType } from '@dxos/functions';
|
|
8
8
|
import { useTranslation } from '@dxos/react-ui';
|
|
9
|
-
import {
|
|
9
|
+
import { type InputProps, SelectInput, useInputProps } from '@dxos/react-ui-form';
|
|
10
10
|
|
|
11
11
|
import { AUTOMATION_PLUGIN } from '../../meta';
|
|
12
12
|
|
|
@@ -14,22 +14,22 @@ export type SpecSelectorProps = InputProps;
|
|
|
14
14
|
|
|
15
15
|
export const SpecSelector = (props: SpecSelectorProps) => {
|
|
16
16
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
17
|
-
const specProps = useInputProps(['spec' satisfies keyof
|
|
17
|
+
const specProps = useInputProps(['spec' satisfies keyof FunctionTrigger]);
|
|
18
18
|
|
|
19
19
|
const handleTypeChange = useCallback(
|
|
20
20
|
(_type: any, value: string): TriggerType | undefined => {
|
|
21
21
|
const getDefaultTriggerSpec = (kind: string) => {
|
|
22
22
|
switch (kind) {
|
|
23
|
-
case
|
|
24
|
-
return { kind:
|
|
25
|
-
case
|
|
26
|
-
return { kind:
|
|
27
|
-
case
|
|
28
|
-
return { kind:
|
|
29
|
-
case
|
|
30
|
-
return { kind:
|
|
31
|
-
case
|
|
32
|
-
return { kind:
|
|
23
|
+
case 'timer':
|
|
24
|
+
return { kind: 'timer', cron: '' };
|
|
25
|
+
case 'subscription':
|
|
26
|
+
return { kind: 'subscription', filter: {} };
|
|
27
|
+
case 'queue':
|
|
28
|
+
return { kind: 'queue', queue: '' };
|
|
29
|
+
case 'email':
|
|
30
|
+
return { kind: 'email' };
|
|
31
|
+
case 'webhook':
|
|
32
|
+
return { kind: 'webhook' };
|
|
33
33
|
default:
|
|
34
34
|
return undefined;
|
|
35
35
|
}
|
|
@@ -48,7 +48,7 @@ export const SpecSelector = (props: SpecSelectorProps) => {
|
|
|
48
48
|
|
|
49
49
|
const options = useMemo(
|
|
50
50
|
() =>
|
|
51
|
-
|
|
51
|
+
TriggerKinds.map((kind) => ({
|
|
52
52
|
value: kind,
|
|
53
53
|
label: t(`trigger type ${kind}`),
|
|
54
54
|
})),
|
|
@@ -4,20 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React, { useEffect, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { Obj } from '@dxos/echo';
|
|
11
|
-
import {
|
|
11
|
+
import { FunctionTrigger, FunctionType } from '@dxos/functions';
|
|
12
12
|
import { faker } from '@dxos/random';
|
|
13
13
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
14
14
|
import { ContactType, withClientProvider } from '@dxos/react-client/testing';
|
|
15
15
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
16
16
|
|
|
17
|
-
import { TriggerEditor } from './TriggerEditor';
|
|
18
17
|
import { functions } from '../../testing';
|
|
19
18
|
import { translations } from '../../translations';
|
|
20
19
|
|
|
20
|
+
import { TriggerEditor } from './TriggerEditor';
|
|
21
|
+
|
|
21
22
|
const DefaultStory = () => {
|
|
22
23
|
const spaces = useSpaces();
|
|
23
24
|
const space = spaces[1];
|
|
@@ -27,7 +28,7 @@ const DefaultStory = () => {
|
|
|
27
28
|
return;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
const trigger = space.db.add(Obj.make(FunctionTrigger, { spec: { kind:
|
|
31
|
+
const trigger = space.db.add(Obj.make(FunctionTrigger, { spec: { kind: 'timer', cron: '' } }));
|
|
31
32
|
setTrigger(trigger);
|
|
32
33
|
}, [space]);
|
|
33
34
|
|
|
@@ -42,9 +43,9 @@ const DefaultStory = () => {
|
|
|
42
43
|
);
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
const meta
|
|
46
|
+
const meta = {
|
|
46
47
|
title: 'plugins/plugin-automation/TriggerEditor',
|
|
47
|
-
component: TriggerEditor,
|
|
48
|
+
component: TriggerEditor as any,
|
|
48
49
|
render: DefaultStory,
|
|
49
50
|
decorators: [
|
|
50
51
|
withClientProvider({
|
|
@@ -71,8 +72,10 @@ const meta: Meta = {
|
|
|
71
72
|
parameters: {
|
|
72
73
|
translations,
|
|
73
74
|
},
|
|
74
|
-
}
|
|
75
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
75
76
|
|
|
76
77
|
export default meta;
|
|
77
78
|
|
|
78
|
-
|
|
79
|
+
type Story = StoryObj<typeof meta>;
|
|
80
|
+
|
|
81
|
+
export const Default: Story = {};
|
|
@@ -6,14 +6,8 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { ComputeGraph } from '@dxos/conductor';
|
|
8
8
|
import { Type } from '@dxos/echo';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
FunctionTriggerSchema,
|
|
12
|
-
type FunctionTriggerType,
|
|
13
|
-
type FunctionTrigger,
|
|
14
|
-
ScriptType,
|
|
15
|
-
} from '@dxos/functions';
|
|
16
|
-
import { Filter, Ref, useQuery, type Space } from '@dxos/react-client/echo';
|
|
9
|
+
import { FunctionTrigger, FunctionType, ScriptType } from '@dxos/functions';
|
|
10
|
+
import { Filter, Ref, type Space, useQuery } from '@dxos/react-client/echo';
|
|
17
11
|
import { type CustomInputMap, Form, SelectInput, useRefQueryLookupHandler } from '@dxos/react-ui-form';
|
|
18
12
|
|
|
19
13
|
import { FunctionInputEditor, type FunctionInputEditorProps } from './FunctionInputEditor';
|
|
@@ -21,13 +15,13 @@ import { SpecSelector } from './SpecSelector';
|
|
|
21
15
|
|
|
22
16
|
export type TriggerEditorProps = {
|
|
23
17
|
space: Space;
|
|
24
|
-
trigger:
|
|
18
|
+
trigger: FunctionTrigger;
|
|
25
19
|
onSave?: (trigger: Omit<FunctionTrigger, 'id'>) => void;
|
|
26
20
|
onCancel?: () => void;
|
|
27
21
|
};
|
|
28
22
|
|
|
29
23
|
export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEditorProps) => {
|
|
30
|
-
const handleSave = (values:
|
|
24
|
+
const handleSave = (values: FunctionTrigger) => {
|
|
31
25
|
onSave?.(values);
|
|
32
26
|
};
|
|
33
27
|
|
|
@@ -38,7 +32,7 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
38
32
|
<Form
|
|
39
33
|
outerSpacing={false}
|
|
40
34
|
Custom={Custom}
|
|
41
|
-
schema={
|
|
35
|
+
schema={FunctionTrigger}
|
|
42
36
|
values={trigger}
|
|
43
37
|
onSave={handleSave}
|
|
44
38
|
onCancel={onCancel}
|
|
@@ -55,7 +49,7 @@ const useCustomInputs = (space: Space, onQueryRefOptions: FunctionInputEditorPro
|
|
|
55
49
|
return useMemo(
|
|
56
50
|
(): CustomInputMap => ({
|
|
57
51
|
// Function selector.
|
|
58
|
-
['function' satisfies keyof
|
|
52
|
+
['function' satisfies keyof FunctionTrigger]: (props) => {
|
|
59
53
|
const getValue = useCallback(() => {
|
|
60
54
|
const formValue = props.getValue();
|
|
61
55
|
if (Ref.isRef(formValue)) {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/AutomationContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { useTranslation } from '@dxos/react-ui';\nimport { ControlSection, ControlPage } from '@dxos/react-ui-form';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { AutomationPanel, type AutomationPanelProps } from './AutomationPanel';\nimport { AUTOMATION_PLUGIN } from '../meta';\n\nexport const AutomationContainer = (props: AutomationPanelProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n return (\n <StackItem.Content classNames='block overflow-y-auto'>\n <ControlPage>\n <ControlSection\n title={t('automation verbose label', { ns: AUTOMATION_PLUGIN })}\n description={t('automation description', { ns: AUTOMATION_PLUGIN })}\n >\n <AutomationPanel {...props} />\n </ControlSection>\n </ControlPage>\n </StackItem.Content>\n );\n};\n\nexport default AutomationContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,sBAAsB;AAC/B,SAASC,gBAAgBC,mBAAmB;AAC5C,SAASC,iBAAiB;AAKnB,IAAMC,sBAAsB,CAACC,UAAAA;;;AAClC,UAAM,EAAEC,EAAC,IAAKC,eAAeC,iBAAAA;AAC7B,WACE,sBAAA,cAACC,UAAUC,SAAO;MAACC,YAAW;OAC5B,sBAAA,cAACC,aAAAA,MACC,sBAAA,cAACC,gBAAAA;MACCC,OAAOR,EAAE,4BAA4B;QAAES,IAAIP;MAAkB,CAAA;MAC7DQ,aAAaV,EAAE,0BAA0B;QAAES,IAAIP;MAAkB,CAAA;OAEjE,sBAAA,cAACS,iBAAoBZ,KAAAA,CAAAA,CAAAA,CAAAA;;;;AAK/B;AAEA,IAAA,8BAAeD;",
|
|
6
|
-
"names": ["React", "useTranslation", "ControlSection", "ControlPage", "StackItem", "AutomationContainer", "props", "t", "useTranslation", "AUTOMATION_PLUGIN", "StackItem", "Content", "classNames", "ControlPage", "ControlSection", "title", "ns", "description", "AutomationPanel"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/FunctionsContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Space } from '@dxos/react-client/echo';\nimport { useTranslation } from '@dxos/react-ui';\nimport { ControlPage, ControlSection } from '@dxos/react-ui-form';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { FunctionsPanel } from './FunctionsPanel';\nimport { AUTOMATION_PLUGIN } from '../meta';\n\nexport const FunctionsContainer = ({ space }: { space: Space }) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n return (\n <StackItem.Content classNames='block overflow-y-auto'>\n <ControlPage>\n <ControlSection\n title={t('functions verbose label', { ns: AUTOMATION_PLUGIN })}\n description={t('functions description', { ns: AUTOMATION_PLUGIN })}\n >\n <FunctionsPanel space={space} />\n </ControlSection>\n </ControlPage>\n </StackItem.Content>\n );\n};\n\nexport default FunctionsContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,OAAOA,WAAW;AAGlB,SAASC,sBAAsB;AAC/B,SAASC,aAAaC,sBAAsB;AAC5C,SAASC,iBAAiB;AAKnB,IAAMC,qBAAqB,CAAC,EAAEC,MAAK,MAAoB;;;AAC5D,UAAM,EAAEC,EAAC,IAAKC,eAAeC,iBAAAA;AAC7B,WACE,sBAAA,cAACC,UAAUC,SAAO;MAACC,YAAW;OAC5B,sBAAA,cAACC,aAAAA,MACC,sBAAA,cAACC,gBAAAA;MACCC,OAAOR,EAAE,2BAA2B;QAAES,IAAIP;MAAkB,CAAA;MAC5DQ,aAAaV,EAAE,yBAAyB;QAAES,IAAIP;MAAkB,CAAA;OAEhE,sBAAA,cAACS,gBAAAA;MAAeZ;;;;;AAK1B;AAEA,IAAA,6BAAeD;",
|
|
6
|
-
"names": ["React", "useTranslation", "ControlPage", "ControlSection", "StackItem", "FunctionsContainer", "space", "t", "useTranslation", "AUTOMATION_PLUGIN", "StackItem", "Content", "classNames", "ControlPage", "ControlSection", "title", "ns", "description", "FunctionsPanel"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/AutomationPanel/AutomationPanel.tsx", "../../../src/components/AutomationPanel/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\nimport React, { useState } from 'react';\n\nimport { Filter, Obj } from '@dxos/echo';\nimport {\n FunctionType,\n FunctionTrigger,\n FunctionTriggerSchema,\n type FunctionTriggerType,\n ScriptType,\n TriggerKind,\n} from '@dxos/functions';\nimport { type Client, useClient } from '@dxos/react-client';\nimport { useQuery, type Space, getSpace } from '@dxos/react-client/echo';\nimport { Clipboard, IconButton, Input, Separator, useTranslation } from '@dxos/react-ui';\nimport { ControlItem, controlItemClasses } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/react-ui-theme';\n\nimport { AUTOMATION_PLUGIN } from '../../meta';\nimport { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';\n\nconst grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';\n\nexport type AutomationPanelProps = {\n space: Space;\n object?: Obj.Any;\n initialTrigger?: FunctionTriggerType;\n onDone?: () => void;\n};\n\n// TODO(burdon): Factor out common layout with ViewEditor.\nexport const AutomationPanel = ({ space, object, initialTrigger, onDone }: AutomationPanelProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const client = useClient();\n const triggers = useQuery(space, Filter.type(FunctionTrigger));\n const functions = useQuery(space, Filter.type(FunctionType));\n const scripts = useQuery(space, Filter.type(ScriptType));\n\n const [trigger, setTrigger] = useState<FunctionTriggerType | undefined>(initialTrigger);\n const [selected, setSelected] = useState<FunctionTrigger>();\n\n const handleSelect = (trigger: FunctionTrigger) => {\n const { id: _, ...values } = trigger;\n setTrigger(values);\n setSelected(trigger);\n };\n\n const handleAdd = () => {\n setTrigger(Obj.make(FunctionTriggerSchema, {}));\n setSelected(undefined);\n };\n\n const handleDelete = (trigger: FunctionTrigger) => {\n space.db.remove(trigger);\n setTrigger(undefined);\n setSelected(undefined);\n };\n\n const handleSave: TriggerEditorProps['onSave'] = (trigger) => {\n if (selected) {\n Object.assign(selected, trigger);\n } else {\n space.db.add(Obj.make(FunctionTrigger, trigger));\n }\n\n setTrigger(undefined);\n setSelected(undefined);\n onDone?.();\n };\n\n const handleCancel: TriggerEditorProps['onCancel'] = () => {\n setTrigger(undefined);\n onDone?.();\n };\n\n if (trigger) {\n return (\n <ControlItem title={t('trigger editor title')}>\n <TriggerEditor space={space} trigger={trigger} onSave={handleSave} onCancel={handleCancel} />\n </ControlItem>\n );\n }\n\n return (\n <div className={controlItemClasses}>\n {triggers.length > 0 && (\n <List.Root<FunctionTrigger> items={triggers} isItem={Schema.is(FunctionTrigger)} getId={(field) => field.id}>\n {({ items: triggers }) => (\n <div role='list' className='flex flex-col w-full'>\n {triggers?.map((trigger) => {\n const copyAction = getCopyAction(client, trigger);\n return (\n <List.Item<FunctionTrigger>\n key={trigger.id}\n item={trigger}\n classNames={mx(grid, ghostHover, 'items-center', 'px-2')}\n >\n <Input.Root>\n <Input.Switch\n checked={trigger.enabled}\n onCheckedChange={(checked) => (trigger.enabled = checked)}\n />\n </Input.Root>\n\n <div className={'flex'}>\n <List.ItemTitle\n classNames='px-1 cursor-pointer w-0 shrink truncate'\n onClick={() => handleSelect(trigger)}\n >\n {getFunctionName(scripts, functions, trigger) ?? '∅'}\n </List.ItemTitle>\n\n {/* TODO: a better way to expose copy action */}\n {copyAction && (\n <Clipboard.IconButton\n label={t(copyAction.translationKey)}\n value={copyAction.contentProvider()}\n />\n )}\n </div>\n\n <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />\n </List.Item>\n );\n })}\n </div>\n )}\n </List.Root>\n )}\n {triggers.length > 0 && <Separator classNames='mlb-4' />}\n <IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />\n </div>\n );\n};\n\nconst getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) => {\n if (trigger?.spec?.kind === TriggerKind.Email) {\n return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };\n }\n\n if (trigger?.spec?.kind === TriggerKind.Webhook) {\n return { translationKey: 'trigger copy url', contentProvider: () => getWebhookUrl(client, trigger) };\n }\n\n return undefined;\n};\n\nconst getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {\n const spaceId = getSpace(trigger)!.id;\n const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);\n const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');\n edgeUrl.protocol = isSecure ? 'https' : 'http';\n return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();\n};\n\nconst getFunctionName = (scripts: ScriptType[], functions: FunctionType[], trigger: FunctionTriggerType) => {\n // TODO(wittjosiah): Truncation should be done in the UI.\n // Warning that the List component is currently a can of worms.\n const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}…`;\n const functionObject = functions.find((fn) => fn === trigger.function?.target);\n if (!functionObject) {\n return shortId;\n }\n\n return scripts.find((s) => functionObject.source?.target?.id === s.id)?.name ?? shortId;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AutomationPanel } from './AutomationPanel';\n\nexport * from './AutomationPanel';\n\nexport default AutomationPanel;\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["Schema", "React", "useState", "Filter", "Obj", "FunctionType", "FunctionTrigger", "FunctionTriggerSchema", "ScriptType", "TriggerKind", "useClient", "useQuery", "getSpace", "Clipboard", "IconButton", "Input", "Separator", "useTranslation", "ControlItem", "controlItemClasses", "List", "ghostHover", "mx", "grid", "AutomationPanel", "space", "object", "initialTrigger", "onDone", "t", "useTranslation", "AUTOMATION_PLUGIN", "client", "useClient", "triggers", "useQuery", "Filter", "type", "FunctionTrigger", "functions", "FunctionType", "scripts", "ScriptType", "trigger", "setTrigger", "useState", "selected", "setSelected", "handleSelect", "id", "_", "values", "handleAdd", "Obj", "make", "FunctionTriggerSchema", "undefined", "handleDelete", "db", "remove", "handleSave", "Object", "assign", "add", "handleCancel", "ControlItem", "title", "TriggerEditor", "onSave", "onCancel", "div", "className", "controlItemClasses", "length", "List", "Root", "items", "isItem", "Schema", "is", "getId", "field", "role", "map", "copyAction", "getCopyAction", "Item", "key", "item", "classNames", "mx", "ghostHover", "Input", "Switch", "checked", "enabled", "onCheckedChange", "ItemTitle", "onClick", "getFunctionName", "Clipboard", "IconButton", "label", "translationKey", "value", "contentProvider", "ItemDeleteButton", "Separator", "icon", "spec", "kind", "TriggerKind", "Email", "getSpace", "Webhook", "getWebhookUrl", "spaceId", "edgeUrl", "URL", "config", "runtime", "services", "edge", "url", "isSecure", "protocol", "startsWith", "toString", "shortId", "function", "dxn", "slice", "functionObject", "find", "fn", "target", "s", "source", "name", "AutomationPanel"]
|
|
7
|
-
}
|