@dxos/plugin-automation 0.8.4-main.937b3ca → 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 +204 -2
- 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
|
@@ -13,8 +13,9 @@ import * as Option from 'effect/Option';
|
|
|
13
13
|
import { CommandConfig } from '@dxos/cli-util';
|
|
14
14
|
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
15
15
|
import { Common } from '@dxos/cli-util';
|
|
16
|
-
import { Database, Filter, Query, Ref
|
|
17
|
-
import {
|
|
16
|
+
import { Database, Filter, JsonSchema, Query, Ref } from '@dxos/echo';
|
|
17
|
+
import { Trigger } from '@dxos/functions';
|
|
18
|
+
import { Operation } from '@dxos/operation';
|
|
18
19
|
|
|
19
20
|
import { Deep, Delay, Enabled, Input, Typename } from '../options';
|
|
20
21
|
import { printTrigger, promptForSchemaInput, selectFunction } from '../util';
|
|
@@ -38,7 +39,7 @@ export const subscription = Command.make(
|
|
|
38
39
|
onNone: () => selectFunction(),
|
|
39
40
|
onSome: (id) => Effect.succeed(id),
|
|
40
41
|
});
|
|
41
|
-
const functions = yield* Database.
|
|
42
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
42
43
|
const fn = functions.find((fn) => fn.id === functionId);
|
|
43
44
|
if (!fn) {
|
|
44
45
|
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -85,7 +86,7 @@ export const subscription = Command.make(
|
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
const input = yield* Option.match(options.input, {
|
|
88
|
-
onNone: () => promptForSchemaInput(fn.inputSchema ?
|
|
89
|
+
onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
|
|
89
90
|
onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
|
|
90
91
|
});
|
|
91
92
|
|
|
@@ -111,7 +112,7 @@ export const subscription = Command.make(
|
|
|
111
112
|
},
|
|
112
113
|
input,
|
|
113
114
|
});
|
|
114
|
-
yield* Database.
|
|
115
|
+
yield* Database.add(trigger);
|
|
115
116
|
|
|
116
117
|
if (json) {
|
|
117
118
|
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
@@ -124,5 +125,5 @@ export const subscription = Command.make(
|
|
|
124
125
|
).pipe(
|
|
125
126
|
Command.withDescription('Create a subscription trigger.'),
|
|
126
127
|
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
127
|
-
Command.provideEffectDiscard(() => withTypes(
|
|
128
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
128
129
|
);
|
|
@@ -13,8 +13,9 @@ import * as Option from 'effect/Option';
|
|
|
13
13
|
import { CommandConfig } from '@dxos/cli-util';
|
|
14
14
|
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
15
15
|
import { Common } from '@dxos/cli-util';
|
|
16
|
-
import { Database, Filter,
|
|
17
|
-
import {
|
|
16
|
+
import { Database, Filter, JsonSchema, Ref } from '@dxos/echo';
|
|
17
|
+
import { Trigger } from '@dxos/functions';
|
|
18
|
+
import { Operation } from '@dxos/operation';
|
|
18
19
|
|
|
19
20
|
import { Cron, Enabled, Input } from '../options';
|
|
20
21
|
import { printTrigger, promptForSchemaInput, selectFunction } from '../util';
|
|
@@ -37,7 +38,7 @@ export const timer = Command.make(
|
|
|
37
38
|
onNone: () => selectFunction(),
|
|
38
39
|
onSome: (id) => Effect.succeed(id),
|
|
39
40
|
});
|
|
40
|
-
const functions = yield* Database.
|
|
41
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
41
42
|
const fn = functions.find((fn) => fn.id === functionId);
|
|
42
43
|
if (!fn) {
|
|
43
44
|
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
@@ -52,7 +53,7 @@ export const timer = Command.make(
|
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
const input = yield* Option.match(options.input, {
|
|
55
|
-
onNone: () => promptForSchemaInput(fn.inputSchema ?
|
|
56
|
+
onNone: () => promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined),
|
|
56
57
|
onSome: (value) => Effect.succeed(Object.fromEntries(HashMap.toEntries(value))),
|
|
57
58
|
});
|
|
58
59
|
|
|
@@ -76,7 +77,7 @@ export const timer = Command.make(
|
|
|
76
77
|
input,
|
|
77
78
|
});
|
|
78
79
|
|
|
79
|
-
yield* Database.
|
|
80
|
+
yield* Database.add(trigger);
|
|
80
81
|
|
|
81
82
|
if (json) {
|
|
82
83
|
yield* Console.log(JSON.stringify(trigger, null, 2));
|
|
@@ -89,5 +90,5 @@ export const timer = Command.make(
|
|
|
89
90
|
).pipe(
|
|
90
91
|
Command.withDescription('Create a timer trigger.'),
|
|
91
92
|
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
92
|
-
Command.provideEffectDiscard(() => withTypes(
|
|
93
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
93
94
|
);
|
|
@@ -9,6 +9,7 @@ import * as Effect from 'effect/Effect';
|
|
|
9
9
|
|
|
10
10
|
import { CommandConfig, Common, printList, spaceIdWithDefault, spaceLayer } from '@dxos/cli-util';
|
|
11
11
|
import { ClientService } from '@dxos/client';
|
|
12
|
+
import { Context } from '@dxos/context';
|
|
12
13
|
import { Database, Filter } from '@dxos/echo';
|
|
13
14
|
import { Trigger } from '@dxos/functions';
|
|
14
15
|
|
|
@@ -23,13 +24,13 @@ export const list = Command.make(
|
|
|
23
24
|
const { json } = yield* CommandConfig;
|
|
24
25
|
|
|
25
26
|
// Fetch local triggers
|
|
26
|
-
const triggers = yield* Database.
|
|
27
|
+
const triggers = yield* Database.runQuery(Filter.type(Trigger.Trigger));
|
|
27
28
|
|
|
28
29
|
// Fetch remote cron triggers to check availability
|
|
29
30
|
const remoteCronIds = yield* Effect.gen(function* () {
|
|
30
31
|
const client = yield* ClientService;
|
|
31
32
|
const spaceId = yield* spaceIdWithDefault(spaceIdOption);
|
|
32
|
-
const result = yield* Effect.promise(() => client.edge.getCronTriggers(spaceId)).pipe(
|
|
33
|
+
const result = yield* Effect.promise(() => client.edge.http.getCronTriggers(Context.default(), spaceId)).pipe(
|
|
33
34
|
Effect.catchAll(() => Effect.succeed({ cronIds: [] })),
|
|
34
35
|
);
|
|
35
36
|
return result.cronIds;
|
|
@@ -30,8 +30,8 @@ export const remove = Command.make(
|
|
|
30
30
|
onSome: (id) => Effect.succeed(id),
|
|
31
31
|
});
|
|
32
32
|
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
33
|
-
const trigger = yield* Database.
|
|
34
|
-
yield* Database.
|
|
33
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
34
|
+
yield* Database.remove(trigger);
|
|
35
35
|
if (json) {
|
|
36
36
|
yield* Console.log(JSON.stringify({ id: trigger.id, removed: true }, null, 2));
|
|
37
37
|
} else {
|
|
@@ -12,8 +12,9 @@ import * as Option from 'effect/Option';
|
|
|
12
12
|
import { CommandConfig } from '@dxos/cli-util';
|
|
13
13
|
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
14
14
|
import { Common } from '@dxos/cli-util';
|
|
15
|
-
import { DXN, Database, Filter, Obj, Ref
|
|
16
|
-
import {
|
|
15
|
+
import { DXN, Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
16
|
+
import { Trigger } from '@dxos/functions';
|
|
17
|
+
import { Operation } from '@dxos/operation';
|
|
17
18
|
|
|
18
19
|
import { Enabled, Input, Queue, TriggerId } from '../options';
|
|
19
20
|
import { printTrigger, promptForSchemaInput, selectFunction, selectQueue, selectTrigger } from '../util';
|
|
@@ -31,13 +32,12 @@ export const queue = Command.make(
|
|
|
31
32
|
(options) =>
|
|
32
33
|
Effect.gen(function* () {
|
|
33
34
|
const { json } = yield* CommandConfig;
|
|
34
|
-
|
|
35
35
|
const triggerId = yield* Option.match(options.id, {
|
|
36
36
|
onNone: () => selectTrigger('queue'),
|
|
37
37
|
onSome: (id) => Effect.succeed(id),
|
|
38
38
|
});
|
|
39
39
|
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
40
|
-
const trigger = yield* Database.
|
|
40
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
41
41
|
if (trigger.spec?.kind !== 'queue') {
|
|
42
42
|
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
43
43
|
}
|
|
@@ -58,7 +58,7 @@ export const queue = Command.make(
|
|
|
58
58
|
).pipe(
|
|
59
59
|
Command.withDescription('Update a queue trigger.'),
|
|
60
60
|
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
61
|
-
Command.provideEffectDiscard(() => withTypes(
|
|
61
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
/**
|
|
@@ -67,10 +67,10 @@ export const queue = Command.make(
|
|
|
67
67
|
* @returns The current function (either original or newly assigned)
|
|
68
68
|
*/
|
|
69
69
|
const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
|
|
70
|
-
let currentFn:
|
|
71
|
-
? yield* Database.
|
|
70
|
+
let currentFn: Operation.PersistentOperation | undefined = trigger.function
|
|
71
|
+
? yield* Database.load(trigger.function) as any
|
|
72
72
|
: undefined;
|
|
73
|
-
if (currentFn && !Obj.instanceOf(
|
|
73
|
+
if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, currentFn)) {
|
|
74
74
|
currentFn = undefined;
|
|
75
75
|
}
|
|
76
76
|
const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
|
|
@@ -87,13 +87,13 @@ const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionId
|
|
|
87
87
|
onNone: () => selectFunction(),
|
|
88
88
|
onSome: (id) => Effect.succeed(id),
|
|
89
89
|
});
|
|
90
|
-
const functions = yield* Database.
|
|
90
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
91
91
|
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
92
|
-
if (!foundFn || !Obj.instanceOf(
|
|
92
|
+
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
93
93
|
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
94
94
|
}
|
|
95
|
-
Obj.change(trigger, (
|
|
96
|
-
|
|
95
|
+
Obj.change(trigger, (trigger) => {
|
|
96
|
+
trigger.function = Ref.make(foundFn);
|
|
97
97
|
});
|
|
98
98
|
currentFn = foundFn;
|
|
99
99
|
}
|
|
@@ -130,9 +130,9 @@ const updateQueue = Effect.fn(function* (trigger: Trigger.Trigger, queueOption:
|
|
|
130
130
|
onNone: () => selectQueue(),
|
|
131
131
|
onSome: (dxn) => Effect.succeed(dxn.toString()),
|
|
132
132
|
});
|
|
133
|
-
Obj.change(trigger, (
|
|
134
|
-
if (
|
|
135
|
-
|
|
133
|
+
Obj.change(trigger, (trigger) => {
|
|
134
|
+
if (trigger.spec?.kind === 'queue') {
|
|
135
|
+
trigger.spec.queue = queueDxn;
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
}
|
|
@@ -144,7 +144,7 @@ const updateQueue = Effect.fn(function* (trigger: Trigger.Trigger, queueOption:
|
|
|
144
144
|
*/
|
|
145
145
|
const updateInput = Effect.fn(function* (
|
|
146
146
|
trigger: Trigger.Trigger,
|
|
147
|
-
fn:
|
|
147
|
+
fn: Operation.PersistentOperation,
|
|
148
148
|
inputOption: Option.Option<Record<string, any>>,
|
|
149
149
|
) {
|
|
150
150
|
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
@@ -163,11 +163,11 @@ const updateInput = Effect.fn(function* (
|
|
|
163
163
|
if (shouldChangeInput) {
|
|
164
164
|
const inputObj = yield* Option.match(inputOption, {
|
|
165
165
|
onNone: () =>
|
|
166
|
-
promptForSchemaInput(fn.inputSchema ?
|
|
166
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
167
167
|
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
168
168
|
});
|
|
169
|
-
Obj.change(trigger, (
|
|
170
|
-
|
|
169
|
+
Obj.change(trigger, (trigger) => {
|
|
170
|
+
trigger.input = inputObj;
|
|
171
171
|
});
|
|
172
172
|
}
|
|
173
173
|
});
|
|
@@ -189,7 +189,7 @@ const updateEnabled = Effect.fn(function* (
|
|
|
189
189
|
}).pipe(Prompt.run),
|
|
190
190
|
onSome: () => Effect.succeed(enabled),
|
|
191
191
|
});
|
|
192
|
-
Obj.change(trigger, (
|
|
193
|
-
|
|
192
|
+
Obj.change(trigger, (trigger) => {
|
|
193
|
+
trigger.enabled = enabledValue;
|
|
194
194
|
});
|
|
195
195
|
});
|
|
@@ -13,8 +13,9 @@ import * as Option from 'effect/Option';
|
|
|
13
13
|
import { CommandConfig } from '@dxos/cli-util';
|
|
14
14
|
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
15
15
|
import { Common } from '@dxos/cli-util';
|
|
16
|
-
import { DXN, Database, Filter, Obj, Query, Ref
|
|
17
|
-
import {
|
|
16
|
+
import { DXN, Database, Filter, JsonSchema, Obj, Query, Ref } from '@dxos/echo';
|
|
17
|
+
import { Trigger } from '@dxos/functions';
|
|
18
|
+
import { Operation } from '@dxos/operation';
|
|
18
19
|
|
|
19
20
|
import { Deep, Delay, Enabled, Input, TriggerId, Typename } from '../options';
|
|
20
21
|
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
@@ -40,7 +41,7 @@ export const subscription = Command.make(
|
|
|
40
41
|
onSome: (id) => Effect.succeed(id),
|
|
41
42
|
});
|
|
42
43
|
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
43
|
-
const trigger = yield* Database.
|
|
44
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
44
45
|
if (trigger.spec?.kind !== 'subscription') {
|
|
45
46
|
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
46
47
|
}
|
|
@@ -61,7 +62,7 @@ export const subscription = Command.make(
|
|
|
61
62
|
).pipe(
|
|
62
63
|
Command.withDescription('Update a subscription trigger.'),
|
|
63
64
|
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
64
|
-
Command.provideEffectDiscard(() => withTypes(
|
|
65
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
65
66
|
);
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -95,10 +96,10 @@ const extractCurrentTypename = (spec: Trigger.SubscriptionSpec | undefined): Opt
|
|
|
95
96
|
* @returns The current function (either original or newly assigned)
|
|
96
97
|
*/
|
|
97
98
|
const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
|
|
98
|
-
let currentFn:
|
|
99
|
-
? yield* Database.
|
|
99
|
+
let currentFn: Operation.PersistentOperation | undefined = trigger.function
|
|
100
|
+
? yield* Database.load(trigger.function) as any
|
|
100
101
|
: undefined;
|
|
101
|
-
if (currentFn && !Obj.instanceOf(
|
|
102
|
+
if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, currentFn)) {
|
|
102
103
|
currentFn = undefined;
|
|
103
104
|
}
|
|
104
105
|
const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
|
|
@@ -115,13 +116,13 @@ const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionId
|
|
|
115
116
|
onNone: () => selectFunction(),
|
|
116
117
|
onSome: (id) => Effect.succeed(id),
|
|
117
118
|
});
|
|
118
|
-
const functions = yield* Database.
|
|
119
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
119
120
|
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
120
|
-
if (!foundFn || !Obj.instanceOf(
|
|
121
|
+
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
121
122
|
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
122
123
|
}
|
|
123
|
-
Obj.change(trigger, (
|
|
124
|
-
|
|
124
|
+
Obj.change(trigger, (trigger) => {
|
|
125
|
+
trigger.function = Ref.make(foundFn);
|
|
125
126
|
});
|
|
126
127
|
currentFn = foundFn;
|
|
127
128
|
}
|
|
@@ -210,8 +211,8 @@ const updateSpec = Effect.fn(function* (
|
|
|
210
211
|
subscriptionOptions.delay = delayOptionValue.value;
|
|
211
212
|
}
|
|
212
213
|
|
|
213
|
-
Obj.change(trigger, (
|
|
214
|
-
const spec =
|
|
214
|
+
Obj.change(trigger, (trigger) => {
|
|
215
|
+
const spec = trigger.spec;
|
|
215
216
|
if (spec?.kind === 'subscription') {
|
|
216
217
|
// Cast needed because QueryAST types are deeply readonly but spec.query expects mutable.
|
|
217
218
|
spec.query = { ast: queryAst } as NonNullable<typeof spec.query>;
|
|
@@ -227,7 +228,7 @@ const updateSpec = Effect.fn(function* (
|
|
|
227
228
|
*/
|
|
228
229
|
const updateInput = Effect.fn(function* (
|
|
229
230
|
trigger: Trigger.Trigger,
|
|
230
|
-
fn:
|
|
231
|
+
fn: Operation.PersistentOperation,
|
|
231
232
|
inputOption: Option.Option<Record<string, any>>,
|
|
232
233
|
) {
|
|
233
234
|
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
@@ -246,11 +247,11 @@ const updateInput = Effect.fn(function* (
|
|
|
246
247
|
if (shouldChangeInput) {
|
|
247
248
|
const inputObj = yield* Option.match(inputOption, {
|
|
248
249
|
onNone: () =>
|
|
249
|
-
promptForSchemaInput(fn.inputSchema ?
|
|
250
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
250
251
|
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
251
252
|
});
|
|
252
|
-
Obj.change(trigger, (
|
|
253
|
-
|
|
253
|
+
Obj.change(trigger, (trigger) => {
|
|
254
|
+
trigger.input = inputObj;
|
|
254
255
|
});
|
|
255
256
|
}
|
|
256
257
|
});
|
|
@@ -272,7 +273,7 @@ const updateEnabled = Effect.fn(function* (
|
|
|
272
273
|
}).pipe(Prompt.run),
|
|
273
274
|
onSome: () => Effect.succeed(enabled),
|
|
274
275
|
});
|
|
275
|
-
Obj.change(trigger, (
|
|
276
|
-
|
|
276
|
+
Obj.change(trigger, (trigger) => {
|
|
277
|
+
trigger.enabled = enabledValue;
|
|
277
278
|
});
|
|
278
279
|
});
|
|
@@ -12,8 +12,9 @@ import * as Option from 'effect/Option';
|
|
|
12
12
|
import { CommandConfig } from '@dxos/cli-util';
|
|
13
13
|
import { flushAndSync, print, spaceLayer, withTypes } from '@dxos/cli-util';
|
|
14
14
|
import { Common } from '@dxos/cli-util';
|
|
15
|
-
import { DXN, Database, Filter, Obj, Ref
|
|
16
|
-
import {
|
|
15
|
+
import { DXN, Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
16
|
+
import { Trigger } from '@dxos/functions';
|
|
17
|
+
import { Operation } from '@dxos/operation';
|
|
17
18
|
|
|
18
19
|
import { Cron, Enabled, Input, TriggerId } from '../options';
|
|
19
20
|
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
@@ -37,7 +38,7 @@ export const timer = Command.make(
|
|
|
37
38
|
onSome: (id) => Effect.succeed(id),
|
|
38
39
|
});
|
|
39
40
|
const dxn = DXN.fromLocalObjectId(triggerId);
|
|
40
|
-
const trigger = yield* Database.
|
|
41
|
+
const trigger = yield* Database.resolve(dxn, Trigger.Trigger);
|
|
41
42
|
if (!trigger.spec || trigger.spec?.kind !== 'timer') {
|
|
42
43
|
return yield* Effect.fail(new Error(`Invalid trigger type: ${trigger.spec?.kind}`));
|
|
43
44
|
}
|
|
@@ -58,7 +59,7 @@ export const timer = Command.make(
|
|
|
58
59
|
).pipe(
|
|
59
60
|
Command.withDescription('Update a timer trigger.'),
|
|
60
61
|
Command.provide(({ spaceId }) => spaceLayer(spaceId, true)),
|
|
61
|
-
Command.provideEffectDiscard(() => withTypes(
|
|
62
|
+
Command.provideEffectDiscard(() => withTypes(Operation.PersistentOperation, Trigger.Trigger)),
|
|
62
63
|
);
|
|
63
64
|
|
|
64
65
|
/**
|
|
@@ -67,10 +68,10 @@ export const timer = Command.make(
|
|
|
67
68
|
* @returns The current function (either original or newly assigned)
|
|
68
69
|
*/
|
|
69
70
|
const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionIdOption: Option.Option<string>) {
|
|
70
|
-
let currentFn:
|
|
71
|
-
? yield* Database.
|
|
71
|
+
let currentFn: Operation.PersistentOperation | undefined = trigger.function
|
|
72
|
+
? yield* Database.load(trigger.function) as any
|
|
72
73
|
: undefined;
|
|
73
|
-
if (currentFn && !Obj.instanceOf(
|
|
74
|
+
if (currentFn && !Obj.instanceOf(Operation.PersistentOperation, currentFn)) {
|
|
74
75
|
currentFn = undefined;
|
|
75
76
|
}
|
|
76
77
|
const currentFunctionName = currentFn ? (currentFn.name ?? currentFn.id) : undefined;
|
|
@@ -87,13 +88,13 @@ const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionId
|
|
|
87
88
|
onNone: () => selectFunction(),
|
|
88
89
|
onSome: (id) => Effect.succeed(id),
|
|
89
90
|
});
|
|
90
|
-
const functions = yield* Database.
|
|
91
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
91
92
|
const foundFn = functions.find((fn) => fn.id === functionId);
|
|
92
|
-
if (!foundFn || !Obj.instanceOf(
|
|
93
|
+
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
93
94
|
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
94
95
|
}
|
|
95
|
-
Obj.change(trigger, (
|
|
96
|
-
|
|
96
|
+
Obj.change(trigger, (trigger) => {
|
|
97
|
+
trigger.function = Ref.make(foundFn);
|
|
97
98
|
});
|
|
98
99
|
currentFn = foundFn;
|
|
99
100
|
}
|
|
@@ -128,9 +129,9 @@ const updateCron = Effect.fn(function* (trigger: Trigger.Trigger, cronOption: Op
|
|
|
128
129
|
}).pipe(Prompt.run),
|
|
129
130
|
onSome: (value) => Effect.succeed(value),
|
|
130
131
|
});
|
|
131
|
-
Obj.change(trigger, (
|
|
132
|
-
if (
|
|
133
|
-
|
|
132
|
+
Obj.change(trigger, (trigger) => {
|
|
133
|
+
if (trigger.spec?.kind === 'timer') {
|
|
134
|
+
trigger.spec.cron = cron;
|
|
134
135
|
}
|
|
135
136
|
});
|
|
136
137
|
}
|
|
@@ -142,7 +143,7 @@ const updateCron = Effect.fn(function* (trigger: Trigger.Trigger, cronOption: Op
|
|
|
142
143
|
*/
|
|
143
144
|
const updateInput = Effect.fn(function* (
|
|
144
145
|
trigger: Trigger.Trigger,
|
|
145
|
-
fn:
|
|
146
|
+
fn: Operation.PersistentOperation,
|
|
146
147
|
inputOption: Option.Option<Record<string, any>>,
|
|
147
148
|
) {
|
|
148
149
|
const currentInput = trigger.input as Record<string, any> | undefined;
|
|
@@ -161,11 +162,11 @@ const updateInput = Effect.fn(function* (
|
|
|
161
162
|
if (shouldChangeInput) {
|
|
162
163
|
const inputObj = yield* Option.match(inputOption, {
|
|
163
164
|
onNone: () =>
|
|
164
|
-
promptForSchemaInput(fn.inputSchema ?
|
|
165
|
+
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
165
166
|
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
166
167
|
});
|
|
167
|
-
Obj.change(trigger, (
|
|
168
|
-
|
|
168
|
+
Obj.change(trigger, (trigger) => {
|
|
169
|
+
trigger.input = inputObj;
|
|
169
170
|
});
|
|
170
171
|
}
|
|
171
172
|
});
|
|
@@ -187,7 +188,7 @@ const updateEnabled = Effect.fn(function* (
|
|
|
187
188
|
}).pipe(Prompt.run),
|
|
188
189
|
onSome: () => Effect.succeed(enabled),
|
|
189
190
|
});
|
|
190
|
-
Obj.change(trigger, (
|
|
191
|
-
|
|
191
|
+
Obj.change(trigger, (trigger) => {
|
|
192
|
+
trigger.enabled = enabledValue;
|
|
192
193
|
});
|
|
193
194
|
});
|
|
@@ -12,10 +12,11 @@ import type * as Schema from 'effect/Schema';
|
|
|
12
12
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
13
13
|
|
|
14
14
|
import { FormBuilder } from '@dxos/cli-util';
|
|
15
|
-
import { Annotation, Database, Entity, Filter, Obj, Ref, Type } from '@dxos/echo';
|
|
15
|
+
import { Annotation, Database, Entity, Feed, Filter, Obj, Ref, Type } from '@dxos/echo';
|
|
16
16
|
import { getProperties } from '@dxos/effect';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { Trigger } from '@dxos/functions';
|
|
18
|
+
import { Operation } from '@dxos/operation';
|
|
19
|
+
import { FeedAnnotation } from '@dxos/schema';
|
|
19
20
|
|
|
20
21
|
export type TriggerRemoteStatus = 'available' | 'not available' | 'n/a';
|
|
21
22
|
|
|
@@ -34,7 +35,7 @@ export const getTriggerRemoteStatus = (trigger: Trigger.Trigger, remoteCronIds:
|
|
|
34
35
|
* Pretty prints a trigger with ANSI colors.
|
|
35
36
|
*/
|
|
36
37
|
export const printTrigger = Effect.fn(function* (trigger: Trigger.Trigger, remoteStatus?: TriggerRemoteStatus) {
|
|
37
|
-
const fn = trigger.function && (yield* Database.
|
|
38
|
+
const fn = trigger.function && (yield* Database.load(trigger.function));
|
|
38
39
|
|
|
39
40
|
return FormBuilder.make({
|
|
40
41
|
title: trigger.id,
|
|
@@ -60,7 +61,10 @@ export const printTrigger = Effect.fn(function* (trigger: Trigger.Trigger, remot
|
|
|
60
61
|
fn,
|
|
61
62
|
FormBuilder.nest(
|
|
62
63
|
'function',
|
|
63
|
-
FormBuilder.make().pipe(
|
|
64
|
+
FormBuilder.make().pipe(
|
|
65
|
+
FormBuilder.set('key', (fn as Operation.PersistentOperation).key),
|
|
66
|
+
FormBuilder.set('dxn', Obj.getDXN(fn as Obj.Unknown).toString()),
|
|
67
|
+
),
|
|
64
68
|
),
|
|
65
69
|
),
|
|
66
70
|
FormBuilder.nestedOption('spec', Option.fromNullable(trigger.spec).pipe(Option.map(printSpec))),
|
|
@@ -239,7 +243,7 @@ export const promptForSchemaInput = Effect.fn(function* (
|
|
|
239
243
|
inputObj[key] = templateStr === '' && defaultValue !== undefined ? defaultValue : templateStr;
|
|
240
244
|
} else {
|
|
241
245
|
const annotation = Annotation.ReferenceAnnotation.getFromAst(propType).pipe(Option.getOrThrow);
|
|
242
|
-
const objects = yield* Database.
|
|
246
|
+
const objects = yield* Database.runQuery(Filter.typename(annotation.typename));
|
|
243
247
|
if (objects.length === 0) {
|
|
244
248
|
inputObj[key] = undefined;
|
|
245
249
|
} else {
|
|
@@ -272,7 +276,7 @@ export const promptForSchemaInput = Effect.fn(function* (
|
|
|
272
276
|
* Queries the database for functions and prompts the user to select one.
|
|
273
277
|
*/
|
|
274
278
|
export const selectFunction = Effect.fn(function* () {
|
|
275
|
-
const functions = yield* Database.
|
|
279
|
+
const functions = yield* Database.runQuery(Filter.type(Operation.PersistentOperation));
|
|
276
280
|
|
|
277
281
|
if (functions.length === 0) {
|
|
278
282
|
return yield* Effect.fail(new Error('No functions available'));
|
|
@@ -280,7 +284,7 @@ export const selectFunction = Effect.fn(function* () {
|
|
|
280
284
|
|
|
281
285
|
const selected = yield* Prompt.select({
|
|
282
286
|
message: 'Select a function:',
|
|
283
|
-
choices: functions.map((fn:
|
|
287
|
+
choices: functions.map((fn: Operation.PersistentOperation) => ({
|
|
284
288
|
title: fn.name ?? fn.id,
|
|
285
289
|
value: fn.id,
|
|
286
290
|
description: fn.description,
|
|
@@ -296,7 +300,7 @@ export const selectFunction = Effect.fn(function* () {
|
|
|
296
300
|
* Queries the database for triggers and prompts the user to select one.
|
|
297
301
|
*/
|
|
298
302
|
export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
|
|
299
|
-
const triggers = yield* Database.
|
|
303
|
+
const triggers = yield* Database.runQuery(Filter.type(Trigger.Trigger));
|
|
300
304
|
const filteredTriggers = kind ? triggers.filter((trigger) => trigger.spec?.kind === kind) : triggers;
|
|
301
305
|
|
|
302
306
|
if (filteredTriggers.length === 0) {
|
|
@@ -306,8 +310,9 @@ export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
|
|
|
306
310
|
const choices = yield* Effect.all(
|
|
307
311
|
filteredTriggers.map((trigger) =>
|
|
308
312
|
Effect.gen(function* () {
|
|
309
|
-
const fn = trigger.function ? yield* Database.
|
|
310
|
-
const functionName =
|
|
313
|
+
const fn = trigger.function ? yield* Database.load(trigger.function) : undefined;
|
|
314
|
+
const functionName =
|
|
315
|
+
fn && Obj.instanceOf(Operation.PersistentOperation, fn) ? (fn.name ?? fn.key ?? fn.id) : undefined;
|
|
311
316
|
const title = functionName ?? trigger.id;
|
|
312
317
|
const description = `${trigger.enabled ? 'enabled' : 'disabled'} - ${trigger.spec?.kind ?? 'unknown'}`;
|
|
313
318
|
|
|
@@ -330,46 +335,55 @@ export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
|
|
|
330
335
|
|
|
331
336
|
/**
|
|
332
337
|
* Selects a queue interactively from available queues in the database.
|
|
333
|
-
* Queries schemas with
|
|
334
|
-
* and extracts queue DXNs from the objects'
|
|
338
|
+
* Queries schemas with FeedAnnotation, then queries objects of those types,
|
|
339
|
+
* and extracts queue DXNs from the objects' feed properties.
|
|
335
340
|
*/
|
|
336
341
|
export const selectQueue = Effect.fn(function* () {
|
|
337
|
-
// Query schema registry for schemas with
|
|
338
|
-
const schemas = yield* Database.
|
|
342
|
+
// Query schema registry for schemas with FeedAnnotation.
|
|
343
|
+
const schemas = yield* Database.runSchemaQuery({ location: ['database', 'runtime'] });
|
|
339
344
|
|
|
340
|
-
// Filter schemas that have
|
|
341
|
-
const
|
|
342
|
-
const annotation =
|
|
345
|
+
// Filter schemas that have FeedAnnotation.
|
|
346
|
+
const feedSchemas = schemas.filter((schema) => {
|
|
347
|
+
const annotation = FeedAnnotation.get(schema);
|
|
343
348
|
return Option.isSome(annotation) && annotation.value === true;
|
|
344
349
|
});
|
|
345
350
|
|
|
346
|
-
if (
|
|
347
|
-
return yield* Effect.fail(new Error('No schemas with
|
|
351
|
+
if (feedSchemas.length === 0) {
|
|
352
|
+
return yield* Effect.fail(new Error('No schemas with Feed annotation found'));
|
|
348
353
|
}
|
|
349
354
|
|
|
350
|
-
// Collect all objects with queues
|
|
355
|
+
// Collect all objects with queues.
|
|
351
356
|
const queueChoices: Array<{ title: string; value: string; description?: string }> = [];
|
|
352
357
|
|
|
353
|
-
// Process each schema,
|
|
354
|
-
for (const schema of
|
|
358
|
+
// Process each feed schema, loading the Feed object to extract queue DXN.
|
|
359
|
+
for (const schema of feedSchemas) {
|
|
355
360
|
yield* Effect.gen(function* () {
|
|
356
361
|
const typename = Type.getTypename(schema);
|
|
357
|
-
const objects = yield* Database.
|
|
362
|
+
const objects = yield* Database.runQuery(Filter.type(typename));
|
|
358
363
|
|
|
359
364
|
for (const obj of objects) {
|
|
360
|
-
// Access the
|
|
361
|
-
const
|
|
362
|
-
if (!
|
|
365
|
+
// Access the feed property (which is a Ref<Feed>).
|
|
366
|
+
const feedRef = (obj as any).feed as Ref.Ref<any> | undefined;
|
|
367
|
+
if (!feedRef) {
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const feedObj = yield* Effect.promise(() => feedRef.tryLoad());
|
|
372
|
+
if (!feedObj || !Obj.instanceOf(Feed.Feed, feedObj)) {
|
|
373
|
+
continue;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const queueDxn = Feed.getQueueDxn(feedObj);
|
|
377
|
+
if (!queueDxn) {
|
|
363
378
|
continue;
|
|
364
379
|
}
|
|
365
380
|
|
|
366
|
-
const queueDxn = queueRef.dxn.toString();
|
|
367
381
|
const label = Obj.getLabel(obj) ?? obj.id;
|
|
368
382
|
const description = Obj.getTypename(obj);
|
|
369
383
|
|
|
370
384
|
queueChoices.push({
|
|
371
385
|
title: label,
|
|
372
|
-
value: queueDxn,
|
|
386
|
+
value: queueDxn.toString(),
|
|
373
387
|
description,
|
|
374
388
|
});
|
|
375
389
|
}
|
package/src/cli/plugin.ts
CHANGED
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
import { AppPlugin } from '@dxos/app-toolkit';
|
|
6
7
|
import { ClientEvents } from '@dxos/plugin-client/types';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { AutomationEvents } from '../types';
|
|
9
|
+
import { ComputeRuntime } from '#capabilities';
|
|
10
|
+
import { meta } from '#meta';
|
|
11
|
+
import { AutomationEvents } from '#types';
|
|
12
12
|
|
|
13
13
|
import { trigger } from './commands';
|
|
14
14
|
|
|
15
15
|
export const AutomationPlugin = Plugin.define(meta).pipe(
|
|
16
|
-
|
|
16
|
+
AppPlugin.addCommandModule({ commands: [trigger] }),
|
|
17
17
|
Plugin.addModule({
|
|
18
18
|
activatesOn: ClientEvents.ClientReady,
|
|
19
19
|
activatesAfter: [AutomationEvents.ComputeRuntimeReady],
|