@dxos/plugin-automation 0.8.2-main.5885341 → 0.8.2-main.5ca3450

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 (131) hide show
  1. package/dist/lib/browser/{AutomationContainer-KEQ5RNIW.mjs → AutomationContainer-PDPL34DX.mjs} +3 -3
  2. package/dist/lib/browser/{AutomationPanel-G3OB6ELR.mjs → AutomationPanel-3WG2B7JM.mjs} +3 -3
  3. package/dist/lib/browser/{FunctionsContainer-STXBW4CX.mjs → FunctionsContainer-HLISW5QI.mjs} +2 -2
  4. package/dist/lib/browser/{FunctionsPanel-JJPLIAJW.mjs → FunctionsPanel-OKFRBXLO.mjs} +2 -2
  5. package/dist/lib/browser/chunk-ADYCSC6Y.mjs +39 -0
  6. package/dist/lib/browser/chunk-ADYCSC6Y.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-QJPKWYTL.mjs → chunk-GUPG3Q72.mjs} +5 -5
  8. package/dist/lib/browser/{chunk-65VL4EYS.mjs → chunk-IDCVJ2JW.mjs} +4 -4
  9. package/dist/lib/browser/chunk-IDCVJ2JW.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-NGG4ICAQ.mjs → chunk-QFIPNCNF.mjs} +9 -9
  11. package/dist/lib/browser/chunk-QFIPNCNF.mjs.map +7 -0
  12. package/dist/lib/browser/chunk-W4T2BTH2.mjs +211 -0
  13. package/dist/lib/browser/chunk-W4T2BTH2.mjs.map +7 -0
  14. package/dist/lib/browser/index.mjs +5 -5
  15. package/dist/lib/browser/index.mjs.map +1 -1
  16. package/dist/lib/browser/{intent-resolver-SNIAQ7V5.mjs → intent-resolver-TCUIVOEW.mjs} +9 -10
  17. package/dist/lib/browser/intent-resolver-TCUIVOEW.mjs.map +7 -0
  18. package/dist/lib/browser/meta.json +1 -1
  19. package/dist/lib/browser/{react-surface-L22QIANU.mjs → react-surface-P65PEZPN.mjs} +4 -4
  20. package/dist/lib/browser/{react-surface-L22QIANU.mjs.map → react-surface-P65PEZPN.mjs.map} +1 -1
  21. package/dist/lib/browser/types.mjs +1 -1
  22. package/dist/lib/node/{AutomationContainer-E5I76FPP.cjs → AutomationContainer-EXTHQ7B3.cjs} +7 -7
  23. package/dist/lib/node/{AutomationPanel-YLXAFJDP.cjs → AutomationPanel-G7R6RL7O.cjs} +8 -8
  24. package/dist/lib/node/{AutomationPanel-YLXAFJDP.cjs.map → AutomationPanel-G7R6RL7O.cjs.map} +2 -2
  25. package/dist/lib/node/{FunctionsContainer-3HCURMEB.cjs → FunctionsContainer-RNZTNQEU.cjs} +6 -6
  26. package/dist/lib/node/{FunctionsPanel-SYIZHPGU.cjs → FunctionsPanel-7I7YCHPJ.cjs} +7 -7
  27. package/dist/lib/node/{FunctionsPanel-SYIZHPGU.cjs.map → FunctionsPanel-7I7YCHPJ.cjs.map} +2 -2
  28. package/dist/lib/node/chunk-A4DMUH7U.cjs +234 -0
  29. package/dist/lib/node/chunk-A4DMUH7U.cjs.map +7 -0
  30. package/dist/lib/node/{chunk-L5TWLPGA.cjs → chunk-B3OL2E3B.cjs} +8 -8
  31. package/dist/lib/node/{chunk-SRXHHBDE.cjs → chunk-F74YVA6P.cjs} +18 -18
  32. package/dist/lib/node/chunk-F74YVA6P.cjs.map +7 -0
  33. package/dist/lib/node/{chunk-PSIJDHAX.cjs → chunk-GDCG2BML.cjs} +19 -19
  34. package/dist/lib/node/chunk-GDCG2BML.cjs.map +7 -0
  35. package/dist/lib/node/{chunk-BSK5SHTR.cjs → chunk-GLXGAIZC.cjs} +9 -9
  36. package/dist/lib/node/chunk-GLXGAIZC.cjs.map +7 -0
  37. package/dist/lib/node/index.cjs +12 -12
  38. package/dist/lib/node/index.cjs.map +2 -2
  39. package/dist/lib/node/{intent-resolver-A44BNFEG.cjs → intent-resolver-6XS2NYC7.cjs} +16 -17
  40. package/dist/lib/node/intent-resolver-6XS2NYC7.cjs.map +7 -0
  41. package/dist/lib/node/meta.json +1 -1
  42. package/dist/lib/node/{react-surface-PCZCHIET.cjs → react-surface-OYJMJXJI.cjs} +11 -11
  43. package/dist/lib/node/react-surface-OYJMJXJI.cjs.map +7 -0
  44. package/dist/lib/node/types.cjs +2 -2
  45. package/dist/lib/node/types.cjs.map +1 -1
  46. package/dist/lib/node-esm/{AutomationContainer-22PUFPSE.mjs → AutomationContainer-FSWEGDKP.mjs} +3 -3
  47. package/dist/lib/node-esm/{AutomationPanel-6UXIAJVS.mjs → AutomationPanel-LIPLJA55.mjs} +3 -3
  48. package/dist/lib/node-esm/{FunctionsContainer-XG5WVAN3.mjs → FunctionsContainer-435FW56J.mjs} +2 -2
  49. package/dist/lib/node-esm/{FunctionsPanel-J3QGUESH.mjs → FunctionsPanel-NXXT5ERU.mjs} +2 -2
  50. package/dist/lib/node-esm/{chunk-HMYAQLGF.mjs → chunk-27IHWHDH.mjs} +9 -9
  51. package/dist/lib/node-esm/chunk-27IHWHDH.mjs.map +7 -0
  52. package/dist/lib/node-esm/{chunk-YYBCQXB2.mjs → chunk-EEA6CZ6B.mjs} +16 -16
  53. package/dist/lib/node-esm/chunk-EEA6CZ6B.mjs.map +7 -0
  54. package/dist/lib/node-esm/chunk-IS3BYE3I.mjs +212 -0
  55. package/dist/lib/node-esm/chunk-IS3BYE3I.mjs.map +7 -0
  56. package/dist/lib/node-esm/{chunk-4UPGANGV.mjs → chunk-VYSTWH6Q.mjs} +4 -4
  57. package/dist/lib/node-esm/chunk-VYSTWH6Q.mjs.map +7 -0
  58. package/dist/lib/node-esm/{chunk-TMMB5ETD.mjs → chunk-YCNX76NJ.mjs} +5 -5
  59. package/dist/lib/node-esm/index.mjs +5 -5
  60. package/dist/lib/node-esm/index.mjs.map +1 -1
  61. package/dist/lib/node-esm/{intent-resolver-JFLTVJ7D.mjs → intent-resolver-CHDYUFFN.mjs} +9 -10
  62. package/dist/lib/node-esm/intent-resolver-CHDYUFFN.mjs.map +7 -0
  63. package/dist/lib/node-esm/meta.json +1 -1
  64. package/dist/lib/node-esm/{react-surface-VSO4NWC6.mjs → react-surface-FDGQORLY.mjs} +4 -4
  65. package/dist/lib/node-esm/{react-surface-VSO4NWC6.mjs.map → react-surface-FDGQORLY.mjs.map} +1 -1
  66. package/dist/lib/node-esm/types.mjs +1 -1
  67. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  68. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  69. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  70. package/dist/types/src/components/AutomationContainer.d.ts.map +1 -1
  71. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -1
  72. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
  73. package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -1
  74. package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
  75. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +12 -0
  76. package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -0
  77. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +5 -0
  78. package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -0
  79. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -1
  80. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  81. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  82. package/dist/types/src/testing/test-functions.d.ts.map +1 -1
  83. package/dist/types/src/types.d.ts +15 -15
  84. package/dist/types/src/types.d.ts.map +1 -1
  85. package/dist/types/tsconfig.tsbuildinfo +1 -1
  86. package/package.json +28 -24
  87. package/src/AutomationPlugin.tsx +1 -1
  88. package/src/capabilities/intent-resolver.ts +6 -9
  89. package/src/capabilities/react-surface.tsx +1 -1
  90. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -1
  91. package/src/components/AutomationPanel/AutomationPanel.tsx +8 -7
  92. package/src/components/FunctionsPanel/FunctionsPanel.tsx +3 -3
  93. package/src/components/TriggerEditor/FunctionInputEditor.tsx +77 -0
  94. package/src/components/TriggerEditor/SpecSelector.tsx +59 -0
  95. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +16 -7
  96. package/src/components/TriggerEditor/TriggerEditor.tsx +50 -90
  97. package/src/testing/test-functions.ts +23 -9
  98. package/src/types.ts +11 -10
  99. package/dist/lib/browser/chunk-65VL4EYS.mjs.map +0 -7
  100. package/dist/lib/browser/chunk-FALBBJNO.mjs +0 -138
  101. package/dist/lib/browser/chunk-FALBBJNO.mjs.map +0 -7
  102. package/dist/lib/browser/chunk-FCLWFVFX.mjs +0 -39
  103. package/dist/lib/browser/chunk-FCLWFVFX.mjs.map +0 -7
  104. package/dist/lib/browser/chunk-NGG4ICAQ.mjs.map +0 -7
  105. package/dist/lib/browser/intent-resolver-SNIAQ7V5.mjs.map +0 -7
  106. package/dist/lib/node/chunk-BSK5SHTR.cjs.map +0 -7
  107. package/dist/lib/node/chunk-FTEDH5Q6.cjs +0 -167
  108. package/dist/lib/node/chunk-FTEDH5Q6.cjs.map +0 -7
  109. package/dist/lib/node/chunk-PSIJDHAX.cjs.map +0 -7
  110. package/dist/lib/node/chunk-SRXHHBDE.cjs.map +0 -7
  111. package/dist/lib/node/intent-resolver-A44BNFEG.cjs.map +0 -7
  112. package/dist/lib/node/react-surface-PCZCHIET.cjs.map +0 -7
  113. package/dist/lib/node-esm/chunk-4UPGANGV.mjs.map +0 -7
  114. package/dist/lib/node-esm/chunk-HMYAQLGF.mjs.map +0 -7
  115. package/dist/lib/node-esm/chunk-M4QXMIIB.mjs +0 -139
  116. package/dist/lib/node-esm/chunk-M4QXMIIB.mjs.map +0 -7
  117. package/dist/lib/node-esm/chunk-YYBCQXB2.mjs.map +0 -7
  118. package/dist/lib/node-esm/intent-resolver-JFLTVJ7D.mjs.map +0 -7
  119. /package/dist/lib/browser/{AutomationContainer-KEQ5RNIW.mjs.map → AutomationContainer-PDPL34DX.mjs.map} +0 -0
  120. /package/dist/lib/browser/{AutomationPanel-G3OB6ELR.mjs.map → AutomationPanel-3WG2B7JM.mjs.map} +0 -0
  121. /package/dist/lib/browser/{FunctionsContainer-STXBW4CX.mjs.map → FunctionsContainer-HLISW5QI.mjs.map} +0 -0
  122. /package/dist/lib/browser/{FunctionsPanel-JJPLIAJW.mjs.map → FunctionsPanel-OKFRBXLO.mjs.map} +0 -0
  123. /package/dist/lib/browser/{chunk-QJPKWYTL.mjs.map → chunk-GUPG3Q72.mjs.map} +0 -0
  124. /package/dist/lib/node/{AutomationContainer-E5I76FPP.cjs.map → AutomationContainer-EXTHQ7B3.cjs.map} +0 -0
  125. /package/dist/lib/node/{FunctionsContainer-3HCURMEB.cjs.map → FunctionsContainer-RNZTNQEU.cjs.map} +0 -0
  126. /package/dist/lib/node/{chunk-L5TWLPGA.cjs.map → chunk-B3OL2E3B.cjs.map} +0 -0
  127. /package/dist/lib/node-esm/{AutomationContainer-22PUFPSE.mjs.map → AutomationContainer-FSWEGDKP.mjs.map} +0 -0
  128. /package/dist/lib/node-esm/{AutomationPanel-6UXIAJVS.mjs.map → AutomationPanel-LIPLJA55.mjs.map} +0 -0
  129. /package/dist/lib/node-esm/{FunctionsContainer-XG5WVAN3.mjs.map → FunctionsContainer-435FW56J.mjs.map} +0 -0
  130. /package/dist/lib/node-esm/{FunctionsPanel-J3QGUESH.mjs.map → FunctionsPanel-NXXT5ERU.mjs.map} +0 -0
  131. /package/dist/lib/node-esm/{chunk-TMMB5ETD.mjs.map → chunk-YCNX76NJ.mjs.map} +0 -0
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_A4DMUH7U_exports = {};
30
+ __export(chunk_A4DMUH7U_exports, {
31
+ TriggerEditor: () => TriggerEditor
32
+ });
33
+ module.exports = __toCommonJS(chunk_A4DMUH7U_exports);
34
+ var import_chunk_7GXNXMSM = require("./chunk-7GXNXMSM.cjs");
35
+ var import_react = __toESM(require("react"));
36
+ var import_conductor = require("@dxos/conductor");
37
+ var import_echo = require("@dxos/echo");
38
+ var import_functions = require("@dxos/functions");
39
+ var import_echo2 = require("@dxos/react-client/echo");
40
+ var import_react_ui = require("@dxos/react-ui");
41
+ var import_react_ui_form = require("@dxos/react-ui-form");
42
+ var import_react2 = __toESM(require("react"));
43
+ var import_echo_schema = require("@dxos/echo-schema");
44
+ var import_react_ui2 = require("@dxos/react-ui");
45
+ var import_react_ui_form2 = require("@dxos/react-ui-form");
46
+ var import_react3 = __toESM(require("react"));
47
+ var import_functions2 = require("@dxos/functions");
48
+ var import_react_ui3 = require("@dxos/react-ui");
49
+ var import_react_ui_form3 = require("@dxos/react-ui-form");
50
+ var FunctionInputEditor = ({ functions, getValue, onValueChange, onQueryRefOptions }) => {
51
+ const selectedFunctionValue = (0, import_react_ui_form2.useFormValues)([
52
+ "function"
53
+ ]);
54
+ const selectedFunctionId = (0, import_react2.useMemo)(() => {
55
+ if (selectedFunctionValue instanceof import_echo_schema.RefImpl) {
56
+ return selectedFunctionValue.dxn.toString().split("dxn:echo:@:").at(1);
57
+ }
58
+ }, [
59
+ selectedFunctionValue
60
+ ]);
61
+ const selectedFunction = (0, import_react2.useMemo)(() => functions.find((f) => f.id === selectedFunctionId), [
62
+ functions,
63
+ selectedFunctionId
64
+ ]);
65
+ (0, import_react_ui2.useOnTransition)(
66
+ // Clear function parameter input when the function changes.
67
+ selectedFunctionValue,
68
+ (prevValue) => prevValue !== void 0 && prevValue !== selectedFunctionValue,
69
+ (currValue) => currValue !== void 0,
70
+ () => onValueChange("object", {})
71
+ );
72
+ const inputSchema = (0, import_react2.useMemo)(() => selectedFunction?.inputSchema, [
73
+ selectedFunction
74
+ ]);
75
+ const effectSchema = (0, import_react2.useMemo)(() => inputSchema ? (0, import_echo_schema.toEffectSchema)(inputSchema) : void 0, [
76
+ inputSchema
77
+ ]);
78
+ const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
79
+ const values = (0, import_react2.useMemo)(() => getValue() ?? {}, [
80
+ getValue
81
+ ]);
82
+ const handleValuesChanged = (0, import_react2.useCallback)((values2) => {
83
+ onValueChange("object", values2);
84
+ }, [
85
+ onValueChange
86
+ ]);
87
+ if (selectedFunction === void 0 || effectSchema === void 0 || propertyCount === 0) {
88
+ return null;
89
+ }
90
+ return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("h3", {
91
+ className: "text-md"
92
+ }, "Function parameters"), /* @__PURE__ */ import_react2.default.createElement(import_react_ui_form2.Form, {
93
+ schema: effectSchema,
94
+ values,
95
+ classNames: "p-0",
96
+ onValuesChanged: handleValuesChanged,
97
+ onQueryRefOptions
98
+ }));
99
+ };
100
+ var SpecSelector = (props) => {
101
+ const { t } = (0, import_react_ui3.useTranslation)(import_chunk_7GXNXMSM.AUTOMATION_PLUGIN);
102
+ const specProps = (0, import_react_ui_form3.useInputProps)([
103
+ "spec"
104
+ ]);
105
+ const handleTypeChange = (0, import_react3.useCallback)((_type, value) => {
106
+ const getDefaultTriggerSpec = (kind) => {
107
+ switch (kind) {
108
+ case import_functions2.TriggerKind.Timer:
109
+ return {
110
+ type: import_functions2.TriggerKind.Timer,
111
+ cron: ""
112
+ };
113
+ case import_functions2.TriggerKind.Subscription:
114
+ return {
115
+ type: import_functions2.TriggerKind.Subscription,
116
+ filter: {}
117
+ };
118
+ case import_functions2.TriggerKind.Queue:
119
+ return {
120
+ type: import_functions2.TriggerKind.Queue,
121
+ queue: ""
122
+ };
123
+ case import_functions2.TriggerKind.Email:
124
+ return {
125
+ type: import_functions2.TriggerKind.Email
126
+ };
127
+ case import_functions2.TriggerKind.Webhook:
128
+ return {
129
+ type: import_functions2.TriggerKind.Webhook
130
+ };
131
+ default:
132
+ return void 0;
133
+ }
134
+ };
135
+ const defaultSpec = getDefaultTriggerSpec(value);
136
+ if (!defaultSpec) {
137
+ return;
138
+ }
139
+ specProps.onValueChange("object", defaultSpec);
140
+ }, [
141
+ specProps
142
+ ]);
143
+ const options = (0, import_react3.useMemo)(() => Object.values(import_functions2.TriggerKind).map((kind) => ({
144
+ value: kind,
145
+ label: t(`trigger type ${kind}`)
146
+ })), [
147
+ t
148
+ ]);
149
+ return /* @__PURE__ */ import_react3.default.createElement(import_react_ui_form3.SelectInput, {
150
+ ...props,
151
+ options,
152
+ onValueChange: handleTypeChange
153
+ });
154
+ };
155
+ var TriggerEditor = ({ space, trigger, onSave, onCancel }) => {
156
+ const { t } = (0, import_react_ui.useTranslation)(import_chunk_7GXNXMSM.AUTOMATION_PLUGIN);
157
+ const functions = (0, import_echo2.useQuery)(space, import_echo2.Filter.schema(import_functions.FunctionType));
158
+ const workflows = (0, import_echo2.useQuery)(space, import_echo2.Filter.schema(import_conductor.ComputeGraph));
159
+ const scripts = (0, import_echo2.useQuery)(space, import_echo2.Filter.schema(import_functions.ScriptType));
160
+ const handleSave = (values) => {
161
+ onSave?.(values);
162
+ };
163
+ const handleRefQueryLookup = (0, import_react_ui_form.useRefQueryLookupHandler)({
164
+ space
165
+ });
166
+ const Custom = (0, import_react.useMemo)(() => ({
167
+ ["function"]: (props) => {
168
+ const getValue = (0, import_react.useCallback)(() => {
169
+ const formValue = props.getValue();
170
+ if (import_echo2.Ref.isRef(formValue)) {
171
+ return formValue.dxn.toString();
172
+ }
173
+ return void 0;
174
+ }, [
175
+ props
176
+ ]);
177
+ const handleOnValueChange = (0, import_react.useCallback)((_type, dxnString) => {
178
+ const dxn = import_echo.DXN.parse(dxnString);
179
+ if (dxn) {
180
+ const ref = import_echo2.Ref.fromDXN(dxn);
181
+ props.onValueChange("object", ref);
182
+ }
183
+ }, [
184
+ props.onValueChange
185
+ ]);
186
+ return /* @__PURE__ */ import_react.default.createElement(import_react_ui_form.SelectInput, {
187
+ ...props,
188
+ getValue,
189
+ onValueChange: handleOnValueChange,
190
+ options: getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))
191
+ });
192
+ },
193
+ ["spec.kind"]: SpecSelector,
194
+ ["input"]: (props) => /* @__PURE__ */ import_react.default.createElement(FunctionInputEditor, {
195
+ ...props,
196
+ functions,
197
+ onQueryRefOptions: handleRefQueryLookup
198
+ })
199
+ }), [
200
+ workflows,
201
+ scripts,
202
+ functions,
203
+ t
204
+ ]);
205
+ return /* @__PURE__ */ import_react.default.createElement("div", {
206
+ role: "none",
207
+ className: "bs-full is-full"
208
+ }, /* @__PURE__ */ import_react.default.createElement(import_react_ui_form.Form, {
209
+ schema: import_functions.FunctionTriggerSchema,
210
+ values: trigger,
211
+ onSave: handleSave,
212
+ onCancel,
213
+ Custom,
214
+ onQueryRefOptions: handleRefQueryLookup
215
+ }));
216
+ };
217
+ var getWorkflowOptions = (graphs) => {
218
+ return graphs.map((graph) => ({
219
+ label: `compute-${graph.id}`,
220
+ value: `dxn:echo:@:${graph.id}`
221
+ }));
222
+ };
223
+ var getFunctionOptions = (scripts, functions) => {
224
+ const getLabel = (fn) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
225
+ return functions.map((fn) => ({
226
+ label: getLabel(fn),
227
+ value: `dxn:echo:@:${fn.id}`
228
+ }));
229
+ };
230
+ // Annotate the CommonJS export names for ESM import in node:
231
+ 0 && (module.exports = {
232
+ TriggerEditor
233
+ });
234
+ //# sourceMappingURL=chunk-A4DMUH7U.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/TriggerEditor/TriggerEditor.tsx", "../../../src/components/TriggerEditor/FunctionInputEditor.tsx", "../../../src/components/TriggerEditor/SpecSelector.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { ComputeGraph } from '@dxos/conductor';\nimport { DXN } from '@dxos/echo';\nimport {\n FunctionType,\n FunctionTriggerSchema,\n type FunctionTriggerType,\n type FunctionTrigger,\n ScriptType,\n} from '@dxos/functions';\nimport { Filter, Ref, useQuery, type Space } from '@dxos/react-client/echo';\nimport { useTranslation } from '@dxos/react-ui';\nimport { type CustomInputMap, Form, SelectInput, useRefQueryLookupHandler } from '@dxos/react-ui-form';\n\nimport { FunctionInputEditor } from './FunctionInputEditor';\nimport { SpecSelector } from './SpecSelector';\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\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 handleRefQueryLookup = useRefQueryLookupHandler({ space });\n\n const Custom = useMemo(\n (): CustomInputMap => ({\n ['function' satisfies keyof FunctionTriggerType]: (props) => {\n const getValue = useCallback(() => {\n const formValue = props.getValue();\n if (Ref.isRef(formValue)) {\n return formValue.dxn.toString() as string;\n }\n return undefined;\n }, [props]);\n\n const handleOnValueChange = useCallback(\n (_type: any, dxnString: string) => {\n const dxn = DXN.parse(dxnString);\n if (dxn) {\n const ref = Ref.fromDXN(dxn);\n props.onValueChange('object', ref);\n }\n },\n [props.onValueChange],\n );\n\n return (\n <SelectInput\n {...props}\n getValue={getValue as any}\n onValueChange={handleOnValueChange}\n options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}\n />\n );\n },\n ['spec.kind' as const]: SpecSelector,\n ['input' as const]: (props) => (\n <FunctionInputEditor {...props} functions={functions} onQueryRefOptions={handleRefQueryLookup} />\n ),\n }),\n [workflows, scripts, functions, t],\n );\n\n return (\n <div role='none' className='bs-full is-full'>\n <Form\n schema={FunctionTriggerSchema}\n values={trigger}\n onSave={handleSave}\n onCancel={onCancel}\n Custom={Custom}\n onQueryRefOptions={handleRefQueryLookup}\n />\n </div>\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:echo:@:${fn.id}` }));\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type JsonPath, RefImpl, toEffectSchema } from '@dxos/echo-schema';\nimport { type FunctionType } from '@dxos/functions';\nimport { useOnTransition } from '@dxos/react-ui';\nimport { Form, type FormInputStateProps, type QueryRefOptions, useFormValues } from '@dxos/react-ui-form';\n\nexport type FunctionInputEditorProps = {\n functions: FunctionType[];\n onQueryRefOptions: QueryRefOptions;\n} & FormInputStateProps;\n\n/**\n * Editor component for function input parameters.\n */\nexport const FunctionInputEditor = ({\n functions,\n getValue,\n onValueChange,\n onQueryRefOptions,\n}: FunctionInputEditorProps) => {\n const selectedFunctionValue = useFormValues(['function' as JsonPath]);\n const selectedFunctionId = useMemo(() => {\n if (selectedFunctionValue instanceof RefImpl) {\n return selectedFunctionValue.dxn.toString().split('dxn:echo:@:').at(1);\n }\n }, [selectedFunctionValue]);\n\n const selectedFunction = useMemo(\n () => functions.find((f) => f.id === selectedFunctionId),\n [functions, selectedFunctionId],\n );\n\n useOnTransition(\n // Clear function parameter input when the function changes.\n selectedFunctionValue,\n (prevValue) => prevValue !== undefined && prevValue !== selectedFunctionValue,\n (currValue) => currValue !== undefined,\n () => onValueChange('object', {}),\n );\n\n const inputSchema = useMemo(() => selectedFunction?.inputSchema, [selectedFunction]);\n const effectSchema = useMemo(() => (inputSchema ? toEffectSchema(inputSchema) : undefined), [inputSchema]);\n const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;\n\n const values = useMemo(() => getValue() ?? {}, [getValue]);\n\n const handleValuesChanged = useCallback(\n (values: any) => {\n onValueChange('object', values);\n },\n [onValueChange],\n );\n\n if (selectedFunction === undefined || effectSchema === undefined || propertyCount === 0) {\n return null;\n }\n\n return (\n <>\n <h3 className='text-md'>Function parameters</h3>\n {/* TODO(ZaymonFC): Try using <FormFields /> internal component for this nesting.\n This would allow errors to flow up to the root context. */}\n <Form\n schema={effectSchema}\n values={values}\n classNames='p-0'\n onValuesChanged={handleValuesChanged}\n onQueryRefOptions={onQueryRefOptions}\n />\n </>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type FunctionTriggerType, TriggerKind, type TriggerType } from '@dxos/functions';\nimport { useTranslation } from '@dxos/react-ui';\nimport { SelectInput, type InputProps, useInputProps } from '@dxos/react-ui-form';\n\nimport { AUTOMATION_PLUGIN } from '../../meta';\n\nexport type SpecSelectorProps = InputProps;\n\nexport const SpecSelector = (props: SpecSelectorProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const specProps = useInputProps(['spec' satisfies keyof FunctionTriggerType]);\n\n const handleTypeChange = useCallback(\n (_type: any, value: string): TriggerType | undefined => {\n const getDefaultTriggerSpec = (kind: string) => {\n switch (kind) {\n case TriggerKind.Timer:\n return { type: TriggerKind.Timer, cron: '' };\n case TriggerKind.Subscription:\n return { type: TriggerKind.Subscription, filter: {} };\n case TriggerKind.Queue:\n return { type: TriggerKind.Queue, queue: '' };\n case TriggerKind.Email:\n return { type: TriggerKind.Email };\n case TriggerKind.Webhook:\n return { type: TriggerKind.Webhook };\n default:\n return undefined;\n }\n };\n\n const defaultSpec = getDefaultTriggerSpec(value);\n if (!defaultSpec) {\n return;\n }\n\n // Update the entire spec object, not just the `spec.type`.\n specProps.onValueChange('object', defaultSpec);\n },\n [specProps],\n );\n\n const options = useMemo(\n () =>\n Object.values(TriggerKind).map((kind) => ({\n value: kind,\n label: t(`trigger type ${kind}`),\n })),\n [t],\n );\n\n return <SelectInput {...props} options={options} onValueChange={handleTypeChange} />;\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAA4C;AAE5C,uBAA6B;AAC7B,kBAAoB;AACpB,uBAMO;AACP,IAAAA,eAAkD;AAClD,sBAA+B;AAC/B,2BAAiF;ACbjF,IAAAC,gBAA4C;AAE5C,yBAAuD;AAEvD,IAAAC,mBAAgC;AAChC,IAAAC,wBAAoF;ACLpF,IAAAF,gBAA4C;AAE5C,IAAAG,oBAAwE;AACxE,IAAAF,mBAA+B;AAC/B,IAAAC,wBAA4D;ADWrD,IAAME,sBAAsB,CAAC,E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A,QAAA,cAACG,qBAAAA,MAAAA;IACCC,QAAQ4D;IACRnE,QAAQuC;IACRC,QAAQS;IACRR;IACAW;IACA9E,mBAAmB4E;;AAI3B;AAEA,IAAMY,qBAAqB,CAACM,WAAAA;AAC1B,SAAOA,OAAOlC,IAAI,CAACmC,WAAW;IAAElC,OAAO,WAAWkC,MAAMlF,EAAE;IAAIgC,OAAO,cAAckD,MAAMlF,EAAE;EAAG,EAAA;AAChG;AAEA,IAAM6E,qBAAqB,CAACjB,SAAuB5E,cAAAA;AACjD,QAAMmG,WAAW,CAACC,OAAqBxB,QAAQ9D,KAAK,CAACuF,MAAMD,GAAGE,QAAQC,QAAQvF,OAAOqF,EAAErF,EAAE,GAAGwF,QAAQJ,GAAGI;AACvG,SAAOxG,UAAU+D,IAAI,CAACqC,QAAQ;IAAEpC,OAAOmC,SAASC,EAAAA;IAAKpD,OAAO,cAAcoD,GAAGpF,EAAE;EAAG,EAAA;AACpF;",
6
+ "names": ["import_echo", "import_react", "import_react_ui", "import_react_ui_form", "import_functions", "FunctionInputEditor", "functions", "getValue", "onValueChange", "onQueryRefOptions", "selectedFunctionValue", "useFormValues", "selectedFunctionId", "useMemo", "RefImpl", "dxn", "toString", "split", "at", "selectedFunction", "find", "f", "id", "useOnTransition", "prevValue", "undefined", "currValue", "inputSchema", "effectSchema", "toEffectSchema", "propertyCount", "properties", "Object", "keys", "length", "values", "handleValuesChanged", "useCallback", "React", "h3", "className", "Form", "schema", "classNames", "onValuesChanged", "SpecSelector", "props", "t", "useTranslation", "AUTOMATION_PLUGIN", "specProps", "useInputProps", "handleTypeChange", "_type", "value", "getDefaultTriggerSpec", "kind", "TriggerKind", "Timer", "type", "cron", "Subscription", "filter", "Queue", "queue", "Email", "Webhook", "defaultSpec", "options", "map", "label", "SelectInput", "TriggerEditor", "space", "trigger", "onSave", "onCancel", "useQuery", "Filter", "FunctionType", "workflows", "ComputeGraph", "scripts", "ScriptType", "handleSave", "handleRefQueryLookup", "useRefQueryLookupHandler", "Custom", "formValue", "Ref", "isRef", "handleOnValueChange", "dxnString", "DXN", "parse", "ref", "fromDXN", "getWorkflowOptions", "concat", "getFunctionOptions", "div", "role", "FunctionTriggerSchema", "graphs", "graph", "getLabel", "fn", "s", "source", "target", "name"]
7
+ }
@@ -26,19 +26,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_L5TWLPGA_exports = {};
30
- __export(chunk_L5TWLPGA_exports, {
29
+ var chunk_B3OL2E3B_exports = {};
30
+ __export(chunk_B3OL2E3B_exports, {
31
31
  AutomationContainer: () => AutomationContainer,
32
32
  AutomationPanel: () => AutomationPanel,
33
33
  FunctionsContainer: () => FunctionsContainer,
34
34
  FunctionsPanel: () => FunctionsPanel
35
35
  });
36
- module.exports = __toCommonJS(chunk_L5TWLPGA_exports);
36
+ module.exports = __toCommonJS(chunk_B3OL2E3B_exports);
37
37
  var import_react = require("react");
38
- var AutomationContainer = (0, import_react.lazy)(() => import("./AutomationContainer-E5I76FPP.cjs"));
39
- var AutomationPanel = (0, import_react.lazy)(() => import("./AutomationPanel-YLXAFJDP.cjs"));
40
- var FunctionsContainer = (0, import_react.lazy)(() => import("./FunctionsContainer-3HCURMEB.cjs"));
41
- var FunctionsPanel = (0, import_react.lazy)(() => import("./FunctionsPanel-SYIZHPGU.cjs"));
38
+ var AutomationContainer = (0, import_react.lazy)(() => import("./AutomationContainer-EXTHQ7B3.cjs"));
39
+ var AutomationPanel = (0, import_react.lazy)(() => import("./AutomationPanel-G7R6RL7O.cjs"));
40
+ var FunctionsContainer = (0, import_react.lazy)(() => import("./FunctionsContainer-RNZTNQEU.cjs"));
41
+ var FunctionsPanel = (0, import_react.lazy)(() => import("./FunctionsPanel-7I7YCHPJ.cjs"));
42
42
  // Annotate the CommonJS export names for ESM import in node:
43
43
  0 && (module.exports = {
44
44
  AutomationContainer,
@@ -46,4 +46,4 @@ var FunctionsPanel = (0, import_react.lazy)(() => import("./FunctionsPanel-SYIZH
46
46
  FunctionsContainer,
47
47
  FunctionsPanel
48
48
  });
49
- //# sourceMappingURL=chunk-L5TWLPGA.cjs.map
49
+ //# sourceMappingURL=chunk-B3OL2E3B.cjs.map
@@ -26,17 +26,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_SRXHHBDE_exports = {};
30
- __export(chunk_SRXHHBDE_exports, {
29
+ var chunk_F74YVA6P_exports = {};
30
+ __export(chunk_F74YVA6P_exports, {
31
31
  AutomationPanel: () => AutomationPanel,
32
32
  AutomationPanel_default: () => AutomationPanel_default
33
33
  });
34
- module.exports = __toCommonJS(chunk_SRXHHBDE_exports);
35
- var import_chunk_FTEDH5Q6 = require("./chunk-FTEDH5Q6.cjs");
34
+ module.exports = __toCommonJS(chunk_F74YVA6P_exports);
35
+ var import_chunk_A4DMUH7U = require("./chunk-A4DMUH7U.cjs");
36
36
  var import_chunk_7GXNXMSM = require("./chunk-7GXNXMSM.cjs");
37
+ var import_effect = require("effect");
37
38
  var import_react = __toESM(require("react"));
38
- var import_echo_schema = require("@dxos/echo-schema");
39
- var import_types = require("@dxos/functions/types");
39
+ var import_functions = require("@dxos/functions");
40
40
  var import_react_client = require("@dxos/react-client");
41
41
  var import_echo = require("@dxos/react-client/echo");
42
42
  var import_react_ui = require("@dxos/react-ui");
@@ -47,9 +47,9 @@ var grid = "grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]";
47
47
  var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
48
48
  const { t } = (0, import_react_ui.useTranslation)(import_chunk_7GXNXMSM.AUTOMATION_PLUGIN);
49
49
  const client = (0, import_react_client.useClient)();
50
- const triggers = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_types.FunctionTrigger));
51
- const functions = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_types.FunctionType));
52
- const scripts = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_types.ScriptType));
50
+ const triggers = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_functions.FunctionTrigger));
51
+ const functions = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_functions.FunctionType));
52
+ const scripts = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_functions.ScriptType));
53
53
  const [trigger, setTrigger] = (0, import_react.useState)(initialTrigger);
54
54
  const [selected, setSelected] = (0, import_react.useState)();
55
55
  const handleSelect = (trigger2) => {
@@ -58,7 +58,7 @@ var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
58
58
  setSelected(trigger2);
59
59
  };
60
60
  const handleAdd = () => {
61
- setTrigger((0, import_echo.live)(import_types.FunctionTriggerSchema, {}));
61
+ setTrigger((0, import_echo.live)(import_functions.FunctionTriggerSchema, {}));
62
62
  setSelected(void 0);
63
63
  };
64
64
  const handleDelete = (trigger2) => {
@@ -70,7 +70,7 @@ var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
70
70
  if (selected) {
71
71
  Object.assign(selected, trigger2);
72
72
  } else {
73
- space.db.add((0, import_echo.live)(import_types.FunctionTrigger, trigger2));
73
+ space.db.add((0, import_echo.live)(import_functions.FunctionTrigger, trigger2));
74
74
  }
75
75
  setTrigger(void 0);
76
76
  setSelected(void 0);
@@ -84,7 +84,7 @@ var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
84
84
  className: "flex flex-col w-full"
85
85
  }, trigger ? /* @__PURE__ */ import_react.default.createElement(import_react_ui_form.ControlItem, {
86
86
  title: t("trigger editor title")
87
- }, /* @__PURE__ */ import_react.default.createElement(import_chunk_FTEDH5Q6.TriggerEditor, {
87
+ }, /* @__PURE__ */ import_react.default.createElement(import_chunk_A4DMUH7U.TriggerEditor, {
88
88
  space,
89
89
  trigger,
90
90
  onSave: handleSave,
@@ -94,7 +94,7 @@ var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
94
94
  className: import_react_ui_form.controlItemClasses
95
95
  }, /* @__PURE__ */ import_react.default.createElement(import_react_ui_list.List.Root, {
96
96
  items: triggers,
97
- isItem: import_echo_schema.S.is(import_types.FunctionTrigger),
97
+ isItem: import_effect.Schema.is(import_functions.FunctionTrigger),
98
98
  getId: (field) => field.id
99
99
  }, ({ items: triggers2 }) => /* @__PURE__ */ import_react.default.createElement("div", {
100
100
  role: "list",
@@ -128,13 +128,13 @@ var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
128
128
  })));
129
129
  };
130
130
  var getCopyAction = (client, trigger) => {
131
- if (trigger?.spec?.type === import_types.TriggerKind.Email) {
131
+ if (trigger?.spec?.kind === import_functions.TriggerKind.Email) {
132
132
  return {
133
133
  translationKey: "trigger copy email",
134
134
  contentProvider: () => `${(0, import_echo.getSpace)(trigger).id}@dxos.network`
135
135
  };
136
136
  }
137
- if (trigger?.spec?.type === import_types.TriggerKind.Webhook) {
137
+ if (trigger?.spec?.kind === import_functions.TriggerKind.Webhook) {
138
138
  return {
139
139
  translationKey: "trigger copy url",
140
140
  contentProvider: () => getWebhookUrl(client, trigger)
@@ -150,8 +150,8 @@ var getWebhookUrl = (client, trigger) => {
150
150
  return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();
151
151
  };
152
152
  var getFunctionName = (scripts, functions, trigger) => {
153
- const shortId = trigger.function && `${trigger.function?.slice(0, 16)}\u2026`;
154
- const functionObject = functions.find((fn) => `dxn:worker:${fn.name}` === trigger.function);
153
+ const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}\u2026`;
154
+ const functionObject = functions.find((fn) => fn === trigger.function?.target);
155
155
  if (!functionObject) {
156
156
  return shortId;
157
157
  }
@@ -163,4 +163,4 @@ var AutomationPanel_default = AutomationPanel;
163
163
  AutomationPanel,
164
164
  AutomationPanel_default
165
165
  });
166
- //# sourceMappingURL=chunk-SRXHHBDE.cjs.map
166
+ //# sourceMappingURL=chunk-F74YVA6P.cjs.map
@@ -0,0 +1,7 @@
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 { Schema } from 'effect';\nimport React, { useState } from 'react';\n\nimport {\n FunctionType,\n FunctionTrigger,\n FunctionTriggerSchema,\n TriggerKind,\n type FunctionTriggerType,\n ScriptType,\n} from '@dxos/functions';\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={Schema.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?.kind === TriggerKind.Email) {\n return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };\n }\n\n if (trigger?.spec?.kind === 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.dxn.toString().slice(0, 16)}…`;\n const functionObject = functions.find((fn) => fn === trigger.function?.target);\n if (!functionObject) {\n return shortId;\n }\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,oBAAuB;AACvB,mBAAgC;AAEhC,uBAOO;AACP,0BAAuC;AACvC,kBAAwE;AACxE,sBAAwE;AACxE,2BAAgD;AAChD,2BAAqB;AACrB,4BAA+B;AAK/B,IAAMA,OAAO;AAUN,IAAMC,kBAAkB,CAAC,EAAEC,OAAOC,QAAQC,gBAAgBC,OAAM,MAAwB;AAC7F,QAAM,EAAEC,EAAC,QAAKC,gCAAeC,uCAAAA;AAC7B,QAAMC,aAASC,+BAAAA;AACf,QAAMC,eA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CAACpD,QAAgBW,YAAAA;AACrC,MAAIA,SAASkE,MAAMC,SAASC,6BAAYC,OAAO;AAC7C,WAAO;MAAEV,gBAAgB;MAAsBE,iBAAiB,MAAM,OAAGS,sBAAStE,OAAAA,EAAUM,EAAE;IAAgB;EAChH;AAEA,MAAIN,SAASkE,MAAMC,SAASC,6BAAYG,SAAS;AAC/C,WAAO;MAAEZ,gBAAgB;MAAoBE,iBAAiB,MAAMW,cAAcnF,QAAQW,OAAAA;IAAS;EACrG;AAEA,SAAOY;AACT;AAEA,IAAM4D,gBAAgB,CAACnF,QAAgBW,YAAAA;AACrC,QAAMyE,cAAUH,sBAAStE,OAAAA,EAAUM;AACnC,QAAMoE,UAAU,IAAIC,IAAItF,OAAOuF,OAAOpE,OAAOqE,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,IAAWzE,QAAQM,EAAE,IAAIoE,OAAAA,EAASU,SAAQ;AACvE;AAEA,IAAM7B,kBAAkB,CAACzD,SAAuBF,WAA2BI,YAAAA;AAGzE,QAAMqF,UAAUrF,QAAQsF,YAAY,GAAGtF,QAAQsF,SAASC,IAAIH,SAAQ,EAAGI,MAAM,GAAG,EAAA,CAAA;AAChF,QAAMC,iBAAiB7F,UAAU8F,KAAK,CAACC,OAAOA,OAAO3F,QAAQsF,UAAUM,MAAAA;AACvE,MAAI,CAACH,gBAAgB;AACnB,WAAOJ;EACT;AAEA,SAAOvF,QAAQ4F,KAAK,CAACG,MAAMJ,eAAeK,QAAQF,QAAQtF,OAAOuF,EAAEvF,EAAE,GAAGyF,QAAQV;AAClF;AC/JA,IAAA,0BAAexG;",
6
+ "names": ["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", "React", "div", "className", "ControlItem", "title", "TriggerEditor", "onSave", "onCancel", "role", "controlItemClasses", "List", "Root", "items", "isItem", "Schema", "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", "kind", "TriggerKind", "Email", "getSpace", "Webhook", "getWebhookUrl", "spaceId", "edgeUrl", "URL", "config", "runtime", "services", "edge", "url", "isSecure", "protocol", "startsWith", "toString", "shortId", "function", "dxn", "slice", "functionObject", "find", "fn", "target", "s", "source", "name"]
7
+ }
@@ -16,37 +16,37 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_PSIJDHAX_exports = {};
20
- __export(chunk_PSIJDHAX_exports, {
19
+ var chunk_GDCG2BML_exports = {};
20
+ __export(chunk_GDCG2BML_exports, {
21
21
  AutomationAction: () => AutomationAction
22
22
  });
23
- module.exports = __toCommonJS(chunk_PSIJDHAX_exports);
23
+ module.exports = __toCommonJS(chunk_GDCG2BML_exports);
24
24
  var import_chunk_7GXNXMSM = require("./chunk-7GXNXMSM.cjs");
25
- var import_echo_schema = require("@dxos/echo-schema");
25
+ var import_effect = require("effect");
26
26
  var import_echo = require("@dxos/react-client/echo");
27
- var TriggerTemplate = import_echo_schema.S.Union(import_echo_schema.S.Struct({
28
- type: import_echo_schema.S.Literal("timer"),
29
- cron: import_echo_schema.S.String
30
- }), import_echo_schema.S.Struct({
31
- type: import_echo_schema.S.Literal("queue"),
32
- queueDXN: import_echo_schema.S.Any
27
+ var TriggerTemplate = import_effect.Schema.Union(import_effect.Schema.Struct({
28
+ type: import_effect.Schema.Literal("timer"),
29
+ cron: import_effect.Schema.String
30
+ }), import_effect.Schema.Struct({
31
+ type: import_effect.Schema.Literal("queue"),
32
+ queueDXN: import_effect.Schema.Any
33
33
  }));
34
34
  var AutomationAction;
35
35
  (function(AutomationAction2) {
36
36
  const AUTOMATION_ACTION = `${import_chunk_7GXNXMSM.AUTOMATION_PLUGIN}/action`;
37
- class CreateTriggerFromTemplate extends import_echo_schema.S.TaggedClass()(`${AUTOMATION_ACTION}/create-trigger-from-template`, {
38
- input: import_echo_schema.S.Struct({
37
+ class CreateTriggerFromTemplate extends import_effect.Schema.TaggedClass()(`${AUTOMATION_ACTION}/create-trigger-from-template`, {
38
+ input: import_effect.Schema.Struct({
39
39
  space: import_echo.SpaceSchema,
40
40
  template: TriggerTemplate,
41
- enabled: import_echo_schema.S.optional(import_echo_schema.S.Boolean),
41
+ enabled: import_effect.Schema.optional(import_effect.Schema.Boolean),
42
42
  // TODO(wittjosiah): Improve how this lookup is done.
43
- scriptName: import_echo_schema.S.optional(import_echo_schema.S.String),
44
- payload: import_echo_schema.S.optional(import_echo_schema.S.Record({
45
- key: import_echo_schema.S.String,
46
- value: import_echo_schema.S.Any
43
+ scriptName: import_effect.Schema.optional(import_effect.Schema.String),
44
+ input: import_effect.Schema.optional(import_effect.Schema.Record({
45
+ key: import_effect.Schema.String,
46
+ value: import_effect.Schema.Any
47
47
  }))
48
48
  }),
49
- output: import_echo_schema.S.Void
49
+ output: import_effect.Schema.Void
50
50
  }) {
51
51
  }
52
52
  AutomationAction2.CreateTriggerFromTemplate = CreateTriggerFromTemplate;
@@ -55,4 +55,4 @@ var AutomationAction;
55
55
  0 && (module.exports = {
56
56
  AutomationAction
57
57
  });
58
- //# sourceMappingURL=chunk-PSIJDHAX.cjs.map
58
+ //# sourceMappingURL=chunk-GDCG2BML.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Schema } from 'effect';\n\nimport { SpaceSchema } from '@dxos/react-client/echo';\n\nimport { AUTOMATION_PLUGIN } from './meta';\n\nconst TriggerTemplate = Schema.Union(\n Schema.Struct({ type: Schema.Literal('timer'), cron: Schema.String }),\n Schema.Struct({ type: Schema.Literal('queue'), queueDXN: Schema.Any }),\n);\n\nexport namespace AutomationAction {\n const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;\n\n export class CreateTriggerFromTemplate extends Schema.TaggedClass<CreateTriggerFromTemplate>()(\n `${AUTOMATION_ACTION}/create-trigger-from-template`,\n {\n input: Schema.Struct({\n space: SpaceSchema,\n template: TriggerTemplate,\n enabled: Schema.optional(Schema.Boolean),\n // TODO(wittjosiah): Improve how this lookup is done.\n scriptName: Schema.optional(Schema.String),\n input: Schema.optional(Schema.Record({ key: Schema.String, value: Schema.Any })),\n }),\n output: Schema.Void,\n },\n ) {}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAIA,oBAAuB;AAEvB,kBAA4B;AAI5B,IAAMA,kBAAkBC,qBAAOC,MAC7BD,qBAAOE,OAAO;EAAEC,MAAMH,qBAAOI,QAAQ,OAAA;EAAUC,MAAML,qBAAOM;AAAO,CAAA,GACnEN,qBAAOE,OAAO;EAAEC,MAAMH,qBAAOI,QAAQ,OAAA;EAAUG,UAAUP,qBAAOQ;AAAI,CAAA,CAAA;;UAGrDC,mBAAAA;AACf,QAAMC,oBAAoB,GAAGC,uCAAAA;EAEtB,MAAMC,kCAAkCZ,qBAAOa,YAAW,EAC/D,GAAGH,iBAAAA,iCACH;IACEI,OAAOd,qBAAOE,OAAO;MACnBa,OAAOC;MACPC,UAAUlB;MACVmB,SAASlB,qBAAOmB,SAASnB,qBAAOoB,OAAO;;MAEvCC,YAAYrB,qBAAOmB,SAASnB,qBAAOM,MAAM;MACzCQ,OAAOd,qBAAOmB,SAASnB,qBAAOsB,OAAO;QAAEC,KAAKvB,qBAAOM;QAAQkB,OAAOxB,qBAAOQ;MAAI,CAAA,CAAA;IAC/E,CAAA;IACAiB,QAAQzB,qBAAO0B;EACjB,CAAA,EAAA;EACC;oBAbUd,4BAAAA;AAcf,GAjBiBH,qBAAAA,mBAAAA,CAAAA,EAAAA;",
6
+ "names": ["TriggerTemplate", "Schema", "Union", "Struct", "type", "Literal", "cron", "String", "queueDXN", "Any", "AutomationAction", "AUTOMATION_ACTION", "AUTOMATION_PLUGIN", "CreateTriggerFromTemplate", "TaggedClass", "input", "space", "SpaceSchema", "template", "enabled", "optional", "Boolean", "scriptName", "Record", "key", "value", "output", "Void"]
7
+ }
@@ -26,17 +26,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_BSK5SHTR_exports = {};
30
- __export(chunk_BSK5SHTR_exports, {
29
+ var chunk_GLXGAIZC_exports = {};
30
+ __export(chunk_GLXGAIZC_exports, {
31
31
  FunctionsPanel: () => FunctionsPanel,
32
32
  FunctionsPanel_default: () => FunctionsPanel_default
33
33
  });
34
- module.exports = __toCommonJS(chunk_BSK5SHTR_exports);
34
+ module.exports = __toCommonJS(chunk_GLXGAIZC_exports);
35
35
  var import_chunk_7GXNXMSM = require("./chunk-7GXNXMSM.cjs");
36
+ var import_effect = require("effect");
36
37
  var import_react = __toESM(require("react"));
37
38
  var import_app_framework = require("@dxos/app-framework");
38
- var import_echo_schema = require("@dxos/echo-schema");
39
- var import_types = require("@dxos/functions/types");
39
+ var import_functions = require("@dxos/functions");
40
40
  var import_echo = require("@dxos/react-client/echo");
41
41
  var import_react_ui = require("@dxos/react-ui");
42
42
  var import_react_ui_form = require("@dxos/react-ui-form");
@@ -45,8 +45,8 @@ var import_react_ui_theme = require("@dxos/react-ui-theme");
45
45
  var grid = "grid grid-cols-[1fr_auto] min-bs-[2.5rem]";
46
46
  var FunctionsPanel = ({ space }) => {
47
47
  const { t } = (0, import_react_ui.useTranslation)(import_chunk_7GXNXMSM.AUTOMATION_PLUGIN);
48
- const functions = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_types.FunctionType));
49
- const scripts = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_types.ScriptType));
48
+ const functions = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_functions.FunctionType));
49
+ const scripts = (0, import_echo.useQuery)(space, import_echo.Filter.schema(import_functions.ScriptType));
50
50
  const { dispatchPromise: dispatch } = (0, import_app_framework.useIntentDispatcher)();
51
51
  const functionToScriptMap = (0, import_react.useMemo)(() => functions.reduce((map, func) => {
52
52
  const scriptId = func.source?.target?.id;
@@ -86,7 +86,7 @@ var FunctionsPanel = ({ space }) => {
86
86
  className: (0, import_react_ui_theme.mx)(import_react_ui_form.controlItemClasses)
87
87
  }, /* @__PURE__ */ import_react.default.createElement(import_react_ui_list.List.Root, {
88
88
  items: functions,
89
- isItem: import_echo_schema.S.is(import_types.FunctionType),
89
+ isItem: import_effect.Schema.is(import_functions.FunctionType),
90
90
  getId: (func) => func.id
91
91
  }, ({ items }) => /* @__PURE__ */ import_react.default.createElement("div", {
92
92
  role: "list",
@@ -113,4 +113,4 @@ var FunctionsPanel_default = FunctionsPanel;
113
113
  FunctionsPanel,
114
114
  FunctionsPanel_default
115
115
  });
116
- //# sourceMappingURL=chunk-BSK5SHTR.cjs.map
116
+ //# sourceMappingURL=chunk-GLXGAIZC.cjs.map
@@ -0,0 +1,7 @@
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 { Schema } from 'effect';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { createIntent, LayoutAction, useIntentDispatcher } from '@dxos/app-framework';\nimport { FunctionType, ScriptType } from '@dxos/functions';\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={Schema.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,oBAAuB;AACvB,mBAA4C;AAE5C,2BAAgE;AAChE,uBAAyC;AACzC,kBAA+D;AAC/D,sBAAuC;AACvC,2BAAmC;AACnC,2BAAqB;AACrB,4BAA+B;AAI/B,IAAMA,OAAO;AAMN,IAAMC,iBAAiB,CAAC,EAAEC,MAAK,MAAuB;AAC3D,QAAM,EAAEC,EAAC,QAAKC,gCAAeC,uCAAAA;AAC7B,QAAMC,gBAAYC,sBAASL,OAAOM,mBAAOC,OAAOC,6BAAAA,CAAAA;AAChD,QAAMC,cAAUJ,sBAASL,OAAOM,mBAAOC,OAAOG,2BAAAA,CAAAA;AAC9C,QAAM,EAAEC,iBAAiBC,SAAQ,QAAKC,0CAAAA;AAEtC,QAAMC,0BAAsBC,sBAC1B,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;G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,CAAA,CAAA,CAAA,CAAA,GAQ7DG,UAAUqD,WAAW,KAAK,6BAAArB,QAAA,cAACC,OAAAA;IAAIE,WAAU;KAAmCtC,EAAE,oBAAA,CAAA,CAAA;AAGrF;ACvFA,IAAA,yBAAeF;",
6
+ "names": ["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", "React", "div", "role", "className", "mx", "controlItemClasses", "List", "Root", "items", "isItem", "Schema", "is", "getId", "Item", "key", "item", "classNames", "ghostHover", "ItemTitle", "Button", "onClick", "length"]
7
+ }