@dxos/plugin-automation 0.8.1 → 0.8.2-main.2f9c567
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/AutomationContainer-3MP23OGQ.mjs +34 -0
- package/dist/lib/browser/AutomationContainer-3MP23OGQ.mjs.map +7 -0
- package/dist/lib/browser/AutomationPanel-75HVBBNG.mjs +11 -0
- package/dist/lib/browser/AutomationPanel-75HVBBNG.mjs.map +7 -0
- package/dist/lib/browser/FunctionsContainer-HLISW5QI.mjs +33 -0
- package/dist/lib/browser/FunctionsContainer-HLISW5QI.mjs.map +7 -0
- package/dist/lib/browser/FunctionsPanel-OKFRBXLO.mjs +10 -0
- package/dist/lib/browser/FunctionsPanel-OKFRBXLO.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-K3BIQFWW.mjs → app-graph-builder-ND64CHOM.mjs} +42 -1
- package/dist/lib/browser/app-graph-builder-ND64CHOM.mjs.map +7 -0
- package/dist/lib/browser/chunk-ADYCSC6Y.mjs +39 -0
- package/dist/lib/browser/chunk-ADYCSC6Y.mjs.map +7 -0
- package/dist/lib/browser/{AutomationPanel-YAHFXQX6.mjs → chunk-HTVXRMNH.mjs} +19 -18
- package/dist/lib/browser/chunk-HTVXRMNH.mjs.map +7 -0
- package/dist/lib/browser/chunk-IDCVJ2JW.mjs +88 -0
- package/dist/lib/browser/chunk-IDCVJ2JW.mjs.map +7 -0
- package/dist/lib/browser/chunk-N4PTKEWO.mjs +14 -0
- package/dist/lib/browser/chunk-N4PTKEWO.mjs.map +7 -0
- package/dist/lib/browser/chunk-Q2ACSERA.mjs +211 -0
- package/dist/lib/browser/chunk-Q2ACSERA.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +25 -19
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-YH4YPX52.mjs +77 -0
- package/dist/lib/browser/intent-resolver-YH4YPX52.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-GA67CQBV.mjs +68 -0
- package/dist/lib/browser/react-surface-GA67CQBV.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +8 -0
- package/dist/lib/browser/types.mjs.map +7 -0
- package/dist/lib/node/AutomationContainer-RIDHNHPT.cjs +62 -0
- package/dist/lib/node/AutomationContainer-RIDHNHPT.cjs.map +7 -0
- package/dist/lib/node/AutomationPanel-6RLBWAGL.cjs +32 -0
- package/dist/lib/node/AutomationPanel-6RLBWAGL.cjs.map +7 -0
- package/dist/lib/node/FunctionsContainer-RNZTNQEU.cjs +61 -0
- package/dist/lib/node/FunctionsContainer-RNZTNQEU.cjs.map +7 -0
- package/dist/lib/node/FunctionsPanel-7I7YCHPJ.cjs +31 -0
- package/dist/lib/node/FunctionsPanel-7I7YCHPJ.cjs.map +7 -0
- package/dist/lib/node/{app-graph-builder-HO4FPGZ5.cjs → app-graph-builder-TVFR6RXO.cjs} +45 -4
- package/dist/lib/node/app-graph-builder-TVFR6RXO.cjs.map +7 -0
- package/dist/lib/node/{AutomationPanel-ZKAMIU6O.cjs → chunk-52JFIUOD.cjs} +31 -26
- package/dist/lib/node/chunk-52JFIUOD.cjs.map +7 -0
- package/dist/lib/node/chunk-ESVJ2X6U.cjs +234 -0
- package/dist/lib/node/chunk-ESVJ2X6U.cjs.map +7 -0
- package/dist/lib/node/chunk-GDCG2BML.cjs +58 -0
- package/dist/lib/node/chunk-GDCG2BML.cjs.map +7 -0
- package/dist/lib/node/chunk-GLXGAIZC.cjs +116 -0
- package/dist/lib/node/chunk-GLXGAIZC.cjs.map +7 -0
- package/dist/lib/node/{chunk-AGJ6XTDN.cjs → chunk-HZTVNN4S.cjs} +16 -7
- package/dist/lib/node/chunk-HZTVNN4S.cjs.map +7 -0
- package/dist/lib/node/index.cjs +28 -22
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/intent-resolver-6FJ6PJJI.cjs +93 -0
- package/dist/lib/node/intent-resolver-6FJ6PJJI.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-52M54VWV.cjs → react-surface-UJDYSHZ5.cjs} +39 -15
- package/dist/lib/node/react-surface-UJDYSHZ5.cjs.map +7 -0
- package/dist/lib/node/types.cjs +30 -0
- package/dist/lib/node/types.cjs.map +7 -0
- package/dist/lib/node-esm/AutomationContainer-MCUWF267.mjs +35 -0
- package/dist/lib/node-esm/AutomationContainer-MCUWF267.mjs.map +7 -0
- package/dist/lib/node-esm/AutomationPanel-U34H2Q7Z.mjs +12 -0
- package/dist/lib/node-esm/AutomationPanel-U34H2Q7Z.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsContainer-435FW56J.mjs +34 -0
- package/dist/lib/node-esm/FunctionsContainer-435FW56J.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsPanel-NXXT5ERU.mjs +11 -0
- package/dist/lib/node-esm/FunctionsPanel-NXXT5ERU.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-XCJR33VS.mjs → app-graph-builder-NYLOXWVV.mjs} +42 -1
- package/dist/lib/node-esm/app-graph-builder-NYLOXWVV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5JC4JVYZ.mjs +212 -0
- package/dist/lib/node-esm/chunk-5JC4JVYZ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-EEA6CZ6B.mjs +40 -0
- package/dist/lib/node-esm/chunk-EEA6CZ6B.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-RG3M42SO.mjs +16 -0
- package/dist/lib/node-esm/chunk-RG3M42SO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VYSTWH6Q.mjs +89 -0
- package/dist/lib/node-esm/chunk-VYSTWH6Q.mjs.map +7 -0
- package/dist/lib/node-esm/{AutomationPanel-XF7YPSKM.mjs → chunk-WYXWQFPK.mjs} +19 -18
- package/dist/lib/node-esm/chunk-WYXWQFPK.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +25 -19
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-PVY22PBL.mjs +78 -0
- package/dist/lib/node-esm/intent-resolver-PVY22PBL.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-R72A4EHM.mjs +69 -0
- package/dist/lib/node-esm/react-surface-R72A4EHM.mjs.map +7 -0
- package/dist/lib/node-esm/types.mjs +9 -0
- package/dist/lib/node-esm/types.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AutomationContainer.d.ts +7 -0
- package/dist/types/src/components/AutomationContainer.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +6 -3
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/index.d.ts +1 -0
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsContainer.d.ts +7 -0
- package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -0
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts +7 -0
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -0
- package/dist/types/src/components/FunctionsPanel/index.d.ts +4 -0
- package/dist/types/src/components/FunctionsPanel/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/FunctionPayloadEditor.d.ts +12 -0
- package/dist/types/src/components/TriggerEditor/FunctionPayloadEditor.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts +5 -0
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +8 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +8 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +25 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/package.json +33 -24
- package/src/AutomationPlugin.tsx +5 -10
- package/src/capabilities/app-graph-builder.ts +31 -0
- package/src/capabilities/index.ts +1 -0
- package/src/capabilities/intent-resolver.ts +73 -0
- package/src/capabilities/react-surface.tsx +32 -8
- package/src/components/AutomationContainer.tsx +31 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +5 -5
- package/src/components/AutomationPanel/AutomationPanel.tsx +67 -67
- package/src/components/AutomationPanel/index.ts +2 -0
- package/src/components/FunctionsContainer.tsx +31 -0
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +95 -0
- package/src/components/FunctionsPanel/index.ts +8 -0
- package/src/components/TriggerEditor/FunctionPayloadEditor.tsx +77 -0
- package/src/components/TriggerEditor/SpecSelector.tsx +59 -0
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +18 -9
- package/src/components/TriggerEditor/TriggerEditor.tsx +49 -89
- package/src/components/index.ts +3 -0
- package/src/testing/test-functions.ts +23 -9
- package/src/translations.ts +10 -1
- package/src/types.ts +33 -0
- package/dist/lib/browser/AutomationPanel-YAHFXQX6.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-K3BIQFWW.mjs.map +0 -7
- package/dist/lib/browser/chunk-FALBBJNO.mjs +0 -138
- package/dist/lib/browser/chunk-FALBBJNO.mjs.map +0 -7
- package/dist/lib/browser/chunk-MT3FZH4V.mjs +0 -8
- package/dist/lib/browser/chunk-MT3FZH4V.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4QQSJR4A.mjs +0 -42
- package/dist/lib/browser/react-surface-4QQSJR4A.mjs.map +0 -7
- package/dist/lib/node/AutomationPanel-ZKAMIU6O.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-HO4FPGZ5.cjs.map +0 -7
- package/dist/lib/node/chunk-AGJ6XTDN.cjs.map +0 -7
- package/dist/lib/node/chunk-FTEDH5Q6.cjs +0 -167
- package/dist/lib/node/chunk-FTEDH5Q6.cjs.map +0 -7
- package/dist/lib/node/react-surface-52M54VWV.cjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-XF7YPSKM.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-XCJR33VS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-M4QXMIIB.mjs +0 -139
- package/dist/lib/node-esm/chunk-M4QXMIIB.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OA75PSGH.mjs +0 -10
- package/dist/lib/node-esm/chunk-OA75PSGH.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-MGKM3OO3.mjs +0 -43
- package/dist/lib/node-esm/react-surface-MGKM3OO3.mjs.map +0 -7
|
@@ -10,7 +10,48 @@ import { ScriptType } from "@dxos/functions";
|
|
|
10
10
|
import { PLANK_COMPANION_TYPE, ATTENDABLE_PATH_SEPARATOR } from "@dxos/plugin-deck/types";
|
|
11
11
|
import { createExtension } from "@dxos/plugin-graph";
|
|
12
12
|
import { SCRIPT_PLUGIN } from "@dxos/plugin-script/types";
|
|
13
|
+
import { SPACE_PLUGIN } from "@dxos/plugin-space";
|
|
13
14
|
var app_graph_builder_default = (context) => contributes(Capabilities.AppGraphBuilder, [
|
|
15
|
+
createExtension({
|
|
16
|
+
id: `${meta.id}/space-settings-automation`,
|
|
17
|
+
filter: (node) => node.type === `${SPACE_PLUGIN}/settings`,
|
|
18
|
+
connector: ({ node }) => [
|
|
19
|
+
{
|
|
20
|
+
id: `automation-${node.id}`,
|
|
21
|
+
type: `${meta.id}/space-settings-automation`,
|
|
22
|
+
data: `${meta.id}/space-settings-automation`,
|
|
23
|
+
properties: {
|
|
24
|
+
label: [
|
|
25
|
+
"automation panel label",
|
|
26
|
+
{
|
|
27
|
+
ns: meta.id
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
icon: "ph--lightning--regular"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}),
|
|
35
|
+
createExtension({
|
|
36
|
+
id: `${meta.id}/space-settings-functions`,
|
|
37
|
+
filter: (node) => node.type === `${SPACE_PLUGIN}/settings`,
|
|
38
|
+
connector: ({ node }) => [
|
|
39
|
+
{
|
|
40
|
+
id: `functions-${node.id}`,
|
|
41
|
+
type: `${meta.id}/space-settings-functions`,
|
|
42
|
+
data: `${meta.id}/space-settings-functions`,
|
|
43
|
+
properties: {
|
|
44
|
+
label: [
|
|
45
|
+
"functions panel label",
|
|
46
|
+
{
|
|
47
|
+
ns: meta.id
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
icon: "ph--function--regular"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
14
55
|
createExtension({
|
|
15
56
|
id: `${SCRIPT_PLUGIN}/script-companion`,
|
|
16
57
|
filter: (node) => isInstanceOf(ScriptType, node.data),
|
|
@@ -38,4 +79,4 @@ var app_graph_builder_default = (context) => contributes(Capabilities.AppGraphBu
|
|
|
38
79
|
export {
|
|
39
80
|
app_graph_builder_default as default
|
|
40
81
|
};
|
|
41
|
-
//# sourceMappingURL=app-graph-builder-
|
|
82
|
+
//# sourceMappingURL=app-graph-builder-NYLOXWVV.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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,SA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Type", "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
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
AUTOMATION_PLUGIN
|
|
4
|
+
} from "./chunk-DZ44LGYT.mjs";
|
|
5
|
+
|
|
6
|
+
// packages/plugins/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx
|
|
7
|
+
import React3, { useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
8
|
+
import { ComputeGraph } from "@dxos/conductor";
|
|
9
|
+
import { DXN } from "@dxos/echo";
|
|
10
|
+
import { FunctionType, FunctionTriggerSchema, ScriptType } from "@dxos/functions";
|
|
11
|
+
import { Filter, Ref, useQuery } from "@dxos/react-client/echo";
|
|
12
|
+
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
13
|
+
import { Form as Form2, SelectInput as SelectInput2, useRefQueryLookupHandler } from "@dxos/react-ui-form";
|
|
14
|
+
|
|
15
|
+
// packages/plugins/plugin-automation/src/components/TriggerEditor/FunctionPayloadEditor.tsx
|
|
16
|
+
import React, { useCallback, useMemo } from "react";
|
|
17
|
+
import { RefImpl, toEffectSchema } from "@dxos/echo-schema";
|
|
18
|
+
import { useOnTransition } from "@dxos/react-ui";
|
|
19
|
+
import { Form, useFormValues } from "@dxos/react-ui-form";
|
|
20
|
+
var FunctionPayloadEditor = ({ functions, getValue, onValueChange, onQueryRefOptions }) => {
|
|
21
|
+
const selectedFunctionValue = useFormValues([
|
|
22
|
+
"function"
|
|
23
|
+
]);
|
|
24
|
+
const selectedFunctionName = useMemo(() => {
|
|
25
|
+
if (selectedFunctionValue instanceof RefImpl) {
|
|
26
|
+
return selectedFunctionValue.dxn.toString().split("dxn:worker:").at(1);
|
|
27
|
+
}
|
|
28
|
+
}, [
|
|
29
|
+
selectedFunctionValue
|
|
30
|
+
]);
|
|
31
|
+
const selectedFunction = useMemo(() => functions.find((f) => f.name === selectedFunctionName), [
|
|
32
|
+
functions,
|
|
33
|
+
selectedFunctionName
|
|
34
|
+
]);
|
|
35
|
+
useOnTransition(
|
|
36
|
+
// Clear function parameter meta when the function changes.
|
|
37
|
+
selectedFunctionValue,
|
|
38
|
+
(prevValue) => prevValue !== void 0 && prevValue !== selectedFunctionValue,
|
|
39
|
+
(currValue) => currValue !== void 0,
|
|
40
|
+
() => onValueChange("object", {})
|
|
41
|
+
);
|
|
42
|
+
const inputSchema = useMemo(() => selectedFunction?.inputSchema, [
|
|
43
|
+
selectedFunction
|
|
44
|
+
]);
|
|
45
|
+
const effectSchema = useMemo(() => inputSchema ? toEffectSchema(inputSchema) : void 0, [
|
|
46
|
+
inputSchema
|
|
47
|
+
]);
|
|
48
|
+
const propertyCount = inputSchema?.properties ? Object.keys(inputSchema.properties).length : 0;
|
|
49
|
+
const values = useMemo(() => getValue() ?? {}, [
|
|
50
|
+
getValue
|
|
51
|
+
]);
|
|
52
|
+
const handleValuesChanged = useCallback((values2) => {
|
|
53
|
+
onValueChange("object", values2);
|
|
54
|
+
}, [
|
|
55
|
+
onValueChange
|
|
56
|
+
]);
|
|
57
|
+
if (selectedFunction === void 0 || effectSchema === void 0 || propertyCount === 0) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h3", {
|
|
61
|
+
className: "text-md"
|
|
62
|
+
}, "Function parameters"), /* @__PURE__ */ React.createElement(Form, {
|
|
63
|
+
schema: effectSchema,
|
|
64
|
+
values,
|
|
65
|
+
classNames: "p-0",
|
|
66
|
+
onValuesChanged: handleValuesChanged,
|
|
67
|
+
onQueryRefOptions
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// packages/plugins/plugin-automation/src/components/TriggerEditor/SpecSelector.tsx
|
|
72
|
+
import React2, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
73
|
+
import { TriggerKind } from "@dxos/functions";
|
|
74
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
75
|
+
import { SelectInput, useInputProps } from "@dxos/react-ui-form";
|
|
76
|
+
var SpecSelector = (props) => {
|
|
77
|
+
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
78
|
+
const specProps = useInputProps([
|
|
79
|
+
"spec"
|
|
80
|
+
]);
|
|
81
|
+
const handleTypeChange = useCallback2((_type, value) => {
|
|
82
|
+
const getDefaultTriggerSpec = (kind) => {
|
|
83
|
+
switch (kind) {
|
|
84
|
+
case TriggerKind.Timer:
|
|
85
|
+
return {
|
|
86
|
+
type: TriggerKind.Timer,
|
|
87
|
+
cron: ""
|
|
88
|
+
};
|
|
89
|
+
case TriggerKind.Subscription:
|
|
90
|
+
return {
|
|
91
|
+
type: TriggerKind.Subscription,
|
|
92
|
+
filter: {}
|
|
93
|
+
};
|
|
94
|
+
case TriggerKind.Queue:
|
|
95
|
+
return {
|
|
96
|
+
type: TriggerKind.Queue,
|
|
97
|
+
queue: ""
|
|
98
|
+
};
|
|
99
|
+
case TriggerKind.Email:
|
|
100
|
+
return {
|
|
101
|
+
type: TriggerKind.Email
|
|
102
|
+
};
|
|
103
|
+
case TriggerKind.Webhook:
|
|
104
|
+
return {
|
|
105
|
+
type: TriggerKind.Webhook
|
|
106
|
+
};
|
|
107
|
+
default:
|
|
108
|
+
return void 0;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const defaultSpec = getDefaultTriggerSpec(value);
|
|
112
|
+
if (!defaultSpec) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
specProps.onValueChange("object", defaultSpec);
|
|
116
|
+
}, [
|
|
117
|
+
specProps
|
|
118
|
+
]);
|
|
119
|
+
const options = useMemo2(() => Object.values(TriggerKind).map((kind) => ({
|
|
120
|
+
value: kind,
|
|
121
|
+
label: t(`trigger type ${kind}`)
|
|
122
|
+
})), [
|
|
123
|
+
t
|
|
124
|
+
]);
|
|
125
|
+
return /* @__PURE__ */ React2.createElement(SelectInput, {
|
|
126
|
+
...props,
|
|
127
|
+
options,
|
|
128
|
+
onValueChange: handleTypeChange
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// packages/plugins/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx
|
|
133
|
+
var TriggerEditor = ({ space, trigger, onSave, onCancel }) => {
|
|
134
|
+
const { t } = useTranslation2(AUTOMATION_PLUGIN);
|
|
135
|
+
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
136
|
+
const workflows = useQuery(space, Filter.schema(ComputeGraph));
|
|
137
|
+
const scripts = useQuery(space, Filter.schema(ScriptType));
|
|
138
|
+
const handleSave = (values) => {
|
|
139
|
+
onSave?.(values);
|
|
140
|
+
};
|
|
141
|
+
const handleRefQueryLookup = useRefQueryLookupHandler({
|
|
142
|
+
space
|
|
143
|
+
});
|
|
144
|
+
const Custom = useMemo3(() => ({
|
|
145
|
+
["function"]: (props) => {
|
|
146
|
+
const getValue = useCallback3(() => {
|
|
147
|
+
const formValue = props.getValue();
|
|
148
|
+
if (formValue instanceof DXN) {
|
|
149
|
+
return formValue.toString();
|
|
150
|
+
}
|
|
151
|
+
return void 0;
|
|
152
|
+
}, [
|
|
153
|
+
props
|
|
154
|
+
]);
|
|
155
|
+
const handleOnValueChange = useCallback3((_type, dxnString) => {
|
|
156
|
+
const dxn = DXN.parse(dxnString);
|
|
157
|
+
if (dxn) {
|
|
158
|
+
const ref = Ref.fromDXN(dxn);
|
|
159
|
+
props.onValueChange("object", ref);
|
|
160
|
+
}
|
|
161
|
+
}, [
|
|
162
|
+
props.onValueChange
|
|
163
|
+
]);
|
|
164
|
+
return /* @__PURE__ */ React3.createElement(SelectInput2, {
|
|
165
|
+
...props,
|
|
166
|
+
getValue,
|
|
167
|
+
onValueChange: handleOnValueChange,
|
|
168
|
+
options: getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
["spec.type"]: SpecSelector,
|
|
172
|
+
["payload"]: (props) => /* @__PURE__ */ React3.createElement(FunctionPayloadEditor, {
|
|
173
|
+
...props,
|
|
174
|
+
functions,
|
|
175
|
+
onQueryRefOptions: handleRefQueryLookup
|
|
176
|
+
})
|
|
177
|
+
}), [
|
|
178
|
+
workflows,
|
|
179
|
+
scripts,
|
|
180
|
+
functions,
|
|
181
|
+
t
|
|
182
|
+
]);
|
|
183
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
184
|
+
role: "none",
|
|
185
|
+
className: "bs-full is-full"
|
|
186
|
+
}, /* @__PURE__ */ React3.createElement(Form2, {
|
|
187
|
+
schema: FunctionTriggerSchema,
|
|
188
|
+
values: trigger,
|
|
189
|
+
onSave: handleSave,
|
|
190
|
+
onCancel,
|
|
191
|
+
Custom,
|
|
192
|
+
onQueryRefOptions: handleRefQueryLookup
|
|
193
|
+
}));
|
|
194
|
+
};
|
|
195
|
+
var getWorkflowOptions = (graphs) => {
|
|
196
|
+
return graphs.map((graph) => ({
|
|
197
|
+
label: `compute-${graph.id}`,
|
|
198
|
+
value: `dxn:echo:@:${graph.id}`
|
|
199
|
+
}));
|
|
200
|
+
};
|
|
201
|
+
var getFunctionOptions = (scripts, functions) => {
|
|
202
|
+
const getLabel = (fn) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
|
|
203
|
+
return functions.map((fn) => ({
|
|
204
|
+
label: getLabel(fn),
|
|
205
|
+
value: `dxn:worker:${fn.name}`
|
|
206
|
+
}));
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export {
|
|
210
|
+
TriggerEditor
|
|
211
|
+
};
|
|
212
|
+
//# sourceMappingURL=chunk-5JC4JVYZ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/TriggerEditor/TriggerEditor.tsx", "../../../src/components/TriggerEditor/FunctionPayloadEditor.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 { FunctionPayloadEditor } from './FunctionPayloadEditor';\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 (formValue instanceof DXN) {\n return formValue.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.type' as const]: SpecSelector,\n ['payload' as const]: (props) => (\n <FunctionPayloadEditor {...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:worker:${fn.name}` }));\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 FunctionMetaEditorProps = {\n functions: FunctionType[];\n onQueryRefOptions: QueryRefOptions;\n} & FormInputStateProps;\n\n/**\n * Editor component for function meta parameters.\n */\nexport const FunctionPayloadEditor = ({\n functions,\n getValue,\n onValueChange,\n onQueryRefOptions,\n}: FunctionMetaEditorProps) => {\n const selectedFunctionValue = useFormValues(['function' as JsonPath]);\n const selectedFunctionName = useMemo(() => {\n if (selectedFunctionValue instanceof RefImpl) {\n return selectedFunctionValue.dxn.toString().split('dxn:worker:').at(1);\n }\n }, [selectedFunctionValue]);\n\n const selectedFunction = useMemo(\n () => functions.find((f) => f.name === selectedFunctionName),\n [functions, selectedFunctionName],\n );\n\n useOnTransition(\n // Clear function parameter meta 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,OAAOA,UAASC,eAAAA,cAAaC,WAAAA,gBAAe;AAE5C,SAASC,oBAAoB;AAC7B,SAASC,WAAW;AACpB,SACEC,cACAC,uBAGAC,kBACK;AACP,SAASC,QAAQC,KAAKC,gBAA4B;AAClD,SAASC,kBAAAA,uBAAsB;AAC/B,SAA8BC,QAAAA,OAAMC,eAAAA,cAAaC,gCAAgC;;;ACbjF,OAAOC,SAASC,aAAaC,eAAe;AAE5C,SAAwBC,SAASC,sBAAsB;AAEvD,SAASC,uBAAuB;AAChC,SAASC,MAAsDC,qBAAqB;AAU7E,IAAMC,wBAAwB,CAAC,EACpCC,WACAC,UACAC,eACAC,kBAAiB,MACO;AACxB,QAAMC,wBAAwBC,cAAc;IAAC;GAAuB;AACpE,QAAMC,uBAAuBC,QAAQ,MAAA;AACnC,QAAIH,iCAAiCI,SAAS;AAC5C,aAAOJ,sBAAsBK,IAAIC,SAAQ,EAAGC,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AAC7B,SAAuBP,cAAAA;AACjD,QAAMmD,WAAW,CAACC,OAAqB7C,QAAQ8C,KAAK,CAACC,MAAMF,GAAGG,QAAQC,QAAQP,OAAOK,EAAEL,EAAE,GAAGQ,QAAQL,GAAGK;AACvG,SAAOzD,UAAU8C,IAAI,CAACM,QAAQ;IAAEJ,OAAOG,SAASC,EAAAA;IAAKF,OAAO,cAAcE,GAAGK,IAAI;EAAG,EAAA;AACtF;",
|
|
6
|
+
"names": ["React", "useCallback", "useMemo", "ComputeGraph", "DXN", "FunctionType", "FunctionTriggerSchema", "ScriptType", "Filter", "Ref", "useQuery", "useTranslation", "Form", "SelectInput", "useRefQueryLookupHandler", "React", "useCallback", "useMemo", "RefImpl", "toEffectSchema", "useOnTransition", "Form", "useFormValues", "FunctionPayloadEditor", "functions", "getValue", "onValueChange", "onQueryRefOptions", "selectedFunctionValue", "useFormValues", "selectedFunctionName", "useMemo", "RefImpl", "dxn", "toString", "split", "at", "selectedFunction", "find", "f", "name", "useOnTransition", "prevValue", "undefined", "currValue", "inputSchema", "effectSchema", "toEffectSchema", "propertyCount", "properties", "Object", "keys", "length", "values", "handleValuesChanged", "useCallback", "h3", "className", "Form", "schema", "classNames", "onValuesChanged", "React", "useCallback", "useMemo", "TriggerKind", "useTranslation", "SelectInput", "useInputProps", "SpecSelector", "props", "t", "useTranslation", "AUTOMATION_PLUGIN", "specProps", "useInputProps", "handleTypeChange", "useCallback", "_type", "value", "getDefaultTriggerSpec", "kind", "TriggerKind", "Timer", "type", "cron", "Subscription", "filter", "Queue", "queue", "Email", "Webhook", "undefined", "defaultSpec", "onValueChange", "options", "useMemo", "Object", "values", "map", "label", "React", "SelectInput", "TriggerEditor", "space", "trigger", "onSave", "onCancel", "t", "useTranslation", "AUTOMATION_PLUGIN", "functions", "useQuery", "Filter", "schema", "FunctionType", "workflows", "ComputeGraph", "scripts", "ScriptType", "handleSave", "values", "handleRefQueryLookup", "useRefQueryLookupHandler", "Custom", "useMemo", "props", "getValue", "useCallback", "formValue", "DXN", "toString", "undefined", "handleOnValueChange", "_type", "dxnString", "dxn", "parse", "ref", "Ref", "fromDXN", "onValueChange", "React", "SelectInput", "options", "getWorkflowOptions", "concat", "getFunctionOptions", "SpecSelector", "FunctionPayloadEditor", "onQueryRefOptions", "div", "role", "className", "Form", "FunctionTriggerSchema", "graphs", "map", "graph", "label", "id", "value", "getLabel", "fn", "find", "s", "source", "target", "name"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
AUTOMATION_PLUGIN
|
|
4
|
+
} from "./chunk-DZ44LGYT.mjs";
|
|
5
|
+
|
|
6
|
+
// packages/plugins/plugin-automation/src/types.ts
|
|
7
|
+
import { Schema } from "effect";
|
|
8
|
+
import { SpaceSchema } from "@dxos/react-client/echo";
|
|
9
|
+
var TriggerTemplate = Schema.Union(Schema.Struct({
|
|
10
|
+
type: Schema.Literal("timer"),
|
|
11
|
+
cron: Schema.String
|
|
12
|
+
}), Schema.Struct({
|
|
13
|
+
type: Schema.Literal("queue"),
|
|
14
|
+
queueDXN: Schema.Any
|
|
15
|
+
}));
|
|
16
|
+
var AutomationAction;
|
|
17
|
+
(function(AutomationAction2) {
|
|
18
|
+
const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;
|
|
19
|
+
class CreateTriggerFromTemplate extends Schema.TaggedClass()(`${AUTOMATION_ACTION}/create-trigger-from-template`, {
|
|
20
|
+
input: Schema.Struct({
|
|
21
|
+
space: SpaceSchema,
|
|
22
|
+
template: TriggerTemplate,
|
|
23
|
+
enabled: Schema.optional(Schema.Boolean),
|
|
24
|
+
// TODO(wittjosiah): Improve how this lookup is done.
|
|
25
|
+
scriptName: Schema.optional(Schema.String),
|
|
26
|
+
input: Schema.optional(Schema.Record({
|
|
27
|
+
key: Schema.String,
|
|
28
|
+
value: Schema.Any
|
|
29
|
+
}))
|
|
30
|
+
}),
|
|
31
|
+
output: Schema.Void
|
|
32
|
+
}) {
|
|
33
|
+
}
|
|
34
|
+
AutomationAction2.CreateTriggerFromTemplate = CreateTriggerFromTemplate;
|
|
35
|
+
})(AutomationAction || (AutomationAction = {}));
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
AutomationAction
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=chunk-EEA6CZ6B.mjs.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,SAASA,cAAc;AAEvB,SAASC,mBAAmB;AAI5B,IAAMC,kBAAkBC,OAAOC,MAC7BD,OAAOE,OAAO;EAAEC,MAAMH,OAAOI,QAAQ,OAAA;EAAUC,MAAML,OAAOM;AAAO,CAAA,GACnEN,OAAOE,OAAO;EAAEC,MAAMH,OAAOI,QAAQ,OAAA;EAAUG,UAAUP,OAAOQ;AAAI,CAAA,CAAA;;UAGrDC,mBAAAA;AACf,QAAMC,oBAAoB,GAAGC,iBAAAA;EAEtB,MAAMC,kCAAkCZ,OAAOa,YAAW,EAC/D,GAAGH,iBAAAA,iCACH;IACEI,OAAOd,OAAOE,OAAO;MACnBa,OAAOC;MACPC,UAAUlB;MACVmB,SAASlB,OAAOmB,SAASnB,OAAOoB,OAAO;;MAEvCC,YAAYrB,OAAOmB,SAASnB,OAAOM,MAAM;MACzCQ,OAAOd,OAAOmB,SAASnB,OAAOsB,OAAO;QAAEC,KAAKvB,OAAOM;QAAQkB,OAAOxB,OAAOQ;MAAI,CAAA,CAAA;IAC/E,CAAA;IACAiB,QAAQzB,OAAO0B;EACjB,CAAA,EAAA;EACC;oBAbUd,4BAAAA;AAcf,GAjBiBH,qBAAAA,mBAAAA,CAAAA,EAAAA;",
|
|
6
|
+
"names": ["Schema", "SpaceSchema", "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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// packages/plugins/plugin-automation/src/components/index.ts
|
|
4
|
+
import { lazy } from "react";
|
|
5
|
+
var AutomationContainer = lazy(() => import("./AutomationContainer-MCUWF267.mjs"));
|
|
6
|
+
var AutomationPanel = lazy(() => import("./AutomationPanel-U34H2Q7Z.mjs"));
|
|
7
|
+
var FunctionsContainer = lazy(() => import("./FunctionsContainer-435FW56J.mjs"));
|
|
8
|
+
var FunctionsPanel = lazy(() => import("./FunctionsPanel-NXXT5ERU.mjs"));
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
AutomationContainer,
|
|
12
|
+
AutomationPanel,
|
|
13
|
+
FunctionsContainer,
|
|
14
|
+
FunctionsPanel
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chunk-RG3M42SO.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { lazy } from 'react';\n\nexport * from './TriggerEditor';\n\nexport const AutomationContainer = lazy(() => import('./AutomationContainer'));\nexport const AutomationPanel = lazy(() => import('./AutomationPanel'));\nexport const FunctionsContainer = lazy(() => import('./FunctionsContainer'));\nexport const FunctionsPanel = lazy(() => import('./FunctionsPanel'));\n"],
|
|
5
|
+
"mappings": ";;;AAIA,SAASA,YAAY;AAId,IAAMC,sBAAsBC,KAAK,MAAM,OAAO,oCAAA,CAAA;AAC9C,IAAMC,kBAAkBD,KAAK,MAAM,OAAO,gCAAA,CAAA;AAC1C,IAAME,qBAAqBF,KAAK,MAAM,OAAO,mCAAA,CAAA;AAC7C,IAAMG,iBAAiBH,KAAK,MAAM,OAAO,+BAAA,CAAA;",
|
|
6
|
+
"names": ["lazy", "AutomationContainer", "lazy", "AutomationPanel", "FunctionsContainer", "FunctionsPanel"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
AUTOMATION_PLUGIN
|
|
4
|
+
} from "./chunk-DZ44LGYT.mjs";
|
|
5
|
+
|
|
6
|
+
// packages/plugins/plugin-automation/src/components/FunctionsPanel/FunctionsPanel.tsx
|
|
7
|
+
import { Schema } from "effect";
|
|
8
|
+
import React, { useCallback, useMemo } from "react";
|
|
9
|
+
import { createIntent, LayoutAction, useIntentDispatcher } from "@dxos/app-framework";
|
|
10
|
+
import { FunctionType, ScriptType } from "@dxos/functions";
|
|
11
|
+
import { Filter, fullyQualifiedId, useQuery } from "@dxos/react-client/echo";
|
|
12
|
+
import { Button, useTranslation } from "@dxos/react-ui";
|
|
13
|
+
import { controlItemClasses } from "@dxos/react-ui-form";
|
|
14
|
+
import { List } from "@dxos/react-ui-list";
|
|
15
|
+
import { ghostHover, mx } from "@dxos/react-ui-theme";
|
|
16
|
+
var grid = "grid grid-cols-[1fr_auto] min-bs-[2.5rem]";
|
|
17
|
+
var FunctionsPanel = ({ space }) => {
|
|
18
|
+
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
19
|
+
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
20
|
+
const scripts = useQuery(space, Filter.schema(ScriptType));
|
|
21
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
22
|
+
const functionToScriptMap = useMemo(() => functions.reduce((map, func) => {
|
|
23
|
+
const scriptId = func.source?.target?.id;
|
|
24
|
+
if (scriptId) {
|
|
25
|
+
const script = scripts.find((s) => s.id === scriptId);
|
|
26
|
+
if (script) {
|
|
27
|
+
map[func.id] = script;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return map;
|
|
31
|
+
}, {}), [
|
|
32
|
+
functions,
|
|
33
|
+
scripts
|
|
34
|
+
]);
|
|
35
|
+
const getScriptName = useCallback((func) => {
|
|
36
|
+
const script = functionToScriptMap[func.id];
|
|
37
|
+
return script?.name;
|
|
38
|
+
}, [
|
|
39
|
+
functionToScriptMap
|
|
40
|
+
]);
|
|
41
|
+
const handleGoToScript = useCallback((func) => {
|
|
42
|
+
const script = functionToScriptMap[func.id];
|
|
43
|
+
if (script) {
|
|
44
|
+
void dispatch(createIntent(LayoutAction.Open, {
|
|
45
|
+
part: "main",
|
|
46
|
+
subject: [
|
|
47
|
+
fullyQualifiedId(script)
|
|
48
|
+
]
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
}, [
|
|
52
|
+
functionToScriptMap,
|
|
53
|
+
dispatch
|
|
54
|
+
]);
|
|
55
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
56
|
+
role: "none",
|
|
57
|
+
className: mx(controlItemClasses)
|
|
58
|
+
}, /* @__PURE__ */ React.createElement(List.Root, {
|
|
59
|
+
items: functions,
|
|
60
|
+
isItem: Schema.is(FunctionType),
|
|
61
|
+
getId: (func) => func.id
|
|
62
|
+
}, ({ items }) => /* @__PURE__ */ React.createElement("div", {
|
|
63
|
+
role: "list",
|
|
64
|
+
className: "flex flex-col w-full"
|
|
65
|
+
}, items?.map((func) => /* @__PURE__ */ React.createElement(List.Item, {
|
|
66
|
+
key: func.id,
|
|
67
|
+
item: func,
|
|
68
|
+
classNames: mx(grid, ghostHover, "items-center", "pli-2", "min-bs-[3rem]")
|
|
69
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
70
|
+
className: "flex flex-col truncate"
|
|
71
|
+
}, /* @__PURE__ */ React.createElement(List.ItemTitle, {
|
|
72
|
+
classNames: "truncate"
|
|
73
|
+
}, func.name), getScriptName(func) && /* @__PURE__ */ React.createElement("div", {
|
|
74
|
+
className: "text-xs text-description truncate"
|
|
75
|
+
}, getScriptName(func))), functionToScriptMap[func.id] && /* @__PURE__ */ React.createElement(Button, {
|
|
76
|
+
onClick: () => handleGoToScript(func)
|
|
77
|
+
}, t("go to function source button label")))))), functions.length === 0 && /* @__PURE__ */ React.createElement("div", {
|
|
78
|
+
className: "text-center plb-4 text-gray-500"
|
|
79
|
+
}, t("no functions found")));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// packages/plugins/plugin-automation/src/components/FunctionsPanel/index.ts
|
|
83
|
+
var FunctionsPanel_default = FunctionsPanel;
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
FunctionsPanel,
|
|
87
|
+
FunctionsPanel_default
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=chunk-VYSTWH6Q.mjs.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,SAASA,cAAc;AACvB,OAAOC,SAASC,aAAaC,eAAe;AAE5C,SAASC,cAAcC,cAAcC,2BAA2B;AAChE,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,W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CZ,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": ["Schema", "React", "useCallback", "useMemo", "createIntent", "LayoutAction", "useIntentDispatcher", "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", "Schema", "is", "getId", "Item", "key", "item", "classNames", "ghostHover", "ItemTitle", "Button", "onClick", "length", "FunctionsPanel"]
|
|
7
|
+
}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
TriggerEditor
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-5JC4JVYZ.mjs";
|
|
5
5
|
import {
|
|
6
6
|
AUTOMATION_PLUGIN
|
|
7
7
|
} from "./chunk-DZ44LGYT.mjs";
|
|
8
8
|
|
|
9
9
|
// packages/plugins/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx
|
|
10
|
+
import { Schema } from "effect";
|
|
10
11
|
import React, { useState } from "react";
|
|
11
|
-
import {
|
|
12
|
-
import { FunctionType, FunctionTrigger, FunctionTriggerSchema, TriggerKind, ScriptType } from "@dxos/functions/types";
|
|
12
|
+
import { FunctionType, FunctionTrigger, FunctionTriggerSchema, TriggerKind, ScriptType } from "@dxos/functions";
|
|
13
13
|
import { useClient } from "@dxos/react-client";
|
|
14
|
-
import {
|
|
14
|
+
import { live, Filter, useQuery, getSpace } from "@dxos/react-client/echo";
|
|
15
15
|
import { Clipboard, IconButton, Input, Separator, useTranslation } from "@dxos/react-ui";
|
|
16
16
|
import { ControlItem, controlItemClasses } from "@dxos/react-ui-form";
|
|
17
17
|
import { List } from "@dxos/react-ui-list";
|
|
18
|
-
import { StackItem } from "@dxos/react-ui-stack";
|
|
19
18
|
import { ghostHover, mx } from "@dxos/react-ui-theme";
|
|
20
19
|
var grid = "grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]";
|
|
21
|
-
var AutomationPanel = ({ space, object }) => {
|
|
20
|
+
var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
|
|
22
21
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
23
22
|
const client = useClient();
|
|
24
23
|
const triggers = useQuery(space, Filter.schema(FunctionTrigger));
|
|
25
24
|
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
26
25
|
const scripts = useQuery(space, Filter.schema(ScriptType));
|
|
27
|
-
const [trigger, setTrigger] = useState();
|
|
26
|
+
const [trigger, setTrigger] = useState(initialTrigger);
|
|
28
27
|
const [selected, setSelected] = useState();
|
|
29
28
|
const handleSelect = (trigger2) => {
|
|
30
29
|
const { id: _, ...values } = trigger2;
|
|
@@ -32,7 +31,7 @@ var AutomationPanel = ({ space, object }) => {
|
|
|
32
31
|
setSelected(trigger2);
|
|
33
32
|
};
|
|
34
33
|
const handleAdd = () => {
|
|
35
|
-
setTrigger(
|
|
34
|
+
setTrigger(live(FunctionTriggerSchema, {}));
|
|
36
35
|
setSelected(void 0);
|
|
37
36
|
};
|
|
38
37
|
const handleDelete = (trigger2) => {
|
|
@@ -44,17 +43,17 @@ var AutomationPanel = ({ space, object }) => {
|
|
|
44
43
|
if (selected) {
|
|
45
44
|
Object.assign(selected, trigger2);
|
|
46
45
|
} else {
|
|
47
|
-
space.db.add(
|
|
46
|
+
space.db.add(live(FunctionTrigger, trigger2));
|
|
48
47
|
}
|
|
49
48
|
setTrigger(void 0);
|
|
50
49
|
setSelected(void 0);
|
|
50
|
+
onDone?.();
|
|
51
51
|
};
|
|
52
52
|
const handleCancel = () => {
|
|
53
53
|
setTrigger(void 0);
|
|
54
|
+
onDone?.();
|
|
54
55
|
};
|
|
55
|
-
return /* @__PURE__ */ React.createElement(
|
|
56
|
-
classNames: "block overflow-y-auto"
|
|
57
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
56
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
58
57
|
className: "flex flex-col w-full"
|
|
59
58
|
}, trigger ? /* @__PURE__ */ React.createElement(ControlItem, {
|
|
60
59
|
title: t("trigger editor title")
|
|
@@ -68,7 +67,7 @@ var AutomationPanel = ({ space, object }) => {
|
|
|
68
67
|
className: controlItemClasses
|
|
69
68
|
}, /* @__PURE__ */ React.createElement(List.Root, {
|
|
70
69
|
items: triggers,
|
|
71
|
-
isItem:
|
|
70
|
+
isItem: Schema.is(FunctionTrigger),
|
|
72
71
|
getId: (field) => field.id
|
|
73
72
|
}, ({ items: triggers2 }) => /* @__PURE__ */ React.createElement("div", {
|
|
74
73
|
role: "list",
|
|
@@ -99,7 +98,7 @@ var AutomationPanel = ({ space, object }) => {
|
|
|
99
98
|
icon: "ph--plus--regular",
|
|
100
99
|
label: t("new trigger label"),
|
|
101
100
|
onClick: handleAdd
|
|
102
|
-
})))
|
|
101
|
+
})));
|
|
103
102
|
};
|
|
104
103
|
var getCopyAction = (client, trigger) => {
|
|
105
104
|
if (trigger?.spec?.type === TriggerKind.Email) {
|
|
@@ -124,8 +123,8 @@ var getWebhookUrl = (client, trigger) => {
|
|
|
124
123
|
return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();
|
|
125
124
|
};
|
|
126
125
|
var getFunctionName = (scripts, functions, trigger) => {
|
|
127
|
-
const shortId = trigger.function && `${trigger.function
|
|
128
|
-
const functionObject = functions.find((fn) =>
|
|
126
|
+
const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}\u2026`;
|
|
127
|
+
const functionObject = functions.find((fn) => fn === trigger.function?.target);
|
|
129
128
|
if (!functionObject) {
|
|
130
129
|
return shortId;
|
|
131
130
|
}
|
|
@@ -134,7 +133,9 @@ var getFunctionName = (scripts, functions, trigger) => {
|
|
|
134
133
|
|
|
135
134
|
// packages/plugins/plugin-automation/src/components/AutomationPanel/index.ts
|
|
136
135
|
var AutomationPanel_default = AutomationPanel;
|
|
136
|
+
|
|
137
137
|
export {
|
|
138
|
-
|
|
138
|
+
AutomationPanel,
|
|
139
|
+
AutomationPanel_default
|
|
139
140
|
};
|
|
140
|
-
//# sourceMappingURL=
|
|
141
|
+
//# sourceMappingURL=chunk-WYXWQFPK.mjs.map
|