@dxos/plugin-automation 0.8.2-main.f11618f → 0.8.2-staging.42af850

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 (165) hide show
  1. package/dist/lib/browser/AutomationContainer-HQK7FTN6.mjs +40 -0
  2. package/dist/lib/{node-esm/AutomationContainer-22PUFPSE.mjs.map → browser/AutomationContainer-HQK7FTN6.mjs.map} +1 -1
  3. package/dist/lib/browser/AutomationPanel-GU37N5LO.mjs +11 -0
  4. package/dist/lib/browser/FunctionsContainer-B7RDWVMX.mjs +39 -0
  5. package/dist/lib/{node-esm/FunctionsContainer-XG5WVAN3.mjs.map → browser/FunctionsContainer-B7RDWVMX.mjs.map} +1 -1
  6. package/dist/lib/browser/{FunctionsPanel-JJPLIAJW.mjs → FunctionsPanel-LCCPDIT6.mjs} +3 -3
  7. package/dist/lib/browser/{app-graph-builder-ND64CHOM.mjs → app-graph-builder-BYECL42X.mjs} +16 -17
  8. package/dist/lib/browser/app-graph-builder-BYECL42X.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-4E2KPMLB.mjs +39 -0
  10. package/dist/lib/browser/chunk-4E2KPMLB.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-4QTXMPBC.mjs +229 -0
  12. package/dist/lib/browser/chunk-4QTXMPBC.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-D2ESAYQD.mjs +149 -0
  14. package/dist/lib/browser/chunk-D2ESAYQD.mjs.map +7 -0
  15. package/dist/lib/browser/{chunk-QJPKWYTL.mjs → chunk-ELQ2FX5G.mjs} +5 -5
  16. package/dist/lib/browser/{chunk-WKKQV4PC.mjs → chunk-IHAKPP5A.mjs} +2 -2
  17. package/dist/lib/browser/{chunk-WKKQV4PC.mjs.map → chunk-IHAKPP5A.mjs.map} +1 -1
  18. package/dist/lib/browser/chunk-ZTRYR6RJ.mjs +94 -0
  19. package/dist/lib/browser/chunk-ZTRYR6RJ.mjs.map +7 -0
  20. package/dist/lib/browser/index.mjs +7 -7
  21. package/dist/lib/browser/index.mjs.map +1 -1
  22. package/dist/lib/browser/{intent-resolver-SNIAQ7V5.mjs → intent-resolver-ZRBBYZUX.mjs} +13 -14
  23. package/dist/lib/browser/intent-resolver-ZRBBYZUX.mjs.map +7 -0
  24. package/dist/lib/browser/meta.json +1 -1
  25. package/dist/lib/browser/{react-surface-L22QIANU.mjs → react-surface-VKO6PA2P.mjs} +5 -5
  26. package/dist/lib/browser/{react-surface-L22QIANU.mjs.map → react-surface-VKO6PA2P.mjs.map} +1 -1
  27. package/dist/lib/browser/types.mjs +2 -2
  28. package/dist/lib/node/{AutomationContainer-E5I76FPP.cjs → AutomationContainer-5J7LJK7L.cjs} +26 -20
  29. package/dist/lib/node/{AutomationContainer-E5I76FPP.cjs.map → AutomationContainer-5J7LJK7L.cjs.map} +1 -1
  30. package/dist/lib/node/{AutomationPanel-YLXAFJDP.cjs → AutomationPanel-NPDBUQ7D.cjs} +9 -9
  31. package/dist/lib/node/{AutomationPanel-YLXAFJDP.cjs.map → AutomationPanel-NPDBUQ7D.cjs.map} +2 -2
  32. package/dist/lib/node/{FunctionsContainer-3HCURMEB.cjs → FunctionsContainer-LNLDZUZ6.cjs} +25 -19
  33. package/dist/lib/node/{FunctionsContainer-3HCURMEB.cjs.map → FunctionsContainer-LNLDZUZ6.cjs.map} +1 -1
  34. package/dist/lib/node/{FunctionsPanel-SYIZHPGU.cjs → FunctionsPanel-7AOXIQMA.cjs} +8 -8
  35. package/dist/lib/node/FunctionsPanel-7AOXIQMA.cjs.map +7 -0
  36. package/dist/lib/node/{app-graph-builder-TVFR6RXO.cjs → app-graph-builder-DUKR2BRB.cjs} +28 -29
  37. package/dist/lib/node/app-graph-builder-DUKR2BRB.cjs.map +7 -0
  38. package/dist/lib/node/{chunk-7GXNXMSM.cjs → chunk-3EF7MLFX.cjs} +5 -5
  39. package/dist/lib/node/{chunk-7GXNXMSM.cjs.map → chunk-3EF7MLFX.cjs.map} +1 -1
  40. package/dist/lib/node/chunk-4O627QZU.cjs +175 -0
  41. package/dist/lib/node/chunk-4O627QZU.cjs.map +7 -0
  42. package/dist/lib/node/{chunk-L5TWLPGA.cjs → chunk-DOLMQUQ5.cjs} +8 -8
  43. package/dist/lib/node/{chunk-PSIJDHAX.cjs → chunk-GIIVTK4O.cjs} +22 -22
  44. package/dist/lib/node/chunk-GIIVTK4O.cjs.map +7 -0
  45. package/dist/lib/node/chunk-O42NQYQT.cjs +252 -0
  46. package/dist/lib/node/chunk-O42NQYQT.cjs.map +7 -0
  47. package/dist/lib/node/chunk-WXQAVUBJ.cjs +122 -0
  48. package/dist/lib/node/chunk-WXQAVUBJ.cjs.map +7 -0
  49. package/dist/lib/node/index.cjs +23 -23
  50. package/dist/lib/node/index.cjs.map +2 -2
  51. package/dist/lib/node/{intent-resolver-A44BNFEG.cjs → intent-resolver-JC4Q4TYU.cjs} +18 -19
  52. package/dist/lib/node/intent-resolver-JC4Q4TYU.cjs.map +7 -0
  53. package/dist/lib/node/meta.json +1 -1
  54. package/dist/lib/node/{react-surface-PCZCHIET.cjs → react-surface-HB3MYTCK.cjs} +17 -17
  55. package/dist/lib/node/react-surface-HB3MYTCK.cjs.map +7 -0
  56. package/dist/lib/node/types.cjs +3 -3
  57. package/dist/lib/node/types.cjs.map +1 -1
  58. package/dist/lib/node-esm/AutomationContainer-OJGH76X2.mjs +41 -0
  59. package/dist/lib/{browser/AutomationContainer-KEQ5RNIW.mjs.map → node-esm/AutomationContainer-OJGH76X2.mjs.map} +1 -1
  60. package/dist/lib/node-esm/{AutomationPanel-6UXIAJVS.mjs → AutomationPanel-HIWEJUWL.mjs} +4 -4
  61. package/dist/lib/node-esm/FunctionsContainer-PPR6XNNR.mjs +40 -0
  62. package/dist/lib/{browser/FunctionsContainer-STXBW4CX.mjs.map → node-esm/FunctionsContainer-PPR6XNNR.mjs.map} +1 -1
  63. package/dist/lib/node-esm/{FunctionsPanel-J3QGUESH.mjs → FunctionsPanel-SBXKWTHR.mjs} +3 -3
  64. package/dist/lib/node-esm/{app-graph-builder-NYLOXWVV.mjs → app-graph-builder-UAXHKKGW.mjs} +16 -17
  65. package/dist/lib/node-esm/app-graph-builder-UAXHKKGW.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-5IAHBEHR.mjs +95 -0
  67. package/dist/lib/node-esm/chunk-5IAHBEHR.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-6JOJ2NN4.mjs +40 -0
  69. package/dist/lib/node-esm/chunk-6JOJ2NN4.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-D5HK4XLC.mjs +230 -0
  71. package/dist/lib/node-esm/chunk-D5HK4XLC.mjs.map +7 -0
  72. package/dist/lib/node-esm/{chunk-DZ44LGYT.mjs → chunk-HCCLRNMJ.mjs} +2 -2
  73. package/dist/lib/node-esm/{chunk-DZ44LGYT.mjs.map → chunk-HCCLRNMJ.mjs.map} +1 -1
  74. package/dist/lib/node-esm/chunk-P2FKMPRE.mjs +150 -0
  75. package/dist/lib/node-esm/chunk-P2FKMPRE.mjs.map +7 -0
  76. package/dist/lib/node-esm/{chunk-TMMB5ETD.mjs → chunk-Z7VAQDEE.mjs} +5 -5
  77. package/dist/lib/node-esm/index.mjs +7 -7
  78. package/dist/lib/node-esm/index.mjs.map +1 -1
  79. package/dist/lib/node-esm/{intent-resolver-JFLTVJ7D.mjs → intent-resolver-KRCXJEDR.mjs} +13 -14
  80. package/dist/lib/node-esm/intent-resolver-KRCXJEDR.mjs.map +7 -0
  81. package/dist/lib/node-esm/meta.json +1 -1
  82. package/dist/lib/node-esm/{react-surface-VSO4NWC6.mjs → react-surface-TRKCIZAB.mjs} +5 -5
  83. package/dist/lib/node-esm/{react-surface-VSO4NWC6.mjs.map → react-surface-TRKCIZAB.mjs.map} +1 -1
  84. package/dist/lib/node-esm/types.mjs +2 -2
  85. package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
  86. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  87. package/dist/types/src/capabilities/index.d.ts +2 -178
  88. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  89. package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
  90. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  91. package/dist/types/src/components/AutomationContainer.d.ts.map +1 -1
  92. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -1
  93. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  94. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
  95. package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -1
  96. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
  97. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +12 -0
  98. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -0
  99. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +5 -0
  100. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -0
  101. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -1
  102. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  103. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  104. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  105. package/dist/types/src/types.d.ts +15 -15
  106. package/dist/types/src/types.d.ts.map +1 -1
  107. package/dist/types/tsconfig.tsbuildinfo +1 -1
  108. package/package.json +33 -25
  109. package/src/AutomationPlugin.tsx +1 -1
  110. package/src/capabilities/app-graph-builder.ts +65 -41
  111. package/src/capabilities/intent-resolver.ts +10 -13
  112. package/src/capabilities/react-surface.tsx +1 -1
  113. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +4 -3
  114. package/src/components/AutomationPanel/AutomationPanel.tsx +25 -20
  115. package/src/components/FunctionsPanel/FunctionsPanel.tsx +5 -5
  116. package/src/components/TriggerEditor/FunctionInputEditor.tsx +77 -0
  117. package/src/components/TriggerEditor/SpecSelector.tsx +59 -0
  118. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +17 -8
  119. package/src/components/TriggerEditor/TriggerEditor.tsx +64 -102
  120. package/src/meta.ts +1 -1
  121. package/src/testing/test-functions.ts +23 -9
  122. package/src/types.ts +11 -10
  123. package/dist/lib/browser/AutomationContainer-KEQ5RNIW.mjs +0 -34
  124. package/dist/lib/browser/AutomationPanel-G3OB6ELR.mjs +0 -11
  125. package/dist/lib/browser/FunctionsContainer-STXBW4CX.mjs +0 -33
  126. package/dist/lib/browser/app-graph-builder-ND64CHOM.mjs.map +0 -7
  127. package/dist/lib/browser/chunk-65VL4EYS.mjs +0 -88
  128. package/dist/lib/browser/chunk-65VL4EYS.mjs.map +0 -7
  129. package/dist/lib/browser/chunk-FALBBJNO.mjs +0 -138
  130. package/dist/lib/browser/chunk-FALBBJNO.mjs.map +0 -7
  131. package/dist/lib/browser/chunk-FCLWFVFX.mjs +0 -39
  132. package/dist/lib/browser/chunk-FCLWFVFX.mjs.map +0 -7
  133. package/dist/lib/browser/chunk-NGG4ICAQ.mjs +0 -140
  134. package/dist/lib/browser/chunk-NGG4ICAQ.mjs.map +0 -7
  135. package/dist/lib/browser/intent-resolver-SNIAQ7V5.mjs.map +0 -7
  136. package/dist/lib/node/FunctionsPanel-SYIZHPGU.cjs.map +0 -7
  137. package/dist/lib/node/app-graph-builder-TVFR6RXO.cjs.map +0 -7
  138. package/dist/lib/node/chunk-BSK5SHTR.cjs +0 -116
  139. package/dist/lib/node/chunk-BSK5SHTR.cjs.map +0 -7
  140. package/dist/lib/node/chunk-FTEDH5Q6.cjs +0 -167
  141. package/dist/lib/node/chunk-FTEDH5Q6.cjs.map +0 -7
  142. package/dist/lib/node/chunk-PSIJDHAX.cjs.map +0 -7
  143. package/dist/lib/node/chunk-SRXHHBDE.cjs +0 -166
  144. package/dist/lib/node/chunk-SRXHHBDE.cjs.map +0 -7
  145. package/dist/lib/node/intent-resolver-A44BNFEG.cjs.map +0 -7
  146. package/dist/lib/node/react-surface-PCZCHIET.cjs.map +0 -7
  147. package/dist/lib/node-esm/AutomationContainer-22PUFPSE.mjs +0 -35
  148. package/dist/lib/node-esm/FunctionsContainer-XG5WVAN3.mjs +0 -34
  149. package/dist/lib/node-esm/app-graph-builder-NYLOXWVV.mjs.map +0 -7
  150. package/dist/lib/node-esm/chunk-4UPGANGV.mjs +0 -89
  151. package/dist/lib/node-esm/chunk-4UPGANGV.mjs.map +0 -7
  152. package/dist/lib/node-esm/chunk-HMYAQLGF.mjs +0 -141
  153. package/dist/lib/node-esm/chunk-HMYAQLGF.mjs.map +0 -7
  154. package/dist/lib/node-esm/chunk-M4QXMIIB.mjs +0 -139
  155. package/dist/lib/node-esm/chunk-M4QXMIIB.mjs.map +0 -7
  156. package/dist/lib/node-esm/chunk-YYBCQXB2.mjs +0 -40
  157. package/dist/lib/node-esm/chunk-YYBCQXB2.mjs.map +0 -7
  158. package/dist/lib/node-esm/intent-resolver-JFLTVJ7D.mjs.map +0 -7
  159. /package/dist/lib/browser/{AutomationPanel-G3OB6ELR.mjs.map → AutomationPanel-GU37N5LO.mjs.map} +0 -0
  160. /package/dist/lib/browser/{FunctionsPanel-JJPLIAJW.mjs.map → FunctionsPanel-LCCPDIT6.mjs.map} +0 -0
  161. /package/dist/lib/browser/{chunk-QJPKWYTL.mjs.map → chunk-ELQ2FX5G.mjs.map} +0 -0
  162. /package/dist/lib/node/{chunk-L5TWLPGA.cjs.map → chunk-DOLMQUQ5.cjs.map} +0 -0
  163. /package/dist/lib/node-esm/{AutomationPanel-6UXIAJVS.mjs.map → AutomationPanel-HIWEJUWL.mjs.map} +0 -0
  164. /package/dist/lib/node-esm/{FunctionsPanel-J3QGUESH.mjs.map → FunctionsPanel-SBXKWTHR.mjs.map} +0 -0
  165. /package/dist/lib/node-esm/{chunk-TMMB5ETD.mjs.map → chunk-Z7VAQDEE.mjs.map} +0 -0
@@ -1,23 +1,23 @@
1
1
  //
2
- // Copyright 2024 DXOS.org
2
+ // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
5
+ import React, { useCallback, useMemo } from 'react';
6
6
 
7
7
  import { ComputeGraph } from '@dxos/conductor';
8
+ import { Type } from '@dxos/echo';
8
9
  import {
9
10
  FunctionType,
10
11
  FunctionTriggerSchema,
11
12
  type FunctionTriggerType,
12
13
  type FunctionTrigger,
13
14
  ScriptType,
14
- TriggerKind,
15
- } from '@dxos/functions/types';
16
- import { Filter, useQuery, type Space } from '@dxos/react-client/echo';
17
- import { IconButton, Input, useTranslation } from '@dxos/react-ui';
18
- import { type CustomInputMap, Form, type InputProps, SelectInput, TextInput, useInputProps } from '@dxos/react-ui-form';
15
+ } from '@dxos/functions';
16
+ import { Filter, Ref, useQuery, type Space } from '@dxos/react-client/echo';
17
+ import { type CustomInputMap, Form, SelectInput, useRefQueryLookupHandler } from '@dxos/react-ui-form';
19
18
 
20
- import { AUTOMATION_PLUGIN } from '../../meta';
19
+ import { FunctionInputEditor, type FunctionInputEditorProps } from './FunctionInputEditor';
20
+ import { SpecSelector } from './SpecSelector';
21
21
 
22
22
  export type TriggerEditorProps = {
23
23
  space: Space;
@@ -26,119 +26,81 @@ export type TriggerEditorProps = {
26
26
  onCancel?: () => void;
27
27
  };
28
28
 
29
- const PayloadInput = (props: InputProps & { property: string }) => {
30
- const { t } = useTranslation(AUTOMATION_PLUGIN);
31
- // TODO(dmaretskyi): Prop name (`meta`) should be passed in.
32
- const inputProps = useInputProps(['meta', props.property]);
33
- return (
34
- <div role='none' className='flex items-center mt-2 gap-1'>
35
- <div role='none' className='flex-1'>
36
- <TextInput {...inputProps} type='string' label={props.property} />
37
- </div>
38
- <IconButton
39
- icon='ph--trash--regular'
40
- iconOnly
41
- classNames={'mt-6'}
42
- label={t('trigger meta remove')}
43
- onClick={() => {
44
- const newValues: any = { ...props.getValue() };
45
- delete newValues[props.property];
46
- props.onValueChange('object', newValues);
47
- }}
48
- />
49
- </div>
50
- );
51
- };
52
-
53
29
  export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEditorProps) => {
54
- const { t } = useTranslation(AUTOMATION_PLUGIN);
55
-
56
- const functions = useQuery(space, Filter.schema(FunctionType));
57
- const workflows = useQuery(space, Filter.schema(ComputeGraph));
58
- const scripts = useQuery(space, Filter.schema(ScriptType));
59
-
60
30
  const handleSave = (values: FunctionTriggerType) => {
61
31
  onSave?.(values);
62
32
  };
63
33
 
64
- const Custom = useMemo(
65
- (): CustomInputMap => ({
66
- ['function' satisfies keyof FunctionTriggerType]: (props) => (
67
- <SelectInput
68
- {...props}
69
- options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}
70
- />
71
- ),
72
- ['spec.type' as const]: (props) => (
73
- <SelectInput
74
- {...props}
75
- options={Object.values(TriggerKind).map((kind) => ({
76
- value: kind,
77
- label: t(`trigger type ${kind}`),
78
- }))}
79
- />
80
- ),
81
- // TODO(wittjosiah): Form should be able to handle arbitrary records by default.
82
- ['meta' as const]: (props) => {
83
- const payload = props.getValue() ?? {};
84
- useEffect(() => props.onValueChange('object', { ...payload }), []);
85
- const [newPayloadFieldName, setNewPayloadFieldName] = useState('');
86
-
87
- const handleAddPayload = useCallback(() => {
88
- if (newPayloadFieldName.length) {
89
- const payload = props.getValue() ?? {};
90
- const payloadWithNewProp = { ...payload, [newPayloadFieldName]: '' };
91
- setNewPayloadFieldName('');
92
- props.onValueChange('object', payloadWithNewProp);
93
- }
94
- }, [newPayloadFieldName, props.getValue, props.onValueChange]);
95
-
96
- return (
97
- <>
98
- <div>{/* TODO(wittjosiah): props.label */ 'Payload'}</div>
99
- {[...Object.keys(payload)].map((key) => (
100
- <PayloadInput key={key} property={key} {...props} />
101
- ))}
102
- <div role='none' className='flex items-center mt-2 gap-1 plb-1'>
103
- <div role='none' className='flex-1'>
104
- <Input.Root>
105
- <Input.TextInput
106
- placeholder={t('trigger payload prop name placeholder')}
107
- value={newPayloadFieldName}
108
- onChange={(event) => setNewPayloadFieldName(event.target.value)}
109
- />
110
- </Input.Root>
111
- </div>
112
- <IconButton
113
- icon='ph--plus--regular'
114
- iconOnly
115
- label={t('trigger payload add')}
116
- onClick={handleAddPayload}
117
- />
118
- </div>
119
- </>
120
- );
121
- },
122
- }),
123
- [workflows, scripts, functions, t],
124
- );
34
+ const handleRefQueryLookup = useRefQueryLookupHandler({ space });
35
+ const Custom = useCustomInputs(space, handleRefQueryLookup);
125
36
 
126
37
  return (
127
- <Form<FunctionTriggerType>
38
+ <Form
39
+ Custom={Custom}
128
40
  schema={FunctionTriggerSchema}
129
41
  values={trigger}
130
42
  onSave={handleSave}
131
43
  onCancel={onCancel}
132
- Custom={Custom}
44
+ onQueryRefOptions={handleRefQueryLookup}
133
45
  />
134
46
  );
135
47
  };
136
48
 
49
+ const useCustomInputs = (space: Space, onQueryRefOptions: FunctionInputEditorProps['onQueryRefOptions']) => {
50
+ const functions = useQuery(space, Filter.type(FunctionType));
51
+ const workflows = useQuery(space, Filter.type(ComputeGraph));
52
+ const scripts = useQuery(space, Filter.type(ScriptType));
53
+
54
+ return useMemo(
55
+ (): CustomInputMap => ({
56
+ // Function selector.
57
+ ['function' satisfies keyof FunctionTriggerType]: (props) => {
58
+ const getValue = useCallback(() => {
59
+ const formValue = props.getValue();
60
+ if (Ref.isRef(formValue)) {
61
+ return formValue.dxn.toString() as string;
62
+ }
63
+ return undefined;
64
+ }, [props]);
65
+
66
+ const handleOnValueChange = useCallback(
67
+ (_type: any, dxnString: string) => {
68
+ const dxn = Type.DXN.parse(dxnString);
69
+ if (dxn) {
70
+ const ref = Ref.fromDXN(dxn);
71
+ props.onValueChange('object', ref);
72
+ }
73
+ },
74
+ [props.onValueChange],
75
+ );
76
+
77
+ return (
78
+ <SelectInput
79
+ {...props}
80
+ getValue={getValue as any}
81
+ onValueChange={handleOnValueChange}
82
+ options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}
83
+ />
84
+ );
85
+ },
86
+
87
+ // Spec selector.
88
+ ['spec.kind' as const]: SpecSelector,
89
+
90
+ // Function input editor.
91
+ ['input' as const]: (props) => (
92
+ <FunctionInputEditor {...props} functions={functions} onQueryRefOptions={onQueryRefOptions} />
93
+ ),
94
+ }),
95
+ [workflows, scripts, functions],
96
+ );
97
+ };
98
+
137
99
  const getWorkflowOptions = (graphs: ComputeGraph[]) => {
138
100
  return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));
139
101
  };
140
102
 
141
103
  const getFunctionOptions = (scripts: ScriptType[], functions: FunctionType[]) => {
142
104
  const getLabel = (fn: FunctionType) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
143
- return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:worker:${fn.name}` }));
105
+ return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:echo:@:${fn.id}` }));
144
106
  };
package/src/meta.ts CHANGED
@@ -12,5 +12,5 @@ export const meta: PluginMeta = {
12
12
  description:
13
13
  'The Automation tab allows you to trigger pre-defined workflows related to the element you are interacting with inside of Composer.',
14
14
  icon: 'ph--robot--regular',
15
- source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-automation',
15
+ source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',
16
16
  };
@@ -2,16 +2,19 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { AST, S, toJsonSchema } from '@dxos/echo-schema';
5
+ import { Schema } from 'effect';
6
+
7
+ import { ContactType } from '@dxos/client/testing';
8
+ import { Ref, toJsonSchema } from '@dxos/echo-schema';
6
9
 
7
10
  export const functions = [
8
11
  {
9
12
  name: 'example.com/function/chess',
10
13
  version: '0.1.0',
11
14
  inputSchema: toJsonSchema(
12
- S.Struct({
13
- level: S.Number.annotations({
14
- [AST.TitleAnnotationId]: 'Level',
15
+ Schema.Struct({
16
+ level: Schema.Number.annotations({
17
+ title: 'Level',
15
18
  }),
16
19
  }),
17
20
  ),
@@ -21,12 +24,23 @@ export const functions = [
21
24
  version: '0.1.0',
22
25
  binding: 'FOREX',
23
26
  inputSchema: toJsonSchema(
24
- S.Struct({
25
- from: S.String.annotations({
26
- [AST.TitleAnnotationId]: 'Currency from',
27
+ Schema.Struct({
28
+ from: Schema.String.annotations({
29
+ title: 'Currency from',
30
+ }),
31
+ to: Schema.String.annotations({
32
+ title: 'Currency to',
27
33
  }),
28
- to: S.String.annotations({
29
- [AST.TitleAnnotationId]: 'Currency to',
34
+ }),
35
+ ),
36
+ },
37
+ {
38
+ name: 'example.com/function/ping-contact',
39
+ version: '0.0.1',
40
+ inputSchema: toJsonSchema(
41
+ Schema.Struct({
42
+ contact: Ref(ContactType).annotations({
43
+ title: 'Contact',
30
44
  }),
31
45
  }),
32
46
  ),
package/src/types.ts CHANGED
@@ -2,31 +2,32 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { S } from '@dxos/echo-schema';
5
+ import { Schema } from 'effect';
6
+
6
7
  import { SpaceSchema } from '@dxos/react-client/echo';
7
8
 
8
9
  import { AUTOMATION_PLUGIN } from './meta';
9
10
 
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 }),
11
+ const TriggerTemplate = Schema.Union(
12
+ Schema.Struct({ type: Schema.Literal('timer'), cron: Schema.String }),
13
+ Schema.Struct({ type: Schema.Literal('queue'), queueDXN: Schema.Any }),
13
14
  );
14
15
 
15
16
  export namespace AutomationAction {
16
17
  const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;
17
18
 
18
- export class CreateTriggerFromTemplate extends S.TaggedClass<CreateTriggerFromTemplate>()(
19
+ export class CreateTriggerFromTemplate extends Schema.TaggedClass<CreateTriggerFromTemplate>()(
19
20
  `${AUTOMATION_ACTION}/create-trigger-from-template`,
20
21
  {
21
- input: S.Struct({
22
+ input: Schema.Struct({
22
23
  space: SpaceSchema,
23
24
  template: TriggerTemplate,
24
- enabled: S.optional(S.Boolean),
25
+ enabled: Schema.optional(Schema.Boolean),
25
26
  // 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 })),
27
+ scriptName: Schema.optional(Schema.String),
28
+ input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),
28
29
  }),
29
- output: S.Void,
30
+ output: Schema.Void,
30
31
  },
31
32
  ) {}
32
33
  }
@@ -1,34 +0,0 @@
1
- import {
2
- AutomationPanel
3
- } from "./chunk-NGG4ICAQ.mjs";
4
- import "./chunk-FALBBJNO.mjs";
5
- import {
6
- AUTOMATION_PLUGIN
7
- } from "./chunk-WKKQV4PC.mjs";
8
-
9
- // packages/plugins/plugin-automation/src/components/AutomationContainer.tsx
10
- import React from "react";
11
- import { useTranslation } from "@dxos/react-ui";
12
- import { ControlSection, ControlPage } from "@dxos/react-ui-form";
13
- import { StackItem } from "@dxos/react-ui-stack";
14
- var AutomationContainer = ({ space }) => {
15
- const { t } = useTranslation(AUTOMATION_PLUGIN);
16
- return /* @__PURE__ */ React.createElement(StackItem.Content, {
17
- classNames: "block overflow-y-auto"
18
- }, /* @__PURE__ */ React.createElement(ControlPage, null, /* @__PURE__ */ React.createElement(ControlSection, {
19
- title: t("automation verbose label", {
20
- ns: AUTOMATION_PLUGIN
21
- }),
22
- description: t("automation description", {
23
- ns: AUTOMATION_PLUGIN
24
- })
25
- }, /* @__PURE__ */ React.createElement(AutomationPanel, {
26
- space
27
- }))));
28
- };
29
- var AutomationContainer_default = AutomationContainer;
30
- export {
31
- AutomationContainer,
32
- AutomationContainer_default as default
33
- };
34
- //# sourceMappingURL=AutomationContainer-KEQ5RNIW.mjs.map
@@ -1,11 +0,0 @@
1
- import {
2
- AutomationPanel,
3
- AutomationPanel_default
4
- } from "./chunk-NGG4ICAQ.mjs";
5
- import "./chunk-FALBBJNO.mjs";
6
- import "./chunk-WKKQV4PC.mjs";
7
- export {
8
- AutomationPanel,
9
- AutomationPanel_default as default
10
- };
11
- //# sourceMappingURL=AutomationPanel-G3OB6ELR.mjs.map
@@ -1,33 +0,0 @@
1
- import {
2
- FunctionsPanel
3
- } from "./chunk-65VL4EYS.mjs";
4
- import {
5
- AUTOMATION_PLUGIN
6
- } from "./chunk-WKKQV4PC.mjs";
7
-
8
- // packages/plugins/plugin-automation/src/components/FunctionsContainer.tsx
9
- import React from "react";
10
- import { useTranslation } from "@dxos/react-ui";
11
- import { ControlPage, ControlSection } from "@dxos/react-ui-form";
12
- import { StackItem } from "@dxos/react-ui-stack";
13
- var FunctionsContainer = ({ space }) => {
14
- const { t } = useTranslation(AUTOMATION_PLUGIN);
15
- return /* @__PURE__ */ React.createElement(StackItem.Content, {
16
- classNames: "block overflow-y-auto"
17
- }, /* @__PURE__ */ React.createElement(ControlPage, null, /* @__PURE__ */ React.createElement(ControlSection, {
18
- title: t("functions verbose label", {
19
- ns: AUTOMATION_PLUGIN
20
- }),
21
- description: t("functions description", {
22
- ns: AUTOMATION_PLUGIN
23
- })
24
- }, /* @__PURE__ */ React.createElement(FunctionsPanel, {
25
- space
26
- }))));
27
- };
28
- var FunctionsContainer_default = FunctionsContainer;
29
- export {
30
- FunctionsContainer,
31
- FunctionsContainer_default as default
32
- };
33
- //# sourceMappingURL=FunctionsContainer-STXBW4CX.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/app-graph-builder.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capabilities, contributes, type PluginsContext } from '@dxos/app-framework';\nimport { isInstanceOf } from '@dxos/echo-schema';\nimport { ScriptType } from '@dxos/functions';\nimport { PLANK_COMPANION_TYPE, ATTENDABLE_PATH_SEPARATOR } from '@dxos/plugin-deck/types';\nimport { createExtension, type Node } from '@dxos/plugin-graph';\nimport { SCRIPT_PLUGIN } from '@dxos/plugin-script/types';\nimport { SPACE_PLUGIN } from '@dxos/plugin-space';\n\nimport { meta } from '../meta';\n\nexport default (context: PluginsContext) =>\n contributes(Capabilities.AppGraphBuilder, [\n createExtension({\n id: `${meta.id}/space-settings-automation`,\n filter: (node): node is Node<null> => node.type === `${SPACE_PLUGIN}/settings`,\n connector: ({ node }) => [\n {\n id: `automation-${node.id}`,\n type: `${meta.id}/space-settings-automation`,\n data: `${meta.id}/space-settings-automation`,\n properties: {\n label: ['automation panel label', { ns: meta.id }],\n icon: 'ph--lightning--regular',\n },\n },\n ],\n }),\n createExtension({\n id: `${meta.id}/space-settings-functions`,\n filter: (node): node is Node<null> => node.type === `${SPACE_PLUGIN}/settings`,\n connector: ({ node }) => [\n {\n id: `functions-${node.id}`,\n type: `${meta.id}/space-settings-functions`,\n data: `${meta.id}/space-settings-functions`,\n properties: {\n label: ['functions panel label', { ns: meta.id }],\n icon: 'ph--function--regular',\n },\n },\n ],\n }),\n createExtension({\n id: `${SCRIPT_PLUGIN}/script-companion`,\n filter: (node): node is Node<ScriptType> => isInstanceOf(ScriptType, node.data),\n connector: ({ node }) => [\n {\n id: [node.id, 'automation'].join(ATTENDABLE_PATH_SEPARATOR),\n type: PLANK_COMPANION_TYPE,\n data: 'automation',\n properties: {\n label: ['script automation label', { ns: meta.id }],\n icon: 'ph--lightning--regular',\n },\n },\n ],\n }),\n ]);\n"],
5
- "mappings": ";;;;;AAIA,SAASA,cAAcC,mBAAwC;AAC/D,SAASC,oBAAoB;AAC7B,SAASC,kBAAkB;AAC3B,SAASC,sBAAsBC,iCAAiC;AAChE,SAASC,uBAAkC;AAC3C,SAASC,qBAAqB;AAC9B,SAASC,oBAAoB;AAI7B,IAAA,4BAAe,CAACC,YACdC,YAAYC,aAAaC,iBAAiB;EACxCC,gBAAgB;IACdC,IAAI,GAAGC,KAAKD,EAAE;IACdE,QAAQ,CAACC,SAA6BA,KAAKC,SAAS,GAAGC,YAAAA;IACvDC,WAAW,CAAC,EAAEH,KAAI,MAAO;MACvB;QACEH,IAAI,cAAcG,KAAKH,EAAE;QACzBI,MAAM,GAAGH,KAAKD,EAAE;QAChBO,MAAM,GAAGN,KAAKD,EAAE;QAChBQ,YAAY;UACVC,OAAO;YAAC;YAA0B;cAAEC,IAAIT,KAAKD;YAAG;;UAChDW,MAAM;QACR;MACF;;EAEJ,CAAA;EACAZ,gBAAgB;IACdC,IAAI,GAAGC,KAAKD,EAAE;IACdE,QAAQ,CAACC,SAA6BA,KAAKC,SAAS,GAAGC,YAAAA;IACvDC,WAAW,CAAC,EAAEH,KAAI,MAAO;MACvB;QACEH,IAAI,aAAaG,KAAKH,EAAE;QACxBI,MAAM,GAAGH,KAAKD,EAAE;QAChBO,MAAM,GAAGN,KAAKD,EAAE;QAChBQ,YAAY;UACVC,OAAO;YAAC;YAAyB;cAAEC,IAAIT,KAAKD;YAAG;;UAC/CW,MAAM;QACR;MACF;;EAEJ,CAAA;EACAZ,gBAAgB;IACdC,IAAI,GAAGY,aAAAA;IACPV,QAAQ,CAACC,SAAmCU,aAAaC,YAAYX,KAAKI,IAAI;IAC9ED,WAAW,CAAC,EAAEH,KAAI,MAAO;MACvB;QACEH,IAAI;UAACG,KAAKH;UAAI;UAAce,KAAKC,yBAAAA;QACjCZ,MAAMa;QACNV,MAAM;QACNC,YAAY;UACVC,OAAO;YAAC;YAA2B;cAAEC,IAAIT,KAAKD;YAAG;;UACjDW,MAAM;QACR;MACF;;EAEJ,CAAA;CACD;",
6
- "names": ["Capabilities", "contributes", "isInstanceOf", "ScriptType", "PLANK_COMPANION_TYPE", "ATTENDABLE_PATH_SEPARATOR", "createExtension", "SCRIPT_PLUGIN", "SPACE_PLUGIN", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "meta", "filter", "node", "type", "SPACE_PLUGIN", "connector", "data", "properties", "label", "ns", "icon", "SCRIPT_PLUGIN", "isInstanceOf", "ScriptType", "join", "ATTENDABLE_PATH_SEPARATOR", "PLANK_COMPANION_TYPE"]
7
- }
@@ -1,88 +0,0 @@
1
- import {
2
- AUTOMATION_PLUGIN
3
- } from "./chunk-WKKQV4PC.mjs";
4
-
5
- // packages/plugins/plugin-automation/src/components/FunctionsPanel/FunctionsPanel.tsx
6
- import React, { useCallback, useMemo } from "react";
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 } 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
- var grid = "grid grid-cols-[1fr_auto] min-bs-[2.5rem]";
16
- var FunctionsPanel = ({ space }) => {
17
- const { t } = useTranslation(AUTOMATION_PLUGIN);
18
- const functions = useQuery(space, Filter.schema(FunctionType));
19
- const scripts = useQuery(space, Filter.schema(ScriptType));
20
- const { dispatchPromise: dispatch } = useIntentDispatcher();
21
- const functionToScriptMap = useMemo(() => functions.reduce((map, func) => {
22
- const scriptId = func.source?.target?.id;
23
- if (scriptId) {
24
- const script = scripts.find((s) => s.id === scriptId);
25
- if (script) {
26
- map[func.id] = script;
27
- }
28
- }
29
- return map;
30
- }, {}), [
31
- functions,
32
- scripts
33
- ]);
34
- const getScriptName = useCallback((func) => {
35
- const script = functionToScriptMap[func.id];
36
- return script?.name;
37
- }, [
38
- functionToScriptMap
39
- ]);
40
- const handleGoToScript = useCallback((func) => {
41
- const script = functionToScriptMap[func.id];
42
- if (script) {
43
- void dispatch(createIntent(LayoutAction.Open, {
44
- part: "main",
45
- subject: [
46
- fullyQualifiedId(script)
47
- ]
48
- }));
49
- }
50
- }, [
51
- functionToScriptMap,
52
- dispatch
53
- ]);
54
- return /* @__PURE__ */ React.createElement("div", {
55
- role: "none",
56
- className: mx(controlItemClasses)
57
- }, /* @__PURE__ */ React.createElement(List.Root, {
58
- items: functions,
59
- isItem: S.is(FunctionType),
60
- getId: (func) => func.id
61
- }, ({ items }) => /* @__PURE__ */ React.createElement("div", {
62
- role: "list",
63
- className: "flex flex-col w-full"
64
- }, items?.map((func) => /* @__PURE__ */ React.createElement(List.Item, {
65
- key: func.id,
66
- item: func,
67
- classNames: mx(grid, ghostHover, "items-center", "pli-2", "min-bs-[3rem]")
68
- }, /* @__PURE__ */ React.createElement("div", {
69
- className: "flex flex-col truncate"
70
- }, /* @__PURE__ */ React.createElement(List.ItemTitle, {
71
- classNames: "truncate"
72
- }, func.name), getScriptName(func) && /* @__PURE__ */ React.createElement("div", {
73
- className: "text-xs text-description truncate"
74
- }, getScriptName(func))), functionToScriptMap[func.id] && /* @__PURE__ */ React.createElement(Button, {
75
- onClick: () => handleGoToScript(func)
76
- }, t("go to function source button label")))))), functions.length === 0 && /* @__PURE__ */ React.createElement("div", {
77
- className: "text-center plb-4 text-gray-500"
78
- }, t("no functions found")));
79
- };
80
-
81
- // packages/plugins/plugin-automation/src/components/FunctionsPanel/index.ts
82
- var FunctionsPanel_default = FunctionsPanel;
83
-
84
- export {
85
- FunctionsPanel,
86
- FunctionsPanel_default
87
- };
88
- //# sourceMappingURL=chunk-65VL4EYS.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/FunctionsPanel/FunctionsPanel.tsx", "../../../src/components/FunctionsPanel/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { createIntent, LayoutAction, useIntentDispatcher } from '@dxos/app-framework';\nimport { S } from '@dxos/echo-schema';\nimport { FunctionType, ScriptType } from '@dxos/functions/types';\nimport { Filter, fullyQualifiedId, useQuery, type Space } from '@dxos/react-client/echo';\nimport { Button, useTranslation } from '@dxos/react-ui';\nimport { controlItemClasses } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/react-ui-theme';\n\nimport { AUTOMATION_PLUGIN } from '../../meta';\n\nconst grid = 'grid grid-cols-[1fr_auto] min-bs-[2.5rem]';\n\nexport type FunctionsPanelProps = {\n space: Space;\n};\n\nexport const FunctionsPanel = ({ space }: FunctionsPanelProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const functions = useQuery(space, Filter.schema(FunctionType));\n const scripts = useQuery(space, Filter.schema(ScriptType));\n const { dispatchPromise: dispatch } = useIntentDispatcher();\n\n const functionToScriptMap = useMemo(\n () =>\n functions.reduce(\n (map, func) => {\n const scriptId = func.source?.target?.id;\n if (scriptId) {\n const script = scripts.find((s) => s.id === scriptId);\n if (script) {\n map[func.id] = script;\n }\n }\n return map;\n },\n {} as Record<string, ScriptType>,\n ),\n [functions, scripts],\n );\n\n const getScriptName = useCallback(\n (func: FunctionType) => {\n const script = functionToScriptMap[func.id];\n return script?.name;\n },\n [functionToScriptMap],\n );\n\n const handleGoToScript = useCallback(\n (func: FunctionType) => {\n const script = functionToScriptMap[func.id];\n if (script) {\n void dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(script)] }));\n }\n },\n [functionToScriptMap, dispatch],\n );\n\n return (\n <div role='none' className={mx(controlItemClasses)}>\n <List.Root<FunctionType> items={functions} isItem={S.is(FunctionType)} getId={(func) => func.id}>\n {({ items }) => (\n <div role='list' className='flex flex-col w-full'>\n {items?.map((func) => (\n <List.Item<FunctionType>\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 {getScriptName(func) && (\n <div className='text-xs text-description truncate'>{getScriptName(func)}</div>\n )}\n </div>\n {functionToScriptMap[func.id] && (\n <Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>\n )}\n </List.Item>\n ))}\n </div>\n )}\n </List.Root>\n\n {functions.length === 0 && <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>}\n </div>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { FunctionsPanel } from './FunctionsPanel';\n\nexport * from './FunctionsPanel';\nexport default FunctionsPanel;\n"],
5
- "mappings": ";;;;;AAIA,OAAOA,SAASC,aAAaC,eAAe;AAE5C,SAASC,cAAcC,cAAcC,2BAA2B;AAChE,SAASC,SAAS;AAClB,SAASC,cAAcC,kBAAkB;AACzC,SAASC,QAAQC,kBAAkBC,gBAA4B;AAC/D,SAASC,QAAQC,sBAAsB;AACvC,SAASC,0BAA0B;AACnC,SAASC,YAAY;AACrB,SAASC,YAAYC,UAAU;AAI/B,IAAMC,OAAO;AAMN,IAAMC,iBAAiB,CAAC,EAAEC,MAAK,MAAuB;AAC3D,QAAM,EAAEC,EAAC,IAAKC,eAAeC,iBAAAA;AAC7B,QAAMC,YAAYC,SAASL,OAAOM,OAAOC,OAAOC,YAAAA,CAAAA;AAChD,QAAMC,UAAUJ,SAASL,OAAOM,OAAOC,OAAOG,UAAAA,CAAAA;AAC9C,QAAM,EAAEC,iBAAiBC,SAAQ,IAAKC,oBAAAA;AAEtC,QAAMC,sBAAsBC,QAC1B,MACEX,UAAUY,OACR,CAACC,KAAKC,SAAAA;AACJ,UAAMC,WAAWD,KAAKE,QAAQC,QAAQC;AACtC,QAAIH,UAAU;AACZ,YAAMI,SAASd,QAAQe,KAAK,CAACC,MAAMA,EAAEH,OAAOH,QAAAA;AAC5C,UAAII,QAAQ;AACVN,YAAIC,KAAKI,EAAE,IAAIC;MACjB;IACF;AACA,WAAON;EACT,GACA,CAAC,CAAA,GAEL;IAACb;IAAWK;GAAQ;AAGtB,QAAMiB,gBAAgBC,YACpB,CAACT,SAAAA;AACC,UAAMK,SAAST,oBAAoBI,KAAKI,EAAE;AAC1C,WAAOC,QAAQK;EACjB,GACA;IAACd;GAAoB;AAGvB,QAAMe,mBAAmBF,YACvB,CAACT,SAAAA;AACC,UAAMK,SAAST,oBAAoBI,KAAKI,EAAE;AAC1C,QAAIC,QAAQ;AACV,WAAKX,SAASkB,aAAaC,aAAaC,MAAM;QAAEC,MAAM;QAAQC,SAAS;UAACC,iBAAiBZ,MAAAA;;MAAS,CAAA,CAAA;IACpG;EACF,GACA;IAACT;IAAqBF;GAAS;AAGjC,SACE,sBAAA,cAACwB,OAAAA;IAAIC,MAAK;IAAOC,WAAWC,GAAGC,kBAAAA;KAC7B,sBAAA,cAACC,KAAKC,MAAI;IAAeC,OAAOvC;IAAWwC,QAAQC,EAAEC,GAAGtC,YAAAA;IAAeuC,OAAO,CAAC7B,SAASA,KAAKI;KAC1F,CAAC,EAAEqB,MAAK,MACP,sBAAA,cAACP,OAAAA;IAAIC,MAAK;IAAOC,WAAU;KACxBK,OAAO1B,IAAI,CAACC,SACX,sBAAA,cAACuB,KAAKO,MAAI;IACRC,KAAK/B,KAAKI;IACV4B,MAAMhC;IACNiC,YAAYZ,GAAGzC,MAAMsD,YAAY,gBAAgB,SAAS,eAAA;KAE1D,sBAAA,cAAChB,OAAAA;IAAIE,WAAU;KACb,sBAAA,cAACG,KAAKY,WAAS;IAACF,YAAW;KAAYjC,KAAKU,IAAI,GAC/CF,cAAcR,IAAAA,KACb,sBAAA,cAACkB,OAAAA;IAAIE,WAAU;KAAqCZ,cAAcR,IAAAA,CAAAA,CAAAA,GAGrEJ,oBAAoBI,KAAKI,EAAE,KAC1B,sBAAA,cAACgC,QAAAA;IAAOC,SAAS,MAAM1B,iBAAiBX,IAAAA;KAAQjB,EAAE,oCAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAQ7DG,UAAUoD,WAAW,KAAK,sBAAA,cAACpB,OAAAA;IAAIE,WAAU;KAAmCrC,EAAE,oBAAA,CAAA,CAAA;AAGrF;;;ACvFA,IAAA,yBAAewD;",
6
- "names": ["React", "useCallback", "useMemo", "createIntent", "LayoutAction", "useIntentDispatcher", "S", "FunctionType", "ScriptType", "Filter", "fullyQualifiedId", "useQuery", "Button", "useTranslation", "controlItemClasses", "List", "ghostHover", "mx", "grid", "FunctionsPanel", "space", "t", "useTranslation", "AUTOMATION_PLUGIN", "functions", "useQuery", "Filter", "schema", "FunctionType", "scripts", "ScriptType", "dispatchPromise", "dispatch", "useIntentDispatcher", "functionToScriptMap", "useMemo", "reduce", "map", "func", "scriptId", "source", "target", "id", "script", "find", "s", "getScriptName", "useCallback", "name", "handleGoToScript", "createIntent", "LayoutAction", "Open", "part", "subject", "fullyQualifiedId", "div", "role", "className", "mx", "controlItemClasses", "List", "Root", "items", "isItem", "S", "is", "getId", "Item", "key", "item", "classNames", "ghostHover", "ItemTitle", "Button", "onClick", "length", "FunctionsPanel"]
7
- }
@@ -1,138 +0,0 @@
1
- import {
2
- AUTOMATION_PLUGIN
3
- } from "./chunk-WKKQV4PC.mjs";
4
-
5
- // packages/plugins/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx
6
- import React, { useCallback, useEffect, useMemo, useState } from "react";
7
- import { ComputeGraph } from "@dxos/conductor";
8
- import { FunctionType, FunctionTriggerSchema, ScriptType, TriggerKind } from "@dxos/functions/types";
9
- import { Filter, useQuery } from "@dxos/react-client/echo";
10
- import { IconButton, Input, useTranslation } from "@dxos/react-ui";
11
- import { Form, SelectInput, TextInput, useInputProps } from "@dxos/react-ui-form";
12
- var PayloadInput = (props) => {
13
- const { t } = useTranslation(AUTOMATION_PLUGIN);
14
- const inputProps = useInputProps([
15
- "meta",
16
- props.property
17
- ]);
18
- return /* @__PURE__ */ React.createElement("div", {
19
- role: "none",
20
- className: "flex items-center mt-2 gap-1"
21
- }, /* @__PURE__ */ React.createElement("div", {
22
- role: "none",
23
- className: "flex-1"
24
- }, /* @__PURE__ */ React.createElement(TextInput, {
25
- ...inputProps,
26
- type: "string",
27
- label: props.property
28
- })), /* @__PURE__ */ React.createElement(IconButton, {
29
- icon: "ph--trash--regular",
30
- iconOnly: true,
31
- classNames: "mt-6",
32
- label: t("trigger meta remove"),
33
- onClick: () => {
34
- const newValues = {
35
- ...props.getValue()
36
- };
37
- delete newValues[props.property];
38
- props.onValueChange("object", newValues);
39
- }
40
- }));
41
- };
42
- var TriggerEditor = ({ space, trigger, onSave, onCancel }) => {
43
- const { t } = useTranslation(AUTOMATION_PLUGIN);
44
- const functions = useQuery(space, Filter.schema(FunctionType));
45
- const workflows = useQuery(space, Filter.schema(ComputeGraph));
46
- const scripts = useQuery(space, Filter.schema(ScriptType));
47
- const handleSave = (values) => {
48
- onSave?.(values);
49
- };
50
- const Custom = useMemo(() => ({
51
- ["function"]: (props) => /* @__PURE__ */ React.createElement(SelectInput, {
52
- ...props,
53
- options: getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))
54
- }),
55
- ["spec.type"]: (props) => /* @__PURE__ */ React.createElement(SelectInput, {
56
- ...props,
57
- options: Object.values(TriggerKind).map((kind) => ({
58
- value: kind,
59
- label: t(`trigger type ${kind}`)
60
- }))
61
- }),
62
- // TODO(wittjosiah): Form should be able to handle arbitrary records by default.
63
- ["meta"]: (props) => {
64
- const payload = props.getValue() ?? {};
65
- useEffect(() => props.onValueChange("object", {
66
- ...payload
67
- }), []);
68
- const [newPayloadFieldName, setNewPayloadFieldName] = useState("");
69
- const handleAddPayload = useCallback(() => {
70
- if (newPayloadFieldName.length) {
71
- const payload2 = props.getValue() ?? {};
72
- const payloadWithNewProp = {
73
- ...payload2,
74
- [newPayloadFieldName]: ""
75
- };
76
- setNewPayloadFieldName("");
77
- props.onValueChange("object", payloadWithNewProp);
78
- }
79
- }, [
80
- newPayloadFieldName,
81
- props.getValue,
82
- props.onValueChange
83
- ]);
84
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", null, "Payload"), [
85
- ...Object.keys(payload)
86
- ].map((key) => /* @__PURE__ */ React.createElement(PayloadInput, {
87
- key,
88
- property: key,
89
- ...props
90
- })), /* @__PURE__ */ React.createElement("div", {
91
- role: "none",
92
- className: "flex items-center mt-2 gap-1 plb-1"
93
- }, /* @__PURE__ */ React.createElement("div", {
94
- role: "none",
95
- className: "flex-1"
96
- }, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
97
- placeholder: t("trigger payload prop name placeholder"),
98
- value: newPayloadFieldName,
99
- onChange: (event) => setNewPayloadFieldName(event.target.value)
100
- }))), /* @__PURE__ */ React.createElement(IconButton, {
101
- icon: "ph--plus--regular",
102
- iconOnly: true,
103
- label: t("trigger payload add"),
104
- onClick: handleAddPayload
105
- })));
106
- }
107
- }), [
108
- workflows,
109
- scripts,
110
- functions,
111
- t
112
- ]);
113
- return /* @__PURE__ */ React.createElement(Form, {
114
- schema: FunctionTriggerSchema,
115
- values: trigger,
116
- onSave: handleSave,
117
- onCancel,
118
- Custom
119
- });
120
- };
121
- var getWorkflowOptions = (graphs) => {
122
- return graphs.map((graph) => ({
123
- label: `compute-${graph.id}`,
124
- value: `dxn:echo:@:${graph.id}`
125
- }));
126
- };
127
- var getFunctionOptions = (scripts, functions) => {
128
- const getLabel = (fn) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
129
- return functions.map((fn) => ({
130
- label: getLabel(fn),
131
- value: `dxn:worker:${fn.name}`
132
- }));
133
- };
134
-
135
- export {
136
- TriggerEditor
137
- };
138
- //# sourceMappingURL=chunk-FALBBJNO.mjs.map