@dxos/plugin-automation 0.8.4-main.5ad4a44 → 0.8.4-main.66e292d
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/AutomationPanel-M4M77L4V.mjs +11 -0
- package/dist/lib/browser/{AutomationSettings-3LABN6ER.mjs → AutomationSettings-4HCI6KJR.mjs} +6 -7
- package/dist/lib/{node-esm/AutomationSettings-XENNIIZM.mjs.map → browser/AutomationSettings-4HCI6KJR.mjs.map} +1 -1
- package/dist/lib/browser/FunctionsContainer-CDVBRQCT.mjs +144 -0
- package/dist/lib/browser/FunctionsContainer-CDVBRQCT.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-NRIKAPQV.mjs → FunctionsPanel-CRW6SJUN.mjs} +3 -3
- package/dist/lib/browser/{app-graph-builder-DV5HMFX4.mjs → app-graph-builder-W7LLC6XW.mjs} +7 -7
- package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs.map +7 -0
- package/dist/lib/browser/chunk-4MBM6C6A.mjs +100 -0
- package/dist/lib/browser/chunk-4MBM6C6A.mjs.map +7 -0
- package/dist/lib/browser/{chunk-NIJWEQRD.mjs → chunk-7W6QMY3L.mjs} +26 -42
- package/dist/lib/browser/chunk-7W6QMY3L.mjs.map +7 -0
- package/dist/lib/browser/{chunk-AY67OUDA.mjs → chunk-CZVA5NMD.mjs} +5 -5
- package/dist/lib/browser/chunk-LZQFZO3B.mjs +17 -0
- package/dist/lib/browser/chunk-LZQFZO3B.mjs.map +7 -0
- package/dist/lib/browser/{chunk-LC3QQU47.mjs → chunk-T6ZESHDY.mjs} +38 -18
- package/dist/lib/browser/chunk-T6ZESHDY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-DLLE4FKP.mjs → chunk-TWWFNOIR.mjs} +27 -12
- package/dist/lib/browser/chunk-TWWFNOIR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5ARH77PV.mjs → chunk-XAKZ4ANY.mjs} +2 -2
- package/dist/lib/browser/chunk-XAKZ4ANY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VGBZKM3O.mjs → chunk-YBPJCY3F.mjs} +2 -2
- package/dist/lib/browser/compute-runtime-B4XJVY4Y.mjs +113 -0
- package/dist/lib/browser/compute-runtime-B4XJVY4Y.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +5 -4
- package/dist/lib/browser/index.mjs +19 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-D2OHKQRR.mjs → intent-resolver-5HR7M7T6.mjs} +8 -8
- package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-JXFO46V4.mjs → react-surface-TKU2EQ5A.mjs} +6 -5
- package/dist/lib/browser/react-surface-TKU2EQ5A.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{AutomationPanel-GHK5UG4K.mjs → AutomationPanel-F5CTC6AT.mjs} +4 -4
- package/dist/lib/node-esm/{AutomationSettings-XENNIIZM.mjs → AutomationSettings-BQLJIFRT.mjs} +6 -7
- package/dist/lib/node-esm/FunctionsContainer-ZHHJPQAZ.mjs +145 -0
- package/dist/lib/node-esm/FunctionsContainer-ZHHJPQAZ.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-SAMRTELO.mjs → FunctionsPanel-RVVCS6VH.mjs} +3 -3
- package/dist/lib/node-esm/{app-graph-builder-TR2WXPX2.mjs → app-graph-builder-SLQOO7GH.mjs} +7 -7
- package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-LWASMQIF.mjs → chunk-3IYSC75Z.mjs} +5 -5
- package/dist/lib/node-esm/chunk-7B6NAAI6.mjs +101 -0
- package/dist/lib/node-esm/chunk-7B6NAAI6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5MQJPJR2.mjs → chunk-CEVIVRTY.mjs} +6 -2
- package/dist/lib/node-esm/chunk-CEVIVRTY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-EX74SIDO.mjs → chunk-CF2SWXPW.mjs} +26 -42
- package/dist/lib/node-esm/chunk-CF2SWXPW.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-CJUI6AKX.mjs → chunk-ECJKIUBO.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-3EWMZAU6.mjs → chunk-F76XVENA.mjs} +38 -18
- package/dist/lib/node-esm/chunk-F76XVENA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WHCSOUNN.mjs → chunk-KB7NFEYY.mjs} +2 -2
- package/dist/lib/node-esm/chunk-KB7NFEYY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YQXW3JXD.mjs → chunk-RVK52XGK.mjs} +27 -12
- package/dist/lib/node-esm/chunk-RVK52XGK.mjs.map +7 -0
- package/dist/lib/node-esm/compute-runtime-JUWTQXOV.mjs +114 -0
- package/dist/lib/node-esm/compute-runtime-JUWTQXOV.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +5 -4
- package/dist/lib/node-esm/index.mjs +19 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-2LGBVXT5.mjs → intent-resolver-KDRYB5BC.mjs} +8 -8
- package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-YDJ43B3N.mjs → react-surface-7QROSEGH.mjs} +6 -5
- package/dist/lib/node-esm/react-surface-7QROSEGH.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/capabilities/capabilities.d.ts +2 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +2 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +3 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts +8 -0
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts +2 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +2 -2
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/SpecSelector.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +6 -5
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +3 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts +5 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +2 -2
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts +2 -3
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -33
- package/src/AutomationPlugin.tsx +2 -2
- package/src/capabilities/app-graph-builder.ts +6 -6
- package/src/capabilities/capabilities.ts +2 -9
- package/src/capabilities/compute-runtime.ts +27 -36
- package/src/capabilities/intent-resolver.ts +5 -5
- package/src/capabilities/react-surface.tsx +2 -1
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +4 -5
- package/src/components/AutomationPanel/AutomationPanel.tsx +48 -35
- package/src/components/FunctionsContainer.tsx +7 -0
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +32 -13
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +127 -0
- package/src/components/FunctionsRegistry/index.ts +5 -0
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +2 -2
- package/src/components/TriggerEditor/SpecSelector.tsx +4 -5
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +37 -16
- package/src/components/TriggerEditor/TriggerEditor.tsx +24 -54
- package/src/hooks/useComputeRuntimeCallback.ts +40 -2
- package/src/hooks/useTriggerRuntimeControls.ts +4 -3
- package/src/index.ts +1 -0
- package/src/meta.ts +5 -2
- package/src/testing/test-functions.ts +2 -2
- package/src/translations.ts +3 -0
- package/dist/lib/browser/AutomationPanel-PNBH5L5C.mjs +0 -11
- package/dist/lib/browser/FunctionsContainer-HHBMPUOD.mjs +0 -36
- package/dist/lib/browser/FunctionsContainer-HHBMPUOD.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DV5HMFX4.mjs.map +0 -7
- package/dist/lib/browser/chunk-5ARH77PV.mjs.map +0 -7
- package/dist/lib/browser/chunk-DLLE4FKP.mjs.map +0 -7
- package/dist/lib/browser/chunk-LC3QQU47.mjs.map +0 -7
- package/dist/lib/browser/chunk-MVPRI3DB.mjs +0 -53
- package/dist/lib/browser/chunk-MVPRI3DB.mjs.map +0 -7
- package/dist/lib/browser/chunk-NIJWEQRD.mjs.map +0 -7
- package/dist/lib/browser/chunk-QT3YWUOT.mjs +0 -14
- package/dist/lib/browser/chunk-QT3YWUOT.mjs.map +0 -7
- package/dist/lib/browser/chunk-WWURMV25.mjs +0 -13
- package/dist/lib/browser/chunk-WWURMV25.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-YJREH6WP.mjs +0 -160
- package/dist/lib/browser/compute-runtime-YJREH6WP.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-D2OHKQRR.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JXFO46V4.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-ZKVOBUHV.mjs +0 -37
- package/dist/lib/node-esm/FunctionsContainer-ZKVOBUHV.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-TR2WXPX2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3EWMZAU6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5MQJPJR2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EX74SIDO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QCA543ZR.mjs +0 -54
- package/dist/lib/node-esm/chunk-QCA543ZR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U7LJXQS4.mjs +0 -16
- package/dist/lib/node-esm/chunk-U7LJXQS4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WHCSOUNN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YQXW3JXD.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-CMEPAYND.mjs +0 -161
- package/dist/lib/node-esm/compute-runtime-CMEPAYND.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-2LGBVXT5.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-YDJ43B3N.mjs.map +0 -7
- /package/dist/lib/browser/{AutomationPanel-PNBH5L5C.mjs.map → AutomationPanel-M4M77L4V.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-NRIKAPQV.mjs.map → FunctionsPanel-CRW6SJUN.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-AY67OUDA.mjs.map → chunk-CZVA5NMD.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-VGBZKM3O.mjs.map → chunk-YBPJCY3F.mjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-GHK5UG4K.mjs.map → AutomationPanel-F5CTC6AT.mjs.map} +0 -0
- /package/dist/lib/{browser/AutomationSettings-3LABN6ER.mjs.map → node-esm/AutomationSettings-BQLJIFRT.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-SAMRTELO.mjs.map → FunctionsPanel-RVVCS6VH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-LWASMQIF.mjs.map → chunk-3IYSC75Z.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-CJUI6AKX.mjs.map → chunk-ECJKIUBO.mjs.map} +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
FunctionsPanel
|
|
4
|
+
} from "./chunk-RVK52XGK.mjs";
|
|
5
|
+
import {
|
|
6
|
+
meta
|
|
7
|
+
} from "./chunk-CEVIVRTY.mjs";
|
|
8
|
+
|
|
9
|
+
// src/components/FunctionsContainer.tsx
|
|
10
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
11
|
+
import React2 from "react";
|
|
12
|
+
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
13
|
+
import { ControlPage, ControlSection } from "@dxos/react-ui-form";
|
|
14
|
+
|
|
15
|
+
// src/components/FunctionsRegistry/FunctionsRegistry.tsx
|
|
16
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
17
|
+
import * as Array from "effect/Array";
|
|
18
|
+
import * as EffectFunction from "effect/Function";
|
|
19
|
+
import * as Order from "effect/Order";
|
|
20
|
+
import * as Schema from "effect/Schema";
|
|
21
|
+
import { useState } from "react";
|
|
22
|
+
import React, { useCallback } from "react";
|
|
23
|
+
import { Function } from "@dxos/functions";
|
|
24
|
+
import { getDeployedFunctions } from "@dxos/functions-runtime/edge";
|
|
25
|
+
import { useClient } from "@dxos/react-client";
|
|
26
|
+
import { Filter, Query, useQuery } from "@dxos/react-client/echo";
|
|
27
|
+
import { useAsyncEffect } from "@dxos/react-ui";
|
|
28
|
+
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
29
|
+
import { controlItemClasses } from "@dxos/react-ui-form";
|
|
30
|
+
import { List } from "@dxos/react-ui-list";
|
|
31
|
+
import { ghostHover, mx } from "@dxos/react-ui-theme";
|
|
32
|
+
var grid = "grid grid-cols-[1fr_1fr_auto] min-bs-[2.5rem]";
|
|
33
|
+
var FunctionsRegistry = ({ space }) => {
|
|
34
|
+
var _effect = _useSignals();
|
|
35
|
+
try {
|
|
36
|
+
const client = useClient();
|
|
37
|
+
const [loading, setLoading] = useState(true);
|
|
38
|
+
const [functions, setFunctions] = useState([]);
|
|
39
|
+
const { t } = useTranslation(meta.id);
|
|
40
|
+
const dbFunctions = useQuery(space, Filter.type(Function.Function));
|
|
41
|
+
const state = (func) => {
|
|
42
|
+
const dbFunction = dbFunctions.find((f) => f.key === func.key);
|
|
43
|
+
if (!dbFunction) {
|
|
44
|
+
return "import";
|
|
45
|
+
}
|
|
46
|
+
if (dbFunction.version === func.version && dbFunction.updated === func.updated) {
|
|
47
|
+
return "none";
|
|
48
|
+
}
|
|
49
|
+
return "update";
|
|
50
|
+
};
|
|
51
|
+
useAsyncEffect(async () => {
|
|
52
|
+
setLoading(true);
|
|
53
|
+
const functions2 = await getDeployedFunctions(client);
|
|
54
|
+
setFunctions(functions2);
|
|
55
|
+
setLoading(false);
|
|
56
|
+
}, []);
|
|
57
|
+
const dedupedFunctions = EffectFunction.pipe(functions, Array.filter((_) => _.key !== void 0), Array.sort(Order.reverse(Order.mapInput(Order.string, (_) => _.updated ?? ""))), Array.dedupeWith((self, that) => self.key === that.key), Array.sort(Order.mapInput(Order.string, (_) => _.key ?? "")));
|
|
58
|
+
const hanleImportOrUpdate = useCallback(async (func) => {
|
|
59
|
+
const { objects: [existingFunc] } = await space.db.query(Query.type(Function.Function, {
|
|
60
|
+
key: func.key
|
|
61
|
+
})).run();
|
|
62
|
+
if (!existingFunc) {
|
|
63
|
+
space.db.add(func);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
Function.setFrom(existingFunc, func);
|
|
67
|
+
}, [
|
|
68
|
+
space
|
|
69
|
+
]);
|
|
70
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
71
|
+
role: "none",
|
|
72
|
+
className: mx(controlItemClasses)
|
|
73
|
+
}, dedupedFunctions.length > 0 && /* @__PURE__ */ React.createElement(List.Root, {
|
|
74
|
+
items: dedupedFunctions,
|
|
75
|
+
isItem: Schema.is(Function.Function),
|
|
76
|
+
getId: (func) => func.id
|
|
77
|
+
}, ({ items }) => /* @__PURE__ */ React.createElement("div", {
|
|
78
|
+
role: "list",
|
|
79
|
+
className: "flex flex-col is-full"
|
|
80
|
+
}, items?.map((func) => /* @__PURE__ */ React.createElement(List.Item, {
|
|
81
|
+
key: func.id,
|
|
82
|
+
item: func,
|
|
83
|
+
classNames: mx(grid, ghostHover, "items-center", "pli-2", "min-bs-[3rem]")
|
|
84
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
85
|
+
className: "flex flex-col truncate"
|
|
86
|
+
}, /* @__PURE__ */ React.createElement(List.ItemTitle, {
|
|
87
|
+
classNames: "truncate"
|
|
88
|
+
}, func.name), /* @__PURE__ */ React.createElement("div", {
|
|
89
|
+
className: "text-xs text-description truncate"
|
|
90
|
+
}, func.key)), /* @__PURE__ */ React.createElement("div", {
|
|
91
|
+
className: "flex flex-col truncate"
|
|
92
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
93
|
+
className: "text-xs text-description truncate"
|
|
94
|
+
}, func.version), /* @__PURE__ */ React.createElement("div", {
|
|
95
|
+
className: "text-xs text-description truncate"
|
|
96
|
+
}, func.updated ? `Uploaded ${new Date(func.updated).toLocaleString()}` : "")), /* @__PURE__ */ React.createElement(IconButton, {
|
|
97
|
+
iconOnly: true,
|
|
98
|
+
icon: state(func) === "update" ? "ph--arrows-clockwise--regular" : "ph--download--regular",
|
|
99
|
+
label: state(func) === "update" ? t("update function button label") : t("import function button label"),
|
|
100
|
+
disabled: state(func) === "none",
|
|
101
|
+
onClick: () => hanleImportOrUpdate(func)
|
|
102
|
+
}))))), dedupedFunctions.length === 0 && !loading && /* @__PURE__ */ React.createElement("div", {
|
|
103
|
+
className: "text-center plb-4 text-gray-500"
|
|
104
|
+
}, t("no functions found")), loading && /* @__PURE__ */ React.createElement("div", {
|
|
105
|
+
className: "text-center plb-4 text-gray-500"
|
|
106
|
+
}, t("loading functions")));
|
|
107
|
+
} finally {
|
|
108
|
+
_effect.f();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
// src/components/FunctionsContainer.tsx
|
|
113
|
+
var FunctionsContainer = ({ space }) => {
|
|
114
|
+
var _effect = _useSignals2();
|
|
115
|
+
try {
|
|
116
|
+
const { t } = useTranslation2(meta.id);
|
|
117
|
+
return /* @__PURE__ */ React2.createElement(ControlPage, null, /* @__PURE__ */ React2.createElement(ControlSection, {
|
|
118
|
+
title: t("functions verbose label", {
|
|
119
|
+
ns: meta.id
|
|
120
|
+
}),
|
|
121
|
+
description: t("functions description", {
|
|
122
|
+
ns: meta.id
|
|
123
|
+
})
|
|
124
|
+
}, /* @__PURE__ */ React2.createElement(FunctionsPanel, {
|
|
125
|
+
space
|
|
126
|
+
})), /* @__PURE__ */ React2.createElement(ControlSection, {
|
|
127
|
+
title: t("functions registry verbose label", {
|
|
128
|
+
ns: meta.id
|
|
129
|
+
}),
|
|
130
|
+
description: t("functions registry description", {
|
|
131
|
+
ns: meta.id
|
|
132
|
+
})
|
|
133
|
+
}, /* @__PURE__ */ React2.createElement(FunctionsRegistry, {
|
|
134
|
+
space
|
|
135
|
+
})));
|
|
136
|
+
} finally {
|
|
137
|
+
_effect.f();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var FunctionsContainer_default = FunctionsContainer;
|
|
141
|
+
export {
|
|
142
|
+
FunctionsContainer,
|
|
143
|
+
FunctionsContainer_default as default
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=FunctionsContainer-ZHHJPQAZ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/FunctionsContainer.tsx", "../../../src/components/FunctionsRegistry/FunctionsRegistry.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Space } from '@dxos/react-client/echo';\nimport { useTranslation } from '@dxos/react-ui';\nimport { ControlPage, ControlSection } from '@dxos/react-ui-form';\n\nimport { meta } from '../meta';\n\nimport { FunctionsPanel } from './FunctionsPanel';\nimport { FunctionsRegistry } from './FunctionsRegistry';\n\nexport const FunctionsContainer = ({ space }: { space: Space }) => {\n const { t } = useTranslation(meta.id);\n return (\n <ControlPage>\n <ControlSection\n title={t('functions verbose label', { ns: meta.id })}\n description={t('functions description', { ns: meta.id })}\n >\n <FunctionsPanel space={space} />\n </ControlSection>\n <ControlSection\n title={t('functions registry verbose label', { ns: meta.id })}\n description={t('functions registry description', { ns: meta.id })}\n >\n <FunctionsRegistry space={space} />\n </ControlSection>\n </ControlPage>\n );\n};\n\nexport default FunctionsContainer;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Array from 'effect/Array';\nimport * as EffectFunction from 'effect/Function';\nimport * as Order from 'effect/Order';\nimport * as Schema from 'effect/Schema';\nimport { useState } from 'react';\nimport React, { useCallback } from 'react';\n\nimport { Function } from '@dxos/functions';\nimport { getDeployedFunctions } from '@dxos/functions-runtime/edge';\nimport { useClient } from '@dxos/react-client';\nimport { Filter, Query, type Space, useQuery } from '@dxos/react-client/echo';\nimport { useAsyncEffect } from '@dxos/react-ui';\nimport { IconButton, 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 { meta } from '../../meta';\n\nconst grid = 'grid grid-cols-[1fr_1fr_auto] min-bs-[2.5rem]';\n\ntype FunctionsRegistryProps = {\n space: Space;\n};\n\nexport const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {\n const client = useClient();\n const [loading, setLoading] = useState(true);\n const [functions, setFunctions] = useState<Function.Function[]>([]);\n const { t } = useTranslation(meta.id);\n\n const dbFunctions = useQuery(space, Filter.type(Function.Function));\n\n const state = (func: Function.Function) => {\n const dbFunction = dbFunctions.find((f) => f.key === func.key);\n if (!dbFunction) {\n return 'import';\n }\n if (dbFunction.version === func.version && dbFunction.updated === func.updated) {\n return 'none';\n }\n return 'update';\n };\n\n useAsyncEffect(async () => {\n setLoading(true);\n const functions = await getDeployedFunctions(client);\n setFunctions(functions);\n setLoading(false);\n }, []);\n\n const dedupedFunctions = EffectFunction.pipe(\n functions,\n Array.filter((_) => _.key !== undefined),\n Array.sort(Order.reverse(Order.mapInput(Order.string, (_: Function.Function) => _.updated ?? ''))),\n Array.dedupeWith((self, that) => self.key === that.key),\n Array.sort(Order.mapInput(Order.string, (_: Function.Function) => _.key ?? '')),\n );\n\n const hanleImportOrUpdate = useCallback(\n async (func: Function.Function) => {\n const {\n objects: [existingFunc],\n } = await space.db.query(Query.type(Function.Function, { key: func.key })).run();\n if (!existingFunc) {\n space.db.add(func);\n return;\n }\n Function.setFrom(existingFunc, func);\n },\n [space],\n );\n\n return (\n <div role='none' className={mx(controlItemClasses)}>\n {dedupedFunctions.length > 0 && (\n <List.Root<Function.Function>\n items={dedupedFunctions}\n isItem={Schema.is(Function.Function)}\n getId={(func) => func.id}\n >\n {({ items }) => (\n <div role='list' className='flex flex-col is-full'>\n {items?.map((func) => (\n <List.Item<Function.Function>\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 <div className='text-xs text-description truncate'>{func.key}</div>\n </div>\n <div className='flex flex-col truncate'>\n <div className='text-xs text-description truncate'>{func.version}</div>\n <div className='text-xs text-description truncate'>\n {func.updated ? `Uploaded ${new Date(func.updated).toLocaleString()}` : ''}\n </div>\n </div>\n\n <IconButton\n iconOnly\n icon={state(func) === 'update' ? 'ph--arrows-clockwise--regular' : 'ph--download--regular'}\n label={\n state(func) === 'update' ? t('update function button label') : t('import function button label')\n }\n disabled={state(func) === 'none'}\n onClick={() => hanleImportOrUpdate(func)}\n />\n </List.Item>\n ))}\n </div>\n )}\n </List.Root>\n )}\n\n {dedupedFunctions.length === 0 && !loading && (\n <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>\n )}\n {loading && <div className='text-center plb-4 text-gray-500'>{t('loading functions')}</div>}\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["React", "useTranslation", "ControlPage", "ControlSection", "Array", "EffectFunction", "Order", "Schema", "useState", "React", "useCallback", "Function", "getDeployedFunctions", "useClient", "Filter", "Query", "useQuery", "useAsyncEffect", "IconButton", "useTranslation", "controlItemClasses", "List", "ghostHover", "mx", "grid", "FunctionsRegistry", "space", "client", "useClient", "loading", "setLoading", "useState", "functions", "setFunctions", "t", "useTranslation", "meta", "id", "dbFunctions", "useQuery", "Filter", "type", "Function", "state", "func", "dbFunction", "find", "f", "key", "version", "updated", "useAsyncEffect", "getDeployedFunctions", "dedupedFunctions", "pipe", "filter", "_", "undefined", "sort", "reverse", "mapInput", "string", "dedupeWith", "self", "that", "hanleImportOrUpdate", "useCallback", "objects", "existingFunc", "db", "query", "Query", "run", "add", "setFrom", "div", "role", "className", "mx", "controlItemClasses", "length", "List", "Root", "items", "isItem", "is", "getId", "map", "Item", "item", "classNames", "ghostHover", "ItemTitle", "name", "Date", "toLocaleString", "IconButton", "iconOnly", "icon", "label", "disabled", "onClick", "FunctionsContainer", "space", "t", "useTranslation", "meta", "id", "React", "ControlPage", "ControlSection", "title", "ns", "description", "FunctionsPanel", "FunctionsRegistry"]
|
|
7
|
+
}
|
|
@@ -2,10 +2,10 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
2
2
|
import {
|
|
3
3
|
FunctionsPanel,
|
|
4
4
|
FunctionsPanel_default
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-RVK52XGK.mjs";
|
|
6
|
+
import "./chunk-CEVIVRTY.mjs";
|
|
7
7
|
export {
|
|
8
8
|
FunctionsPanel,
|
|
9
9
|
FunctionsPanel_default as default
|
|
10
10
|
};
|
|
11
|
-
//# sourceMappingURL=FunctionsPanel-
|
|
11
|
+
//# sourceMappingURL=FunctionsPanel-RVVCS6VH.mjs.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
meta
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CEVIVRTY.mjs";
|
|
5
5
|
|
|
6
6
|
// src/capabilities/app-graph-builder.ts
|
|
7
|
-
import {
|
|
7
|
+
import { Atom } from "@effect-atom/atom-react";
|
|
8
8
|
import * as Function from "effect/Function";
|
|
9
9
|
import * as Option from "effect/Option";
|
|
10
10
|
import { Capabilities, contributes } from "@dxos/app-framework";
|
|
11
11
|
import { Obj } from "@dxos/echo";
|
|
12
|
-
import {
|
|
12
|
+
import { Script } from "@dxos/functions";
|
|
13
13
|
import { ATTENDABLE_PATH_SEPARATOR, PLANK_COMPANION_TYPE } from "@dxos/plugin-deck/types";
|
|
14
14
|
import { createExtension } from "@dxos/plugin-graph";
|
|
15
15
|
import { meta as spaceMeta } from "@dxos/plugin-space";
|
|
16
16
|
var app_graph_builder_default = ((context) => contributes(Capabilities.AppGraphBuilder, [
|
|
17
17
|
createExtension({
|
|
18
18
|
id: `${meta.id}/space-settings-automation`,
|
|
19
|
-
connector: (node) =>
|
|
19
|
+
connector: (node) => Atom.make((get) => Function.pipe(get(node), Option.flatMap((node2) => node2.type === `${spaceMeta.id}/settings` ? Option.some(node2) : Option.none()), Option.map((node2) => [
|
|
20
20
|
{
|
|
21
21
|
id: `automation-${node2.id}`,
|
|
22
22
|
type: `${meta.id}/space-settings-automation`,
|
|
@@ -35,7 +35,7 @@ var app_graph_builder_default = ((context) => contributes(Capabilities.AppGraphB
|
|
|
35
35
|
}),
|
|
36
36
|
createExtension({
|
|
37
37
|
id: `${meta.id}/space-settings-functions`,
|
|
38
|
-
connector: (node) =>
|
|
38
|
+
connector: (node) => Atom.make((get) => Function.pipe(get(node), Option.flatMap((node2) => node2.type === `${spaceMeta.id}/settings` ? Option.some(node2) : Option.none()), Option.map((node2) => [
|
|
39
39
|
{
|
|
40
40
|
id: `functions-${node2.id}`,
|
|
41
41
|
type: `${meta.id}/space-settings-functions`,
|
|
@@ -54,7 +54,7 @@ var app_graph_builder_default = ((context) => contributes(Capabilities.AppGraphB
|
|
|
54
54
|
}),
|
|
55
55
|
createExtension({
|
|
56
56
|
id: `${meta.id}/script-companion`,
|
|
57
|
-
connector: (node) =>
|
|
57
|
+
connector: (node) => Atom.make((get) => Function.pipe(get(node), Option.flatMap((node2) => Obj.instanceOf(Script.Script, node2.data) ? Option.some(node2) : Option.none()), Option.map((node2) => [
|
|
58
58
|
{
|
|
59
59
|
id: [
|
|
60
60
|
node2.id,
|
|
@@ -79,4 +79,4 @@ var app_graph_builder_default = ((context) => contributes(Capabilities.AppGraphB
|
|
|
79
79
|
export {
|
|
80
80
|
app_graph_builder_default as default
|
|
81
81
|
};
|
|
82
|
-
//# sourceMappingURL=app-graph-builder-
|
|
82
|
+
//# sourceMappingURL=app-graph-builder-SLQOO7GH.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 { Atom } from '@effect-atom/atom-react';\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\n\nimport { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\nimport { Script } from '@dxos/functions';\nimport { ATTENDABLE_PATH_SEPARATOR, PLANK_COMPANION_TYPE } from '@dxos/plugin-deck/types';\nimport { createExtension } from '@dxos/plugin-graph';\nimport { meta as spaceMeta } from '@dxos/plugin-space';\n\nimport { meta } from '../meta';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.AppGraphBuilder, [\n createExtension({\n id: `${meta.id}/space-settings-automation`,\n connector: (node) =>\n Atom.make((get) =>\n Function.pipe(\n get(node),\n Option.flatMap((node) => (node.type === `${spaceMeta.id}/settings` ? Option.some(node) : Option.none())),\n Option.map((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 Option.getOrElse(() => []),\n ),\n ),\n }),\n createExtension({\n id: `${meta.id}/space-settings-functions`,\n connector: (node) =>\n Atom.make((get) =>\n Function.pipe(\n get(node),\n Option.flatMap((node) => (node.type === `${spaceMeta.id}/settings` ? Option.some(node) : Option.none())),\n Option.map((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 Option.getOrElse(() => []),\n ),\n ),\n }),\n createExtension({\n id: `${meta.id}/script-companion`,\n connector: (node) =>\n Atom.make((get) =>\n Function.pipe(\n get(node),\n Option.flatMap((node) => (Obj.instanceOf(Script.Script, node.data) ? Option.some(node) : Option.none())),\n Option.map((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 disposition: 'hidden',\n },\n },\n ]),\n Option.getOrElse(() => []),\n ),\n ),\n }),\n ]);\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,SAASA,YAAY;AACrB,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AAExB,SAASC,cAAkCC,mBAAmB;AAC9D,SAASC,WAAW;AACpB,SAASC,cAAc;AACvB,SAASC,2BAA2BC,4BAA4B;AAChE,SAASC,uBAAuB;AAChC,SAASC,QAAQC,iBAAiB;AAIlC,IAAA,6BAAe,CAACC,YACdC,YAAYC,aAAaC,iBAAiB;EACxCC,gBAAgB;IACdC,IAAI,GAAGC,KAAKD,EAAE;IACdE,WAAW,CAACC,SACVC,KAAKC,KAAK,CAACC,QACAC,cACPD,IAAIH,IAAAA,GACGK,eAAQ,CAACL,UAAUA,MAAKM,SAAS,GAAGC,UAAUV,EAAE,cAAqBW,YAAKR,KAAAA,IAAeS,YAAI,CAAA,GAC7FC,WAAI,CAACV,UAAS;MACnB;QACEH,IAAI,cAAcG,MAAKH,EAAE;QACzBS,MAAM,GAAGR,KAAKD,EAAE;QAChBc,MAAM,GAAGb,KAAKD,EAAE;QAChBe,YAAY;UACVC,OAAO;YAAC;YAA0B;cAAEC,IAAIhB,KAAKD;YAAG;;UAChDkB,MAAM;QACR;MACF;KACD,GACMC,iBAAU,MAAM,CAAA,CAAE,CAAA,CAAA;EAGjC,CAAA;EACApB,gBAAgB;IACdC,IAAI,GAAGC,KAAKD,EAAE;IACdE,WAAW,CAACC,SACVC,KAAKC,KAAK,CAACC,QACAC,cACPD,IAAIH,IAAAA,GACGK,eAAQ,CAACL,UAAUA,MAAKM,SAAS,GAAGC,UAAUV,EAAE,cAAqBW,YAAKR,KAAAA,IAAeS,YAAI,CAAA,GAC7FC,WAAI,CAACV,UAAS;MACnB;QACEH,IAAI,aAAaG,MAAKH,EAAE;QACxBS,MAAM,GAAGR,KAAKD,EAAE;QAChBc,MAAM,GAAGb,KAAKD,EAAE;QAChBe,YAAY;UACVC,OAAO;YAAC;YAAyB;cAAEC,IAAIhB,KAAKD;YAAG;;UAC/CkB,MAAM;QACR;MACF;KACD,GACMC,iBAAU,MAAM,CAAA,CAAE,CAAA,CAAA;EAGjC,CAAA;EACApB,gBAAgB;IACdC,IAAI,GAAGC,KAAKD,EAAE;IACdE,WAAW,CAACC,SACVC,KAAKC,KAAK,CAACC,QACAC,cACPD,IAAIH,IAAAA,GACGK,eAAQ,CAACL,UAAUiB,IAAIC,WAAWC,OAAOA,QAAQnB,MAAKW,IAAI,IAAWH,YAAKR,KAAAA,IAAeS,YAAI,CAAA,GAC7FC,WAAI,CAACV,UAAS;MACnB;QACEH,IAAI;UAACG,MAAKH;UAAI;UAAcuB,KAAKC,yBAAAA;QACjCf,MAAMgB;QACNX,MAAM;QACNC,YAAY;UACVC,OAAO;YAAC;YAA2B;cAAEC,IAAIhB,KAAKD;YAAG;;UACjDkB,MAAM;UACNQ,aAAa;QACf;MACF;KACD,GACMP,iBAAU,MAAM,CAAA,CAAE,CAAA,CAAA;EAGjC,CAAA;CACD;",
|
|
6
|
+
"names": ["Atom", "Function", "Option", "Capabilities", "contributes", "Obj", "Script", "ATTENDABLE_PATH_SEPARATOR", "PLANK_COMPANION_TYPE", "createExtension", "meta", "spaceMeta", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "meta", "connector", "node", "Atom", "make", "get", "pipe", "flatMap", "type", "spaceMeta", "some", "none", "map", "data", "properties", "label", "ns", "icon", "getOrElse", "Obj", "instanceOf", "Script", "join", "ATTENDABLE_PATH_SEPARATOR", "PLANK_COMPANION_TYPE", "disposition"]
|
|
7
|
+
}
|
|
@@ -2,10 +2,10 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
2
2
|
|
|
3
3
|
// src/components/index.ts
|
|
4
4
|
import { lazy } from "react";
|
|
5
|
-
var AutomationPanel = lazy(() => import("./AutomationPanel-
|
|
6
|
-
var AutomationSettings = lazy(() => import("./AutomationSettings-
|
|
7
|
-
var FunctionsContainer = lazy(() => import("./FunctionsContainer-
|
|
8
|
-
var FunctionsPanel = lazy(() => import("./FunctionsPanel-
|
|
5
|
+
var AutomationPanel = lazy(() => import("./AutomationPanel-F5CTC6AT.mjs"));
|
|
6
|
+
var AutomationSettings = lazy(() => import("./AutomationSettings-BQLJIFRT.mjs"));
|
|
7
|
+
var FunctionsContainer = lazy(() => import("./FunctionsContainer-ZHHJPQAZ.mjs"));
|
|
8
|
+
var FunctionsPanel = lazy(() => import("./FunctionsPanel-RVVCS6VH.mjs"));
|
|
9
9
|
|
|
10
10
|
export {
|
|
11
11
|
AutomationPanel,
|
|
@@ -13,4 +13,4 @@ export {
|
|
|
13
13
|
FunctionsContainer,
|
|
14
14
|
FunctionsPanel
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=chunk-
|
|
16
|
+
//# sourceMappingURL=chunk-3IYSC75Z.mjs.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
AutomationCapabilities
|
|
4
|
+
} from "./chunk-KB7NFEYY.mjs";
|
|
5
|
+
|
|
6
|
+
// src/hooks/useComputeRuntimeCallback.ts
|
|
7
|
+
import * as Cause from "effect/Cause";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Exit from "effect/Exit";
|
|
10
|
+
import { useCallback } from "react";
|
|
11
|
+
import { useCapability } from "@dxos/app-framework/react";
|
|
12
|
+
import { FunctionInvocationService } from "@dxos/functions";
|
|
13
|
+
import { InvocationTracer, TracingServiceExt } from "@dxos/functions-runtime";
|
|
14
|
+
import { log } from "@dxos/log";
|
|
15
|
+
|
|
16
|
+
// src/capabilities/index.ts
|
|
17
|
+
import { lazy } from "@dxos/app-framework";
|
|
18
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-SLQOO7GH.mjs"));
|
|
19
|
+
var ComputeRuntime = lazy(() => import("./compute-runtime-JUWTQXOV.mjs"));
|
|
20
|
+
var IntentResolver = lazy(() => import("./intent-resolver-KDRYB5BC.mjs"));
|
|
21
|
+
var ReactSurface = lazy(() => import("./react-surface-7QROSEGH.mjs"));
|
|
22
|
+
|
|
23
|
+
// src/hooks/useComputeRuntimeCallback.ts
|
|
24
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-automation/src/hooks/useComputeRuntimeCallback.ts";
|
|
25
|
+
var useComputeRuntimeCallback = (space, fn, deps) => {
|
|
26
|
+
const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);
|
|
27
|
+
const runtime = space !== void 0 ? computeRuntime.getRuntime(space.id) : void 0;
|
|
28
|
+
return useCallback(() => {
|
|
29
|
+
if (!runtime) {
|
|
30
|
+
throw new TypeError("Space not provided to useComputeRuntimeCallback");
|
|
31
|
+
}
|
|
32
|
+
return runtime.runPromise(fn());
|
|
33
|
+
}, [
|
|
34
|
+
runtime,
|
|
35
|
+
...deps ?? []
|
|
36
|
+
]);
|
|
37
|
+
};
|
|
38
|
+
var invokeFunctionWithTracing = (functionDef, inputData) => Effect.gen(function* () {
|
|
39
|
+
const tracer = yield* InvocationTracer;
|
|
40
|
+
const trace = yield* tracer.traceInvocationStart({
|
|
41
|
+
target: void 0,
|
|
42
|
+
payload: {
|
|
43
|
+
data: {}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
const result = yield* FunctionInvocationService.invokeFunction(functionDef, inputData).pipe(Effect.provide(TracingServiceExt.layerQueue(trace.invocationTraceQueue)), Effect.exit);
|
|
47
|
+
if (Exit.isFailure(result)) {
|
|
48
|
+
const error = Cause.prettyErrors(result.cause)[0];
|
|
49
|
+
log.error(error.message, error.cause ?? error.stack, {
|
|
50
|
+
F: __dxlog_file,
|
|
51
|
+
L: 58,
|
|
52
|
+
S: this,
|
|
53
|
+
C: (f, a) => f(...a)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
yield* tracer.traceInvocationEnd({
|
|
57
|
+
trace,
|
|
58
|
+
// TODO(dmaretskyi): Might miss errors.
|
|
59
|
+
exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : void 0
|
|
60
|
+
});
|
|
61
|
+
return result;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// src/hooks/useTriggerRuntimeControls.ts
|
|
65
|
+
import * as Effect2 from "effect/Effect";
|
|
66
|
+
import { Filter } from "@dxos/echo";
|
|
67
|
+
import { Trigger } from "@dxos/functions";
|
|
68
|
+
import { TriggerDispatcher } from "@dxos/functions-runtime";
|
|
69
|
+
import { useQuery } from "@dxos/react-client/echo";
|
|
70
|
+
import { useAsyncState } from "@dxos/react-ui";
|
|
71
|
+
var useTriggerRuntimeControls = (space) => {
|
|
72
|
+
const triggers = useQuery(space, Filter.type(Trigger.Trigger));
|
|
73
|
+
const [isRunningState, setIsRunningState] = useAsyncState(useComputeRuntimeCallback(space, () => TriggerDispatcher.pipe(Effect2.map((t) => t.running))));
|
|
74
|
+
const start = useComputeRuntimeCallback(space, Effect2.fnUntraced(function* () {
|
|
75
|
+
const dispatcher = yield* TriggerDispatcher;
|
|
76
|
+
yield* dispatcher.start();
|
|
77
|
+
setIsRunningState(true);
|
|
78
|
+
}));
|
|
79
|
+
const stop = useComputeRuntimeCallback(space, Effect2.fnUntraced(function* () {
|
|
80
|
+
const dispatcher = yield* TriggerDispatcher;
|
|
81
|
+
yield* dispatcher.stop();
|
|
82
|
+
setIsRunningState(false);
|
|
83
|
+
}));
|
|
84
|
+
return {
|
|
85
|
+
triggers,
|
|
86
|
+
isRunning: isRunningState ?? false,
|
|
87
|
+
start: () => void start(),
|
|
88
|
+
stop: () => void stop()
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
useComputeRuntimeCallback,
|
|
94
|
+
invokeFunctionWithTracing,
|
|
95
|
+
useTriggerRuntimeControls,
|
|
96
|
+
AppGraphBuilder,
|
|
97
|
+
ComputeRuntime,
|
|
98
|
+
IntentResolver,
|
|
99
|
+
ReactSurface
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=chunk-7B6NAAI6.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/hooks/useComputeRuntimeCallback.ts", "../../../src/capabilities/index.ts", "../../../src/hooks/useTriggerRuntimeControls.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport { useCallback } from 'react';\n\nimport { useCapability } from '@dxos/app-framework/react';\nimport { type FunctionDefinition, FunctionInvocationService } from '@dxos/functions';\nimport { InvocationTracer, TracingServiceExt } from '@dxos/functions-runtime';\nimport { log } from '@dxos/log';\nimport type { Space } from '@dxos/react-client/echo';\n\nimport { AutomationCapabilities } from '../capabilities';\n\n/**\n * Create an effectful function that has access to compute services\n */\n// TODO(burdon): Factor out (figure out cross-plugin capabilities dependencies).\nexport const useComputeRuntimeCallback = <T>(\n space: Space | undefined,\n fn: () => Effect.Effect<T, any, AutomationCapabilities.ComputeServices>,\n deps?: React.DependencyList,\n): (() => Promise<T>) => {\n const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);\n const runtime = space !== undefined ? computeRuntime.getRuntime(space.id) : undefined;\n\n return useCallback(() => {\n if (!runtime) {\n throw new TypeError('Space not provided to useComputeRuntimeCallback');\n }\n\n return runtime.runPromise(fn());\n }, [runtime, ...(deps ?? [])]);\n};\n\n// TODO(wittjosiah): Function invoking should automatically be traced (DX-647).\nexport const invokeFunctionWithTracing = <I, O>(functionDef: FunctionDefinition<I, O>, inputData: I) =>\n Effect.gen(function* () {\n const tracer = yield* InvocationTracer;\n const trace = yield* tracer.traceInvocationStart({\n target: undefined,\n payload: {\n data: {},\n },\n });\n\n // Invoke the function.\n const result = yield* FunctionInvocationService.invokeFunction(functionDef, inputData).pipe(\n Effect.provide(TracingServiceExt.layerQueue(trace.invocationTraceQueue)),\n Effect.exit,\n );\n\n if (Exit.isFailure(result)) {\n const error = Cause.prettyErrors(result.cause)[0];\n log.error(error.message, error.cause ?? error.stack);\n }\n\n yield* tracer.traceInvocationEnd({\n trace,\n // TODO(dmaretskyi): Might miss errors.\n exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,\n });\n\n return result;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const AppGraphBuilder = lazy(() => import('./app-graph-builder'));\nexport const ComputeRuntime = lazy(() => import('./compute-runtime'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n\nexport * from './capabilities';\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Filter } from '@dxos/echo';\nimport { Trigger } from '@dxos/functions';\nimport { TriggerDispatcher } from '@dxos/functions-runtime';\nimport { type Space, useQuery } from '@dxos/react-client/echo';\nimport { useAsyncState } from '@dxos/react-ui';\n\nimport { useComputeRuntimeCallback } from './useComputeRuntimeCallback';\n\ninterface TriggerRuntimeControls {\n triggers: Trigger.Trigger[];\n isRunning: boolean;\n start: () => void;\n stop: () => void;\n}\n\nexport const useTriggerRuntimeControls = (space: Space | undefined): TriggerRuntimeControls => {\n const triggers = useQuery(space, Filter.type(Trigger.Trigger));\n\n const [isRunningState, setIsRunningState] = useAsyncState(\n useComputeRuntimeCallback(space, () => TriggerDispatcher.pipe(Effect.map((t) => t.running))),\n );\n\n const start = useComputeRuntimeCallback(\n space,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.start();\n setIsRunningState(true);\n }),\n );\n\n const stop = useComputeRuntimeCallback(\n space,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.stop();\n setIsRunningState(false);\n }),\n );\n\n return {\n triggers,\n isRunning: isRunningState ?? false,\n start: () => void start(),\n stop: () => void stop(),\n };\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,YAAYA,WAAW;AACvB,YAAYC,YAAY;AACxB,YAAYC,UAAU;AACtB,SAASC,mBAAmB;AAE5B,SAASC,qBAAqB;AAC9B,SAAkCC,iCAAiC;AACnE,SAASC,kBAAkBC,yBAAyB;AACpD,SAASC,WAAW;;;ACRpB,SAASC,YAAY;AAEd,IAAMC,kBAAkBC,KAAK,MAAM,OAAO,kCAAA,CAAA;AAC1C,IAAMC,iBAAiBD,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAME,iBAAiBF,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAMG,eAAeH,KAAK,MAAM,OAAO,8BAAA,CAAA;;;;ADYvC,IAAMI,4BAA4B,CACvCC,OACAC,IACAC,SAAAA;AAEA,QAAMC,iBAAiBC,cAAcC,uBAAuBC,cAAc;AAC1E,QAAMC,UAAUP,UAAUQ,SAAYL,eAAeM,WAAWT,MAAMU,EAAE,IAAIF;AAE5E,SAAOG,YAAY,MAAA;AACjB,QAAI,CAACJ,SAAS;AACZ,YAAM,IAAIK,UAAU,iDAAA;IACtB;AAEA,WAAOL,QAAQM,WAAWZ,GAAAA,CAAAA;EAC5B,GAAG;IAACM;OAAaL,QAAQ,CAAA;GAAI;AAC/B;AAGO,IAAMY,4BAA4B,CAAOC,aAAuCC,cAC9EC,WAAI,aAAA;AACT,QAAMC,SAAS,OAAOC;AACtB,QAAMC,QAAQ,OAAOF,OAAOG,qBAAqB;IAC/CC,QAAQd;IACRe,SAAS;MACPC,MAAM,CAAC;IACT;EACF,CAAA;AAGA,QAAMC,SAAS,OAAOC,0BAA0BC,eAAeZ,aAAaC,SAAAA,EAAWY,KAC9EC,eAAQC,kBAAkBC,WAAWX,MAAMY,oBAAoB,CAAA,GAC/DC,WAAI;AAGb,MAASC,eAAUT,MAAAA,GAAS;AAC1B,UAAMU,QAAcC,mBAAaX,OAAOY,KAAK,EAAE,CAAA;AAC/CC,QAAIH,MAAMA,MAAMI,SAASJ,MAAME,SAASF,MAAMK,OAAK;;;;;;EACrD;AAEA,SAAOtB,OAAOuB,mBAAmB;IAC/BrB;;IAEAsB,WAAgBR,eAAUT,MAAAA,IAAgBW,mBAAaX,OAAOY,KAAK,EAAE,CAAA,IAAK7B;EAC5E,CAAA;AAEA,SAAOiB;AACT,CAAA;;;AE/DF,YAAYkB,aAAY;AAExB,SAASC,cAAc;AACvB,SAASC,eAAe;AACxB,SAASC,yBAAyB;AAClC,SAAqBC,gBAAgB;AACrC,SAASC,qBAAqB;AAWvB,IAAMC,4BAA4B,CAACC,UAAAA;AACxC,QAAMC,WAAWC,SAASF,OAAOG,OAAOC,KAAKC,QAAQA,OAAO,CAAA;AAE5D,QAAM,CAACC,gBAAgBC,iBAAAA,IAAqBC,cAC1CC,0BAA0BT,OAAO,MAAMU,kBAAkBC,KAAYC,YAAI,CAACC,MAAMA,EAAEC,OAAO,CAAA,CAAA,CAAA;AAG3F,QAAMC,QAAQN,0BACZT,OACOgB,mBAAW,aAAA;AAChB,UAAMC,aAAa,OAAOP;AAC1B,WAAOO,WAAWF,MAAK;AACvBR,sBAAkB,IAAA;EACpB,CAAA,CAAA;AAGF,QAAMW,OAAOT,0BACXT,OACOgB,mBAAW,aAAA;AAChB,UAAMC,aAAa,OAAOP;AAC1B,WAAOO,WAAWC,KAAI;AACtBX,sBAAkB,KAAA;EACpB,CAAA,CAAA;AAGF,SAAO;IACLN;IACAkB,WAAWb,kBAAkB;IAC7BS,OAAO,MAAM,KAAKA,MAAAA;IAClBG,MAAM,MAAM,KAAKA,KAAAA;EACnB;AACF;",
|
|
6
|
+
"names": ["Cause", "Effect", "Exit", "useCallback", "useCapability", "FunctionInvocationService", "InvocationTracer", "TracingServiceExt", "log", "lazy", "AppGraphBuilder", "lazy", "ComputeRuntime", "IntentResolver", "ReactSurface", "useComputeRuntimeCallback", "space", "fn", "deps", "computeRuntime", "useCapability", "AutomationCapabilities", "ComputeRuntime", "runtime", "undefined", "getRuntime", "id", "useCallback", "TypeError", "runPromise", "invokeFunctionWithTracing", "functionDef", "inputData", "gen", "tracer", "InvocationTracer", "trace", "traceInvocationStart", "target", "payload", "data", "result", "FunctionInvocationService", "invokeFunction", "pipe", "provide", "TracingServiceExt", "layerQueue", "invocationTraceQueue", "exit", "isFailure", "error", "prettyErrors", "cause", "log", "message", "stack", "traceInvocationEnd", "exception", "Effect", "Filter", "Trigger", "TriggerDispatcher", "useQuery", "useAsyncState", "useTriggerRuntimeControls", "space", "triggers", "useQuery", "Filter", "type", "Trigger", "isRunningState", "setIsRunningState", "useAsyncState", "useComputeRuntimeCallback", "TriggerDispatcher", "pipe", "map", "t", "running", "start", "fnUntraced", "dispatcher", "stop", "isRunning"]
|
|
7
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
|
|
3
3
|
// src/meta.ts
|
|
4
|
+
import { trim } from "@dxos/util";
|
|
4
5
|
var meta = {
|
|
5
6
|
id: "dxos.org/plugin/automation",
|
|
6
7
|
name: "Automation",
|
|
7
|
-
description:
|
|
8
|
+
description: trim`
|
|
9
|
+
Workflow automation engine that triggers custom actions based on object events and conditions.
|
|
10
|
+
Create automated pipelines that respond to changes and streamline repetitive tasks.
|
|
11
|
+
`,
|
|
8
12
|
icon: "ph--robot--regular",
|
|
9
13
|
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation"
|
|
10
14
|
};
|
|
@@ -12,4 +16,4 @@ var meta = {
|
|
|
12
16
|
export {
|
|
13
17
|
meta
|
|
14
18
|
};
|
|
15
|
-
//# sourceMappingURL=chunk-
|
|
19
|
+
//# sourceMappingURL=chunk-CEVIVRTY.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: PluginMeta = {\n id: 'dxos.org/plugin/automation',\n name: 'Automation',\n description: trim`\n Workflow automation engine that triggers custom actions based on object events and conditions.\n Create automated pipelines that respond to changes and streamline repetitive tasks.\n `,\n icon: 'ph--robot--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',\n};\n"],
|
|
5
|
+
"mappings": ";;;AAKA,SAASA,YAAY;AAEd,IAAMC,OAAmB;EAC9BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
|
+
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "source"]
|
|
7
|
+
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
meta
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-CEVIVRTY.mjs";
|
|
5
5
|
|
|
6
6
|
// src/components/TriggerEditor/TriggerEditor.tsx
|
|
7
7
|
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
8
8
|
import React3, { useCallback as useCallback3, useMemo as useMemo3 } from "react";
|
|
9
9
|
import { ComputeGraph } from "@dxos/conductor";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { DXN } from "@dxos/echo";
|
|
11
|
+
import { Function, Script, Trigger as Trigger2 } from "@dxos/functions";
|
|
12
12
|
import { Filter as Filter2, Ref as Ref2, useQuery } from "@dxos/react-client/echo";
|
|
13
|
-
import { Input
|
|
14
|
-
import {
|
|
13
|
+
import { Input } from "@dxos/react-ui";
|
|
14
|
+
import { QueryForm } from "@dxos/react-ui-components";
|
|
15
15
|
import { Form as Form2, InputHeader, SelectInput as SelectInput2, useRefQueryLookupHandler } from "@dxos/react-ui-form";
|
|
16
|
-
import { inputTheme, mx } from "@dxos/react-ui-theme";
|
|
17
16
|
|
|
18
17
|
// src/components/TriggerEditor/FunctionInputEditor.tsx
|
|
19
18
|
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
@@ -86,7 +85,7 @@ var FunctionInputEditor = ({ functions, getValue, onValueChange, onQueryRefOptio
|
|
|
86
85
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
87
86
|
import React2, { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
88
87
|
import { Filter, Query } from "@dxos/echo";
|
|
89
|
-
import {
|
|
88
|
+
import { Trigger } from "@dxos/functions";
|
|
90
89
|
import { useTranslation } from "@dxos/react-ui";
|
|
91
90
|
import { SelectInput, useInputProps } from "@dxos/react-ui-form";
|
|
92
91
|
var SpecSelector = (props) => {
|
|
@@ -108,7 +107,6 @@ var SpecSelector = (props) => {
|
|
|
108
107
|
return {
|
|
109
108
|
kind: "subscription",
|
|
110
109
|
query: {
|
|
111
|
-
string: "Query.select(Filter.nothing())",
|
|
112
110
|
ast: Query.select(Filter.nothing()).ast
|
|
113
111
|
}
|
|
114
112
|
};
|
|
@@ -137,7 +135,7 @@ var SpecSelector = (props) => {
|
|
|
137
135
|
}, [
|
|
138
136
|
specProps
|
|
139
137
|
]);
|
|
140
|
-
const options = useMemo2(() =>
|
|
138
|
+
const options = useMemo2(() => Trigger.Kinds.map((kind) => ({
|
|
141
139
|
value: kind,
|
|
142
140
|
label: t(`trigger type ${kind}`)
|
|
143
141
|
})), [
|
|
@@ -154,10 +152,10 @@ var SpecSelector = (props) => {
|
|
|
154
152
|
};
|
|
155
153
|
|
|
156
154
|
// src/components/TriggerEditor/TriggerEditor.tsx
|
|
157
|
-
var TriggerEditor = ({ space, trigger, readonlySpec, onSave, onCancel }) => {
|
|
155
|
+
var TriggerEditor = ({ space, trigger, readonlySpec, types, tags, onSave, onCancel }) => {
|
|
158
156
|
var _effect = _useSignals3();
|
|
159
157
|
try {
|
|
160
|
-
const handleSave = (values) => {
|
|
158
|
+
const handleSave = ({ id: _, ...values }) => {
|
|
161
159
|
onSave?.(values);
|
|
162
160
|
};
|
|
163
161
|
const handleRefQueryLookup = useRefQueryLookupHandler({
|
|
@@ -166,12 +164,14 @@ var TriggerEditor = ({ space, trigger, readonlySpec, onSave, onCancel }) => {
|
|
|
166
164
|
const Custom = useCustomInputs({
|
|
167
165
|
space,
|
|
168
166
|
readonlySpec,
|
|
167
|
+
types,
|
|
168
|
+
tags,
|
|
169
169
|
onQueryRefOptions: handleRefQueryLookup
|
|
170
170
|
});
|
|
171
171
|
return /* @__PURE__ */ React3.createElement(Form2, {
|
|
172
172
|
outerSpacing: false,
|
|
173
173
|
Custom,
|
|
174
|
-
schema:
|
|
174
|
+
schema: Trigger2.Trigger,
|
|
175
175
|
values: trigger,
|
|
176
176
|
onSave: handleSave,
|
|
177
177
|
onCancel,
|
|
@@ -181,11 +181,10 @@ var TriggerEditor = ({ space, trigger, readonlySpec, onSave, onCancel }) => {
|
|
|
181
181
|
_effect.f();
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
var useCustomInputs = ({ space, readonlySpec, onQueryRefOptions }) => {
|
|
185
|
-
const
|
|
186
|
-
const functions = useQuery(space, Filter2.type(FunctionType));
|
|
184
|
+
var useCustomInputs = ({ space, readonlySpec, types, tags, onQueryRefOptions }) => {
|
|
185
|
+
const functions = useQuery(space, Filter2.type(Function.Function));
|
|
187
186
|
const workflows = useQuery(space, Filter2.type(ComputeGraph));
|
|
188
|
-
const scripts = useQuery(space, Filter2.type(
|
|
187
|
+
const scripts = useQuery(space, Filter2.type(Script.Script));
|
|
189
188
|
return useMemo3(() => ({
|
|
190
189
|
// Function selector.
|
|
191
190
|
["function"]: (props) => {
|
|
@@ -199,7 +198,7 @@ var useCustomInputs = ({ space, readonlySpec, onQueryRefOptions }) => {
|
|
|
199
198
|
props
|
|
200
199
|
]);
|
|
201
200
|
const handleOnValueChange = useCallback3((_type, dxnString) => {
|
|
202
|
-
const dxn =
|
|
201
|
+
const dxn = DXN.parse(dxnString);
|
|
203
202
|
if (dxn) {
|
|
204
203
|
const ref = Ref2.fromDXN(dxn);
|
|
205
204
|
props.onValueChange("object", ref);
|
|
@@ -222,32 +221,17 @@ var useCustomInputs = ({ space, readonlySpec, onQueryRefOptions }) => {
|
|
|
222
221
|
// TODO(wittjosiah): Copied from ViewEditor.
|
|
223
222
|
// Query input editor.
|
|
224
223
|
["spec.query"]: (props) => {
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
...value,
|
|
231
|
-
string: text
|
|
232
|
-
}), []);
|
|
233
|
-
const extensions = useMemo3(() => [
|
|
234
|
-
createBasicExtensions({
|
|
235
|
-
readOnly: readonlySpec,
|
|
236
|
-
placeholder: t("query placeholder")
|
|
237
|
-
}),
|
|
238
|
-
createThemeExtensions({
|
|
239
|
-
themeMode
|
|
240
|
-
})
|
|
241
|
-
], []);
|
|
224
|
+
const handleChange = useCallback3((query) => props.onValueChange("object", {
|
|
225
|
+
ast: query.ast
|
|
226
|
+
}), [
|
|
227
|
+
props.onValueChange
|
|
228
|
+
]);
|
|
242
229
|
return /* @__PURE__ */ React3.createElement(Input.Root, null, /* @__PURE__ */ React3.createElement(InputHeader, {
|
|
243
230
|
label: props.label
|
|
244
|
-
}), /* @__PURE__ */ React3.createElement(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}), "flex items-center", "focus-within:bg-focusSurface focus-within:border-separator focus-within:hover:bg-focusSurface"),
|
|
249
|
-
extensions,
|
|
250
|
-
value: value.string,
|
|
231
|
+
}), /* @__PURE__ */ React3.createElement(QueryForm, {
|
|
232
|
+
initialQuery: props.getValue().ast,
|
|
233
|
+
types,
|
|
234
|
+
tags,
|
|
251
235
|
onChange: handleChange
|
|
252
236
|
}));
|
|
253
237
|
},
|
|
@@ -281,4 +265,4 @@ var getFunctionOptions = (scripts, functions) => {
|
|
|
281
265
|
export {
|
|
282
266
|
TriggerEditor
|
|
283
267
|
};
|
|
284
|
-
//# sourceMappingURL=chunk-
|
|
268
|
+
//# sourceMappingURL=chunk-CF2SWXPW.mjs.map
|