@dxos/plugin-automation 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/AutomationPanel-IGLIQY2N.mjs +11 -0
- package/dist/lib/browser/AutomationSettings-XGJGVBDD.mjs +37 -0
- package/dist/lib/browser/AutomationSettings-XGJGVBDD.mjs.map +7 -0
- package/dist/lib/browser/FunctionsContainer-R4ZMYSFJ.mjs +43 -0
- package/dist/lib/browser/FunctionsContainer-R4ZMYSFJ.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-ZX4J75UM.mjs → FunctionsPanel-NMA4RYJL.mjs} +3 -3
- package/dist/lib/browser/FunctionsRegistry-TMKAEG5E.mjs +10 -0
- package/dist/lib/browser/TriggerSettings-GW5OEM2G.mjs +11 -0
- package/dist/lib/browser/{app-graph-builder-LAQMEBMH.mjs → app-graph-builder-74ILZP25.mjs} +19 -20
- package/dist/lib/browser/app-graph-builder-74ILZP25.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JOXPQ27I.mjs → chunk-5WMYSXEH.mjs} +7 -7
- package/dist/lib/browser/chunk-5WMYSXEH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BFUIVUQH.mjs → chunk-75XLBFAG.mjs} +11 -16
- package/dist/lib/browser/chunk-75XLBFAG.mjs.map +7 -0
- package/dist/lib/browser/{chunk-QW3EM35H.mjs → chunk-BWEKRPFJ.mjs} +62 -16
- package/dist/lib/browser/chunk-BWEKRPFJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PZNBEKO5.mjs → chunk-EL64ZPPN.mjs} +2 -2
- package/dist/lib/browser/{chunk-PZNBEKO5.mjs.map → chunk-EL64ZPPN.mjs.map} +1 -1
- package/dist/lib/browser/{FunctionsContainer-6QLC7JP4.mjs → chunk-FUVAC5EC.mjs} +15 -48
- package/dist/lib/browser/chunk-FUVAC5EC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BKFQBKYO.mjs → chunk-LHJEQVX5.mjs} +2 -2
- package/dist/lib/browser/{chunk-YWLEY2FD.mjs → chunk-O23LHDEX.mjs} +119 -50
- package/dist/lib/browser/chunk-O23LHDEX.mjs.map +7 -0
- package/dist/lib/browser/chunk-PUYY7B5F.mjs +31 -0
- package/dist/lib/browser/chunk-PUYY7B5F.mjs.map +7 -0
- package/dist/lib/browser/{chunk-RAF2FJST.mjs → chunk-ZBEMNWNY.mjs} +19 -12
- package/dist/lib/browser/chunk-ZBEMNWNY.mjs.map +7 -0
- package/dist/lib/browser/cli/index.mjs +62 -54
- package/dist/lib/browser/cli/index.mjs.map +3 -3
- package/dist/lib/browser/{compute-runtime-WTWLQ67J.mjs → compute-runtime-I3I2BIRE.mjs} +36 -20
- package/dist/lib/browser/compute-runtime-I3I2BIRE.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +3 -3
- package/dist/lib/browser/index.mjs +26 -25
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-Q3MWOR7K.mjs → operation-resolver-NGN4BEWN.mjs} +11 -9
- package/dist/lib/browser/operation-resolver-NGN4BEWN.mjs.map +7 -0
- package/dist/lib/browser/react-surface-SXDIM3RM.mjs +65 -0
- package/dist/lib/browser/react-surface-SXDIM3RM.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{AutomationPanel-B7NAGDFA.mjs → AutomationPanel-O2BCQA7P.mjs} +4 -4
- package/dist/lib/node-esm/AutomationPanel-O2BCQA7P.mjs.map +7 -0
- package/dist/lib/node-esm/AutomationSettings-W52ZO2XI.mjs +38 -0
- package/dist/lib/node-esm/AutomationSettings-W52ZO2XI.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsContainer-GYRPQZM7.mjs +44 -0
- package/dist/lib/node-esm/FunctionsContainer-GYRPQZM7.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-SS6GIVNU.mjs → FunctionsPanel-DCXXLSVP.mjs} +3 -3
- package/dist/lib/node-esm/FunctionsPanel-DCXXLSVP.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsRegistry-7WCHC64E.mjs +11 -0
- package/dist/lib/node-esm/FunctionsRegistry-7WCHC64E.mjs.map +7 -0
- package/dist/lib/node-esm/TriggerSettings-2GKFPECW.mjs +12 -0
- package/dist/lib/node-esm/TriggerSettings-2GKFPECW.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-4UCMXHYY.mjs → app-graph-builder-VDXPOWCH.mjs} +19 -20
- package/dist/lib/node-esm/app-graph-builder-VDXPOWCH.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsContainer-J4O2ULWR.mjs → chunk-6JVB3IHW.mjs} +15 -48
- package/dist/lib/node-esm/chunk-6JVB3IHW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BNWZ2NNI.mjs +32 -0
- package/dist/lib/node-esm/chunk-BNWZ2NNI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-2CKVH7JC.mjs → chunk-FPXVLTEY.mjs} +119 -50
- package/dist/lib/node-esm/chunk-FPXVLTEY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-KWKWOGS5.mjs → chunk-K7T2MVB7.mjs} +11 -16
- package/dist/lib/node-esm/chunk-K7T2MVB7.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LJAXQ6CX.mjs → chunk-Q5JSKD6Z.mjs} +62 -16
- package/dist/lib/node-esm/chunk-Q5JSKD6Z.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-K7GCM342.mjs → chunk-V3VUE2NR.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-5FXNN3MV.mjs → chunk-WC5AT7B3.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-5FXNN3MV.mjs.map → chunk-WC5AT7B3.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-RX52VKI2.mjs → chunk-XCFO2IXT.mjs} +7 -7
- package/dist/lib/node-esm/chunk-XCFO2IXT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HQLVREIX.mjs → chunk-XQO3HK62.mjs} +19 -12
- package/dist/lib/node-esm/chunk-XQO3HK62.mjs.map +7 -0
- package/dist/lib/node-esm/cli/index.mjs +62 -54
- package/dist/lib/node-esm/cli/index.mjs.map +3 -3
- package/dist/lib/node-esm/{compute-runtime-ZHROOBLY.mjs → compute-runtime-7HCSIYFG.mjs} +36 -20
- package/dist/lib/node-esm/compute-runtime-7HCSIYFG.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +3 -3
- package/dist/lib/node-esm/index.mjs +26 -25
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{operation-resolver-R5GA4YNO.mjs → operation-resolver-ANGACQZG.mjs} +11 -9
- package/dist/lib/node-esm/operation-resolver-ANGACQZG.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-S6VZJCEZ.mjs → react-surface-QVLVDEVW.mjs} +25 -25
- package/dist/lib/node-esm/react-surface-QVLVDEVW.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts +1 -1
- package/dist/types/src/capabilities/compute-runtime/compute-runtime.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +1 -1
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/cli/commands/trigger/update/queue.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 +1 -0
- 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.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 +2 -0
- 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 +3 -0
- package/dist/types/src/containers/AutomationSettings/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/FunctionsContainer}/FunctionsContainer.d.ts +0 -1
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts +3 -0
- package/dist/types/src/containers/FunctionsContainer/index.d.ts.map +1 -0
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.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/useTriggerRuntimeControls.d.ts +2 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +3 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +3 -3
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -46
- package/src/AutomationPlugin.tsx +7 -6
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +17 -15
- package/src/capabilities/compute-runtime/compute-runtime.ts +36 -14
- package/src/capabilities/operation-resolver/operation-resolver.ts +7 -6
- package/src/capabilities/react-surface/react-surface.tsx +16 -19
- package/src/cli/commands/trigger/create/queue.ts +4 -4
- package/src/cli/commands/trigger/create/subscription.ts +4 -4
- package/src/cli/commands/trigger/create/timer.ts +4 -4
- package/src/cli/commands/trigger/list.ts +2 -2
- package/src/cli/commands/trigger/remove.ts +2 -2
- package/src/cli/commands/trigger/update/queue.ts +5 -5
- package/src/cli/commands/trigger/update/subscription.ts +5 -5
- package/src/cli/commands/trigger/update/timer.ts +5 -5
- package/src/cli/commands/trigger/util.ts +34 -25
- package/src/cli/plugin.ts +3 -2
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +3 -3
- package/src/components/AutomationPanel/AutomationPanel.tsx +137 -69
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +9 -11
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +9 -10
- package/src/components/FunctionsRegistry/index.ts +4 -1
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +13 -4
- package/src/components/TriggerEditor/SpecSelector.tsx +1 -1
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +46 -4
- package/src/components/TriggerEditor/TriggerEditor.tsx +39 -7
- package/src/components/index.ts +1 -2
- package/src/{components → containers/AutomationSettings}/AutomationSettings.tsx +8 -11
- package/src/containers/AutomationSettings/index.ts +7 -0
- package/src/{components → containers/FunctionsContainer}/FunctionsContainer.tsx +10 -13
- package/src/containers/FunctionsContainer/index.ts +7 -0
- package/src/containers/TriggerSettings/TriggerSettings.tsx +26 -0
- package/src/containers/TriggerSettings/index.ts +6 -0
- package/src/containers/index.ts +9 -0
- package/src/hooks/useComputeRuntimeCallback.ts +1 -1
- package/src/hooks/useTriggerRuntimeControls.ts +22 -8
- package/src/meta.ts +1 -1
- package/src/testing/test-functions.ts +5 -5
- package/src/translations.ts +2 -0
- package/src/types/capabilities.ts +5 -2
- package/src/types/events.ts +1 -1
- package/src/types/schema.ts +3 -3
- 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.map +0 -7
- 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.map +0 -7
- package/dist/lib/browser/chunk-JOXPQ27I.mjs.map +0 -7
- package/dist/lib/browser/chunk-QW3EM35H.mjs.map +0 -7
- package/dist/lib/browser/chunk-RAF2FJST.mjs.map +0 -7
- package/dist/lib/browser/chunk-YWLEY2FD.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-WTWLQ67J.mjs.map +0 -7
- 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/AutomationSettings-M5PMZJ6P.mjs +0 -57
- package/dist/lib/node-esm/AutomationSettings-M5PMZJ6P.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-J4O2ULWR.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-4UCMXHYY.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2CKVH7JC.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.map +0 -7
- package/dist/lib/node-esm/chunk-KWKWOGS5.mjs.map +0 -7
- 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.map +0 -7
- package/dist/lib/node-esm/operation-resolver-R5GA4YNO.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-S6VZJCEZ.mjs.map +0 -7
- 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/components/TriggerSettings.tsx +0 -25
- /package/dist/lib/browser/{AutomationPanel-FAS6ADCW.mjs.map → AutomationPanel-IGLIQY2N.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-ZX4J75UM.mjs.map → FunctionsPanel-NMA4RYJL.mjs.map} +0 -0
- /package/dist/lib/{node-esm/AutomationPanel-B7NAGDFA.mjs.map → browser/FunctionsRegistry-TMKAEG5E.mjs.map} +0 -0
- /package/dist/lib/{node-esm/FunctionsPanel-SS6GIVNU.mjs.map → browser/TriggerSettings-GW5OEM2G.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-BKFQBKYO.mjs.map → chunk-LHJEQVX5.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-K7GCM342.mjs.map → chunk-V3VUE2NR.mjs.map} +0 -0
- /package/dist/types/src/{components → containers/TriggerSettings}/TriggerSettings.d.ts +0 -0
|
@@ -3,7 +3,7 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
3
3
|
// src/meta.ts
|
|
4
4
|
import { trim } from "@dxos/util";
|
|
5
5
|
var meta = {
|
|
6
|
-
id: "dxos.
|
|
6
|
+
id: "org.dxos.plugin.automation",
|
|
7
7
|
name: "Automation",
|
|
8
8
|
description: trim`
|
|
9
9
|
Workflow automation engine that triggers custom actions based on object events and conditions.
|
|
@@ -16,4 +16,4 @@ var meta = {
|
|
|
16
16
|
export {
|
|
17
17
|
meta
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-WC5AT7B3.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'dxos.
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'org.dxos.plugin.automation',\n name: 'Automation',\n description: trim`\n Workflow automation engine that triggers custom actions based on object events and conditions.\n Create automated pipelines that respond to changes and streamline repetitive tasks.\n `,\n icon: 'ph--robot--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',\n};\n"],
|
|
5
5
|
"mappings": ";;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
6
|
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source"]
|
|
7
7
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
meta
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-WC5AT7B3.mjs";
|
|
5
5
|
|
|
6
6
|
// src/types/capabilities.ts
|
|
7
7
|
import { Capability } from "@dxos/app-framework";
|
|
8
8
|
(function(AutomationCapabilities2) {
|
|
9
|
-
AutomationCapabilities2.ComputeRuntime = Capability.make(`${meta.id}
|
|
9
|
+
AutomationCapabilities2.ComputeRuntime = Capability.make(`${meta.id}.capability.compute-runtime`);
|
|
10
10
|
})(AutomationCapabilities || (AutomationCapabilities = {}));
|
|
11
11
|
var AutomationCapabilities;
|
|
12
12
|
|
|
13
13
|
// src/types/events.ts
|
|
14
14
|
import { ActivationEvent } from "@dxos/app-framework";
|
|
15
15
|
(function(AutomationEvents2) {
|
|
16
|
-
AutomationEvents2.ComputeRuntimeReady = ActivationEvent.make(`${meta.id}
|
|
16
|
+
AutomationEvents2.ComputeRuntimeReady = ActivationEvent.make(`${meta.id}.event.compute-runtime-ready`);
|
|
17
17
|
})(AutomationEvents || (AutomationEvents = {}));
|
|
18
18
|
var AutomationEvents;
|
|
19
19
|
|
|
@@ -30,7 +30,7 @@ var TriggerTemplate = Schema.Union(Schema.Struct({
|
|
|
30
30
|
queueDXN: Schema.Any
|
|
31
31
|
}));
|
|
32
32
|
(function(AutomationAction2) {
|
|
33
|
-
class CreateTriggerFromTemplate extends Schema.TaggedClass()(`${meta.id}
|
|
33
|
+
class CreateTriggerFromTemplate extends Schema.TaggedClass()(`${meta.id}.action.create-trigger-from-template`, {
|
|
34
34
|
input: Schema.Struct({
|
|
35
35
|
db: Database.Database,
|
|
36
36
|
template: TriggerTemplate,
|
|
@@ -47,11 +47,11 @@ var TriggerTemplate = Schema.Union(Schema.Struct({
|
|
|
47
47
|
}
|
|
48
48
|
AutomationAction2.CreateTriggerFromTemplate = CreateTriggerFromTemplate;
|
|
49
49
|
})(AutomationAction || (AutomationAction = {}));
|
|
50
|
-
var AUTOMATION_OPERATION = `${meta.id}
|
|
50
|
+
var AUTOMATION_OPERATION = `${meta.id}.operation`;
|
|
51
51
|
(function(AutomationOperation2) {
|
|
52
52
|
AutomationOperation2.CreateTriggerFromTemplate = Operation.make({
|
|
53
53
|
meta: {
|
|
54
|
-
key: `${AUTOMATION_OPERATION}
|
|
54
|
+
key: `${AUTOMATION_OPERATION}.create-trigger-from-template`,
|
|
55
55
|
name: "Create Trigger From Template"
|
|
56
56
|
},
|
|
57
57
|
services: [
|
|
@@ -81,4 +81,4 @@ export {
|
|
|
81
81
|
AutomationAction,
|
|
82
82
|
AutomationOperation
|
|
83
83
|
};
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
84
|
+
//# sourceMappingURL=chunk-XCFO2IXT.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/capabilities.ts", "../../../src/types/events.ts", "../../../src/types/schema.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { type AiService, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';\nimport { Capability } from '@dxos/app-framework';\nimport { type Database, type Feed } from '@dxos/echo';\nimport type { CredentialsService, FunctionInvocationService, QueueService, TracingService } from '@dxos/functions';\nimport type { TriggerDispatcher, TriggerStateStore } from '@dxos/functions-runtime';\nimport type { SpaceId } from '@dxos/keys';\nimport type { Blueprint } from '@dxos/blueprints';\n\nimport { meta } from '../meta';\n\nexport namespace AutomationCapabilities {\n /**\n * Service stack for executing agents, functions, and triggers.\n */\n export type ComputeServices =\n | TriggerDispatcher\n | TriggerStateStore\n | AiService.AiService\n | Database.Service\n | Feed.Service\n | QueueService\n | CredentialsService\n | FunctionInvocationService\n | TracingService\n | Blueprint.RegistryService\n // TODO(dmaretskyi): Those should be provided at AI-chat call site.\n | ToolResolverService\n | ToolExecutionService;\n\n export type ComputeRuntime = ManagedRuntime.ManagedRuntime<AutomationCapabilities.ComputeServices, never>;\n export interface ComputeRuntimeProvider {\n getRuntime(spaceId: SpaceId): ComputeRuntime;\n }\n\n /**\n * Runtime for executing agents, functions, and triggers.\n */\n export const ComputeRuntime = Capability.make<ComputeRuntimeProvider>(`${meta.id}.capability.compute-runtime`);\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { ActivationEvent } from '@dxos/app-framework';\n\nimport { meta } from '../meta';\n\nexport namespace AutomationEvents {\n export const ComputeRuntimeReady = ActivationEvent.make(`${meta.id}.event.compute-runtime-ready`);\n}\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Capability } from '@dxos/app-framework';\nimport { Database } from '@dxos/echo';\nimport { Operation } from '@dxos/operation';\n\nimport { meta } from '../meta';\n\nconst TriggerTemplate = Schema.Union(\n Schema.Struct({ type: Schema.Literal('timer'), cron: Schema.String }),\n Schema.Struct({ type: Schema.Literal('queue'), queueDXN: Schema.Any }),\n);\n\nexport namespace AutomationAction {\n export class CreateTriggerFromTemplate extends Schema.TaggedClass<CreateTriggerFromTemplate>()(\n `${meta.id}.action.create-trigger-from-template`,\n {\n input: Schema.Struct({\n db: Database.Database,\n template: TriggerTemplate,\n enabled: Schema.optional(Schema.Boolean),\n // TODO(wittjosiah): Improve how this lookup is done.\n scriptName: Schema.optional(Schema.String),\n input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n }),\n output: Schema.Void,\n },\n ) {}\n}\n\nconst AUTOMATION_OPERATION = `${meta.id}.operation`;\n\nexport namespace AutomationOperation {\n export const CreateTriggerFromTemplate = Operation.make({\n meta: { key: `${AUTOMATION_OPERATION}.create-trigger-from-template`, name: 'Create Trigger From Template' },\n services: [Capability.Service],\n schema: {\n input: Schema.Struct({\n db: Database.Database,\n template: TriggerTemplate,\n enabled: Schema.optional(Schema.Boolean),\n scriptName: Schema.optional(Schema.String),\n input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n }),\n output: Schema.Void,\n },\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;AAOA,SAASA,kBAAkB;UASVC,yBAAAA;0BA2BFC,iBAAiBC,WAAWC,KAA6B,GAAGC,KAAKC,EAAE,6BAA6B;AAC/G,GA5BiBL,2BAAAA,yBAAAA,CAAAA,EAAAA;;;;ACZjB,SAASM,uBAAuB;UAIfC,mBAAAA;oBACFC,sBAAsBC,gBAAgBC,KAAK,GAAGC,KAAKC,EAAE,8BAA8B;AAClG,GAFiBL,qBAAAA,mBAAAA,CAAAA,EAAAA;;;;ACJjB,YAAYM,YAAY;AAExB,SAASC,cAAAA,mBAAkB;AAC3B,SAASC,gBAAgB;AACzB,SAASC,iBAAiB;AAI1B,IAAMC,kBAAyBC,aACtBC,cAAO;EAAEC,MAAaC,eAAQ,OAAA;EAAUC,MAAaC;AAAO,CAAA,GAC5DJ,cAAO;EAAEC,MAAaC,eAAQ,OAAA;EAAUG,UAAiBC;AAAI,CAAA,CAAA;UAGrDC,mBAAAA;EACR,MAAMC,kCAAyCC,mBAAW,EAC/D,GAAGC,KAAKC,EAAE,wCACV;IACEC,OAAcZ,cAAO;MACnBa,IAAIC,SAASA;MACbC,UAAUjB;MACVkB,SAAgBC,gBAAgBC,cAAO;;MAEvCC,YAAmBF,gBAAgBb,aAAM;MACzCQ,OAAcK,gBAAgBG,cAAO;QAAEC,KAAYjB;QAAQkB,OAAchB;MAAI,CAAA,CAAA;IAC/E,CAAA;IACAiB,QAAeC;EACjB,CAAA,EAAA;EACC;oBAbUhB,4BAAAA;AAcf,GAfiBD,qBAAAA,mBAAAA,CAAAA,EAAAA;AAiBjB,IAAMkB,uBAAuB,GAAGf,KAAKC,EAAE;UAEtBe,sBAAAA;uBACFlB,4BAA4BmB,UAAUC,KAAK;IACtDlB,MAAM;MAAEW,KAAK,GAAGI,oBAAAA;MAAqDI,MAAM;IAA+B;IAC1GC,UAAU;MAACC,YAAWC;;IACtBC,QAAQ;MACNrB,OAAcZ,cAAO;QACnBa,IAAIC,SAASA;QACbC,UAAUjB;QACVkB,SAAgBC,gBAAgBC,cAAO;QACvCC,YAAmBF,gBAAgBb,aAAM;QACzCQ,OAAcK,gBAAgBG,cAAO;UAAEC,KAAYjB;UAAQkB,OAAchB;QAAI,CAAA,CAAA;MAC/E,CAAA;MACAiB,QAAeC;IACjB;EACF,CAAA;AACF,GAfiBE,wBAAAA,sBAAAA,CAAAA,EAAAA;;;",
|
|
6
|
+
"names": ["Capability", "AutomationCapabilities", "ComputeRuntime", "Capability", "make", "meta", "id", "ActivationEvent", "AutomationEvents", "ComputeRuntimeReady", "ActivationEvent", "make", "meta", "id", "Schema", "Capability", "Database", "Operation", "TriggerTemplate", "Union", "Struct", "type", "Literal", "cron", "String", "queueDXN", "Any", "AutomationAction", "CreateTriggerFromTemplate", "TaggedClass", "meta", "id", "input", "db", "Database", "template", "enabled", "optional", "Boolean", "scriptName", "Record", "key", "value", "output", "Void", "AUTOMATION_OPERATION", "AutomationOperation", "Operation", "make", "name", "services", "Capability", "Service", "schema"]
|
|
7
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
AutomationCapabilities
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XCFO2IXT.mjs";
|
|
5
5
|
|
|
6
6
|
// src/hooks/useComputeRuntimeCallback.ts
|
|
7
7
|
import * as Cause from "effect/Cause";
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
9
|
import * as Exit from "effect/Exit";
|
|
10
10
|
import { useCallback } from "react";
|
|
11
|
-
import { useCapability } from "@dxos/app-framework/
|
|
11
|
+
import { useCapability } from "@dxos/app-framework/ui";
|
|
12
12
|
import { FunctionInvocationService, TracingService } from "@dxos/functions";
|
|
13
13
|
import { log } from "@dxos/log";
|
|
14
14
|
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-automation/src/hooks/useComputeRuntimeCallback.ts";
|
|
@@ -52,28 +52,35 @@ var invokeFunctionWithTracing = (functionDef, inputData) => Effect.gen(function*
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
// src/hooks/useTriggerRuntimeControls.ts
|
|
55
|
+
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
55
56
|
import * as Effect2 from "effect/Effect";
|
|
57
|
+
import { useEffect, useState } from "react";
|
|
56
58
|
import { Filter } from "@dxos/echo";
|
|
57
59
|
import { Trigger } from "@dxos/functions";
|
|
58
60
|
import { TriggerDispatcher } from "@dxos/functions-runtime";
|
|
59
61
|
import { useQuery } from "@dxos/react-client/echo";
|
|
60
|
-
import { useAsyncState } from "@dxos/react-ui";
|
|
61
62
|
var useTriggerRuntimeControls = (db) => {
|
|
62
63
|
const triggers = useQuery(db, Filter.type(Trigger.Trigger));
|
|
63
|
-
const [
|
|
64
|
+
const [dispatcher, setDispatcher] = useState(void 0);
|
|
65
|
+
const init = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
|
|
66
|
+
const dispatcher2 = yield* TriggerDispatcher;
|
|
67
|
+
setDispatcher(dispatcher2);
|
|
68
|
+
}));
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
void init();
|
|
71
|
+
}, []);
|
|
72
|
+
const state = useAtomValue(dispatcher?.state ?? Atom.make(void 0));
|
|
64
73
|
const start = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
|
|
65
|
-
const
|
|
66
|
-
yield*
|
|
67
|
-
setIsRunningState(true);
|
|
74
|
+
const dispatcher2 = yield* TriggerDispatcher;
|
|
75
|
+
yield* dispatcher2.start();
|
|
68
76
|
}));
|
|
69
77
|
const stop = useComputeRuntimeCallback(db?.spaceId, Effect2.fnUntraced(function* () {
|
|
70
|
-
const
|
|
71
|
-
yield*
|
|
72
|
-
setIsRunningState(false);
|
|
78
|
+
const dispatcher2 = yield* TriggerDispatcher;
|
|
79
|
+
yield* dispatcher2.stop();
|
|
73
80
|
}));
|
|
74
81
|
return {
|
|
75
82
|
triggers,
|
|
76
|
-
|
|
83
|
+
state,
|
|
77
84
|
start: () => void start(),
|
|
78
85
|
stop: () => void stop()
|
|
79
86
|
};
|
|
@@ -84,4 +91,4 @@ export {
|
|
|
84
91
|
invokeFunctionWithTracing,
|
|
85
92
|
useTriggerRuntimeControls
|
|
86
93
|
};
|
|
87
|
-
//# sourceMappingURL=chunk-
|
|
94
|
+
//# sourceMappingURL=chunk-XQO3HK62.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useComputeRuntimeCallback.ts", "../../../src/hooks/useTriggerRuntimeControls.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport { type DependencyList, useCallback } from 'react';\n\nimport { useCapability } from '@dxos/app-framework/ui';\nimport { type Key } from '@dxos/echo';\nimport { type FunctionDefinition, FunctionInvocationService, TracingService } from '@dxos/functions';\nimport { log } from '@dxos/log';\n\nimport { AutomationCapabilities } from '../types';\n\n/**\n * Create an effectful function that has access to compute services\n */\n// TODO(burdon): Factor out (figure out cross-plugin capabilities dependencies).\nexport const useComputeRuntimeCallback = <T>(\n id: Key.SpaceId | undefined,\n fn: () => Effect.Effect<T, any, AutomationCapabilities.ComputeServices>,\n deps?: DependencyList,\n): (() => Promise<T>) => {\n const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);\n const runtime = id !== undefined ? computeRuntime.getRuntime(id) : undefined;\n\n return useCallback(() => {\n if (!runtime) {\n throw new TypeError('Space not provided to useComputeRuntimeCallback');\n }\n\n return runtime.runPromise(fn());\n }, [runtime, ...(deps ?? [])]);\n};\n\n// TODO(wittjosiah): Function invoking should automatically be traced (DX-647).\nexport const invokeFunctionWithTracing = <I, O>(functionDef: FunctionDefinition<I, O>, inputData: I) =>\n Effect.gen(function* () {\n const tracer = yield* TracingService;\n const trace = yield* tracer.traceInvocationStart({\n target: undefined,\n payload: {\n data: {},\n },\n });\n\n // Invoke the function.\n const result = yield* FunctionInvocationService.invokeFunction(functionDef, inputData).pipe(\n Effect.provide(trace.invocationTraceQueue ? TracingService.layerInvocation(trace) : TracingService.layerNoop),\n Effect.exit,\n );\n\n if (Exit.isFailure(result)) {\n const error = Cause.prettyErrors(result.cause)[0];\n log.error(error.message, error.cause ?? error.stack);\n }\n\n yield* tracer.traceInvocationEnd({\n trace,\n // TODO(dmaretskyi): Might miss errors.\n exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,\n });\n\n return result;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, useAtomValue } from '@effect-atom/atom-react';\nimport type * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\nimport { useEffect, useState } from 'react';\n\nimport { type Database, Filter } from '@dxos/echo';\nimport { Trigger } from '@dxos/functions';\nimport { TriggerDispatcher, type TriggerDispatcherState } from '@dxos/functions-runtime';\nimport { useQuery } from '@dxos/react-client/echo';\n\nimport { useComputeRuntimeCallback } from './useComputeRuntimeCallback';\n\ninterface TriggerRuntimeControls {\n triggers: Trigger.Trigger[];\n\n state: TriggerDispatcherState | undefined;\n\n start: () => void;\n stop: () => void;\n}\n\nexport const useTriggerRuntimeControls = (db: Database.Database | undefined): TriggerRuntimeControls => {\n const triggers = useQuery(db, Filter.type(Trigger.Trigger));\n\n const [dispatcher, setDispatcher] = useState<Context.Tag.Service<TriggerDispatcher> | undefined>(undefined);\n\n const init = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n setDispatcher(dispatcher);\n }),\n );\n\n useEffect(() => {\n void init();\n }, []);\n\n const state = useAtomValue(dispatcher?.state ?? Atom.make(undefined));\n\n const start = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.start();\n }),\n );\n\n const stop = useComputeRuntimeCallback(\n db?.spaceId,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.stop();\n }),\n );\n\n return {\n triggers,\n state,\n start: () => void start(),\n stop: () => void stop(),\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,YAAYA,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,UAAU;AACtB,SAA8BC,mBAAmB;AAEjD,SAASC,qBAAqB;AAE9B,SAAkCC,2BAA2BC,sBAAsB;AACnF,SAASC,WAAW;;AAQb,IAAMC,4BAA4B,CACvCC,IACAC,IACAC,SAAAA;AAEA,QAAMC,iBAAiBC,cAAcC,uBAAuBC,cAAc;AAC1E,QAAMC,UAAUP,OAAOQ,SAAYL,eAAeM,WAAWT,EAAAA,IAAMQ;AAEnE,SAAOE,YAAY,MAAA;AACjB,QAAI,CAACH,SAAS;AACZ,YAAM,IAAII,UAAU,iDAAA;IACtB;AAEA,WAAOJ,QAAQK,WAAWX,GAAAA,CAAAA;EAC5B,GAAG;IAACM;OAAaL,QAAQ,CAAA;GAAI;AAC/B;AAGO,IAAMW,4BAA4B,CAAOC,aAAuCC,cAC9EC,WAAI,aAAA;AACT,QAAMC,SAAS,OAAOC;AACtB,QAAMC,QAAQ,OAAOF,OAAOG,qBAAqB;IAC/CC,QAAQb;IACRc,SAAS;MACPC,MAAM,CAAC;IACT;EACF,CAAA;AAGA,QAAMC,SAAS,OAAOC,0BAA0BC,eAAeZ,aAAaC,SAAAA,EAAWY,KAC9EC,eAAQT,MAAMU,uBAAuBX,eAAeY,gBAAgBX,KAAAA,IAASD,eAAea,SAAS,GACrGC,WAAI;AAGb,MAASC,eAAUT,MAAAA,GAAS;AAC1B,UAAMU,QAAcC,mBAAaX,OAAOY,KAAK,EAAE,CAAA;AAC/CC,QAAIH,MAAMA,MAAMI,SAASJ,MAAME,SAASF,MAAMK,OAAK;;;;;;EACrD;AAEA,SAAOtB,OAAOuB,mBAAmB;IAC/BrB;;IAEAsB,WAAgBR,eAAUT,MAAAA,IAAgBW,mBAAaX,OAAOY,KAAK,EAAE,CAAA,IAAK5B;EAC5E,CAAA;AAEA,SAAOgB;AACT,CAAA;;;AC9DF,SAASkB,MAAMC,oBAAoB;AAEnC,YAAYC,aAAY;AACxB,SAASC,WAAWC,gBAAgB;AAEpC,SAAwBC,cAAc;AACtC,SAASC,eAAe;AACxB,SAASC,yBAAsD;AAC/D,SAASC,gBAAgB;AAalB,IAAMC,4BAA4B,CAACC,OAAAA;AACxC,QAAMC,WAAWC,SAASF,IAAIG,OAAOC,KAAKC,QAAQA,OAAO,CAAA;AAEzD,QAAM,CAACC,YAAYC,aAAAA,IAAiBC,SAA6DC,MAAAA;AAEjG,QAAMC,OAAOC,0BACXX,IAAIY,SACGC,mBAAW,aAAA;AAChB,UAAMP,cAAa,OAAOQ;AAC1BP,kBAAcD,WAAAA;EAChB,CAAA,CAAA;AAGFS,YAAU,MAAA;AACR,SAAKL,KAAAA;EACP,GAAG,CAAA,CAAE;AAEL,QAAMM,QAAQC,aAAaX,YAAYU,SAASE,KAAKC,KAAKV,MAAAA,CAAAA;AAE1D,QAAMW,QAAQT,0BACZX,IAAIY,SACGC,mBAAW,aAAA;AAChB,UAAMP,cAAa,OAAOQ;AAC1B,WAAOR,YAAWc,MAAK;EACzB,CAAA,CAAA;AAGF,QAAMC,OAAOV,0BACXX,IAAIY,SACGC,mBAAW,aAAA;AAChB,UAAMP,cAAa,OAAOQ;AAC1B,WAAOR,YAAWe,KAAI;EACxB,CAAA,CAAA;AAGF,SAAO;IACLpB;IACAe;IACAI,OAAO,MAAM,KAAKA,MAAAA;IAClBC,MAAM,MAAM,KAAKA,KAAAA;EACnB;AACF;",
|
|
6
|
+
"names": ["Cause", "Effect", "Exit", "useCallback", "useCapability", "FunctionInvocationService", "TracingService", "log", "useComputeRuntimeCallback", "id", "fn", "deps", "computeRuntime", "useCapability", "AutomationCapabilities", "ComputeRuntime", "runtime", "undefined", "getRuntime", "useCallback", "TypeError", "runPromise", "invokeFunctionWithTracing", "functionDef", "inputData", "gen", "tracer", "TracingService", "trace", "traceInvocationStart", "target", "payload", "data", "result", "FunctionInvocationService", "invokeFunction", "pipe", "provide", "invocationTraceQueue", "layerInvocation", "layerNoop", "exit", "isFailure", "error", "prettyErrors", "cause", "log", "message", "stack", "traceInvocationEnd", "exception", "Atom", "useAtomValue", "Effect", "useEffect", "useState", "Filter", "Trigger", "TriggerDispatcher", "useQuery", "useTriggerRuntimeControls", "db", "triggers", "useQuery", "Filter", "type", "Trigger", "dispatcher", "setDispatcher", "useState", "undefined", "init", "useComputeRuntimeCallback", "spaceId", "fnUntraced", "TriggerDispatcher", "useEffect", "state", "useAtomValue", "Atom", "make", "start", "stop"]
|
|
7
|
+
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
ComputeRuntime
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-V3VUE2NR.mjs";
|
|
5
5
|
import {
|
|
6
6
|
AutomationEvents
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-XCFO2IXT.mjs";
|
|
8
8
|
import {
|
|
9
9
|
meta
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-WC5AT7B3.mjs";
|
|
11
11
|
|
|
12
12
|
// src/cli/plugin.ts
|
|
13
|
-
import {
|
|
13
|
+
import { Plugin } from "@dxos/app-framework";
|
|
14
|
+
import { AppPlugin } from "@dxos/app-toolkit";
|
|
14
15
|
import { ClientEvents } from "@dxos/plugin-client/types";
|
|
15
16
|
|
|
16
17
|
// src/cli/commands/trigger/index.ts
|
|
@@ -30,7 +31,7 @@ import * as Option2 from "effect/Option";
|
|
|
30
31
|
import { CommandConfig } from "@dxos/cli-util";
|
|
31
32
|
import { flushAndSync, print, spaceLayer, withTypes } from "@dxos/cli-util";
|
|
32
33
|
import { Common } from "@dxos/cli-util";
|
|
33
|
-
import { Database as Database2, Filter as Filter2, Ref as Ref2
|
|
34
|
+
import { Database as Database2, Filter as Filter2, JsonSchema, Ref as Ref2 } from "@dxos/echo";
|
|
34
35
|
import { Function as Function2, Trigger as Trigger2 } from "@dxos/functions";
|
|
35
36
|
|
|
36
37
|
// src/cli/commands/trigger/options.ts
|
|
@@ -63,10 +64,10 @@ import * as Match from "effect/Match";
|
|
|
63
64
|
import * as Option from "effect/Option";
|
|
64
65
|
import * as SchemaAST from "effect/SchemaAST";
|
|
65
66
|
import { FormBuilder } from "@dxos/cli-util";
|
|
66
|
-
import { Annotation, Database, Entity, Filter, Obj, Ref, Type } from "@dxos/echo";
|
|
67
|
+
import { Annotation, Database, Entity, Feed, Filter, Obj, Ref, Type } from "@dxos/echo";
|
|
67
68
|
import { getProperties } from "@dxos/effect";
|
|
68
69
|
import { Function, Trigger } from "@dxos/functions";
|
|
69
|
-
import {
|
|
70
|
+
import { FeedAnnotation } from "@dxos/schema";
|
|
70
71
|
var getTriggerRemoteStatus = (trigger2, remoteCronIds) => {
|
|
71
72
|
if (trigger2.spec?.kind !== "timer") {
|
|
72
73
|
return "n/a";
|
|
@@ -74,7 +75,7 @@ var getTriggerRemoteStatus = (trigger2, remoteCronIds) => {
|
|
|
74
75
|
return remoteCronIds.includes(trigger2.id) ? "available" : "not available";
|
|
75
76
|
};
|
|
76
77
|
var printTrigger = Effect.fn(function* (trigger2, remoteStatus) {
|
|
77
|
-
const fn6 = trigger2.function && (yield* Database.
|
|
78
|
+
const fn6 = trigger2.function && (yield* Database.load(trigger2.function));
|
|
78
79
|
return FormBuilder.make({
|
|
79
80
|
title: trigger2.id
|
|
80
81
|
}).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.dxn?.toString())))), FormBuilder.nestedOption("spec", Option.fromNullable(trigger2.spec).pipe(Option.map(printSpec))), FormBuilder.build);
|
|
@@ -203,7 +204,7 @@ var promptForSchemaInput = Effect.fn(function* (schema, defaults) {
|
|
|
203
204
|
inputObj[key] = templateStr === "" && defaultValue !== void 0 ? defaultValue : templateStr;
|
|
204
205
|
} else {
|
|
205
206
|
const annotation = Annotation.ReferenceAnnotation.getFromAst(propType).pipe(Option.getOrThrow);
|
|
206
|
-
const objects = yield* Database.
|
|
207
|
+
const objects = yield* Database.runQuery(Filter.typename(annotation.typename));
|
|
207
208
|
if (objects.length === 0) {
|
|
208
209
|
inputObj[key] = void 0;
|
|
209
210
|
} else {
|
|
@@ -229,7 +230,7 @@ var promptForSchemaInput = Effect.fn(function* (schema, defaults) {
|
|
|
229
230
|
return inputObj;
|
|
230
231
|
});
|
|
231
232
|
var selectFunction = Effect.fn(function* () {
|
|
232
|
-
const functions = yield* Database.
|
|
233
|
+
const functions = yield* Database.runQuery(Filter.type(Function.Function));
|
|
233
234
|
if (functions.length === 0) {
|
|
234
235
|
return yield* Effect.fail(new Error("No functions available"));
|
|
235
236
|
}
|
|
@@ -244,13 +245,13 @@ var selectFunction = Effect.fn(function* () {
|
|
|
244
245
|
return String(selected);
|
|
245
246
|
});
|
|
246
247
|
var selectTrigger = Effect.fn(function* (kind) {
|
|
247
|
-
const triggers = yield* Database.
|
|
248
|
+
const triggers = yield* Database.runQuery(Filter.type(Trigger.Trigger));
|
|
248
249
|
const filteredTriggers = kind ? triggers.filter((trigger2) => trigger2.spec?.kind === kind) : triggers;
|
|
249
250
|
if (filteredTriggers.length === 0) {
|
|
250
251
|
return yield* Effect.fail(new Error(kind ? `No ${kind} triggers available` : "No triggers available"));
|
|
251
252
|
}
|
|
252
253
|
const choices = yield* Effect.all(filteredTriggers.map((trigger2) => Effect.gen(function* () {
|
|
253
|
-
const fn6 = trigger2.function ? yield* Database.
|
|
254
|
+
const fn6 = trigger2.function ? yield* Database.load(trigger2.function) : void 0;
|
|
254
255
|
const functionName = fn6 && Obj.instanceOf(Function.Function, fn6) ? fn6.name ?? fn6.key ?? fn6.id : void 0;
|
|
255
256
|
const title = functionName ?? trigger2.id;
|
|
256
257
|
const description = `${trigger2.enabled ? "enabled" : "disabled"} - ${trigger2.spec?.kind ?? "unknown"}`;
|
|
@@ -267,35 +268,42 @@ var selectTrigger = Effect.fn(function* (kind) {
|
|
|
267
268
|
return String(selected);
|
|
268
269
|
});
|
|
269
270
|
var selectQueue = Effect.fn(function* () {
|
|
270
|
-
const schemas = yield* Database.
|
|
271
|
+
const schemas = yield* Database.runSchemaQuery({
|
|
271
272
|
location: [
|
|
272
273
|
"database",
|
|
273
274
|
"runtime"
|
|
274
275
|
]
|
|
275
276
|
});
|
|
276
|
-
const
|
|
277
|
-
const annotation =
|
|
277
|
+
const feedSchemas = schemas.filter((schema) => {
|
|
278
|
+
const annotation = FeedAnnotation.get(schema);
|
|
278
279
|
return Option.isSome(annotation) && annotation.value === true;
|
|
279
280
|
});
|
|
280
|
-
if (
|
|
281
|
-
return yield* Effect.fail(new Error("No schemas with
|
|
281
|
+
if (feedSchemas.length === 0) {
|
|
282
|
+
return yield* Effect.fail(new Error("No schemas with Feed annotation found"));
|
|
282
283
|
}
|
|
283
284
|
const queueChoices = [];
|
|
284
|
-
for (const schema of
|
|
285
|
+
for (const schema of feedSchemas) {
|
|
285
286
|
yield* Effect.gen(function* () {
|
|
286
287
|
const typename = Type.getTypename(schema);
|
|
287
|
-
const objects = yield* Database.
|
|
288
|
+
const objects = yield* Database.runQuery(Filter.type(typename));
|
|
288
289
|
for (const obj of objects) {
|
|
289
|
-
const
|
|
290
|
-
if (!
|
|
290
|
+
const feedRef = obj.feed;
|
|
291
|
+
if (!feedRef) {
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
const feedObj = yield* Effect.promise(() => feedRef.tryLoad());
|
|
295
|
+
if (!feedObj || !Obj.instanceOf(Feed.Feed, feedObj)) {
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
const queueDxn = Feed.getQueueDxn(feedObj);
|
|
299
|
+
if (!queueDxn) {
|
|
291
300
|
continue;
|
|
292
301
|
}
|
|
293
|
-
const queueDxn = queueRef.dxn.toString();
|
|
294
302
|
const label = Obj.getLabel(obj) ?? obj.id;
|
|
295
303
|
const description = Obj.getTypename(obj);
|
|
296
304
|
queueChoices.push({
|
|
297
305
|
title: label,
|
|
298
|
-
value: queueDxn,
|
|
306
|
+
value: queueDxn.toString(),
|
|
299
307
|
description
|
|
300
308
|
});
|
|
301
309
|
}
|
|
@@ -327,7 +335,7 @@ var queue = Command.make("queue", {
|
|
|
327
335
|
onNone: () => selectFunction(),
|
|
328
336
|
onSome: (id) => Effect2.succeed(id)
|
|
329
337
|
});
|
|
330
|
-
const functions = yield* Database2.
|
|
338
|
+
const functions = yield* Database2.runQuery(Filter2.type(Function2.Function));
|
|
331
339
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
332
340
|
if (!fn6) {
|
|
333
341
|
return yield* Effect2.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -337,7 +345,7 @@ var queue = Command.make("queue", {
|
|
|
337
345
|
onSome: (dxn) => Effect2.succeed(dxn.toString())
|
|
338
346
|
});
|
|
339
347
|
const input = yield* Option2.match(options.input, {
|
|
340
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
348
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema.toEffectSchema(fn6.inputSchema) : void 0),
|
|
341
349
|
onSome: (value2) => Effect2.succeed(Object.fromEntries(HashMap.toEntries(value2)))
|
|
342
350
|
});
|
|
343
351
|
const enabled = yield* Option2.match(options.functionId, {
|
|
@@ -356,7 +364,7 @@ var queue = Command.make("queue", {
|
|
|
356
364
|
},
|
|
357
365
|
input
|
|
358
366
|
});
|
|
359
|
-
yield* Database2.
|
|
367
|
+
yield* Database2.add(trigger2);
|
|
360
368
|
if (json) {
|
|
361
369
|
yield* Console2.log(JSON.stringify(trigger2, null, 2));
|
|
362
370
|
} else {
|
|
@@ -378,7 +386,7 @@ import * as Option3 from "effect/Option";
|
|
|
378
386
|
import { CommandConfig as CommandConfig2 } from "@dxos/cli-util";
|
|
379
387
|
import { flushAndSync as flushAndSync2, print as print2, spaceLayer as spaceLayer2, withTypes as withTypes2 } from "@dxos/cli-util";
|
|
380
388
|
import { Common as Common2 } from "@dxos/cli-util";
|
|
381
|
-
import { Database as Database3, Filter as Filter3, Query, Ref as Ref3
|
|
389
|
+
import { Database as Database3, Filter as Filter3, JsonSchema as JsonSchema2, Query, Ref as Ref3 } from "@dxos/echo";
|
|
382
390
|
import { Function as Function3, Trigger as Trigger3 } from "@dxos/functions";
|
|
383
391
|
var subscription = Command2.make("subscription", {
|
|
384
392
|
spaceId: Common2.spaceId.pipe(Options3.optional),
|
|
@@ -394,7 +402,7 @@ var subscription = Command2.make("subscription", {
|
|
|
394
402
|
onNone: () => selectFunction(),
|
|
395
403
|
onSome: (id) => Effect3.succeed(id)
|
|
396
404
|
});
|
|
397
|
-
const functions = yield* Database3.
|
|
405
|
+
const functions = yield* Database3.runQuery(Filter3.type(Function3.Function));
|
|
398
406
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
399
407
|
if (!fn6) {
|
|
400
408
|
return yield* Effect3.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -430,7 +438,7 @@ var subscription = Command2.make("subscription", {
|
|
|
430
438
|
subscriptionOptions.delay = delayOption.value;
|
|
431
439
|
}
|
|
432
440
|
const input = yield* Option3.match(options.input, {
|
|
433
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
441
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema2.toEffectSchema(fn6.inputSchema) : void 0),
|
|
434
442
|
onSome: (value2) => Effect3.succeed(Object.fromEntries(HashMap2.toEntries(value2)))
|
|
435
443
|
});
|
|
436
444
|
const enabled = yield* Option3.match(options.functionId, {
|
|
@@ -452,7 +460,7 @@ var subscription = Command2.make("subscription", {
|
|
|
452
460
|
},
|
|
453
461
|
input
|
|
454
462
|
});
|
|
455
|
-
yield* Database3.
|
|
463
|
+
yield* Database3.add(trigger2);
|
|
456
464
|
if (json) {
|
|
457
465
|
yield* Console3.log(JSON.stringify(trigger2, null, 2));
|
|
458
466
|
} else {
|
|
@@ -474,7 +482,7 @@ import * as Option4 from "effect/Option";
|
|
|
474
482
|
import { CommandConfig as CommandConfig3 } from "@dxos/cli-util";
|
|
475
483
|
import { flushAndSync as flushAndSync3, print as print3, spaceLayer as spaceLayer3, withTypes as withTypes3 } from "@dxos/cli-util";
|
|
476
484
|
import { Common as Common3 } from "@dxos/cli-util";
|
|
477
|
-
import { Database as Database4, Filter as Filter4,
|
|
485
|
+
import { Database as Database4, Filter as Filter4, JsonSchema as JsonSchema3, Ref as Ref4 } from "@dxos/echo";
|
|
478
486
|
import { Function as Function4, Trigger as Trigger4 } from "@dxos/functions";
|
|
479
487
|
var timer = Command3.make("timer", {
|
|
480
488
|
spaceId: Common3.spaceId.pipe(Options4.optional),
|
|
@@ -488,7 +496,7 @@ var timer = Command3.make("timer", {
|
|
|
488
496
|
onNone: () => selectFunction(),
|
|
489
497
|
onSome: (id) => Effect4.succeed(id)
|
|
490
498
|
});
|
|
491
|
-
const functions = yield* Database4.
|
|
499
|
+
const functions = yield* Database4.runQuery(Filter4.type(Function4.Function));
|
|
492
500
|
const fn6 = functions.find((fn7) => fn7.id === functionId);
|
|
493
501
|
if (!fn6) {
|
|
494
502
|
return yield* Effect4.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -500,7 +508,7 @@ var timer = Command3.make("timer", {
|
|
|
500
508
|
onSome: (value2) => Effect4.succeed(value2)
|
|
501
509
|
});
|
|
502
510
|
const input = yield* Option4.match(options.input, {
|
|
503
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
511
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema3.toEffectSchema(fn6.inputSchema) : void 0),
|
|
504
512
|
onSome: (value2) => Effect4.succeed(Object.fromEntries(HashMap3.toEntries(value2)))
|
|
505
513
|
});
|
|
506
514
|
const enabled = yield* Option4.match(options.functionId, {
|
|
@@ -519,7 +527,7 @@ var timer = Command3.make("timer", {
|
|
|
519
527
|
},
|
|
520
528
|
input
|
|
521
529
|
});
|
|
522
|
-
yield* Database4.
|
|
530
|
+
yield* Database4.add(trigger2);
|
|
523
531
|
if (json) {
|
|
524
532
|
yield* Console4.log(JSON.stringify(trigger2, null, 2));
|
|
525
533
|
} else {
|
|
@@ -550,11 +558,11 @@ var list = Command5.make("list", {
|
|
|
550
558
|
spaceId: Common4.spaceId.pipe(Options5.optional)
|
|
551
559
|
}, Effect5.fn(function* ({ spaceId: spaceIdOption }) {
|
|
552
560
|
const { json } = yield* CommandConfig4;
|
|
553
|
-
const triggers = yield* Database5.
|
|
561
|
+
const triggers = yield* Database5.runQuery(Filter5.type(Trigger5.Trigger));
|
|
554
562
|
const remoteCronIds = yield* Effect5.gen(function* () {
|
|
555
563
|
const client = yield* ClientService;
|
|
556
564
|
const spaceId = yield* spaceIdWithDefault(spaceIdOption);
|
|
557
|
-
const result = yield* Effect5.promise(() => client.edge.getCronTriggers(spaceId)).pipe(Effect5.catchAll(() => Effect5.succeed({
|
|
565
|
+
const result = yield* Effect5.promise(() => client.edge.http.getCronTriggers(spaceId)).pipe(Effect5.catchAll(() => Effect5.succeed({
|
|
558
566
|
cronIds: []
|
|
559
567
|
})));
|
|
560
568
|
return result.cronIds;
|
|
@@ -598,8 +606,8 @@ var remove = Command6.make("remove", {
|
|
|
598
606
|
onSome: (id) => Effect6.succeed(id)
|
|
599
607
|
});
|
|
600
608
|
const dxn = DXN2.fromLocalObjectId(triggerId);
|
|
601
|
-
const trigger2 = yield* Database6.
|
|
602
|
-
yield* Database6.
|
|
609
|
+
const trigger2 = yield* Database6.resolve(dxn, Trigger6.Trigger);
|
|
610
|
+
yield* Database6.remove(trigger2);
|
|
603
611
|
if (json) {
|
|
604
612
|
yield* Console6.log(JSON.stringify({
|
|
605
613
|
id: trigger2.id,
|
|
@@ -623,7 +631,7 @@ import * as Option6 from "effect/Option";
|
|
|
623
631
|
import { CommandConfig as CommandConfig6 } from "@dxos/cli-util";
|
|
624
632
|
import { flushAndSync as flushAndSync4, print as print5, spaceLayer as spaceLayer6, withTypes as withTypes5 } from "@dxos/cli-util";
|
|
625
633
|
import { Common as Common6 } from "@dxos/cli-util";
|
|
626
|
-
import { DXN as DXN3, Database as Database7, Filter as Filter6,
|
|
634
|
+
import { DXN as DXN3, Database as Database7, Filter as Filter6, JsonSchema as JsonSchema4, Obj as Obj2, Ref as Ref5 } from "@dxos/echo";
|
|
627
635
|
import { Function as Function5, Trigger as Trigger7 } from "@dxos/functions";
|
|
628
636
|
var queue2 = Command7.make("queue", {
|
|
629
637
|
spaceId: Common6.spaceId.pipe(Options7.optional),
|
|
@@ -639,7 +647,7 @@ var queue2 = Command7.make("queue", {
|
|
|
639
647
|
onSome: (id) => Effect7.succeed(id)
|
|
640
648
|
});
|
|
641
649
|
const dxn = DXN3.fromLocalObjectId(triggerId);
|
|
642
|
-
const trigger2 = yield* Database7.
|
|
650
|
+
const trigger2 = yield* Database7.resolve(dxn, Trigger7.Trigger);
|
|
643
651
|
if (trigger2.spec?.kind !== "queue") {
|
|
644
652
|
return yield* Effect7.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
645
653
|
}
|
|
@@ -657,7 +665,7 @@ var queue2 = Command7.make("queue", {
|
|
|
657
665
|
});
|
|
658
666
|
})).pipe(Command7.withDescription("Update a queue trigger."), Command7.provide(({ spaceId }) => spaceLayer6(spaceId, true)), Command7.provideEffectDiscard(() => withTypes5(Function5.Function, Trigger7.Trigger)));
|
|
659
667
|
var updateFunction = Effect7.fn(function* (trigger2, functionIdOption) {
|
|
660
|
-
let currentFn = trigger2.function ? yield* Database7.
|
|
668
|
+
let currentFn = trigger2.function ? yield* Database7.load(trigger2.function) : void 0;
|
|
661
669
|
if (currentFn && !Obj2.instanceOf(Function5.Function, currentFn)) {
|
|
662
670
|
currentFn = void 0;
|
|
663
671
|
}
|
|
@@ -674,7 +682,7 @@ var updateFunction = Effect7.fn(function* (trigger2, functionIdOption) {
|
|
|
674
682
|
onNone: () => selectFunction(),
|
|
675
683
|
onSome: (id) => Effect7.succeed(id)
|
|
676
684
|
});
|
|
677
|
-
const functions = yield* Database7.
|
|
685
|
+
const functions = yield* Database7.runQuery(Filter6.type(Function5.Function));
|
|
678
686
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
679
687
|
if (!foundFn || !Obj2.instanceOf(Function5.Function, foundFn)) {
|
|
680
688
|
return yield* Effect7.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -727,7 +735,7 @@ var updateInput = Effect7.fn(function* (trigger2, fn6, inputOption) {
|
|
|
727
735
|
});
|
|
728
736
|
if (shouldChangeInput) {
|
|
729
737
|
const inputObj = yield* Option6.match(inputOption, {
|
|
730
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
738
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema4.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
|
|
731
739
|
onSome: (value2) => Effect7.succeed(value2)
|
|
732
740
|
});
|
|
733
741
|
Obj2.change(trigger2, (mutableTrigger) => {
|
|
@@ -759,7 +767,7 @@ import * as Option7 from "effect/Option";
|
|
|
759
767
|
import { CommandConfig as CommandConfig7 } from "@dxos/cli-util";
|
|
760
768
|
import { flushAndSync as flushAndSync5, print as print6, spaceLayer as spaceLayer7, withTypes as withTypes6 } from "@dxos/cli-util";
|
|
761
769
|
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
|
|
770
|
+
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";
|
|
763
771
|
import { Function as Function6, Trigger as Trigger8 } from "@dxos/functions";
|
|
764
772
|
var subscription2 = Command8.make("subscription", {
|
|
765
773
|
spaceId: Common7.spaceId.pipe(Options8.optional),
|
|
@@ -777,7 +785,7 @@ var subscription2 = Command8.make("subscription", {
|
|
|
777
785
|
onSome: (id) => Effect8.succeed(id)
|
|
778
786
|
});
|
|
779
787
|
const dxn = DXN4.fromLocalObjectId(triggerId);
|
|
780
|
-
const trigger2 = yield* Database8.
|
|
788
|
+
const trigger2 = yield* Database8.resolve(dxn, Trigger8.Trigger);
|
|
781
789
|
if (trigger2.spec?.kind !== "subscription") {
|
|
782
790
|
return yield* Effect8.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
783
791
|
}
|
|
@@ -805,7 +813,7 @@ var extractCurrentTypename = (spec) => {
|
|
|
805
813
|
}, (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
814
|
};
|
|
807
815
|
var updateFunction2 = Effect8.fn(function* (trigger2, functionIdOption) {
|
|
808
|
-
let currentFn = trigger2.function ? yield* Database8.
|
|
816
|
+
let currentFn = trigger2.function ? yield* Database8.load(trigger2.function) : void 0;
|
|
809
817
|
if (currentFn && !Obj3.instanceOf(Function6.Function, currentFn)) {
|
|
810
818
|
currentFn = void 0;
|
|
811
819
|
}
|
|
@@ -822,7 +830,7 @@ var updateFunction2 = Effect8.fn(function* (trigger2, functionIdOption) {
|
|
|
822
830
|
onNone: () => selectFunction(),
|
|
823
831
|
onSome: (id) => Effect8.succeed(id)
|
|
824
832
|
});
|
|
825
|
-
const functions = yield* Database8.
|
|
833
|
+
const functions = yield* Database8.runQuery(Filter7.type(Function6.Function));
|
|
826
834
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
827
835
|
if (!foundFn || !Obj3.instanceOf(Function6.Function, foundFn)) {
|
|
828
836
|
return yield* Effect8.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -918,7 +926,7 @@ var updateInput2 = Effect8.fn(function* (trigger2, fn6, inputOption) {
|
|
|
918
926
|
});
|
|
919
927
|
if (shouldChangeInput) {
|
|
920
928
|
const inputObj = yield* Option7.match(inputOption, {
|
|
921
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
929
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema5.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
|
|
922
930
|
onSome: (value2) => Effect8.succeed(value2)
|
|
923
931
|
});
|
|
924
932
|
Obj3.change(trigger2, (mutableTrigger) => {
|
|
@@ -949,7 +957,7 @@ import * as Option8 from "effect/Option";
|
|
|
949
957
|
import { CommandConfig as CommandConfig8 } from "@dxos/cli-util";
|
|
950
958
|
import { flushAndSync as flushAndSync6, print as print7, spaceLayer as spaceLayer8, withTypes as withTypes7 } from "@dxos/cli-util";
|
|
951
959
|
import { Common as Common8 } from "@dxos/cli-util";
|
|
952
|
-
import { DXN as DXN5, Database as Database9, Filter as Filter8,
|
|
960
|
+
import { DXN as DXN5, Database as Database9, Filter as Filter8, JsonSchema as JsonSchema6, Obj as Obj4, Ref as Ref7 } from "@dxos/echo";
|
|
953
961
|
import { Function as Function7, Trigger as Trigger9 } from "@dxos/functions";
|
|
954
962
|
var timer2 = Command9.make("timer", {
|
|
955
963
|
spaceId: Common8.spaceId.pipe(Options9.optional),
|
|
@@ -965,7 +973,7 @@ var timer2 = Command9.make("timer", {
|
|
|
965
973
|
onSome: (id) => Effect9.succeed(id)
|
|
966
974
|
});
|
|
967
975
|
const dxn = DXN5.fromLocalObjectId(triggerId);
|
|
968
|
-
const trigger2 = yield* Database9.
|
|
976
|
+
const trigger2 = yield* Database9.resolve(dxn, Trigger9.Trigger);
|
|
969
977
|
if (!trigger2.spec || trigger2.spec?.kind !== "timer") {
|
|
970
978
|
return yield* Effect9.fail(new Error(`Invalid trigger type: ${trigger2.spec?.kind}`));
|
|
971
979
|
}
|
|
@@ -983,7 +991,7 @@ var timer2 = Command9.make("timer", {
|
|
|
983
991
|
});
|
|
984
992
|
})).pipe(Command9.withDescription("Update a timer trigger."), Command9.provide(({ spaceId }) => spaceLayer8(spaceId, true)), Command9.provideEffectDiscard(() => withTypes7(Function7.Function, Trigger9.Trigger)));
|
|
985
993
|
var updateFunction3 = Effect9.fn(function* (trigger2, functionIdOption) {
|
|
986
|
-
let currentFn = trigger2.function ? yield* Database9.
|
|
994
|
+
let currentFn = trigger2.function ? yield* Database9.load(trigger2.function) : void 0;
|
|
987
995
|
if (currentFn && !Obj4.instanceOf(Function7.Function, currentFn)) {
|
|
988
996
|
currentFn = void 0;
|
|
989
997
|
}
|
|
@@ -1000,7 +1008,7 @@ var updateFunction3 = Effect9.fn(function* (trigger2, functionIdOption) {
|
|
|
1000
1008
|
onNone: () => selectFunction(),
|
|
1001
1009
|
onSome: (id) => Effect9.succeed(id)
|
|
1002
1010
|
});
|
|
1003
|
-
const functions = yield* Database9.
|
|
1011
|
+
const functions = yield* Database9.runQuery(Filter8.type(Function7.Function));
|
|
1004
1012
|
const foundFn = functions.find((fn6) => fn6.id === functionId);
|
|
1005
1013
|
if (!foundFn || !Obj4.instanceOf(Function7.Function, foundFn)) {
|
|
1006
1014
|
return yield* Effect9.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -1054,7 +1062,7 @@ var updateInput3 = Effect9.fn(function* (trigger2, fn6, inputOption) {
|
|
|
1054
1062
|
});
|
|
1055
1063
|
if (shouldChangeInput) {
|
|
1056
1064
|
const inputObj = yield* Option8.match(inputOption, {
|
|
1057
|
-
onNone: () => promptForSchemaInput(fn6.inputSchema ?
|
|
1065
|
+
onNone: () => promptForSchemaInput(fn6.inputSchema ? JsonSchema6.toEffectSchema(fn6.inputSchema) : void 0, currentInput),
|
|
1058
1066
|
onSome: (value2) => Effect9.succeed(value2)
|
|
1059
1067
|
});
|
|
1060
1068
|
Obj4.change(trigger2, (mutableTrigger) => {
|
|
@@ -1091,7 +1099,7 @@ var trigger = Command11.make("trigger").pipe(Command11.withDescription("Manage E
|
|
|
1091
1099
|
]));
|
|
1092
1100
|
|
|
1093
1101
|
// src/cli/plugin.ts
|
|
1094
|
-
var AutomationPlugin = Plugin.define(meta).pipe(
|
|
1102
|
+
var AutomationPlugin = Plugin.define(meta).pipe(AppPlugin.addCommandModule({
|
|
1095
1103
|
commands: [
|
|
1096
1104
|
trigger
|
|
1097
1105
|
]
|