@dxos/plugin-automation 0.8.4-main.b97322e → 0.8.4-main.bcb3aa67d6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-NQY2QL47.mjs +44 -0
- package/dist/lib/browser/chunk-NQY2QL47.mjs.map +7 -0
- package/dist/lib/browser/chunk-WZKRIDQ6.mjs +54 -0
- package/dist/lib/browser/chunk-WZKRIDQ6.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +1122 -0
- package/dist/lib/browser/cli/index.mjs.map +7 -0
- package/dist/lib/browser/create-trigger-from-template-J2Z7AAHV.mjs +77 -0
- package/dist/lib/browser/create-trigger-from-template-J2Z7AAHV.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +117 -0
- package/dist/lib/browser/hooks/index.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +72 -83
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +14 -0
- package/dist/lib/browser/operations/index.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +10 -4
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-POUAOKR5.mjs +56 -0
- package/dist/lib/node-esm/chunk-POUAOKR5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Z6J7TDVZ.mjs +45 -0
- package/dist/lib/node-esm/chunk-Z6J7TDVZ.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +1123 -0
- package/dist/lib/node-esm/cli/index.mjs.map +7 -0
- package/dist/lib/node-esm/create-trigger-from-template-TRSHHYEB.mjs +78 -0
- package/dist/lib/node-esm/create-trigger-from-template-TRSHHYEB.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +118 -0
- package/dist/lib/node-esm/hooks/index.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +72 -83
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operations/index.mjs +15 -0
- package/dist/lib/node-esm/operations/index.mjs.map +7 -0
- package/dist/lib/node-esm/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.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 +6 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +3 -0
- package/dist/types/src/capabilities/node.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/cli/commands/index.d.ts +2 -0
- package/dist/types/src/cli/commands/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/index.d.ts +25 -0
- package/dist/types/src/cli/commands/trigger/create/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts +15 -0
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/index.d.ts +57 -0
- package/dist/types/src/cli/commands/trigger/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/list.d.ts +7 -0
- package/dist/types/src/cli/commands/trigger/list.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/options.d.ts +11 -0
- package/dist/types/src/cli/commands/trigger/options.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/remove.d.ts +8 -0
- package/dist/types/src/cli/commands/trigger/remove.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/index.d.ts +28 -0
- package/dist/types/src/cli/commands/trigger/update/index.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts +12 -0
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts +13 -0
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts +11 -0
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/util.d.ts +46 -0
- package/dist/types/src/cli/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/cli/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts.map +1 -0
- package/dist/types/src/cli/plugin.d.ts +3 -0
- package/dist/types/src/cli/plugin.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +3 -3
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +47 -4
- 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 +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 +116 -4
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +4 -0
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts +3 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/FunctionsContainer}/FunctionsContainer.d.ts +0 -1
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts +3 -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 +7 -0
- package/dist/types/src/hooks/useComputeRuntime.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +13 -0
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts +5 -0
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts.map +1 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +12 -0
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-trigger-from-template.d.ts +5 -0
- package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -0
- package/dist/types/src/operations/definitions.d.ts +19 -0
- package/dist/types/src/operations/definitions.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +4 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +204 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +29 -25
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +24 -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 +12 -4
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +105 -41
- package/src/AutomationPlugin.tsx +22 -33
- package/src/capabilities/app-graph-builder.ts +55 -79
- package/src/capabilities/compute-runtime.ts +180 -0
- package/src/capabilities/index.ts +9 -4
- package/src/capabilities/node.ts +7 -0
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +46 -45
- 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 +90 -0
- package/src/cli/commands/trigger/create/subscription.ts +129 -0
- package/src/cli/commands/trigger/create/timer.ts +94 -0
- package/src/cli/commands/trigger/index.ts +16 -0
- package/src/cli/commands/trigger/list.ts +68 -0
- package/src/cli/commands/trigger/options.ts +59 -0
- package/src/cli/commands/trigger/remove.ts +45 -0
- package/src/cli/commands/trigger/update/index.ts +14 -0
- package/src/cli/commands/trigger/update/queue.ts +195 -0
- package/src/cli/commands/trigger/update/subscription.ts +279 -0
- package/src/cli/commands/trigger/update/timer.ts +194 -0
- package/src/cli/commands/trigger/util.ts +409 -0
- package/src/cli/index.ts +5 -0
- package/src/cli/plugin.ts +24 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +18 -17
- package/src/components/AutomationPanel/AutomationPanel.tsx +240 -90
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +52 -32
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +114 -0
- package/src/components/FunctionsRegistry/index.ts +8 -0
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +42 -35
- package/src/components/TriggerEditor/SpecSelector.tsx +39 -22
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +123 -34
- package/src/components/TriggerEditor/TriggerEditor.tsx +110 -48
- package/src/components/index.ts +1 -2
- package/src/containers/AutomationSettings/AutomationSettings.tsx +27 -0
- package/src/containers/AutomationSettings/index.ts +7 -0
- package/src/containers/FunctionsContainer/FunctionsContainer.tsx +33 -0
- package/src/containers/FunctionsContainer/index.ts +7 -0
- package/src/containers/TriggerSettings/TriggerSettings.tsx +26 -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 +15 -0
- package/src/hooks/useComputeRuntimeCallback.ts +67 -0
- package/src/hooks/useComputeRuntimeService.ts +22 -0
- package/src/hooks/useTriggerRuntimeControls.ts +67 -0
- package/src/index.ts +2 -4
- package/src/meta.ts +8 -7
- package/src/operations/create-trigger-from-template.ts +74 -0
- package/src/operations/definitions.ts +27 -0
- package/src/operations/index.ts +9 -0
- package/src/testing/test-functions.ts +10 -7
- package/src/translations.ts +37 -29
- package/src/types/capabilities.ts +54 -0
- package/src/types/events.ts +11 -0
- package/src/types/index.ts +2 -0
- package/src/types/schema.ts +6 -6
- package/dist/lib/browser/AutomationContainer-VZNV2ZQF.mjs +0 -38
- package/dist/lib/browser/AutomationContainer-VZNV2ZQF.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-ZWA6GOFY.mjs +0 -11
- package/dist/lib/browser/FunctionsContainer-IOB333TX.mjs +0 -39
- package/dist/lib/browser/FunctionsContainer-IOB333TX.mjs.map +0 -7
- package/dist/lib/browser/FunctionsPanel-56ZKRVM5.mjs +0 -10
- package/dist/lib/browser/app-graph-builder-ZTAUTFI4.mjs +0 -80
- package/dist/lib/browser/app-graph-builder-ZTAUTFI4.mjs.map +0 -7
- package/dist/lib/browser/chunk-ECSTS2UI.mjs +0 -14
- package/dist/lib/browser/chunk-ECSTS2UI.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERTIGJYE.mjs +0 -147
- package/dist/lib/browser/chunk-ERTIGJYE.mjs.map +0 -7
- package/dist/lib/browser/chunk-FSJZXTS2.mjs +0 -230
- package/dist/lib/browser/chunk-FSJZXTS2.mjs.map +0 -7
- package/dist/lib/browser/chunk-GW5U2DGT.mjs +0 -15
- package/dist/lib/browser/chunk-GW5U2DGT.mjs.map +0 -7
- package/dist/lib/browser/chunk-HN7OHFCB.mjs +0 -38
- package/dist/lib/browser/chunk-HN7OHFCB.mjs.map +0 -7
- package/dist/lib/browser/chunk-LYJVTIVD.mjs +0 -94
- package/dist/lib/browser/chunk-LYJVTIVD.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-U3ZAQEFW.mjs +0 -76
- package/dist/lib/browser/intent-resolver-U3ZAQEFW.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4DFSM7OX.mjs +0 -64
- package/dist/lib/browser/react-surface-4DFSM7OX.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationContainer-WMIH3F4V.mjs +0 -39
- package/dist/lib/node-esm/AutomationContainer-WMIH3F4V.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-YYUMSK2W.mjs +0 -12
- package/dist/lib/node-esm/AutomationPanel-YYUMSK2W.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-DJWB6WFH.mjs +0 -40
- package/dist/lib/node-esm/FunctionsContainer-DJWB6WFH.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsPanel-KGIOZSPZ.mjs +0 -11
- package/dist/lib/node-esm/FunctionsPanel-KGIOZSPZ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-3FP63ZSG.mjs +0 -81
- package/dist/lib/node-esm/app-graph-builder-3FP63ZSG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AZH66CED.mjs +0 -231
- package/dist/lib/node-esm/chunk-AZH66CED.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HIMYPGHF.mjs +0 -148
- package/dist/lib/node-esm/chunk-HIMYPGHF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NK5N3QKD.mjs +0 -17
- package/dist/lib/node-esm/chunk-NK5N3QKD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OEZNHUL2.mjs +0 -39
- package/dist/lib/node-esm/chunk-OEZNHUL2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SGZPTJ47.mjs +0 -16
- package/dist/lib/node-esm/chunk-SGZPTJ47.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZGPUV5VS.mjs +0 -95
- package/dist/lib/node-esm/chunk-ZGPUV5VS.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-3QWXEBPX.mjs +0 -77
- package/dist/lib/node-esm/intent-resolver-3QWXEBPX.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-3PNW7NDW.mjs +0 -65
- package/dist/lib/node-esm/react-surface-3PNW7NDW.mjs.map +0 -7
- package/dist/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.map +0 -1
- package/src/capabilities/intent-resolver.ts +0 -72
- package/src/components/AutomationContainer.tsx +0 -30
- package/src/components/FunctionsContainer.tsx +0 -31
- /package/dist/lib/browser/{AutomationPanel-ZWA6GOFY.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{browser/FunctionsPanel-56ZKRVM5.mjs.map → node-esm/chunk-HSLMI22Q.mjs.map} +0 -0
|
@@ -2,55 +2,56 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
9
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
10
|
import { Obj } from '@dxos/echo';
|
|
9
|
-
import {
|
|
10
|
-
import { getSpace
|
|
11
|
+
import { useActiveSpace } from '@dxos/app-toolkit/ui';
|
|
12
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
11
13
|
|
|
12
|
-
import {
|
|
13
|
-
import { meta } from '
|
|
14
|
+
import { AutomationSettings, FunctionsContainer } from '#containers';
|
|
15
|
+
import { meta } from '#meta';
|
|
14
16
|
|
|
15
|
-
export default () =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
17
|
+
export default Capability.makeModule(() =>
|
|
18
|
+
Effect.succeed(
|
|
19
|
+
Capability.contributes(Capabilities.ReactSurface, [
|
|
20
|
+
Surface.create({
|
|
21
|
+
id: `${meta.id}.space-settings-functions`,
|
|
22
|
+
role: 'article',
|
|
23
|
+
filter: (data): data is { subject: string } => data.subject === `${meta.id}.space-settings-functions`,
|
|
24
|
+
component: () => {
|
|
25
|
+
const space = useActiveSpace();
|
|
26
|
+
if (!space) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
30
|
+
return <FunctionsContainer space={space} />;
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
Surface.create({
|
|
34
|
+
id: `${meta.id}.space-settings-automation`,
|
|
35
|
+
role: 'article',
|
|
36
|
+
filter: (data): data is { subject: string } => data.subject === `${meta.id}.space-settings-automation`,
|
|
37
|
+
component: () => {
|
|
38
|
+
const space = useActiveSpace();
|
|
39
|
+
if (!space) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
return <AutomationSettings space={space} />;
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
Surface.create({
|
|
47
|
+
id: `${meta.id}.companion.automation`,
|
|
48
|
+
role: 'article',
|
|
49
|
+
filter: (data): data is { companionTo: Obj.Unknown; subject: 'automation' } =>
|
|
50
|
+
Obj.isObject(data.companionTo) && data.subject === 'automation',
|
|
51
|
+
component: ({ data }) => {
|
|
52
|
+
return <AutomationSettings space={getSpace(data.companionTo)!} object={data.companionTo} />;
|
|
53
|
+
},
|
|
54
|
+
}),
|
|
55
|
+
]),
|
|
56
|
+
),
|
|
57
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
|
|
7
|
+
import { queue } from './queue';
|
|
8
|
+
import { subscription } from './subscription';
|
|
9
|
+
import { timer } from './timer';
|
|
10
|
+
|
|
11
|
+
export const create = Command.make('create').pipe(
|
|
12
|
+
Command.withDescription('Create a trigger.'),
|
|
13
|
+
Command.withSubcommands([subscription, timer, queue]),
|
|
14
|
+
);
|
|
@@ -0,0 +1,90 @@
|
|
|
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 HashMap from 'effect/HashMap';
|
|
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 { Database, Filter, JsonSchema, Ref } from '@dxos/echo';
|
|
17
|
+
import { Trigger } from '@dxos/functions';
|
|
18
|
+
import { Operation } from '@dxos/operation';
|
|
19
|
+
|
|
20
|
+
import { Enabled, Input, Queue } from '../options';
|
|
21
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectQueue } from '../util';
|
|
22
|
+
|
|
23
|
+
export const queue = Command.make(
|
|
24
|
+
'queue',
|
|
25
|
+
{
|
|
26
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
27
|
+
enabled: Enabled,
|
|
28
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
29
|
+
queue: Queue.pipe(Options.optional),
|
|
30
|
+
input: Input.pipe(Options.optional),
|
|
31
|
+
},
|
|
32
|
+
(options) =>
|
|
33
|
+
Effect.gen(function* () {
|
|
34
|
+
const { json } = yield* CommandConfig;
|
|
35
|
+
|
|
36
|
+
const functionId = yield* Option.match(options.functionId, {
|
|
37
|
+
onNone: () => selectFunction(),
|
|
38
|
+
onSome: (id) => Effect.succeed(id),
|
|
39
|
+
});
|
|
40
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
41
|
+
const fn = functions.find((fn) => fn.id === functionId);
|
|
42
|
+
if (!fn) {
|
|
43
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const queueDxn = yield* Option.match(options.queue, {
|
|
47
|
+
onNone: () => selectQueue(),
|
|
48
|
+
onSome: (dxn) => Effect.succeed(dxn.toString()),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const input = yield* Option.match(options.input, {
|
|
52
|
+
onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
|
|
53
|
+
onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Always prompt for enabled if functionId is not provided.
|
|
57
|
+
const enabled = yield* Option.match(options.functionId, {
|
|
58
|
+
onNone: () =>
|
|
59
|
+
Prompt.confirm({
|
|
60
|
+
message: 'Enable the trigger?',
|
|
61
|
+
initial: true,
|
|
62
|
+
}).pipe(Prompt.run),
|
|
63
|
+
onSome: () => Effect.succeed(options.enabled),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const trigger = Trigger.make({
|
|
67
|
+
function: Ref.make(fn),
|
|
68
|
+
enabled,
|
|
69
|
+
spec: {
|
|
70
|
+
kind: 'queue',
|
|
71
|
+
queue: queueDxn,
|
|
72
|
+
},
|
|
73
|
+
input,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
yield* Database.add(trigger);
|
|
77
|
+
|
|
78
|
+
if (json) {
|
|
79
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
80
|
+
} else {
|
|
81
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
yield* flushAndSync({ indexes: true });
|
|
85
|
+
}),
|
|
86
|
+
).pipe(
|
|
87
|
+
Command.withDescription('Create a queue trigger.'),
|
|
88
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
89
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
90
|
+
);
|
|
@@ -0,0 +1,129 @@
|
|
|
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 HashMap from 'effect/HashMap';
|
|
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 { Database, Filter, JsonSchema, Query, Ref } from '@dxos/echo';
|
|
17
|
+
import { Trigger } from '@dxos/functions';
|
|
18
|
+
import { Operation } from '@dxos/operation';
|
|
19
|
+
|
|
20
|
+
import { Deep, Delay, Enabled, Input, Typename } from '../options';
|
|
21
|
+
import { printTrigger, promptForSchemaInput, selectFunction } from '../util';
|
|
22
|
+
|
|
23
|
+
export const subscription = Command.make(
|
|
24
|
+
'subscription',
|
|
25
|
+
{
|
|
26
|
+
spaceId: Common.spaceId.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 functionId = yield* Option.match(options.functionId, {
|
|
39
|
+
onNone: () => selectFunction(),
|
|
40
|
+
onSome: (id) => Effect.succeed(id),
|
|
41
|
+
});
|
|
42
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
43
|
+
const fn = functions.find((fn) => fn.id === functionId);
|
|
44
|
+
if (!fn) {
|
|
45
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const typename = yield* Option.match(options.typename, {
|
|
49
|
+
onNone: () =>
|
|
50
|
+
Prompt.text({
|
|
51
|
+
message: 'Enter type name:',
|
|
52
|
+
}).pipe(Prompt.run),
|
|
53
|
+
onSome: (value) => Effect.succeed(value),
|
|
54
|
+
});
|
|
55
|
+
const queryAst = Query.select(Filter.type(typename)).ast;
|
|
56
|
+
|
|
57
|
+
const deepOption = yield* Option.match(options.deep, {
|
|
58
|
+
onNone: () =>
|
|
59
|
+
Prompt.confirm({
|
|
60
|
+
message: 'Watch changes to nested properties (deep)?',
|
|
61
|
+
initial: false,
|
|
62
|
+
}).pipe(
|
|
63
|
+
Prompt.run,
|
|
64
|
+
Effect.map((value) => (value ? Option.some(value) : Option.none())),
|
|
65
|
+
),
|
|
66
|
+
onSome: () => Effect.succeed(Option.some(true)),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const delayOption = yield* Option.match(options.delay, {
|
|
70
|
+
onNone: () =>
|
|
71
|
+
Effect.gen(function* () {
|
|
72
|
+
const delayStr = yield* Prompt.text({
|
|
73
|
+
message: 'Debounce delay in milliseconds (optional, press Enter to skip):',
|
|
74
|
+
}).pipe(Prompt.run);
|
|
75
|
+
return delayStr === '' ? Option.none<number>() : Option.some(parseInt(delayStr, 10));
|
|
76
|
+
}),
|
|
77
|
+
onSome: (value) => Effect.succeed(Option.some(value)),
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const subscriptionOptions: { deep?: boolean; delay?: number } = {};
|
|
81
|
+
if (Option.isSome(deepOption)) {
|
|
82
|
+
subscriptionOptions.deep = deepOption.value;
|
|
83
|
+
}
|
|
84
|
+
if (Option.isSome(delayOption)) {
|
|
85
|
+
subscriptionOptions.delay = delayOption.value;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const input = yield* Option.match(options.input, {
|
|
89
|
+
onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
|
|
90
|
+
onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Always prompt for enabled if functionId is not provided.
|
|
94
|
+
const enabled = yield* Option.match(options.functionId, {
|
|
95
|
+
onNone: () =>
|
|
96
|
+
Prompt.confirm({
|
|
97
|
+
message: 'Enable the trigger?',
|
|
98
|
+
initial: true,
|
|
99
|
+
}).pipe(Prompt.run),
|
|
100
|
+
onSome: () => Effect.succeed(options.enabled),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const trigger = Trigger.make({
|
|
104
|
+
function: Ref.make(fn),
|
|
105
|
+
enabled,
|
|
106
|
+
spec: {
|
|
107
|
+
kind: 'subscription',
|
|
108
|
+
query: {
|
|
109
|
+
ast: queryAst,
|
|
110
|
+
},
|
|
111
|
+
options: Object.keys(subscriptionOptions).length > 0 ? subscriptionOptions : undefined,
|
|
112
|
+
},
|
|
113
|
+
input,
|
|
114
|
+
});
|
|
115
|
+
yield* Database.add(trigger);
|
|
116
|
+
|
|
117
|
+
if (json) {
|
|
118
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
119
|
+
} else {
|
|
120
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
yield* flushAndSync({ indexes: true });
|
|
124
|
+
}),
|
|
125
|
+
).pipe(
|
|
126
|
+
Command.withDescription('Create a subscription trigger.'),
|
|
127
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
128
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
129
|
+
);
|
|
@@ -0,0 +1,94 @@
|
|
|
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 HashMap from 'effect/HashMap';
|
|
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 { Database, Filter, JsonSchema, Ref } from '@dxos/echo';
|
|
17
|
+
import { Trigger } from '@dxos/functions';
|
|
18
|
+
import { Operation } from '@dxos/operation';
|
|
19
|
+
|
|
20
|
+
import { Cron, Enabled, Input } from '../options';
|
|
21
|
+
import { printTrigger, promptForSchemaInput, selectFunction } from '../util';
|
|
22
|
+
|
|
23
|
+
// trigger create timer --cron "0 0 * * *" --functionId <functionId>
|
|
24
|
+
export const timer = Command.make(
|
|
25
|
+
'timer',
|
|
26
|
+
{
|
|
27
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
28
|
+
enabled: Enabled,
|
|
29
|
+
functionId: Common.functionId.pipe(Options.optional),
|
|
30
|
+
cron: Cron.pipe(Options.optional),
|
|
31
|
+
input: Input.pipe(Options.optional),
|
|
32
|
+
},
|
|
33
|
+
(options) =>
|
|
34
|
+
Effect.gen(function* () {
|
|
35
|
+
const { json } = yield* CommandConfig;
|
|
36
|
+
|
|
37
|
+
const functionId = yield* Option.match(options.functionId, {
|
|
38
|
+
onNone: () => selectFunction(),
|
|
39
|
+
onSome: (id) => Effect.succeed(id),
|
|
40
|
+
});
|
|
41
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
42
|
+
const fn = functions.find((fn) => fn.id === functionId);
|
|
43
|
+
if (!fn) {
|
|
44
|
+
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const cron = yield* Option.match(options.cron, {
|
|
48
|
+
onNone: () =>
|
|
49
|
+
Prompt.text({
|
|
50
|
+
message: 'Enter cron expression:',
|
|
51
|
+
}).pipe(Prompt.run),
|
|
52
|
+
onSome: (value) => Effect.succeed(value),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const input = yield* Option.match(options.input, {
|
|
56
|
+
onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
|
|
57
|
+
onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Always prompt for enabled if functionId is not provided.
|
|
61
|
+
const enabled = yield* Option.match(options.functionId, {
|
|
62
|
+
onNone: () =>
|
|
63
|
+
Prompt.confirm({
|
|
64
|
+
message: 'Enable the trigger?',
|
|
65
|
+
initial: true,
|
|
66
|
+
}).pipe(Prompt.run),
|
|
67
|
+
onSome: () => Effect.succeed(options.enabled),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const trigger = Trigger.make({
|
|
71
|
+
function: Ref.make(fn),
|
|
72
|
+
enabled,
|
|
73
|
+
spec: {
|
|
74
|
+
kind: 'timer',
|
|
75
|
+
cron,
|
|
76
|
+
},
|
|
77
|
+
input,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
yield* Database.add(trigger);
|
|
81
|
+
|
|
82
|
+
if (json) {
|
|
83
|
+
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
84
|
+
} else {
|
|
85
|
+
yield* Console.log(print(yield* printTrigger(trigger)));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
yield* flushAndSync({ indexes: true });
|
|
89
|
+
}),
|
|
90
|
+
).pipe(
|
|
91
|
+
Command.withDescription('Create a timer trigger.'),
|
|
92
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
93
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
94
|
+
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
|
|
7
|
+
import { create } from './create';
|
|
8
|
+
import { list } from './list';
|
|
9
|
+
import { remove } from './remove';
|
|
10
|
+
import { update } from './update';
|
|
11
|
+
|
|
12
|
+
// TODO(wittjosiah): Rename to automation to align with Composer?
|
|
13
|
+
export const trigger = Command.make('trigger').pipe(
|
|
14
|
+
Command.withDescription('Manage EDGE triggers.'),
|
|
15
|
+
Command.withSubcommands([create, list, remove, update]),
|
|
16
|
+
);
|
|
@@ -0,0 +1,68 @@
|
|
|
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 Console from 'effect/Console';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
|
|
10
|
+
import { CommandConfig, Common, printList, spaceIdWithDefault, spaceLayer } from '@dxos/cli-util';
|
|
11
|
+
import { ClientService } from '@dxos/client';
|
|
12
|
+
import { Context } from '@dxos/context';
|
|
13
|
+
import { Database, Filter } from '@dxos/echo';
|
|
14
|
+
import { Trigger } from '@dxos/functions';
|
|
15
|
+
|
|
16
|
+
import { getTriggerRemoteStatus, printTrigger } from './util';
|
|
17
|
+
|
|
18
|
+
export const list = Command.make(
|
|
19
|
+
'list',
|
|
20
|
+
{
|
|
21
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
22
|
+
},
|
|
23
|
+
Effect.fn(function* ({ spaceId: spaceIdOption }) {
|
|
24
|
+
const { json } = yield* CommandConfig;
|
|
25
|
+
|
|
26
|
+
// Fetch local triggers
|
|
27
|
+
const triggers = yield* Database.runQuery(Filter.type(Trigger.Trigger));
|
|
28
|
+
|
|
29
|
+
// Fetch remote cron triggers to check availability
|
|
30
|
+
const remoteCronIds = yield* Effect.gen(function* () {
|
|
31
|
+
const client = yield* ClientService;
|
|
32
|
+
const spaceId = yield* spaceIdWithDefault(spaceIdOption);
|
|
33
|
+
const result = yield* Effect.promise(() => client.edge.http.getCronTriggers(Context.default(), spaceId)).pipe(
|
|
34
|
+
Effect.catchAll(() => Effect.succeed({ cronIds: [] })),
|
|
35
|
+
);
|
|
36
|
+
return result.cronIds;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Determine remote status for each trigger
|
|
40
|
+
const triggersWithStatus = triggers.map((trigger) => ({
|
|
41
|
+
trigger,
|
|
42
|
+
remoteStatus: getTriggerRemoteStatus(trigger, remoteCronIds),
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
// Print triggers
|
|
46
|
+
if (json) {
|
|
47
|
+
yield* Console.log(
|
|
48
|
+
JSON.stringify(
|
|
49
|
+
triggersWithStatus.map(({ trigger, remoteStatus }) => ({ ...trigger, remoteStatus })),
|
|
50
|
+
null,
|
|
51
|
+
2,
|
|
52
|
+
),
|
|
53
|
+
);
|
|
54
|
+
} else {
|
|
55
|
+
if (triggersWithStatus.length === 0) {
|
|
56
|
+
yield* Console.log('No triggers found.');
|
|
57
|
+
} else {
|
|
58
|
+
const items = yield* Effect.all(
|
|
59
|
+
triggersWithStatus.map(({ trigger, remoteStatus }) => printTrigger(trigger, remoteStatus)),
|
|
60
|
+
);
|
|
61
|
+
yield* Console.log(printList(items));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}),
|
|
65
|
+
).pipe(
|
|
66
|
+
Command.withDescription('List triggers configured on EDGE.'),
|
|
67
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
68
|
+
);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Options from '@effect/cli/Options';
|
|
6
|
+
import * as Schema from 'effect/Schema';
|
|
7
|
+
|
|
8
|
+
import { DXN } from '@dxos/keys';
|
|
9
|
+
|
|
10
|
+
export const TriggerId = Options.text('id').pipe(Options.withDescription('The id of the trigger.'));
|
|
11
|
+
|
|
12
|
+
export const Enabled = Options.boolean('enabled', { ifPresent: true }).pipe(
|
|
13
|
+
Options.withDescription('Whether the trigger is enabled.'),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const Input = Options.keyValueMap('input').pipe(
|
|
17
|
+
Options.withDescription("Input data to pass to the function. Must match the function's input schema."),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
//
|
|
21
|
+
// Subscription
|
|
22
|
+
//
|
|
23
|
+
|
|
24
|
+
export const Typename = Options.text('typename').pipe(
|
|
25
|
+
Options.withDescription('The type name to query for the subscription trigger.'),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const Deep = Options.boolean('deep', { ifPresent: true }).pipe(
|
|
29
|
+
Options.withDescription('Watch changes to nested properties (not just creation).'),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export const Delay = Options.integer('delay').pipe(
|
|
33
|
+
Options.withDescription('Debounce changes with a delay in milliseconds.'),
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
//
|
|
37
|
+
// Timer
|
|
38
|
+
//
|
|
39
|
+
|
|
40
|
+
export const Cron = Options.text('cron').pipe(
|
|
41
|
+
Options.withDescription('The cron expression to use for the timer trigger.'),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
//
|
|
45
|
+
// Queue
|
|
46
|
+
//
|
|
47
|
+
|
|
48
|
+
// TODO(dmaretskyi): Extract
|
|
49
|
+
const DXNSchema = Schema.String.pipe(
|
|
50
|
+
Schema.transform(Schema.instanceOf(DXN), {
|
|
51
|
+
decode: (value: string) => DXN.parse(value),
|
|
52
|
+
encode: (value: DXN) => value.toString(),
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
export const Queue = Options.text('queue').pipe(
|
|
57
|
+
Options.withDescription('The DXN of the queue for the queue trigger.'),
|
|
58
|
+
Options.withSchema(DXNSchema),
|
|
59
|
+
);
|
|
@@ -0,0 +1,45 @@
|
|
|
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 Console from 'effect/Console';
|
|
8
|
+
import * as Effect from 'effect/Effect';
|
|
9
|
+
import * as Option from 'effect/Option';
|
|
10
|
+
|
|
11
|
+
import { CommandConfig, Common, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
12
|
+
import { DXN } from '@dxos/echo';
|
|
13
|
+
import { Database } from '@dxos/echo';
|
|
14
|
+
import { Trigger } from '@dxos/functions';
|
|
15
|
+
|
|
16
|
+
import { TriggerId } from './options';
|
|
17
|
+
import { printTriggerRemoved, selectTrigger } from './util';
|
|
18
|
+
|
|
19
|
+
export const remove = Command.make(
|
|
20
|
+
'remove',
|
|
21
|
+
{
|
|
22
|
+
spaceId: Common.spaceId.pipe(Options.optional),
|
|
23
|
+
id: TriggerId.pipe(Options.optional),
|
|
24
|
+
},
|
|
25
|
+
(options) =>
|
|
26
|
+
Effect.gen(function* () {
|
|
27
|
+
const { json } = yield* CommandConfig;
|
|
28
|
+
const triggerId = yield* Option.match(options.id, {
|
|
29
|
+
onNone: () => selectTrigger(),
|
|
30
|
+
onSome: (id) => Effect.succeed(id),
|
|
31
|
+
});
|
|
32
|
+
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
33
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
34
|
+
yield* Database.remove(trigger);
|
|
35
|
+
if (json) {
|
|
36
|
+
yield* Console.log(JSON.stringify({ id: trigger.id, removed: true }, null, 2));
|
|
37
|
+
} else {
|
|
38
|
+
yield* Console.log(print(printTriggerRemoved(trigger.id)));
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
).pipe(
|
|
42
|
+
Command.withDescription('Remove a trigger.'),
|
|
43
|
+
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
44
|
+
Command.provideEffectDiscard(() => withTypes(Trigger.Trigger)),
|
|
45
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Command from '@effect/cli/Command';
|
|
6
|
+
|
|
7
|
+
import { queue } from './queue';
|
|
8
|
+
import { subscription } from './subscription';
|
|
9
|
+
import { timer } from './timer';
|
|
10
|
+
|
|
11
|
+
export const update = Command.make('update').pipe(
|
|
12
|
+
Command.withDescription('Update a trigger.'),
|
|
13
|
+
Command.withSubcommands([subscription, timer, queue]),
|
|
14
|
+
);
|