@dxos/plugin-automation 0.8.4-main.7ace549 → 0.8.4-main.937b3ca
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-FAS6ADCW.mjs +11 -0
- package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs +56 -0
- package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs.map +7 -0
- package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs +129 -0
- package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-CRW6SJUN.mjs → FunctionsPanel-ZX4J75UM.mjs} +3 -3
- package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs +84 -0
- package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CZVA5NMD.mjs → chunk-54PANILA.mjs} +5 -5
- package/dist/lib/browser/chunk-BFUIVUQH.mjs +102 -0
- package/dist/lib/browser/chunk-BFUIVUQH.mjs.map +7 -0
- package/dist/lib/browser/chunk-BKFQBKYO.mjs +8 -0
- package/dist/lib/browser/chunk-BKFQBKYO.mjs.map +7 -0
- package/dist/lib/browser/chunk-JOXPQ27I.mjs +83 -0
- package/dist/lib/browser/chunk-JOXPQ27I.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LZQFZO3B.mjs → chunk-PZNBEKO5.mjs} +1 -1
- package/dist/lib/browser/chunk-PZNBEKO5.mjs.map +7 -0
- package/dist/lib/browser/chunk-QW3EM35H.mjs +248 -0
- package/dist/lib/browser/chunk-QW3EM35H.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4MBM6C6A.mjs → chunk-RAF2FJST.mjs} +14 -28
- package/dist/lib/browser/chunk-RAF2FJST.mjs.map +7 -0
- package/dist/lib/browser/chunk-YWLEY2FD.mjs +200 -0
- package/dist/lib/browser/chunk-YWLEY2FD.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/compute-runtime-WTWLQ67J.mjs +114 -0
- package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +3 -3
- package/dist/lib/browser/index.mjs +49 -57
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs +82 -0
- package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-TKU2EQ5A.mjs → react-surface-EV3AC62F.mjs} +12 -11
- package/dist/lib/browser/react-surface-EV3AC62F.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +10 -4
- package/dist/lib/node-esm/{AutomationPanel-F5CTC6AT.mjs → AutomationPanel-B7NAGDFA.mjs} +4 -4
- package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs +57 -0
- package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs +130 -0
- package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-RVVCS6VH.mjs → FunctionsPanel-SS6GIVNU.mjs} +3 -3
- package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs +85 -0
- package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2CKVH7JC.mjs +201 -0
- package/dist/lib/node-esm/chunk-2CKVH7JC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-CEVIVRTY.mjs → chunk-5FXNN3MV.mjs} +1 -1
- package/dist/lib/node-esm/chunk-5FXNN3MV.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-3IYSC75Z.mjs → chunk-7QRUPEHH.mjs} +5 -5
- package/dist/lib/node-esm/{chunk-7B6NAAI6.mjs → chunk-HQLVREIX.mjs} +14 -28
- package/dist/lib/node-esm/chunk-HQLVREIX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-K7GCM342.mjs +10 -0
- package/dist/lib/node-esm/chunk-K7GCM342.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KWKWOGS5.mjs +103 -0
- package/dist/lib/node-esm/chunk-KWKWOGS5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs +249 -0
- package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RX52VKI2.mjs +84 -0
- package/dist/lib/node-esm/chunk-RX52VKI2.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/compute-runtime-ZHROOBLY.mjs +115 -0
- package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +3 -3
- package/dist/lib/node-esm/index.mjs +49 -57
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs +83 -0
- package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-7QROSEGH.mjs → react-surface-S6VZJCEZ.mjs} +12 -11
- package/dist/lib/node-esm/react-surface-S6VZJCEZ.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +10 -4
- 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/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts +6 -0
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-runtime/index.d.ts +3 -0
- package/dist/types/src/capabilities/compute-runtime/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +4 -5
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- 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 +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +10 -7
- 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 +7 -6
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +70 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TriggerSettings.d.ts +3 -3
- package/dist/types/src/components/TriggerSettings.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +6 -6
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +2 -2
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +22 -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 +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +30 -1
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +61 -49
- package/src/AutomationPlugin.tsx +13 -33
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +71 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/{compute-runtime.ts → compute-runtime/compute-runtime.ts} +48 -44
- package/src/capabilities/compute-runtime/index.ts +7 -0
- package/src/capabilities/index.ts +4 -8
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +79 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +60 -0
- 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 +89 -0
- package/src/cli/commands/trigger/create/subscription.ts +128 -0
- package/src/cli/commands/trigger/create/timer.ts +93 -0
- package/src/cli/commands/trigger/index.ts +16 -0
- package/src/cli/commands/trigger/list.ts +67 -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 +278 -0
- package/src/cli/commands/trigger/update/timer.ts +193 -0
- package/src/cli/commands/trigger/util.ts +395 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +23 -0
- package/src/components/AutomationPanel/AutomationPanel.tsx +33 -12
- package/src/components/AutomationSettings.tsx +1 -1
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +11 -16
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +8 -24
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +23 -31
- package/src/components/TriggerEditor/SpecSelector.tsx +8 -6
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +27 -24
- package/src/components/TriggerEditor/TriggerEditor.tsx +55 -42
- package/src/components/TriggerSettings.tsx +3 -3
- package/src/hooks/useComputeRuntimeCallback.ts +9 -10
- package/src/hooks/useTriggerRuntimeControls.ts +7 -7
- package/src/index.ts +1 -2
- package/src/meta.ts +2 -2
- package/src/translations.ts +2 -0
- package/src/{capabilities → types}/capabilities.ts +8 -7
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +2 -0
- package/src/types/schema.ts +23 -2
- package/dist/lib/browser/AutomationPanel-M4M77L4V.mjs +0 -11
- package/dist/lib/browser/AutomationSettings-4HCI6KJR.mjs +0 -68
- package/dist/lib/browser/AutomationSettings-4HCI6KJR.mjs.map +0 -7
- package/dist/lib/browser/FunctionsContainer-CDVBRQCT.mjs +0 -144
- package/dist/lib/browser/FunctionsContainer-CDVBRQCT.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs +0 -81
- package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs.map +0 -7
- package/dist/lib/browser/chunk-4MBM6C6A.mjs.map +0 -7
- package/dist/lib/browser/chunk-7W6QMY3L.mjs +0 -267
- package/dist/lib/browser/chunk-7W6QMY3L.mjs.map +0 -7
- package/dist/lib/browser/chunk-LZQFZO3B.mjs.map +0 -7
- package/dist/lib/browser/chunk-T6ZESHDY.mjs +0 -191
- package/dist/lib/browser/chunk-T6ZESHDY.mjs.map +0 -7
- package/dist/lib/browser/chunk-TWWFNOIR.mjs +0 -109
- package/dist/lib/browser/chunk-TWWFNOIR.mjs.map +0 -7
- package/dist/lib/browser/chunk-XAKZ4ANY.mjs +0 -15
- package/dist/lib/browser/chunk-XAKZ4ANY.mjs.map +0 -7
- package/dist/lib/browser/chunk-YBPJCY3F.mjs +0 -38
- package/dist/lib/browser/chunk-YBPJCY3F.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-B4XJVY4Y.mjs +0 -113
- package/dist/lib/browser/compute-runtime-B4XJVY4Y.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs +0 -77
- package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs.map +0 -7
- package/dist/lib/browser/react-surface-TKU2EQ5A.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationSettings-BQLJIFRT.mjs +0 -69
- package/dist/lib/node-esm/AutomationSettings-BQLJIFRT.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-ZHHJPQAZ.mjs +0 -145
- package/dist/lib/node-esm/FunctionsContainer-ZHHJPQAZ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs +0 -82
- package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7B6NAAI6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CEVIVRTY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CF2SWXPW.mjs +0 -268
- package/dist/lib/node-esm/chunk-CF2SWXPW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ECJKIUBO.mjs +0 -39
- package/dist/lib/node-esm/chunk-ECJKIUBO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F76XVENA.mjs +0 -192
- package/dist/lib/node-esm/chunk-F76XVENA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KB7NFEYY.mjs +0 -16
- package/dist/lib/node-esm/chunk-KB7NFEYY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RVK52XGK.mjs +0 -110
- package/dist/lib/node-esm/chunk-RVK52XGK.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-JUWTQXOV.mjs +0 -114
- package/dist/lib/node-esm/compute-runtime-JUWTQXOV.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs +0 -78
- package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-7QROSEGH.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -20
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts +0 -5
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +0 -1
- 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/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -87
- package/src/capabilities/intent-resolver.ts +0 -72
- package/src/capabilities/react-surface.tsx +0 -56
- package/src/events.ts +0 -11
- /package/dist/lib/browser/{AutomationPanel-M4M77L4V.mjs.map → AutomationPanel-FAS6ADCW.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-CRW6SJUN.mjs.map → FunctionsPanel-ZX4J75UM.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-CZVA5NMD.mjs.map → chunk-54PANILA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-F5CTC6AT.mjs.map → AutomationPanel-B7NAGDFA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-RVVCS6VH.mjs.map → FunctionsPanel-SS6GIVNU.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-3IYSC75Z.mjs.map → chunk-7QRUPEHH.mjs.map} +0 -0
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Array from 'effect/Array';
|
|
6
|
-
import * as EffectFunction from 'effect/Function';
|
|
7
|
-
import * as Order from 'effect/Order';
|
|
8
5
|
import * as Schema from 'effect/Schema';
|
|
9
6
|
import { useState } from 'react';
|
|
10
7
|
import React, { useCallback } from 'react';
|
|
@@ -17,7 +14,7 @@ import { useAsyncEffect } from '@dxos/react-ui';
|
|
|
17
14
|
import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
18
15
|
import { controlItemClasses } from '@dxos/react-ui-form';
|
|
19
16
|
import { List } from '@dxos/react-ui-list';
|
|
20
|
-
import { ghostHover, mx } from '@dxos/
|
|
17
|
+
import { ghostHover, mx } from '@dxos/ui-theme';
|
|
21
18
|
|
|
22
19
|
import { meta } from '../../meta';
|
|
23
20
|
|
|
@@ -33,7 +30,7 @@ export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
|
|
|
33
30
|
const [functions, setFunctions] = useState<Function.Function[]>([]);
|
|
34
31
|
const { t } = useTranslation(meta.id);
|
|
35
32
|
|
|
36
|
-
const dbFunctions = useQuery(space, Filter.type(Function.Function));
|
|
33
|
+
const dbFunctions = useQuery(space.db, Filter.type(Function.Function));
|
|
37
34
|
|
|
38
35
|
const state = (func: Function.Function) => {
|
|
39
36
|
const dbFunction = dbFunctions.find((f) => f.key === func.key);
|
|
@@ -48,24 +45,15 @@ export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
|
|
|
48
45
|
|
|
49
46
|
useAsyncEffect(async () => {
|
|
50
47
|
setLoading(true);
|
|
51
|
-
const functions = await getDeployedFunctions(client);
|
|
48
|
+
const functions = await getDeployedFunctions(client, true);
|
|
52
49
|
setFunctions(functions);
|
|
53
50
|
setLoading(false);
|
|
54
51
|
}, []);
|
|
55
52
|
|
|
56
|
-
const dedupedFunctions = EffectFunction.pipe(
|
|
57
|
-
functions,
|
|
58
|
-
Array.filter((_) => _.key !== undefined),
|
|
59
|
-
Array.sort(Order.reverse(Order.mapInput(Order.string, (_: Function.Function) => _.updated ?? ''))),
|
|
60
|
-
Array.dedupeWith((self, that) => self.key === that.key),
|
|
61
|
-
Array.sort(Order.mapInput(Order.string, (_: Function.Function) => _.key ?? '')),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
53
|
const hanleImportOrUpdate = useCallback(
|
|
65
54
|
async (func: Function.Function) => {
|
|
66
|
-
const {
|
|
67
|
-
|
|
68
|
-
} = await space.db.query(Query.type(Function.Function, { key: func.key })).run();
|
|
55
|
+
const functions = await space.db.query(Query.type(Function.Function, { key: func.key })).run();
|
|
56
|
+
const [existingFunc] = functions;
|
|
69
57
|
if (!existingFunc) {
|
|
70
58
|
space.db.add(func);
|
|
71
59
|
return;
|
|
@@ -77,12 +65,8 @@ export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
|
|
|
77
65
|
|
|
78
66
|
return (
|
|
79
67
|
<div role='none' className={mx(controlItemClasses)}>
|
|
80
|
-
{
|
|
81
|
-
<List.Root<Function.Function>
|
|
82
|
-
items={dedupedFunctions}
|
|
83
|
-
isItem={Schema.is(Function.Function)}
|
|
84
|
-
getId={(func) => func.id}
|
|
85
|
-
>
|
|
68
|
+
{functions.length > 0 && (
|
|
69
|
+
<List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>
|
|
86
70
|
{({ items }) => (
|
|
87
71
|
<div role='list' className='flex flex-col is-full'>
|
|
88
72
|
{items?.map((func) => (
|
|
@@ -118,7 +102,7 @@ export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
|
|
|
118
102
|
</List.Root>
|
|
119
103
|
)}
|
|
120
104
|
|
|
121
|
-
{
|
|
105
|
+
{functions.length === 0 && !loading && (
|
|
122
106
|
<div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>
|
|
123
107
|
)}
|
|
124
108
|
{loading && <div className='text-center plb-4 text-gray-500'>{t('loading functions')}</div>}
|
|
@@ -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 { Ref, Type } from '@dxos/echo';
|
|
8
|
+
import { type Database, Ref, Type } from '@dxos/echo';
|
|
8
9
|
import { type JsonPath } from '@dxos/echo/internal';
|
|
9
10
|
import { type Function } from '@dxos/functions';
|
|
10
|
-
import { useOnTransition } from '@dxos/react-ui';
|
|
11
|
-
import { Form, type
|
|
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 = {
|
|
17
|
+
type: SchemaAST.AST;
|
|
14
18
|
functions: Function.Function[];
|
|
15
|
-
|
|
16
|
-
} &
|
|
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);
|
|
@@ -47,20 +44,19 @@ export const FunctionInputEditor = ({
|
|
|
47
44
|
return prevValue.dxn.toString() !== selectedFunctionValue.dxn.toString();
|
|
48
45
|
},
|
|
49
46
|
(currValue) => currValue !== undefined,
|
|
50
|
-
() => onValueChange(
|
|
47
|
+
() => onValueChange(type, {}),
|
|
51
48
|
);
|
|
52
49
|
|
|
53
50
|
const inputSchema = useMemo(() => selectedFunction?.inputSchema, [selectedFunction]);
|
|
54
51
|
const effectSchema = useMemo(() => (inputSchema ? Type.toEffectSchema(inputSchema) : undefined), [inputSchema]);
|
|
55
52
|
const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
|
|
56
|
-
|
|
57
53
|
const values = useMemo(() => getValue() ?? {}, [getValue]);
|
|
58
54
|
|
|
59
|
-
const handleValuesChanged = useCallback(
|
|
60
|
-
(values
|
|
61
|
-
onValueChange(
|
|
55
|
+
const handleValuesChanged = useCallback<NonNullable<FormRootProps['onValuesChanged']>>(
|
|
56
|
+
(values) => {
|
|
57
|
+
onValueChange(type, values);
|
|
62
58
|
},
|
|
63
|
-
[onValueChange],
|
|
59
|
+
[type, onValueChange],
|
|
64
60
|
);
|
|
65
61
|
|
|
66
62
|
if (selectedFunction === undefined || effectSchema === undefined || propertyCount === 0) {
|
|
@@ -69,16 +65,12 @@ export const FunctionInputEditor = ({
|
|
|
69
65
|
|
|
70
66
|
return (
|
|
71
67
|
<>
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
schema={effectSchema}
|
|
77
|
-
values={values}
|
|
78
|
-
onValuesChanged={handleValuesChanged}
|
|
79
|
-
onQueryRefOptions={onQueryRefOptions}
|
|
80
|
-
outerSpacing={false}
|
|
81
|
-
/>
|
|
68
|
+
<Form.Label label={t('function parameters label')} asChild />
|
|
69
|
+
<Form.Root schema={effectSchema} values={values} db={db} onValuesChanged={handleValuesChanged}>
|
|
70
|
+
<Form.FieldSet />
|
|
71
|
+
</Form.Root>
|
|
82
72
|
</>
|
|
83
73
|
);
|
|
84
74
|
};
|
|
75
|
+
|
|
76
|
+
FunctionInputEditor.displayName = 'AutomationTrigger.FunctionInputEditor';
|
|
@@ -7,15 +7,15 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
7
7
|
import { Filter, Query } from '@dxos/echo';
|
|
8
8
|
import { Trigger } from '@dxos/functions';
|
|
9
9
|
import { useTranslation } from '@dxos/react-ui';
|
|
10
|
-
import { type
|
|
10
|
+
import { type FormFieldComponentProps, SelectField, useFormFieldState } from '@dxos/react-ui-form';
|
|
11
11
|
|
|
12
12
|
import { meta } from '../../meta';
|
|
13
13
|
|
|
14
|
-
export type SpecSelectorProps =
|
|
14
|
+
export type SpecSelectorProps = FormFieldComponentProps;
|
|
15
15
|
|
|
16
16
|
export const SpecSelector = (props: SpecSelectorProps) => {
|
|
17
17
|
const { t } = useTranslation(meta.id);
|
|
18
|
-
const specProps =
|
|
18
|
+
const specProps = useFormFieldState(SpecSelector.displayName, ['spec' satisfies keyof Trigger.Trigger]);
|
|
19
19
|
|
|
20
20
|
const handleTypeChange = useCallback(
|
|
21
21
|
(_type: any, value: string): Trigger.Spec | undefined => {
|
|
@@ -47,9 +47,9 @@ export const SpecSelector = (props: SpecSelectorProps) => {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// Update the entire spec object, not just the `spec.kind`.
|
|
50
|
-
specProps.onValueChange(
|
|
50
|
+
specProps.onValueChange(props.type, defaultSpec);
|
|
51
51
|
},
|
|
52
|
-
[specProps],
|
|
52
|
+
[props.type, specProps],
|
|
53
53
|
);
|
|
54
54
|
|
|
55
55
|
const options = useMemo(
|
|
@@ -61,5 +61,7 @@ export const SpecSelector = (props: SpecSelectorProps) => {
|
|
|
61
61
|
[t],
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
return <
|
|
64
|
+
return <SelectField {...props} options={options} onValueChange={handleTypeChange} />;
|
|
65
65
|
};
|
|
66
|
+
|
|
67
|
+
SpecSelector.displayName = 'Form.SpecSelector';
|
|
@@ -6,14 +6,14 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Filter, Obj, Ref, Tag, Type } from '@dxos/echo';
|
|
9
|
-
import { Function } from '@dxos/functions';
|
|
10
|
-
import { Trigger } from '@dxos/functions';
|
|
9
|
+
import { Function, Trigger } from '@dxos/functions';
|
|
11
10
|
import { invariant } from '@dxos/invariant';
|
|
12
11
|
import { faker } from '@dxos/random';
|
|
13
12
|
import { useQuery } from '@dxos/react-client/echo';
|
|
14
|
-
import { TestSchema,
|
|
13
|
+
import { TestSchema, useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
15
14
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
16
15
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
16
|
+
import { translations as formTranslations } from '@dxos/react-ui-form';
|
|
17
17
|
import { Employer, Organization, Person, Project } from '@dxos/types';
|
|
18
18
|
|
|
19
19
|
import { functions } from '../../testing';
|
|
@@ -30,17 +30,17 @@ const types = [
|
|
|
30
30
|
];
|
|
31
31
|
|
|
32
32
|
const DefaultStory = (props: Partial<TriggerEditorProps>) => {
|
|
33
|
-
const { space } =
|
|
33
|
+
const { space } = useClientStory();
|
|
34
34
|
const [trigger, setTrigger] = useState<Trigger.Trigger>();
|
|
35
|
-
const tags = useQuery(space, Filter.type(Tag.Tag));
|
|
35
|
+
const tags = useQuery(space?.db, Filter.type(Tag.Tag));
|
|
36
36
|
|
|
37
37
|
useAsyncEffect(async () => {
|
|
38
38
|
if (!space) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
const fn =
|
|
42
|
+
const functions = await space.db.query(Filter.type(Function.Function)).run();
|
|
43
|
+
const fn = functions.find((fn) => fn.name === 'example.com/function/forex');
|
|
44
44
|
invariant(fn);
|
|
45
45
|
const trigger = space.db.add(
|
|
46
46
|
Trigger.make({
|
|
@@ -60,16 +60,14 @@ const DefaultStory = (props: Partial<TriggerEditorProps>) => {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
return (
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
/>
|
|
72
|
-
</div>
|
|
63
|
+
<TriggerEditor
|
|
64
|
+
db={space.db}
|
|
65
|
+
trigger={trigger}
|
|
66
|
+
types={types}
|
|
67
|
+
tags={tags}
|
|
68
|
+
onSave={(values) => console.log('on save', values)}
|
|
69
|
+
{...props}
|
|
70
|
+
/>
|
|
73
71
|
);
|
|
74
72
|
};
|
|
75
73
|
|
|
@@ -79,19 +77,23 @@ const meta = {
|
|
|
79
77
|
render: DefaultStory,
|
|
80
78
|
decorators: [
|
|
81
79
|
withTheme,
|
|
82
|
-
withLayout({
|
|
80
|
+
withLayout({ layout: 'column' }),
|
|
83
81
|
withClientProvider({
|
|
84
82
|
createIdentity: true,
|
|
85
83
|
createSpace: true,
|
|
86
84
|
types: [Tag.Tag, Function.Function, Trigger.Trigger, TestSchema.ContactType],
|
|
87
85
|
onCreateSpace: ({ space }) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
86
|
+
// Tags.
|
|
87
|
+
['Important', 'Investor', 'New'].forEach((label) => {
|
|
88
|
+
space.db.add(Tag.make({ label }));
|
|
89
|
+
});
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
// Functions.
|
|
92
|
+
functions.forEach((fn) => {
|
|
93
93
|
space.db.add(Function.make(fn));
|
|
94
|
-
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Objects.
|
|
95
97
|
Array.from({ length: 10 }).map(() => {
|
|
96
98
|
return space.db.add(
|
|
97
99
|
Obj.make(TestSchema.ContactType, {
|
|
@@ -104,7 +106,8 @@ const meta = {
|
|
|
104
106
|
}),
|
|
105
107
|
],
|
|
106
108
|
parameters: {
|
|
107
|
-
|
|
109
|
+
layout: 'fullscreen',
|
|
110
|
+
translations: [...formTranslations, ...translations],
|
|
108
111
|
},
|
|
109
112
|
} satisfies Meta<typeof DefaultStory>;
|
|
110
113
|
|
|
@@ -5,59 +5,74 @@
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { ComputeGraph } from '@dxos/conductor';
|
|
8
|
-
import { DXN, type Query } from '@dxos/echo';
|
|
8
|
+
import { DXN, type Database, type Query } from '@dxos/echo';
|
|
9
9
|
import { Function, Script, Trigger } from '@dxos/functions';
|
|
10
|
-
import { Filter, Ref,
|
|
10
|
+
import { Filter, Ref, useQuery } from '@dxos/react-client/echo';
|
|
11
11
|
import { Input } from '@dxos/react-ui';
|
|
12
12
|
import { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
import {
|
|
14
|
+
type ExcludeId,
|
|
15
|
+
Form,
|
|
16
|
+
FormFieldLabel,
|
|
17
|
+
type FormFieldMap,
|
|
18
|
+
type FormRootProps,
|
|
19
|
+
SelectField,
|
|
20
|
+
omitId,
|
|
21
|
+
} from '@dxos/react-ui-form';
|
|
22
|
+
|
|
23
|
+
import { FunctionInputEditor } from './FunctionInputEditor';
|
|
16
24
|
import { SpecSelector } from './SpecSelector';
|
|
17
25
|
|
|
26
|
+
type TriggerFormSchema = ExcludeId<typeof Trigger.Trigger>;
|
|
27
|
+
|
|
18
28
|
export type TriggerEditorProps = {
|
|
19
|
-
|
|
29
|
+
db: Database.Database;
|
|
20
30
|
trigger: Trigger.Trigger;
|
|
21
31
|
// TODO(wittjosiah): This needs to apply to whole spec but currently only applies to spec.kind & spec.query.
|
|
22
32
|
readonlySpec?: boolean;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
} &
|
|
34
|
+
// prettier-ignore
|
|
35
|
+
Pick<QueryFormProps, 'types' | 'tags'> &
|
|
36
|
+
Pick<FormRootProps<TriggerFormSchema>, 'onSave' | 'onCancel'>;
|
|
37
|
+
|
|
38
|
+
export const TriggerEditor = ({ db, types, tags, readonlySpec, trigger, ...formProps }: TriggerEditorProps) => {
|
|
39
|
+
const fieldMap = useCustomInputs({
|
|
40
|
+
db,
|
|
41
|
+
types,
|
|
42
|
+
tags,
|
|
43
|
+
readonlySpec,
|
|
44
|
+
});
|
|
34
45
|
|
|
35
46
|
return (
|
|
36
|
-
<Form
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
schema={Trigger.Trigger}
|
|
47
|
+
<Form.Root<TriggerFormSchema>
|
|
48
|
+
{...formProps}
|
|
49
|
+
schema={omitId(Trigger.Trigger)}
|
|
40
50
|
values={trigger}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
db={db}
|
|
52
|
+
fieldMap={fieldMap}
|
|
53
|
+
>
|
|
54
|
+
<Form.Viewport>
|
|
55
|
+
<Form.Content>
|
|
56
|
+
<Form.FieldSet />
|
|
57
|
+
<Form.Actions />
|
|
58
|
+
</Form.Content>
|
|
59
|
+
</Form.Viewport>
|
|
60
|
+
</Form.Root>
|
|
45
61
|
);
|
|
46
62
|
};
|
|
47
63
|
|
|
48
64
|
type UseCustomInputsProps = {
|
|
49
|
-
|
|
65
|
+
db: Database.Database;
|
|
50
66
|
readonlySpec?: boolean;
|
|
51
|
-
onQueryRefOptions: FunctionInputEditorProps['onQueryRefOptions'];
|
|
52
67
|
} & Pick<QueryFormProps, 'types' | 'tags'>;
|
|
53
68
|
|
|
54
|
-
const useCustomInputs = ({
|
|
55
|
-
const functions = useQuery(
|
|
56
|
-
const workflows = useQuery(
|
|
57
|
-
const scripts = useQuery(
|
|
69
|
+
const useCustomInputs = ({ db, readonlySpec, types, tags }: UseCustomInputsProps): FormFieldMap => {
|
|
70
|
+
const functions = useQuery(db, Filter.type(Function.Function));
|
|
71
|
+
const workflows = useQuery(db, Filter.type(ComputeGraph));
|
|
72
|
+
const scripts = useQuery(db, Filter.type(Script.Script));
|
|
58
73
|
|
|
59
74
|
return useMemo(
|
|
60
|
-
():
|
|
75
|
+
(): FormFieldMap => ({
|
|
61
76
|
// Function selector.
|
|
62
77
|
['function' satisfies keyof Trigger.Trigger]: (props) => {
|
|
63
78
|
const getValue = useCallback(() => {
|
|
@@ -73,14 +88,14 @@ const useCustomInputs = ({ space, readonlySpec, types, tags, onQueryRefOptions }
|
|
|
73
88
|
const dxn = DXN.parse(dxnString);
|
|
74
89
|
if (dxn) {
|
|
75
90
|
const ref = Ref.fromDXN(dxn);
|
|
76
|
-
props.onValueChange(
|
|
91
|
+
props.onValueChange(props.type, ref);
|
|
77
92
|
}
|
|
78
93
|
},
|
|
79
|
-
[props.onValueChange],
|
|
94
|
+
[props.type, props.onValueChange],
|
|
80
95
|
);
|
|
81
96
|
|
|
82
97
|
return (
|
|
83
|
-
<
|
|
98
|
+
<SelectField
|
|
84
99
|
{...props}
|
|
85
100
|
getValue={getValue as any}
|
|
86
101
|
onValueChange={handleOnValueChange}
|
|
@@ -90,28 +105,26 @@ const useCustomInputs = ({ space, readonlySpec, types, tags, onQueryRefOptions }
|
|
|
90
105
|
},
|
|
91
106
|
|
|
92
107
|
// Spec selector.
|
|
93
|
-
['spec.kind' as const]: (props) => <SpecSelector {...props} readonly={readonlySpec
|
|
108
|
+
['spec.kind' as const]: (props) => <SpecSelector {...props} readonly={readonlySpec} />,
|
|
94
109
|
|
|
95
110
|
// TODO(wittjosiah): Copied from ViewEditor.
|
|
96
111
|
// Query input editor.
|
|
97
112
|
['spec.query' as const]: (props) => {
|
|
98
113
|
const handleChange = useCallback(
|
|
99
|
-
(query: Query.Any) => props.onValueChange(
|
|
100
|
-
[props.onValueChange],
|
|
114
|
+
(query: Query.Any) => props.onValueChange(props.type, { ast: query.ast }),
|
|
115
|
+
[props.type, props.onValueChange],
|
|
101
116
|
);
|
|
102
117
|
|
|
103
118
|
return (
|
|
104
119
|
<Input.Root>
|
|
105
|
-
<
|
|
120
|
+
<FormFieldLabel label={props.label} asChild />
|
|
106
121
|
<QueryForm initialQuery={(props.getValue() as any).ast} types={types} tags={tags} onChange={handleChange} />
|
|
107
122
|
</Input.Root>
|
|
108
123
|
);
|
|
109
124
|
},
|
|
110
125
|
|
|
111
126
|
// Function input editor.
|
|
112
|
-
['input' as const]: (props) =>
|
|
113
|
-
<FunctionInputEditor {...props} functions={functions} onQueryRefOptions={onQueryRefOptions} />
|
|
114
|
-
),
|
|
127
|
+
['input' as const]: (props) => <FunctionInputEditor {...props} functions={functions} db={db} />,
|
|
115
128
|
}),
|
|
116
129
|
[workflows, scripts, functions, readonlySpec],
|
|
117
130
|
);
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Database } from '@dxos/echo';
|
|
8
8
|
import { Input, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { ControlItemInput } from '@dxos/react-ui-form';
|
|
10
10
|
|
|
11
11
|
import { useTriggerRuntimeControls } from '../hooks';
|
|
12
12
|
import { meta } from '../meta';
|
|
13
13
|
|
|
14
|
-
export const TriggersSettings = ({
|
|
15
|
-
const { triggers, isRunning, start, stop } = useTriggerRuntimeControls(
|
|
14
|
+
export const TriggersSettings = ({ db }: { db: Database.Database }) => {
|
|
15
|
+
const { triggers, isRunning, start, stop } = useTriggerRuntimeControls(db);
|
|
16
16
|
const { t } = useTranslation(meta.id);
|
|
17
17
|
|
|
18
18
|
return (
|
|
@@ -5,27 +5,26 @@
|
|
|
5
5
|
import * as Cause from 'effect/Cause';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import * as Exit from 'effect/Exit';
|
|
8
|
-
import { useCallback } from 'react';
|
|
8
|
+
import { type DependencyList, useCallback } from 'react';
|
|
9
9
|
|
|
10
10
|
import { useCapability } from '@dxos/app-framework/react';
|
|
11
|
-
import { type
|
|
12
|
-
import {
|
|
11
|
+
import { type Key } from '@dxos/echo';
|
|
12
|
+
import { type FunctionDefinition, FunctionInvocationService, TracingService } from '@dxos/functions';
|
|
13
13
|
import { log } from '@dxos/log';
|
|
14
|
-
import type { Space } from '@dxos/react-client/echo';
|
|
15
14
|
|
|
16
|
-
import { AutomationCapabilities } from '../
|
|
15
|
+
import { AutomationCapabilities } from '../types';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Create an effectful function that has access to compute services
|
|
20
19
|
*/
|
|
21
20
|
// TODO(burdon): Factor out (figure out cross-plugin capabilities dependencies).
|
|
22
21
|
export const useComputeRuntimeCallback = <T>(
|
|
23
|
-
|
|
22
|
+
id: Key.SpaceId | undefined,
|
|
24
23
|
fn: () => Effect.Effect<T, any, AutomationCapabilities.ComputeServices>,
|
|
25
|
-
deps?:
|
|
24
|
+
deps?: DependencyList,
|
|
26
25
|
): (() => Promise<T>) => {
|
|
27
26
|
const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);
|
|
28
|
-
const runtime =
|
|
27
|
+
const runtime = id !== undefined ? computeRuntime.getRuntime(id) : undefined;
|
|
29
28
|
|
|
30
29
|
return useCallback(() => {
|
|
31
30
|
if (!runtime) {
|
|
@@ -39,7 +38,7 @@ export const useComputeRuntimeCallback = <T>(
|
|
|
39
38
|
// TODO(wittjosiah): Function invoking should automatically be traced (DX-647).
|
|
40
39
|
export const invokeFunctionWithTracing = <I, O>(functionDef: FunctionDefinition<I, O>, inputData: I) =>
|
|
41
40
|
Effect.gen(function* () {
|
|
42
|
-
const tracer = yield*
|
|
41
|
+
const tracer = yield* TracingService;
|
|
43
42
|
const trace = yield* tracer.traceInvocationStart({
|
|
44
43
|
target: undefined,
|
|
45
44
|
payload: {
|
|
@@ -49,7 +48,7 @@ export const invokeFunctionWithTracing = <I, O>(functionDef: FunctionDefinition<
|
|
|
49
48
|
|
|
50
49
|
// Invoke the function.
|
|
51
50
|
const result = yield* FunctionInvocationService.invokeFunction(functionDef, inputData).pipe(
|
|
52
|
-
Effect.provide(
|
|
51
|
+
Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop),
|
|
53
52
|
Effect.exit,
|
|
54
53
|
);
|
|
55
54
|
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import { Filter } from '@dxos/echo';
|
|
7
|
+
import { type Database, Filter } from '@dxos/echo';
|
|
8
8
|
import { Trigger } from '@dxos/functions';
|
|
9
9
|
import { TriggerDispatcher } from '@dxos/functions-runtime';
|
|
10
|
-
import {
|
|
10
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
11
11
|
import { useAsyncState } from '@dxos/react-ui';
|
|
12
12
|
|
|
13
13
|
import { useComputeRuntimeCallback } from './useComputeRuntimeCallback';
|
|
@@ -19,15 +19,15 @@ interface TriggerRuntimeControls {
|
|
|
19
19
|
stop: () => void;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export const useTriggerRuntimeControls = (
|
|
23
|
-
const triggers = useQuery(
|
|
22
|
+
export const useTriggerRuntimeControls = (db: Database.Database | undefined): TriggerRuntimeControls => {
|
|
23
|
+
const triggers = useQuery(db, Filter.type(Trigger.Trigger));
|
|
24
24
|
|
|
25
25
|
const [isRunningState, setIsRunningState] = useAsyncState(
|
|
26
|
-
useComputeRuntimeCallback(
|
|
26
|
+
useComputeRuntimeCallback(db?.spaceId, () => TriggerDispatcher.pipe(Effect.map((t) => t.running))),
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
const start = useComputeRuntimeCallback(
|
|
30
|
-
|
|
30
|
+
db?.spaceId,
|
|
31
31
|
Effect.fnUntraced(function* () {
|
|
32
32
|
const dispatcher = yield* TriggerDispatcher;
|
|
33
33
|
yield* dispatcher.start();
|
|
@@ -36,7 +36,7 @@ export const useTriggerRuntimeControls = (space: Space | undefined): TriggerRunt
|
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
const stop = useComputeRuntimeCallback(
|
|
39
|
-
|
|
39
|
+
db?.spaceId,
|
|
40
40
|
Effect.fnUntraced(function* () {
|
|
41
41
|
const dispatcher = yield* TriggerDispatcher;
|
|
42
42
|
yield* dispatcher.stop();
|
package/src/index.ts
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export { AutomationCapabilities } from './capabilities';
|
|
6
5
|
export * from './components';
|
|
7
6
|
export * from './meta';
|
|
8
|
-
export * from './events';
|
|
9
7
|
export * from './hooks';
|
|
8
|
+
export * from './types';
|
|
10
9
|
|
|
11
10
|
export * from './AutomationPlugin';
|
package/src/meta.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Plugin } from '@dxos/app-framework';
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
export const meta:
|
|
8
|
+
export const meta: Plugin.Meta = {
|
|
9
9
|
id: 'dxos.org/plugin/automation',
|
|
10
10
|
name: 'Automation',
|
|
11
11
|
description: trim`
|
package/src/translations.ts
CHANGED
|
@@ -30,6 +30,8 @@ export const translations = [
|
|
|
30
30
|
'go to function source button label': 'Show function source',
|
|
31
31
|
'delete function button label': 'Delete function',
|
|
32
32
|
|
|
33
|
+
'function parameters label': 'Function parameters',
|
|
34
|
+
|
|
33
35
|
'trigger editor title': 'Configure Trigger',
|
|
34
36
|
'new trigger label': 'Add Trigger',
|
|
35
37
|
'trigger type timer': 'Timer',
|