@dxos/plugin-automation 0.7.5-main.9d2a38b → 0.7.5-main.e94eead
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-ITYXSN5Z.mjs +132 -0
- package/dist/lib/browser/AutomationPanel-ITYXSN5Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs → chunk-OFDNNRLE.mjs} +4 -7
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs.map → chunk-OFDNNRLE.mjs.map} +3 -3
- package/dist/lib/browser/chunk-U7QLNY2S.mjs +8 -0
- package/dist/lib/browser/chunk-U7QLNY2S.mjs.map +7 -0
- package/dist/lib/browser/chunk-WY2C7JY4.mjs +119 -0
- package/dist/lib/browser/chunk-WY2C7JY4.mjs.map +7 -0
- package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs +56 -0
- package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +21 -313
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-LL72F3F4.mjs → react-surface-SAPMN4PF.mjs} +4 -11
- package/dist/lib/browser/react-surface-SAPMN4PF.mjs.map +7 -0
- package/dist/lib/node/{AutomationPanel-PPODB5XA.cjs → AutomationPanel-X33HHDMQ.cjs} +19 -117
- package/dist/lib/node/AutomationPanel-X33HHDMQ.cjs.map +7 -0
- package/dist/lib/node/chunk-7Q5SNGCL.cjs +148 -0
- package/dist/lib/node/chunk-7Q5SNGCL.cjs.map +7 -0
- package/dist/lib/node/{chunk-25AQIF3L.cjs → chunk-CB5OB6JH.cjs} +5 -8
- package/dist/lib/node/chunk-CB5OB6JH.cjs.map +7 -0
- package/dist/lib/node/{chunk-5VF5JKUN.cjs → chunk-ORMEYEBE.cjs} +7 -10
- package/dist/lib/node/{chunk-5VF5JKUN.cjs.map → chunk-ORMEYEBE.cjs.map} +3 -3
- package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs +72 -0
- package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +26 -318
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-DVAU4MGD.cjs → react-surface-2WRVAPGR.cjs} +9 -15
- package/dist/lib/node/react-surface-2WRVAPGR.cjs.map +7 -0
- package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs +133 -0
- package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs → chunk-6MUUH67V.mjs} +4 -7
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs.map → chunk-6MUUH67V.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-XW7TEQA3.mjs → chunk-R3P2WPBQ.mjs} +2 -4
- package/dist/lib/node-esm/chunk-R3P2WPBQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UDD2VA6G.mjs +120 -0
- package/dist/lib/node-esm/chunk-UDD2VA6G.mjs.map +7 -0
- package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs +57 -0
- package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -313
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-4BED2PZ4.mjs → react-surface-QWLPOYXO.mjs} +4 -11
- package/dist/lib/node-esm/react-surface-QWLPOYXO.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/complementary-panel.d.ts +4 -0
- package/dist/types/src/capabilities/complementary-panel.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +2 -178
- package/dist/types/src/capabilities/index.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 +1 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- 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/testing/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/{testing.d.ts → test-functions.d.ts} +1 -1
- package/dist/types/src/testing/test-functions.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +2 -20
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +23 -57
- package/src/AutomationPlugin.tsx +10 -42
- package/src/capabilities/complementary-panel.ts +56 -0
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/react-surface.tsx +1 -6
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -2
- package/src/components/AutomationPanel/AutomationPanel.tsx +56 -49
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +1 -2
- package/src/components/TriggerEditor/TriggerEditor.tsx +25 -18
- package/src/components/index.ts +2 -1
- package/src/index.ts +2 -3
- package/src/meta.ts +3 -3
- package/src/testing/index.ts +1 -1
- package/src/testing/{testing.ts → test-functions.ts} +2 -2
- package/src/translations.ts +2 -23
- package/dist/lib/browser/AssistantPanel-N276BTPV.mjs +0 -339
- package/dist/lib/browser/AssistantPanel-N276BTPV.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-IHZ4JKVS.mjs +0 -232
- package/dist/lib/browser/AutomationPanel-IHZ4JKVS.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-IJTTULDP.mjs +0 -131
- package/dist/lib/browser/app-graph-builder-IJTTULDP.mjs.map +0 -7
- package/dist/lib/browser/chunk-4AIMDHKY.mjs +0 -10
- package/dist/lib/browser/chunk-4AIMDHKY.mjs.map +0 -7
- package/dist/lib/browser/chunk-DL6LB2NI.mjs +0 -43
- package/dist/lib/browser/chunk-DL6LB2NI.mjs.map +0 -7
- package/dist/lib/browser/react-surface-LL72F3F4.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -13
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node/AssistantPanel-Z4GVHUF3.cjs +0 -359
- package/dist/lib/node/AssistantPanel-Z4GVHUF3.cjs.map +0 -7
- package/dist/lib/node/AutomationPanel-PPODB5XA.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-MF5M4QRS.cjs +0 -147
- package/dist/lib/node/app-graph-builder-MF5M4QRS.cjs.map +0 -7
- package/dist/lib/node/chunk-25AQIF3L.cjs.map +0 -7
- package/dist/lib/node/chunk-JNDMZQH7.cjs +0 -68
- package/dist/lib/node/chunk-JNDMZQH7.cjs.map +0 -7
- package/dist/lib/node/react-surface-DVAU4MGD.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -35
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantPanel-DDCQHBJX.mjs +0 -340
- package/dist/lib/node-esm/AssistantPanel-DDCQHBJX.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-R3D6CRF5.mjs +0 -233
- package/dist/lib/node-esm/AutomationPanel-R3D6CRF5.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-5N7OK23B.mjs +0 -132
- package/dist/lib/node-esm/app-graph-builder-5N7OK23B.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GIAYUM5I.mjs +0 -45
- package/dist/lib/node-esm/chunk-GIAYUM5I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XW7TEQA3.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-4BED2PZ4.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -14
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -180
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts +0 -8
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/index.d.ts +0 -3
- package/dist/types/src/components/AssistantPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts +0 -6
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +0 -10
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts +0 -6
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/index.d.ts +0 -2
- package/dist/types/src/components/PromptEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts +0 -4
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/types.d.ts +0 -18
- package/dist/types/src/components/PromptEditor/types.d.ts.map +0 -1
- package/dist/types/src/hooks/email.d.ts +0 -4
- package/dist/types/src/hooks/email.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -2
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/invocation-handler.d.ts +0 -5
- package/dist/types/src/hooks/invocation-handler.d.ts.map +0 -1
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts +0 -3
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +0 -1
- package/dist/types/src/presets.d.ts +0 -9
- package/dist/types/src/presets.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -2
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -63
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -127
- package/src/components/AssistantPanel/AssistantPanel.tsx +0 -230
- package/src/components/AssistantPanel/index.ts +0 -7
- package/src/components/AssistantPanel/system-instructions.ts +0 -166
- package/src/components/PromptEditor/PromptEditor.stories.tsx +0 -64
- package/src/components/PromptEditor/PromptEditor.tsx +0 -222
- package/src/components/PromptEditor/index.ts +0 -5
- package/src/components/PromptEditor/prompt-extension.ts +0 -43
- package/src/components/PromptEditor/types.tsx +0 -28
- package/src/hooks/email.ts +0 -49
- package/src/hooks/index.ts +0 -5
- package/src/hooks/invocation-handler.ts +0 -109
- package/src/hooks/useLocalTriggerManager.ts +0 -82
- package/src/presets.ts +0 -248
- package/src/types/index.ts +0 -5
- package/src/types/schema.ts +0 -38
|
@@ -7,16 +7,11 @@ import React from 'react';
|
|
|
7
7
|
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
8
8
|
import { getSpace, isEchoObject, type ReactiveEchoObject } from '@dxos/react-client/echo';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { AutomationPanel } from '../components';
|
|
11
11
|
import { AUTOMATION_PLUGIN } from '../meta';
|
|
12
12
|
|
|
13
13
|
export default () =>
|
|
14
14
|
contributes(Capabilities.ReactSurface, [
|
|
15
|
-
createSurface({
|
|
16
|
-
id: `${AUTOMATION_PLUGIN}/assistant`,
|
|
17
|
-
role: 'complementary--assistant',
|
|
18
|
-
component: ({ data }) => <AssistantPanel subject={data.subject} />,
|
|
19
|
-
}),
|
|
20
15
|
createSurface({
|
|
21
16
|
id: `${AUTOMATION_PLUGIN}/automation`,
|
|
22
17
|
role: 'complementary--automation',
|
|
@@ -15,7 +15,6 @@ import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
|
15
15
|
import { AutomationPanel } from './AutomationPanel';
|
|
16
16
|
import { functions } from '../../testing';
|
|
17
17
|
import translations from '../../translations';
|
|
18
|
-
import { ChainPromptType } from '../../types';
|
|
19
18
|
|
|
20
19
|
const DefaultStory = () => {
|
|
21
20
|
const spaces = useSpaces();
|
|
@@ -36,7 +35,7 @@ const meta: Meta = {
|
|
|
36
35
|
withClientProvider({
|
|
37
36
|
createIdentity: true,
|
|
38
37
|
createSpace: true,
|
|
39
|
-
types: [FunctionType, FunctionTrigger
|
|
38
|
+
types: [FunctionType, FunctionTrigger],
|
|
40
39
|
onSpaceCreated: ({ space }) => {
|
|
41
40
|
for (const fn of functions) {
|
|
42
41
|
space.db.add(create(FunctionType, fn));
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from '@dxos/functions';
|
|
16
16
|
import { type Client, useClient } from '@dxos/react-client';
|
|
17
17
|
import { create, Filter, useQuery, type Space, type ReactiveObject, getSpace } from '@dxos/react-client/echo';
|
|
18
|
-
import { IconButton, Input, useTranslation
|
|
18
|
+
import { Clipboard, IconButton, Input, useTranslation } from '@dxos/react-ui';
|
|
19
19
|
import { List } from '@dxos/react-ui-list';
|
|
20
20
|
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
21
21
|
|
|
@@ -73,57 +73,62 @@ export const AutomationPanel = ({ space, object }: AutomationPanelProps) => {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
return (
|
|
76
|
-
<
|
|
77
|
-
<
|
|
78
|
-
{
|
|
79
|
-
<
|
|
80
|
-
{triggers
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<Input.Switch
|
|
90
|
-
checked={trigger.enabled}
|
|
91
|
-
onCheckedChange={(checked) => (trigger.enabled = checked)}
|
|
92
|
-
/>
|
|
93
|
-
</Input.Root>
|
|
94
|
-
|
|
95
|
-
<div className={'flex'}>
|
|
96
|
-
<List.ItemTitle
|
|
97
|
-
classNames='px-1 cursor-pointer w-0 shrink truncate'
|
|
98
|
-
onClick={() => handleSelect(trigger)}
|
|
76
|
+
<Clipboard.Provider>
|
|
77
|
+
<div className='flex flex-col w-full'>
|
|
78
|
+
{!trigger && (
|
|
79
|
+
<List.Root<FunctionTrigger> items={triggers} isItem={S.is(FunctionTrigger)} getId={(field) => field.id}>
|
|
80
|
+
{({ items: triggers }) => (
|
|
81
|
+
<div role='list' className='flex flex-col w-full'>
|
|
82
|
+
{triggers?.map((trigger) => {
|
|
83
|
+
const copyAction = getCopyAction(client, trigger);
|
|
84
|
+
return (
|
|
85
|
+
<List.Item<FunctionTrigger>
|
|
86
|
+
key={trigger.id}
|
|
87
|
+
item={trigger}
|
|
88
|
+
classNames={mx(grid, ghostHover, 'items-center', 'px-2')}
|
|
99
89
|
>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
90
|
+
<Input.Root>
|
|
91
|
+
<Input.Switch
|
|
92
|
+
checked={trigger.enabled}
|
|
93
|
+
onCheckedChange={(checked) => (trigger.enabled = checked)}
|
|
94
|
+
/>
|
|
95
|
+
</Input.Root>
|
|
96
|
+
|
|
97
|
+
<div className={'flex'}>
|
|
98
|
+
<List.ItemTitle
|
|
99
|
+
classNames='px-1 cursor-pointer w-0 shrink truncate'
|
|
100
|
+
onClick={() => handleSelect(trigger)}
|
|
101
|
+
>
|
|
102
|
+
{getFunctionName(scripts, functions, trigger) ?? '∅'}
|
|
103
|
+
</List.ItemTitle>
|
|
104
|
+
|
|
105
|
+
{/* TODO: a better way to expose copy action */}
|
|
106
|
+
{copyAction && (
|
|
107
|
+
<Clipboard.IconButton
|
|
108
|
+
label={t(copyAction.translationKey)}
|
|
109
|
+
value={copyAction.contentProvider()}
|
|
110
|
+
/>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
<List.ItemDeleteButton onClick={() => handleDelete(trigger)} />
|
|
115
|
+
</List.Item>
|
|
116
|
+
);
|
|
117
|
+
})}
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
</List.Root>
|
|
116
121
|
)}
|
|
117
|
-
</List.Root>
|
|
118
122
|
|
|
119
|
-
|
|
123
|
+
{trigger && <TriggerEditor space={space} trigger={trigger} onSave={handleSave} onCancel={handleCancel} />}
|
|
120
124
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
{!trigger && (
|
|
126
|
+
<div className='flex p-2 justify-center'>
|
|
127
|
+
<IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />
|
|
128
|
+
</div>
|
|
129
|
+
)}
|
|
130
|
+
</div>
|
|
131
|
+
</Clipboard.Provider>
|
|
127
132
|
);
|
|
128
133
|
};
|
|
129
134
|
|
|
@@ -148,8 +153,10 @@ const getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {
|
|
|
148
153
|
};
|
|
149
154
|
|
|
150
155
|
const getFunctionName = (scripts: ScriptType[], functions: FunctionType[], trigger: FunctionTriggerType) => {
|
|
156
|
+
// TODO(wittjosiah): Truncation should be done in the UI.
|
|
157
|
+
// Warning that the List component is currently a can of worms.
|
|
151
158
|
const shortId = trigger.function && `${trigger.function?.slice(0, 16)}…`;
|
|
152
|
-
const functionObject = functions.find((fn) => fn.name === trigger.function);
|
|
159
|
+
const functionObject = functions.find((fn) => `dxn:worker:${fn.name}` === trigger.function);
|
|
153
160
|
if (!functionObject) {
|
|
154
161
|
return shortId;
|
|
155
162
|
}
|
|
@@ -16,7 +16,6 @@ import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
|
16
16
|
import { TriggerEditor } from './TriggerEditor';
|
|
17
17
|
import { functions } from '../../testing';
|
|
18
18
|
import translations from '../../translations';
|
|
19
|
-
import { ChainPromptType } from '../../types';
|
|
20
19
|
|
|
21
20
|
const DefaultStory = () => {
|
|
22
21
|
const spaces = useSpaces();
|
|
@@ -50,7 +49,7 @@ const meta: Meta = {
|
|
|
50
49
|
withClientProvider({
|
|
51
50
|
createIdentity: true,
|
|
52
51
|
createSpace: true,
|
|
53
|
-
types: [FunctionType, FunctionTrigger
|
|
52
|
+
types: [FunctionType, FunctionTrigger],
|
|
54
53
|
onSpaceCreated: ({ space }) => {
|
|
55
54
|
for (const fn of functions) {
|
|
56
55
|
space.db.add(create(FunctionType, fn));
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { useState } from 'react';
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
+
import { ComputeGraph } from '@dxos/conductor';
|
|
7
8
|
import {
|
|
8
9
|
FunctionType,
|
|
9
10
|
FunctionTriggerSchema,
|
|
@@ -29,6 +30,7 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
29
30
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
30
31
|
|
|
31
32
|
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
33
|
+
const workflows = useQuery(space, Filter.schema(ComputeGraph));
|
|
32
34
|
const scripts = useQuery(space, Filter.schema(ScriptType));
|
|
33
35
|
|
|
34
36
|
const handleSave = (values: FunctionTriggerType) => {
|
|
@@ -43,16 +45,13 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
43
45
|
onCancel={onCancel}
|
|
44
46
|
Custom={{
|
|
45
47
|
['function' satisfies keyof FunctionTriggerType]: (props) => (
|
|
46
|
-
<SelectInput
|
|
48
|
+
<SelectInput
|
|
47
49
|
{...props}
|
|
48
|
-
options={
|
|
49
|
-
value: fn.name,
|
|
50
|
-
label: getFunctionName(scripts, fn),
|
|
51
|
-
}))}
|
|
50
|
+
options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}
|
|
52
51
|
/>
|
|
53
52
|
),
|
|
54
53
|
['spec.type' as const]: (props) => (
|
|
55
|
-
<SelectInput
|
|
54
|
+
<SelectInput
|
|
56
55
|
{...props}
|
|
57
56
|
options={Object.values(TriggerKind).map((kind) => ({
|
|
58
57
|
value: kind,
|
|
@@ -61,12 +60,10 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
61
60
|
/>
|
|
62
61
|
),
|
|
63
62
|
['meta' as const]: (props) => {
|
|
64
|
-
const meta = props.getValue(
|
|
65
|
-
|
|
63
|
+
const meta = props.getValue()!;
|
|
64
|
+
useEffect(() => props.onValueChange('object', { ...meta }), []);
|
|
66
65
|
const [newMetaFieldName, setNewMetaFieldName] = useState('');
|
|
67
66
|
|
|
68
|
-
React.useEffect(() => props.onValueChange('meta', 'object', { ...meta }), []);
|
|
69
|
-
|
|
70
67
|
return (
|
|
71
68
|
<>
|
|
72
69
|
<div>{props.label}</div>
|
|
@@ -75,7 +72,12 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
75
72
|
return (
|
|
76
73
|
<div key={compositeKey} role='none' className='flex items-center mt-2 gap-1'>
|
|
77
74
|
<div role='none' className='flex-1'>
|
|
78
|
-
<TextInput
|
|
75
|
+
<TextInput
|
|
76
|
+
{...props}
|
|
77
|
+
getValue={() => (props.getValue() as any)[key]}
|
|
78
|
+
type={'string'}
|
|
79
|
+
label={key}
|
|
80
|
+
/>
|
|
79
81
|
</div>
|
|
80
82
|
<IconButton
|
|
81
83
|
icon='ph--trash--regular'
|
|
@@ -83,9 +85,9 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
83
85
|
classNames={'mt-6'}
|
|
84
86
|
label={t('trigger meta remove')}
|
|
85
87
|
onClick={() => {
|
|
86
|
-
const newValues: any = { ...props.getValue(
|
|
88
|
+
const newValues: any = { ...props.getValue() };
|
|
87
89
|
delete newValues[key];
|
|
88
|
-
props.onValueChange('
|
|
90
|
+
props.onValueChange('object', newValues);
|
|
89
91
|
}}
|
|
90
92
|
/>
|
|
91
93
|
</div>
|
|
@@ -107,10 +109,10 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
107
109
|
label={t('trigger meta add')}
|
|
108
110
|
onClick={() => {
|
|
109
111
|
if (newMetaFieldName.length) {
|
|
110
|
-
const meta = props.getValue(
|
|
112
|
+
const meta = props.getValue() ?? {};
|
|
111
113
|
const metaWithNewProp = { ...meta, [newMetaFieldName]: '' };
|
|
112
114
|
setNewMetaFieldName('');
|
|
113
|
-
props.onValueChange('
|
|
115
|
+
props.onValueChange('object', metaWithNewProp);
|
|
114
116
|
}
|
|
115
117
|
}}
|
|
116
118
|
/>
|
|
@@ -123,6 +125,11 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
123
125
|
);
|
|
124
126
|
};
|
|
125
127
|
|
|
126
|
-
const
|
|
127
|
-
return
|
|
128
|
+
const getWorkflowOptions = (graphs: ComputeGraph[]) => {
|
|
129
|
+
return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const getFunctionOptions = (scripts: ScriptType[], functions: FunctionType[]) => {
|
|
133
|
+
const getLabel = (fn: FunctionType) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
|
|
134
|
+
return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:worker:${fn.name}` }));
|
|
128
135
|
};
|
package/src/components/index.ts
CHANGED
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -9,8 +9,8 @@ export const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';
|
|
|
9
9
|
export const meta = {
|
|
10
10
|
id: AUTOMATION_PLUGIN,
|
|
11
11
|
name: 'Automation',
|
|
12
|
-
description:
|
|
13
|
-
|
|
12
|
+
description:
|
|
13
|
+
'The Automation tab allows you to trigger pre-defined workflows related to the element you are interacting with inside of Composer.',
|
|
14
|
+
icon: 'ph--robot--regular',
|
|
14
15
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-automation',
|
|
15
|
-
tags: ['experimental'],
|
|
16
16
|
} satisfies PluginMeta;
|
package/src/testing/index.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { AST, S, toJsonSchema } from '@dxos/echo-schema';
|
|
|
7
7
|
export const functions = [
|
|
8
8
|
{
|
|
9
9
|
name: 'example.com/function/chess',
|
|
10
|
-
version: '0.0
|
|
10
|
+
version: '0.1.0',
|
|
11
11
|
inputSchema: toJsonSchema(
|
|
12
12
|
S.Struct({
|
|
13
13
|
level: S.Number.annotations({
|
|
@@ -18,7 +18,7 @@ export const functions = [
|
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
name: 'example.com/function/forex',
|
|
21
|
-
version: '0.0
|
|
21
|
+
version: '0.1.0',
|
|
22
22
|
binding: 'FOREX',
|
|
23
23
|
inputSchema: toJsonSchema(
|
|
24
24
|
S.Struct({
|
package/src/translations.ts
CHANGED
|
@@ -9,33 +9,15 @@ export default [
|
|
|
9
9
|
'en-US': {
|
|
10
10
|
[AUTOMATION_PLUGIN]: {
|
|
11
11
|
'plugin name': 'Automation',
|
|
12
|
-
'object placeholder': 'New prompt',
|
|
13
|
-
'create object label': 'Create prompt',
|
|
14
|
-
'create trigger label': 'Create trigger',
|
|
15
|
-
'create stack section label': 'Create prompt',
|
|
16
|
-
'command placeholder': 'Enter slash command...',
|
|
17
|
-
'template placeholder': 'Enter template...',
|
|
18
|
-
'value placeholder': 'Enter value...',
|
|
19
|
-
'select preset template placeholder': 'Select preset',
|
|
20
|
-
'open automation panel label': 'Show Automations',
|
|
21
12
|
'automation panel label': 'Automations',
|
|
22
13
|
|
|
23
|
-
'
|
|
24
|
-
'function select placeholder': 'Select function',
|
|
25
|
-
'function enabled': 'Enabled',
|
|
26
|
-
'trigger select label': 'Trigger',
|
|
27
|
-
'trigger select placeholder': 'Trigger type',
|
|
28
|
-
|
|
14
|
+
'new trigger label': 'New Trigger',
|
|
29
15
|
'trigger type timer': 'Timer',
|
|
30
16
|
'trigger type webhook': 'Webhook',
|
|
31
17
|
'trigger type websocket': 'Websocket',
|
|
32
18
|
'trigger type subscription': 'Subscription',
|
|
33
19
|
'trigger type email': 'Email',
|
|
34
|
-
|
|
35
|
-
'trigger filter': 'Filter',
|
|
36
|
-
'trigger cron': 'Cron',
|
|
37
|
-
'trigger method': 'Method',
|
|
38
|
-
'trigger endpoint': 'Endpoint',
|
|
20
|
+
'trigger type queue': 'Queue',
|
|
39
21
|
|
|
40
22
|
'trigger copy url': 'Copy URL',
|
|
41
23
|
'trigger copy email': 'Copy Email',
|
|
@@ -43,9 +25,6 @@ export default [
|
|
|
43
25
|
'trigger meta add': 'Add',
|
|
44
26
|
'trigger meta remove': 'Remove',
|
|
45
27
|
'trigger meta prop name placeholder': 'New meta property name',
|
|
46
|
-
|
|
47
|
-
'open assistant panel label': 'Show Assistant',
|
|
48
|
-
'assistant panel label': 'Assistant',
|
|
49
28
|
},
|
|
50
29
|
},
|
|
51
30
|
},
|