@dxos/plugin-automation 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29
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/neutral/AutomationPanel-64U7W3SJ.mjs +11 -0
- package/dist/lib/neutral/AutomationPlugin.mjs +38 -0
- package/dist/lib/neutral/AutomationPlugin.mjs.map +7 -0
- package/dist/lib/neutral/AutomationPlugin.node.mjs +1113 -0
- package/dist/lib/neutral/AutomationPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/AutomationSettings-NNL2AVNT.mjs +31 -0
- package/dist/lib/neutral/AutomationSettings-NNL2AVNT.mjs.map +7 -0
- package/dist/lib/neutral/FunctionsContainer-CU2FVKZF.mjs +38 -0
- package/dist/lib/neutral/FunctionsContainer-CU2FVKZF.mjs.map +7 -0
- package/dist/lib/neutral/FunctionsPanel-GLCUBEDT.mjs +96 -0
- package/dist/lib/neutral/FunctionsPanel-GLCUBEDT.mjs.map +7 -0
- package/dist/lib/neutral/FunctionsRegistry-VRU4FBVH.mjs +94 -0
- package/dist/lib/neutral/FunctionsRegistry-VRU4FBVH.mjs.map +7 -0
- package/dist/lib/neutral/TriggerSettings-XCHIZPOR.mjs +9 -0
- package/dist/lib/neutral/app-graph-builder-GDCGRYEP.mjs +75 -0
- package/dist/lib/neutral/app-graph-builder-GDCGRYEP.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +15 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/node.mjs +13 -0
- package/dist/lib/neutral/capabilities/node.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2JP77CMN.mjs +42 -0
- package/dist/lib/neutral/chunk-2JP77CMN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ATECY555.mjs +20 -0
- package/dist/lib/neutral/chunk-ATECY555.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DSCOLDT5.mjs +93 -0
- package/dist/lib/neutral/chunk-DSCOLDT5.mjs.map +7 -0
- package/dist/lib/neutral/chunk-FKFFU54G.mjs +270 -0
- package/dist/lib/neutral/chunk-FKFFU54G.mjs.map +7 -0
- package/dist/lib/neutral/chunk-GDNOJOAR.mjs +8 -0
- package/dist/lib/neutral/chunk-GDNOJOAR.mjs.map +7 -0
- package/dist/lib/neutral/chunk-IGGNE2XI.mjs +12 -0
- package/dist/lib/neutral/chunk-IGGNE2XI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-N735CP33.mjs +285 -0
- package/dist/lib/neutral/chunk-N735CP33.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +16 -0
- package/dist/lib/neutral/compute-runtime-2Q5MGOR6.mjs +220 -0
- package/dist/lib/neutral/compute-runtime-2Q5MGOR6.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +13 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/create-trigger-from-template-5FT7O7OU.mjs +69 -0
- package/dist/lib/neutral/create-trigger-from-template-5FT7O7OU.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +129 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +20 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs +13 -0
- package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-3OGMAMKV.mjs +57 -0
- package/dist/lib/neutral/react-surface-3OGMAMKV.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +47 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +16 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts +3 -1
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/AutomationPlugin.node.d.ts +4 -0
- package/dist/types/src/AutomationPlugin.node.d.ts.map +1 -0
- package/dist/types/src/AutomationPlugin.test.d.ts +2 -0
- package/dist/types/src/AutomationPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts +14 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +6 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/commands/index.d.ts +2 -0
- package/dist/types/src/commands/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/index.d.ts +25 -0
- package/dist/types/src/commands/trigger/create/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/queue.d.ts +13 -0
- package/dist/types/src/commands/trigger/create/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/subscription.d.ts +15 -0
- package/dist/types/src/commands/trigger/create/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/create/timer.d.ts +13 -0
- package/dist/types/src/commands/trigger/create/timer.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/index.d.ts +57 -0
- package/dist/types/src/commands/trigger/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/list.d.ts +7 -0
- package/dist/types/src/commands/trigger/list.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/options.d.ts +11 -0
- package/dist/types/src/commands/trigger/options.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/remove.d.ts +8 -0
- package/dist/types/src/commands/trigger/remove.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/index.d.ts +28 -0
- package/dist/types/src/commands/trigger/update/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts +12 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts +13 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts +11 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/util.d.ts +46 -0
- package/dist/types/src/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +6 -7
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +32 -26
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts +8 -0
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts +4 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +12 -9
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +6 -3
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +11 -8
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +107 -30
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +6 -0
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts +2 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts +4 -0
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts +2 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts +6 -0
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/index.d.ts +3 -0
- package/dist/types/src/containers/TriggerSettings/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +5 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntime.d.ts +8 -0
- package/dist/types/src/hooks/useComputeRuntime.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +9 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts +17 -0
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts.map +1 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +12 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-trigger-from-template.d.ts +5 -0
- package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +204 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +32 -26
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/AutomationCapabilities.d.ts +22 -0
- package/dist/types/src/types/AutomationCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/AutomationEvents.d.ts +3 -0
- package/dist/types/src/types/AutomationEvents.d.ts.map +1 -0
- package/dist/types/src/types/AutomationOperation.d.ts +19 -0
- package/dist/types/src/types/AutomationOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +12 -4
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +138 -50
- package/src/AutomationPlugin.node.ts +29 -0
- package/src/AutomationPlugin.test.ts +27 -0
- package/src/AutomationPlugin.tsx +23 -34
- package/src/capabilities/app-graph-builder.ts +59 -79
- package/src/capabilities/compute-runtime.ts +325 -0
- package/src/capabilities/index.ts +9 -4
- package/src/capabilities/node.ts +13 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +49 -46
- package/src/commands/index.ts +5 -0
- package/src/commands/trigger/create/index.ts +14 -0
- package/src/commands/trigger/create/queue.ts +86 -0
- package/src/commands/trigger/create/subscription.ts +125 -0
- package/src/commands/trigger/create/timer.ts +90 -0
- package/src/commands/trigger/index.ts +16 -0
- package/src/commands/trigger/list.ts +70 -0
- package/src/commands/trigger/options.ts +59 -0
- package/src/commands/trigger/remove.ts +45 -0
- package/src/commands/trigger/update/index.ts +14 -0
- package/src/commands/trigger/update/queue.ts +194 -0
- package/src/commands/trigger/update/subscription.ts +278 -0
- package/src/commands/trigger/update/timer.ts +193 -0
- package/src/commands/trigger/util.ts +410 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +9 -12
- package/src/components/AutomationPanel/AutomationPanel.tsx +250 -82
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +51 -32
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +114 -0
- package/src/components/FunctionsRegistry/index.ts +8 -0
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +42 -35
- package/src/components/TriggerEditor/SpecSelector.tsx +29 -17
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +117 -32
- package/src/components/TriggerEditor/TriggerEditor.tsx +109 -42
- package/src/components/index.ts +1 -2
- package/src/containers/AutomationSettings/AutomationSettings.tsx +31 -0
- package/src/containers/AutomationSettings/index.ts +5 -0
- package/src/containers/FunctionsContainer/FunctionsContainer.tsx +33 -0
- package/src/containers/FunctionsContainer/index.ts +5 -0
- package/src/containers/TriggerSettings/TriggerSettings.tsx +48 -0
- package/src/containers/TriggerSettings/index.ts +6 -0
- package/src/containers/index.ts +9 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useComputeRuntime.ts +30 -0
- package/src/hooks/useComputeRuntimeCallback.ts +32 -0
- package/src/hooks/useComputeRuntimeService.ts +64 -0
- package/src/hooks/useTriggerRuntimeControls.ts +70 -0
- package/src/index.ts +1 -3
- package/src/meta.ts +10 -8
- package/src/operations/create-trigger-from-template.ts +72 -0
- package/src/operations/index.ts +7 -0
- package/src/plugin.ts +11 -0
- package/src/testing/test-functions.ts +13 -10
- package/src/translations.ts +39 -29
- package/src/types/AutomationCapabilities.ts +48 -0
- package/src/types/AutomationEvents.ts +11 -0
- package/src/types/AutomationOperation.ts +30 -0
- package/src/types/index.ts +4 -0
- package/src/types/schema.ts +6 -6
- package/dist/lib/browser/AutomationContainer-BRV5AJZ3.mjs +0 -35
- package/dist/lib/browser/AutomationContainer-BRV5AJZ3.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-N5HFJJXW.mjs +0 -11
- package/dist/lib/browser/FunctionsContainer-U4HASI4P.mjs +0 -36
- package/dist/lib/browser/FunctionsContainer-U4HASI4P.mjs.map +0 -7
- package/dist/lib/browser/FunctionsPanel-I443Y6KB.mjs +0 -10
- package/dist/lib/browser/app-graph-builder-4OFKIRAI.mjs +0 -80
- package/dist/lib/browser/app-graph-builder-4OFKIRAI.mjs.map +0 -7
- package/dist/lib/browser/chunk-4TWQV33E.mjs +0 -143
- package/dist/lib/browser/chunk-4TWQV33E.mjs.map +0 -7
- package/dist/lib/browser/chunk-EIY2EUWC.mjs +0 -14
- package/dist/lib/browser/chunk-EIY2EUWC.mjs.map +0 -7
- package/dist/lib/browser/chunk-GW5U2DGT.mjs +0 -15
- package/dist/lib/browser/chunk-GW5U2DGT.mjs.map +0 -7
- package/dist/lib/browser/chunk-HN7OHFCB.mjs +0 -38
- package/dist/lib/browser/chunk-HN7OHFCB.mjs.map +0 -7
- package/dist/lib/browser/chunk-S4SM663I.mjs +0 -230
- package/dist/lib/browser/chunk-S4SM663I.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z5DT4MHW.mjs +0 -94
- package/dist/lib/browser/chunk-Z5DT4MHW.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -101
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-4PSYSQQG.mjs +0 -77
- package/dist/lib/browser/intent-resolver-4PSYSQQG.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-M52XGLXY.mjs +0 -64
- package/dist/lib/browser/react-surface-M52XGLXY.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -8
- package/dist/lib/node-esm/AutomationContainer-FYRDTERM.mjs +0 -36
- package/dist/lib/node-esm/AutomationContainer-FYRDTERM.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-MKOLA2FE.mjs +0 -12
- package/dist/lib/node-esm/FunctionsContainer-VZIVURH6.mjs +0 -37
- package/dist/lib/node-esm/FunctionsContainer-VZIVURH6.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsPanel-ELINCXPW.mjs +0 -11
- package/dist/lib/node-esm/app-graph-builder-555IHYOB.mjs +0 -81
- package/dist/lib/node-esm/app-graph-builder-555IHYOB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AONUBWBE.mjs +0 -144
- package/dist/lib/node-esm/chunk-AONUBWBE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CICQ73ZT.mjs +0 -16
- package/dist/lib/node-esm/chunk-CICQ73ZT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CX2AILIS.mjs +0 -95
- package/dist/lib/node-esm/chunk-CX2AILIS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NK5N3QKD.mjs +0 -17
- package/dist/lib/node-esm/chunk-NK5N3QKD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OEZNHUL2.mjs +0 -39
- package/dist/lib/node-esm/chunk-OEZNHUL2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZOJVKPCA.mjs +0 -231
- package/dist/lib/node-esm/chunk-ZOJVKPCA.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -102
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-6ZGBUILG.mjs +0 -78
- package/dist/lib/node-esm/intent-resolver-6ZGBUILG.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-Y6AOXM75.mjs +0 -65
- package/dist/lib/node-esm/react-surface-Y6AOXM75.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -9
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/AutomationContainer.d.ts +0 -5
- package/dist/types/src/components/AutomationContainer.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsContainer.d.ts +0 -7
- package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -72
- package/src/components/AutomationContainer.tsx +0 -28
- package/src/components/FunctionsContainer.tsx +0 -29
- /package/dist/lib/{browser/AutomationPanel-N5HFJJXW.mjs.map → neutral/AutomationPanel-64U7W3SJ.mjs.map} +0 -0
- /package/dist/lib/{browser/FunctionsPanel-I443Y6KB.mjs.map → neutral/TriggerSettings-XCHIZPOR.mjs.map} +0 -0
- /package/dist/lib/{browser/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{node-esm/types → neutral/components}/index.mjs.map +0 -0
- /package/dist/lib/{node-esm/AutomationPanel-MKOLA2FE.mjs.map → neutral/index.mjs.map} +0 -0
- /package/dist/lib/{node-esm/FunctionsPanel-ELINCXPW.mjs.map → neutral/meta.mjs.map} +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
import * as Options from '@effect/cli/Options';
|
|
7
|
+
import * as Prompt from '@effect/cli/Prompt';
|
|
8
|
+
import * as Console from 'effect/Console';
|
|
9
|
+
import * as Effect from 'effect/Effect';
|
|
10
|
+
import * as Match from 'effect/Match';
|
|
11
|
+
import * as Option from 'effect/Option';
|
|
12
|
+
|
|
13
|
+
import { CommandConfig } from '@dxos/cli-util';
|
|
14
|
+
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
15
|
+
import { Common } from '@dxos/cli-util';
|
|
16
|
+
import { Operation, Trigger } from '@dxos/compute';
|
|
17
|
+
import { DXN, Database, Filter, JsonSchema, Obj, Query, Ref } from '@dxos/echo';
|
|
18
|
+
|
|
19
|
+
import { Deep, Delay, Enabled, Input, TriggerId, Typename } from '../options';
|
|
20
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
21
|
+
|
|
22
|
+
export const subscription = Command.make(
|
|
23
|
+
'subscription',
|
|
24
|
+
{
|
|
25
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
26
|
+
id: TriggerId.pipe(Options.optional),
|
|
27
|
+
enabled: Enabled,
|
|
28
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
29
|
+
typename: Typename.pipe(Options.optional),
|
|
30
|
+
deep: Deep.pipe(Options.optional),
|
|
31
|
+
delay: Delay.pipe(Options.optional),
|
|
32
|
+
input: Input.pipe(Options.optional),
|
|
33
|
+
},
|
|
34
|
+
(options) =>
|
|
35
|
+
Effect.gen(function* () {
|
|
36
|
+
const { json } = yield* CommandConfig;
|
|
37
|
+
|
|
38
|
+
const triggerId = yield* Option.match(options.id, {
|
|
39
|
+
onNone: () => selectTrigger('subscription'),
|
|
40
|
+
onSome: (id) => Effect.succeed(id),
|
|
41
|
+
});
|
|
42
|
+
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
43
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
44
|
+
if (trigger.spec?.kind !== 'subscription') {
|
|
45
|
+
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const currentFn = yield* updateFunction(trigger, options.functionId);
|
|
49
|
+
yield* updateSpec(trigger, options.typename, options.deep, options.delay);
|
|
50
|
+
yield* updateInput(trigger, currentFn, options.input);
|
|
51
|
+
yield* updateEnabled(trigger, options.id, options.enabled);
|
|
52
|
+
|
|
53
|
+
if (json) {
|
|
54
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
55
|
+
} else {
|
|
56
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
yield* flushAndSync({ indexes: true });
|
|
60
|
+
}),
|
|
61
|
+
).pipe(
|
|
62
|
+
Command.withDescription('Update a subscription trigger.'),
|
|
63
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
64
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Extracts the current typename from a subscription trigger's query AST.
|
|
69
|
+
*/
|
|
70
|
+
const extractCurrentTypename = (spec: Trigger.SubscriptionSpec | undefined): Option.Option<string> => {
|
|
71
|
+
if (!spec?.query?.ast) {
|
|
72
|
+
return Option.none();
|
|
73
|
+
}
|
|
74
|
+
return Match.value(spec.query.ast).pipe(
|
|
75
|
+
Match.withReturnType<Option.Option<string>>(),
|
|
76
|
+
Match.when({ type: 'select' }, (q) =>
|
|
77
|
+
Match.value(q.filter).pipe(
|
|
78
|
+
Match.withReturnType<Option.Option<string>>(),
|
|
79
|
+
Match.when({ type: 'object' }, (f) =>
|
|
80
|
+
Option.fromNullable(f.typename).pipe(
|
|
81
|
+
Option.flatMap((dxn) => Option.fromNullable(DXN.tryParse(dxn))),
|
|
82
|
+
Option.flatMap((dxn) => Option.fromNullable(dxn.asTypeDXN()?.type)),
|
|
83
|
+
),
|
|
84
|
+
),
|
|
85
|
+
Match.orElse(() => Option.none()),
|
|
86
|
+
),
|
|
87
|
+
),
|
|
88
|
+
Match.orElse(() => Option.none()),
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Handles updating the function for a trigger.
|
|
94
|
+
* Prompts for confirmation if functionId is not provided, then updates the function if confirmed.
|
|
95
|
+
* @returns The current function (either original or newly assigned)
|
|
96
|
+
*/
|
|
97
|
+
const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
|
|
98
|
+
let currentFn: Operation.PersistentOperation | undefined = trigger.function
|
|
99
|
+
? yield* Database.load(trigger.function) as any
|
|
100
|
+
: undefined;
|
|
101
|
+
if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, currentFn)) {
|
|
102
|
+
currentFn = undefined;
|
|
103
|
+
}
|
|
104
|
+
const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
|
|
105
|
+
const shouldChangeFunction = yield* Option.match(functionIdOption, {
|
|
106
|
+
onNone: () =>
|
|
107
|
+
Prompt.confirm({
|
|
108
|
+
message: `Change the function${currentFunctionName ? ` (current: ${currentFunctionName})` : ''}?`,
|
|
109
|
+
initial: false,
|
|
110
|
+
}).pipe(Prompt.run),
|
|
111
|
+
onSome: () => Effect.succeed(true),
|
|
112
|
+
});
|
|
113
|
+
if (shouldChangeFunction) {
|
|
114
|
+
const functionId = yield* Option.match(functionIdOption, {
|
|
115
|
+
onNone: () => selectFunction(),
|
|
116
|
+
onSome: (id) => Effect.succeed(id),
|
|
117
|
+
});
|
|
118
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
119
|
+
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
120
|
+
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
121
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
122
|
+
}
|
|
123
|
+
Obj.update(trigger, (trigger) => {
|
|
124
|
+
trigger.function = Ref.make(foundFn);
|
|
125
|
+
});
|
|
126
|
+
currentFn = foundFn;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!currentFn) {
|
|
130
|
+
const functionId = trigger.function?.dxn.asEchoDXN()?.echoId ?? 'unknown';
|
|
131
|
+
return yield* Effect.fail(new Error(`Invalid reference for ${functionId}`));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return currentFn;
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Handles updating the subscription trigger spec (typename, deep, delay).
|
|
139
|
+
* Prompts for confirmation if no spec options are provided, then updates the spec if confirmed.
|
|
140
|
+
*/
|
|
141
|
+
const updateSpec = Effect.fn(function* (
|
|
142
|
+
trigger: Trigger.Trigger,
|
|
143
|
+
typenameOption: Option.Option<string>,
|
|
144
|
+
deepOption: Option.Option<boolean>,
|
|
145
|
+
delayOption: Option.Option<number>,
|
|
146
|
+
) {
|
|
147
|
+
const currentSpec = trigger.spec?.kind === 'subscription' ? trigger.spec : undefined;
|
|
148
|
+
const currentTypename = extractCurrentTypename(currentSpec);
|
|
149
|
+
const currentTypenameStr = Option.getOrUndefined(currentTypename);
|
|
150
|
+
const currentDeep = currentSpec?.options?.deep;
|
|
151
|
+
const currentDelay = currentSpec?.options?.delay;
|
|
152
|
+
const specParts: string[] = [];
|
|
153
|
+
if (currentTypenameStr) {
|
|
154
|
+
specParts.push(`typename: ${currentTypenameStr}`);
|
|
155
|
+
}
|
|
156
|
+
if (currentDeep !== undefined) {
|
|
157
|
+
specParts.push(`deep: ${currentDeep}`);
|
|
158
|
+
}
|
|
159
|
+
if (currentDelay !== undefined) {
|
|
160
|
+
specParts.push(`delay: ${currentDelay}`);
|
|
161
|
+
}
|
|
162
|
+
const currentSpecStr = specParts.length > 0 ? specParts.join(', ') : 'none';
|
|
163
|
+
|
|
164
|
+
const hasSpecOption = Option.isSome(typenameOption) || Option.isSome(deepOption) || Option.isSome(delayOption);
|
|
165
|
+
const shouldChangeSpec = yield* hasSpecOption
|
|
166
|
+
? Effect.succeed(true)
|
|
167
|
+
: Prompt.confirm({
|
|
168
|
+
message: `Change the trigger spec (current: ${currentSpecStr})?`,
|
|
169
|
+
initial: false,
|
|
170
|
+
}).pipe(Prompt.run);
|
|
171
|
+
if (shouldChangeSpec) {
|
|
172
|
+
const typename = yield* Option.match(typenameOption, {
|
|
173
|
+
onNone: () =>
|
|
174
|
+
Prompt.text({
|
|
175
|
+
message: `Enter type name${currentTypenameStr ? ` (current: ${currentTypenameStr})` : ''}:`,
|
|
176
|
+
}).pipe(Prompt.run),
|
|
177
|
+
onSome: (value) => Effect.succeed(value),
|
|
178
|
+
});
|
|
179
|
+
const queryAst = Query.select(Filter.type(typename)).ast;
|
|
180
|
+
|
|
181
|
+
const deepOptionValue = yield* Option.match(deepOption, {
|
|
182
|
+
onNone: () =>
|
|
183
|
+
Prompt.confirm({
|
|
184
|
+
message: 'Watch changes to nested properties (deep)?',
|
|
185
|
+
initial: currentSpec?.options?.deep ?? false,
|
|
186
|
+
}).pipe(
|
|
187
|
+
Prompt.run,
|
|
188
|
+
Effect.map((value) => (value ? Option.some(value) : Option.none())),
|
|
189
|
+
),
|
|
190
|
+
onSome: () => Effect.succeed(Option.some(true)),
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
const delayOptionValue = yield* Option.match(delayOption, {
|
|
194
|
+
onNone: () =>
|
|
195
|
+
Effect.gen(function* () {
|
|
196
|
+
const currentDelay = currentSpec?.options?.delay;
|
|
197
|
+
const delayStr = yield* Prompt.text({
|
|
198
|
+
message: `Debounce delay in milliseconds (optional, press Enter to skip)${currentDelay ? ` (current: ${currentDelay})` : ''}:`,
|
|
199
|
+
}).pipe(Prompt.run);
|
|
200
|
+
return delayStr === '' ? Option.none<number>() : Option.some(parseInt(delayStr, 10));
|
|
201
|
+
}),
|
|
202
|
+
onSome: (value) => Effect.succeed(Option.some(value)),
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
const subscriptionOptions: { deep?: boolean; delay?: number } = {};
|
|
206
|
+
if (Option.isSome(deepOptionValue)) {
|
|
207
|
+
subscriptionOptions.deep = deepOptionValue.value;
|
|
208
|
+
}
|
|
209
|
+
if (Option.isSome(delayOptionValue)) {
|
|
210
|
+
subscriptionOptions.delay = delayOptionValue.value;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
Obj.update(trigger, (trigger) => {
|
|
214
|
+
const spec = trigger.spec;
|
|
215
|
+
if (spec?.kind === 'subscription') {
|
|
216
|
+
// Cast needed because QueryAST types are deeply readonly but spec.query expects mutable.
|
|
217
|
+
spec.query = { ast: queryAst } as NonNullable<typeof spec.query>;
|
|
218
|
+
spec.options = Object.keys(subscriptionOptions).length > 0 ? subscriptionOptions : undefined;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Handles updating the input for a trigger.
|
|
226
|
+
* Prompts for confirmation if input is not provided, then updates the input if confirmed.
|
|
227
|
+
*/
|
|
228
|
+
const updateInput = Effect.fn(function* (
|
|
229
|
+
trigger: Trigger.Trigger,
|
|
230
|
+
fn: Operation.PersistentOperation,
|
|
231
|
+
inputOption: Option.Option<Record<string, any>>,
|
|
232
|
+
) {
|
|
233
|
+
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
234
|
+
const currentInputStr = currentInput ? JSON.stringify(currentInput) : 'none';
|
|
235
|
+
const shouldChangeInput = yield* Option.match(inputOption, {
|
|
236
|
+
onNone: () =>
|
|
237
|
+
Effect.gen(function* () {
|
|
238
|
+
yield* Console.log(`Current input: ${currentInputStr}`);
|
|
239
|
+
return yield* Prompt.confirm({
|
|
240
|
+
message: 'Change input?',
|
|
241
|
+
initial: false,
|
|
242
|
+
}).pipe(Prompt.run);
|
|
243
|
+
}),
|
|
244
|
+
onSome: () => Effect.succeed(true),
|
|
245
|
+
});
|
|
246
|
+
if (shouldChangeInput) {
|
|
247
|
+
const inputObj = yield* Option.match(inputOption, {
|
|
248
|
+
onNone: () =>
|
|
249
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
250
|
+
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
251
|
+
});
|
|
252
|
+
Obj.update(trigger, (trigger) => {
|
|
253
|
+
trigger.input = inputObj;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Handles updating the enabled status for a trigger.
|
|
260
|
+
* Prompts for enabled if id is not provided.
|
|
261
|
+
*/
|
|
262
|
+
const updateEnabled = Effect.fn(function* (
|
|
263
|
+
trigger: Trigger.Trigger,
|
|
264
|
+
idOption: Option.Option<string>,
|
|
265
|
+
enabled: boolean,
|
|
266
|
+
) {
|
|
267
|
+
const enabledValue = yield* Option.match(idOption, {
|
|
268
|
+
onNone: () =>
|
|
269
|
+
Prompt.confirm({
|
|
270
|
+
message: 'Enable the trigger?',
|
|
271
|
+
initial: trigger.enabled,
|
|
272
|
+
}).pipe(Prompt.run),
|
|
273
|
+
onSome: () => Effect.succeed(enabled),
|
|
274
|
+
});
|
|
275
|
+
Obj.update(trigger, (trigger) => {
|
|
276
|
+
trigger.enabled = enabledValue;
|
|
277
|
+
});
|
|
278
|
+
});
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
import * as Options from '@effect/cli/Options';
|
|
7
|
+
import * as Prompt from '@effect/cli/Prompt';
|
|
8
|
+
import * as Console from 'effect/Console';
|
|
9
|
+
import * as Effect from 'effect/Effect';
|
|
10
|
+
import * as Option from 'effect/Option';
|
|
11
|
+
|
|
12
|
+
import { CommandConfig } from '@dxos/cli-util';
|
|
13
|
+
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
14
|
+
import { Common } from '@dxos/cli-util';
|
|
15
|
+
import { Operation, Trigger } from '@dxos/compute';
|
|
16
|
+
import { DXN, Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
17
|
+
|
|
18
|
+
import { Cron, Enabled, Input, TriggerId } from '../options';
|
|
19
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
20
|
+
|
|
21
|
+
export const timer = Command.make(
|
|
22
|
+
'timer',
|
|
23
|
+
{
|
|
24
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
25
|
+
id: TriggerId.pipe(Options.optional),
|
|
26
|
+
enabled: Enabled,
|
|
27
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
28
|
+
cron: Cron.pipe(Options.optional),
|
|
29
|
+
input: Input.pipe(Options.optional),
|
|
30
|
+
},
|
|
31
|
+
(options) =>
|
|
32
|
+
Effect.gen(function* () {
|
|
33
|
+
const { json } = yield* CommandConfig;
|
|
34
|
+
|
|
35
|
+
const triggerId = yield* Option.match(options.id, {
|
|
36
|
+
onNone: () => selectTrigger('timer'),
|
|
37
|
+
onSome: (id) => Effect.succeed(id),
|
|
38
|
+
});
|
|
39
|
+
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
40
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
41
|
+
if (!trigger.spec || trigger.spec?.kind !== 'timer') {
|
|
42
|
+
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const currentFn = yield* updateFunction(trigger, options.functionId);
|
|
46
|
+
yield* updateCron(trigger, options.cron);
|
|
47
|
+
yield* updateInput(trigger, currentFn, options.input);
|
|
48
|
+
yield* updateEnabled(trigger, options.id, options.enabled);
|
|
49
|
+
|
|
50
|
+
if (json) {
|
|
51
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
52
|
+
} else {
|
|
53
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
yield* flushAndSync({ indexes: true });
|
|
57
|
+
}),
|
|
58
|
+
).pipe(
|
|
59
|
+
Command.withDescription('Update a timer trigger.'),
|
|
60
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
61
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Handles updating the function for a trigger.
|
|
66
|
+
* Prompts for confirmation if functionId is not provided, then updates the function if confirmed.
|
|
67
|
+
* @returns The current function (either original or newly assigned)
|
|
68
|
+
*/
|
|
69
|
+
const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
|
|
70
|
+
let currentFn: Operation.PersistentOperation | undefined = trigger.function
|
|
71
|
+
? yield* Database.load(trigger.function) as any
|
|
72
|
+
: undefined;
|
|
73
|
+
if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, currentFn)) {
|
|
74
|
+
currentFn = undefined;
|
|
75
|
+
}
|
|
76
|
+
const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
|
|
77
|
+
const shouldChangeFunction = yield* Option.match(functionIdOption, {
|
|
78
|
+
onNone: () =>
|
|
79
|
+
Prompt.confirm({
|
|
80
|
+
message: `Change the function${currentFunctionName ? ` (current: ${currentFunctionName})` : ''}?`,
|
|
81
|
+
initial: false,
|
|
82
|
+
}).pipe(Prompt.run),
|
|
83
|
+
onSome: () => Effect.succeed(true),
|
|
84
|
+
});
|
|
85
|
+
if (shouldChangeFunction) {
|
|
86
|
+
const functionId = yield* Option.match(functionIdOption, {
|
|
87
|
+
onNone: () => selectFunction(),
|
|
88
|
+
onSome: (id) => Effect.succeed(id),
|
|
89
|
+
});
|
|
90
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
91
|
+
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
92
|
+
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
93
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
94
|
+
}
|
|
95
|
+
Obj.update(trigger, (trigger) => {
|
|
96
|
+
trigger.function = Ref.make(foundFn);
|
|
97
|
+
});
|
|
98
|
+
currentFn = foundFn;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!currentFn) {
|
|
102
|
+
const functionId = trigger.function?.dxn.asEchoDXN()?.echoId ?? 'unknown';
|
|
103
|
+
return yield* Effect.fail(new Error(`Invalid reference for ${functionId}`));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return currentFn;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Handles updating the cron expression for a timer trigger.
|
|
111
|
+
* Prompts for confirmation if cron is not provided, then updates the cron if confirmed.
|
|
112
|
+
*/
|
|
113
|
+
const updateCron = Effect.fn(function* (trigger: Trigger.Trigger, cronOption: Option.Option<string>) {
|
|
114
|
+
const currentCron = trigger.spec?.kind === 'timer' ? trigger.spec.cron : undefined;
|
|
115
|
+
const shouldChangeCron = yield* Option.match(cronOption, {
|
|
116
|
+
onNone: () =>
|
|
117
|
+
Prompt.confirm({
|
|
118
|
+
message: `Change the cron expression${currentCron ? ` (current: ${currentCron})` : ''}?`,
|
|
119
|
+
initial: false,
|
|
120
|
+
}).pipe(Prompt.run),
|
|
121
|
+
onSome: () => Effect.succeed(true),
|
|
122
|
+
});
|
|
123
|
+
if (shouldChangeCron) {
|
|
124
|
+
const cron = yield* Option.match(cronOption, {
|
|
125
|
+
onNone: () =>
|
|
126
|
+
Prompt.text({
|
|
127
|
+
message: `Enter cron expression${currentCron ? ` (current: ${currentCron})` : ''}:`,
|
|
128
|
+
}).pipe(Prompt.run),
|
|
129
|
+
onSome: (value) => Effect.succeed(value),
|
|
130
|
+
});
|
|
131
|
+
Obj.update(trigger, (trigger) => {
|
|
132
|
+
if (trigger.spec?.kind === 'timer') {
|
|
133
|
+
trigger.spec.cron = cron;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Handles updating the input for a trigger.
|
|
141
|
+
* Prompts for confirmation if input is not provided, then updates the input if confirmed.
|
|
142
|
+
*/
|
|
143
|
+
const updateInput = Effect.fn(function* (
|
|
144
|
+
trigger: Trigger.Trigger,
|
|
145
|
+
fn: Operation.PersistentOperation,
|
|
146
|
+
inputOption: Option.Option<Record<string, any>>,
|
|
147
|
+
) {
|
|
148
|
+
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
149
|
+
const currentInputStr = currentInput ? JSON.stringify(currentInput) : 'none';
|
|
150
|
+
const shouldChangeInput = yield* Option.match(inputOption, {
|
|
151
|
+
onNone: () =>
|
|
152
|
+
Effect.gen(function* () {
|
|
153
|
+
yield* Console.log(`Current input: ${currentInputStr}`);
|
|
154
|
+
return yield* Prompt.confirm({
|
|
155
|
+
message: 'Change input?',
|
|
156
|
+
initial: false,
|
|
157
|
+
}).pipe(Prompt.run);
|
|
158
|
+
}),
|
|
159
|
+
onSome: () => Effect.succeed(true),
|
|
160
|
+
});
|
|
161
|
+
if (shouldChangeInput) {
|
|
162
|
+
const inputObj = yield* Option.match(inputOption, {
|
|
163
|
+
onNone: () =>
|
|
164
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
165
|
+
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
166
|
+
});
|
|
167
|
+
Obj.update(trigger, (trigger) => {
|
|
168
|
+
trigger.input = inputObj;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Handles updating the enabled status for a trigger.
|
|
175
|
+
* Prompts for enabled if id is not provided.
|
|
176
|
+
*/
|
|
177
|
+
const updateEnabled = Effect.fn(function* (
|
|
178
|
+
trigger: Trigger.Trigger,
|
|
179
|
+
idOption: Option.Option<string>,
|
|
180
|
+
enabled: boolean,
|
|
181
|
+
) {
|
|
182
|
+
const enabledValue = yield* Option.match(idOption, {
|
|
183
|
+
onNone: () =>
|
|
184
|
+
Prompt.confirm({
|
|
185
|
+
message: 'Enable the trigger?',
|
|
186
|
+
initial: trigger.enabled,
|
|
187
|
+
}).pipe(Prompt.run),
|
|
188
|
+
onSome: () => Effect.succeed(enabled),
|
|
189
|
+
});
|
|
190
|
+
Obj.update(trigger, (trigger) => {
|
|
191
|
+
trigger.enabled = enabledValue;
|
|
192
|
+
});
|
|
193
|
+
});
|