@dxos/plugin-automation 0.8.4-main.74a063c4e0 → 0.8.4-main.765dc60934
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/AutomationPanel-HI63JQ2X.mjs +11 -0
- package/dist/lib/neutral/AutomationPlugin.mjs +10 -0
- package/dist/lib/{browser/cli/index.mjs → neutral/AutomationPlugin.node.mjs} +102 -112
- package/dist/lib/neutral/AutomationPlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/AutomationSettings-LM5GSR4H.mjs +31 -0
- package/dist/lib/neutral/AutomationSettings-LM5GSR4H.mjs.map +7 -0
- package/dist/lib/neutral/FunctionsContainer-CEMKJIGV.mjs +38 -0
- package/dist/lib/neutral/FunctionsContainer-CEMKJIGV.mjs.map +7 -0
- package/dist/lib/neutral/FunctionsPanel-SVRKRUXZ.mjs +97 -0
- package/dist/lib/neutral/FunctionsPanel-SVRKRUXZ.mjs.map +7 -0
- package/dist/lib/neutral/FunctionsRegistry-7ITCFJCW.mjs +95 -0
- package/dist/lib/neutral/FunctionsRegistry-7ITCFJCW.mjs.map +7 -0
- package/dist/lib/neutral/TriggerSettings-XCHIZPOR.mjs +9 -0
- package/dist/lib/neutral/app-graph-builder-GDCGRYEP.mjs +75 -0
- package/dist/lib/neutral/app-graph-builder-GDCGRYEP.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +15 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/node.mjs +13 -0
- package/dist/lib/neutral/capabilities/node.mjs.map +7 -0
- package/dist/lib/neutral/chunk-2JP77CMN.mjs +42 -0
- package/dist/lib/neutral/chunk-2JP77CMN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-6CKX6RIL.mjs +270 -0
- package/dist/lib/neutral/chunk-6CKX6RIL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ATECY555.mjs +20 -0
- package/dist/lib/neutral/chunk-ATECY555.mjs.map +7 -0
- package/dist/lib/neutral/chunk-CNFKEN7S.mjs +37 -0
- package/dist/lib/neutral/chunk-CNFKEN7S.mjs.map +7 -0
- package/dist/lib/neutral/chunk-DSCOLDT5.mjs +93 -0
- package/dist/lib/neutral/chunk-DSCOLDT5.mjs.map +7 -0
- package/dist/lib/neutral/chunk-K3C5ZTZA.mjs +285 -0
- package/dist/lib/neutral/chunk-K3C5ZTZA.mjs.map +7 -0
- package/dist/lib/neutral/chunk-M3TIHFXN.mjs +8 -0
- package/dist/lib/neutral/chunk-M3TIHFXN.mjs.map +7 -0
- package/dist/lib/neutral/chunk-YV7TKOVL.mjs +12 -0
- package/dist/lib/neutral/chunk-YV7TKOVL.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +16 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/compute-runtime-D7MPZJ4R.mjs +222 -0
- package/dist/lib/neutral/compute-runtime-D7MPZJ4R.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +13 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/{browser/create-trigger-from-template-JPF5BFMX.mjs → neutral/create-trigger-from-template-7K3OYOHQ.mjs} +13 -22
- package/dist/lib/neutral/create-trigger-from-template-7K3OYOHQ.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +129 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +20 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +8 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs +13 -0
- package/dist/lib/neutral/operation-handler-YXGYH5W5.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-3OGMAMKV.mjs +57 -0
- package/dist/lib/neutral/react-surface-3OGMAMKV.mjs.map +7 -0
- package/dist/lib/neutral/testing.mjs +8 -0
- package/dist/lib/neutral/testing.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +47 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +16 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts +1 -0
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/{cli/plugin.d.ts → AutomationPlugin.node.d.ts} +2 -1
- package/dist/types/src/AutomationPlugin.node.d.ts.map +1 -0
- package/dist/types/src/AutomationPlugin.test.d.ts +2 -0
- package/dist/types/src/AutomationPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts +8 -0
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -2
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/node.d.ts +4 -1
- package/dist/types/src/capabilities/node.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/commands/index.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/create/index.d.ts +6 -6
- package/dist/types/src/commands/trigger/create/index.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/create/queue.d.ts +1 -1
- package/dist/types/src/commands/trigger/create/queue.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/create/subscription.d.ts +1 -1
- package/dist/types/src/commands/trigger/create/subscription.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/create/timer.d.ts +1 -1
- package/dist/types/src/commands/trigger/create/timer.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/index.d.ts +7 -7
- package/dist/types/src/commands/trigger/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/list.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/options.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/remove.d.ts +1 -1
- package/dist/types/src/commands/trigger/remove.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/update/index.d.ts +5 -5
- package/dist/types/src/commands/trigger/update/index.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/queue.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/subscription.d.ts.map +1 -0
- package/dist/types/src/commands/trigger/update/timer.d.ts.map +1 -0
- package/dist/types/src/{cli/commands → commands}/trigger/util.d.ts +4 -4
- package/dist/types/src/commands/trigger/util.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +32 -29
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/index.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.map +1 -1
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +5 -5
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +4 -4
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +95 -90
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts +3 -1
- package/dist/types/src/containers/AutomationSettings/AutomationSettings.d.ts.map +1 -1
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts +2 -4
- package/dist/types/src/containers/FunctionsContainer/FunctionsContainer.d.ts.map +1 -1
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts +3 -3
- package/dist/types/src/containers/TriggerSettings/TriggerSettings.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntime.d.ts +1 -0
- package/dist/types/src/hooks/useComputeRuntime.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts +14 -2
- package/dist/types/src/hooks/useComputeRuntimeService.d.ts.map +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/create-trigger-from-template.d.ts +3 -3
- package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +1 -2
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +77 -77
- package/dist/types/src/testing.d.ts +2 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +32 -30
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/AutomationCapabilities.d.ts +22 -0
- package/dist/types/src/types/AutomationCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/AutomationEvents.d.ts +3 -0
- package/dist/types/src/types/AutomationEvents.d.ts.map +1 -0
- package/dist/types/src/{operations/definitions.d.ts → types/AutomationOperation.d.ts} +5 -5
- package/dist/types/src/types/AutomationOperation.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -2
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +113 -82
- package/src/AutomationPlugin.node.ts +29 -0
- package/src/AutomationPlugin.test.ts +27 -0
- package/src/AutomationPlugin.tsx +7 -7
- package/src/capabilities/app-graph-builder.ts +10 -6
- package/src/capabilities/compute-runtime.ts +218 -138
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/node.ts +6 -0
- package/src/capabilities/operation-handler.ts +1 -1
- package/src/capabilities/react-surface.tsx +6 -6
- package/src/{cli/commands → commands}/trigger/create/queue.ts +5 -9
- package/src/{cli/commands → commands}/trigger/create/subscription.ts +6 -10
- package/src/{cli/commands → commands}/trigger/create/timer.ts +2 -6
- package/src/{cli/commands → commands}/trigger/list.ts +5 -3
- package/src/{cli/commands → commands}/trigger/remove.ts +2 -3
- package/src/{cli/commands → commands}/trigger/update/queue.ts +13 -14
- package/src/{cli/commands → commands}/trigger/update/subscription.ts +9 -10
- package/src/{cli/commands → commands}/trigger/update/timer.ts +10 -11
- package/src/{cli/commands → commands}/trigger/util.ts +19 -16
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +9 -4
- package/src/components/AutomationPanel/AutomationPanel.tsx +40 -35
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +4 -4
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +14 -9
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +1 -1
- package/src/components/TriggerEditor/SpecSelector.tsx +6 -11
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +12 -7
- package/src/components/TriggerEditor/TriggerEditor.tsx +8 -9
- package/src/containers/AutomationSettings/AutomationSettings.tsx +5 -2
- package/src/containers/FunctionsContainer/FunctionsContainer.tsx +3 -4
- package/src/containers/TriggerSettings/TriggerSettings.tsx +29 -7
- package/src/hooks/useComputeRuntime.ts +17 -3
- package/src/hooks/useComputeRuntimeCallback.ts +2 -3
- package/src/hooks/useComputeRuntimeService.ts +49 -9
- package/src/hooks/useTriggerRuntimeControls.ts +6 -3
- package/src/index.ts +2 -2
- package/src/meta.ts +2 -1
- package/src/operations/create-trigger-from-template.ts +51 -55
- package/src/operations/index.ts +1 -3
- package/src/plugin.ts +11 -0
- package/src/testing/test-functions.ts +6 -6
- package/src/testing.ts +7 -0
- package/src/translations.ts +8 -6
- package/src/types/AutomationCapabilities.ts +48 -0
- package/src/types/AutomationEvents.ts +11 -0
- package/src/{operations/definitions.ts → types/AutomationOperation.ts} +4 -2
- package/src/types/index.ts +4 -2
- package/dist/lib/browser/chunk-POEIL4RN.mjs +0 -44
- package/dist/lib/browser/chunk-POEIL4RN.mjs.map +0 -7
- package/dist/lib/browser/chunk-WQLEMRPU.mjs +0 -54
- package/dist/lib/browser/chunk-WQLEMRPU.mjs.map +0 -7
- package/dist/lib/browser/cli/index.mjs.map +0 -7
- package/dist/lib/browser/create-trigger-from-template-JPF5BFMX.mjs.map +0 -7
- package/dist/lib/browser/hooks/index.mjs +0 -85
- package/dist/lib/browser/hooks/index.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -90
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/operations/index.mjs +0 -14
- package/dist/lib/browser/operations/index.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -14
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +0 -11
- package/dist/lib/node-esm/chunk-JWZAVQLF.mjs +0 -56
- package/dist/lib/node-esm/chunk-JWZAVQLF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SP3P4OUI.mjs +0 -45
- package/dist/lib/node-esm/chunk-SP3P4OUI.mjs.map +0 -7
- package/dist/lib/node-esm/cli/index.mjs +0 -1123
- package/dist/lib/node-esm/cli/index.mjs.map +0 -7
- package/dist/lib/node-esm/create-trigger-from-template-FT75A4SF.mjs +0 -78
- package/dist/lib/node-esm/create-trigger-from-template-FT75A4SF.mjs.map +0 -7
- package/dist/lib/node-esm/hooks/index.mjs +0 -86
- package/dist/lib/node-esm/hooks/index.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -91
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/operations/index.mjs +0 -15
- package/dist/lib/node-esm/operations/index.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -15
- package/dist/types/src/cli/commands/index.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/create/index.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/create/queue.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/create/subscription.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/create/timer.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/index.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/list.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/options.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/remove.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/update/index.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/update/queue.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/update/subscription.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/update/timer.d.ts.map +0 -1
- package/dist/types/src/cli/commands/trigger/util.d.ts.map +0 -1
- package/dist/types/src/cli/index.d.ts +0 -2
- package/dist/types/src/cli/index.d.ts.map +0 -1
- package/dist/types/src/cli/plugin.d.ts.map +0 -1
- package/dist/types/src/operations/definitions.d.ts.map +0 -1
- package/dist/types/src/types/capabilities.d.ts +0 -25
- package/dist/types/src/types/capabilities.d.ts.map +0 -1
- package/dist/types/src/types/events.d.ts +0 -5
- package/dist/types/src/types/events.d.ts.map +0 -1
- package/src/cli/index.ts +0 -5
- package/src/cli/plugin.ts +0 -23
- package/src/types/capabilities.ts +0 -56
- package/src/types/events.ts +0 -11
- /package/dist/lib/{browser/chunk-J5LGTIGS.mjs.map → neutral/AutomationPanel-HI63JQ2X.mjs.map} +0 -0
- /package/dist/lib/{browser/types/index.mjs.map → neutral/AutomationPlugin.mjs.map} +0 -0
- /package/dist/lib/{node-esm/chunk-HSLMI22Q.mjs.map → neutral/TriggerSettings-XCHIZPOR.mjs.map} +0 -0
- /package/dist/lib/{browser → neutral}/chunk-J5LGTIGS.mjs +0 -0
- /package/dist/lib/{node-esm/types/index.mjs.map → neutral/chunk-J5LGTIGS.mjs.map} +0 -0
- /package/dist/types/src/{cli/commands → commands}/index.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/list.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/options.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/update/queue.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/update/subscription.d.ts +0 -0
- /package/dist/types/src/{cli/commands → commands}/trigger/update/timer.d.ts +0 -0
- /package/src/{cli/commands → commands}/index.ts +0 -0
- /package/src/{cli/commands → commands}/trigger/create/index.ts +0 -0
- /package/src/{cli/commands → commands}/trigger/index.ts +0 -0
- /package/src/{cli/commands → commands}/trigger/options.ts +0 -0
- /package/src/{cli/commands → commands}/trigger/update/index.ts +0 -0
|
@@ -12,12 +12,11 @@ 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 { Operation, Trigger } from '@dxos/compute';
|
|
15
16
|
import { DXN, Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
16
|
-
import { Trigger } from '@dxos/functions';
|
|
17
|
-
import { Operation } from '@dxos/operation';
|
|
18
17
|
|
|
19
18
|
import { Enabled, Input, Queue, TriggerId } from '../options';
|
|
20
|
-
import { printTrigger, promptForSchemaInput, selectFunction,
|
|
19
|
+
import { printTrigger, promptForSchemaInput, selectFunction, selectFeed, selectTrigger } from '../util';
|
|
21
20
|
|
|
22
21
|
export const queue = Command.make(
|
|
23
22
|
'queue',
|
|
@@ -92,8 +91,8 @@ const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionId
|
|
|
92
91
|
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
93
92
|
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
94
93
|
}
|
|
95
|
-
Obj.
|
|
96
|
-
|
|
94
|
+
Obj.update(trigger, (trigger) => {
|
|
95
|
+
trigger.function = Ref.make(foundFn);
|
|
97
96
|
});
|
|
98
97
|
currentFn = foundFn;
|
|
99
98
|
}
|
|
@@ -126,13 +125,13 @@ const updateQueue = Effect.fn(function* (trigger: Trigger.Trigger, queueOption:
|
|
|
126
125
|
onSome: () => Effect.succeed(true),
|
|
127
126
|
});
|
|
128
127
|
if (shouldChangeQueue) {
|
|
129
|
-
const
|
|
130
|
-
onNone: () =>
|
|
128
|
+
const queueDXN = yield* Option.match(queueOption, {
|
|
129
|
+
onNone: () => selectFeed(),
|
|
131
130
|
onSome: (dxn) => Effect.succeed(dxn.toString()),
|
|
132
131
|
});
|
|
133
|
-
Obj.
|
|
134
|
-
if (
|
|
135
|
-
|
|
132
|
+
Obj.update(trigger, (trigger) => {
|
|
133
|
+
if (trigger.spec?.kind === 'queue') {
|
|
134
|
+
trigger.spec.queue = queueDXN;
|
|
136
135
|
}
|
|
137
136
|
});
|
|
138
137
|
}
|
|
@@ -166,8 +165,8 @@ const updateInput = Effect.fn(function* (
|
|
|
166
165
|
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
167
166
|
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
168
167
|
});
|
|
169
|
-
Obj.
|
|
170
|
-
|
|
168
|
+
Obj.update(trigger, (trigger) => {
|
|
169
|
+
trigger.input = inputObj;
|
|
171
170
|
});
|
|
172
171
|
}
|
|
173
172
|
});
|
|
@@ -189,7 +188,7 @@ const updateEnabled = Effect.fn(function* (
|
|
|
189
188
|
}).pipe(Prompt.run),
|
|
190
189
|
onSome: () => Effect.succeed(enabled),
|
|
191
190
|
});
|
|
192
|
-
Obj.
|
|
193
|
-
|
|
191
|
+
Obj.update(trigger, (trigger) => {
|
|
192
|
+
trigger.enabled = enabledValue;
|
|
194
193
|
});
|
|
195
194
|
});
|
|
@@ -13,9 +13,8 @@ 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 { Operation, Trigger } from '@dxos/compute';
|
|
16
17
|
import { DXN, Database, Filter, JsonSchema, Obj, Query, Ref } from '@dxos/echo';
|
|
17
|
-
import { Trigger } from '@dxos/functions';
|
|
18
|
-
import { Operation } from '@dxos/operation';
|
|
19
18
|
|
|
20
19
|
import { Deep, Delay, Enabled, Input, TriggerId, Typename } from '../options';
|
|
21
20
|
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
@@ -121,8 +120,8 @@ const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionId
|
|
|
121
120
|
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
122
121
|
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
123
122
|
}
|
|
124
|
-
Obj.
|
|
125
|
-
|
|
123
|
+
Obj.update(trigger, (trigger) => {
|
|
124
|
+
trigger.function = Ref.make(foundFn);
|
|
126
125
|
});
|
|
127
126
|
currentFn = foundFn;
|
|
128
127
|
}
|
|
@@ -211,8 +210,8 @@ const updateSpec = Effect.fn(function* (
|
|
|
211
210
|
subscriptionOptions.delay = delayOptionValue.value;
|
|
212
211
|
}
|
|
213
212
|
|
|
214
|
-
Obj.
|
|
215
|
-
const spec =
|
|
213
|
+
Obj.update(trigger, (trigger) => {
|
|
214
|
+
const spec = trigger.spec;
|
|
216
215
|
if (spec?.kind === 'subscription') {
|
|
217
216
|
// Cast needed because QueryAST types are deeply readonly but spec.query expects mutable.
|
|
218
217
|
spec.query = { ast: queryAst } as NonNullable<typeof spec.query>;
|
|
@@ -250,8 +249,8 @@ const updateInput = Effect.fn(function* (
|
|
|
250
249
|
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
251
250
|
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
252
251
|
});
|
|
253
|
-
Obj.
|
|
254
|
-
|
|
252
|
+
Obj.update(trigger, (trigger) => {
|
|
253
|
+
trigger.input = inputObj;
|
|
255
254
|
});
|
|
256
255
|
}
|
|
257
256
|
});
|
|
@@ -273,7 +272,7 @@ const updateEnabled = Effect.fn(function* (
|
|
|
273
272
|
}).pipe(Prompt.run),
|
|
274
273
|
onSome: () => Effect.succeed(enabled),
|
|
275
274
|
});
|
|
276
|
-
Obj.
|
|
277
|
-
|
|
275
|
+
Obj.update(trigger, (trigger) => {
|
|
276
|
+
trigger.enabled = enabledValue;
|
|
278
277
|
});
|
|
279
278
|
});
|
|
@@ -12,9 +12,8 @@ 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 { Operation, Trigger } from '@dxos/compute';
|
|
15
16
|
import { DXN, Database, Filter, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
16
|
-
import { Trigger } from '@dxos/functions';
|
|
17
|
-
import { Operation } from '@dxos/operation';
|
|
18
17
|
|
|
19
18
|
import { Cron, Enabled, Input, TriggerId } from '../options';
|
|
20
19
|
import { printTrigger, promptForSchemaInput, selectFunction, selectTrigger } from '../util';
|
|
@@ -93,8 +92,8 @@ const updateFunction = Effect.fn(function* (trigger: Trigger.Trigger, functionId
|
|
|
93
92
|
if (!foundFn || !Obj.instanceOf(Operation.PersistentOperation, foundFn)) {
|
|
94
93
|
return yield* Effect.fail(new Error(`Function not found: ${functionId}`));
|
|
95
94
|
}
|
|
96
|
-
Obj.
|
|
97
|
-
|
|
95
|
+
Obj.update(trigger, (trigger) => {
|
|
96
|
+
trigger.function = Ref.make(foundFn);
|
|
98
97
|
});
|
|
99
98
|
currentFn = foundFn;
|
|
100
99
|
}
|
|
@@ -129,9 +128,9 @@ const updateCron = Effect.fn(function* (trigger: Trigger.Trigger, cronOption: Op
|
|
|
129
128
|
}).pipe(Prompt.run),
|
|
130
129
|
onSome: (value) => Effect.succeed(value),
|
|
131
130
|
});
|
|
132
|
-
Obj.
|
|
133
|
-
if (
|
|
134
|
-
|
|
131
|
+
Obj.update(trigger, (trigger) => {
|
|
132
|
+
if (trigger.spec?.kind === 'timer') {
|
|
133
|
+
trigger.spec.cron = cron;
|
|
135
134
|
}
|
|
136
135
|
});
|
|
137
136
|
}
|
|
@@ -165,8 +164,8 @@ const updateInput = Effect.fn(function* (
|
|
|
165
164
|
promptForSchemaInput(fn.inputSchema ? JsonSchema.toEffectSchema(fn.inputSchema) : undefined, currentInput),
|
|
166
165
|
onSome: (value) => Effect.succeed(value as Record<string, any>),
|
|
167
166
|
});
|
|
168
|
-
Obj.
|
|
169
|
-
|
|
167
|
+
Obj.update(trigger, (trigger) => {
|
|
168
|
+
trigger.input = inputObj;
|
|
170
169
|
});
|
|
171
170
|
}
|
|
172
171
|
});
|
|
@@ -188,7 +187,7 @@ const updateEnabled = Effect.fn(function* (
|
|
|
188
187
|
}).pipe(Prompt.run),
|
|
189
188
|
onSome: () => Effect.succeed(enabled),
|
|
190
189
|
});
|
|
191
|
-
Obj.
|
|
192
|
-
|
|
190
|
+
Obj.update(trigger, (trigger) => {
|
|
191
|
+
trigger.enabled = enabledValue;
|
|
193
192
|
});
|
|
194
193
|
});
|
|
@@ -12,10 +12,9 @@ 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 {
|
|
15
|
+
import { Operation, Trigger } from '@dxos/compute';
|
|
16
|
+
import { Annotation, Database, Entity, Feed, Filter, Obj, Query, Ref, Type } from '@dxos/echo';
|
|
16
17
|
import { getProperties } from '@dxos/effect';
|
|
17
|
-
import { Trigger } from '@dxos/functions';
|
|
18
|
-
import { Operation } from '@dxos/operation';
|
|
19
18
|
import { FeedAnnotation } from '@dxos/schema';
|
|
20
19
|
|
|
21
20
|
export type TriggerRemoteStatus = 'available' | 'not available' | 'n/a';
|
|
@@ -62,7 +61,7 @@ export const printTrigger = Effect.fn(function* (trigger: Trigger.Trigger, remot
|
|
|
62
61
|
FormBuilder.nest(
|
|
63
62
|
'function',
|
|
64
63
|
FormBuilder.make().pipe(
|
|
65
|
-
FormBuilder.set('key', (fn as Operation.PersistentOperation).key),
|
|
64
|
+
FormBuilder.set('key', Obj.getMeta(fn as Operation.PersistentOperation).key),
|
|
66
65
|
FormBuilder.set('dxn', Obj.getDXN(fn as Obj.Unknown).toString()),
|
|
67
66
|
),
|
|
68
67
|
),
|
|
@@ -300,7 +299,9 @@ export const selectFunction = Effect.fn(function* () {
|
|
|
300
299
|
* Queries the database for triggers and prompts the user to select one.
|
|
301
300
|
*/
|
|
302
301
|
export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
|
|
303
|
-
const triggers = yield* Database.runQuery(
|
|
302
|
+
const triggers = yield* Database.runQuery(
|
|
303
|
+
Query.select(Filter.type(Trigger.Trigger)).debugLabel('cli.trigger.selectTrigger'),
|
|
304
|
+
);
|
|
304
305
|
const filteredTriggers = kind ? triggers.filter((trigger) => trigger.spec?.kind === kind) : triggers;
|
|
305
306
|
|
|
306
307
|
if (filteredTriggers.length === 0) {
|
|
@@ -312,7 +313,9 @@ export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
|
|
|
312
313
|
Effect.gen(function* () {
|
|
313
314
|
const fn = trigger.function ? yield* Database.load(trigger.function) : undefined;
|
|
314
315
|
const functionName =
|
|
315
|
-
fn && Obj.instanceOf(Operation.PersistentOperation, fn)
|
|
316
|
+
fn && Obj.instanceOf(Operation.PersistentOperation, fn)
|
|
317
|
+
? (fn.name ?? Obj.getMeta(fn).key ?? fn.id)
|
|
318
|
+
: undefined;
|
|
316
319
|
const title = functionName ?? trigger.id;
|
|
317
320
|
const description = `${trigger.enabled ? 'enabled' : 'disabled'} - ${trigger.spec?.kind ?? 'unknown'}`;
|
|
318
321
|
|
|
@@ -334,11 +337,11 @@ export const selectTrigger = Effect.fn(function* (kind?: Trigger.Kind) {
|
|
|
334
337
|
});
|
|
335
338
|
|
|
336
339
|
/**
|
|
337
|
-
* Selects a
|
|
340
|
+
* Selects a feed interactively from available feeds in the database.
|
|
338
341
|
* Queries schemas with FeedAnnotation, then queries objects of those types,
|
|
339
342
|
* and extracts queue DXNs from the objects' feed properties.
|
|
340
343
|
*/
|
|
341
|
-
export const
|
|
344
|
+
export const selectFeed = Effect.fn(function* () {
|
|
342
345
|
// Query schema registry for schemas with FeedAnnotation.
|
|
343
346
|
const schemas = yield* Database.runSchemaQuery({ location: ['database', 'runtime'] });
|
|
344
347
|
|
|
@@ -352,8 +355,8 @@ export const selectQueue = Effect.fn(function* () {
|
|
|
352
355
|
return yield* Effect.fail(new Error('No schemas with Feed annotation found'));
|
|
353
356
|
}
|
|
354
357
|
|
|
355
|
-
// Collect all objects with
|
|
356
|
-
const
|
|
358
|
+
// Collect all objects with feeds.
|
|
359
|
+
const feedChoices: Array<{ title: string; value: string; description?: string }> = [];
|
|
357
360
|
|
|
358
361
|
// Process each feed schema, loading the Feed object to extract queue DXN.
|
|
359
362
|
for (const schema of feedSchemas) {
|
|
@@ -373,30 +376,30 @@ export const selectQueue = Effect.fn(function* () {
|
|
|
373
376
|
continue;
|
|
374
377
|
}
|
|
375
378
|
|
|
376
|
-
const
|
|
377
|
-
if (!
|
|
379
|
+
const feedDXN = Feed.getQueueDxn(feedObj);
|
|
380
|
+
if (!feedDXN) {
|
|
378
381
|
continue;
|
|
379
382
|
}
|
|
380
383
|
|
|
381
384
|
const label = Obj.getLabel(obj) ?? obj.id;
|
|
382
385
|
const description = Obj.getTypename(obj);
|
|
383
386
|
|
|
384
|
-
|
|
387
|
+
feedChoices.push({
|
|
385
388
|
title: label,
|
|
386
|
-
value:
|
|
389
|
+
value: feedDXN.toString(),
|
|
387
390
|
description,
|
|
388
391
|
});
|
|
389
392
|
}
|
|
390
393
|
}).pipe(Effect.catchAll(() => Effect.void));
|
|
391
394
|
}
|
|
392
395
|
|
|
393
|
-
if (
|
|
396
|
+
if (feedChoices.length === 0) {
|
|
394
397
|
return yield* Effect.fail(new Error('No objects with queue properties found'));
|
|
395
398
|
}
|
|
396
399
|
|
|
397
400
|
const selected = yield* Prompt.select({
|
|
398
401
|
message: 'Select a queue:',
|
|
399
|
-
choices:
|
|
402
|
+
choices: feedChoices,
|
|
400
403
|
});
|
|
401
404
|
|
|
402
405
|
return String(selected);
|
|
@@ -5,16 +5,15 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
+
import { Operation, Trigger } from '@dxos/compute';
|
|
8
9
|
import { Obj } from '@dxos/echo';
|
|
9
|
-
import { Trigger } from '@dxos/functions';
|
|
10
|
-
import { Operation } from '@dxos/operation';
|
|
11
10
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
12
11
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
12
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
14
13
|
|
|
15
14
|
import { functions } from '#testing';
|
|
15
|
+
import { translations } from '#translations';
|
|
16
16
|
|
|
17
|
-
import { translations } from '../../translations';
|
|
18
17
|
import { AutomationPanel } from './AutomationPanel';
|
|
19
18
|
|
|
20
19
|
const DefaultStory = () => {
|
|
@@ -40,7 +39,13 @@ const meta = {
|
|
|
40
39
|
types: [Operation.PersistentOperation, Trigger.Trigger],
|
|
41
40
|
onCreateSpace: ({ space }) => {
|
|
42
41
|
for (const fn of functions) {
|
|
43
|
-
|
|
42
|
+
const { key, version, ...data } = fn;
|
|
43
|
+
space.db.add(
|
|
44
|
+
Obj.make(Operation.PersistentOperation, {
|
|
45
|
+
[Obj.Meta]: { key, version: version ?? '0.1.0' },
|
|
46
|
+
...data,
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
44
49
|
}
|
|
45
50
|
},
|
|
46
51
|
}),
|
|
@@ -9,12 +9,12 @@ import * as Schema from 'effect/Schema';
|
|
|
9
9
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
10
10
|
|
|
11
11
|
import { useTypeOptions } from '@dxos/app-toolkit/ui';
|
|
12
|
+
import { Script, Trigger } from '@dxos/compute';
|
|
13
|
+
import { Operation } from '@dxos/compute';
|
|
12
14
|
import { Context } from '@dxos/context';
|
|
13
|
-
import { Filter, Obj, Tag } from '@dxos/echo';
|
|
14
|
-
import { Script, Trigger } from '@dxos/functions';
|
|
15
|
+
import { Filter, Obj, Query, Tag } from '@dxos/echo';
|
|
15
16
|
import { KEY_QUEUE_CURSOR } from '@dxos/functions-runtime';
|
|
16
17
|
import { FunctionsServiceClient } from '@dxos/functions-runtime/edge';
|
|
17
|
-
import { Operation } from '@dxos/operation';
|
|
18
18
|
import { type Client, useClient } from '@dxos/react-client';
|
|
19
19
|
import { type Space, useObject, useQuery } from '@dxos/react-client/echo';
|
|
20
20
|
import { Clipboard, IconButton, type IconButtonProps, Input, Separator, useTranslation } from '@dxos/react-ui';
|
|
@@ -43,13 +43,16 @@ export const AutomationPanel = ({ space, object, initialTrigger, onDone }: Autom
|
|
|
43
43
|
const client = useClient();
|
|
44
44
|
const functionsServiceClient = useMemo(() => FunctionsServiceClient.fromClient(client), [client]);
|
|
45
45
|
const functions = useQuery(space.db, Filter.type(Operation.PersistentOperation));
|
|
46
|
-
const triggers = useQuery(
|
|
46
|
+
const triggers = useQuery(
|
|
47
|
+
space.db,
|
|
48
|
+
Query.select(Filter.type(Trigger.Trigger)).debugLabel('plugin-automation.AutomationPanel'),
|
|
49
|
+
);
|
|
47
50
|
const filteredTriggers = useMemo(() => {
|
|
48
51
|
return object ? triggers.filter(triggerMatch(object)) : triggers;
|
|
49
52
|
}, [object, triggers]);
|
|
50
53
|
const tags = useQuery(space.db, Filter.type(Tag.Tag));
|
|
51
54
|
const types = useTypeOptions({
|
|
52
|
-
space,
|
|
55
|
+
db: space.db,
|
|
53
56
|
annotation: {
|
|
54
57
|
location: ['database', 'runtime'],
|
|
55
58
|
kind: ['user'],
|
|
@@ -77,8 +80,8 @@ export const AutomationPanel = ({ space, object, initialTrigger, onDone }: Autom
|
|
|
77
80
|
|
|
78
81
|
const handleSave: TriggerEditorProps['onSave'] = (trigger) => {
|
|
79
82
|
if (selected) {
|
|
80
|
-
Obj.
|
|
81
|
-
Object.assign(
|
|
83
|
+
Obj.update(selected, (selected) => {
|
|
84
|
+
Object.assign(selected, trigger);
|
|
82
85
|
});
|
|
83
86
|
} else {
|
|
84
87
|
space.db.add(Trigger.make(trigger));
|
|
@@ -99,8 +102,8 @@ export const AutomationPanel = ({ space, object, initialTrigger, onDone }: Autom
|
|
|
99
102
|
};
|
|
100
103
|
|
|
101
104
|
const handleResetCursor = async (trigger: Trigger.Trigger) => {
|
|
102
|
-
Obj.
|
|
103
|
-
Obj.deleteKeys(
|
|
105
|
+
Obj.update(trigger, (trigger) => {
|
|
106
|
+
Obj.deleteKeys(trigger, KEY_QUEUE_CURSOR);
|
|
104
107
|
});
|
|
105
108
|
await space.db.flush({ indexes: true });
|
|
106
109
|
};
|
|
@@ -123,32 +126,34 @@ export const AutomationPanel = ({ space, object, initialTrigger, onDone }: Autom
|
|
|
123
126
|
|
|
124
127
|
return (
|
|
125
128
|
<Settings.Panel>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
129
|
+
<Clipboard.Provider>
|
|
130
|
+
{filteredTriggers.length > 0 && (
|
|
131
|
+
<List.Root<Trigger.Trigger>
|
|
132
|
+
items={filteredTriggers}
|
|
133
|
+
isItem={Schema.is(Trigger.Trigger)}
|
|
134
|
+
getId={(field) => field.id}
|
|
135
|
+
>
|
|
136
|
+
{({ items: filteredTriggers }) => (
|
|
137
|
+
<div role='list' className='flex flex-col w-full'>
|
|
138
|
+
{filteredTriggers?.map((trigger) => (
|
|
139
|
+
<TriggerListItem
|
|
140
|
+
key={trigger.id}
|
|
141
|
+
trigger={trigger}
|
|
142
|
+
functions={functions}
|
|
143
|
+
onSelect={handleSelect}
|
|
144
|
+
onDelete={handleDelete}
|
|
145
|
+
onResetCursor={handleResetCursor}
|
|
146
|
+
onForceRun={handleForceRunTrigger}
|
|
147
|
+
/>
|
|
148
|
+
))}
|
|
149
|
+
</div>
|
|
150
|
+
)}
|
|
151
|
+
</List.Root>
|
|
152
|
+
)}
|
|
153
|
+
|
|
154
|
+
{filteredTriggers.length > 0 && <Separator classNames='my-4' />}
|
|
155
|
+
<IconButton icon='ph--plus--regular' label={t('new-trigger.label')} onClick={handleAdd} />
|
|
156
|
+
</Clipboard.Provider>
|
|
152
157
|
</Settings.Panel>
|
|
153
158
|
);
|
|
154
159
|
};
|
|
@@ -7,10 +7,10 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
9
9
|
import { LayoutOperation, getObjectPathFromObject } from '@dxos/app-toolkit';
|
|
10
|
-
import { Script } from '@dxos/
|
|
11
|
-
import {
|
|
12
|
-
import { SpaceOperation } from '@dxos/plugin-space
|
|
13
|
-
import {
|
|
10
|
+
import { Operation, Script } from '@dxos/compute';
|
|
11
|
+
import { Filter } from '@dxos/echo';
|
|
12
|
+
import { SpaceOperation } from '@dxos/plugin-space';
|
|
13
|
+
import { type Space, useQuery } from '@dxos/react-client/echo';
|
|
14
14
|
import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
15
15
|
import { Settings } from '@dxos/react-ui-form';
|
|
16
16
|
import { List } from '@dxos/react-ui-list';
|
|
@@ -6,11 +6,12 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import { useState } from 'react';
|
|
7
7
|
import React, { useCallback } from 'react';
|
|
8
8
|
|
|
9
|
+
import * as OperationModule from '@dxos/compute';
|
|
9
10
|
import { Context } from '@dxos/context';
|
|
11
|
+
import { Filter, Obj } from '@dxos/echo';
|
|
10
12
|
import { getDeployedFunctions } from '@dxos/functions-runtime/edge';
|
|
11
|
-
import * as OperationModule from '@dxos/operation';
|
|
12
13
|
import { useClient } from '@dxos/react-client';
|
|
13
|
-
import {
|
|
14
|
+
import { type Space, useQuery } from '@dxos/react-client/echo';
|
|
14
15
|
import { IconButton, useAsyncEffect, useTranslation } from '@dxos/react-ui';
|
|
15
16
|
import { Settings } from '@dxos/react-ui-form';
|
|
16
17
|
import { List } from '@dxos/react-ui-list';
|
|
@@ -33,11 +34,12 @@ export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
|
|
|
33
34
|
const dbFunctions = useQuery(space.db, Filter.type(OperationModule.Operation.PersistentOperation));
|
|
34
35
|
|
|
35
36
|
const state = (func: OperationModule.Operation.PersistentOperation) => {
|
|
36
|
-
const
|
|
37
|
+
const funcKey = Obj.getMeta(func).key;
|
|
38
|
+
const dbFunction = dbFunctions.find((f) => Obj.getMeta(f).key === funcKey);
|
|
37
39
|
if (!dbFunction) {
|
|
38
40
|
return 'import';
|
|
39
41
|
}
|
|
40
|
-
if (dbFunction.version === func.version && dbFunction.updated === func.updated) {
|
|
42
|
+
if (Obj.getMeta(dbFunction).version === Obj.getMeta(func).version && dbFunction.updated === func.updated) {
|
|
41
43
|
return 'none';
|
|
42
44
|
}
|
|
43
45
|
return 'update';
|
|
@@ -52,9 +54,12 @@ export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
|
|
|
52
54
|
|
|
53
55
|
const hanleImportOrUpdate = useCallback(
|
|
54
56
|
async (func: OperationModule.Operation.PersistentOperation) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
.
|
|
57
|
+
const funcKey = Obj.getMeta(func).key;
|
|
58
|
+
const functions = funcKey
|
|
59
|
+
? await space.db
|
|
60
|
+
.query(Filter.and(Filter.type(OperationModule.Operation.PersistentOperation), Filter.key(funcKey)))
|
|
61
|
+
.run()
|
|
62
|
+
: [];
|
|
58
63
|
const [existingFunc] = functions;
|
|
59
64
|
if (!existingFunc) {
|
|
60
65
|
space.db.add(func);
|
|
@@ -83,10 +88,10 @@ export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
|
|
|
83
88
|
>
|
|
84
89
|
<div className='flex flex-col truncate'>
|
|
85
90
|
<List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>
|
|
86
|
-
<div className='text-xs text-description truncate'>{func.key}</div>
|
|
91
|
+
<div className='text-xs text-description truncate'>{Obj.getMeta(func).key}</div>
|
|
87
92
|
</div>
|
|
88
93
|
<div className='flex flex-col truncate'>
|
|
89
|
-
<div className='text-xs text-description truncate'>{func.version}</div>
|
|
94
|
+
<div className='text-xs text-description truncate'>{Obj.getMeta(func).version}</div>
|
|
90
95
|
<div className='text-xs text-description truncate'>
|
|
91
96
|
{func.updated ? `Uploaded ${new Date(func.updated).toLocaleString()}` : ''}
|
|
92
97
|
</div>
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import type * as SchemaAST from 'effect/SchemaAST';
|
|
6
6
|
import React, { useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
+
import { type Operation } from '@dxos/compute';
|
|
8
9
|
import { type Database, JsonSchema, Obj, Ref } from '@dxos/echo';
|
|
9
10
|
import { type JsonPath } from '@dxos/echo/internal';
|
|
10
|
-
import { type Operation } from '@dxos/operation';
|
|
11
11
|
import { useOnTransition, useTranslation } from '@dxos/react-ui';
|
|
12
12
|
import { Form, type FormFieldStateProps, type FormRootProps, useFormValues } from '@dxos/react-ui-form';
|
|
13
13
|
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
+
import { Trigger } from '@dxos/compute';
|
|
7
8
|
import { Filter, Query } from '@dxos/echo';
|
|
8
|
-
import { Trigger } from '@dxos/functions';
|
|
9
9
|
import { useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { type FormFieldComponentProps, SelectField, useFormFieldState } from '@dxos/react-ui-form';
|
|
11
11
|
|
|
@@ -22,20 +22,15 @@ export const SpecSelector = (props: SpecSelectorProps) => {
|
|
|
22
22
|
const getDefaultTriggerSpec = (kind: string) => {
|
|
23
23
|
switch (kind) {
|
|
24
24
|
case 'timer':
|
|
25
|
-
return
|
|
25
|
+
return Trigger.specTimer('');
|
|
26
26
|
case 'subscription':
|
|
27
|
-
return
|
|
28
|
-
kind: 'subscription',
|
|
29
|
-
query: {
|
|
30
|
-
ast: Query.select(Filter.nothing()).ast,
|
|
31
|
-
},
|
|
32
|
-
};
|
|
27
|
+
return Trigger.specSubscription(Query.select(Filter.nothing()));
|
|
33
28
|
case 'queue':
|
|
34
|
-
return
|
|
29
|
+
return Trigger.specQueue('dxn:queue:default');
|
|
35
30
|
case 'email':
|
|
36
|
-
return
|
|
31
|
+
return Trigger.specEmail();
|
|
37
32
|
case 'webhook':
|
|
38
|
-
return
|
|
33
|
+
return Trigger.specWebhook();
|
|
39
34
|
default:
|
|
40
35
|
return undefined;
|
|
41
36
|
}
|
|
@@ -6,21 +6,20 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
7
|
import { expect, userEvent, within } from 'storybook/test';
|
|
8
8
|
|
|
9
|
+
import { Operation, Trigger } from '@dxos/compute';
|
|
9
10
|
import { Filter, Obj, Ref, Tag, Type } from '@dxos/echo';
|
|
10
|
-
import { Trigger } from '@dxos/functions';
|
|
11
11
|
import { invariant } from '@dxos/invariant';
|
|
12
|
-
import { Operation } from '@dxos/operation';
|
|
13
12
|
import { random } from '@dxos/random';
|
|
14
13
|
import { useQuery } from '@dxos/react-client/echo';
|
|
15
14
|
import { TestSchema, useClientStory, withClientProvider } from '@dxos/react-client/testing';
|
|
16
15
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
17
|
-
import { translations as formTranslations } from '@dxos/react-ui-form';
|
|
16
|
+
import { translations as formTranslations } from '@dxos/react-ui-form/translations';
|
|
18
17
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
19
18
|
import { Employer, Organization, Person, Pipeline } from '@dxos/types';
|
|
20
19
|
|
|
21
20
|
import { functions } from '#testing';
|
|
21
|
+
import { translations } from '#translations';
|
|
22
22
|
|
|
23
|
-
import { translations } from '../../translations';
|
|
24
23
|
import { TriggerEditor, type TriggerEditorProps } from './TriggerEditor';
|
|
25
24
|
|
|
26
25
|
const types = [
|
|
@@ -42,12 +41,12 @@ const DefaultStory = (props: Partial<TriggerEditorProps>) => {
|
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
const functions = await space.db.query(Filter.type(Operation.PersistentOperation)).run();
|
|
45
|
-
const fn = functions.find((fn) => fn.name === 'example.
|
|
44
|
+
const fn = functions.find((fn) => fn.name === 'com.example.function.forex');
|
|
46
45
|
invariant(fn);
|
|
47
46
|
const trigger = space.db.add(
|
|
48
47
|
Trigger.make({
|
|
49
48
|
function: Ref.make(fn),
|
|
50
|
-
spec:
|
|
49
|
+
spec: Trigger.specWebhook(),
|
|
51
50
|
input: {
|
|
52
51
|
from: 'USD',
|
|
53
52
|
to: 'JPY',
|
|
@@ -92,7 +91,13 @@ const meta = {
|
|
|
92
91
|
|
|
93
92
|
// Functions.
|
|
94
93
|
functions.forEach((fn) => {
|
|
95
|
-
|
|
94
|
+
const { key, version, ...data } = fn;
|
|
95
|
+
space.db.add(
|
|
96
|
+
Obj.make(Operation.PersistentOperation, {
|
|
97
|
+
[Obj.Meta]: { key, version: version ?? '0.1.0' },
|
|
98
|
+
...data,
|
|
99
|
+
}),
|
|
100
|
+
);
|
|
96
101
|
});
|
|
97
102
|
|
|
98
103
|
// Objects.
|
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
+
import { Operation, Script, Trigger } from '@dxos/compute';
|
|
7
8
|
import { ComputeGraph } from '@dxos/conductor';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { Operation } from '@dxos/operation';
|
|
11
|
-
import { Filter, Ref, useQuery } from '@dxos/react-client/echo';
|
|
9
|
+
import { type Database, DXN, Entity, Feed, Filter, Obj, type Query, Ref } from '@dxos/echo';
|
|
10
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
12
11
|
import { Input } from '@dxos/react-ui';
|
|
13
12
|
import { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';
|
|
14
13
|
import {
|
|
@@ -41,8 +40,8 @@ export const TriggerEditor = ({ db, types, tags, readonlySpec, trigger, ...formP
|
|
|
41
40
|
|
|
42
41
|
const handleValuesChanged = useCallback(
|
|
43
42
|
(newValues: Partial<TriggerFormSchema>) => {
|
|
44
|
-
Obj.
|
|
45
|
-
Object.assign(
|
|
43
|
+
Obj.update(trigger, (trigger) => {
|
|
44
|
+
Object.assign(trigger, newValues);
|
|
46
45
|
});
|
|
47
46
|
},
|
|
48
47
|
[trigger],
|
|
@@ -158,12 +157,12 @@ const getFunctionOptions = (scripts: Script.Script[], functions: Operation.Persi
|
|
|
158
157
|
|
|
159
158
|
const getFeedQueueOptions = (feeds: Feed.Feed[]) => {
|
|
160
159
|
return feeds.flatMap((feed) => {
|
|
161
|
-
const
|
|
162
|
-
if (!
|
|
160
|
+
const queueDXN = Feed.getQueueDxn(feed);
|
|
161
|
+
if (!queueDXN) {
|
|
163
162
|
return [];
|
|
164
163
|
}
|
|
165
164
|
const parent = Obj.getParent(feed);
|
|
166
165
|
const label = parent ? Entity.getLabel(parent) : Entity.getLabel(feed);
|
|
167
|
-
return [{ label: label ?? feed.id, value:
|
|
166
|
+
return [{ label: label ?? feed.id, value: queueDXN.toString() }];
|
|
168
167
|
});
|
|
169
168
|
};
|