@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
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Prompt from '@effect/cli/Prompt';
|
|
6
|
+
import * as Ansi from '@effect/printer-ansi/Ansi';
|
|
7
|
+
import * as Console from 'effect/Console';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Match from 'effect/Match';
|
|
10
|
+
import * as Option from 'effect/Option';
|
|
11
|
+
import type * as Schema from 'effect/Schema';
|
|
12
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
13
|
+
|
|
14
|
+
import { FormBuilder } from '@dxos/cli-util';
|
|
15
|
+
import { Annotation, Database, Entity, Filter, Obj, Ref, Type } from '@dxos/echo';
|
|
16
|
+
import { getProperties } from '@dxos/effect';
|
|
17
|
+
import { Function, Trigger } from '@dxos/functions';
|
|
18
|
+
import { QueueAnnotation } from '@dxos/schema';
|
|
19
|
+
|
|
20
|
+
export type TriggerRemoteStatus = 'available' | 'not available' | 'n/a';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Determines the remote status of a trigger.
|
|
24
|
+
* Only timer/cron triggers can be checked for remote availability.
|
|
25
|
+
*/
|
|
26
|
+
export const getTriggerRemoteStatus = (trigger: Trigger.Trigger, remoteCronIds: string[]): TriggerRemoteStatus => {
|
|
27
|
+
if (trigger.spec?.kind !== 'timer') {
|
|
28
|
+
return 'n/a';
|
|
29
|
+
}
|
|
30
|
+
return remoteCronIds.includes(trigger.id) ? 'available' : 'not available';
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Pretty prints a trigger with ANSI colors.
|
|
35
|
+
*/
|
|
36
|
+
export const printTrigger = Effect.fn(function* (trigger: Trigger.Trigger, remoteStatus?: TriggerRemoteStatus) {
|
|
37
|
+
const fn = trigger.function && (yield* Database.Service.load(trigger.function));
|
|
38
|
+
|
|
39
|
+
return FormBuilder.make({
|
|
40
|
+
title: trigger.id,
|
|
41
|
+
}).pipe(
|
|
42
|
+
FormBuilder.set(
|
|
43
|
+
'status',
|
|
44
|
+
trigger.enabled ? 'enabled' : 'disabled',
|
|
45
|
+
trigger.enabled ? Ansi.green : Ansi.blackBright,
|
|
46
|
+
),
|
|
47
|
+
FormBuilder.option('kind', Option.fromNullable(trigger.spec?.kind)),
|
|
48
|
+
FormBuilder.option(
|
|
49
|
+
'remote',
|
|
50
|
+
Option.fromNullable(remoteStatus),
|
|
51
|
+
Match.type<TriggerRemoteStatus>().pipe(
|
|
52
|
+
Match.withReturnType<Ansi.Ansi>(),
|
|
53
|
+
Match.when('available', () => Ansi.green),
|
|
54
|
+
Match.when('not available', () => Ansi.yellow),
|
|
55
|
+
Match.when('n/a', () => Ansi.blackBright),
|
|
56
|
+
Match.exhaustive,
|
|
57
|
+
),
|
|
58
|
+
),
|
|
59
|
+
FormBuilder.when(
|
|
60
|
+
fn,
|
|
61
|
+
FormBuilder.nest(
|
|
62
|
+
'function',
|
|
63
|
+
FormBuilder.make().pipe(FormBuilder.set('key', fn!.key), FormBuilder.set('dxn', fn!.dxn?.toString())),
|
|
64
|
+
),
|
|
65
|
+
),
|
|
66
|
+
FormBuilder.nestedOption('spec', Option.fromNullable(trigger.spec).pipe(Option.map(printSpec))),
|
|
67
|
+
FormBuilder.build,
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const printSpec = <T extends Trigger.Spec>(spec: T): FormBuilder.FormBuilder => {
|
|
72
|
+
switch (spec.kind) {
|
|
73
|
+
case 'timer':
|
|
74
|
+
return printTimer(spec);
|
|
75
|
+
case 'subscription':
|
|
76
|
+
return printSubscription(spec);
|
|
77
|
+
case 'webhook':
|
|
78
|
+
return printWebhook(spec);
|
|
79
|
+
case 'queue':
|
|
80
|
+
return printQueue(spec);
|
|
81
|
+
default:
|
|
82
|
+
return FormBuilder.make({}).pipe(FormBuilder.set('unknown', 'Unknown spec type'));
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const printTimer = (spec: Trigger.TimerSpec) => FormBuilder.make({}).pipe(FormBuilder.set('cron', spec.cron));
|
|
87
|
+
|
|
88
|
+
const printSubscription = (spec: Trigger.SubscriptionSpec) =>
|
|
89
|
+
FormBuilder.make({}).pipe(FormBuilder.set('query', spec.query?.raw ?? '[Query AST]'));
|
|
90
|
+
|
|
91
|
+
const printWebhook = (spec: Trigger.WebhookSpec) =>
|
|
92
|
+
FormBuilder.make({}).pipe(FormBuilder.set('method', spec.method), FormBuilder.set('port', spec.port));
|
|
93
|
+
|
|
94
|
+
const printQueue = (spec: Trigger.QueueSpec) => FormBuilder.make({}).pipe(FormBuilder.set('queue', spec.queue));
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Prompts for input values based on an Effect schema.
|
|
98
|
+
* First shows a multi-select to choose which properties to specify,
|
|
99
|
+
* then prompts for values of the selected properties.
|
|
100
|
+
* Required properties are automatically included and cannot be unselected.
|
|
101
|
+
* @param schema - The Effect schema to prompt for
|
|
102
|
+
* @param defaults - Optional default values to use as initial values and pre-select optional properties
|
|
103
|
+
*/
|
|
104
|
+
export const promptForSchemaInput = Effect.fn(function* (
|
|
105
|
+
schema: Schema.Schema.AnyNoContext | undefined,
|
|
106
|
+
defaults?: Record<string, any> | undefined,
|
|
107
|
+
) {
|
|
108
|
+
if (!schema) {
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const ast = schema.ast;
|
|
113
|
+
|
|
114
|
+
// Check if it's a struct/object type
|
|
115
|
+
if (!SchemaAST.isTypeLiteral(ast)) {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const properties = getProperties(ast);
|
|
120
|
+
if (properties.length === 0) {
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Separate required and optional properties
|
|
125
|
+
const requiredProperties: typeof properties = [];
|
|
126
|
+
const optionalProperties: typeof properties = [];
|
|
127
|
+
|
|
128
|
+
for (const prop of properties) {
|
|
129
|
+
if (prop.isOptional) {
|
|
130
|
+
optionalProperties.push(prop);
|
|
131
|
+
} else {
|
|
132
|
+
requiredProperties.push(prop);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Build property info
|
|
137
|
+
const propertyInfo = properties.map((prop) => {
|
|
138
|
+
const key = prop.name.toString();
|
|
139
|
+
return {
|
|
140
|
+
prop,
|
|
141
|
+
key,
|
|
142
|
+
isRequired: !prop.isOptional,
|
|
143
|
+
};
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Multi-select: show all properties and let user select which optional ones to include
|
|
147
|
+
const selectedKeys = new Set<string>();
|
|
148
|
+
|
|
149
|
+
// Required properties are automatically selected
|
|
150
|
+
for (const info of propertyInfo) {
|
|
151
|
+
if (info.isRequired) {
|
|
152
|
+
selectedKeys.add(info.key);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Show required properties that will be automatically included
|
|
157
|
+
if (requiredProperties.length > 0) {
|
|
158
|
+
const requiredNames = requiredProperties.map((p) => {
|
|
159
|
+
const info = propertyInfo.find((i) => i.prop === p);
|
|
160
|
+
return info?.key ?? p.name.toString();
|
|
161
|
+
});
|
|
162
|
+
yield* Console.log(`Required properties (will be included): ${requiredNames.join(', ')}`);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// For optional properties, use multi-select to choose which ones to include
|
|
166
|
+
if (optionalProperties.length > 0) {
|
|
167
|
+
const optionalInfo = propertyInfo.filter((info) => !info.isRequired);
|
|
168
|
+
const choices = optionalInfo.map((info) => {
|
|
169
|
+
const hasDefault = defaults?.[info.key] !== undefined;
|
|
170
|
+
const defaultText = hasDefault ? ` (current: ${JSON.stringify(defaults[info.key])})` : '';
|
|
171
|
+
return {
|
|
172
|
+
title: `${info.key}${defaultText}`,
|
|
173
|
+
value: info.key,
|
|
174
|
+
description: hasDefault ? 'Has default value' : undefined,
|
|
175
|
+
};
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
const selected = yield* Prompt.multiSelect({
|
|
179
|
+
message: 'Select optional properties to include:',
|
|
180
|
+
choices,
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Add selected optional properties to selectedKeys
|
|
184
|
+
for (const key of selected) {
|
|
185
|
+
selectedKeys.add(String(key));
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// If no properties selected (shouldn't happen if there are required ones), return empty
|
|
190
|
+
if (selectedKeys.size === 0) {
|
|
191
|
+
return {};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Prompt for values of selected properties
|
|
195
|
+
const inputObj: Record<string, any> = {};
|
|
196
|
+
|
|
197
|
+
for (const info of propertyInfo) {
|
|
198
|
+
if (!selectedKeys.has(info.key)) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const key = info.key;
|
|
203
|
+
const propType = info.prop.type;
|
|
204
|
+
const schemaDefault = Option.getOrUndefined(SchemaAST.getDefaultAnnotation(propType));
|
|
205
|
+
const defaultValue = defaults?.[key] ?? schemaDefault;
|
|
206
|
+
|
|
207
|
+
if (SchemaAST.isBooleanKeyword(propType)) {
|
|
208
|
+
const initialValue =
|
|
209
|
+
typeof defaultValue === 'boolean' ? defaultValue : typeof schemaDefault === 'boolean' ? schemaDefault : false;
|
|
210
|
+
const value = yield* Prompt.confirm({
|
|
211
|
+
message: `${info.key}${defaults?.[key] !== undefined ? ` (current: ${defaults[key]})` : ''}:`,
|
|
212
|
+
initial: initialValue,
|
|
213
|
+
});
|
|
214
|
+
inputObj[key] = value;
|
|
215
|
+
} else if (SchemaAST.isNumberKeyword(propType)) {
|
|
216
|
+
const currentValue = typeof defaultValue === 'number' ? String(defaultValue) : '';
|
|
217
|
+
const valueStr = yield* Prompt.text({
|
|
218
|
+
message: `${info.key}${currentValue ? ` (current: ${currentValue}, press Enter to keep)` : ''}:`,
|
|
219
|
+
}).pipe(Prompt.run);
|
|
220
|
+
inputObj[key] = valueStr === '' && defaultValue !== undefined ? defaultValue : parseFloat(valueStr) || 0;
|
|
221
|
+
} else if (SchemaAST.isStringKeyword(propType)) {
|
|
222
|
+
const currentValue = typeof defaultValue === 'string' ? defaultValue : '';
|
|
223
|
+
const valueStr = yield* Prompt.text({
|
|
224
|
+
message: `${info.key}${currentValue ? ` (current: ${currentValue}, press Enter to keep)` : ''}:`,
|
|
225
|
+
}).pipe(Prompt.run);
|
|
226
|
+
inputObj[key] = valueStr === '' && defaultValue !== undefined ? defaultValue : valueStr;
|
|
227
|
+
} else if (Ref.isRefType(propType)) {
|
|
228
|
+
const isDefaultTemplate =
|
|
229
|
+
typeof defaultValue === 'string' && defaultValue.startsWith('{{') && defaultValue.endsWith('}}');
|
|
230
|
+
const useTemplate = yield* Prompt.confirm({
|
|
231
|
+
message: `Use a template to specify ${info.key}?${isDefaultTemplate ? ' (current: template)' : ''}`,
|
|
232
|
+
initial: isDefaultTemplate,
|
|
233
|
+
});
|
|
234
|
+
if (useTemplate) {
|
|
235
|
+
const currentValue = typeof defaultValue === 'string' ? defaultValue : '';
|
|
236
|
+
const templateStr = yield* Prompt.text({
|
|
237
|
+
message: `${info.key} template${currentValue ? ` (current: ${currentValue}, press Enter to keep)` : ''}:`,
|
|
238
|
+
}).pipe(Prompt.run);
|
|
239
|
+
inputObj[key] = templateStr === '' && defaultValue !== undefined ? defaultValue : templateStr;
|
|
240
|
+
} else {
|
|
241
|
+
const annotation = Annotation.ReferenceAnnotation.getFromAst(propType).pipe(Option.getOrThrow);
|
|
242
|
+
const objects = yield* Database.Service.runQuery(Filter.typename(annotation.typename));
|
|
243
|
+
if (objects.length === 0) {
|
|
244
|
+
inputObj[key] = undefined;
|
|
245
|
+
} else {
|
|
246
|
+
const selected = yield* Prompt.select({
|
|
247
|
+
message: `Select ${info.key}:`,
|
|
248
|
+
choices: objects.map((obj: Entity.Any) => ({
|
|
249
|
+
title: Entity.getLabel(obj) ?? obj.id,
|
|
250
|
+
value: Ref.make(obj),
|
|
251
|
+
description: Entity.getDescription(obj),
|
|
252
|
+
})),
|
|
253
|
+
});
|
|
254
|
+
inputObj[key] = selected;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
// For other types, prompt as string and let validation handle it
|
|
259
|
+
const currentValue = defaultValue !== undefined ? String(defaultValue) : '';
|
|
260
|
+
const valueStr = yield* Prompt.text({
|
|
261
|
+
message: `${info.key}${currentValue ? ` (current: ${currentValue}, press Enter to keep)` : ''}:`,
|
|
262
|
+
}).pipe(Prompt.run);
|
|
263
|
+
inputObj[key] = valueStr === '' && defaultValue !== undefined ? defaultValue : valueStr;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return inputObj;
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Selects a function interactively from available functions in the database.
|
|
272
|
+
* Queries the database for functions and prompts the user to select one.
|
|
273
|
+
*/
|
|
274
|
+
export const selectFunction = Effect.fn(function* () {
|
|
275
|
+
const functions = yield* Database.Service.runQuery(Filter.type(Function.Function));
|
|
276
|
+
|
|
277
|
+
if (functions.length === 0) {
|
|
278
|
+
return yield* Effect.fail(new Error('No functions available'));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
const selected = yield* Prompt.select({
|
|
282
|
+
message: 'Select a function:',
|
|
283
|
+
choices: functions.map((fn: Function.Function) => ({
|
|
284
|
+
title: fn.name ?? fn.id,
|
|
285
|
+
value: fn.id,
|
|
286
|
+
description: fn.description,
|
|
287
|
+
})),
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
return String(selected);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Selects a trigger interactively from available triggers.
|
|
295
|
+
* If kind is provided, filters triggers by that kind.
|
|
296
|
+
* Queries the database for triggers and prompts the user to select one.
|
|
297
|
+
*/
|
|
298
|
+
export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
|
|
299
|
+
const triggers = yield* Database.Service.runQuery(Filter.type(Trigger.Trigger));
|
|
300
|
+
const filteredTriggers = kind ? triggers.filter((trigger) => trigger.spec?.kind === kind) : triggers;
|
|
301
|
+
|
|
302
|
+
if (filteredTriggers.length === 0) {
|
|
303
|
+
return yield* Effect.fail(new Error(kind ? `No ${kind} triggers available` : 'No triggers available'));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const choices = yield* Effect.all(
|
|
307
|
+
filteredTriggers.map((trigger) =>
|
|
308
|
+
Effect.gen(function* () {
|
|
309
|
+
const fn = trigger.function ? yield* Database.Service.load(trigger.function) : undefined;
|
|
310
|
+
const functionName = fn && Obj.instanceOf(Function.Function, fn) ? (fn.name ?? fn.key ?? fn.id) : undefined;
|
|
311
|
+
const title = functionName ?? trigger.id;
|
|
312
|
+
const description = `${trigger.enabled ? 'enabled' : 'disabled'} - ${trigger.spec?.kind ?? 'unknown'}`;
|
|
313
|
+
|
|
314
|
+
return {
|
|
315
|
+
title,
|
|
316
|
+
value: trigger.id,
|
|
317
|
+
description,
|
|
318
|
+
};
|
|
319
|
+
}),
|
|
320
|
+
),
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
const selected = yield* Prompt.select({
|
|
324
|
+
message: kind ? `Select a ${kind} trigger:` : 'Select a trigger:',
|
|
325
|
+
choices,
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
return String(selected);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Selects a queue interactively from available queues in the database.
|
|
333
|
+
* Queries schemas with QueueAnnotation, then queries objects of those types,
|
|
334
|
+
* and extracts queue DXNs from the objects' queue properties.
|
|
335
|
+
*/
|
|
336
|
+
export const selectQueue = Effect.fn(function* () {
|
|
337
|
+
// Query schema registry for schemas with QueueAnnotation
|
|
338
|
+
const schemas = yield* Database.Service.runSchemaQuery({ location: ['database', 'runtime'] });
|
|
339
|
+
|
|
340
|
+
// Filter schemas that have QueueAnnotation
|
|
341
|
+
const queueSchemas = schemas.filter((schema) => {
|
|
342
|
+
const annotation = QueueAnnotation.get(schema);
|
|
343
|
+
return Option.isSome(annotation) && annotation.value === true;
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
if (queueSchemas.length === 0) {
|
|
347
|
+
return yield* Effect.fail(new Error('No schemas with Queue annotation found'));
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// Collect all objects with queues
|
|
351
|
+
const queueChoices: Array<{ title: string; value: string; description?: string }> = [];
|
|
352
|
+
|
|
353
|
+
// Process each schema, skipping ones that fail
|
|
354
|
+
for (const schema of queueSchemas) {
|
|
355
|
+
yield* Effect.gen(function* () {
|
|
356
|
+
const typename = Type.getTypename(schema);
|
|
357
|
+
const objects = yield* Database.Service.runQuery(Filter.type(typename));
|
|
358
|
+
|
|
359
|
+
for (const obj of objects) {
|
|
360
|
+
// Access the queue property (which is a Ref<Queue>)
|
|
361
|
+
const queueRef = (obj as any).queue as Ref.Ref<any> | undefined;
|
|
362
|
+
if (!queueRef) {
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const queueDxn = queueRef.dxn.toString();
|
|
367
|
+
const label = Obj.getLabel(obj) ?? obj.id;
|
|
368
|
+
const description = Obj.getTypename(obj);
|
|
369
|
+
|
|
370
|
+
queueChoices.push({
|
|
371
|
+
title: label,
|
|
372
|
+
value: queueDxn,
|
|
373
|
+
description,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}).pipe(Effect.catchAll(() => Effect.void));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (queueChoices.length === 0) {
|
|
380
|
+
return yield* Effect.fail(new Error('No objects with queue properties found'));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const selected = yield* Prompt.select({
|
|
384
|
+
message: 'Select a queue:',
|
|
385
|
+
choices: queueChoices,
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
return String(selected);
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Pretty prints trigger removal result with ANSI colors.
|
|
393
|
+
*/
|
|
394
|
+
export const printTriggerRemoved = (id: string) =>
|
|
395
|
+
FormBuilder.make({ title: 'Trigger removed' }).pipe(FormBuilder.set('id', id), FormBuilder.build);
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Common, Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { ClientEvents } from '@dxos/plugin-client/types';
|
|
7
|
+
|
|
8
|
+
// NOTE: Must not import from index to avoid pulling in react dependencies.
|
|
9
|
+
import { ComputeRuntime } from '../capabilities/compute-runtime';
|
|
10
|
+
import { meta } from '../meta';
|
|
11
|
+
import { AutomationEvents } from '../types';
|
|
12
|
+
|
|
13
|
+
import { trigger } from './commands';
|
|
14
|
+
|
|
15
|
+
export const AutomationPlugin = Plugin.define(meta).pipe(
|
|
16
|
+
Common.Plugin.addCommandModule({ commands: [trigger] }),
|
|
17
|
+
Plugin.addModule({
|
|
18
|
+
activatesOn: ClientEvents.ClientReady,
|
|
19
|
+
activatesAfter: [AutomationEvents.ComputeRuntimeReady],
|
|
20
|
+
activate: ComputeRuntime,
|
|
21
|
+
}),
|
|
22
|
+
Plugin.make,
|
|
23
|
+
);
|
|
@@ -10,24 +10,25 @@ import React, { useMemo, useState } from 'react';
|
|
|
10
10
|
|
|
11
11
|
import { Filter, Obj, Tag } from '@dxos/echo';
|
|
12
12
|
import { Function, Script, Trigger } from '@dxos/functions';
|
|
13
|
+
import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
|
|
13
14
|
import { useTypeOptions } from '@dxos/plugin-space';
|
|
14
15
|
import { type Client, useClient } from '@dxos/react-client';
|
|
15
|
-
import { type Space,
|
|
16
|
+
import { type Space, useQuery } from '@dxos/react-client/echo';
|
|
16
17
|
import { Clipboard, IconButton, Input, Separator, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
17
18
|
import { ControlItem, controlItemClasses } from '@dxos/react-ui-form';
|
|
18
19
|
import { List } from '@dxos/react-ui-list';
|
|
19
|
-
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
20
20
|
import { Project } from '@dxos/types';
|
|
21
|
+
import { ghostHover, mx } from '@dxos/ui-theme';
|
|
21
22
|
import { isNonNullable } from '@dxos/util';
|
|
22
23
|
|
|
23
24
|
import { meta } from '../../meta';
|
|
24
25
|
import { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';
|
|
25
26
|
|
|
26
|
-
const grid = 'grid grid-cols-[
|
|
27
|
+
const grid = 'grid grid-cols-[40px_1fr_32px_32px] min-bs-[2.5rem]';
|
|
27
28
|
|
|
28
29
|
export type AutomationPanelProps = ThemedClassName<{
|
|
29
30
|
space: Space;
|
|
30
|
-
object?: Obj.
|
|
31
|
+
object?: Obj.Unknown;
|
|
31
32
|
initialTrigger?: Trigger.Trigger;
|
|
32
33
|
onDone?: () => void;
|
|
33
34
|
}>;
|
|
@@ -36,12 +37,13 @@ export type AutomationPanelProps = ThemedClassName<{
|
|
|
36
37
|
export const AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }: AutomationPanelProps) => {
|
|
37
38
|
const { t } = useTranslation(meta.id);
|
|
38
39
|
const client = useClient();
|
|
39
|
-
const
|
|
40
|
-
const
|
|
40
|
+
const functionsServiceClient = useMemo(() => FunctionsServiceClient.fromClient(client), [client]);
|
|
41
|
+
const functions = useQuery(space.db, Filter.type(Function.Function));
|
|
42
|
+
const triggers = useQuery(space.db, Filter.type(Trigger.Trigger));
|
|
41
43
|
const filteredTriggers = useMemo(() => {
|
|
42
44
|
return object ? triggers.filter(triggerMatch(object)) : triggers;
|
|
43
45
|
}, [object, triggers]);
|
|
44
|
-
const tags = useQuery(space, Filter.type(Tag.Tag));
|
|
46
|
+
const tags = useQuery(space.db, Filter.type(Tag.Tag));
|
|
45
47
|
const types = useTypeOptions({
|
|
46
48
|
space,
|
|
47
49
|
annotation: {
|
|
@@ -87,11 +89,15 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
87
89
|
onDone?.();
|
|
88
90
|
};
|
|
89
91
|
|
|
92
|
+
const handleForceRunTrigger = async (trigger: Trigger.Trigger) => {
|
|
93
|
+
await functionsServiceClient.forceRunCronTrigger(space.id, trigger.id);
|
|
94
|
+
};
|
|
95
|
+
|
|
90
96
|
if (trigger) {
|
|
91
97
|
return (
|
|
92
98
|
<ControlItem title={t('trigger editor title')}>
|
|
93
99
|
<TriggerEditor
|
|
94
|
-
|
|
100
|
+
db={space.db}
|
|
95
101
|
trigger={trigger}
|
|
96
102
|
readonlySpec={Boolean(object)}
|
|
97
103
|
tags={tags}
|
|
@@ -124,7 +130,11 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
124
130
|
<Input.Root>
|
|
125
131
|
<Input.Switch
|
|
126
132
|
checked={trigger.enabled}
|
|
127
|
-
onCheckedChange={(checked) =>
|
|
133
|
+
onCheckedChange={(checked) =>
|
|
134
|
+
Obj.change(trigger, (t) => {
|
|
135
|
+
t.enabled = checked;
|
|
136
|
+
})
|
|
137
|
+
}
|
|
128
138
|
/>
|
|
129
139
|
</Input.Root>
|
|
130
140
|
|
|
@@ -145,6 +155,14 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
145
155
|
)}
|
|
146
156
|
</div>
|
|
147
157
|
|
|
158
|
+
<List.ItemButton
|
|
159
|
+
autoHide={false}
|
|
160
|
+
disabled={!trigger.enabled || trigger.spec?.kind !== 'timer'}
|
|
161
|
+
icon='ph--play--regular'
|
|
162
|
+
label='Force run'
|
|
163
|
+
onClick={() => handleForceRunTrigger(trigger)}
|
|
164
|
+
/>
|
|
165
|
+
|
|
148
166
|
<List.ItemDeleteButton onClick={() => handleDelete(trigger)} />
|
|
149
167
|
</List.Item>
|
|
150
168
|
);
|
|
@@ -161,7 +179,10 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
161
179
|
|
|
162
180
|
const getCopyAction = (client: Client, trigger: Trigger.Trigger | undefined) => {
|
|
163
181
|
if (trigger?.spec?.kind === 'email') {
|
|
164
|
-
return {
|
|
182
|
+
return {
|
|
183
|
+
translationKey: 'trigger copy email',
|
|
184
|
+
contentProvider: () => `${Obj.getDatabase(trigger)!.spaceId}@dxos.network`,
|
|
185
|
+
};
|
|
165
186
|
}
|
|
166
187
|
|
|
167
188
|
if (trigger?.spec?.kind === 'webhook') {
|
|
@@ -172,7 +193,7 @@ const getCopyAction = (client: Client, trigger: Trigger.Trigger | undefined) =>
|
|
|
172
193
|
};
|
|
173
194
|
|
|
174
195
|
const getWebhookUrl = (client: Client, trigger: Trigger.Trigger) => {
|
|
175
|
-
const spaceId =
|
|
196
|
+
const spaceId = Obj.getDatabase(trigger)!.spaceId;
|
|
176
197
|
const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);
|
|
177
198
|
const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');
|
|
178
199
|
edgeUrl.protocol = isSecure ? 'https' : 'http';
|
|
@@ -216,7 +237,7 @@ const projectMatch = (project: Project.Project) => {
|
|
|
216
237
|
};
|
|
217
238
|
};
|
|
218
239
|
|
|
219
|
-
const triggerMatch = Match.type<Obj.
|
|
240
|
+
const triggerMatch = Match.type<Obj.Unknown>().pipe(
|
|
220
241
|
Match.withReturnType<(trigger: Trigger.Trigger) => boolean>(),
|
|
221
242
|
Match.when(
|
|
222
243
|
(obj) => Obj.instanceOf(Script.Script, obj),
|
|
@@ -21,7 +21,7 @@ export const AutomationSettings = (props: AutomationPanelProps) => {
|
|
|
21
21
|
description={t('automation description', { ns: meta.id })}
|
|
22
22
|
>
|
|
23
23
|
<AutomationPanel {...props} />
|
|
24
|
-
<TriggersSettings
|
|
24
|
+
<TriggersSettings db={props.space.db} />
|
|
25
25
|
</ControlSection>
|
|
26
26
|
</ControlPage>
|
|
27
27
|
);
|
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { Common } from '@dxos/app-framework';
|
|
9
|
+
import { useOperationInvoker } from '@dxos/app-framework/react';
|
|
10
10
|
import { Obj } from '@dxos/echo';
|
|
11
11
|
import { Function, Script } from '@dxos/functions';
|
|
12
|
-
import {
|
|
12
|
+
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
13
13
|
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
14
14
|
import { Button, IconButton, useTranslation } from '@dxos/react-ui';
|
|
15
15
|
import { controlItemClasses } from '@dxos/react-ui-form';
|
|
16
16
|
import { List } from '@dxos/react-ui-list';
|
|
17
|
-
import { ghostHover, mx } from '@dxos/
|
|
17
|
+
import { ghostHover, mx } from '@dxos/ui-theme';
|
|
18
18
|
|
|
19
19
|
import { meta } from '../../meta';
|
|
20
20
|
|
|
@@ -26,9 +26,9 @@ export type FunctionsPanelProps = {
|
|
|
26
26
|
|
|
27
27
|
export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
28
28
|
const { t } = useTranslation(meta.id);
|
|
29
|
-
const functions = useQuery(space, Filter.type(Function.Function));
|
|
30
|
-
const scripts = useQuery(space, Filter.type(Script.Script));
|
|
31
|
-
const {
|
|
29
|
+
const functions = useQuery(space.db, Filter.type(Function.Function));
|
|
30
|
+
const scripts = useQuery(space.db, Filter.type(Script.Script));
|
|
31
|
+
const { invokePromise } = useOperationInvoker();
|
|
32
32
|
|
|
33
33
|
const functionToScriptMap = useMemo(
|
|
34
34
|
() =>
|
|
@@ -60,20 +60,15 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
60
60
|
(func: Function.Function) => {
|
|
61
61
|
const script = functionToScriptMap[func.id];
|
|
62
62
|
if (script) {
|
|
63
|
-
void
|
|
64
|
-
createIntent(LayoutAction.Open, {
|
|
65
|
-
part: 'main',
|
|
66
|
-
subject: [Obj.getDXN(script).toString()],
|
|
67
|
-
}),
|
|
68
|
-
);
|
|
63
|
+
void invokePromise(Common.LayoutOperation.Open, { subject: [Obj.getDXN(script).toString()] });
|
|
69
64
|
}
|
|
70
65
|
},
|
|
71
|
-
[functionToScriptMap,
|
|
66
|
+
[functionToScriptMap, invokePromise],
|
|
72
67
|
);
|
|
73
68
|
|
|
74
69
|
const handleDelete = useCallback(
|
|
75
|
-
(func: Function.Function) =>
|
|
76
|
-
[
|
|
70
|
+
(func: Function.Function) => invokePromise(SpaceOperation.RemoveObjects, { objects: [func] }),
|
|
71
|
+
[invokePromise],
|
|
77
72
|
);
|
|
78
73
|
|
|
79
74
|
return (
|