@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
package/src/index.ts
CHANGED
|
@@ -2,9 +2,5 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export * from './hooks';
|
|
8
|
-
export * from './types';
|
|
9
|
-
|
|
10
|
-
export * from './AutomationPlugin';
|
|
5
|
+
export { AutomationPlugin } from './AutomationPlugin';
|
|
6
|
+
export { meta } from './meta';
|
package/src/meta.ts
CHANGED
|
@@ -6,12 +6,12 @@ import { type Plugin } from '@dxos/app-framework';
|
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
8
|
export const meta: Plugin.Meta = {
|
|
9
|
-
id: 'dxos.
|
|
9
|
+
id: 'org.dxos.plugin.automation',
|
|
10
10
|
name: 'Automation',
|
|
11
11
|
description: trim`
|
|
12
12
|
Workflow automation engine that triggers custom actions based on object events and conditions.
|
|
13
13
|
Create automated pipelines that respond to changes and streamline repetitive tasks.
|
|
14
14
|
`,
|
|
15
|
-
icon: 'ph--
|
|
15
|
+
icon: 'ph--atom--regular',
|
|
16
16
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',
|
|
17
17
|
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Effect from 'effect/Effect';
|
|
6
|
+
|
|
7
|
+
import { LayoutOperation, getSpacePath } from '@dxos/app-toolkit';
|
|
8
|
+
import { Obj, Ref } from '@dxos/echo';
|
|
9
|
+
import { Script, Trigger } from '@dxos/functions';
|
|
10
|
+
import { type DXN } from '@dxos/keys';
|
|
11
|
+
import { Operation } from '@dxos/operation';
|
|
12
|
+
import { SpaceOperation } from '@dxos/plugin-space/operations';
|
|
13
|
+
import { Filter } from '@dxos/react-client/echo';
|
|
14
|
+
|
|
15
|
+
import { meta } from '#meta';
|
|
16
|
+
|
|
17
|
+
import { CreateTriggerFromTemplate } from './definitions';
|
|
18
|
+
|
|
19
|
+
const handler: Operation.WithHandler<typeof CreateTriggerFromTemplate> = CreateTriggerFromTemplate.pipe(
|
|
20
|
+
Operation.withHandler(
|
|
21
|
+
Effect.fnUntraced(function* ({ db, template, enabled = false, scriptName, input }) {
|
|
22
|
+
const trigger = Trigger.make({ enabled, input });
|
|
23
|
+
|
|
24
|
+
// TODO(wittjosiah): Factor out function lookup by script name?
|
|
25
|
+
if (scriptName) {
|
|
26
|
+
const scripts = yield* Effect.promise(() => db.query(Filter.type(Script.Script, { name: scriptName })).run());
|
|
27
|
+
const [script] = scripts;
|
|
28
|
+
if (script) {
|
|
29
|
+
const functions = yield* Effect.promise(() =>
|
|
30
|
+
db.query(Filter.type(Operation.PersistentOperation, { source: Ref.make(script) })).run(),
|
|
31
|
+
);
|
|
32
|
+
const [fn] = functions;
|
|
33
|
+
if (fn) {
|
|
34
|
+
Obj.change(trigger, (trigger) => {
|
|
35
|
+
trigger.function = Ref.make(fn);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
switch (template.type) {
|
|
42
|
+
case 'timer': {
|
|
43
|
+
Obj.change(trigger, (trigger) => {
|
|
44
|
+
trigger.spec = { kind: 'timer', cron: template.cron };
|
|
45
|
+
});
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case 'queue': {
|
|
49
|
+
Obj.change(trigger, (trigger) => {
|
|
50
|
+
trigger.spec = {
|
|
51
|
+
kind: 'queue',
|
|
52
|
+
queue: (template.queueDXN as DXN).toString(),
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
default: {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
yield* Operation.invoke(SpaceOperation.AddObject, {
|
|
63
|
+
object: trigger,
|
|
64
|
+
target: db,
|
|
65
|
+
hidden: true,
|
|
66
|
+
});
|
|
67
|
+
yield* Operation.invoke(LayoutOperation.Open, {
|
|
68
|
+
subject: [`${getSpacePath(db.spaceId)}/settings/${meta.id}.automations`],
|
|
69
|
+
workspace: getSpacePath(db.spaceId),
|
|
70
|
+
});
|
|
71
|
+
}),
|
|
72
|
+
),
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
export default handler;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Database } from '@dxos/echo';
|
|
9
|
+
import { Operation } from '@dxos/operation';
|
|
10
|
+
|
|
11
|
+
import { meta } from '#meta';
|
|
12
|
+
|
|
13
|
+
import { TriggerTemplate } from '../types';
|
|
14
|
+
|
|
15
|
+
const AUTOMATION_OPERATION = `${meta.id}.operation`;
|
|
16
|
+
|
|
17
|
+
export const CreateTriggerFromTemplate = Operation.make({
|
|
18
|
+
meta: { key: `${AUTOMATION_OPERATION}.create-trigger-from-template`, name: 'Create Trigger From Template' },
|
|
19
|
+
services: [Capability.Service],
|
|
20
|
+
input: Schema.Struct({
|
|
21
|
+
db: Database.Database,
|
|
22
|
+
template: TriggerTemplate,
|
|
23
|
+
enabled: Schema.optional(Schema.Boolean),
|
|
24
|
+
scriptName: Schema.optional(Schema.String),
|
|
25
|
+
input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
|
|
26
|
+
}),
|
|
27
|
+
output: Schema.Void,
|
|
28
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { OperationHandlerSet } from '@dxos/operation';
|
|
6
|
+
|
|
7
|
+
export * as AutomationOperation from './definitions';
|
|
8
|
+
|
|
9
|
+
export const AutomationOperationHandlerSet = OperationHandlerSet.lazy(() => import('./create-trigger-from-template'));
|
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { TestSchema } from '@dxos/client/testing';
|
|
8
|
-
import {
|
|
8
|
+
import { JsonSchema, Ref } from '@dxos/echo';
|
|
9
9
|
|
|
10
10
|
export const functions = [
|
|
11
11
|
{
|
|
12
|
+
key: 'example.com/function/chess',
|
|
12
13
|
name: 'example.com/function/chess',
|
|
13
14
|
version: '0.1.0',
|
|
14
|
-
inputSchema:
|
|
15
|
+
inputSchema: JsonSchema.toJsonSchema(
|
|
15
16
|
Schema.Struct({
|
|
16
17
|
level: Schema.Number.annotations({
|
|
17
18
|
title: 'Level',
|
|
@@ -20,10 +21,11 @@ export const functions = [
|
|
|
20
21
|
),
|
|
21
22
|
},
|
|
22
23
|
{
|
|
24
|
+
key: 'example.com/function/forex',
|
|
23
25
|
name: 'example.com/function/forex',
|
|
24
26
|
version: '0.1.0',
|
|
25
27
|
binding: 'FOREX',
|
|
26
|
-
inputSchema:
|
|
28
|
+
inputSchema: JsonSchema.toJsonSchema(
|
|
27
29
|
Schema.Struct({
|
|
28
30
|
from: Schema.String.annotations({ title: 'Currency from' }),
|
|
29
31
|
to: Schema.String.annotations({ title: 'Currency to' }),
|
|
@@ -31,11 +33,12 @@ export const functions = [
|
|
|
31
33
|
),
|
|
32
34
|
},
|
|
33
35
|
{
|
|
36
|
+
key: 'example.com/function/ping-contact',
|
|
34
37
|
name: 'example.com/function/ping-contact',
|
|
35
38
|
version: '0.0.1',
|
|
36
|
-
inputSchema:
|
|
39
|
+
inputSchema: JsonSchema.toJsonSchema(
|
|
37
40
|
Schema.Struct({
|
|
38
|
-
contact:
|
|
41
|
+
contact: Ref.Ref(TestSchema.ContactType).annotations({ title: 'Contact' }),
|
|
39
42
|
}),
|
|
40
43
|
),
|
|
41
44
|
},
|
package/src/translations.ts
CHANGED
|
@@ -4,49 +4,48 @@
|
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
7
|
+
import { meta } from '#meta';
|
|
8
8
|
|
|
9
9
|
export const translations = [
|
|
10
10
|
{
|
|
11
11
|
'en-US': {
|
|
12
12
|
[meta.id]: {
|
|
13
|
-
'plugin
|
|
14
|
-
'automation
|
|
15
|
-
'script
|
|
16
|
-
'automation
|
|
17
|
-
'automation
|
|
18
|
-
|
|
19
|
-
'runtime
|
|
20
|
-
'runtime
|
|
13
|
+
'plugin.name': 'Automation',
|
|
14
|
+
'automation-panel.label': 'Automations',
|
|
15
|
+
'script-automation.label': 'Automation',
|
|
16
|
+
'automation-verbose.label': 'Manage automations',
|
|
17
|
+
'automation.description': 'You can manage all the triggers which automate your space here.',
|
|
18
|
+
|
|
19
|
+
'runtime.label': 'Enable Local Runtime',
|
|
20
|
+
'runtime.description':
|
|
21
21
|
'This will start a trigger dispatcher locally for this space to run triggers on your device while Composer is running.',
|
|
22
22
|
|
|
23
|
-
'functions
|
|
24
|
-
'functions
|
|
25
|
-
'functions
|
|
26
|
-
'functions
|
|
27
|
-
'functions
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
|
|
31
|
-
'
|
|
32
|
-
|
|
33
|
-
'
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'new
|
|
37
|
-
|
|
38
|
-
'trigger
|
|
39
|
-
'trigger
|
|
40
|
-
'trigger
|
|
41
|
-
'trigger
|
|
42
|
-
'trigger
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
'trigger
|
|
46
|
-
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'trigger payload prop name placeholder': 'New payload property name',
|
|
23
|
+
'functions-panel.label': 'Functions',
|
|
24
|
+
'functions-verbose.label': 'Manage deployed functions',
|
|
25
|
+
'functions-registry-verbose.label': 'Functions registry',
|
|
26
|
+
'functions-registry.description': 'Import functions from the registry',
|
|
27
|
+
'functions.description': 'You can manage all the functions deployed from your space on EDGE here.',
|
|
28
|
+
'show-source-button.label': 'Show source',
|
|
29
|
+
'delete-function-button.label': 'Delete function',
|
|
30
|
+
|
|
31
|
+
'function-parameters.label': 'Function parameters',
|
|
32
|
+
|
|
33
|
+
'trigger-editor.title': 'Configure Trigger',
|
|
34
|
+
'trigger-editor.description':
|
|
35
|
+
'Triggers are used to run functions at specific times or when specific events occur.',
|
|
36
|
+
'new-trigger.label': 'Add Trigger',
|
|
37
|
+
|
|
38
|
+
'trigger-type.timer.label': 'Timer',
|
|
39
|
+
'trigger-type.webhook.label': 'Webhook',
|
|
40
|
+
'trigger-type.websocket.label': 'Websocket',
|
|
41
|
+
'trigger-type.subscription.label': 'Subscription',
|
|
42
|
+
'trigger-type.email.label': 'Email',
|
|
43
|
+
'trigger-type.queue.label': 'Feed',
|
|
44
|
+
|
|
45
|
+
'trigger-payload-prop-name.placeholder': 'New payload property name',
|
|
46
|
+
'import-function-button.label': 'Loading...',
|
|
47
|
+
'loading-functions.message': 'Loading functions...',
|
|
48
|
+
'update-function-button.label': 'Update',
|
|
50
49
|
},
|
|
51
50
|
},
|
|
52
51
|
},
|
|
@@ -6,12 +6,21 @@ import type * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
|
6
6
|
|
|
7
7
|
import { type AiService, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';
|
|
8
8
|
import { Capability } from '@dxos/app-framework';
|
|
9
|
-
import {
|
|
10
|
-
import type {
|
|
9
|
+
import { AgentService } from '@dxos/assistant';
|
|
10
|
+
import type { Blueprint } from '@dxos/blueprints';
|
|
11
|
+
import { type Database, type Feed } from '@dxos/echo';
|
|
12
|
+
import type {
|
|
13
|
+
CredentialsService,
|
|
14
|
+
FunctionInvocationService,
|
|
15
|
+
Process,
|
|
16
|
+
QueueService,
|
|
17
|
+
TracingService,
|
|
18
|
+
} from '@dxos/functions';
|
|
11
19
|
import type { TriggerDispatcher, TriggerStateStore } from '@dxos/functions-runtime';
|
|
12
20
|
import type { SpaceId } from '@dxos/keys';
|
|
21
|
+
import type { Operation } from '@dxos/operation';
|
|
13
22
|
|
|
14
|
-
import { meta } from '
|
|
23
|
+
import { meta } from '#meta';
|
|
15
24
|
|
|
16
25
|
export namespace AutomationCapabilities {
|
|
17
26
|
/**
|
|
@@ -22,10 +31,15 @@ export namespace AutomationCapabilities {
|
|
|
22
31
|
| TriggerStateStore
|
|
23
32
|
| AiService.AiService
|
|
24
33
|
| Database.Service
|
|
34
|
+
| Feed.FeedService
|
|
25
35
|
| QueueService
|
|
26
36
|
| CredentialsService
|
|
27
|
-
|
|
|
28
|
-
|
|
|
37
|
+
| Blueprint.RegistryService
|
|
38
|
+
| AgentService.AgentService
|
|
39
|
+
| Process.ProcessMonitorService
|
|
40
|
+
| TracingService // TODO(dmaretskyi): Probably should not be provided here.
|
|
41
|
+
| FunctionInvocationService // TODO(dmaretskyi): Deprecated
|
|
42
|
+
| Operation.Service
|
|
29
43
|
// TODO(dmaretskyi): Those should be provided at AI-chat call site.
|
|
30
44
|
| ToolResolverService
|
|
31
45
|
| ToolExecutionService;
|
|
@@ -38,5 +52,5 @@ export namespace AutomationCapabilities {
|
|
|
38
52
|
/**
|
|
39
53
|
* Runtime for executing agents, functions, and triggers.
|
|
40
54
|
*/
|
|
41
|
-
export const ComputeRuntime = Capability.make<ComputeRuntimeProvider>(`${meta.id}
|
|
55
|
+
export const ComputeRuntime = Capability.make<ComputeRuntimeProvider>(`${meta.id}.capability.compute-runtime`);
|
|
42
56
|
}
|
package/src/types/events.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { ActivationEvent } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
import { meta } from '
|
|
7
|
+
import { meta } from '#meta';
|
|
8
8
|
|
|
9
9
|
export namespace AutomationEvents {
|
|
10
|
-
export const ComputeRuntimeReady = ActivationEvent.make(`${meta.id}
|
|
10
|
+
export const ComputeRuntimeReady = ActivationEvent.make(`${meta.id}.event.compute-runtime-ready`);
|
|
11
11
|
}
|
package/src/types/schema.ts
CHANGED
|
@@ -4,20 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import { Capability } from '@dxos/app-framework';
|
|
8
7
|
import { Database } from '@dxos/echo';
|
|
9
|
-
import { Operation } from '@dxos/operation';
|
|
10
8
|
|
|
11
|
-
import { meta } from '
|
|
9
|
+
import { meta } from '#meta';
|
|
12
10
|
|
|
13
|
-
const TriggerTemplate = Schema.Union(
|
|
11
|
+
export const TriggerTemplate = Schema.Union(
|
|
14
12
|
Schema.Struct({ type: Schema.Literal('timer'), cron: Schema.String }),
|
|
15
13
|
Schema.Struct({ type: Schema.Literal('queue'), queueDXN: Schema.Any }),
|
|
16
14
|
);
|
|
17
15
|
|
|
18
16
|
export namespace AutomationAction {
|
|
19
17
|
export class CreateTriggerFromTemplate extends Schema.TaggedClass<CreateTriggerFromTemplate>()(
|
|
20
|
-
`${meta.id}
|
|
18
|
+
`${meta.id}.action.create-trigger-from-template`,
|
|
21
19
|
{
|
|
22
20
|
input: Schema.Struct({
|
|
23
21
|
db: Database.Database,
|
|
@@ -31,22 +29,3 @@ export namespace AutomationAction {
|
|
|
31
29
|
},
|
|
32
30
|
) {}
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
const AUTOMATION_OPERATION = `${meta.id}/operation`;
|
|
36
|
-
|
|
37
|
-
export namespace AutomationOperation {
|
|
38
|
-
export const CreateTriggerFromTemplate = Operation.make({
|
|
39
|
-
meta: { key: `${AUTOMATION_OPERATION}/create-trigger-from-template`, name: 'Create Trigger From Template' },
|
|
40
|
-
services: [Capability.Service],
|
|
41
|
-
schema: {
|
|
42
|
-
input: Schema.Struct({
|
|
43
|
-
db: Database.Database,
|
|
44
|
-
template: TriggerTemplate,
|
|
45
|
-
enabled: Schema.optional(Schema.Boolean),
|
|
46
|
-
scriptName: Schema.optional(Schema.String),
|
|
47
|
-
input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
|
|
48
|
-
}),
|
|
49
|
-
output: Schema.Void,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutomationPanel,
|
|
3
|
-
AutomationPanel_default
|
|
4
|
-
} from "./chunk-YWLEY2FD.mjs";
|
|
5
|
-
import "./chunk-QW3EM35H.mjs";
|
|
6
|
-
import "./chunk-PZNBEKO5.mjs";
|
|
7
|
-
export {
|
|
8
|
-
AutomationPanel,
|
|
9
|
-
AutomationPanel_default as default
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=AutomationPanel-FAS6ADCW.mjs.map
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useTriggerRuntimeControls
|
|
3
|
-
} from "./chunk-RAF2FJST.mjs";
|
|
4
|
-
import "./chunk-JOXPQ27I.mjs";
|
|
5
|
-
import {
|
|
6
|
-
AutomationPanel
|
|
7
|
-
} from "./chunk-YWLEY2FD.mjs";
|
|
8
|
-
import "./chunk-QW3EM35H.mjs";
|
|
9
|
-
import {
|
|
10
|
-
meta
|
|
11
|
-
} from "./chunk-PZNBEKO5.mjs";
|
|
12
|
-
|
|
13
|
-
// src/components/AutomationSettings.tsx
|
|
14
|
-
import React2 from "react";
|
|
15
|
-
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
16
|
-
import { ControlPage, ControlSection } from "@dxos/react-ui-form";
|
|
17
|
-
|
|
18
|
-
// src/components/TriggerSettings.tsx
|
|
19
|
-
import React from "react";
|
|
20
|
-
import { Input, useTranslation } from "@dxos/react-ui";
|
|
21
|
-
import { ControlItemInput } from "@dxos/react-ui-form";
|
|
22
|
-
var TriggersSettings = ({ db }) => {
|
|
23
|
-
const { triggers, isRunning, start, stop } = useTriggerRuntimeControls(db);
|
|
24
|
-
const { t } = useTranslation(meta.id);
|
|
25
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
26
|
-
className: "container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content]"
|
|
27
|
-
}, /* @__PURE__ */ React.createElement(ControlItemInput, {
|
|
28
|
-
title: t("runtime label"),
|
|
29
|
-
description: t("runtime description")
|
|
30
|
-
}, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
31
|
-
classNames: "justify-self-end",
|
|
32
|
-
checked: isRunning,
|
|
33
|
-
onCheckedChange: isRunning ? stop : start
|
|
34
|
-
})));
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
// src/components/AutomationSettings.tsx
|
|
38
|
-
var AutomationSettings = (props) => {
|
|
39
|
-
const { t } = useTranslation2(meta.id);
|
|
40
|
-
return /* @__PURE__ */ React2.createElement(ControlPage, null, /* @__PURE__ */ React2.createElement(ControlSection, {
|
|
41
|
-
title: t("automation verbose label", {
|
|
42
|
-
ns: meta.id
|
|
43
|
-
}),
|
|
44
|
-
description: t("automation description", {
|
|
45
|
-
ns: meta.id
|
|
46
|
-
})
|
|
47
|
-
}, /* @__PURE__ */ React2.createElement(AutomationPanel, props), /* @__PURE__ */ React2.createElement(TriggersSettings, {
|
|
48
|
-
db: props.space.db
|
|
49
|
-
})));
|
|
50
|
-
};
|
|
51
|
-
var AutomationSettings_default = AutomationSettings;
|
|
52
|
-
export {
|
|
53
|
-
AutomationSettings,
|
|
54
|
-
AutomationSettings_default as default
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=AutomationSettings-XN2OIYWL.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/AutomationSettings.tsx", "../../../src/components/TriggerSettings.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { useTranslation } from '@dxos/react-ui';\nimport { ControlPage, ControlSection } from '@dxos/react-ui-form';\n\nimport { meta } from '../meta';\n\nimport { AutomationPanel, type AutomationPanelProps } from './AutomationPanel';\nimport { TriggersSettings } from './TriggerSettings';\n\nexport const AutomationSettings = (props: AutomationPanelProps) => {\n const { t } = useTranslation(meta.id);\n return (\n <ControlPage>\n <ControlSection\n title={t('automation verbose label', { ns: meta.id })}\n description={t('automation description', { ns: meta.id })}\n >\n <AutomationPanel {...props} />\n <TriggersSettings db={props.space.db} />\n </ControlSection>\n </ControlPage>\n );\n};\n\nexport default AutomationSettings;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Database } from '@dxos/echo';\nimport { Input, useTranslation } from '@dxos/react-ui';\nimport { ControlItemInput } from '@dxos/react-ui-form';\n\nimport { useTriggerRuntimeControls } from '../hooks';\nimport { meta } from '../meta';\n\nexport const TriggersSettings = ({ db }: { db: Database.Database }) => {\n const { triggers, isRunning, start, stop } = useTriggerRuntimeControls(db);\n const { t } = useTranslation(meta.id);\n\n return (\n <div className='container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content]'>\n <ControlItemInput title={t('runtime label')} description={t('runtime description')}>\n <Input.Switch classNames='justify-self-end' checked={isRunning} onCheckedChange={isRunning ? stop : start} />\n </ControlItemInput>\n </div>\n );\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;AAIA,OAAOA,YAAW;AAElB,SAASC,kBAAAA,uBAAsB;AAC/B,SAASC,aAAaC,sBAAsB;;;ACH5C,OAAOC,WAAW;AAGlB,SAASC,OAAOC,sBAAsB;AACtC,SAASC,wBAAwB;AAK1B,IAAMC,mBAAmB,CAAC,EAAEC,GAAE,MAA6B;AAChE,QAAM,EAAEC,UAAUC,WAAWC,OAAOC,KAAI,IAAKC,0BAA0BL,EAAAA;AACvE,QAAM,EAAEM,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AAEpC,SACE,sBAAA,cAACC,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACC,kBAAAA;IAAiBC,OAAOP,EAAE,eAAA;IAAkBQ,aAAaR,EAAE,qBAAA;KAC1D,sBAAA,cAACS,MAAMC,QAAM;IAACC,YAAW;IAAmBC,SAAShB;IAAWiB,iBAAiBjB,YAAYE,OAAOD;;AAI5G;;;ADVO,IAAMiB,qBAAqB,CAACC,UAAAA;AACjC,QAAM,EAAEC,EAAC,IAAKC,gBAAeC,KAAKC,EAAE;AACpC,SACE,gBAAAC,OAAA,cAACC,aAAAA,MACC,gBAAAD,OAAA,cAACE,gBAAAA;IACCC,OAAOP,EAAE,4BAA4B;MAAEQ,IAAIN,KAAKC;IAAG,CAAA;IACnDM,aAAaT,EAAE,0BAA0B;MAAEQ,IAAIN,KAAKC;IAAG,CAAA;KAEvD,gBAAAC,OAAA,cAACM,iBAAoBX,KAAAA,GACrB,gBAAAK,OAAA,cAACO,kBAAAA;IAAiBC,IAAIb,MAAMc,MAAMD;;AAI1C;AAEA,IAAA,6BAAed;",
|
|
6
|
-
"names": ["React", "useTranslation", "ControlPage", "ControlSection", "React", "Input", "useTranslation", "ControlItemInput", "TriggersSettings", "db", "triggers", "isRunning", "start", "stop", "useTriggerRuntimeControls", "t", "useTranslation", "meta", "id", "div", "className", "ControlItemInput", "title", "description", "Input", "Switch", "classNames", "checked", "onCheckedChange", "AutomationSettings", "props", "t", "useTranslation", "meta", "id", "React", "ControlPage", "ControlSection", "title", "ns", "description", "AutomationPanel", "TriggersSettings", "db", "space"]
|
|
7
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FunctionsPanel
|
|
3
|
-
} from "./chunk-BFUIVUQH.mjs";
|
|
4
|
-
import {
|
|
5
|
-
meta
|
|
6
|
-
} from "./chunk-PZNBEKO5.mjs";
|
|
7
|
-
|
|
8
|
-
// src/components/FunctionsContainer.tsx
|
|
9
|
-
import React2 from "react";
|
|
10
|
-
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
11
|
-
import { ControlPage, ControlSection } from "@dxos/react-ui-form";
|
|
12
|
-
|
|
13
|
-
// src/components/FunctionsRegistry/FunctionsRegistry.tsx
|
|
14
|
-
import * as Schema from "effect/Schema";
|
|
15
|
-
import { useState } from "react";
|
|
16
|
-
import React, { useCallback } from "react";
|
|
17
|
-
import { Function } from "@dxos/functions";
|
|
18
|
-
import { getDeployedFunctions } from "@dxos/functions-runtime/edge";
|
|
19
|
-
import { useClient } from "@dxos/react-client";
|
|
20
|
-
import { Filter, Query, useQuery } from "@dxos/react-client/echo";
|
|
21
|
-
import { useAsyncEffect } from "@dxos/react-ui";
|
|
22
|
-
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
23
|
-
import { controlItemClasses } from "@dxos/react-ui-form";
|
|
24
|
-
import { List } from "@dxos/react-ui-list";
|
|
25
|
-
import { ghostHover, mx } from "@dxos/ui-theme";
|
|
26
|
-
var grid = "grid grid-cols-[1fr_1fr_auto] min-bs-[2.5rem]";
|
|
27
|
-
var FunctionsRegistry = ({ space }) => {
|
|
28
|
-
const client = useClient();
|
|
29
|
-
const [loading, setLoading] = useState(true);
|
|
30
|
-
const [functions, setFunctions] = useState([]);
|
|
31
|
-
const { t } = useTranslation(meta.id);
|
|
32
|
-
const dbFunctions = useQuery(space.db, Filter.type(Function.Function));
|
|
33
|
-
const state = (func) => {
|
|
34
|
-
const dbFunction = dbFunctions.find((f) => f.key === func.key);
|
|
35
|
-
if (!dbFunction) {
|
|
36
|
-
return "import";
|
|
37
|
-
}
|
|
38
|
-
if (dbFunction.version === func.version && dbFunction.updated === func.updated) {
|
|
39
|
-
return "none";
|
|
40
|
-
}
|
|
41
|
-
return "update";
|
|
42
|
-
};
|
|
43
|
-
useAsyncEffect(async () => {
|
|
44
|
-
setLoading(true);
|
|
45
|
-
const functions2 = await getDeployedFunctions(client, true);
|
|
46
|
-
setFunctions(functions2);
|
|
47
|
-
setLoading(false);
|
|
48
|
-
}, []);
|
|
49
|
-
const hanleImportOrUpdate = useCallback(async (func) => {
|
|
50
|
-
const functions2 = await space.db.query(Query.type(Function.Function, {
|
|
51
|
-
key: func.key
|
|
52
|
-
})).run();
|
|
53
|
-
const [existingFunc] = functions2;
|
|
54
|
-
if (!existingFunc) {
|
|
55
|
-
space.db.add(func);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
Function.setFrom(existingFunc, func);
|
|
59
|
-
}, [
|
|
60
|
-
space
|
|
61
|
-
]);
|
|
62
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
63
|
-
role: "none",
|
|
64
|
-
className: mx(controlItemClasses)
|
|
65
|
-
}, functions.length > 0 && /* @__PURE__ */ React.createElement(List.Root, {
|
|
66
|
-
items: functions,
|
|
67
|
-
isItem: Schema.is(Function.Function),
|
|
68
|
-
getId: (func) => func.id
|
|
69
|
-
}, ({ items }) => /* @__PURE__ */ React.createElement("div", {
|
|
70
|
-
role: "list",
|
|
71
|
-
className: "flex flex-col is-full"
|
|
72
|
-
}, items?.map((func) => /* @__PURE__ */ React.createElement(List.Item, {
|
|
73
|
-
key: func.id,
|
|
74
|
-
item: func,
|
|
75
|
-
classNames: mx(grid, ghostHover, "items-center", "pli-2", "min-bs-[3rem]")
|
|
76
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
77
|
-
className: "flex flex-col truncate"
|
|
78
|
-
}, /* @__PURE__ */ React.createElement(List.ItemTitle, {
|
|
79
|
-
classNames: "truncate"
|
|
80
|
-
}, func.name), /* @__PURE__ */ React.createElement("div", {
|
|
81
|
-
className: "text-xs text-description truncate"
|
|
82
|
-
}, func.key)), /* @__PURE__ */ React.createElement("div", {
|
|
83
|
-
className: "flex flex-col truncate"
|
|
84
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
85
|
-
className: "text-xs text-description truncate"
|
|
86
|
-
}, func.version), /* @__PURE__ */ React.createElement("div", {
|
|
87
|
-
className: "text-xs text-description truncate"
|
|
88
|
-
}, func.updated ? `Uploaded ${new Date(func.updated).toLocaleString()}` : "")), /* @__PURE__ */ React.createElement(IconButton, {
|
|
89
|
-
iconOnly: true,
|
|
90
|
-
icon: state(func) === "update" ? "ph--arrows-clockwise--regular" : "ph--download--regular",
|
|
91
|
-
label: state(func) === "update" ? t("update function button label") : t("import function button label"),
|
|
92
|
-
disabled: state(func) === "none",
|
|
93
|
-
onClick: () => hanleImportOrUpdate(func)
|
|
94
|
-
}))))), functions.length === 0 && !loading && /* @__PURE__ */ React.createElement("div", {
|
|
95
|
-
className: "text-center plb-4 text-gray-500"
|
|
96
|
-
}, t("no functions found")), loading && /* @__PURE__ */ React.createElement("div", {
|
|
97
|
-
className: "text-center plb-4 text-gray-500"
|
|
98
|
-
}, t("loading functions")));
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// src/components/FunctionsContainer.tsx
|
|
102
|
-
var FunctionsContainer = ({ space }) => {
|
|
103
|
-
const { t } = useTranslation2(meta.id);
|
|
104
|
-
return /* @__PURE__ */ React2.createElement(ControlPage, null, /* @__PURE__ */ React2.createElement(ControlSection, {
|
|
105
|
-
title: t("functions verbose label", {
|
|
106
|
-
ns: meta.id
|
|
107
|
-
}),
|
|
108
|
-
description: t("functions description", {
|
|
109
|
-
ns: meta.id
|
|
110
|
-
})
|
|
111
|
-
}, /* @__PURE__ */ React2.createElement(FunctionsPanel, {
|
|
112
|
-
space
|
|
113
|
-
})), /* @__PURE__ */ React2.createElement(ControlSection, {
|
|
114
|
-
title: t("functions registry verbose label", {
|
|
115
|
-
ns: meta.id
|
|
116
|
-
}),
|
|
117
|
-
description: t("functions registry description", {
|
|
118
|
-
ns: meta.id
|
|
119
|
-
})
|
|
120
|
-
}, /* @__PURE__ */ React2.createElement(FunctionsRegistry, {
|
|
121
|
-
space
|
|
122
|
-
})));
|
|
123
|
-
};
|
|
124
|
-
var FunctionsContainer_default = FunctionsContainer;
|
|
125
|
-
export {
|
|
126
|
-
FunctionsContainer,
|
|
127
|
-
FunctionsContainer_default as default
|
|
128
|
-
};
|
|
129
|
-
//# sourceMappingURL=FunctionsContainer-6QLC7JP4.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/FunctionsContainer.tsx", "../../../src/components/FunctionsRegistry/FunctionsRegistry.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Space } from '@dxos/react-client/echo';\nimport { useTranslation } from '@dxos/react-ui';\nimport { ControlPage, ControlSection } from '@dxos/react-ui-form';\n\nimport { meta } from '../meta';\n\nimport { FunctionsPanel } from './FunctionsPanel';\nimport { FunctionsRegistry } from './FunctionsRegistry';\n\nexport const FunctionsContainer = ({ space }: { space: Space }) => {\n const { t } = useTranslation(meta.id);\n return (\n <ControlPage>\n <ControlSection\n title={t('functions verbose label', { ns: meta.id })}\n description={t('functions description', { ns: meta.id })}\n >\n <FunctionsPanel space={space} />\n </ControlSection>\n <ControlSection\n title={t('functions registry verbose label', { ns: meta.id })}\n description={t('functions registry description', { ns: meta.id })}\n >\n <FunctionsRegistry space={space} />\n </ControlSection>\n </ControlPage>\n );\n};\n\nexport default FunctionsContainer;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport { useState } from 'react';\nimport React, { useCallback } from 'react';\n\nimport { Function } from '@dxos/functions';\nimport { getDeployedFunctions } from '@dxos/functions-runtime/edge';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, Query, type Space, useQuery } from '@dxos/react-client/echo';\nimport { useAsyncEffect } from '@dxos/react-ui';\nimport { IconButton, useTranslation } from '@dxos/react-ui';\nimport { controlItemClasses } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/ui-theme';\n\nimport { meta } from '../../meta';\n\nconst grid = 'grid grid-cols-[1fr_1fr_auto] min-bs-[2.5rem]';\n\ntype FunctionsRegistryProps = {\n space: Space;\n};\n\nexport const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {\n const client = useClient();\n const [loading, setLoading] = useState(true);\n const [functions, setFunctions] = useState<Function.Function[]>([]);\n const { t } = useTranslation(meta.id);\n\n const dbFunctions = useQuery(space.db, Filter.type(Function.Function));\n\n const state = (func: Function.Function) => {\n const dbFunction = dbFunctions.find((f) => f.key === func.key);\n if (!dbFunction) {\n return 'import';\n }\n if (dbFunction.version === func.version && dbFunction.updated === func.updated) {\n return 'none';\n }\n return 'update';\n };\n\n useAsyncEffect(async () => {\n setLoading(true);\n const functions = await getDeployedFunctions(client, true);\n setFunctions(functions);\n setLoading(false);\n }, []);\n\n const hanleImportOrUpdate = useCallback(\n async (func: Function.Function) => {\n const functions = await space.db.query(Query.type(Function.Function, { key: func.key })).run();\n const [existingFunc] = functions;\n if (!existingFunc) {\n space.db.add(func);\n return;\n }\n Function.setFrom(existingFunc, func);\n },\n [space],\n );\n\n return (\n <div role='none' className={mx(controlItemClasses)}>\n {functions.length > 0 && (\n <List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>\n {({ items }) => (\n <div role='list' className='flex flex-col is-full'>\n {items?.map((func) => (\n <List.Item<Function.Function>\n key={func.id}\n item={func}\n classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}\n >\n <div className='flex flex-col truncate'>\n <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>\n <div className='text-xs text-description truncate'>{func.key}</div>\n </div>\n <div className='flex flex-col truncate'>\n <div className='text-xs text-description truncate'>{func.version}</div>\n <div className='text-xs text-description truncate'>\n {func.updated ? `Uploaded ${new Date(func.updated).toLocaleString()}` : ''}\n </div>\n </div>\n\n <IconButton\n iconOnly\n icon={state(func) === 'update' ? 'ph--arrows-clockwise--regular' : 'ph--download--regular'}\n label={\n state(func) === 'update' ? t('update function button label') : t('import function button label')\n }\n disabled={state(func) === 'none'}\n onClick={() => hanleImportOrUpdate(func)}\n />\n </List.Item>\n ))}\n </div>\n )}\n </List.Root>\n )}\n\n {functions.length === 0 && !loading && (\n <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>\n )}\n {loading && <div className='text-center plb-4 text-gray-500'>{t('loading functions')}</div>}\n </div>\n );\n};\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["React", "useTranslation", "ControlPage", "ControlSection", "Schema", "useState", "React", "useCallback", "Function", "getDeployedFunctions", "useClient", "Filter", "Query", "useQuery", "useAsyncEffect", "IconButton", "useTranslation", "controlItemClasses", "List", "ghostHover", "mx", "grid", "FunctionsRegistry", "space", "client", "useClient", "loading", "setLoading", "useState", "functions", "setFunctions", "t", "useTranslation", "meta", "id", "dbFunctions", "useQuery", "db", "Filter", "type", "Function", "state", "func", "dbFunction", "find", "f", "key", "version", "updated", "useAsyncEffect", "getDeployedFunctions", "hanleImportOrUpdate", "useCallback", "query", "Query", "run", "existingFunc", "add", "setFrom", "div", "role", "className", "mx", "controlItemClasses", "length", "List", "Root", "items", "isItem", "is", "getId", "map", "Item", "item", "classNames", "ghostHover", "ItemTitle", "name", "Date", "toLocaleString", "IconButton", "iconOnly", "icon", "label", "disabled", "onClick", "FunctionsContainer", "space", "t", "useTranslation", "meta", "id", "React", "ControlPage", "ControlSection", "title", "ns", "description", "FunctionsPanel", "FunctionsRegistry"]
|
|
7
|
-
}
|