@dxos/plugin-automation 0.8.2-main.f11618f → 0.8.2-main.fbd8ed0

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 (144) hide show
  1. package/dist/lib/browser/{AutomationContainer-KEQ5RNIW.mjs → AutomationContainer-DA6IW7O2.mjs} +3 -3
  2. package/dist/lib/browser/{AutomationPanel-G3OB6ELR.mjs → AutomationPanel-R42D3LDD.mjs} +3 -3
  3. package/dist/lib/browser/{FunctionsContainer-STXBW4CX.mjs → FunctionsContainer-MPBMMOMS.mjs} +2 -2
  4. package/dist/lib/browser/{FunctionsPanel-JJPLIAJW.mjs → FunctionsPanel-NSI3P53X.mjs} +2 -2
  5. package/dist/lib/browser/{app-graph-builder-ND64CHOM.mjs → app-graph-builder-2OGPEVBA.mjs} +13 -15
  6. package/dist/lib/browser/app-graph-builder-2OGPEVBA.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-NGG4ICAQ.mjs → chunk-2QF27UJ2.mjs} +12 -12
  8. package/dist/lib/browser/chunk-2QF27UJ2.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-ADYCSC6Y.mjs +39 -0
  10. package/dist/lib/browser/chunk-ADYCSC6Y.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-BNQNURZN.mjs +211 -0
  12. package/dist/lib/browser/chunk-BNQNURZN.mjs.map +7 -0
  13. package/dist/lib/browser/{chunk-QJPKWYTL.mjs → chunk-SGT76SL2.mjs} +5 -5
  14. package/dist/lib/browser/{chunk-65VL4EYS.mjs → chunk-TRC3J2I6.mjs} +6 -6
  15. package/dist/lib/browser/chunk-TRC3J2I6.mjs.map +7 -0
  16. package/dist/lib/browser/index.mjs +6 -6
  17. package/dist/lib/browser/index.mjs.map +1 -1
  18. package/dist/lib/browser/{intent-resolver-SNIAQ7V5.mjs → intent-resolver-X3H6ZSP4.mjs} +12 -13
  19. package/dist/lib/browser/intent-resolver-X3H6ZSP4.mjs.map +7 -0
  20. package/dist/lib/browser/meta.json +1 -1
  21. package/dist/lib/browser/{react-surface-L22QIANU.mjs → react-surface-MOXIHBMS.mjs} +4 -4
  22. package/dist/lib/browser/{react-surface-L22QIANU.mjs.map → react-surface-MOXIHBMS.mjs.map} +1 -1
  23. package/dist/lib/browser/types.mjs +1 -1
  24. package/dist/lib/node/{AutomationContainer-E5I76FPP.cjs → AutomationContainer-FIFH4P5T.cjs} +7 -7
  25. package/dist/lib/node/{AutomationPanel-YLXAFJDP.cjs → AutomationPanel-HTNEWBGB.cjs} +8 -8
  26. package/dist/lib/node/{AutomationPanel-YLXAFJDP.cjs.map → AutomationPanel-HTNEWBGB.cjs.map} +2 -2
  27. package/dist/lib/node/{FunctionsContainer-3HCURMEB.cjs → FunctionsContainer-LF2F6CPE.cjs} +6 -6
  28. package/dist/lib/node/{FunctionsPanel-SYIZHPGU.cjs → FunctionsPanel-6HOAIMQ3.cjs} +7 -7
  29. package/dist/lib/node/{FunctionsPanel-SYIZHPGU.cjs.map → FunctionsPanel-6HOAIMQ3.cjs.map} +2 -2
  30. package/dist/lib/node/{app-graph-builder-TVFR6RXO.cjs → app-graph-builder-3XGDVWHR.cjs} +16 -18
  31. package/dist/lib/node/app-graph-builder-3XGDVWHR.cjs.map +7 -0
  32. package/dist/lib/node/{chunk-BSK5SHTR.cjs → chunk-CBHWMYKF.cjs} +9 -9
  33. package/dist/lib/node/chunk-CBHWMYKF.cjs.map +7 -0
  34. package/dist/lib/node/{chunk-PSIJDHAX.cjs → chunk-GDCG2BML.cjs} +19 -19
  35. package/dist/lib/node/chunk-GDCG2BML.cjs.map +7 -0
  36. package/dist/lib/node/chunk-S3Z4AP77.cjs +234 -0
  37. package/dist/lib/node/chunk-S3Z4AP77.cjs.map +7 -0
  38. package/dist/lib/node/{chunk-L5TWLPGA.cjs → chunk-SV2CB3FT.cjs} +8 -8
  39. package/dist/lib/node/{chunk-SRXHHBDE.cjs → chunk-TI3WBQIB.cjs} +18 -18
  40. package/dist/lib/node/chunk-TI3WBQIB.cjs.map +7 -0
  41. package/dist/lib/node/index.cjs +13 -13
  42. package/dist/lib/node/index.cjs.map +2 -2
  43. package/dist/lib/node/{intent-resolver-A44BNFEG.cjs → intent-resolver-Q7WJ4PZZ.cjs} +17 -18
  44. package/dist/lib/node/intent-resolver-Q7WJ4PZZ.cjs.map +7 -0
  45. package/dist/lib/node/meta.json +1 -1
  46. package/dist/lib/node/{react-surface-PCZCHIET.cjs → react-surface-43VHU36V.cjs} +11 -11
  47. package/dist/lib/node/react-surface-43VHU36V.cjs.map +7 -0
  48. package/dist/lib/node/types.cjs +2 -2
  49. package/dist/lib/node/types.cjs.map +1 -1
  50. package/dist/lib/node-esm/{AutomationContainer-22PUFPSE.mjs → AutomationContainer-OP43F4PD.mjs} +3 -3
  51. package/dist/lib/node-esm/{AutomationPanel-6UXIAJVS.mjs → AutomationPanel-ZQKRBWP2.mjs} +3 -3
  52. package/dist/lib/node-esm/{FunctionsContainer-XG5WVAN3.mjs → FunctionsContainer-5TVRDIX5.mjs} +2 -2
  53. package/dist/lib/node-esm/{FunctionsPanel-J3QGUESH.mjs → FunctionsPanel-NMEW26KL.mjs} +2 -2
  54. package/dist/lib/node-esm/{app-graph-builder-NYLOXWVV.mjs → app-graph-builder-UR2E5CQY.mjs} +13 -15
  55. package/dist/lib/node-esm/app-graph-builder-UR2E5CQY.mjs.map +7 -0
  56. package/dist/lib/node-esm/{chunk-4UPGANGV.mjs → chunk-AD4C4IK2.mjs} +6 -6
  57. package/dist/lib/node-esm/chunk-AD4C4IK2.mjs.map +7 -0
  58. package/dist/lib/node-esm/{chunk-TMMB5ETD.mjs → chunk-CUPEMOYK.mjs} +5 -5
  59. package/dist/lib/node-esm/{chunk-HMYAQLGF.mjs → chunk-DIUPZXCQ.mjs} +12 -12
  60. package/dist/lib/node-esm/chunk-DIUPZXCQ.mjs.map +7 -0
  61. package/dist/lib/node-esm/chunk-DZ7RKC52.mjs +212 -0
  62. package/dist/lib/node-esm/chunk-DZ7RKC52.mjs.map +7 -0
  63. package/dist/lib/node-esm/{chunk-YYBCQXB2.mjs → chunk-EEA6CZ6B.mjs} +16 -16
  64. package/dist/lib/node-esm/chunk-EEA6CZ6B.mjs.map +7 -0
  65. package/dist/lib/node-esm/index.mjs +6 -6
  66. package/dist/lib/node-esm/index.mjs.map +1 -1
  67. package/dist/lib/node-esm/{intent-resolver-JFLTVJ7D.mjs → intent-resolver-HEUGQ6SL.mjs} +12 -13
  68. package/dist/lib/node-esm/intent-resolver-HEUGQ6SL.mjs.map +7 -0
  69. package/dist/lib/node-esm/meta.json +1 -1
  70. package/dist/lib/node-esm/{react-surface-VSO4NWC6.mjs → react-surface-TER7JEF6.mjs} +4 -4
  71. package/dist/lib/node-esm/{react-surface-VSO4NWC6.mjs.map → react-surface-TER7JEF6.mjs.map} +1 -1
  72. package/dist/lib/node-esm/types.mjs +1 -1
  73. package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
  74. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  75. package/dist/types/src/capabilities/index.d.ts +2 -178
  76. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  77. package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
  78. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  79. package/dist/types/src/components/AutomationContainer.d.ts.map +1 -1
  80. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -1
  81. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  82. package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -1
  83. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
  84. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +12 -0
  85. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -0
  86. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +5 -0
  87. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -0
  88. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -1
  89. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  90. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  91. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  92. package/dist/types/src/types.d.ts +15 -15
  93. package/dist/types/src/types.d.ts.map +1 -1
  94. package/dist/types/tsconfig.tsbuildinfo +1 -1
  95. package/package.json +31 -24
  96. package/src/AutomationPlugin.tsx +1 -1
  97. package/src/capabilities/app-graph-builder.ts +64 -41
  98. package/src/capabilities/intent-resolver.ts +10 -13
  99. package/src/capabilities/react-surface.tsx +1 -1
  100. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +2 -2
  101. package/src/components/AutomationPanel/AutomationPanel.tsx +11 -10
  102. package/src/components/FunctionsPanel/FunctionsPanel.tsx +5 -5
  103. package/src/components/TriggerEditor/FunctionInputEditor.tsx +77 -0
  104. package/src/components/TriggerEditor/SpecSelector.tsx +59 -0
  105. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +17 -8
  106. package/src/components/TriggerEditor/TriggerEditor.tsx +53 -93
  107. package/src/testing/test-functions.ts +23 -9
  108. package/src/types.ts +11 -10
  109. package/dist/lib/browser/app-graph-builder-ND64CHOM.mjs.map +0 -7
  110. package/dist/lib/browser/chunk-65VL4EYS.mjs.map +0 -7
  111. package/dist/lib/browser/chunk-FALBBJNO.mjs +0 -138
  112. package/dist/lib/browser/chunk-FALBBJNO.mjs.map +0 -7
  113. package/dist/lib/browser/chunk-FCLWFVFX.mjs +0 -39
  114. package/dist/lib/browser/chunk-FCLWFVFX.mjs.map +0 -7
  115. package/dist/lib/browser/chunk-NGG4ICAQ.mjs.map +0 -7
  116. package/dist/lib/browser/intent-resolver-SNIAQ7V5.mjs.map +0 -7
  117. package/dist/lib/node/app-graph-builder-TVFR6RXO.cjs.map +0 -7
  118. package/dist/lib/node/chunk-BSK5SHTR.cjs.map +0 -7
  119. package/dist/lib/node/chunk-FTEDH5Q6.cjs +0 -167
  120. package/dist/lib/node/chunk-FTEDH5Q6.cjs.map +0 -7
  121. package/dist/lib/node/chunk-PSIJDHAX.cjs.map +0 -7
  122. package/dist/lib/node/chunk-SRXHHBDE.cjs.map +0 -7
  123. package/dist/lib/node/intent-resolver-A44BNFEG.cjs.map +0 -7
  124. package/dist/lib/node/react-surface-PCZCHIET.cjs.map +0 -7
  125. package/dist/lib/node-esm/app-graph-builder-NYLOXWVV.mjs.map +0 -7
  126. package/dist/lib/node-esm/chunk-4UPGANGV.mjs.map +0 -7
  127. package/dist/lib/node-esm/chunk-HMYAQLGF.mjs.map +0 -7
  128. package/dist/lib/node-esm/chunk-M4QXMIIB.mjs +0 -139
  129. package/dist/lib/node-esm/chunk-M4QXMIIB.mjs.map +0 -7
  130. package/dist/lib/node-esm/chunk-YYBCQXB2.mjs.map +0 -7
  131. package/dist/lib/node-esm/intent-resolver-JFLTVJ7D.mjs.map +0 -7
  132. /package/dist/lib/browser/{AutomationContainer-KEQ5RNIW.mjs.map → AutomationContainer-DA6IW7O2.mjs.map} +0 -0
  133. /package/dist/lib/browser/{AutomationPanel-G3OB6ELR.mjs.map → AutomationPanel-R42D3LDD.mjs.map} +0 -0
  134. /package/dist/lib/browser/{FunctionsContainer-STXBW4CX.mjs.map → FunctionsContainer-MPBMMOMS.mjs.map} +0 -0
  135. /package/dist/lib/browser/{FunctionsPanel-JJPLIAJW.mjs.map → FunctionsPanel-NSI3P53X.mjs.map} +0 -0
  136. /package/dist/lib/browser/{chunk-QJPKWYTL.mjs.map → chunk-SGT76SL2.mjs.map} +0 -0
  137. /package/dist/lib/node/{AutomationContainer-E5I76FPP.cjs.map → AutomationContainer-FIFH4P5T.cjs.map} +0 -0
  138. /package/dist/lib/node/{FunctionsContainer-3HCURMEB.cjs.map → FunctionsContainer-LF2F6CPE.cjs.map} +0 -0
  139. /package/dist/lib/node/{chunk-L5TWLPGA.cjs.map → chunk-SV2CB3FT.cjs.map} +0 -0
  140. /package/dist/lib/node-esm/{AutomationContainer-22PUFPSE.mjs.map → AutomationContainer-OP43F4PD.mjs.map} +0 -0
  141. /package/dist/lib/node-esm/{AutomationPanel-6UXIAJVS.mjs.map → AutomationPanel-ZQKRBWP2.mjs.map} +0 -0
  142. /package/dist/lib/node-esm/{FunctionsContainer-XG5WVAN3.mjs.map → FunctionsContainer-5TVRDIX5.mjs.map} +0 -0
  143. /package/dist/lib/node-esm/{FunctionsPanel-J3QGUESH.mjs.map → FunctionsPanel-NMEW26KL.mjs.map} +0 -0
  144. /package/dist/lib/node-esm/{chunk-TMMB5ETD.mjs.map → chunk-CUPEMOYK.mjs.map} +0 -0
@@ -1,22 +1,24 @@
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 { DXN } 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 { useTranslation } from '@dxos/react-ui';
18
+ import { type CustomInputMap, Form, SelectInput, useRefQueryLookupHandler } from '@dxos/react-ui-form';
19
19
 
20
+ import { FunctionInputEditor } from './FunctionInputEditor';
21
+ import { SpecSelector } from './SpecSelector';
20
22
  import { AUTOMATION_PLUGIN } from '../../meta';
21
23
 
22
24
  export type TriggerEditorProps = {
@@ -26,111 +28,69 @@ export type TriggerEditorProps = {
26
28
  onCancel?: () => void;
27
29
  };
28
30
 
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
31
  export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEditorProps) => {
54
32
  const { t } = useTranslation(AUTOMATION_PLUGIN);
55
33
 
56
- const functions = useQuery(space, Filter.schema(FunctionType));
57
- const workflows = useQuery(space, Filter.schema(ComputeGraph));
58
- const scripts = useQuery(space, Filter.schema(ScriptType));
34
+ const functions = useQuery(space, Filter.type(FunctionType));
35
+ const workflows = useQuery(space, Filter.type(ComputeGraph));
36
+ const scripts = useQuery(space, Filter.type(ScriptType));
59
37
 
60
38
  const handleSave = (values: FunctionTriggerType) => {
61
39
  onSave?.(values);
62
40
  };
63
41
 
42
+ const handleRefQueryLookup = useRefQueryLookupHandler({ space });
43
+
64
44
  const Custom = useMemo(
65
45
  (): 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);
46
+ ['function' satisfies keyof FunctionTriggerType]: (props) => {
47
+ const getValue = useCallback(() => {
48
+ const formValue = props.getValue();
49
+ if (Ref.isRef(formValue)) {
50
+ return formValue.dxn.toString() as string;
93
51
  }
94
- }, [newPayloadFieldName, props.getValue, props.onValueChange]);
52
+ return undefined;
53
+ }, [props]);
54
+
55
+ const handleOnValueChange = useCallback(
56
+ (_type: any, dxnString: string) => {
57
+ const dxn = DXN.parse(dxnString);
58
+ if (dxn) {
59
+ const ref = Ref.fromDXN(dxn);
60
+ props.onValueChange('object', ref);
61
+ }
62
+ },
63
+ [props.onValueChange],
64
+ );
95
65
 
96
66
  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
- </>
67
+ <SelectInput
68
+ {...props}
69
+ getValue={getValue as any}
70
+ onValueChange={handleOnValueChange}
71
+ options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}
72
+ />
120
73
  );
121
74
  },
75
+ ['spec.kind' as const]: SpecSelector,
76
+ ['input' as const]: (props) => (
77
+ <FunctionInputEditor {...props} functions={functions} onQueryRefOptions={handleRefQueryLookup} />
78
+ ),
122
79
  }),
123
80
  [workflows, scripts, functions, t],
124
81
  );
125
82
 
126
83
  return (
127
- <Form<FunctionTriggerType>
128
- schema={FunctionTriggerSchema}
129
- values={trigger}
130
- onSave={handleSave}
131
- onCancel={onCancel}
132
- Custom={Custom}
133
- />
84
+ <div role='none' className='bs-full is-full'>
85
+ <Form
86
+ schema={FunctionTriggerSchema}
87
+ values={trigger}
88
+ onSave={handleSave}
89
+ onCancel={onCancel}
90
+ Custom={Custom}
91
+ onQueryRefOptions={handleRefQueryLookup}
92
+ />
93
+ </div>
134
94
  );
135
95
  };
136
96
 
@@ -140,5 +100,5 @@ const getWorkflowOptions = (graphs: ComputeGraph[]) => {
140
100
 
141
101
  const getFunctionOptions = (scripts: ScriptType[], functions: FunctionType[]) => {
142
102
  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}` }));
103
+ return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:echo:@:${fn.id}` }));
144
104
  };
@@ -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, SchemaAST } 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
+ [SchemaAST.TitleAnnotationId]: '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
+ [SchemaAST.TitleAnnotationId]: 'Currency from',
30
+ }),
31
+ to: Schema.String.annotations({
32
+ [SchemaAST.TitleAnnotationId]: '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
+ [SchemaAST.TitleAnnotationId]: '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,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,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
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/TriggerEditor/TriggerEditor.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { ComputeGraph } from '@dxos/conductor';\nimport {\n FunctionType,\n FunctionTriggerSchema,\n type FunctionTriggerType,\n type FunctionTrigger,\n ScriptType,\n TriggerKind,\n} from '@dxos/functions/types';\nimport { Filter, useQuery, type Space } from '@dxos/react-client/echo';\nimport { IconButton, Input, useTranslation } from '@dxos/react-ui';\nimport { type CustomInputMap, Form, type InputProps, SelectInput, TextInput, useInputProps } from '@dxos/react-ui-form';\n\nimport { AUTOMATION_PLUGIN } from '../../meta';\n\nexport type TriggerEditorProps = {\n space: Space;\n trigger: FunctionTriggerType;\n onSave?: (trigger: Omit<FunctionTrigger, 'id'>) => void;\n onCancel?: () => void;\n};\n\nconst PayloadInput = (props: InputProps & { property: string }) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n // TODO(dmaretskyi): Prop name (`meta`) should be passed in.\n const inputProps = useInputProps(['meta', props.property]);\n return (\n <div role='none' className='flex items-center mt-2 gap-1'>\n <div role='none' className='flex-1'>\n <TextInput {...inputProps} type='string' label={props.property} />\n </div>\n <IconButton\n icon='ph--trash--regular'\n iconOnly\n classNames={'mt-6'}\n label={t('trigger meta remove')}\n onClick={() => {\n const newValues: any = { ...props.getValue() };\n delete newValues[props.property];\n props.onValueChange('object', newValues);\n }}\n />\n </div>\n );\n};\n\nexport const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEditorProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n\n const functions = useQuery(space, Filter.schema(FunctionType));\n const workflows = useQuery(space, Filter.schema(ComputeGraph));\n const scripts = useQuery(space, Filter.schema(ScriptType));\n\n const handleSave = (values: FunctionTriggerType) => {\n onSave?.(values);\n };\n\n const Custom = useMemo(\n (): CustomInputMap => ({\n ['function' satisfies keyof FunctionTriggerType]: (props) => (\n <SelectInput\n {...props}\n options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}\n />\n ),\n ['spec.type' as const]: (props) => (\n <SelectInput\n {...props}\n options={Object.values(TriggerKind).map((kind) => ({\n value: kind,\n label: t(`trigger type ${kind}`),\n }))}\n />\n ),\n // TODO(wittjosiah): Form should be able to handle arbitrary records by default.\n ['meta' as const]: (props) => {\n const payload = props.getValue() ?? {};\n useEffect(() => props.onValueChange('object', { ...payload }), []);\n const [newPayloadFieldName, setNewPayloadFieldName] = useState('');\n\n const handleAddPayload = useCallback(() => {\n if (newPayloadFieldName.length) {\n const payload = props.getValue() ?? {};\n const payloadWithNewProp = { ...payload, [newPayloadFieldName]: '' };\n setNewPayloadFieldName('');\n props.onValueChange('object', payloadWithNewProp);\n }\n }, [newPayloadFieldName, props.getValue, props.onValueChange]);\n\n return (\n <>\n <div>{/* TODO(wittjosiah): props.label */ 'Payload'}</div>\n {[...Object.keys(payload)].map((key) => (\n <PayloadInput key={key} property={key} {...props} />\n ))}\n <div role='none' className='flex items-center mt-2 gap-1 plb-1'>\n <div role='none' className='flex-1'>\n <Input.Root>\n <Input.TextInput\n placeholder={t('trigger payload prop name placeholder')}\n value={newPayloadFieldName}\n onChange={(event) => setNewPayloadFieldName(event.target.value)}\n />\n </Input.Root>\n </div>\n <IconButton\n icon='ph--plus--regular'\n iconOnly\n label={t('trigger payload add')}\n onClick={handleAddPayload}\n />\n </div>\n </>\n );\n },\n }),\n [workflows, scripts, functions, t],\n );\n\n return (\n <Form<FunctionTriggerType>\n schema={FunctionTriggerSchema}\n values={trigger}\n onSave={handleSave}\n onCancel={onCancel}\n Custom={Custom}\n />\n );\n};\n\nconst getWorkflowOptions = (graphs: ComputeGraph[]) => {\n return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));\n};\n\nconst getFunctionOptions = (scripts: ScriptType[], functions: FunctionType[]) => {\n const getLabel = (fn: FunctionType) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;\n return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:worker:${fn.name}` }));\n};\n"],
5
- "mappings": ";;;;;AAIA,OAAOA,SAASC,aAAaC,WAAWC,SAASC,gBAAgB;AAEjE,SAASC,oBAAoB;AAC7B,SACEC,cACAC,uBAGAC,YACAC,mBACK;AACP,SAASC,QAAQC,gBAA4B;AAC7C,SAASC,YAAYC,OAAOC,sBAAsB;AAClD,SAA8BC,MAAuBC,aAAaC,WAAWC,qBAAqB;AAWlG,IAAMC,eAAe,CAACC,UAAAA;AACpB,QAAM,EAAEC,EAAC,I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,sBAAA,cAACiE,MAAAA;IACCrC,QAAQsC;IACR/B,QAAQb;IACRC,QAAQW;IACRV;IACAY;;AAGN;AAEA,IAAMI,qBAAqB,CAAC2B,WAAAA;AAC1B,SAAOA,OAAOtB,IAAI,CAACuB,WAAW;IAAEzD,OAAO,WAAWyD,MAAMC,EAAE;IAAItB,OAAO,cAAcqB,MAAMC,EAAE;EAAG,EAAA;AAChG;AAEA,IAAM3B,qBAAqB,CAACV,SAAuBP,cAAAA;AACjD,QAAM6C,WAAW,CAACC,OAAqBvC,QAAQwC,KAAK,CAACC,MAAMF,GAAGG,QAAQV,QAAQK,OAAOI,EAAEJ,EAAE,GAAGM,QAAQJ,GAAGI;AACvG,SAAOlD,UAAUoB,IAAI,CAAC0B,QAAQ;IAAE5D,OAAO2D,SAASC,EAAAA;IAAKxB,OAAO,cAAcwB,GAAGI,IAAI;EAAG,EAAA;AACtF;",
6
- "names": ["React", "useCallback", "useEffect", "useMemo", "useState", "ComputeGraph", "FunctionType", "FunctionTriggerSchema", "ScriptType", "TriggerKind", "Filter", "useQuery", "IconButton", "Input", "useTranslation", "Form", "SelectInput", "TextInput", "useInputProps", "PayloadInput", "props", "t", "useTranslation", "AUTOMATION_PLUGIN", "inputProps", "useInputProps", "property", "div", "role", "className", "TextInput", "type", "label", "IconButton", "icon", "iconOnly", "classNames", "onClick", "newValues", "getValue", "onValueChange", "TriggerEditor", "space", "trigger", "onSave", "onCancel", "functions", "useQuery", "Filter", "schema", "FunctionType", "workflows", "ComputeGraph", "scripts", "ScriptType", "handleSave", "values", "Custom", "useMemo", "SelectInput", "options", "getWorkflowOptions", "concat", "getFunctionOptions", "Object", "TriggerKind", "map", "kind", "value", "payload", "useEffect", "newPayloadFieldName", "setNewPayloadFieldName", "useState", "handleAddPayload", "useCallback", "length", "payloadWithNewProp", "keys", "key", "Input", "Root", "placeholder", "onChange", "event", "target", "Form", "FunctionTriggerSchema", "graphs", "graph", "id", "getLabel", "fn", "find", "s", "source", "name"]
7
- }
@@ -1,39 +0,0 @@
1
- import {
2
- AUTOMATION_PLUGIN
3
- } from "./chunk-WKKQV4PC.mjs";
4
-
5
- // packages/plugins/plugin-automation/src/types.ts
6
- import { S } from "@dxos/echo-schema";
7
- import { SpaceSchema } from "@dxos/react-client/echo";
8
- var TriggerTemplate = S.Union(S.Struct({
9
- type: S.Literal("timer"),
10
- cron: S.String
11
- }), S.Struct({
12
- type: S.Literal("queue"),
13
- queueDXN: S.Any
14
- }));
15
- var AutomationAction;
16
- (function(AutomationAction2) {
17
- const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;
18
- class CreateTriggerFromTemplate extends S.TaggedClass()(`${AUTOMATION_ACTION}/create-trigger-from-template`, {
19
- input: S.Struct({
20
- space: SpaceSchema,
21
- template: TriggerTemplate,
22
- enabled: S.optional(S.Boolean),
23
- // TODO(wittjosiah): Improve how this lookup is done.
24
- scriptName: S.optional(S.String),
25
- payload: S.optional(S.Record({
26
- key: S.String,
27
- value: S.Any
28
- }))
29
- }),
30
- output: S.Void
31
- }) {
32
- }
33
- AutomationAction2.CreateTriggerFromTemplate = CreateTriggerFromTemplate;
34
- })(AutomationAction || (AutomationAction = {}));
35
-
36
- export {
37
- AutomationAction
38
- };
39
- //# sourceMappingURL=chunk-FCLWFVFX.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/types.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { S } from '@dxos/echo-schema';\nimport { SpaceSchema } from '@dxos/react-client/echo';\n\nimport { AUTOMATION_PLUGIN } from './meta';\n\nconst TriggerTemplate = S.Union(\n S.Struct({ type: S.Literal('timer'), cron: S.String }),\n S.Struct({ type: S.Literal('queue'), queueDXN: S.Any }),\n);\n\nexport namespace AutomationAction {\n const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;\n\n export class CreateTriggerFromTemplate extends S.TaggedClass<CreateTriggerFromTemplate>()(\n `${AUTOMATION_ACTION}/create-trigger-from-template`,\n {\n input: S.Struct({\n space: SpaceSchema,\n template: TriggerTemplate,\n enabled: S.optional(S.Boolean),\n // TODO(wittjosiah): Improve how this lookup is done.\n scriptName: S.optional(S.String),\n payload: S.optional(S.Record({ key: S.String, value: S.Any })),\n }),\n output: S.Void,\n },\n ) {}\n}\n"],
5
- "mappings": ";;;;;AAIA,SAASA,SAAS;AAClB,SAASC,mBAAmB;AAI5B,IAAMC,kBAAkBC,EAAEC,MACxBD,EAAEE,OAAO;EAAEC,MAAMH,EAAEI,QAAQ,OAAA;EAAUC,MAAML,EAAEM;AAAO,CAAA,GACpDN,EAAEE,OAAO;EAAEC,MAAMH,EAAEI,QAAQ,OAAA;EAAUG,UAAUP,EAAEQ;AAAI,CAAA,CAAA;;UAGtCC,mBAAAA;AACf,QAAMC,oBAAoB,GAAGC,iBAAAA;EAEtB,MAAMC,kCAAkCZ,EAAEa,YAAW,EAC1D,GAAGH,iBAAAA,iCACH;IACEI,OAAOd,EAAEE,OAAO;MACda,OAAOC;MACPC,UAAUlB;MACVmB,SAASlB,EAAEmB,SAASnB,EAAEoB,OAAO;;MAE7BC,YAAYrB,EAAEmB,SAASnB,EAAEM,MAAM;MAC/BgB,SAAStB,EAAEmB,SAASnB,EAAEuB,OAAO;QAAEC,KAAKxB,EAAEM;QAAQmB,OAAOzB,EAAEQ;MAAI,CAAA,CAAA;IAC7D,CAAA;IACAkB,QAAQ1B,EAAE2B;EACZ,CAAA,EAAA;EACC;oBAbUf,4BAAAA;AAcf,GAjBiBH,qBAAAA,mBAAAA,CAAAA,EAAAA;",
6
- "names": ["S", "SpaceSchema", "TriggerTemplate", "S", "Union", "Struct", "type", "Literal", "cron", "String", "queueDXN", "Any", "AutomationAction", "AUTOMATION_ACTION", "AUTOMATION_PLUGIN", "CreateTriggerFromTemplate", "TaggedClass", "input", "space", "SpaceSchema", "template", "enabled", "optional", "Boolean", "scriptName", "payload", "Record", "key", "value", "output", "Void"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/AutomationPanel/AutomationPanel.tsx", "../../../src/components/AutomationPanel/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useState } from 'react';\n\nimport { S } from '@dxos/echo-schema';\nimport {\n FunctionType,\n FunctionTrigger,\n FunctionTriggerSchema,\n TriggerKind,\n type FunctionTriggerType,\n ScriptType,\n} from '@dxos/functions/types';\nimport { type Client, useClient } from '@dxos/react-client';\nimport { live, Filter, useQuery, type Space, type Live, getSpace } from '@dxos/react-client/echo';\nimport { Clipboard, IconButton, Input, Separator, useTranslation } from '@dxos/react-ui';\nimport { ControlItem, 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';\nimport { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';\n\nconst grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';\n\nexport type AutomationPanelProps = {\n space: Space;\n object?: Live<any>;\n initialTrigger?: FunctionTriggerType;\n onDone?: () => void;\n};\n\n// TODO(burdon): Factor out common layout with ViewEditor.\nexport const AutomationPanel = ({ space, object, initialTrigger, onDone }: AutomationPanelProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const client = useClient();\n const triggers = useQuery(space, Filter.schema(FunctionTrigger));\n const functions = useQuery(space, Filter.schema(FunctionType));\n const scripts = useQuery(space, Filter.schema(ScriptType));\n\n const [trigger, setTrigger] = useState<FunctionTriggerType | undefined>(initialTrigger);\n const [selected, setSelected] = useState<FunctionTrigger>();\n\n const handleSelect = (trigger: FunctionTrigger) => {\n const { id: _, ...values } = trigger;\n setTrigger(values);\n setSelected(trigger);\n };\n\n const handleAdd = () => {\n setTrigger(live(FunctionTriggerSchema, {}));\n setSelected(undefined);\n };\n\n const handleDelete = (trigger: FunctionTrigger) => {\n space.db.remove(trigger);\n setTrigger(undefined);\n setSelected(undefined);\n };\n\n const handleSave: TriggerEditorProps['onSave'] = (trigger) => {\n if (selected) {\n Object.assign(selected, trigger);\n } else {\n space.db.add(live(FunctionTrigger, trigger));\n }\n\n setTrigger(undefined);\n setSelected(undefined);\n onDone?.();\n };\n\n const handleCancel: TriggerEditorProps['onCancel'] = () => {\n setTrigger(undefined);\n onDone?.();\n };\n\n return (\n <div className='flex flex-col w-full'>\n {trigger ? (\n <ControlItem title={t('trigger editor title')}>\n <TriggerEditor space={space} trigger={trigger} onSave={handleSave} onCancel={handleCancel} />\n </ControlItem>\n ) : (\n <div role='none' className={controlItemClasses}>\n <List.Root<FunctionTrigger> items={triggers} isItem={S.is(FunctionTrigger)} getId={(field) => field.id}>\n {({ items: triggers }) => (\n <div role='list' className='flex flex-col w-full'>\n {triggers?.map((trigger) => {\n const copyAction = getCopyAction(client, trigger);\n return (\n <List.Item<FunctionTrigger>\n key={trigger.id}\n item={trigger}\n classNames={mx(grid, ghostHover, 'items-center', 'px-2')}\n >\n <Input.Root>\n <Input.Switch\n checked={trigger.enabled}\n onCheckedChange={(checked) => (trigger.enabled = checked)}\n />\n </Input.Root>\n\n <div className={'flex'}>\n <List.ItemTitle\n classNames='px-1 cursor-pointer w-0 shrink truncate'\n onClick={() => handleSelect(trigger)}\n >\n {getFunctionName(scripts, functions, trigger) ?? '∅'}\n </List.ItemTitle>\n\n {/* TODO: a better way to expose copy action */}\n {copyAction && (\n <Clipboard.IconButton\n label={t(copyAction.translationKey)}\n value={copyAction.contentProvider()}\n />\n )}\n </div>\n\n <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />\n </List.Item>\n );\n })}\n </div>\n )}\n </List.Root>\n {triggers.length > 0 && <Separator classNames='mlb-4' />}\n <IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />\n </div>\n )}\n </div>\n );\n};\n\nconst getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) => {\n if (trigger?.spec?.type === TriggerKind.Email) {\n return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };\n }\n\n if (trigger?.spec?.type === TriggerKind.Webhook) {\n return { translationKey: 'trigger copy url', contentProvider: () => getWebhookUrl(client, trigger) };\n }\n\n return undefined;\n};\n\nconst getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {\n const spaceId = getSpace(trigger)!.id;\n const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);\n const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');\n edgeUrl.protocol = isSecure ? 'https' : 'http';\n return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();\n};\n\nconst getFunctionName = (scripts: ScriptType[], functions: FunctionType[], trigger: FunctionTriggerType) => {\n // TODO(wittjosiah): Truncation should be done in the UI.\n // Warning that the List component is currently a can of worms.\n const shortId = trigger.function && `${trigger.function?.slice(0, 16)}…`;\n const functionObject = functions.find((fn) => `dxn:worker:${fn.name}` === trigger.function);\n if (!functionObject) {\n return shortId;\n }\n return scripts.find((s) => functionObject.source?.target?.id === s.id)?.name ?? shortId;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AutomationPanel } from './AutomationPanel';\n\nexport * from './AutomationPanel';\n\nexport default AutomationPanel;\n"],
5
- "mappings": ";;;;;;;;AAIA,OAAOA,SAASC,gBAAgB;AAEhC,SAASC,SAAS;AAClB,SACEC,cACAC,iBACAC,uBACAC,aAEAC,kBACK;AACP,SAAsBC,iBAAiB;AACvC,SAASC,MAAMC,QAAQC,UAAiCC,gBAAgB;AACxE,SAASC,WAAWC,YAAYC,OAAOC,WAAWC,sBAAsB;AACxE,SAASC,aAAaC,0BAA0B;AAChD,SAASC,YAAY;AACrB,SAASC,YAAYC,UAAU;AAK/B,IAAMC,OAAO;AAUN,IAAMC,kBAAkB,CAAC,EAAEC,OAAOC,QAAQC,gBAAgBC,OAAM,MAAwB;AAC7F,QAAM,EAAEC,EAAC,IAAKC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AgB;MAAsBE,iBAAiB,MAAM,GAAGS,SAASrE,OAAAA,EAAUM,EAAE;IAAgB;EAChH;AAEA,MAAIN,SAASiE,MAAMC,SAASC,YAAYG,SAAS;AAC/C,WAAO;MAAEZ,gBAAgB;MAAoBE,iBAAiB,MAAMW,cAAclF,QAAQW,OAAAA;IAAS;EACrG;AAEA,SAAOY;AACT;AAEA,IAAM2D,gBAAgB,CAAClF,QAAgBW,YAAAA;AACrC,QAAMwE,UAAUH,SAASrE,OAAAA,EAAUM;AACnC,QAAMmE,UAAU,IAAIC,IAAIrF,OAAOsF,OAAOnE,OAAOoE,QAASC,SAAUC,KAAMC,GAAG;AACzE,QAAMC,WAAWP,QAAQQ,SAASC,WAAW,OAAA,KAAYT,QAAQQ,SAASC,WAAW,KAAA;AACrFT,UAAQQ,WAAWD,WAAW,UAAU;AACxC,SAAO,IAAIN,IAAI,YAAYF,OAAAA,IAAWxE,QAAQM,EAAE,IAAImE,OAAAA,EAASU,SAAQ;AACvE;AAEA,IAAM7B,kBAAkB,CAACxD,SAAuBF,WAA2BI,YAAAA;AAGzE,QAAMoF,UAAUpF,QAAQqF,YAAY,GAAGrF,QAAQqF,UAAUC,MAAM,GAAG,EAAA,CAAA;AAClE,QAAMC,iBAAiB3F,UAAU4F,KAAK,CAACC,OAAO,cAAcA,GAAGC,IAAI,OAAO1F,QAAQqF,QAAQ;AAC1F,MAAI,CAACE,gBAAgB;AACnB,WAAOH;EACT;AACA,SAAOtF,QAAQ0F,KAAK,CAACG,MAAMJ,eAAeK,QAAQC,QAAQvF,OAAOqF,EAAErF,EAAE,GAAGoF,QAAQN;AAClF;;;AC9JA,IAAA,0BAAeU;",
6
- "names": ["React", "useState", "S", "FunctionType", "FunctionTrigger", "FunctionTriggerSchema", "TriggerKind", "ScriptType", "useClient", "live", "Filter", "useQuery", "getSpace", "Clipboard", "IconButton", "Input", "Separator", "useTranslation", "ControlItem", "controlItemClasses", "List", "ghostHover", "mx", "grid", "AutomationPanel", "space", "object", "initialTrigger", "onDone", "t", "useTranslation", "AUTOMATION_PLUGIN", "client", "useClient", "triggers", "useQuery", "Filter", "schema", "FunctionTrigger", "functions", "FunctionType", "scripts", "ScriptType", "trigger", "setTrigger", "useState", "selected", "setSelected", "handleSelect", "id", "_", "values", "handleAdd", "live", "FunctionTriggerSchema", "undefined", "handleDelete", "db", "remove", "handleSave", "Object", "assign", "add", "handleCancel", "div", "className", "ControlItem", "title", "TriggerEditor", "onSave", "onCancel", "role", "controlItemClasses", "List", "Root", "items", "isItem", "S", "is", "getId", "field", "map", "copyAction", "getCopyAction", "Item", "key", "item", "classNames", "mx", "ghostHover", "Input", "Switch", "checked", "enabled", "onCheckedChange", "ItemTitle", "onClick", "getFunctionName", "Clipboard", "IconButton", "label", "translationKey", "value", "contentProvider", "ItemDeleteButton", "length", "Separator", "icon", "spec", "type", "TriggerKind", "Email", "getSpace", "Webhook", "getWebhookUrl", "spaceId", "edgeUrl", "URL", "config", "runtime", "services", "edge", "url", "isSecure", "protocol", "startsWith", "toString", "shortId", "function", "slice", "functionObject", "find", "fn", "name", "s", "source", "target", "AutomationPanel"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/capabilities/intent-resolver.ts"],
4
- "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport {\n contributes,\n Capabilities,\n createResolver,\n type PluginsContext,\n createIntent,\n LayoutAction,\n} from '@dxos/app-framework';\nimport { FunctionTrigger, FunctionType, ScriptType, TriggerKind } from '@dxos/functions';\nimport { type DXN } from '@dxos/keys';\nimport { live } from '@dxos/live-object';\nimport { ATTENDABLE_PATH_SEPARATOR } from '@dxos/plugin-deck/types';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { Filter } from '@dxos/react-client/echo';\n\nimport { AutomationAction } from '../types';\n\nexport default (context: PluginsContext) =>\n contributes(Capabilities.IntentResolver, [\n createResolver({\n intent: AutomationAction.CreateTriggerFromTemplate,\n resolve: async ({ space, template, enabled = false, scriptName, payload }) => {\n const trigger = live(FunctionTrigger, { enabled });\n\n // TODO(wittjosiah): Factor out function lookup by script name?\n if (scriptName) {\n const {\n objects: [script],\n } = await space.db.query(Filter.schema(ScriptType, { name: scriptName })).run();\n if (script) {\n const {\n objects: [fn],\n } = await space.db.query(Filter.schema(FunctionType, { source: script })).run();\n if (fn) {\n trigger.function = `dxn:worker:${fn.name}`;\n }\n }\n }\n\n if (payload) {\n trigger.meta = payload;\n }\n\n switch (template.type) {\n case 'timer': {\n trigger.spec = { type: TriggerKind.Timer, cron: template.cron };\n break;\n }\n case 'queue': {\n trigger.spec = { type: TriggerKind.Queue, queue: (template.queueDXN as DXN).toString() };\n break;\n }\n default: {\n break;\n }\n }\n\n return {\n intents: [\n createIntent(SpaceAction.AddObject, { object: trigger, target: space }),\n createIntent(LayoutAction.Open, {\n part: 'main',\n subject: [`automation-settings${ATTENDABLE_PATH_SEPARATOR}${space.id}`],\n options: {\n workspace: space.id,\n },\n }),\n ],\n };\n },\n }),\n ]);\n"],
5
- "mappings": ";;;;;;AAIA,SACEA,aACAC,cACAC,gBAEAC,cACAC,oBACK;AACP,SAASC,iBAAiBC,cAAcC,YAAYC,mBAAmB;AAEvE,SAASC,YAAY;AACrB,SAASC,iCAAiC;AAC1C,SAASC,mBAAmB;AAC5B,SAASC,cAAc;AAIvB,IAAA,0BAAe,CAACC,YACdC,YAAYC,aAAaC,gBAAgB;EACvCC,eAAe;IACbC,QAAQC,iBAAiBC;IACzBC,SAAS,OAAO,EAAEC,OAAOC,UAAUC,UAAU,OAAOC,YAAYC,QAAO,MAAE;AACvE,YAAMC,UAAUC,KAAKC,iBAAiB;QAAEL;MAAQ,CAAA;AAGhD,UAAIC,YAAY;AACd,cAAM,EACJK,SAAS,CAACC,MAAAA,EAAO,IACf,MAAMT,MAAMU,GAAGC,MAAMC,OAAOC,OAAOC,YAAY;UAAEC,MAAMZ;QAAW,CAAA,CAAA,EAAIa,IAAG;AAC7E,YAAIP,QAAQ;AACV,gBAAM,EACJD,SAAS,CAACS,EAAAA,EAAG,IACX,MAAMjB,MAAMU,GAAGC,MAAMC,OAAOC,OAAOK,cAAc;YAAEC,QAAQV;UAAO,CAAA,CAAA,EAAIO,IAAG;AAC7E,cAAIC,IAAI;AACNZ,oBAAQe,WAAW,cAAcH,GAAGF,IAAI;UAC1C;QACF;MACF;AAEA,UAAIX,SAAS;AACXC,gBAAQgB,OAAOjB;MACjB;AAEA,cAAQH,SAASqB,MAAI;QACnB,KAAK,SAAS;AACZjB,kBAAQkB,OAAO;YAAED,MAAME,YAAYC;YAAOC,MAAMzB,SAASyB;UAAK;AAC9D;QACF;QACA,KAAK,SAAS;AACZrB,kBAAQkB,OAAO;YAAED,MAAME,YAAYG;YAAOC,OAAQ3B,SAAS4B,SAAiBC,SAAQ;UAAG;AACvF;QACF;QACA,SAAS;AACP;QACF;MACF;AAEA,aAAO;QACLC,SAAS;UACPC,aAAaC,YAAYC,WAAW;YAAEC,QAAQ9B;YAAS+B,QAAQpC;UAAM,CAAA;UACrEgC,aAAaK,aAAaC,MAAM;YAC9BC,MAAM;YACNC,SAAS;cAAC,sBAAsBC,yBAAAA,GAA4BzC,MAAM0C,EAAE;;YACpEC,SAAS;cACPC,WAAW5C,MAAM0C;YACnB;UACF,CAAA;;MAEJ;IACF;EACF,CAAA;CACD;",
6
- "names": ["contributes", "Capabilities", "createResolver", "createIntent", "LayoutAction", "FunctionTrigger", "FunctionType", "ScriptType", "TriggerKind", "live", "ATTENDABLE_PATH_SEPARATOR", "SpaceAction", "Filter", "context", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "AutomationAction", "CreateTriggerFromTemplate", "resolve", "space", "template", "enabled", "scriptName", "payload", "trigger", "live", "FunctionTrigger", "objects", "script", "db", "query", "Filter", "schema", "ScriptType", "name", "run", "fn", "FunctionType", "source", "function", "meta", "type", "spec", "TriggerKind", "Timer", "cron", "Queue", "queue", "queueDXN", "toString", "intents", "createIntent", "SpaceAction", "AddObject", "object", "target", "LayoutAction", "Open", "part", "subject", "ATTENDABLE_PATH_SEPARATOR", "id", "options", "workspace"]
7
- }
@@ -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: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VC,OAAO;YAAC;YAA2B;cAAEC,IAAIT,2BAAKD;YAAG;;UACjDW,MAAM;QACR;MACF;;EAEJ,CAAA;CACD;",
6
- "names": ["import_types", "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
- }