@dxos/plugin-automation 0.8.4-main.f9ba587 → 0.8.4-main.fcc0d83b33
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/chunk-3JLJBF5C.mjs +54 -0
- package/dist/lib/browser/chunk-3JLJBF5C.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-SZIGF7TB.mjs +44 -0
- package/dist/lib/browser/chunk-SZIGF7TB.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +1107 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/create-trigger-from-template-RSZIPHIG.mjs +71 -0
- package/dist/lib/browser/create-trigger-from-template-RSZIPHIG.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +129 -0
- package/dist/lib/browser/hooks/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +44 -94
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +14 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/translations.mjs +47 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +14 -0
- package/dist/lib/node-esm/chunk-7I6EPBJI.mjs +56 -0
- package/dist/lib/node-esm/chunk-7I6EPBJI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-TR5BMZG5.mjs +45 -0
- package/dist/lib/node-esm/chunk-TR5BMZG5.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +1108 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/create-trigger-from-template-GE76I6FE.mjs +72 -0
- package/dist/lib/node-esm/create-trigger-from-template-GE76I6FE.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +130 -0
- package/dist/lib/node-esm/hooks/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +44 -94
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operations/index.mjs +15 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/translations.mjs +48 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +15 -0
- package/dist/types/src/AutomationPlugin.d.ts +2 -1
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts +14 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +3 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/cli/commands/index.d.ts +2 -0
- package/dist/types/src/cli/commands/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/index.d.ts +25 -0
- package/dist/types/src/cli/commands/trigger/create/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts +15 -0
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/index.d.ts +57 -0
- package/dist/types/src/cli/commands/trigger/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/list.d.ts +7 -0
- package/dist/types/src/cli/commands/trigger/list.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/options.d.ts +11 -0
- package/dist/types/src/cli/commands/trigger/options.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/remove.d.ts +8 -0
- package/dist/types/src/cli/commands/trigger/remove.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/index.d.ts +28 -0
- package/dist/types/src/cli/commands/trigger/update/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts +12 -0
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts +11 -0
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/util.d.ts +46 -0
- package/dist/types/src/cli/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +3 -3
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +50 -4
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts +8 -0
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts +4 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +12 -9
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +6 -3
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +11 -8
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +121 -4
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +6 -0
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts +2 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts +4 -0
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts +2 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts +6 -0
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/index.d.ts +3 -0
- package/dist/types/src/containers/TriggerSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +5 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntime.d.ts +8 -0
- package/dist/types/src/hooks/useComputeRuntime.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +9 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts +17 -0
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts.map +1 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +12 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-trigger-from-template.d.ts +5 -0
- package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +19 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +204 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +32 -26
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +25 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/{types.d.ts → types/schema.d.ts} +13 -5
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +110 -46
- package/src/AutomationPlugin.tsx +22 -34
- package/src/capabilities/app-graph-builder.ts +56 -79
- package/src/capabilities/compute-runtime.ts +320 -0
- package/src/capabilities/index.ts +9 -4
- package/src/capabilities/node.ts +7 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +49 -46
- package/src/cli/commands/index.ts +5 -0
- package/src/cli/commands/trigger/create/index.ts +14 -0
- package/src/cli/commands/trigger/create/queue.ts +87 -0
- package/src/cli/commands/trigger/create/subscription.ts +126 -0
- package/src/cli/commands/trigger/create/timer.ts +91 -0
- package/src/cli/commands/trigger/index.ts +16 -0
- package/src/cli/commands/trigger/list.ts +70 -0
- package/src/cli/commands/trigger/options.ts +59 -0
- package/src/cli/commands/trigger/remove.ts +45 -0
- package/src/cli/commands/trigger/update/index.ts +14 -0
- package/src/cli/commands/trigger/update/queue.ts +195 -0
- package/src/cli/commands/trigger/update/subscription.ts +279 -0
- package/src/cli/commands/trigger/update/timer.ts +194 -0
- package/src/cli/commands/trigger/util.ts +411 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +23 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +18 -17
- package/src/components/AutomationPanel/AutomationPanel.tsx +250 -94
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +52 -32
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +114 -0
- package/src/components/FunctionsRegistry/index.ts +8 -0
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +42 -35
- package/src/components/TriggerEditor/SpecSelector.tsx +34 -22
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +129 -40
- package/src/components/TriggerEditor/TriggerEditor.tsx +110 -48
- package/src/components/index.ts +1 -2
- package/src/containers/AutomationSettings/AutomationSettings.tsx +31 -0
- package/src/containers/AutomationSettings/index.ts +5 -0
- package/src/containers/FunctionsContainer/FunctionsContainer.tsx +33 -0
- package/src/containers/FunctionsContainer/index.ts +5 -0
- package/src/containers/TriggerSettings/TriggerSettings.tsx +48 -0
- package/src/containers/TriggerSettings/index.ts +6 -0
- package/src/containers/index.ts +9 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useComputeRuntime.ts +30 -0
- package/src/hooks/useComputeRuntimeCallback.ts +32 -0
- package/src/hooks/useComputeRuntimeService.ts +64 -0
- package/src/hooks/useTriggerRuntimeControls.ts +70 -0
- package/src/index.ts +2 -4
- package/src/meta.ts +9 -8
- package/src/operations/create-trigger-from-template.ts +72 -0
- package/src/operations/definitions.ts +28 -0
- package/src/operations/index.ts +9 -0
- package/src/testing/test-functions.ts +10 -7
- package/src/translations.ts +39 -29
- package/src/types/capabilities.ts +48 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +7 -0
- package/src/{types.ts → types/schema.ts} +6 -8
- package/dist/lib/browser/AutomationContainer-VZNV2ZQF.mjs +0 -38
- package/dist/lib/browser/AutomationContainer-VZNV2ZQF.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-ZWA6GOFY.mjs +0 -11
- package/dist/lib/browser/FunctionsContainer-IOB333TX.mjs +0 -39
- package/dist/lib/browser/FunctionsContainer-IOB333TX.mjs.map +0 -7
- package/dist/lib/browser/FunctionsPanel-56ZKRVM5.mjs +0 -10
- package/dist/lib/browser/app-graph-builder-ZTAUTFI4.mjs +0 -80
- package/dist/lib/browser/app-graph-builder-ZTAUTFI4.mjs.map +0 -7
- package/dist/lib/browser/chunk-ECSTS2UI.mjs +0 -14
- package/dist/lib/browser/chunk-ECSTS2UI.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERTIGJYE.mjs +0 -147
- package/dist/lib/browser/chunk-ERTIGJYE.mjs.map +0 -7
- package/dist/lib/browser/chunk-FSJZXTS2.mjs +0 -230
- package/dist/lib/browser/chunk-FSJZXTS2.mjs.map +0 -7
- package/dist/lib/browser/chunk-GW5U2DGT.mjs +0 -15
- package/dist/lib/browser/chunk-GW5U2DGT.mjs.map +0 -7
- package/dist/lib/browser/chunk-LYJVTIVD.mjs +0 -94
- package/dist/lib/browser/chunk-LYJVTIVD.mjs.map +0 -7
- package/dist/lib/browser/chunk-S2LE7SYB.mjs +0 -39
- package/dist/lib/browser/chunk-S2LE7SYB.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-YLRSMLH4.mjs +0 -76
- package/dist/lib/browser/intent-resolver-YLRSMLH4.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4DFSM7OX.mjs +0 -64
- package/dist/lib/browser/react-surface-4DFSM7OX.mjs.map +0 -7
- package/dist/lib/browser/types.mjs +0 -8
- package/dist/lib/node-esm/AutomationContainer-WMIH3F4V.mjs +0 -39
- package/dist/lib/node-esm/AutomationContainer-WMIH3F4V.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-YYUMSK2W.mjs +0 -12
- package/dist/lib/node-esm/FunctionsContainer-DJWB6WFH.mjs +0 -40
- package/dist/lib/node-esm/FunctionsContainer-DJWB6WFH.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsPanel-KGIOZSPZ.mjs +0 -11
- package/dist/lib/node-esm/FunctionsPanel-KGIOZSPZ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-3FP63ZSG.mjs +0 -81
- package/dist/lib/node-esm/app-graph-builder-3FP63ZSG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AZH66CED.mjs +0 -231
- package/dist/lib/node-esm/chunk-AZH66CED.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HIMYPGHF.mjs +0 -148
- package/dist/lib/node-esm/chunk-HIMYPGHF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NK5N3QKD.mjs +0 -17
- package/dist/lib/node-esm/chunk-NK5N3QKD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SGZPTJ47.mjs +0 -16
- package/dist/lib/node-esm/chunk-SGZPTJ47.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UKATFY3R.mjs +0 -40
- package/dist/lib/node-esm/chunk-UKATFY3R.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZGPUV5VS.mjs +0 -95
- package/dist/lib/node-esm/chunk-ZGPUV5VS.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-LU7EYWEO.mjs +0 -77
- package/dist/lib/node-esm/intent-resolver-LU7EYWEO.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-3PNW7NDW.mjs +0 -65
- package/dist/lib/node-esm/react-surface-3PNW7NDW.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -9
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/AutomationContainer.d.ts +0 -5
- package/dist/types/src/components/AutomationContainer.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsContainer.d.ts +0 -7
- package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -72
- package/src/components/AutomationContainer.tsx +0 -30
- package/src/components/FunctionsContainer.tsx +0 -31
- /package/dist/lib/browser/{AutomationPanel-ZWA6GOFY.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-56ZKRVM5.mjs.map → types/index.mjs.map} +0 -0
- /package/dist/lib/{browser/types.mjs.map → node-esm/chunk-HSLMI22Q.mjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-YYUMSK2W.mjs.map → types/index.mjs.map} +0 -0
|
@@ -2,29 +2,26 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import type * as SchemaAST from 'effect/SchemaAST';
|
|
5
6
|
import React, { useCallback, useMemo } from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import { type JsonPath } from '@dxos/echo
|
|
9
|
-
import { type
|
|
10
|
-
import { useOnTransition } from '@dxos/react-ui';
|
|
11
|
-
import { Form, type
|
|
8
|
+
import { type Database, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
9
|
+
import { type JsonPath } from '@dxos/echo/internal';
|
|
10
|
+
import { type Operation } from '@dxos/operation';
|
|
11
|
+
import { useOnTransition, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Form, type FormFieldStateProps, type FormRootProps, useFormValues } from '@dxos/react-ui-form';
|
|
13
|
+
|
|
14
|
+
import { meta } from '#meta';
|
|
12
15
|
|
|
13
16
|
export type FunctionInputEditorProps = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
type: SchemaAST.AST;
|
|
18
|
+
functions: Operation.PersistentOperation[];
|
|
19
|
+
db?: Database.Database;
|
|
20
|
+
} & FormFieldStateProps;
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const FunctionInputEditor = ({
|
|
22
|
-
functions,
|
|
23
|
-
getValue,
|
|
24
|
-
onValueChange,
|
|
25
|
-
onQueryRefOptions,
|
|
26
|
-
}: FunctionInputEditorProps) => {
|
|
27
|
-
const selectedFunctionValue = useFormValues(['function' as JsonPath]);
|
|
22
|
+
export const FunctionInputEditor = ({ type, functions, db, getValue, onValueChange }: FunctionInputEditorProps) => {
|
|
23
|
+
const { t } = useTranslation(meta.id);
|
|
24
|
+
const selectedFunctionValue = useFormValues(FunctionInputEditor.displayName, ['function' as JsonPath]);
|
|
28
25
|
const selectedFunctionId = useMemo(() => {
|
|
29
26
|
if (Ref.isRef(selectedFunctionValue)) {
|
|
30
27
|
return selectedFunctionValue.dxn.toString().split('dxn:echo:@:').at(1);
|
|
@@ -39,22 +36,30 @@ export const FunctionInputEditor = ({
|
|
|
39
36
|
useOnTransition(
|
|
40
37
|
// Clear function parameter input when the function changes.
|
|
41
38
|
selectedFunctionValue,
|
|
42
|
-
(prevValue) =>
|
|
39
|
+
(prevValue) => {
|
|
40
|
+
if (!Ref.isRef(prevValue) || !Ref.isRef(selectedFunctionValue)) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return prevValue.dxn.toString() !== selectedFunctionValue.dxn.toString();
|
|
45
|
+
},
|
|
43
46
|
(currValue) => currValue !== undefined,
|
|
44
|
-
() => onValueChange(
|
|
47
|
+
() => onValueChange(type, {}),
|
|
45
48
|
);
|
|
46
49
|
|
|
47
50
|
const inputSchema = useMemo(() => selectedFunction?.inputSchema, [selectedFunction]);
|
|
48
|
-
const effectSchema = useMemo(() => (inputSchema ?
|
|
51
|
+
const effectSchema = useMemo(() => (inputSchema ? JsonSchema.toEffectSchema(inputSchema) : undefined), [inputSchema]);
|
|
49
52
|
const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
|
|
53
|
+
const defaultValues = useMemo(() => {
|
|
54
|
+
const raw = getValue() ?? {};
|
|
55
|
+
return Obj.isObject(raw) ? { ...Obj.getSnapshot(raw) } : { ...raw };
|
|
56
|
+
}, [getValue]);
|
|
50
57
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(values: any) => {
|
|
55
|
-
onValueChange('object', values);
|
|
58
|
+
const handleValuesChanged = useCallback<NonNullable<FormRootProps['onValuesChanged']>>(
|
|
59
|
+
(values) => {
|
|
60
|
+
onValueChange(type, values);
|
|
56
61
|
},
|
|
57
|
-
[onValueChange],
|
|
62
|
+
[type, onValueChange],
|
|
58
63
|
);
|
|
59
64
|
|
|
60
65
|
if (selectedFunction === undefined || effectSchema === undefined || propertyCount === 0) {
|
|
@@ -63,16 +68,18 @@ export const FunctionInputEditor = ({
|
|
|
63
68
|
|
|
64
69
|
return (
|
|
65
70
|
<>
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<Form
|
|
71
|
+
<Form.Label label={t('function-parameters.label')} asChild />
|
|
72
|
+
<Form.Root
|
|
73
|
+
key={selectedFunction.id}
|
|
70
74
|
schema={effectSchema}
|
|
71
|
-
|
|
75
|
+
defaultValues={defaultValues}
|
|
76
|
+
db={db}
|
|
72
77
|
onValuesChanged={handleValuesChanged}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
>
|
|
79
|
+
<Form.FieldSet />
|
|
80
|
+
</Form.Root>
|
|
76
81
|
</>
|
|
77
82
|
);
|
|
78
83
|
};
|
|
84
|
+
|
|
85
|
+
FunctionInputEditor.displayName = 'AutomationTrigger.FunctionInputEditor';
|
|
@@ -4,32 +4,33 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Filter, Query } from '@dxos/echo';
|
|
8
|
+
import { Trigger } from '@dxos/functions';
|
|
8
9
|
import { useTranslation } from '@dxos/react-ui';
|
|
9
|
-
import {
|
|
10
|
+
import { type FormFieldComponentProps, SelectField, useFormFieldState } from '@dxos/react-ui-form';
|
|
10
11
|
|
|
11
|
-
import {
|
|
12
|
+
import { meta } from '#meta';
|
|
12
13
|
|
|
13
|
-
export type SpecSelectorProps =
|
|
14
|
+
export type SpecSelectorProps = FormFieldComponentProps;
|
|
14
15
|
|
|
15
16
|
export const SpecSelector = (props: SpecSelectorProps) => {
|
|
16
|
-
const { t } = useTranslation(
|
|
17
|
-
const specProps =
|
|
17
|
+
const { t } = useTranslation(meta.id);
|
|
18
|
+
const specProps = useFormFieldState(SpecSelector.displayName, ['spec' satisfies keyof Trigger.Trigger]);
|
|
18
19
|
|
|
19
20
|
const handleTypeChange = useCallback(
|
|
20
|
-
(_type: any, value: string):
|
|
21
|
+
(_type: any, value: string): Trigger.Spec | undefined => {
|
|
21
22
|
const getDefaultTriggerSpec = (kind: string) => {
|
|
22
23
|
switch (kind) {
|
|
23
|
-
case
|
|
24
|
-
return
|
|
25
|
-
case
|
|
26
|
-
return
|
|
27
|
-
case
|
|
28
|
-
return
|
|
29
|
-
case
|
|
30
|
-
return
|
|
31
|
-
case
|
|
32
|
-
return
|
|
24
|
+
case 'timer':
|
|
25
|
+
return Trigger.specTimer('');
|
|
26
|
+
case 'subscription':
|
|
27
|
+
return Trigger.specSubscription(Query.select(Filter.nothing()));
|
|
28
|
+
case 'queue':
|
|
29
|
+
return Trigger.specQueue('dxn:queue:default');
|
|
30
|
+
case 'email':
|
|
31
|
+
return Trigger.specEmail();
|
|
32
|
+
case 'webhook':
|
|
33
|
+
return Trigger.specWebhook();
|
|
33
34
|
default:
|
|
34
35
|
return undefined;
|
|
35
36
|
}
|
|
@@ -41,19 +42,30 @@ export const SpecSelector = (props: SpecSelectorProps) => {
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
// Update the entire spec object, not just the `spec.kind`.
|
|
44
|
-
specProps.onValueChange(
|
|
45
|
+
specProps.onValueChange(props.type, defaultSpec);
|
|
45
46
|
},
|
|
46
|
-
[specProps],
|
|
47
|
+
[props.type, specProps],
|
|
47
48
|
);
|
|
48
49
|
|
|
50
|
+
const kindLabels: Record<string, string> = {
|
|
51
|
+
timer: t('trigger-type.timer.label'),
|
|
52
|
+
webhook: t('trigger-type.webhook.label'),
|
|
53
|
+
websocket: t('trigger-type.websocket.label'),
|
|
54
|
+
subscription: t('trigger-type.subscription.label'),
|
|
55
|
+
email: t('trigger-type.email.label'),
|
|
56
|
+
queue: t('trigger-type.queue.label'),
|
|
57
|
+
};
|
|
58
|
+
|
|
49
59
|
const options = useMemo(
|
|
50
60
|
() =>
|
|
51
|
-
|
|
61
|
+
Trigger.Kinds.map((kind) => ({
|
|
52
62
|
value: kind,
|
|
53
|
-
label:
|
|
63
|
+
label: kindLabels[kind],
|
|
54
64
|
})),
|
|
55
65
|
[t],
|
|
56
66
|
);
|
|
57
67
|
|
|
58
|
-
return <
|
|
68
|
+
return <SelectField {...props} options={options} onValueChange={handleTypeChange} />;
|
|
59
69
|
};
|
|
70
|
+
|
|
71
|
+
SpecSelector.displayName = 'Form.SpecSelector';
|
|
@@ -2,32 +2,58 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
import { expect, userEvent, within } from 'storybook/test';
|
|
8
|
+
|
|
9
|
+
import { Filter, Obj, Ref, Tag, Type } from '@dxos/echo';
|
|
10
|
+
import { Trigger } from '@dxos/functions';
|
|
11
|
+
import { invariant } from '@dxos/invariant';
|
|
12
|
+
import { Operation } from '@dxos/operation';
|
|
13
|
+
import { random } from '@dxos/random';
|
|
14
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
15
|
+
import { TestSchema, useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
16
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
17
|
+
import { translations as formTranslations } from '@dxos/react-ui-form/translations';
|
|
18
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
19
|
+
import { Employer, Organization, Person, Pipeline } from '@dxos/types';
|
|
20
|
+
|
|
21
|
+
import { functions } from '#testing';
|
|
22
|
+
import { translations } from '#translations';
|
|
23
|
+
|
|
24
|
+
import { TriggerEditor, type TriggerEditorProps } from './TriggerEditor';
|
|
25
|
+
|
|
26
|
+
const types = [
|
|
27
|
+
// TODO(burdon): Get label from annotation.
|
|
28
|
+
{ value: Organization.Organization.typename, label: 'Organization' },
|
|
29
|
+
{ value: Person.Person.typename, label: 'Person' },
|
|
30
|
+
{ value: Type.getTypename(Pipeline.Pipeline), label: 'Project' },
|
|
31
|
+
{ value: Employer.Employer.typename, label: 'Employer' },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const DefaultStory = (props: Partial<TriggerEditorProps>) => {
|
|
35
|
+
const { space } = useClientStory();
|
|
36
|
+
const [trigger, setTrigger] = useState<Trigger.Trigger>();
|
|
37
|
+
const tags = useQuery(space?.db, Filter.type(Tag.Tag));
|
|
38
|
+
|
|
39
|
+
useAsyncEffect(async () => {
|
|
26
40
|
if (!space) {
|
|
27
41
|
return;
|
|
28
42
|
}
|
|
29
43
|
|
|
30
|
-
const
|
|
44
|
+
const functions = await space.db.query(Filter.type(Operation.PersistentOperation)).run();
|
|
45
|
+
const fn = functions.find((fn) => fn.name === 'example.com/function/forex');
|
|
46
|
+
invariant(fn);
|
|
47
|
+
const trigger = space.db.add(
|
|
48
|
+
Trigger.make({
|
|
49
|
+
function: Ref.make(fn),
|
|
50
|
+
spec: Trigger.specWebhook(),
|
|
51
|
+
input: {
|
|
52
|
+
from: 'USD',
|
|
53
|
+
to: 'JPY',
|
|
54
|
+
},
|
|
55
|
+
}),
|
|
56
|
+
);
|
|
31
57
|
setTrigger(trigger);
|
|
32
58
|
}, [space]);
|
|
33
59
|
|
|
@@ -36,43 +62,106 @@ const DefaultStory = () => {
|
|
|
36
62
|
}
|
|
37
63
|
|
|
38
64
|
return (
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
65
|
+
<TriggerEditor
|
|
66
|
+
db={space.db}
|
|
67
|
+
trigger={trigger}
|
|
68
|
+
types={types}
|
|
69
|
+
tags={tags}
|
|
70
|
+
onSave={(values) => console.log('on save', values)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
42
73
|
);
|
|
43
74
|
};
|
|
44
75
|
|
|
45
|
-
const meta
|
|
46
|
-
title: 'plugins/plugin-automation/TriggerEditor',
|
|
47
|
-
component: TriggerEditor,
|
|
76
|
+
const meta = {
|
|
77
|
+
title: 'plugins/plugin-automation/components/TriggerEditor',
|
|
78
|
+
component: TriggerEditor as any,
|
|
48
79
|
render: DefaultStory,
|
|
49
80
|
decorators: [
|
|
81
|
+
withTheme(),
|
|
82
|
+
withLayout({ layout: 'column' }),
|
|
50
83
|
withClientProvider({
|
|
51
84
|
createIdentity: true,
|
|
52
85
|
createSpace: true,
|
|
53
|
-
types: [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
86
|
+
types: [Tag.Tag, Operation.PersistentOperation, Trigger.Trigger, TestSchema.ContactType],
|
|
87
|
+
onCreateSpace: ({ space }) => {
|
|
88
|
+
// Tags.
|
|
89
|
+
['Important', 'Investor', 'New'].forEach((label) => {
|
|
90
|
+
space.db.add(Tag.make({ label }));
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Functions.
|
|
94
|
+
functions.forEach((fn) => {
|
|
95
|
+
space.db.add(Obj.make(Operation.PersistentOperation, { ...fn, version: fn.version ?? '0.1.0' }));
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Objects.
|
|
58
99
|
Array.from({ length: 10 }).map(() => {
|
|
59
100
|
return space.db.add(
|
|
60
|
-
Obj.make(ContactType, {
|
|
61
|
-
name:
|
|
101
|
+
Obj.make(TestSchema.ContactType, {
|
|
102
|
+
name: random.person.fullName(),
|
|
62
103
|
identifiers: [],
|
|
63
104
|
}),
|
|
64
105
|
);
|
|
65
106
|
});
|
|
66
107
|
},
|
|
67
108
|
}),
|
|
68
|
-
withLayout({ fullscreen: true, classNames: 'flex justify-center m-2' }),
|
|
69
|
-
withTheme,
|
|
70
109
|
],
|
|
71
110
|
parameters: {
|
|
72
|
-
|
|
111
|
+
layout: 'fullscreen',
|
|
112
|
+
translations: [...formTranslations, ...translations],
|
|
73
113
|
},
|
|
74
|
-
}
|
|
114
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
75
115
|
|
|
76
116
|
export default meta;
|
|
77
117
|
|
|
78
|
-
|
|
118
|
+
type Story = StoryObj<typeof meta>;
|
|
119
|
+
|
|
120
|
+
export const Default: Story = {};
|
|
121
|
+
|
|
122
|
+
export const ReadonlySpec: Story = {
|
|
123
|
+
args: {
|
|
124
|
+
readonlySpec: true,
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const Spec: Story = {
|
|
129
|
+
play: async ({ canvasElement }) => {
|
|
130
|
+
const canvas = within(canvasElement);
|
|
131
|
+
const webhookText = await canvas.findByText('Webhook', {}, { timeout: 10_000 });
|
|
132
|
+
const combobox = webhookText.closest('[role="combobox"]') as HTMLElement;
|
|
133
|
+
await expect(combobox).not.toBeDisabled();
|
|
134
|
+
|
|
135
|
+
// Helper to switch to a kind via keyboard.
|
|
136
|
+
// TODO(wittjosiah): Radix Select in popper mode doesn't close on click.
|
|
137
|
+
// Use keyboard navigation: open, type first letter to jump, Enter to select.
|
|
138
|
+
const selectKind = async (combobox: HTMLElement, firstLetter: string) => {
|
|
139
|
+
combobox.focus();
|
|
140
|
+
await userEvent.keyboard('{Enter}');
|
|
141
|
+
await userEvent.keyboard(firstLetter);
|
|
142
|
+
await userEvent.keyboard('{Enter}');
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// Timer — should show "Cron" field.
|
|
146
|
+
await selectKind(combobox, 't');
|
|
147
|
+
await expect(canvas.findByLabelText('Cron')).resolves.toBeInTheDocument();
|
|
148
|
+
|
|
149
|
+
// Email — no extra fields; Cron should be gone.
|
|
150
|
+
await selectKind(combobox, 'e');
|
|
151
|
+
await expect(combobox).not.toBeDisabled();
|
|
152
|
+
await expect(canvas.queryByLabelText('Cron')).not.toBeInTheDocument();
|
|
153
|
+
|
|
154
|
+
// Webhook — should show "Method" field.
|
|
155
|
+
await selectKind(combobox, 'w');
|
|
156
|
+
await expect(canvas.findByLabelText('Method')).resolves.toBeInTheDocument();
|
|
157
|
+
|
|
158
|
+
// Subscription — should show query editor.
|
|
159
|
+
await selectKind(combobox, 's');
|
|
160
|
+
await expect(combobox).not.toBeDisabled();
|
|
161
|
+
await expect(canvas.queryByLabelText('Method')).not.toBeInTheDocument();
|
|
162
|
+
|
|
163
|
+
// Feed — should show DXN field (the queue address). DXN is a combobox, not an input, so use getByText.
|
|
164
|
+
await selectKind(combobox, 'f');
|
|
165
|
+
await expect(canvas.findByText('DXN')).resolves.toBeInTheDocument();
|
|
166
|
+
},
|
|
167
|
+
};
|
|
@@ -5,57 +5,89 @@
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { ComputeGraph } from '@dxos/conductor';
|
|
8
|
-
import {
|
|
8
|
+
import { DXN, type Database, Entity, Feed, Obj, type Query } from '@dxos/echo';
|
|
9
|
+
import { Script, Trigger } from '@dxos/functions';
|
|
10
|
+
import { Operation } from '@dxos/operation';
|
|
11
|
+
import { Filter, Ref, useQuery } from '@dxos/react-client/echo';
|
|
12
|
+
import { Input } from '@dxos/react-ui';
|
|
13
|
+
import { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';
|
|
9
14
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
type
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import { FunctionInputEditor
|
|
15
|
+
type ExcludeId,
|
|
16
|
+
Form,
|
|
17
|
+
FormFieldLabel,
|
|
18
|
+
type FormFieldMap,
|
|
19
|
+
type FormRootProps,
|
|
20
|
+
SelectField,
|
|
21
|
+
omitId,
|
|
22
|
+
} from '@dxos/react-ui-form';
|
|
23
|
+
|
|
24
|
+
import { FunctionInputEditor } from './FunctionInputEditor';
|
|
20
25
|
import { SpecSelector } from './SpecSelector';
|
|
21
26
|
|
|
27
|
+
type TriggerFormSchema = ExcludeId<typeof Trigger.Trigger>;
|
|
28
|
+
|
|
22
29
|
export type TriggerEditorProps = {
|
|
23
|
-
|
|
24
|
-
trigger:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
30
|
+
db: Database.Database;
|
|
31
|
+
trigger: Trigger.Trigger;
|
|
32
|
+
// TODO(wittjosiah): This needs to apply to whole spec but currently only applies to spec.kind & spec.query.
|
|
33
|
+
readonlySpec?: boolean;
|
|
34
|
+
} &
|
|
35
|
+
// prettier-ignore
|
|
36
|
+
Pick<QueryFormProps, 'types' | 'tags'> &
|
|
37
|
+
Pick<FormRootProps<TriggerFormSchema>, 'onSave' | 'onCancel'>;
|
|
38
|
+
|
|
39
|
+
export const TriggerEditor = ({ db, types, tags, readonlySpec, trigger, ...formProps }: TriggerEditorProps) => {
|
|
40
|
+
const fieldMap = useCustomInputs({ db, types, tags, readonlySpec });
|
|
28
41
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
const handleValuesChanged = useCallback(
|
|
43
|
+
(newValues: Partial<TriggerFormSchema>) => {
|
|
44
|
+
Obj.update(trigger, (trigger) => {
|
|
45
|
+
Object.assign(trigger, newValues);
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
[trigger],
|
|
49
|
+
);
|
|
33
50
|
|
|
34
|
-
const
|
|
35
|
-
const
|
|
51
|
+
const triggerSchema = useMemo(() => omitId(Trigger.Trigger), []);
|
|
52
|
+
const defaultValues = useMemo(() => {
|
|
53
|
+
const { id: _, ...values } = trigger;
|
|
54
|
+
return values;
|
|
55
|
+
}, [trigger]);
|
|
36
56
|
|
|
37
57
|
return (
|
|
38
|
-
<Form
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
schema={
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
58
|
+
<Form.Root<TriggerFormSchema>
|
|
59
|
+
{...formProps}
|
|
60
|
+
db={db}
|
|
61
|
+
schema={triggerSchema}
|
|
62
|
+
defaultValues={defaultValues}
|
|
63
|
+
fieldMap={fieldMap}
|
|
64
|
+
onValuesChanged={handleValuesChanged}
|
|
65
|
+
>
|
|
66
|
+
<Form.Viewport>
|
|
67
|
+
<Form.Content>
|
|
68
|
+
<Form.FieldSet />
|
|
69
|
+
<Form.Actions />
|
|
70
|
+
</Form.Content>
|
|
71
|
+
</Form.Viewport>
|
|
72
|
+
</Form.Root>
|
|
47
73
|
);
|
|
48
74
|
};
|
|
49
75
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
76
|
+
type UseCustomInputsProps = {
|
|
77
|
+
db: Database.Database;
|
|
78
|
+
readonlySpec?: boolean;
|
|
79
|
+
} & Pick<QueryFormProps, 'types' | 'tags'>;
|
|
80
|
+
|
|
81
|
+
const useCustomInputs = ({ db, readonlySpec, types, tags }: UseCustomInputsProps): FormFieldMap => {
|
|
82
|
+
const functions = useQuery(db, Filter.type(Operation.PersistentOperation));
|
|
83
|
+
const workflows = useQuery(db, Filter.type(ComputeGraph));
|
|
84
|
+
const scripts = useQuery(db, Filter.type(Script.Script));
|
|
85
|
+
const feeds = useQuery(db, Filter.type(Feed.Feed));
|
|
54
86
|
|
|
55
87
|
return useMemo(
|
|
56
|
-
():
|
|
88
|
+
(): FormFieldMap => ({
|
|
57
89
|
// Function selector.
|
|
58
|
-
['function' satisfies keyof
|
|
90
|
+
['function' satisfies keyof Trigger.Trigger]: (props) => {
|
|
59
91
|
const getValue = useCallback(() => {
|
|
60
92
|
const formValue = props.getValue();
|
|
61
93
|
if (Ref.isRef(formValue)) {
|
|
@@ -66,17 +98,17 @@ const useCustomInputs = (space: Space, onQueryRefOptions: FunctionInputEditorPro
|
|
|
66
98
|
|
|
67
99
|
const handleOnValueChange = useCallback(
|
|
68
100
|
(_type: any, dxnString: string) => {
|
|
69
|
-
const dxn =
|
|
101
|
+
const dxn = DXN.parse(dxnString);
|
|
70
102
|
if (dxn) {
|
|
71
103
|
const ref = Ref.fromDXN(dxn);
|
|
72
|
-
props.onValueChange(
|
|
104
|
+
props.onValueChange(props.type, ref);
|
|
73
105
|
}
|
|
74
106
|
},
|
|
75
|
-
[props.onValueChange],
|
|
107
|
+
[props.type, props.onValueChange],
|
|
76
108
|
);
|
|
77
109
|
|
|
78
110
|
return (
|
|
79
|
-
<
|
|
111
|
+
<SelectField
|
|
80
112
|
{...props}
|
|
81
113
|
getValue={getValue as any}
|
|
82
114
|
onValueChange={handleOnValueChange}
|
|
@@ -86,14 +118,31 @@ const useCustomInputs = (space: Space, onQueryRefOptions: FunctionInputEditorPro
|
|
|
86
118
|
},
|
|
87
119
|
|
|
88
120
|
// Spec selector.
|
|
89
|
-
|
|
121
|
+
'spec.kind': (props) => <SpecSelector {...props} readonly={readonlySpec} />,
|
|
122
|
+
|
|
123
|
+
// Queue feed selector with parent labels.
|
|
124
|
+
'spec.queue': (props) => <SelectField {...props} options={getFeedQueueOptions(feeds)} />,
|
|
125
|
+
|
|
126
|
+
// TODO(wittjosiah): Copied from ViewEditor.
|
|
127
|
+
// Query input editor.
|
|
128
|
+
'spec.query': (props) => {
|
|
129
|
+
const handleChange = useCallback(
|
|
130
|
+
(query: Query.Any) => props.onValueChange(props.type, { ast: query.ast }),
|
|
131
|
+
[props.type, props.onValueChange],
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<Input.Root>
|
|
136
|
+
<FormFieldLabel label={props.label} asChild />
|
|
137
|
+
<QueryForm initialQuery={(props.getValue() as any).ast} types={types} tags={tags} onChange={handleChange} />
|
|
138
|
+
</Input.Root>
|
|
139
|
+
);
|
|
140
|
+
},
|
|
90
141
|
|
|
91
142
|
// Function input editor.
|
|
92
|
-
|
|
93
|
-
<FunctionInputEditor {...props} functions={functions} onQueryRefOptions={onQueryRefOptions} />
|
|
94
|
-
),
|
|
143
|
+
input: (props) => <FunctionInputEditor {...props} functions={functions} db={db} />,
|
|
95
144
|
}),
|
|
96
|
-
[workflows, scripts, functions],
|
|
145
|
+
[workflows, scripts, functions, feeds, readonlySpec],
|
|
97
146
|
);
|
|
98
147
|
};
|
|
99
148
|
|
|
@@ -101,7 +150,20 @@ const getWorkflowOptions = (graphs: ComputeGraph[]) => {
|
|
|
101
150
|
return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));
|
|
102
151
|
};
|
|
103
152
|
|
|
104
|
-
const getFunctionOptions = (scripts:
|
|
105
|
-
const getLabel = (fn:
|
|
153
|
+
const getFunctionOptions = (scripts: Script.Script[], functions: Operation.PersistentOperation[]) => {
|
|
154
|
+
const getLabel = (fn: Operation.PersistentOperation) =>
|
|
155
|
+
scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
|
|
106
156
|
return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:echo:@:${fn.id}` }));
|
|
107
157
|
};
|
|
158
|
+
|
|
159
|
+
const getFeedQueueOptions = (feeds: Feed.Feed[]) => {
|
|
160
|
+
return feeds.flatMap((feed) => {
|
|
161
|
+
const queueDxn = Feed.getQueueDxn(feed);
|
|
162
|
+
if (!queueDxn) {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
const parent = Obj.getParent(feed);
|
|
166
|
+
const label = parent ? Entity.getLabel(parent) : Entity.getLabel(feed);
|
|
167
|
+
return [{ label: label ?? feed.id, value: queueDxn.toString() }];
|
|
168
|
+
});
|
|
169
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { lazy } from 'react';
|
|
|
6
6
|
|
|
7
7
|
export * from './TriggerEditor';
|
|
8
8
|
|
|
9
|
-
export const AutomationContainer = lazy(() => import('./AutomationContainer'));
|
|
10
9
|
export const AutomationPanel = lazy(() => import('./AutomationPanel'));
|
|
11
|
-
export const FunctionsContainer = lazy(() => import('./FunctionsContainer'));
|
|
12
10
|
export const FunctionsPanel = lazy(() => import('./FunctionsPanel'));
|
|
11
|
+
export const FunctionsRegistry = lazy(() => import('./FunctionsRegistry'));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { Settings } from '@dxos/react-ui-form';
|
|
10
|
+
|
|
11
|
+
import { meta } from '#meta';
|
|
12
|
+
|
|
13
|
+
import { AutomationPanel, type AutomationPanelProps } from '../../components/AutomationPanel';
|
|
14
|
+
import { TriggersSettings } from '../TriggerSettings';
|
|
15
|
+
|
|
16
|
+
export type AutomationSettingsProps = AppSurface.SpaceArticleProps<Omit<AutomationPanelProps, 'space'>>;
|
|
17
|
+
|
|
18
|
+
export const AutomationSettings = (props: AutomationSettingsProps) => {
|
|
19
|
+
const { t } = useTranslation(meta.id);
|
|
20
|
+
return (
|
|
21
|
+
<Settings.Viewport>
|
|
22
|
+
<Settings.Section
|
|
23
|
+
title={t('automation-verbose.label', { ns: meta.id })}
|
|
24
|
+
description={t('automation.description', { ns: meta.id })}
|
|
25
|
+
>
|
|
26
|
+
<AutomationPanel {...props} />
|
|
27
|
+
<TriggersSettings space={props.space} />
|
|
28
|
+
</Settings.Section>
|
|
29
|
+
</Settings.Viewport>
|
|
30
|
+
);
|
|
31
|
+
};
|