@dxos/plugin-automation 0.8.1 → 0.8.2-main.f081794

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.
Files changed (139) hide show
  1. package/dist/lib/browser/AutomationContainer-KEQ5RNIW.mjs +34 -0
  2. package/dist/lib/browser/AutomationContainer-KEQ5RNIW.mjs.map +7 -0
  3. package/dist/lib/browser/AutomationPanel-G3OB6ELR.mjs +11 -0
  4. package/dist/lib/browser/AutomationPanel-G3OB6ELR.mjs.map +7 -0
  5. package/dist/lib/browser/FunctionsContainer-STXBW4CX.mjs +33 -0
  6. package/dist/lib/browser/FunctionsContainer-STXBW4CX.mjs.map +7 -0
  7. package/dist/lib/browser/FunctionsPanel-JJPLIAJW.mjs +10 -0
  8. package/dist/lib/browser/FunctionsPanel-JJPLIAJW.mjs.map +7 -0
  9. package/dist/lib/browser/{app-graph-builder-K3BIQFWW.mjs → app-graph-builder-ND64CHOM.mjs} +42 -1
  10. package/dist/lib/browser/app-graph-builder-ND64CHOM.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-65VL4EYS.mjs +88 -0
  12. package/dist/lib/browser/chunk-65VL4EYS.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-FCLWFVFX.mjs +39 -0
  14. package/dist/lib/browser/chunk-FCLWFVFX.mjs.map +7 -0
  15. package/dist/lib/browser/{AutomationPanel-YAHFXQX6.mjs → chunk-NGG4ICAQ.mjs} +13 -12
  16. package/dist/lib/browser/chunk-NGG4ICAQ.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-QJPKWYTL.mjs +14 -0
  18. package/dist/lib/browser/chunk-QJPKWYTL.mjs.map +7 -0
  19. package/dist/lib/browser/index.mjs +23 -17
  20. package/dist/lib/browser/index.mjs.map +3 -3
  21. package/dist/lib/browser/intent-resolver-3J647TIZ.mjs +71 -0
  22. package/dist/lib/browser/intent-resolver-3J647TIZ.mjs.map +7 -0
  23. package/dist/lib/browser/meta.json +1 -1
  24. package/dist/lib/browser/react-surface-L22QIANU.mjs +68 -0
  25. package/dist/lib/browser/react-surface-L22QIANU.mjs.map +7 -0
  26. package/dist/lib/browser/types.mjs +8 -0
  27. package/dist/lib/browser/types.mjs.map +7 -0
  28. package/dist/lib/node/AutomationContainer-E5I76FPP.cjs +62 -0
  29. package/dist/lib/node/AutomationContainer-E5I76FPP.cjs.map +7 -0
  30. package/dist/lib/node/AutomationPanel-YLXAFJDP.cjs +32 -0
  31. package/dist/lib/node/AutomationPanel-YLXAFJDP.cjs.map +7 -0
  32. package/dist/lib/node/FunctionsContainer-3HCURMEB.cjs +61 -0
  33. package/dist/lib/node/FunctionsContainer-3HCURMEB.cjs.map +7 -0
  34. package/dist/lib/node/FunctionsPanel-SYIZHPGU.cjs +31 -0
  35. package/dist/lib/node/FunctionsPanel-SYIZHPGU.cjs.map +7 -0
  36. package/dist/lib/node/{app-graph-builder-HO4FPGZ5.cjs → app-graph-builder-TVFR6RXO.cjs} +45 -4
  37. package/dist/lib/node/app-graph-builder-TVFR6RXO.cjs.map +7 -0
  38. package/dist/lib/node/chunk-BSK5SHTR.cjs +116 -0
  39. package/dist/lib/node/chunk-BSK5SHTR.cjs.map +7 -0
  40. package/dist/lib/node/{chunk-AGJ6XTDN.cjs → chunk-L5TWLPGA.cjs} +16 -7
  41. package/dist/lib/node/chunk-L5TWLPGA.cjs.map +7 -0
  42. package/dist/lib/node/chunk-PSIJDHAX.cjs +58 -0
  43. package/dist/lib/node/chunk-PSIJDHAX.cjs.map +7 -0
  44. package/dist/lib/node/{AutomationPanel-ZKAMIU6O.cjs → chunk-SRXHHBDE.cjs} +19 -14
  45. package/dist/lib/node/chunk-SRXHHBDE.cjs.map +7 -0
  46. package/dist/lib/node/index.cjs +23 -17
  47. package/dist/lib/node/index.cjs.map +3 -3
  48. package/dist/lib/node/intent-resolver-4YYZ2MMZ.cjs +87 -0
  49. package/dist/lib/node/intent-resolver-4YYZ2MMZ.cjs.map +7 -0
  50. package/dist/lib/node/meta.json +1 -1
  51. package/dist/lib/node/{react-surface-52M54VWV.cjs → react-surface-PCZCHIET.cjs} +36 -12
  52. package/dist/lib/node/react-surface-PCZCHIET.cjs.map +7 -0
  53. package/dist/lib/node/types.cjs +30 -0
  54. package/dist/lib/node/types.cjs.map +7 -0
  55. package/dist/lib/node-esm/AutomationContainer-22PUFPSE.mjs +35 -0
  56. package/dist/lib/node-esm/AutomationContainer-22PUFPSE.mjs.map +7 -0
  57. package/dist/lib/node-esm/AutomationPanel-6UXIAJVS.mjs +12 -0
  58. package/dist/lib/node-esm/AutomationPanel-6UXIAJVS.mjs.map +7 -0
  59. package/dist/lib/node-esm/FunctionsContainer-XG5WVAN3.mjs +34 -0
  60. package/dist/lib/node-esm/FunctionsContainer-XG5WVAN3.mjs.map +7 -0
  61. package/dist/lib/node-esm/FunctionsPanel-J3QGUESH.mjs +11 -0
  62. package/dist/lib/node-esm/FunctionsPanel-J3QGUESH.mjs.map +7 -0
  63. package/dist/lib/node-esm/{app-graph-builder-XCJR33VS.mjs → app-graph-builder-NYLOXWVV.mjs} +42 -1
  64. package/dist/lib/node-esm/app-graph-builder-NYLOXWVV.mjs.map +7 -0
  65. package/dist/lib/node-esm/chunk-4UPGANGV.mjs +89 -0
  66. package/dist/lib/node-esm/chunk-4UPGANGV.mjs.map +7 -0
  67. package/dist/lib/node-esm/{AutomationPanel-XF7YPSKM.mjs → chunk-HMYAQLGF.mjs} +13 -12
  68. package/dist/lib/node-esm/chunk-HMYAQLGF.mjs.map +7 -0
  69. package/dist/lib/node-esm/chunk-TMMB5ETD.mjs +16 -0
  70. package/dist/lib/node-esm/chunk-TMMB5ETD.mjs.map +7 -0
  71. package/dist/lib/node-esm/chunk-YYBCQXB2.mjs +40 -0
  72. package/dist/lib/node-esm/chunk-YYBCQXB2.mjs.map +7 -0
  73. package/dist/lib/node-esm/index.mjs +23 -17
  74. package/dist/lib/node-esm/index.mjs.map +3 -3
  75. package/dist/lib/node-esm/intent-resolver-WXIXG5UY.mjs +72 -0
  76. package/dist/lib/node-esm/intent-resolver-WXIXG5UY.mjs.map +7 -0
  77. package/dist/lib/node-esm/meta.json +1 -1
  78. package/dist/lib/node-esm/react-surface-VSO4NWC6.mjs +69 -0
  79. package/dist/lib/node-esm/react-surface-VSO4NWC6.mjs.map +7 -0
  80. package/dist/lib/node-esm/types.mjs +9 -0
  81. package/dist/lib/node-esm/types.mjs.map +7 -0
  82. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  83. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  84. package/dist/types/src/capabilities/index.d.ts +1 -0
  85. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  86. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  87. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  88. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
  89. package/dist/types/src/components/AutomationContainer.d.ts +7 -0
  90. package/dist/types/src/components/AutomationContainer.d.ts.map +1 -0
  91. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +6 -3
  92. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  93. package/dist/types/src/components/AutomationPanel/index.d.ts +1 -0
  94. package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -1
  95. package/dist/types/src/components/FunctionsContainer.d.ts +7 -0
  96. package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -0
  97. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts +7 -0
  98. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -0
  99. package/dist/types/src/components/FunctionsPanel/index.d.ts +4 -0
  100. package/dist/types/src/components/FunctionsPanel/index.d.ts.map +1 -0
  101. package/dist/types/src/components/index.d.ts +8 -1
  102. package/dist/types/src/components/index.d.ts.map +1 -1
  103. package/dist/types/src/translations.d.ts +8 -0
  104. package/dist/types/src/translations.d.ts.map +1 -1
  105. package/dist/types/src/types.d.ts +25 -0
  106. package/dist/types/src/types.d.ts.map +1 -0
  107. package/package.json +29 -24
  108. package/src/AutomationPlugin.tsx +4 -9
  109. package/src/capabilities/app-graph-builder.ts +31 -0
  110. package/src/capabilities/index.ts +1 -0
  111. package/src/capabilities/intent-resolver.ts +62 -0
  112. package/src/capabilities/react-surface.tsx +31 -7
  113. package/src/components/AutomationContainer.tsx +31 -0
  114. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +4 -4
  115. package/src/components/AutomationPanel/AutomationPanel.tsx +62 -63
  116. package/src/components/AutomationPanel/index.ts +2 -0
  117. package/src/components/FunctionsContainer.tsx +31 -0
  118. package/src/components/FunctionsPanel/FunctionsPanel.tsx +95 -0
  119. package/src/components/FunctionsPanel/index.ts +8 -0
  120. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +3 -3
  121. package/src/components/index.ts +3 -0
  122. package/src/translations.ts +10 -1
  123. package/src/types.ts +32 -0
  124. package/dist/lib/browser/AutomationPanel-YAHFXQX6.mjs.map +0 -7
  125. package/dist/lib/browser/app-graph-builder-K3BIQFWW.mjs.map +0 -7
  126. package/dist/lib/browser/chunk-MT3FZH4V.mjs +0 -8
  127. package/dist/lib/browser/chunk-MT3FZH4V.mjs.map +0 -7
  128. package/dist/lib/browser/react-surface-4QQSJR4A.mjs +0 -42
  129. package/dist/lib/browser/react-surface-4QQSJR4A.mjs.map +0 -7
  130. package/dist/lib/node/AutomationPanel-ZKAMIU6O.cjs.map +0 -7
  131. package/dist/lib/node/app-graph-builder-HO4FPGZ5.cjs.map +0 -7
  132. package/dist/lib/node/chunk-AGJ6XTDN.cjs.map +0 -7
  133. package/dist/lib/node/react-surface-52M54VWV.cjs.map +0 -7
  134. package/dist/lib/node-esm/AutomationPanel-XF7YPSKM.mjs.map +0 -7
  135. package/dist/lib/node-esm/app-graph-builder-XCJR33VS.mjs.map +0 -7
  136. package/dist/lib/node-esm/chunk-OA75PSGH.mjs +0 -10
  137. package/dist/lib/node-esm/chunk-OA75PSGH.mjs.map +0 -7
  138. package/dist/lib/node-esm/react-surface-MGKM3OO3.mjs +0 -43
  139. package/dist/lib/node-esm/react-surface-MGKM3OO3.mjs.map +0 -7
@@ -8,11 +8,42 @@ import { ScriptType } from '@dxos/functions';
8
8
  import { PLANK_COMPANION_TYPE, ATTENDABLE_PATH_SEPARATOR } from '@dxos/plugin-deck/types';
9
9
  import { createExtension, type Node } from '@dxos/plugin-graph';
10
10
  import { SCRIPT_PLUGIN } from '@dxos/plugin-script/types';
11
+ import { SPACE_PLUGIN } from '@dxos/plugin-space';
11
12
 
12
13
  import { meta } from '../meta';
13
14
 
14
15
  export default (context: PluginsContext) =>
15
16
  contributes(Capabilities.AppGraphBuilder, [
17
+ createExtension({
18
+ id: `${meta.id}/space-settings-automation`,
19
+ filter: (node): node is Node<null> => node.type === `${SPACE_PLUGIN}/settings`,
20
+ connector: ({ node }) => [
21
+ {
22
+ id: `automation-${node.id}`,
23
+ type: `${meta.id}/space-settings-automation`,
24
+ data: `${meta.id}/space-settings-automation`,
25
+ properties: {
26
+ label: ['automation panel label', { ns: meta.id }],
27
+ icon: 'ph--lightning--regular',
28
+ },
29
+ },
30
+ ],
31
+ }),
32
+ createExtension({
33
+ id: `${meta.id}/space-settings-functions`,
34
+ filter: (node): node is Node<null> => node.type === `${SPACE_PLUGIN}/settings`,
35
+ connector: ({ node }) => [
36
+ {
37
+ id: `functions-${node.id}`,
38
+ type: `${meta.id}/space-settings-functions`,
39
+ data: `${meta.id}/space-settings-functions`,
40
+ properties: {
41
+ label: ['functions panel label', { ns: meta.id }],
42
+ icon: 'ph--function--regular',
43
+ },
44
+ },
45
+ ],
46
+ }),
16
47
  createExtension({
17
48
  id: `${SCRIPT_PLUGIN}/script-companion`,
18
49
  filter: (node): node is Node<ScriptType> => isInstanceOf(ScriptType, node.data),
@@ -5,4 +5,5 @@
5
5
  import { lazy } from '@dxos/app-framework';
6
6
 
7
7
  export const AppGraphBuilder = lazy(() => import('./app-graph-builder'));
8
+ export const IntentResolver = lazy(() => import('./intent-resolver'));
8
9
  export const ReactSurface = lazy(() => import('./react-surface'));
@@ -0,0 +1,62 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { contributes, Capabilities, createResolver, type PluginsContext, createIntent } from '@dxos/app-framework';
6
+ import { FunctionTrigger, FunctionType, ScriptType, TriggerKind } from '@dxos/functions';
7
+ import { type DXN } from '@dxos/keys';
8
+ import { live } from '@dxos/live-object';
9
+ import { SpaceAction } from '@dxos/plugin-space/types';
10
+ import { Filter } from '@dxos/react-client/echo';
11
+
12
+ import { AutomationAction } from '../types';
13
+
14
+ export default (context: PluginsContext) =>
15
+ contributes(Capabilities.IntentResolver, [
16
+ createResolver({
17
+ intent: AutomationAction.CreateTriggerFromTemplate,
18
+ resolve: async ({ space, template, enabled = false, scriptName, payload }) => {
19
+ const trigger = live(FunctionTrigger, { enabled });
20
+
21
+ // TODO(wittjosiah): Factor out function lookup by script name?
22
+ if (scriptName) {
23
+ const {
24
+ objects: [script],
25
+ } = await space.db.query(Filter.schema(ScriptType, { name: scriptName })).run();
26
+ if (script) {
27
+ const {
28
+ objects: [fn],
29
+ } = await space.db.query(Filter.schema(FunctionType, { source: script })).run();
30
+ if (fn) {
31
+ trigger.function = `dxn:worker:${fn.name}`;
32
+ }
33
+ }
34
+ }
35
+
36
+ if (payload) {
37
+ trigger.meta = payload;
38
+ }
39
+
40
+ switch (template.type) {
41
+ case 'timer': {
42
+ trigger.spec = { type: TriggerKind.Timer, cron: template.cron };
43
+ break;
44
+ }
45
+ case 'queue': {
46
+ trigger.spec = { type: TriggerKind.Queue, queue: (template.queueDXN as DXN).toString() };
47
+ break;
48
+ }
49
+ default: {
50
+ break;
51
+ }
52
+ }
53
+
54
+ return {
55
+ intents: [
56
+ createIntent(SpaceAction.AddObject, { object: trigger, target: space }),
57
+ createIntent(SpaceAction.OpenSettings, { space }),
58
+ ],
59
+ };
60
+ },
61
+ }),
62
+ ]);
@@ -4,22 +4,46 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
7
+ import { Capabilities, contributes, createSurface, useLayout } from '@dxos/app-framework';
8
8
  import { isInstanceOf } from '@dxos/echo-schema';
9
9
  import { ScriptType } from '@dxos/functions/types';
10
- import { getSpace, isSpace, type Space } from '@dxos/react-client/echo';
10
+ import { getSpace, parseId, useSpace } from '@dxos/react-client/echo';
11
11
  import { StackItem } from '@dxos/react-ui-stack';
12
12
 
13
- import { AutomationPanel } from '../components';
13
+ import { AutomationContainer, AutomationPanel, FunctionsContainer } from '../components';
14
14
  import { meta } from '../meta';
15
15
 
16
16
  export default () =>
17
17
  contributes(Capabilities.ReactSurface, [
18
18
  createSurface({
19
- id: `${meta.id}/automation`,
20
- role: 'space-settings--automation',
21
- filter: (data): data is { subject: Space } => isSpace(data.subject),
22
- component: ({ data }) => <AutomationPanel space={data.subject} />,
19
+ id: `${meta.id}/space-settings-automation`,
20
+ role: 'article',
21
+ filter: (data): data is { subject: string } => data.subject === `${meta.id}/space-settings-automation`,
22
+ component: () => {
23
+ const layout = useLayout();
24
+ const { spaceId } = parseId(layout.workspace);
25
+ const space = useSpace(spaceId);
26
+ if (!space || !spaceId) {
27
+ return null;
28
+ }
29
+
30
+ return <AutomationContainer space={space} />;
31
+ },
32
+ }),
33
+ createSurface({
34
+ id: `${meta.id}/space-settings-functions`,
35
+ role: 'article',
36
+ filter: (data): data is { subject: string } => data.subject === `${meta.id}/space-settings-functions`,
37
+ component: () => {
38
+ const layout = useLayout();
39
+ const { spaceId } = parseId(layout.workspace);
40
+ const space = useSpace(spaceId);
41
+ if (!space || !spaceId) {
42
+ return null;
43
+ }
44
+
45
+ return <FunctionsContainer space={space} />;
46
+ },
23
47
  }),
24
48
  createSurface({
25
49
  id: `${meta.id}/companion/automation`,
@@ -0,0 +1,31 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { type Space } from '@dxos/react-client/echo';
8
+ import { useTranslation } from '@dxos/react-ui';
9
+ import { ControlSection, ControlPage } from '@dxos/react-ui-form';
10
+ import { StackItem } from '@dxos/react-ui-stack';
11
+
12
+ import { AutomationPanel } from './AutomationPanel';
13
+ import { AUTOMATION_PLUGIN } from '../meta';
14
+
15
+ export const AutomationContainer = ({ space }: { space: Space }) => {
16
+ const { t } = useTranslation(AUTOMATION_PLUGIN);
17
+ return (
18
+ <StackItem.Content classNames='block overflow-y-auto'>
19
+ <ControlPage>
20
+ <ControlSection
21
+ title={t('automation verbose label', { ns: AUTOMATION_PLUGIN })}
22
+ description={t('automation description', { ns: AUTOMATION_PLUGIN })}
23
+ >
24
+ <AutomationPanel space={space} />
25
+ </ControlSection>
26
+ </ControlPage>
27
+ </StackItem.Content>
28
+ );
29
+ };
30
+
31
+ export default AutomationContainer;
@@ -8,7 +8,7 @@ import { type Meta } from '@storybook/react';
8
8
  import React from 'react';
9
9
 
10
10
  import { FunctionType, FunctionTrigger } from '@dxos/functions/types';
11
- import { create, useSpaces } from '@dxos/react-client/echo';
11
+ import { live, useSpaces } from '@dxos/react-client/echo';
12
12
  import { withClientProvider } from '@dxos/react-client/testing';
13
13
  import { withLayout, withTheme } from '@dxos/storybook-utils';
14
14
 
@@ -21,7 +21,7 @@ const DefaultStory = () => {
21
21
  const space = spaces[1];
22
22
 
23
23
  return (
24
- <div role='none' className='flex w-[350px] border border-separator overflow-hidden'>
24
+ <div role='none' className='w-96'>
25
25
  <AutomationPanel space={space} />
26
26
  </div>
27
27
  );
@@ -38,11 +38,11 @@ const meta: Meta = {
38
38
  types: [FunctionType, FunctionTrigger],
39
39
  onSpaceCreated: ({ space }) => {
40
40
  for (const fn of functions) {
41
- space.db.add(create(FunctionType, fn));
41
+ space.db.add(live(FunctionType, fn));
42
42
  }
43
43
  },
44
44
  }),
45
- withLayout({ fullscreen: true, tooltips: true, classNames: 'flex justify-center m-2' }),
45
+ withLayout({ fullscreen: true, tooltips: true, classNames: 'flex juastify-center m-2' }),
46
46
  withTheme,
47
47
  ],
48
48
  parameters: {
@@ -14,11 +14,10 @@ import {
14
14
  ScriptType,
15
15
  } from '@dxos/functions/types';
16
16
  import { type Client, useClient } from '@dxos/react-client';
17
- import { create, Filter, useQuery, type Space, type ReactiveObject, getSpace } from '@dxos/react-client/echo';
17
+ import { live, Filter, useQuery, type Space, type Live, getSpace } from '@dxos/react-client/echo';
18
18
  import { Clipboard, IconButton, Input, Separator, useTranslation } from '@dxos/react-ui';
19
19
  import { ControlItem, controlItemClasses } from '@dxos/react-ui-form';
20
20
  import { List } from '@dxos/react-ui-list';
21
- import { StackItem } from '@dxos/react-ui-stack';
22
21
  import { ghostHover, mx } from '@dxos/react-ui-theme';
23
22
 
24
23
  import { AUTOMATION_PLUGIN } from '../../meta';
@@ -28,18 +27,20 @@ const grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';
28
27
 
29
28
  export type AutomationPanelProps = {
30
29
  space: Space;
31
- object?: ReactiveObject<any>;
30
+ object?: Live<any>;
31
+ initialTrigger?: FunctionTriggerType;
32
+ onDone?: () => void;
32
33
  };
33
34
 
34
35
  // TODO(burdon): Factor out common layout with ViewEditor.
35
- export const AutomationPanel = ({ space, object }: AutomationPanelProps) => {
36
+ export const AutomationPanel = ({ space, object, initialTrigger, onDone }: AutomationPanelProps) => {
36
37
  const { t } = useTranslation(AUTOMATION_PLUGIN);
37
38
  const client = useClient();
38
39
  const triggers = useQuery(space, Filter.schema(FunctionTrigger));
39
40
  const functions = useQuery(space, Filter.schema(FunctionType));
40
41
  const scripts = useQuery(space, Filter.schema(ScriptType));
41
42
 
42
- const [trigger, setTrigger] = useState<FunctionTriggerType>();
43
+ const [trigger, setTrigger] = useState<FunctionTriggerType | undefined>(initialTrigger);
43
44
  const [selected, setSelected] = useState<FunctionTrigger>();
44
45
 
45
46
  const handleSelect = (trigger: FunctionTrigger) => {
@@ -49,7 +50,7 @@ export const AutomationPanel = ({ space, object }: AutomationPanelProps) => {
49
50
  };
50
51
 
51
52
  const handleAdd = () => {
52
- setTrigger(create(FunctionTriggerSchema, {}));
53
+ setTrigger(live(FunctionTriggerSchema, {}));
53
54
  setSelected(undefined);
54
55
  };
55
56
 
@@ -63,76 +64,74 @@ export const AutomationPanel = ({ space, object }: AutomationPanelProps) => {
63
64
  if (selected) {
64
65
  Object.assign(selected, trigger);
65
66
  } else {
66
- space.db.add(create(FunctionTrigger, trigger));
67
+ space.db.add(live(FunctionTrigger, trigger));
67
68
  }
68
69
 
69
70
  setTrigger(undefined);
70
71
  setSelected(undefined);
72
+ onDone?.();
71
73
  };
72
74
 
73
75
  const handleCancel: TriggerEditorProps['onCancel'] = () => {
74
76
  setTrigger(undefined);
77
+ onDone?.();
75
78
  };
76
79
 
77
80
  return (
78
- <Clipboard.Provider>
79
- <StackItem.Content classNames='block overflow-y-auto'>
80
- <div className='flex flex-col w-full'>
81
- {trigger ? (
82
- <ControlItem title={t('trigger editor title')}>
83
- <TriggerEditor space={space} trigger={trigger} onSave={handleSave} onCancel={handleCancel} />
84
- </ControlItem>
85
- ) : (
86
- <div role='none' className={controlItemClasses}>
87
- <List.Root<FunctionTrigger> items={triggers} isItem={S.is(FunctionTrigger)} getId={(field) => field.id}>
88
- {({ items: triggers }) => (
89
- <div role='list' className='flex flex-col w-full'>
90
- {triggers?.map((trigger) => {
91
- const copyAction = getCopyAction(client, trigger);
92
- return (
93
- <List.Item<FunctionTrigger>
94
- key={trigger.id}
95
- item={trigger}
96
- classNames={mx(grid, ghostHover, 'items-center', 'px-2')}
81
+ <div className='flex flex-col w-full'>
82
+ {trigger ? (
83
+ <ControlItem title={t('trigger editor title')}>
84
+ <TriggerEditor space={space} trigger={trigger} onSave={handleSave} onCancel={handleCancel} />
85
+ </ControlItem>
86
+ ) : (
87
+ <div role='none' className={controlItemClasses}>
88
+ <List.Root<FunctionTrigger> items={triggers} isItem={S.is(FunctionTrigger)} getId={(field) => field.id}>
89
+ {({ items: triggers }) => (
90
+ <div role='list' className='flex flex-col w-full'>
91
+ {triggers?.map((trigger) => {
92
+ const copyAction = getCopyAction(client, trigger);
93
+ return (
94
+ <List.Item<FunctionTrigger>
95
+ key={trigger.id}
96
+ item={trigger}
97
+ classNames={mx(grid, ghostHover, 'items-center', 'px-2')}
98
+ >
99
+ <Input.Root>
100
+ <Input.Switch
101
+ checked={trigger.enabled}
102
+ onCheckedChange={(checked) => (trigger.enabled = checked)}
103
+ />
104
+ </Input.Root>
105
+
106
+ <div className={'flex'}>
107
+ <List.ItemTitle
108
+ classNames='px-1 cursor-pointer w-0 shrink truncate'
109
+ onClick={() => handleSelect(trigger)}
97
110
  >
98
- <Input.Root>
99
- <Input.Switch
100
- checked={trigger.enabled}
101
- onCheckedChange={(checked) => (trigger.enabled = checked)}
102
- />
103
- </Input.Root>
104
-
105
- <div className={'flex'}>
106
- <List.ItemTitle
107
- classNames='px-1 cursor-pointer w-0 shrink truncate'
108
- onClick={() => handleSelect(trigger)}
109
- >
110
- {getFunctionName(scripts, functions, trigger) ?? '∅'}
111
- </List.ItemTitle>
112
-
113
- {/* TODO: a better way to expose copy action */}
114
- {copyAction && (
115
- <Clipboard.IconButton
116
- label={t(copyAction.translationKey)}
117
- value={copyAction.contentProvider()}
118
- />
119
- )}
120
- </div>
121
-
122
- <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />
123
- </List.Item>
124
- );
125
- })}
126
- </div>
127
- )}
128
- </List.Root>
129
- {triggers.length > 0 && <Separator classNames='mlb-4' />}
130
- <IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />
131
- </div>
132
- )}
111
+ {getFunctionName(scripts, functions, trigger) ?? '∅'}
112
+ </List.ItemTitle>
113
+
114
+ {/* TODO: a better way to expose copy action */}
115
+ {copyAction && (
116
+ <Clipboard.IconButton
117
+ label={t(copyAction.translationKey)}
118
+ value={copyAction.contentProvider()}
119
+ />
120
+ )}
121
+ </div>
122
+
123
+ <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />
124
+ </List.Item>
125
+ );
126
+ })}
127
+ </div>
128
+ )}
129
+ </List.Root>
130
+ {triggers.length > 0 && <Separator classNames='mlb-4' />}
131
+ <IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />
133
132
  </div>
134
- </StackItem.Content>
135
- </Clipboard.Provider>
133
+ )}
134
+ </div>
136
135
  );
137
136
  };
138
137
 
@@ -4,4 +4,6 @@
4
4
 
5
5
  import { AutomationPanel } from './AutomationPanel';
6
6
 
7
+ export * from './AutomationPanel';
8
+
7
9
  export default AutomationPanel;
@@ -0,0 +1,31 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { type Space } from '@dxos/react-client/echo';
8
+ import { useTranslation } from '@dxos/react-ui';
9
+ import { ControlPage, ControlSection } from '@dxos/react-ui-form';
10
+ import { StackItem } from '@dxos/react-ui-stack';
11
+
12
+ import { FunctionsPanel } from './FunctionsPanel';
13
+ import { AUTOMATION_PLUGIN } from '../meta';
14
+
15
+ export const FunctionsContainer = ({ space }: { space: Space }) => {
16
+ const { t } = useTranslation(AUTOMATION_PLUGIN);
17
+ return (
18
+ <StackItem.Content classNames='block overflow-y-auto'>
19
+ <ControlPage>
20
+ <ControlSection
21
+ title={t('functions verbose label', { ns: AUTOMATION_PLUGIN })}
22
+ description={t('functions description', { ns: AUTOMATION_PLUGIN })}
23
+ >
24
+ <FunctionsPanel space={space} />
25
+ </ControlSection>
26
+ </ControlPage>
27
+ </StackItem.Content>
28
+ );
29
+ };
30
+
31
+ export default FunctionsContainer;
@@ -0,0 +1,95 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { useCallback, useMemo } from 'react';
6
+
7
+ import { createIntent, LayoutAction, useIntentDispatcher } from '@dxos/app-framework';
8
+ import { S } from '@dxos/echo-schema';
9
+ import { FunctionType, ScriptType } from '@dxos/functions/types';
10
+ import { Filter, fullyQualifiedId, useQuery, type Space } from '@dxos/react-client/echo';
11
+ import { Button, useTranslation } from '@dxos/react-ui';
12
+ import { controlItemClasses } from '@dxos/react-ui-form';
13
+ import { List } from '@dxos/react-ui-list';
14
+ import { ghostHover, mx } from '@dxos/react-ui-theme';
15
+
16
+ import { AUTOMATION_PLUGIN } from '../../meta';
17
+
18
+ const grid = 'grid grid-cols-[1fr_auto] min-bs-[2.5rem]';
19
+
20
+ export type FunctionsPanelProps = {
21
+ space: Space;
22
+ };
23
+
24
+ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
25
+ const { t } = useTranslation(AUTOMATION_PLUGIN);
26
+ const functions = useQuery(space, Filter.schema(FunctionType));
27
+ const scripts = useQuery(space, Filter.schema(ScriptType));
28
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
29
+
30
+ const functionToScriptMap = useMemo(
31
+ () =>
32
+ functions.reduce(
33
+ (map, func) => {
34
+ const scriptId = func.source?.target?.id;
35
+ if (scriptId) {
36
+ const script = scripts.find((s) => s.id === scriptId);
37
+ if (script) {
38
+ map[func.id] = script;
39
+ }
40
+ }
41
+ return map;
42
+ },
43
+ {} as Record<string, ScriptType>,
44
+ ),
45
+ [functions, scripts],
46
+ );
47
+
48
+ const getScriptName = useCallback(
49
+ (func: FunctionType) => {
50
+ const script = functionToScriptMap[func.id];
51
+ return script?.name;
52
+ },
53
+ [functionToScriptMap],
54
+ );
55
+
56
+ const handleGoToScript = useCallback(
57
+ (func: FunctionType) => {
58
+ const script = functionToScriptMap[func.id];
59
+ if (script) {
60
+ void dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(script)] }));
61
+ }
62
+ },
63
+ [functionToScriptMap, dispatch],
64
+ );
65
+
66
+ return (
67
+ <div role='none' className={mx(controlItemClasses)}>
68
+ <List.Root<FunctionType> items={functions} isItem={S.is(FunctionType)} getId={(func) => func.id}>
69
+ {({ items }) => (
70
+ <div role='list' className='flex flex-col w-full'>
71
+ {items?.map((func) => (
72
+ <List.Item<FunctionType>
73
+ key={func.id}
74
+ item={func}
75
+ classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
76
+ >
77
+ <div className='flex flex-col truncate'>
78
+ <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>
79
+ {getScriptName(func) && (
80
+ <div className='text-xs text-description truncate'>{getScriptName(func)}</div>
81
+ )}
82
+ </div>
83
+ {functionToScriptMap[func.id] && (
84
+ <Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>
85
+ )}
86
+ </List.Item>
87
+ ))}
88
+ </div>
89
+ )}
90
+ </List.Root>
91
+
92
+ {functions.length === 0 && <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>}
93
+ </div>
94
+ );
95
+ };
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { FunctionsPanel } from './FunctionsPanel';
6
+
7
+ export * from './FunctionsPanel';
8
+ export default FunctionsPanel;
@@ -8,7 +8,7 @@ import { type Meta } from '@storybook/react';
8
8
  import React, { useEffect, useState } from 'react';
9
9
 
10
10
  import { FunctionType, FunctionTrigger, TriggerKind } from '@dxos/functions/types';
11
- import { create } from '@dxos/live-object';
11
+ import { live } from '@dxos/live-object';
12
12
  import { useSpaces } from '@dxos/react-client/echo';
13
13
  import { withClientProvider } from '@dxos/react-client/testing';
14
14
  import { withLayout, withTheme } from '@dxos/storybook-utils';
@@ -26,7 +26,7 @@ const DefaultStory = () => {
26
26
  return;
27
27
  }
28
28
 
29
- const trigger = space.db.add(create(FunctionTrigger, { spec: { type: TriggerKind.Timer, cron: '' } }));
29
+ const trigger = space.db.add(live(FunctionTrigger, { spec: { type: TriggerKind.Timer, cron: '' } }));
30
30
  setTrigger(trigger);
31
31
  }, [space]);
32
32
 
@@ -52,7 +52,7 @@ const meta: Meta = {
52
52
  types: [FunctionType, FunctionTrigger],
53
53
  onSpaceCreated: ({ space }) => {
54
54
  for (const fn of functions) {
55
- space.db.add(create(FunctionType, fn));
55
+ space.db.add(live(FunctionType, fn));
56
56
  }
57
57
  },
58
58
  }),
@@ -6,4 +6,7 @@ import { lazy } from 'react';
6
6
 
7
7
  export * from './TriggerEditor';
8
8
 
9
+ export const AutomationContainer = lazy(() => import('./AutomationContainer'));
9
10
  export const AutomationPanel = lazy(() => import('./AutomationPanel'));
11
+ export const FunctionsContainer = lazy(() => import('./FunctionsContainer'));
12
+ export const FunctionsPanel = lazy(() => import('./FunctionsPanel'));
@@ -11,8 +11,17 @@ export default [
11
11
  'plugin name': 'Automation',
12
12
  'automation panel label': 'Automations',
13
13
  'script automation label': 'Automation',
14
+ 'automation verbose label': 'Manage automations',
15
+ 'automation description': 'You can manage all the triggers which automate your space here.',
14
16
 
15
- 'trigger editor title': 'New Trigger',
17
+ 'functions panel label': 'Functions',
18
+ 'functions verbose label': 'Manage deployed functions',
19
+ 'functions description': 'You can manage all the functions deployed from your space on EDGE here.',
20
+ 'function copy id': 'Copy Function ID',
21
+ 'no functions found': 'No functions found',
22
+ 'go to function source button label': 'Show function source',
23
+
24
+ 'trigger editor title': 'Configure Trigger',
16
25
  'new trigger label': 'Add Trigger',
17
26
  'trigger type timer': 'Timer',
18
27
  'trigger type webhook': 'Webhook',
package/src/types.ts ADDED
@@ -0,0 +1,32 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { S } from '@dxos/echo-schema';
6
+ import { SpaceSchema } from '@dxos/react-client/echo';
7
+
8
+ import { AUTOMATION_PLUGIN } from './meta';
9
+
10
+ const TriggerTemplate = S.Union(
11
+ S.Struct({ type: S.Literal('timer'), cron: S.String }),
12
+ S.Struct({ type: S.Literal('queue'), queueDXN: S.Any }),
13
+ );
14
+
15
+ export namespace AutomationAction {
16
+ const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;
17
+
18
+ export class CreateTriggerFromTemplate extends S.TaggedClass<CreateTriggerFromTemplate>()(
19
+ `${AUTOMATION_ACTION}/create-trigger-from-template`,
20
+ {
21
+ input: S.Struct({
22
+ space: SpaceSchema,
23
+ template: TriggerTemplate,
24
+ enabled: S.optional(S.Boolean),
25
+ // TODO(wittjosiah): Improve how this lookup is done.
26
+ scriptName: S.optional(S.String),
27
+ payload: S.optional(S.Record({ key: S.String, value: S.Any })),
28
+ }),
29
+ output: S.Void,
30
+ },
31
+ ) {}
32
+ }