@dxos/plugin-automation 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
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-WQLEMRPU.mjs → chunk-CHUTFU3D.mjs} +1 -1
- package/dist/lib/browser/chunk-CHUTFU3D.mjs.map +7 -0
- package/dist/lib/browser/{chunk-POEIL4RN.mjs → chunk-RE64VLSV.mjs} +3 -3
- package/dist/lib/browser/{chunk-POEIL4RN.mjs.map → chunk-RE64VLSV.mjs.map} +3 -3
- package/dist/lib/browser/{create-trigger-from-template-JZ62EZTB.mjs → create-trigger-from-template-JLBSJRVB.mjs} +9 -16
- package/dist/lib/browser/create-trigger-from-template-JLBSJRVB.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +61 -17
- package/dist/lib/browser/hooks/index.mjs.map +3 -3
- package/dist/lib/browser/index.mjs +6 -71
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operations/index.mjs +4 -4
- package/dist/lib/browser/operations/index.mjs.map +3 -3
- package/dist/lib/browser/translations.mjs +47 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +1 -1
- package/dist/lib/node-esm/{chunk-SP3P4OUI.mjs → chunk-HHIHREME.mjs} +3 -3
- package/dist/lib/node-esm/{chunk-SP3P4OUI.mjs.map → chunk-HHIHREME.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-JWZAVQLF.mjs → chunk-NWQMBY32.mjs} +1 -1
- package/dist/lib/node-esm/chunk-NWQMBY32.mjs.map +7 -0
- package/dist/lib/node-esm/{create-trigger-from-template-224Z7WJI.mjs → create-trigger-from-template-FUQ3LUIF.mjs} +9 -16
- package/dist/lib/node-esm/create-trigger-from-template-FUQ3LUIF.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +61 -17
- package/dist/lib/node-esm/hooks/index.mjs.map +3 -3
- package/dist/lib/node-esm/index.mjs +6 -71
- 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 +4 -4
- package/dist/lib/node-esm/operations/index.mjs.map +3 -3
- package/dist/lib/node-esm/translations.mjs +48 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +1 -1
- 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 +1 -1
- 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 -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 +2 -2
- 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 -91
- 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.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 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/operations/create-trigger-from-template.d.ts +1 -1
- package/dist/types/src/operations/create-trigger-from-template.d.ts.map +1 -1
- package/dist/types/src/operations/definitions.d.ts +4 -4
- package/dist/types/src/operations/definitions.d.ts.map +1 -1
- package/dist/types/src/operations/index.d.ts +1 -1
- package/dist/types/src/operations/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts +77 -77
- package/dist/types/src/translations.d.ts +32 -30
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +6 -7
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.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 +60 -60
- package/src/{cli/plugin.ts → AutomationPlugin.node.ts} +8 -2
- package/src/AutomationPlugin.test.ts +27 -0
- package/src/AutomationPlugin.tsx +6 -6
- package/src/capabilities/app-graph-builder.ts +10 -6
- package/src/capabilities/compute-runtime.ts +216 -139
- 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 +2 -6
- 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 +1 -1
- package/src/{cli/commands → commands}/trigger/update/queue.ts +5 -6
- package/src/{cli/commands → commands}/trigger/update/subscription.ts +5 -6
- package/src/{cli/commands → commands}/trigger/update/timer.ts +5 -6
- package/src/{cli/commands → commands}/trigger/util.ts +5 -4
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +2 -3
- package/src/components/AutomationPanel/AutomationPanel.tsx +9 -6
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +1 -2
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +1 -1
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +1 -1
- package/src/components/TriggerEditor/SpecSelector.tsx +6 -11
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +4 -5
- package/src/components/TriggerEditor/TriggerEditor.tsx +2 -3
- 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/useComputeRuntimeService.ts +49 -9
- package/src/hooks/useTriggerRuntimeControls.ts +6 -3
- package/src/index.ts +5 -1
- package/src/operations/create-trigger-from-template.ts +6 -10
- package/src/operations/definitions.ts +1 -1
- package/src/operations/index.ts +1 -1
- package/src/translations.ts +8 -6
- package/src/types/capabilities.ts +9 -18
- package/dist/lib/browser/chunk-WQLEMRPU.mjs.map +0 -7
- package/dist/lib/browser/cli/index.mjs +0 -1122
- package/dist/lib/browser/cli/index.mjs.map +0 -7
- package/dist/lib/browser/create-trigger-from-template-JZ62EZTB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JWZAVQLF.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-224Z7WJI.mjs.map +0 -7
- 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/src/cli/index.ts +0 -5
- /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,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 { Enabled, Input, Queue, TriggerId } from '../options';
|
|
20
19
|
import { printTrigger, promptForSchemaInput, selectFunction, selectQueue, selectTrigger } from '../util';
|
|
@@ -92,7 +91,7 @@ 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.
|
|
94
|
+
Obj.update(trigger, (trigger) => {
|
|
96
95
|
trigger.function = Ref.make(foundFn);
|
|
97
96
|
});
|
|
98
97
|
currentFn = foundFn;
|
|
@@ -130,7 +129,7 @@ const updateQueue = Effect.fn(function* (trigger: Trigger.Trigger, queueOption:
|
|
|
130
129
|
onNone: () => selectQueue(),
|
|
131
130
|
onSome: (dxn) => Effect.succeed(dxn.toString()),
|
|
132
131
|
});
|
|
133
|
-
Obj.
|
|
132
|
+
Obj.update(trigger, (trigger) => {
|
|
134
133
|
if (trigger.spec?.kind === 'queue') {
|
|
135
134
|
trigger.spec.queue = queueDxn;
|
|
136
135
|
}
|
|
@@ -166,7 +165,7 @@ 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.
|
|
168
|
+
Obj.update(trigger, (trigger) => {
|
|
170
169
|
trigger.input = inputObj;
|
|
171
170
|
});
|
|
172
171
|
}
|
|
@@ -189,7 +188,7 @@ const updateEnabled = Effect.fn(function* (
|
|
|
189
188
|
}).pipe(Prompt.run),
|
|
190
189
|
onSome: () => Effect.succeed(enabled),
|
|
191
190
|
});
|
|
192
|
-
Obj.
|
|
191
|
+
Obj.update(trigger, (trigger) => {
|
|
193
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,7 +120,7 @@ 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.
|
|
123
|
+
Obj.update(trigger, (trigger) => {
|
|
125
124
|
trigger.function = Ref.make(foundFn);
|
|
126
125
|
});
|
|
127
126
|
currentFn = foundFn;
|
|
@@ -211,7 +210,7 @@ const updateSpec = Effect.fn(function* (
|
|
|
211
210
|
subscriptionOptions.delay = delayOptionValue.value;
|
|
212
211
|
}
|
|
213
212
|
|
|
214
|
-
Obj.
|
|
213
|
+
Obj.update(trigger, (trigger) => {
|
|
215
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.
|
|
@@ -250,7 +249,7 @@ 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.
|
|
252
|
+
Obj.update(trigger, (trigger) => {
|
|
254
253
|
trigger.input = inputObj;
|
|
255
254
|
});
|
|
256
255
|
}
|
|
@@ -273,7 +272,7 @@ const updateEnabled = Effect.fn(function* (
|
|
|
273
272
|
}).pipe(Prompt.run),
|
|
274
273
|
onSome: () => Effect.succeed(enabled),
|
|
275
274
|
});
|
|
276
|
-
Obj.
|
|
275
|
+
Obj.update(trigger, (trigger) => {
|
|
277
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,7 +92,7 @@ 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.
|
|
95
|
+
Obj.update(trigger, (trigger) => {
|
|
97
96
|
trigger.function = Ref.make(foundFn);
|
|
98
97
|
});
|
|
99
98
|
currentFn = foundFn;
|
|
@@ -129,7 +128,7 @@ 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.
|
|
131
|
+
Obj.update(trigger, (trigger) => {
|
|
133
132
|
if (trigger.spec?.kind === 'timer') {
|
|
134
133
|
trigger.spec.cron = cron;
|
|
135
134
|
}
|
|
@@ -165,7 +164,7 @@ 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.
|
|
167
|
+
Obj.update(trigger, (trigger) => {
|
|
169
168
|
trigger.input = inputObj;
|
|
170
169
|
});
|
|
171
170
|
}
|
|
@@ -188,7 +187,7 @@ const updateEnabled = Effect.fn(function* (
|
|
|
188
187
|
}).pipe(Prompt.run),
|
|
189
188
|
onSome: () => Effect.succeed(enabled),
|
|
190
189
|
});
|
|
191
|
-
Obj.
|
|
190
|
+
Obj.update(trigger, (trigger) => {
|
|
192
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';
|
|
@@ -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) {
|
|
@@ -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 = () => {
|
|
@@ -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,7 +43,10 @@ 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]);
|
|
@@ -77,7 +80,7 @@ export const AutomationPanel = ({ space, object, initialTrigger, onDone }: Autom
|
|
|
77
80
|
|
|
78
81
|
const handleSave: TriggerEditorProps['onSave'] = (trigger) => {
|
|
79
82
|
if (selected) {
|
|
80
|
-
Obj.
|
|
83
|
+
Obj.update(selected, (selected) => {
|
|
81
84
|
Object.assign(selected, trigger);
|
|
82
85
|
});
|
|
83
86
|
} else {
|
|
@@ -99,7 +102,7 @@ export const AutomationPanel = ({ space, object, initialTrigger, onDone }: Autom
|
|
|
99
102
|
};
|
|
100
103
|
|
|
101
104
|
const handleResetCursor = async (trigger: Trigger.Trigger) => {
|
|
102
|
-
Obj.
|
|
105
|
+
Obj.update(trigger, (trigger) => {
|
|
103
106
|
Obj.deleteKeys(trigger, KEY_QUEUE_CURSOR);
|
|
104
107
|
});
|
|
105
108
|
await space.db.flush({ indexes: true });
|
|
@@ -7,8 +7,7 @@ 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 { Operation } from '@dxos/operation';
|
|
10
|
+
import { Operation, Script } from '@dxos/compute';
|
|
12
11
|
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
13
12
|
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
14
13
|
import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
@@ -6,9 +6,9 @@ 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';
|
|
10
11
|
import { getDeployedFunctions } from '@dxos/functions-runtime/edge';
|
|
11
|
-
import * as OperationModule from '@dxos/operation';
|
|
12
12
|
import { useClient } from '@dxos/react-client';
|
|
13
13
|
import { Filter, Query, type Space, useQuery } from '@dxos/react-client/echo';
|
|
14
14
|
import { IconButton, useAsyncEffect, useTranslation } from '@dxos/react-ui';
|
|
@@ -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 = [
|
|
@@ -47,7 +46,7 @@ const DefaultStory = (props: Partial<TriggerEditorProps>) => {
|
|
|
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',
|
|
@@ -4,10 +4,9 @@
|
|
|
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
9
|
import { DXN, type Database, Entity, Feed, Obj, type Query } from '@dxos/echo';
|
|
9
|
-
import { Script, Trigger } from '@dxos/functions';
|
|
10
|
-
import { Operation } from '@dxos/operation';
|
|
11
10
|
import { Filter, Ref, 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';
|
|
@@ -41,7 +40,7 @@ export const TriggerEditor = ({ db, types, tags, readonlySpec, trigger, ...formP
|
|
|
41
40
|
|
|
42
41
|
const handleValuesChanged = useCallback(
|
|
43
42
|
(newValues: Partial<TriggerFormSchema>) => {
|
|
44
|
-
Obj.
|
|
43
|
+
Obj.update(trigger, (trigger) => {
|
|
45
44
|
Object.assign(trigger, newValues);
|
|
46
45
|
});
|
|
47
46
|
},
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
7
8
|
import { useTranslation } from '@dxos/react-ui';
|
|
8
9
|
import { Settings } from '@dxos/react-ui-form';
|
|
9
10
|
|
|
@@ -12,7 +13,9 @@ import { meta } from '#meta';
|
|
|
12
13
|
import { AutomationPanel, type AutomationPanelProps } from '../../components/AutomationPanel';
|
|
13
14
|
import { TriggersSettings } from '../TriggerSettings';
|
|
14
15
|
|
|
15
|
-
export
|
|
16
|
+
export type AutomationSettingsProps = AppSurface.SpaceArticleProps<Omit<AutomationPanelProps, 'space'>>;
|
|
17
|
+
|
|
18
|
+
export const AutomationSettings = (props: AutomationSettingsProps) => {
|
|
16
19
|
const { t } = useTranslation(meta.id);
|
|
17
20
|
return (
|
|
18
21
|
<Settings.Viewport>
|
|
@@ -21,7 +24,7 @@ export const AutomationSettings = (props: AutomationPanelProps) => {
|
|
|
21
24
|
description={t('automation.description', { ns: meta.id })}
|
|
22
25
|
>
|
|
23
26
|
<AutomationPanel {...props} />
|
|
24
|
-
<TriggersSettings
|
|
27
|
+
<TriggersSettings space={props.space} />
|
|
25
28
|
</Settings.Section>
|
|
26
29
|
</Settings.Viewport>
|
|
27
30
|
);
|
|
@@ -4,16 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { Settings } from '@dxos/react-ui-form';
|
|
10
10
|
|
|
11
11
|
import { meta } from '#meta';
|
|
12
12
|
|
|
13
|
-
import { FunctionsPanel } from '../../components
|
|
14
|
-
import { FunctionsRegistry } from '../../components/FunctionsRegistry';
|
|
13
|
+
import { FunctionsPanel, FunctionsRegistry } from '../../components';
|
|
15
14
|
|
|
16
|
-
export const FunctionsContainer = ({ space }:
|
|
15
|
+
export const FunctionsContainer = ({ space }: AppSurface.SpaceArticleProps) => {
|
|
17
16
|
const { t } = useTranslation(meta.id);
|
|
18
17
|
return (
|
|
19
18
|
<Settings.Viewport>
|
|
@@ -4,22 +4,44 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
7
|
+
import { type ComputeEnvironment } from '@dxos/client-protocol';
|
|
8
|
+
import { useObject } from '@dxos/echo-react';
|
|
9
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
10
|
+
import { DropdownMenu, IconButton, useTranslation } from '@dxos/react-ui';
|
|
9
11
|
import { Settings } from '@dxos/react-ui-form';
|
|
10
12
|
|
|
11
|
-
import { useTriggerRuntimeControls } from '#hooks';
|
|
12
13
|
import { meta } from '#meta';
|
|
13
14
|
|
|
14
|
-
export const TriggersSettings = ({
|
|
15
|
-
const { state, start, stop } = useTriggerRuntimeControls(db);
|
|
16
|
-
const isRunning = state?.enabled ?? false;
|
|
15
|
+
export const TriggersSettings = ({ space }: { space: Space }) => {
|
|
17
16
|
const { t } = useTranslation(meta.id);
|
|
17
|
+
const [properties, changeProperties] = useObject(space.properties);
|
|
18
|
+
const selected = properties.computeEnvironment ?? 'local';
|
|
19
|
+
|
|
20
|
+
const handleUpdate = (option: ComputeEnvironment) => {
|
|
21
|
+
changeProperties((draft) => {
|
|
22
|
+
draft.computeEnvironment = option;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
18
25
|
|
|
19
26
|
return (
|
|
20
27
|
<div className='grid grid-cols-1 md:grid-cols-[1fr_min-content]'>
|
|
21
28
|
<Settings.Item title={t('runtime.label')} description={t('runtime.description')}>
|
|
22
|
-
<
|
|
29
|
+
<DropdownMenu.Root>
|
|
30
|
+
<DropdownMenu.Trigger asChild>
|
|
31
|
+
<IconButton iconEnd icon='ph--caret-down--regular' size={4} label={t(`runtime.${selected}.label`)} />
|
|
32
|
+
</DropdownMenu.Trigger>
|
|
33
|
+
<DropdownMenu.Portal>
|
|
34
|
+
<DropdownMenu.Content side='bottom'>
|
|
35
|
+
<DropdownMenu.Viewport>
|
|
36
|
+
<DropdownMenu.Item onClick={() => handleUpdate('disabled')}>
|
|
37
|
+
{t(`runtime.disabled.label`)}
|
|
38
|
+
</DropdownMenu.Item>
|
|
39
|
+
<DropdownMenu.Item onClick={() => handleUpdate('local')}>{t(`runtime.local.label`)}</DropdownMenu.Item>
|
|
40
|
+
<DropdownMenu.Item onClick={() => handleUpdate('edge')}>{t(`runtime.edge.label`)}</DropdownMenu.Item>
|
|
41
|
+
</DropdownMenu.Viewport>
|
|
42
|
+
</DropdownMenu.Content>
|
|
43
|
+
</DropdownMenu.Portal>
|
|
44
|
+
</DropdownMenu.Root>
|
|
23
45
|
</Settings.Item>
|
|
24
46
|
</div>
|
|
25
47
|
);
|
|
@@ -2,15 +2,29 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useCapabilities } from '@dxos/app-framework/ui';
|
|
6
8
|
import { SpaceId } from '@dxos/keys';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
7
10
|
|
|
8
11
|
import { AutomationCapabilities } from '../types';
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Resolves the compute runtime for a space.
|
|
15
|
+
* Returns undefined if the AutomationPlugin is not loaded or spaceId is not provided.
|
|
12
16
|
*/
|
|
13
17
|
export const useComputeRuntime = (id: SpaceId | undefined): AutomationCapabilities.ComputeRuntime | undefined => {
|
|
14
|
-
const computeRuntime =
|
|
15
|
-
|
|
18
|
+
const [computeRuntime] = useCapabilities(AutomationCapabilities.ComputeRuntime);
|
|
19
|
+
// One log per change of (capability availability, spaceId) so we can see when
|
|
20
|
+
// the React subscription actually observes the contributed runtime.
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
log('useComputeRuntime', { hasCapability: !!computeRuntime, spaceId: id });
|
|
23
|
+
}, [!!computeRuntime, id]);
|
|
24
|
+
|
|
25
|
+
if (!computeRuntime || id === undefined) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return computeRuntime.getRuntime(id);
|
|
16
30
|
};
|
|
@@ -3,22 +3,62 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import * as Context from 'effect/Context';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Exit from 'effect/Exit';
|
|
8
|
+
import { useEffect, useState } from 'react';
|
|
8
9
|
|
|
9
|
-
import { unwrapExit } from '@dxos/effect';
|
|
10
10
|
import { SpaceId } from '@dxos/keys';
|
|
11
|
+
import { log } from '@dxos/log';
|
|
11
12
|
|
|
12
|
-
import { AutomationCapabilities } from '../types';
|
|
13
13
|
import { useComputeRuntime } from './useComputeRuntime';
|
|
14
14
|
|
|
15
|
+
type ResolvedService<T extends Context.Tag<any, any>> = Context.Tag.Service<T> | undefined;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Resolves a service from the compute runtime for a given space.
|
|
19
|
+
*
|
|
20
|
+
* NOTE: Previously implemented via `use(useMemo(() => runtime.runPromiseExit(...)))`.
|
|
21
|
+
* React's `use()` is weird and unreliable in production builds — the Suspense
|
|
22
|
+
* boundary can stay pending indefinitely without the promise ever resolving
|
|
23
|
+
* from React's perspective (the runtime is built lazily on first invocation
|
|
24
|
+
* and one of its `acquire` steps can block). This `useState` + `useEffect`
|
|
25
|
+
* flavour avoids suspension entirely: the hook returns `undefined` while the
|
|
26
|
+
* service is being acquired or if acquisition fails / times out.
|
|
27
|
+
*/
|
|
15
28
|
export const useComputeRuntimeService = <T extends Context.Tag<any, any>>(
|
|
16
29
|
tag: T,
|
|
17
30
|
spaceId?: SpaceId,
|
|
18
|
-
):
|
|
31
|
+
): ResolvedService<T> => {
|
|
19
32
|
const runtime = useComputeRuntime(spaceId);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
const [service, setService] = useState<ResolvedService<T>>(undefined);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setService(undefined);
|
|
37
|
+
if (!runtime) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let cancelled = false;
|
|
41
|
+
void (async () => {
|
|
42
|
+
try {
|
|
43
|
+
const exit = await runtime.runPromiseExit(tag.pipe(Effect.timeout('30 seconds')));
|
|
44
|
+
if (cancelled) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (Exit.isSuccess(exit)) {
|
|
48
|
+
setService(exit.value);
|
|
49
|
+
} else {
|
|
50
|
+
log.warn('useComputeRuntimeService: failed to acquire service', { cause: exit.cause });
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (!cancelled) {
|
|
54
|
+
log.catch(error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
})();
|
|
58
|
+
return () => {
|
|
59
|
+
cancelled = true;
|
|
60
|
+
};
|
|
61
|
+
}, [runtime, tag]);
|
|
62
|
+
|
|
63
|
+
return service;
|
|
24
64
|
};
|
|
@@ -7,8 +7,8 @@ import type * as Context from 'effect/Context';
|
|
|
7
7
|
import * as Effect from 'effect/Effect';
|
|
8
8
|
import { useEffect, useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { Trigger } from '@dxos/compute';
|
|
11
|
+
import { type Database, Filter, Query } from '@dxos/echo';
|
|
12
12
|
import { TriggerDispatcher, type TriggerDispatcherState } from '@dxos/functions-runtime';
|
|
13
13
|
import { useQuery } from '@dxos/react-client/echo';
|
|
14
14
|
|
|
@@ -24,7 +24,10 @@ interface TriggerRuntimeControls {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const useTriggerRuntimeControls = (db: Database.Database | undefined): TriggerRuntimeControls => {
|
|
27
|
-
const triggers = useQuery(
|
|
27
|
+
const triggers = useQuery(
|
|
28
|
+
db,
|
|
29
|
+
Query.select(Filter.type(Trigger.Trigger)).debugLabel('plugin-automation.useTriggerRuntimeControls'),
|
|
30
|
+
);
|
|
28
31
|
|
|
29
32
|
const [dispatcher, setDispatcher] = useState<Context.Tag.Service<TriggerDispatcher> | undefined>(undefined);
|
|
30
33
|
|
package/src/index.ts
CHANGED
|
@@ -2,5 +2,9 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { Plugin } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { meta } from './meta';
|
|
8
|
+
|
|
9
|
+
export const AutomationPlugin = Plugin.lazy(meta, () => import('#plugin'));
|
|
6
10
|
export { meta } from './meta';
|
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { LayoutOperation, getSpacePath } from '@dxos/app-toolkit';
|
|
8
|
+
import { Operation, Script, Trigger } from '@dxos/compute';
|
|
8
9
|
import { Obj, Ref } from '@dxos/echo';
|
|
9
|
-
import { Script, Trigger } from '@dxos/functions';
|
|
10
10
|
import { type DXN } from '@dxos/keys';
|
|
11
|
-
import { Operation } from '@dxos/operation';
|
|
12
11
|
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
13
12
|
import { Filter } from '@dxos/react-client/echo';
|
|
14
13
|
|
|
@@ -31,7 +30,7 @@ const handler: Operation.WithHandler<typeof CreateTriggerFromTemplate> = CreateT
|
|
|
31
30
|
);
|
|
32
31
|
const [fn] = functions;
|
|
33
32
|
if (fn) {
|
|
34
|
-
Obj.
|
|
33
|
+
Obj.update(trigger, (trigger) => {
|
|
35
34
|
trigger.function = Ref.make(fn);
|
|
36
35
|
});
|
|
37
36
|
}
|
|
@@ -40,17 +39,14 @@ const handler: Operation.WithHandler<typeof CreateTriggerFromTemplate> = CreateT
|
|
|
40
39
|
|
|
41
40
|
switch (template.type) {
|
|
42
41
|
case 'timer': {
|
|
43
|
-
Obj.
|
|
44
|
-
trigger.spec =
|
|
42
|
+
Obj.update(trigger, (trigger) => {
|
|
43
|
+
trigger.spec = Trigger.specTimer(template.cron);
|
|
45
44
|
});
|
|
46
45
|
break;
|
|
47
46
|
}
|
|
48
47
|
case 'queue': {
|
|
49
|
-
Obj.
|
|
50
|
-
trigger.spec =
|
|
51
|
-
kind: 'queue',
|
|
52
|
-
queue: (template.queueDXN as DXN).toString(),
|
|
53
|
-
};
|
|
48
|
+
Obj.update(trigger, (trigger) => {
|
|
49
|
+
trigger.spec = Trigger.specQueue((template.queueDXN as DXN).toString());
|
|
54
50
|
});
|
|
55
51
|
break;
|
|
56
52
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Operation } from '@dxos/compute';
|
|
8
9
|
import { Database } from '@dxos/echo';
|
|
9
|
-
import { Operation } from '@dxos/operation';
|
|
10
10
|
|
|
11
11
|
import { meta } from '#meta';
|
|
12
12
|
|