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