@dxos/plugin-automation 0.8.4-main.ae835ea → 0.8.4-main.bc674ce
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-HFCK3JRB.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-XXZNGORC.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-RAF2FJST.mjs +86 -0
- 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 +5 -3
- package/dist/lib/browser/index.mjs +53 -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-WPMY3EX2.mjs → react-surface-EV3AC62F.mjs} +13 -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-NVEIUIZP.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-74ELGR7P.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-U5Q2NI7H.mjs → chunk-7QRUPEHH.mjs} +5 -5
- package/dist/lib/node-esm/chunk-HQLVREIX.mjs +87 -0
- 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 +5 -3
- package/dist/lib/node-esm/index.mjs +53 -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-Y2BBJV2I.mjs → react-surface-S6VZJCEZ.mjs} +13 -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 +3 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/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 +2 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -0
- 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 +72 -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 +8 -4
- 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/testing/test-functions.d.ts +202 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -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 -47
- 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/compute-runtime.ts +133 -0
- 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.stories.tsx +1 -1
- package/src/components/AutomationPanel/AutomationPanel.tsx +51 -22
- package/src/components/AutomationSettings.tsx +1 -1
- package/src/components/FunctionsContainer.tsx +7 -0
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +14 -12
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +111 -0
- package/src/components/FunctionsRegistry/index.ts +5 -0
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +23 -31
- package/src/components/TriggerEditor/SpecSelector.tsx +8 -6
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +33 -29
- package/src/components/TriggerEditor/TriggerEditor.tsx +56 -43
- package/src/components/TriggerSettings.tsx +3 -3
- package/src/hooks/useComputeRuntimeCallback.ts +43 -8
- package/src/hooks/useTriggerRuntimeControls.ts +9 -8
- package/src/index.ts +1 -2
- package/src/meta.ts +2 -2
- package/src/testing/test-functions.ts +2 -2
- package/src/translations.ts +4 -0
- package/src/{capabilities → types}/capabilities.ts +8 -14
- 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-LBXJDM6Z.mjs +0 -11
- package/dist/lib/browser/AutomationSettings-IIEI5D2K.mjs +0 -68
- package/dist/lib/browser/AutomationSettings-IIEI5D2K.mjs.map +0 -7
- package/dist/lib/browser/FunctionsContainer-IZTCGNJZ.mjs +0 -36
- package/dist/lib/browser/FunctionsContainer-IZTCGNJZ.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-7VKA2GS3.mjs +0 -81
- package/dist/lib/browser/app-graph-builder-7VKA2GS3.mjs.map +0 -7
- package/dist/lib/browser/chunk-CVYJM6OO.mjs +0 -66
- package/dist/lib/browser/chunk-CVYJM6OO.mjs.map +0 -7
- package/dist/lib/browser/chunk-FHSN7G4H.mjs +0 -107
- package/dist/lib/browser/chunk-FHSN7G4H.mjs.map +0 -7
- package/dist/lib/browser/chunk-GCGHLQM2.mjs +0 -15
- package/dist/lib/browser/chunk-GCGHLQM2.mjs.map +0 -7
- package/dist/lib/browser/chunk-JW7XSPYW.mjs +0 -267
- package/dist/lib/browser/chunk-JW7XSPYW.mjs.map +0 -7
- package/dist/lib/browser/chunk-K5YNWESC.mjs +0 -183
- package/dist/lib/browser/chunk-K5YNWESC.mjs.map +0 -7
- package/dist/lib/browser/chunk-LZQFZO3B.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-PFYRMGN2.mjs +0 -114
- package/dist/lib/browser/compute-runtime-PFYRMGN2.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-WPMY3EX2.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationSettings-VIIEPI2P.mjs +0 -69
- package/dist/lib/node-esm/AutomationSettings-VIIEPI2P.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-KKRCIXGB.mjs +0 -37
- package/dist/lib/node-esm/FunctionsContainer-KKRCIXGB.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-RTOFJNFV.mjs +0 -82
- package/dist/lib/node-esm/app-graph-builder-RTOFJNFV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3BJ6BR3E.mjs +0 -67
- package/dist/lib/node-esm/chunk-3BJ6BR3E.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CEVIVRTY.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-JOCKHLFT.mjs +0 -108
- package/dist/lib/node-esm/chunk-JOCKHLFT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MRYKW5TM.mjs +0 -16
- package/dist/lib/node-esm/chunk-MRYKW5TM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-W76WUTZY.mjs +0 -268
- package/dist/lib/node-esm/chunk-W76WUTZY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-Y7PJXFCJ.mjs +0 -184
- package/dist/lib/node-esm/chunk-Y7PJXFCJ.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-IXCSD3W7.mjs +0 -115
- package/dist/lib/node-esm/compute-runtime-IXCSD3W7.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-Y2BBJV2I.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 -19
- 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/compute-runtime.ts +0 -138
- package/src/capabilities/intent-resolver.ts +0 -72
- package/src/capabilities/react-surface.tsx +0 -55
- package/src/events.ts +0 -11
- /package/dist/lib/browser/{AutomationPanel-LBXJDM6Z.mjs.map → AutomationPanel-FAS6ADCW.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-HFCK3JRB.mjs.map → FunctionsPanel-ZX4J75UM.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-XXZNGORC.mjs.map → chunk-54PANILA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-NVEIUIZP.mjs.map → AutomationPanel-B7NAGDFA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-74ELGR7P.mjs.map → FunctionsPanel-SS6GIVNU.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-U5Q2NI7H.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,23 +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 {
|
|
20
|
-
import {
|
|
20
|
+
import { Project } from '@dxos/types';
|
|
21
|
+
import { ghostHover, mx } from '@dxos/ui-theme';
|
|
22
|
+
import { isNonNullable } from '@dxos/util';
|
|
21
23
|
|
|
22
24
|
import { meta } from '../../meta';
|
|
23
25
|
import { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';
|
|
24
26
|
|
|
25
|
-
const grid = 'grid grid-cols-[
|
|
27
|
+
const grid = 'grid grid-cols-[40px_1fr_32px_32px] min-bs-[2.5rem]';
|
|
26
28
|
|
|
27
29
|
export type AutomationPanelProps = ThemedClassName<{
|
|
28
30
|
space: Space;
|
|
29
|
-
object?: Obj.
|
|
31
|
+
object?: Obj.Unknown;
|
|
30
32
|
initialTrigger?: Trigger.Trigger;
|
|
31
33
|
onDone?: () => void;
|
|
32
34
|
}>;
|
|
@@ -35,13 +37,21 @@ export type AutomationPanelProps = ThemedClassName<{
|
|
|
35
37
|
export const AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }: AutomationPanelProps) => {
|
|
36
38
|
const { t } = useTranslation(meta.id);
|
|
37
39
|
const client = useClient();
|
|
38
|
-
const
|
|
39
|
-
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));
|
|
40
43
|
const filteredTriggers = useMemo(() => {
|
|
41
44
|
return object ? triggers.filter(triggerMatch(object)) : triggers;
|
|
42
45
|
}, [object, triggers]);
|
|
43
|
-
const tags = useQuery(space, Filter.type(Tag.Tag));
|
|
44
|
-
const types = useTypeOptions({
|
|
46
|
+
const tags = useQuery(space.db, Filter.type(Tag.Tag));
|
|
47
|
+
const types = useTypeOptions({
|
|
48
|
+
space,
|
|
49
|
+
annotation: {
|
|
50
|
+
location: ['database', 'runtime'],
|
|
51
|
+
kind: ['user'],
|
|
52
|
+
registered: ['registered'],
|
|
53
|
+
},
|
|
54
|
+
});
|
|
45
55
|
|
|
46
56
|
const [trigger, setTrigger] = useState<Trigger.Trigger | undefined>(initialTrigger);
|
|
47
57
|
const [selected, setSelected] = useState<Trigger.Trigger>();
|
|
@@ -79,11 +89,15 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
79
89
|
onDone?.();
|
|
80
90
|
};
|
|
81
91
|
|
|
92
|
+
const handleForceRunTrigger = async (trigger: Trigger.Trigger) => {
|
|
93
|
+
await functionsServiceClient.forceRunCronTrigger(space.id, trigger.id);
|
|
94
|
+
};
|
|
95
|
+
|
|
82
96
|
if (trigger) {
|
|
83
97
|
return (
|
|
84
98
|
<ControlItem title={t('trigger editor title')}>
|
|
85
99
|
<TriggerEditor
|
|
86
|
-
|
|
100
|
+
db={space.db}
|
|
87
101
|
trigger={trigger}
|
|
88
102
|
readonlySpec={Boolean(object)}
|
|
89
103
|
tags={tags}
|
|
@@ -104,25 +118,29 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
104
118
|
getId={(field) => field.id}
|
|
105
119
|
>
|
|
106
120
|
{({ items: filteredTriggers }) => (
|
|
107
|
-
<div role='list' className='flex flex-col
|
|
121
|
+
<div role='list' className='flex flex-col is-full'>
|
|
108
122
|
{filteredTriggers?.map((trigger) => {
|
|
109
123
|
const copyAction = getCopyAction(client, trigger);
|
|
110
124
|
return (
|
|
111
125
|
<List.Item<Trigger.Trigger>
|
|
112
126
|
key={trigger.id}
|
|
113
127
|
item={trigger}
|
|
114
|
-
classNames={mx(grid, ghostHover, 'items-center', '
|
|
128
|
+
classNames={mx(grid, ghostHover, 'items-center', 'pli-2')}
|
|
115
129
|
>
|
|
116
130
|
<Input.Root>
|
|
117
131
|
<Input.Switch
|
|
118
132
|
checked={trigger.enabled}
|
|
119
|
-
onCheckedChange={(checked) =>
|
|
133
|
+
onCheckedChange={(checked) =>
|
|
134
|
+
Obj.change(trigger, (t) => {
|
|
135
|
+
t.enabled = checked;
|
|
136
|
+
})
|
|
137
|
+
}
|
|
120
138
|
/>
|
|
121
139
|
</Input.Root>
|
|
122
140
|
|
|
123
141
|
<div className={'flex'}>
|
|
124
142
|
<List.ItemTitle
|
|
125
|
-
classNames='
|
|
143
|
+
classNames='pli-1 cursor-pointer is-0 shrink truncate'
|
|
126
144
|
onClick={() => handleSelect(trigger)}
|
|
127
145
|
>
|
|
128
146
|
{getFunctionName(functions, trigger) ?? '∅'}
|
|
@@ -137,6 +155,14 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
137
155
|
)}
|
|
138
156
|
</div>
|
|
139
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
|
+
|
|
140
166
|
<List.ItemDeleteButton onClick={() => handleDelete(trigger)} />
|
|
141
167
|
</List.Item>
|
|
142
168
|
);
|
|
@@ -153,7 +179,10 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
153
179
|
|
|
154
180
|
const getCopyAction = (client: Client, trigger: Trigger.Trigger | undefined) => {
|
|
155
181
|
if (trigger?.spec?.kind === 'email') {
|
|
156
|
-
return {
|
|
182
|
+
return {
|
|
183
|
+
translationKey: 'trigger copy email',
|
|
184
|
+
contentProvider: () => `${Obj.getDatabase(trigger)!.spaceId}@dxos.network`,
|
|
185
|
+
};
|
|
157
186
|
}
|
|
158
187
|
|
|
159
188
|
if (trigger?.spec?.kind === 'webhook') {
|
|
@@ -164,7 +193,7 @@ const getCopyAction = (client: Client, trigger: Trigger.Trigger | undefined) =>
|
|
|
164
193
|
};
|
|
165
194
|
|
|
166
195
|
const getWebhookUrl = (client: Client, trigger: Trigger.Trigger) => {
|
|
167
|
-
const spaceId =
|
|
196
|
+
const spaceId = Obj.getDatabase(trigger)!.spaceId;
|
|
168
197
|
const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);
|
|
169
198
|
const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');
|
|
170
199
|
edgeUrl.protocol = isSecure ? 'https' : 'http';
|
|
@@ -188,11 +217,11 @@ const scriptMatch = (script: Script.Script) => (trigger: Trigger.Trigger) => {
|
|
|
188
217
|
return fn.source?.target === script;
|
|
189
218
|
};
|
|
190
219
|
|
|
191
|
-
const projectMatch = (project:
|
|
220
|
+
const projectMatch = (project: Project.Project) => {
|
|
192
221
|
const viewQueries = EFn.pipe(
|
|
193
|
-
project.
|
|
194
|
-
Array.map((
|
|
195
|
-
Array.filter(
|
|
222
|
+
project.columns,
|
|
223
|
+
Array.map((column) => column.view.target),
|
|
224
|
+
Array.filter(isNonNullable),
|
|
196
225
|
Array.map((view) => Obj.getSnapshot(view).query.ast),
|
|
197
226
|
Array.map((ast) => JSON.stringify(ast)),
|
|
198
227
|
);
|
|
@@ -208,14 +237,14 @@ const projectMatch = (project: DataType.Project) => {
|
|
|
208
237
|
};
|
|
209
238
|
};
|
|
210
239
|
|
|
211
|
-
const triggerMatch = Match.type<Obj.
|
|
240
|
+
const triggerMatch = Match.type<Obj.Unknown>().pipe(
|
|
212
241
|
Match.withReturnType<(trigger: Trigger.Trigger) => boolean>(),
|
|
213
242
|
Match.when(
|
|
214
243
|
(obj) => Obj.instanceOf(Script.Script, obj),
|
|
215
244
|
(obj) => scriptMatch(obj),
|
|
216
245
|
),
|
|
217
246
|
Match.when(
|
|
218
|
-
(obj) => Obj.instanceOf(
|
|
247
|
+
(obj) => Obj.instanceOf(Project.Project, obj),
|
|
219
248
|
(obj) => projectMatch(obj),
|
|
220
249
|
),
|
|
221
250
|
Match.orElse((_obj) => () => true),
|
|
@@ -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
|
);
|
|
@@ -11,6 +11,7 @@ import { ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
|
11
11
|
import { meta } from '../meta';
|
|
12
12
|
|
|
13
13
|
import { FunctionsPanel } from './FunctionsPanel';
|
|
14
|
+
import { FunctionsRegistry } from './FunctionsRegistry';
|
|
14
15
|
|
|
15
16
|
export const FunctionsContainer = ({ space }: { space: Space }) => {
|
|
16
17
|
const { t } = useTranslation(meta.id);
|
|
@@ -22,6 +23,12 @@ export const FunctionsContainer = ({ space }: { space: Space }) => {
|
|
|
22
23
|
>
|
|
23
24
|
<FunctionsPanel space={space} />
|
|
24
25
|
</ControlSection>
|
|
26
|
+
<ControlSection
|
|
27
|
+
title={t('functions registry verbose label', { ns: meta.id })}
|
|
28
|
+
description={t('functions registry description', { ns: meta.id })}
|
|
29
|
+
>
|
|
30
|
+
<FunctionsRegistry space={space} />
|
|
31
|
+
</ControlSection>
|
|
25
32
|
</ControlPage>
|
|
26
33
|
);
|
|
27
34
|
};
|