@dxos/plugin-automation 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe
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-POEIL4RN.mjs +44 -0
- package/dist/lib/browser/chunk-POEIL4RN.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JOXPQ27I.mjs → chunk-WQLEMRPU.mjs} +9 -38
- package/dist/lib/browser/chunk-WQLEMRPU.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +122 -107
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/create-trigger-from-template-JZ62EZTB.mjs +77 -0
- package/dist/lib/browser/create-trigger-from-template-JZ62EZTB.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +79 -7
- package/dist/lib/browser/hooks/index.mjs.map +4 -4
- package/dist/lib/browser/index.mjs +60 -92
- 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 +4 -4
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/{chunk-RX52VKI2.mjs → chunk-JWZAVQLF.mjs} +9 -37
- package/dist/lib/node-esm/chunk-JWZAVQLF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SP3P4OUI.mjs +45 -0
- package/dist/lib/node-esm/chunk-SP3P4OUI.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +122 -107
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/create-trigger-from-template-224Z7WJI.mjs +78 -0
- package/dist/lib/node-esm/create-trigger-from-template-224Z7WJI.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +79 -7
- package/dist/lib/node-esm/hooks/index.mjs.map +4 -4
- package/dist/lib/node-esm/index.mjs +60 -92
- 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 +4 -4
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- 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 -4
- 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 +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/cli/commands/trigger/create/index.d.ts +1 -1
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts +1 -1
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts +1 -1
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts +1 -1
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/list.d.ts +1 -1
- package/dist/types/src/cli/commands/trigger/list.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/remove.d.ts +1 -1
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/util.d.ts +2 -2
- package/dist/types/src/cli/commands/trigger/util.d.ts.map +1 -1
- package/dist/types/src/cli/plugin.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +3 -4
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +28 -30
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/index.d.ts +3 -1
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +2 -2
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +91 -91
- 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 +4 -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/{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 +2 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts.map +1 -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 +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- 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 +1 -4
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
- 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 +2 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -5
- package/dist/types/src/index.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 +2 -0
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +29 -31
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +6 -3
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +9 -30
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +73 -46
- package/src/AutomationPlugin.tsx +13 -10
- package/src/capabilities/app-graph-builder.ts +62 -0
- package/src/capabilities/compute-runtime.ts +248 -0
- package/src/capabilities/index.ts +10 -4
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +59 -0
- package/src/cli/commands/trigger/create/queue.ts +7 -6
- package/src/cli/commands/trigger/create/subscription.ts +7 -6
- package/src/cli/commands/trigger/create/timer.ts +7 -6
- package/src/cli/commands/trigger/list.ts +3 -2
- package/src/cli/commands/trigger/remove.ts +2 -2
- package/src/cli/commands/trigger/update/queue.ts +21 -21
- package/src/cli/commands/trigger/update/subscription.ts +20 -19
- package/src/cli/commands/trigger/update/timer.ts +21 -20
- package/src/cli/commands/trigger/util.ts +43 -29
- package/src/cli/plugin.ts +6 -6
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +10 -8
- package/src/components/AutomationPanel/AutomationPanel.tsx +160 -87
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +37 -31
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +27 -24
- package/src/components/FunctionsRegistry/index.ts +4 -1
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +17 -8
- package/src/components/TriggerEditor/SpecSelector.tsx +12 -3
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +56 -13
- package/src/components/TriggerEditor/TriggerEditor.tsx +46 -17
- package/src/components/index.ts +1 -2
- package/src/containers/AutomationSettings/AutomationSettings.tsx +28 -0
- package/src/containers/AutomationSettings/index.ts +5 -0
- package/src/containers/FunctionsContainer/FunctionsContainer.tsx +34 -0
- package/src/containers/FunctionsContainer/index.ts +5 -0
- package/src/{components → containers/TriggerSettings}/TriggerSettings.tsx +8 -7
- package/src/containers/TriggerSettings/index.ts +6 -0
- package/src/containers/index.ts +9 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useComputeRuntime.ts +16 -0
- package/src/hooks/useComputeRuntimeCallback.ts +4 -39
- package/src/hooks/useComputeRuntimeService.ts +24 -0
- package/src/hooks/useTriggerRuntimeControls.ts +22 -8
- package/src/index.ts +2 -6
- package/src/meta.ts +2 -2
- package/src/operations/create-trigger-from-template.ts +75 -0
- package/src/operations/definitions.ts +28 -0
- package/src/operations/index.ts +9 -0
- package/src/testing/test-functions.ts +8 -5
- package/src/translations.ts +35 -36
- package/src/types/capabilities.ts +20 -6
- package/src/types/events.ts +2 -2
- package/src/types/schema.ts +3 -24
- package/dist/lib/browser/AutomationPanel-FAS6ADCW.mjs +0 -11
- package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs +0 -56
- package/dist/lib/browser/AutomationSettings-XN2OIYWL.mjs.map +0 -7
- package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs +0 -129
- package/dist/lib/browser/FunctionsContainer-6QLC7JP4.mjs.map +0 -7
- package/dist/lib/browser/FunctionsPanel-ZX4J75UM.mjs +0 -10
- package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs +0 -84
- package/dist/lib/browser/app-graph-builder-LAQMEBMH.mjs.map +0 -7
- package/dist/lib/browser/chunk-54PANILA.mjs +0 -14
- package/dist/lib/browser/chunk-54PANILA.mjs.map +0 -7
- package/dist/lib/browser/chunk-BFUIVUQH.mjs +0 -102
- package/dist/lib/browser/chunk-BFUIVUQH.mjs.map +0 -7
- package/dist/lib/browser/chunk-BKFQBKYO.mjs +0 -8
- package/dist/lib/browser/chunk-BKFQBKYO.mjs.map +0 -7
- package/dist/lib/browser/chunk-JOXPQ27I.mjs.map +0 -7
- package/dist/lib/browser/chunk-PZNBEKO5.mjs +0 -17
- package/dist/lib/browser/chunk-PZNBEKO5.mjs.map +0 -7
- package/dist/lib/browser/chunk-QW3EM35H.mjs +0 -248
- package/dist/lib/browser/chunk-QW3EM35H.mjs.map +0 -7
- package/dist/lib/browser/chunk-RAF2FJST.mjs +0 -86
- package/dist/lib/browser/chunk-RAF2FJST.mjs.map +0 -7
- package/dist/lib/browser/chunk-YWLEY2FD.mjs +0 -200
- package/dist/lib/browser/chunk-YWLEY2FD.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs +0 -114
- package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs +0 -82
- package/dist/lib/browser/operation-resolver-Q3MWOR7K.mjs.map +0 -7
- package/dist/lib/browser/react-surface-EV3AC62F.mjs +0 -65
- package/dist/lib/browser/react-surface-EV3AC62F.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-B7NAGDFA.mjs +0 -12
- package/dist/lib/node-esm/AutomationPanel-B7NAGDFA.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs +0 -57
- package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs +0 -130
- package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsPanel-SS6GIVNU.mjs +0 -11
- package/dist/lib/node-esm/FunctionsPanel-SS6GIVNU.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs +0 -85
- package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2CKVH7JC.mjs +0 -201
- package/dist/lib/node-esm/chunk-2CKVH7JC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5FXNN3MV.mjs +0 -19
- package/dist/lib/node-esm/chunk-5FXNN3MV.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7QRUPEHH.mjs +0 -16
- package/dist/lib/node-esm/chunk-7QRUPEHH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HQLVREIX.mjs +0 -87
- package/dist/lib/node-esm/chunk-HQLVREIX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-K7GCM342.mjs +0 -10
- package/dist/lib/node-esm/chunk-K7GCM342.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KWKWOGS5.mjs +0 -103
- package/dist/lib/node-esm/chunk-KWKWOGS5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs +0 -249
- package/dist/lib/node-esm/chunk-LJAXQ6CX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RX52VKI2.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs +0 -115
- package/dist/lib/node-esm/compute-runtime-ZHROOBLY.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs +0 -83
- package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-S6VZJCEZ.mjs +0 -66
- package/dist/lib/node-esm/react-surface-S6VZJCEZ.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +0 -6
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +0 -3
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts +0 -6
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-runtime/index.d.ts +0 -3
- package/dist/types/src/capabilities/compute-runtime/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/AutomationSettings.d.ts +0 -5
- package/dist/types/src/components/AutomationSettings.d.ts.map +0 -1
- package/dist/types/src/components/FunctionsContainer.d.ts.map +0 -1
- package/dist/types/src/components/TriggerSettings.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +0 -71
- package/src/capabilities/app-graph-builder/index.ts +0 -7
- package/src/capabilities/compute-runtime/compute-runtime.ts +0 -133
- package/src/capabilities/operation-resolver/index.ts +0 -7
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -79
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -60
- package/src/components/AutomationSettings.tsx +0 -30
- package/src/components/FunctionsContainer.tsx +0 -36
- /package/dist/lib/browser/{AutomationPanel-FAS6ADCW.mjs.map → chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/lib/{browser/FunctionsPanel-ZX4J75UM.mjs.map → node-esm/chunk-HSLMI22Q.mjs.map} +0 -0
- /package/dist/types/src/{components → containers/TriggerSettings}/TriggerSettings.d.ts +0 -0
- /package/src/capabilities/{compute-runtime/index.ts → node.ts} +0 -0
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
ComputeRuntime
|
|
3
|
-
} from "../chunk-BKFQBKYO.mjs";
|
|
4
|
-
import {
|
|
5
|
-
AutomationEvents
|
|
6
|
-
} from "../chunk-JOXPQ27I.mjs";
|
|
7
|
-
import {
|
|
8
|
-
meta
|
|
9
|
-
} from "../chunk-PZNBEKO5.mjs";
|
|
1
|
+
import "../chunk-J5LGTIGS.mjs";
|
|
10
2
|
|
|
11
3
|
// src/cli/plugin.ts
|
|
12
|
-
import {
|
|
4
|
+
import { Plugin } from "@dxos/app-framework";
|
|
5
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
13
6
|
import { ClientEvents } from "@dxos/plugin-client/types";
|
|
7
|
+
import { ComputeRuntime } from "#capabilities";
|
|
8
|
+
import { meta } from "#meta";
|
|
9
|
+
import { AutomationEvents } from "#types";
|
|
14
10
|
|
|
15
11
|
// src/cli/commands/trigger/index.ts
|
|
16
12
|
import * as Command11 from "@effect/cli/Command";
|
|
@@ -29,8 +25,9 @@ import * as Option2 from "effect/Option";
|
|
|
29
25
|
import { CommandConfig } from "@dxos/cli-util";
|
|
30
26
|
import { flushAndSync, print, spaceLayer, withTypes } from "@dxos/cli-util";
|
|
31
27
|
import { Common } from "@dxos/cli-util";
|
|
32
|
-
import { Database as Database2, Filter as Filter2, Ref as Ref2
|
|
33
|
-
import {
|
|
28
|
+
import { Database as Database2, Filter as Filter2, JsonSchema, Ref as Ref2 } from "@dxos/echo";
|
|
29
|
+
import { Trigger as Trigger2 } from "@dxos/functions";
|
|
30
|
+
import { Operation as Operation2 } from "@dxos/operation";
|
|
34
31
|
|
|
35
32
|
// src/cli/commands/trigger/options.ts
|
|
36
33
|
import * as Options from "@effect/cli/Options";
|
|
@@ -62,10 +59,11 @@ import * as Match from "effect/Match";
|
|
|
62
59
|
import * as Option from "effect/Option";
|
|
63
60
|
import * as SchemaAST from "effect/SchemaAST";
|
|
64
61
|
import { FormBuilder } from "@dxos/cli-util";
|
|
65
|
-
import { Annotation, Database, Entity, Filter, Obj, Ref, Type } from "@dxos/echo";
|
|
62
|
+
import { Annotation, Database, Entity, Feed, Filter, Obj, Ref, Type } from "@dxos/echo";
|
|
66
63
|
import { getProperties } from "@dxos/effect";
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
64
|
+
import { Trigger } from "@dxos/functions";
|
|
65
|
+
import { Operation } from "@dxos/operation";
|
|
66
|
+
import { FeedAnnotation } from "@dxos/schema";
|
|
69
67
|
var getTriggerRemoteStatus = (trigger2, remoteCronIds) => {
|
|
70
68
|
if (trigger2.spec?.kind !== "timer") {
|
|
71
69
|
return "n/a";
|
|
@@ -73,10 +71,10 @@ var getTriggerRemoteStatus = (trigger2, remoteCronIds) => {
|
|
|
73
71
|
return remoteCronIds.includes(trigger2.id) ? "available" : "not available";
|
|
74
72
|
};
|
|
75
73
|
var printTrigger = Effect.fn(function* (trigger2, remoteStatus) {
|
|
76
|
-
const fn6 = trigger2.function && (yield* Database.
|
|
74
|
+
const fn6 = trigger2.function && (yield* Database.load(trigger2.function));
|
|
77
75
|
return FormBuilder.make({
|
|
78
76
|
title: trigger2.id
|
|
79
|
-
}).pipe(FormBuilder.set("status", trigger2.enabled ? "enabled" : "disabled", trigger2.enabled ? Ansi.green : Ansi.blackBright), FormBuilder.option("kind", Option.fromNullable(trigger2.spec?.kind)), FormBuilder.option("remote", Option.fromNullable(remoteStatus), Match.type().pipe(Match.withReturnType(), Match.when("available", () => Ansi.green), Match.when("not available", () => Ansi.yellow), Match.when("n/a", () => Ansi.blackBright), Match.exhaustive)), FormBuilder.when(fn6, FormBuilder.nest("function", FormBuilder.make().pipe(FormBuilder.set("key", fn6.key), FormBuilder.set("dxn", fn6.
|
|
77
|
+
}).pipe(FormBuilder.set("status", trigger2.enabled ? "enabled" : "disabled", trigger2.enabled ? Ansi.green : Ansi.blackBright), FormBuilder.option("kind", Option.fromNullable(trigger2.spec?.kind)), FormBuilder.option("remote", Option.fromNullable(remoteStatus), Match.type().pipe(Match.withReturnType(), Match.when("available", () => Ansi.green), Match.when("not available", () => Ansi.yellow), Match.when("n/a", () => Ansi.blackBright), Match.exhaustive)), FormBuilder.when(fn6, FormBuilder.nest("function", FormBuilder.make().pipe(FormBuilder.set("key", fn6.key), FormBuilder.set("dxn", Obj.getDXN(fn6).toString())))), FormBuilder.nestedOption("spec", Option.fromNullable(trigger2.spec).pipe(Option.map(printSpec))), FormBuilder.build);
|
|
80
78
|
});
|
|
81
79
|
var printSpec = (spec) => {
|
|
82
80
|
switch (spec.kind) {
|
|
@@ -202,7 +200,7 @@ var promptForSchemaInput = Effect.fn(function* (schema, defaults) {
|
|
|
202
200
|
inputObj[key] = templateStr === "" && defaultValue !== void 0 ? defaultValue : templateStr;
|
|
203
201
|
} else {
|
|
204
202
|
const annotation = Annotation.ReferenceAnnotation.getFromAst(propType).pipe(Option.getOrThrow);
|
|
205
|
-
const objects = yield* Database.
|
|
203
|
+
const objects = yield* Database.runQuery(Filter.typename(annotation.typename));
|
|
206
204
|
if (objects.length === 0) {
|
|
207
205
|
inputObj[key] = void 0;
|
|
208
206
|
} else {
|
|
@@ -228,7 +226,7 @@ var promptForSchemaInput = Effect.fn(function* (schema, defaults) {
|
|
|
228
226
|
return inputObj;
|
|
229
227
|
});
|
|
230
228
|
var selectFunction = Effect.fn(function* () {
|
|
231
|
-
const functions = yield* Database.
|
|
229
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
232
230
|
if (functions.length === 0) {
|
|
233
231
|
return yield* Effect.fail(new Error("No functions available"));
|
|
234
232
|
}
|
|
@@ -243,14 +241,14 @@ var selectFunction = Effect.fn(function* () {
|
|
|
243
241
|
return String(selected);
|
|
244
242
|
});
|
|
245
243
|
var selectTrigger = Effect.fn(function* (kind) {
|
|
246
|
-
const triggers = yield* Database.
|
|
244
|
+
const triggers = yield* Database.runQuery(Filter.type(Trigger.Trigger));
|
|
247
245
|
const filteredTriggers = kind ? triggers.filter((trigger2) => trigger2.spec?.kind === kind) : triggers;
|
|
248
246
|
if (filteredTriggers.length === 0) {
|
|
249
247
|
return yield* Effect.fail(new Error(kind ? `No ${kind} triggers available` : "No triggers available"));
|
|
250
248
|
}
|
|
251
249
|
const choices = yield* Effect.all(filteredTriggers.map((trigger2) => Effect.gen(function* () {
|
|
252
|
-
const fn6 = trigger2.function ? yield* Database.
|
|
253
|
-
const functionName = fn6 && Obj.instanceOf(
|
|
250
|
+
const fn6 = trigger2.function ? yield* Database.load(trigger2.function) : void 0;
|
|
251
|
+
const functionName = fn6 && Obj.instanceOf(Operation.PersistentOperation, fn6) ? fn6.name ?? fn6.key ?? fn6.id : void 0;
|
|
254
252
|
const title = functionName ?? trigger2.id;
|
|
255
253
|
const description = `${trigger2.enabled ? "enabled" : "disabled"} - ${trigger2.spec?.kind ?? "unknown"}`;
|
|
256
254
|
return {
|
|
@@ -266,35 +264,42 @@ var selectTrigger = Effect.fn(function* (kind) {
|
|
|
266
264
|
return String(selected);
|
|
267
265
|
});
|
|
268
266
|
var selectQueue = Effect.fn(function* () {
|
|
269
|
-
const schemas = yield* Database.
|
|
267
|
+
const schemas = yield* Database.runSchemaQuery({
|
|
270
268
|
location: [
|
|
271
269
|
"database",
|
|
272
270
|
"runtime"
|
|
273
271
|
]
|
|
274
272
|
});
|
|
275
|
-
const
|
|
276
|
-
const annotation =
|
|
273
|
+
const feedSchemas = schemas.filter((schema) => {
|
|
274
|
+
const annotation = FeedAnnotation.get(schema);
|
|
277
275
|
return Option.isSome(annotation) && annotation.value === true;
|
|
278
276
|
});
|
|
279
|
-
if (
|
|
280
|
-
return yield* Effect.fail(new Error("No schemas with
|
|
277
|
+
if (feedSchemas.length === 0) {
|
|
278
|
+
return yield* Effect.fail(new Error("No schemas with Feed annotation found"));
|
|
281
279
|
}
|
|
282
280
|
const queueChoices = [];
|
|
283
|
-
for (const schema of
|
|
281
|
+
for (const schema of feedSchemas) {
|
|
284
282
|
yield* Effect.gen(function* () {
|
|
285
283
|
const typename = Type.getTypename(schema);
|
|
286
|
-
const objects = yield* Database.
|
|
284
|
+
const objects = yield* Database.runQuery(Filter.type(typename));
|
|
287
285
|
for (const obj of objects) {
|
|
288
|
-
const
|
|
289
|
-
if (!
|
|
286
|
+
const feedRef = obj.feed;
|
|
287
|
+
if (!feedRef) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
const feedObj = yield* Effect.promise(() => feedRef.tryLoad());
|
|
291
|
+
if (!feedObj || !Obj.instanceOf(Feed.Feed, feedObj)) {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
const queueDxn = Feed.getQueueDxn(feedObj);
|
|
295
|
+
if (!queueDxn) {
|
|
290
296
|
continue;
|
|
291
297
|
}
|
|
292
|
-
const queueDxn = queueRef.dxn.toString();
|
|
293
298
|
const label = Obj.getLabel(obj) ?? obj.id;
|
|
294
299
|
const description = Obj.getTypename(obj);
|
|
295
300
|
queueChoices.push({
|
|
296
301
|
title: label,
|
|
297
|
-
value: queueDxn,
|
|
302
|
+
value: queueDxn.toString(),
|
|
298
303
|
description
|
|
299
304
|
});
|
|
300
305
|
}
|
|
@@ -326,7 +331,7 @@ var queue = Command.make("queue", {
|
|
|
326
331
|
onNone: () => selectFunction(),
|
|
327
332
|
onSome: (id) => Effect2.succeed(id)
|
|
328
333
|
});
|
|
329
|
-
const functions = yield* Database2.
|
|
334
|
+
const functions = yield* Database2.runQuery(Filter2.type(Operation2.PersistentOperation));
|
|
330
335
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
331
336
|
if (!fn6) {
|
|
332
337
|
return yield* Effect2.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -336,7 +341,7 @@ var queue = Command.make("queue", {
|
|
|
336
341
|
onSome: (dxn) => Effect2.succeed(dxn.toString())
|
|
337
342
|
});
|
|
338
343
|
const input = yield* Option2.match(options.input, {
|
|
339
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
344
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema.toEffectSchema(fn6.inputSchema) : void 0),
|
|
340
345
|
onSome: (value2) => Effect2.succeed(Object.fromEntries(HashMap.toEntries(value2)))
|
|
341
346
|
});
|
|
342
347
|
const enabled = yield* Option2.match(options.functionId, {
|
|
@@ -355,7 +360,7 @@ var queue = Command.make("queue", {
|
|
|
355
360
|
},
|
|
356
361
|
input
|
|
357
362
|
});
|
|
358
|
-
yield* Database2.
|
|
363
|
+
yield* Database2.add(trigger2);
|
|
359
364
|
if (json) {
|
|
360
365
|
yield* Console2.log(JSON.stringify(trigger2, null, 2));
|
|
361
366
|
} else {
|
|
@@ -364,7 +369,7 @@ var queue = Command.make("queue", {
|
|
|
364
369
|
yield* flushAndSync({
|
|
365
370
|
indexes: true
|
|
366
371
|
});
|
|
367
|
-
})).pipe(Command.withDescription("Create a queue trigger."), Command.provide(({ spaceId }) => spaceLayer(spaceId, true)), Command.provideEffectDiscard(() => withTypes(
|
|
372
|
+
})).pipe(Command.withDescription("Create a queue trigger."), Command.provide(({ spaceId }) => spaceLayer(spaceId, true)), Command.provideEffectDiscard(() => withTypes(Operation2.PersistentOperation, Trigger2.Trigger)));
|
|
368
373
|
|
|
369
374
|
// src/cli/commands/trigger/create/subscription.ts
|
|
370
375
|
import * as Command2 from "@effect/cli/Command";
|
|
@@ -377,8 +382,9 @@ import * as Option3 from "effect/Option";
|
|
|
377
382
|
import { CommandConfig as CommandConfig2 } from "@dxos/cli-util";
|
|
378
383
|
import { flushAndSync as flushAndSync2, print as print2, spaceLayer as spaceLayer2, withTypes as withTypes2 } from "@dxos/cli-util";
|
|
379
384
|
import { Common as Common2 } from "@dxos/cli-util";
|
|
380
|
-
import { Database as Database3, Filter as Filter3, Query, Ref as Ref3
|
|
381
|
-
import {
|
|
385
|
+
import { Database as Database3, Filter as Filter3, JsonSchema as JsonSchema2, Query, Ref as Ref3 } from "@dxos/echo";
|
|
386
|
+
import { Trigger as Trigger3 } from "@dxos/functions";
|
|
387
|
+
import { Operation as Operation3 } from "@dxos/operation";
|
|
382
388
|
var subscription = Command2.make("subscription", {
|
|
383
389
|
spaceId: Common2.spaceId.pipe(Options3.optional),
|
|
384
390
|
enabled: Enabled,
|
|
@@ -393,7 +399,7 @@ var subscription = Command2.make("subscription", {
|
|
|
393
399
|
onNone: () => selectFunction(),
|
|
394
400
|
onSome: (id) => Effect3.succeed(id)
|
|
395
401
|
});
|
|
396
|
-
const functions = yield* Database3.
|
|
402
|
+
const functions = yield* Database3.runQuery(Filter3.type(Operation3.PersistentOperation));
|
|
397
403
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
398
404
|
if (!fn6) {
|
|
399
405
|
return yield* Effect3.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -429,7 +435,7 @@ var subscription = Command2.make("subscription", {
|
|
|
429
435
|
subscriptionOptions.delay = delayOption.value;
|
|
430
436
|
}
|
|
431
437
|
const input = yield* Option3.match(options.input, {
|
|
432
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
438
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema2.toEffectSchema(fn6.inputSchema) : void 0),
|
|
433
439
|
onSome: (value2) => Effect3.succeed(Object.fromEntries(HashMap2.toEntries(value2)))
|
|
434
440
|
});
|
|
435
441
|
const enabled = yield* Option3.match(options.functionId, {
|
|
@@ -451,7 +457,7 @@ var subscription = Command2.make("subscription", {
|
|
|
451
457
|
},
|
|
452
458
|
input
|
|
453
459
|
});
|
|
454
|
-
yield* Database3.
|
|
460
|
+
yield* Database3.add(trigger2);
|
|
455
461
|
if (json) {
|
|
456
462
|
yield* Console3.log(JSON.stringify(trigger2, null, 2));
|
|
457
463
|
} else {
|
|
@@ -460,7 +466,7 @@ var subscription = Command2.make("subscription", {
|
|
|
460
466
|
yield* flushAndSync2({
|
|
461
467
|
indexes: true
|
|
462
468
|
});
|
|
463
|
-
})).pipe(Command2.withDescription("Create a subscription trigger."), Command2.provide(({ spaceId }) => spaceLayer2(spaceId, true)), Command2.provideEffectDiscard(() => withTypes2(
|
|
469
|
+
})).pipe(Command2.withDescription("Create a subscription trigger."), Command2.provide(({ spaceId }) => spaceLayer2(spaceId, true)), Command2.provideEffectDiscard(() => withTypes2(Operation3.PersistentOperation, Trigger3.Trigger)));
|
|
464
470
|
|
|
465
471
|
// src/cli/commands/trigger/create/timer.ts
|
|
466
472
|
import * as Command3 from "@effect/cli/Command";
|
|
@@ -473,8 +479,9 @@ import * as Option4 from "effect/Option";
|
|
|
473
479
|
import { CommandConfig as CommandConfig3 } from "@dxos/cli-util";
|
|
474
480
|
import { flushAndSync as flushAndSync3, print as print3, spaceLayer as spaceLayer3, withTypes as withTypes3 } from "@dxos/cli-util";
|
|
475
481
|
import { Common as Common3 } from "@dxos/cli-util";
|
|
476
|
-
import { Database as Database4, Filter as Filter4,
|
|
477
|
-
import {
|
|
482
|
+
import { Database as Database4, Filter as Filter4, JsonSchema as JsonSchema3, Ref as Ref4 } from "@dxos/echo";
|
|
483
|
+
import { Trigger as Trigger4 } from "@dxos/functions";
|
|
484
|
+
import { Operation as Operation4 } from "@dxos/operation";
|
|
478
485
|
var timer = Command3.make("timer", {
|
|
479
486
|
spaceId: Common3.spaceId.pipe(Options4.optional),
|
|
480
487
|
enabled: Enabled,
|
|
@@ -487,7 +494,7 @@ var timer = Command3.make("timer", {
|
|
|
487
494
|
onNone: () => selectFunction(),
|
|
488
495
|
onSome: (id) => Effect4.succeed(id)
|
|
489
496
|
});
|
|
490
|
-
const functions = yield* Database4.
|
|
497
|
+
const functions = yield* Database4.runQuery(Filter4.type(Operation4.PersistentOperation));
|
|
491
498
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
492
499
|
if (!fn6) {
|
|
493
500
|
return yield* Effect4.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -499,7 +506,7 @@ var timer = Command3.make("timer", {
|
|
|
499
506
|
onSome: (value2) => Effect4.succeed(value2)
|
|
500
507
|
});
|
|
501
508
|
const input = yield* Option4.match(options.input, {
|
|
502
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
509
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema3.toEffectSchema(fn6.inputSchema) : void 0),
|
|
503
510
|
onSome: (value2) => Effect4.succeed(Object.fromEntries(HashMap3.toEntries(value2)))
|
|
504
511
|
});
|
|
505
512
|
const enabled = yield* Option4.match(options.functionId, {
|
|
@@ -518,7 +525,7 @@ var timer = Command3.make("timer", {
|
|
|
518
525
|
},
|
|
519
526
|
input
|
|
520
527
|
});
|
|
521
|
-
yield* Database4.
|
|
528
|
+
yield* Database4.add(trigger2);
|
|
522
529
|
if (json) {
|
|
523
530
|
yield* Console4.log(JSON.stringify(trigger2, null, 2));
|
|
524
531
|
} else {
|
|
@@ -527,7 +534,7 @@ var timer = Command3.make("timer", {
|
|
|
527
534
|
yield* flushAndSync3({
|
|
528
535
|
indexes: true
|
|
529
536
|
});
|
|
530
|
-
})).pipe(Command3.withDescription("Create a timer trigger."), Command3.provide(({ spaceId }) => spaceLayer3(spaceId, true)), Command3.provideEffectDiscard(() => withTypes3(
|
|
537
|
+
})).pipe(Command3.withDescription("Create a timer trigger."), Command3.provide(({ spaceId }) => spaceLayer3(spaceId, true)), Command3.provideEffectDiscard(() => withTypes3(Operation4.PersistentOperation, Trigger4.Trigger)));
|
|
531
538
|
|
|
532
539
|
// src/cli/commands/trigger/create/index.ts
|
|
533
540
|
var create = Command4.make("create").pipe(Command4.withDescription("Create a trigger."), Command4.withSubcommands([
|
|
@@ -543,17 +550,22 @@ import * as Console5 from "effect/Console";
|
|
|
543
550
|
import * as Effect5 from "effect/Effect";
|
|
544
551
|
import { CommandConfig as CommandConfig4, Common as Common4, printList, spaceIdWithDefault, spaceLayer as spaceLayer4 } from "@dxos/cli-util";
|
|
545
552
|
import { ClientService } from "@dxos/client";
|
|
553
|
+
import { Context } from "@dxos/context";
|
|
546
554
|
import { Database as Database5, Filter as Filter5 } from "@dxos/echo";
|
|
547
555
|
import { Trigger as Trigger5 } from "@dxos/functions";
|
|
556
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-automation/src/cli/commands/trigger/list.ts";
|
|
548
557
|
var list = Command5.make("list", {
|
|
549
558
|
spaceId: Common4.spaceId.pipe(Options5.optional)
|
|
550
559
|
}, Effect5.fn(function* ({ spaceId: spaceIdOption }) {
|
|
551
560
|
const { json } = yield* CommandConfig4;
|
|
552
|
-
const triggers = yield* Database5.
|
|
561
|
+
const triggers = yield* Database5.runQuery(Filter5.type(Trigger5.Trigger));
|
|
553
562
|
const remoteCronIds = yield* Effect5.gen(function* () {
|
|
554
563
|
const client = yield* ClientService;
|
|
555
564
|
const spaceId = yield* spaceIdWithDefault(spaceIdOption);
|
|
556
|
-
const result = yield* Effect5.promise(() => client.edge.getCronTriggers(
|
|
565
|
+
const result = yield* Effect5.promise(() => client.edge.http.getCronTriggers(Context.default(void 0, {
|
|
566
|
+
F: __dxlog_file,
|
|
567
|
+
L: 33
|
|
568
|
+
}), spaceId)).pipe(Effect5.catchAll(() => Effect5.succeed({
|
|
557
569
|
cronIds: []
|
|
558
570
|
})));
|
|
559
571
|
return result.cronIds;
|
|
@@ -597,8 +609,8 @@ var remove = Command6.make("remove", {
|
|
|
597
609
|
onSome: (id) => Effect6.succeed(id)
|
|
598
610
|
});
|
|
599
611
|
const dxn = DXN2.fromLocalObjectId(triggerId);
|
|
600
|
-
const trigger2 = yield* Database6.
|
|
601
|
-
yield* Database6.
|
|
612
|
+
const trigger2 = yield* Database6.resolve(dxn, Trigger6.Trigger);
|
|
613
|
+
yield* Database6.remove(trigger2);
|
|
602
614
|
if (json) {
|
|
603
615
|
yield* Console6.log(JSON.stringify({
|
|
604
616
|
id: trigger2.id,
|
|
@@ -622,8 +634,9 @@ import * as Option6 from "effect/Option";
|
|
|
622
634
|
import { CommandConfig as CommandConfig6 } from "@dxos/cli-util";
|
|
623
635
|
import { flushAndSync as flushAndSync4, print as print5, spaceLayer as spaceLayer6, withTypes as withTypes5 } from "@dxos/cli-util";
|
|
624
636
|
import { Common as Common6 } from "@dxos/cli-util";
|
|
625
|
-
import { DXN as DXN3, Database as Database7, Filter as Filter6,
|
|
626
|
-
import {
|
|
637
|
+
import { DXN as DXN3, Database as Database7, Filter as Filter6, JsonSchema as JsonSchema4, Obj as Obj2, Ref as Ref5 } from "@dxos/echo";
|
|
638
|
+
import { Trigger as Trigger7 } from "@dxos/functions";
|
|
639
|
+
import { Operation as Operation5 } from "@dxos/operation";
|
|
627
640
|
var queue2 = Command7.make("queue", {
|
|
628
641
|
spaceId: Common6.spaceId.pipe(Options7.optional),
|
|
629
642
|
id: TriggerId.pipe(Options7.optional),
|
|
@@ -638,7 +651,7 @@ var queue2 = Command7.make("queue", {
|
|
|
638
651
|
onSome: (id) => Effect7.succeed(id)
|
|
639
652
|
});
|
|
640
653
|
const dxn = DXN3.fromLocalObjectId(triggerId);
|
|
641
|
-
const trigger2 = yield* Database7.
|
|
654
|
+
const trigger2 = yield* Database7.resolve(dxn, Trigger7.Trigger);
|
|
642
655
|
if (trigger2.spec?.kind !== "queue") {
|
|
643
656
|
return yield* Effect7.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
644
657
|
}
|
|
@@ -654,10 +667,10 @@ var queue2 = Command7.make("queue", {
|
|
|
654
667
|
yield* flushAndSync4({
|
|
655
668
|
indexes: true
|
|
656
669
|
});
|
|
657
|
-
})).pipe(Command7.withDescription("Update a queue trigger."), Command7.provide(({ spaceId }) => spaceLayer6(spaceId, true)), Command7.provideEffectDiscard(() => withTypes5(
|
|
670
|
+
})).pipe(Command7.withDescription("Update a queue trigger."), Command7.provide(({ spaceId }) => spaceLayer6(spaceId, true)), Command7.provideEffectDiscard(() => withTypes5(Operation5.PersistentOperation, Trigger7.Trigger)));
|
|
658
671
|
var updateFunction = Effect7.fn(function* (trigger2, functionIdOption) {
|
|
659
|
-
let currentFn = trigger2.function ? yield* Database7.
|
|
660
|
-
if (currentFn && !Obj2.instanceOf(
|
|
672
|
+
let currentFn = trigger2.function ? yield* Database7.load(trigger2.function) : void 0;
|
|
673
|
+
if (currentFn && !Obj2.instanceOf(Operation5.PersistentOperation, currentFn)) {
|
|
661
674
|
currentFn = void 0;
|
|
662
675
|
}
|
|
663
676
|
const currentFunctionName = currentFn ? currentFn.name ?? currentFn.id : void 0;
|
|
@@ -673,13 +686,13 @@ var updateFunction = Effect7.fn(function* (trigger2, functionIdOption) {
|
|
|
673
686
|
onNone: () => selectFunction(),
|
|
674
687
|
onSome: (id) => Effect7.succeed(id)
|
|
675
688
|
});
|
|
676
|
-
const functions = yield* Database7.
|
|
689
|
+
const functions = yield* Database7.runQuery(Filter6.type(Operation5.PersistentOperation));
|
|
677
690
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
678
|
-
if (!foundFn || !Obj2.instanceOf(
|
|
691
|
+
if (!foundFn || !Obj2.instanceOf(Operation5.PersistentOperation, foundFn)) {
|
|
679
692
|
return yield* Effect7.fail(new Error(`Function not found: ${functionId}`));
|
|
680
693
|
}
|
|
681
|
-
Obj2.change(trigger2, (
|
|
682
|
-
|
|
694
|
+
Obj2.change(trigger2, (trigger3) => {
|
|
695
|
+
trigger3.function = Ref5.make(foundFn);
|
|
683
696
|
});
|
|
684
697
|
currentFn = foundFn;
|
|
685
698
|
}
|
|
@@ -704,9 +717,9 @@ var updateQueue = Effect7.fn(function* (trigger2, queueOption) {
|
|
|
704
717
|
onNone: () => selectQueue(),
|
|
705
718
|
onSome: (dxn) => Effect7.succeed(dxn.toString())
|
|
706
719
|
});
|
|
707
|
-
Obj2.change(trigger2, (
|
|
708
|
-
if (
|
|
709
|
-
|
|
720
|
+
Obj2.change(trigger2, (trigger3) => {
|
|
721
|
+
if (trigger3.spec?.kind === "queue") {
|
|
722
|
+
trigger3.spec.queue = queueDxn;
|
|
710
723
|
}
|
|
711
724
|
});
|
|
712
725
|
}
|
|
@@ -726,11 +739,11 @@ var updateInput = Effect7.fn(function* (trigger2, fn6, inputOption) {
|
|
|
726
739
|
});
|
|
727
740
|
if (shouldChangeInput) {
|
|
728
741
|
const inputObj = yield* Option6.match(inputOption, {
|
|
729
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
742
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema4.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
|
|
730
743
|
onSome: (value2) => Effect7.succeed(value2)
|
|
731
744
|
});
|
|
732
|
-
Obj2.change(trigger2, (
|
|
733
|
-
|
|
745
|
+
Obj2.change(trigger2, (trigger3) => {
|
|
746
|
+
trigger3.input = inputObj;
|
|
734
747
|
});
|
|
735
748
|
}
|
|
736
749
|
});
|
|
@@ -742,8 +755,8 @@ var updateEnabled = Effect7.fn(function* (trigger2, idOption, enabled) {
|
|
|
742
755
|
}).pipe(Prompt5.run),
|
|
743
756
|
onSome: () => Effect7.succeed(enabled)
|
|
744
757
|
});
|
|
745
|
-
Obj2.change(trigger2, (
|
|
746
|
-
|
|
758
|
+
Obj2.change(trigger2, (trigger3) => {
|
|
759
|
+
trigger3.enabled = enabledValue;
|
|
747
760
|
});
|
|
748
761
|
});
|
|
749
762
|
|
|
@@ -758,8 +771,9 @@ import * as Option7 from "effect/Option";
|
|
|
758
771
|
import { CommandConfig as CommandConfig7 } from "@dxos/cli-util";
|
|
759
772
|
import { flushAndSync as flushAndSync5, print as print6, spaceLayer as spaceLayer7, withTypes as withTypes6 } from "@dxos/cli-util";
|
|
760
773
|
import { Common as Common7 } from "@dxos/cli-util";
|
|
761
|
-
import { DXN as DXN4, Database as Database8, Filter as Filter7, Obj as Obj3, Query as Query2, Ref as Ref6
|
|
762
|
-
import {
|
|
774
|
+
import { DXN as DXN4, Database as Database8, Filter as Filter7, JsonSchema as JsonSchema5, Obj as Obj3, Query as Query2, Ref as Ref6 } from "@dxos/echo";
|
|
775
|
+
import { Trigger as Trigger8 } from "@dxos/functions";
|
|
776
|
+
import { Operation as Operation6 } from "@dxos/operation";
|
|
763
777
|
var subscription2 = Command8.make("subscription", {
|
|
764
778
|
spaceId: Common7.spaceId.pipe(Options8.optional),
|
|
765
779
|
id: TriggerId.pipe(Options8.optional),
|
|
@@ -776,7 +790,7 @@ var subscription2 = Command8.make("subscription", {
|
|
|
776
790
|
onSome: (id) => Effect8.succeed(id)
|
|
777
791
|
});
|
|
778
792
|
const dxn = DXN4.fromLocalObjectId(triggerId);
|
|
779
|
-
const trigger2 = yield* Database8.
|
|
793
|
+
const trigger2 = yield* Database8.resolve(dxn, Trigger8.Trigger);
|
|
780
794
|
if (trigger2.spec?.kind !== "subscription") {
|
|
781
795
|
return yield* Effect8.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
782
796
|
}
|
|
@@ -792,7 +806,7 @@ var subscription2 = Command8.make("subscription", {
|
|
|
792
806
|
yield* flushAndSync5({
|
|
793
807
|
indexes: true
|
|
794
808
|
});
|
|
795
|
-
})).pipe(Command8.withDescription("Update a subscription trigger."), Command8.provide(({ spaceId }) => spaceLayer7(spaceId, true)), Command8.provideEffectDiscard(() => withTypes6(
|
|
809
|
+
})).pipe(Command8.withDescription("Update a subscription trigger."), Command8.provide(({ spaceId }) => spaceLayer7(spaceId, true)), Command8.provideEffectDiscard(() => withTypes6(Operation6.PersistentOperation, Trigger8.Trigger)));
|
|
796
810
|
var extractCurrentTypename = (spec) => {
|
|
797
811
|
if (!spec?.query?.ast) {
|
|
798
812
|
return Option7.none();
|
|
@@ -804,8 +818,8 @@ var extractCurrentTypename = (spec) => {
|
|
|
804
818
|
}, (f) => Option7.fromNullable(f.typename).pipe(Option7.flatMap((dxn) => Option7.fromNullable(DXN4.tryParse(dxn))), Option7.flatMap((dxn) => Option7.fromNullable(dxn.asTypeDXN()?.type)))), Match2.orElse(() => Option7.none()))), Match2.orElse(() => Option7.none()));
|
|
805
819
|
};
|
|
806
820
|
var updateFunction2 = Effect8.fn(function* (trigger2, functionIdOption) {
|
|
807
|
-
let currentFn = trigger2.function ? yield* Database8.
|
|
808
|
-
if (currentFn && !Obj3.instanceOf(
|
|
821
|
+
let currentFn = trigger2.function ? yield* Database8.load(trigger2.function) : void 0;
|
|
822
|
+
if (currentFn && !Obj3.instanceOf(Operation6.PersistentOperation, currentFn)) {
|
|
809
823
|
currentFn = void 0;
|
|
810
824
|
}
|
|
811
825
|
const currentFunctionName = currentFn ? currentFn.name ?? currentFn.id : void 0;
|
|
@@ -821,13 +835,13 @@ var updateFunction2 = Effect8.fn(function* (trigger2, functionIdOption) {
|
|
|
821
835
|
onNone: () => selectFunction(),
|
|
822
836
|
onSome: (id) => Effect8.succeed(id)
|
|
823
837
|
});
|
|
824
|
-
const functions = yield* Database8.
|
|
838
|
+
const functions = yield* Database8.runQuery(Filter7.type(Operation6.PersistentOperation));
|
|
825
839
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
826
|
-
if (!foundFn || !Obj3.instanceOf(
|
|
840
|
+
if (!foundFn || !Obj3.instanceOf(Operation6.PersistentOperation, foundFn)) {
|
|
827
841
|
return yield* Effect8.fail(new Error(`Function not found: ${functionId}`));
|
|
828
842
|
}
|
|
829
|
-
Obj3.change(trigger2, (
|
|
830
|
-
|
|
843
|
+
Obj3.change(trigger2, (trigger3) => {
|
|
844
|
+
trigger3.function = Ref6.make(foundFn);
|
|
831
845
|
});
|
|
832
846
|
currentFn = foundFn;
|
|
833
847
|
}
|
|
@@ -891,8 +905,8 @@ var updateSpec = Effect8.fn(function* (trigger2, typenameOption, deepOption, del
|
|
|
891
905
|
if (Option7.isSome(delayOptionValue)) {
|
|
892
906
|
subscriptionOptions.delay = delayOptionValue.value;
|
|
893
907
|
}
|
|
894
|
-
Obj3.change(trigger2, (
|
|
895
|
-
const spec =
|
|
908
|
+
Obj3.change(trigger2, (trigger3) => {
|
|
909
|
+
const spec = trigger3.spec;
|
|
896
910
|
if (spec?.kind === "subscription") {
|
|
897
911
|
spec.query = {
|
|
898
912
|
ast: queryAst
|
|
@@ -917,11 +931,11 @@ var updateInput2 = Effect8.fn(function* (trigger2, fn6, inputOption) {
|
|
|
917
931
|
});
|
|
918
932
|
if (shouldChangeInput) {
|
|
919
933
|
const inputObj = yield* Option7.match(inputOption, {
|
|
920
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
934
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema5.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
|
|
921
935
|
onSome: (value2) => Effect8.succeed(value2)
|
|
922
936
|
});
|
|
923
|
-
Obj3.change(trigger2, (
|
|
924
|
-
|
|
937
|
+
Obj3.change(trigger2, (trigger3) => {
|
|
938
|
+
trigger3.input = inputObj;
|
|
925
939
|
});
|
|
926
940
|
}
|
|
927
941
|
});
|
|
@@ -933,8 +947,8 @@ var updateEnabled2 = Effect8.fn(function* (trigger2, idOption, enabled) {
|
|
|
933
947
|
}).pipe(Prompt6.run),
|
|
934
948
|
onSome: () => Effect8.succeed(enabled)
|
|
935
949
|
});
|
|
936
|
-
Obj3.change(trigger2, (
|
|
937
|
-
|
|
950
|
+
Obj3.change(trigger2, (trigger3) => {
|
|
951
|
+
trigger3.enabled = enabledValue;
|
|
938
952
|
});
|
|
939
953
|
});
|
|
940
954
|
|
|
@@ -948,8 +962,9 @@ import * as Option8 from "effect/Option";
|
|
|
948
962
|
import { CommandConfig as CommandConfig8 } from "@dxos/cli-util";
|
|
949
963
|
import { flushAndSync as flushAndSync6, print as print7, spaceLayer as spaceLayer8, withTypes as withTypes7 } from "@dxos/cli-util";
|
|
950
964
|
import { Common as Common8 } from "@dxos/cli-util";
|
|
951
|
-
import { DXN as DXN5, Database as Database9, Filter as Filter8,
|
|
952
|
-
import {
|
|
965
|
+
import { DXN as DXN5, Database as Database9, Filter as Filter8, JsonSchema as JsonSchema6, Obj as Obj4, Ref as Ref7 } from "@dxos/echo";
|
|
966
|
+
import { Trigger as Trigger9 } from "@dxos/functions";
|
|
967
|
+
import { Operation as Operation7 } from "@dxos/operation";
|
|
953
968
|
var timer2 = Command9.make("timer", {
|
|
954
969
|
spaceId: Common8.spaceId.pipe(Options9.optional),
|
|
955
970
|
id: TriggerId.pipe(Options9.optional),
|
|
@@ -964,7 +979,7 @@ var timer2 = Command9.make("timer", {
|
|
|
964
979
|
onSome: (id) => Effect9.succeed(id)
|
|
965
980
|
});
|
|
966
981
|
const dxn = DXN5.fromLocalObjectId(triggerId);
|
|
967
|
-
const trigger2 = yield* Database9.
|
|
982
|
+
const trigger2 = yield* Database9.resolve(dxn, Trigger9.Trigger);
|
|
968
983
|
if (!trigger2.spec || trigger2.spec?.kind !== "timer") {
|
|
969
984
|
return yield* Effect9.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
970
985
|
}
|
|
@@ -980,10 +995,10 @@ var timer2 = Command9.make("timer", {
|
|
|
980
995
|
yield* flushAndSync6({
|
|
981
996
|
indexes: true
|
|
982
997
|
});
|
|
983
|
-
})).pipe(Command9.withDescription("Update a timer trigger."), Command9.provide(({ spaceId }) => spaceLayer8(spaceId, true)), Command9.provideEffectDiscard(() => withTypes7(
|
|
998
|
+
})).pipe(Command9.withDescription("Update a timer trigger."), Command9.provide(({ spaceId }) => spaceLayer8(spaceId, true)), Command9.provideEffectDiscard(() => withTypes7(Operation7.PersistentOperation, Trigger9.Trigger)));
|
|
984
999
|
var updateFunction3 = Effect9.fn(function* (trigger2, functionIdOption) {
|
|
985
|
-
let currentFn = trigger2.function ? yield* Database9.
|
|
986
|
-
if (currentFn && !Obj4.instanceOf(
|
|
1000
|
+
let currentFn = trigger2.function ? yield* Database9.load(trigger2.function) : void 0;
|
|
1001
|
+
if (currentFn && !Obj4.instanceOf(Operation7.PersistentOperation, currentFn)) {
|
|
987
1002
|
currentFn = void 0;
|
|
988
1003
|
}
|
|
989
1004
|
const currentFunctionName = currentFn ? currentFn.name ?? currentFn.id : void 0;
|
|
@@ -999,13 +1014,13 @@ var updateFunction3 = Effect9.fn(function* (trigger2, functionIdOption) {
|
|
|
999
1014
|
onNone: () => selectFunction(),
|
|
1000
1015
|
onSome: (id) => Effect9.succeed(id)
|
|
1001
1016
|
});
|
|
1002
|
-
const functions = yield* Database9.
|
|
1017
|
+
const functions = yield* Database9.runQuery(Filter8.type(Operation7.PersistentOperation));
|
|
1003
1018
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
1004
|
-
if (!foundFn || !Obj4.instanceOf(
|
|
1019
|
+
if (!foundFn || !Obj4.instanceOf(Operation7.PersistentOperation, foundFn)) {
|
|
1005
1020
|
return yield* Effect9.fail(new Error(`Function not found: ${functionId}`));
|
|
1006
1021
|
}
|
|
1007
|
-
Obj4.change(trigger2, (
|
|
1008
|
-
|
|
1022
|
+
Obj4.change(trigger2, (trigger3) => {
|
|
1023
|
+
trigger3.function = Ref7.make(foundFn);
|
|
1009
1024
|
});
|
|
1010
1025
|
currentFn = foundFn;
|
|
1011
1026
|
}
|
|
@@ -1031,9 +1046,9 @@ var updateCron = Effect9.fn(function* (trigger2, cronOption) {
|
|
|
1031
1046
|
}).pipe(Prompt7.run),
|
|
1032
1047
|
onSome: (value2) => Effect9.succeed(value2)
|
|
1033
1048
|
});
|
|
1034
|
-
Obj4.change(trigger2, (
|
|
1035
|
-
if (
|
|
1036
|
-
|
|
1049
|
+
Obj4.change(trigger2, (trigger3) => {
|
|
1050
|
+
if (trigger3.spec?.kind === "timer") {
|
|
1051
|
+
trigger3.spec.cron = cron;
|
|
1037
1052
|
}
|
|
1038
1053
|
});
|
|
1039
1054
|
}
|
|
@@ -1053,11 +1068,11 @@ var updateInput3 = Effect9.fn(function* (trigger2, fn6, inputOption) {
|
|
|
1053
1068
|
});
|
|
1054
1069
|
if (shouldChangeInput) {
|
|
1055
1070
|
const inputObj = yield* Option8.match(inputOption, {
|
|
1056
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
1071
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema6.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
|
|
1057
1072
|
onSome: (value2) => Effect9.succeed(value2)
|
|
1058
1073
|
});
|
|
1059
|
-
Obj4.change(trigger2, (
|
|
1060
|
-
|
|
1074
|
+
Obj4.change(trigger2, (trigger3) => {
|
|
1075
|
+
trigger3.input = inputObj;
|
|
1061
1076
|
});
|
|
1062
1077
|
}
|
|
1063
1078
|
});
|
|
@@ -1069,8 +1084,8 @@ var updateEnabled3 = Effect9.fn(function* (trigger2, idOption, enabled) {
|
|
|
1069
1084
|
}).pipe(Prompt7.run),
|
|
1070
1085
|
onSome: () => Effect9.succeed(enabled)
|
|
1071
1086
|
});
|
|
1072
|
-
Obj4.change(trigger2, (
|
|
1073
|
-
|
|
1087
|
+
Obj4.change(trigger2, (trigger3) => {
|
|
1088
|
+
trigger3.enabled = enabledValue;
|
|
1074
1089
|
});
|
|
1075
1090
|
});
|
|
1076
1091
|
|
|
@@ -1090,7 +1105,7 @@ var trigger = Command11.make("trigger").pipe(Command11.withDescription("Manage E
|
|
|
1090
1105
|
]));
|
|
1091
1106
|
|
|
1092
1107
|
// src/cli/plugin.ts
|
|
1093
|
-
var AutomationPlugin = Plugin.define(meta).pipe(
|
|
1108
|
+
var AutomationPlugin = Plugin.define(meta).pipe(AppPlugin.addCommandModule({
|
|
1094
1109
|
commands: [
|
|
1095
1110
|
trigger
|
|
1096
1111
|
]
|