@dxos/plugin-automation 0.8.2-staging.7ac8446 → 0.8.2
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-HQK7FTN6.mjs +40 -0
- package/dist/lib/browser/AutomationContainer-HQK7FTN6.mjs.map +7 -0
- package/dist/lib/browser/AutomationPanel-GU37N5LO.mjs +11 -0
- package/dist/lib/browser/AutomationPanel-GU37N5LO.mjs.map +7 -0
- package/dist/lib/browser/FunctionsContainer-B7RDWVMX.mjs +39 -0
- package/dist/lib/browser/FunctionsContainer-B7RDWVMX.mjs.map +7 -0
- package/dist/lib/browser/FunctionsPanel-LCCPDIT6.mjs +10 -0
- package/dist/lib/browser/FunctionsPanel-LCCPDIT6.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-BYECL42X.mjs +80 -0
- package/dist/lib/browser/app-graph-builder-BYECL42X.mjs.map +7 -0
- package/dist/lib/browser/chunk-4E2KPMLB.mjs +39 -0
- package/dist/lib/browser/chunk-4E2KPMLB.mjs.map +7 -0
- package/dist/lib/browser/chunk-4QTXMPBC.mjs +229 -0
- package/dist/lib/browser/chunk-4QTXMPBC.mjs.map +7 -0
- package/dist/lib/browser/chunk-D2ESAYQD.mjs +149 -0
- package/dist/lib/browser/chunk-D2ESAYQD.mjs.map +7 -0
- package/dist/lib/browser/chunk-ELQ2FX5G.mjs +14 -0
- package/dist/lib/browser/chunk-ELQ2FX5G.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WKKQV4PC.mjs → chunk-IHAKPP5A.mjs} +2 -2
- package/dist/lib/browser/{chunk-WKKQV4PC.mjs.map → chunk-IHAKPP5A.mjs.map} +1 -1
- package/dist/lib/browser/chunk-ZTRYR6RJ.mjs +94 -0
- package/dist/lib/browser/chunk-ZTRYR6RJ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +26 -20
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-ZRBBYZUX.mjs +77 -0
- package/dist/lib/browser/intent-resolver-ZRBBYZUX.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-VKO6PA2P.mjs +68 -0
- package/dist/lib/browser/react-surface-VKO6PA2P.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-5J7LJK7L.cjs +68 -0
- package/dist/lib/node/AutomationContainer-5J7LJK7L.cjs.map +7 -0
- package/dist/lib/node/AutomationPanel-NPDBUQ7D.cjs +32 -0
- package/dist/lib/node/AutomationPanel-NPDBUQ7D.cjs.map +7 -0
- package/dist/lib/node/FunctionsContainer-LNLDZUZ6.cjs +67 -0
- package/dist/lib/node/FunctionsContainer-LNLDZUZ6.cjs.map +7 -0
- package/dist/lib/node/FunctionsPanel-7AOXIQMA.cjs +31 -0
- package/dist/lib/node/FunctionsPanel-7AOXIQMA.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-DUKR2BRB.cjs +96 -0
- package/dist/lib/node/app-graph-builder-DUKR2BRB.cjs.map +7 -0
- package/dist/lib/node/{chunk-7GXNXMSM.cjs → chunk-3EF7MLFX.cjs} +5 -5
- package/dist/lib/node/{chunk-7GXNXMSM.cjs.map → chunk-3EF7MLFX.cjs.map} +1 -1
- package/dist/lib/node/chunk-4O627QZU.cjs +175 -0
- package/dist/lib/node/chunk-4O627QZU.cjs.map +7 -0
- package/dist/lib/node/{chunk-AGJ6XTDN.cjs → chunk-DOLMQUQ5.cjs} +16 -7
- package/dist/lib/node/chunk-DOLMQUQ5.cjs.map +7 -0
- package/dist/lib/node/chunk-GIIVTK4O.cjs +58 -0
- package/dist/lib/node/chunk-GIIVTK4O.cjs.map +7 -0
- package/dist/lib/node/chunk-O42NQYQT.cjs +252 -0
- package/dist/lib/node/chunk-O42NQYQT.cjs.map +7 -0
- package/dist/lib/node/chunk-WXQAVUBJ.cjs +122 -0
- package/dist/lib/node/chunk-WXQAVUBJ.cjs.map +7 -0
- package/dist/lib/node/index.cjs +37 -31
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/intent-resolver-JC4Q4TYU.cjs +93 -0
- package/dist/lib/node/intent-resolver-JC4Q4TYU.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-52M54VWV.cjs → react-surface-HB3MYTCK.cjs} +41 -17
- package/dist/lib/node/react-surface-HB3MYTCK.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-OJGH76X2.mjs +41 -0
- package/dist/lib/node-esm/AutomationContainer-OJGH76X2.mjs.map +7 -0
- package/dist/lib/node-esm/AutomationPanel-HIWEJUWL.mjs +12 -0
- package/dist/lib/node-esm/AutomationPanel-HIWEJUWL.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsContainer-PPR6XNNR.mjs +40 -0
- package/dist/lib/node-esm/FunctionsContainer-PPR6XNNR.mjs.map +7 -0
- package/dist/lib/node-esm/FunctionsPanel-SBXKWTHR.mjs +11 -0
- package/dist/lib/node-esm/FunctionsPanel-SBXKWTHR.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-UAXHKKGW.mjs +81 -0
- package/dist/lib/node-esm/app-graph-builder-UAXHKKGW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5IAHBEHR.mjs +95 -0
- package/dist/lib/node-esm/chunk-5IAHBEHR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6JOJ2NN4.mjs +40 -0
- package/dist/lib/node-esm/chunk-6JOJ2NN4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D5HK4XLC.mjs +230 -0
- package/dist/lib/node-esm/chunk-D5HK4XLC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-DZ44LGYT.mjs → chunk-HCCLRNMJ.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-DZ44LGYT.mjs.map → chunk-HCCLRNMJ.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-P2FKMPRE.mjs +150 -0
- package/dist/lib/node-esm/chunk-P2FKMPRE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-Z7VAQDEE.mjs +16 -0
- package/dist/lib/node-esm/chunk-Z7VAQDEE.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +26 -20
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-KRCXJEDR.mjs +78 -0
- package/dist/lib/node-esm/intent-resolver-KRCXJEDR.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-TRKCIZAB.mjs +69 -0
- package/dist/lib/node-esm/react-surface-TRKCIZAB.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 +2 -179
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +2 -177
- 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/AutomationPanel.stories.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/FunctionInputEditor.d.ts +12 -0
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.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/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +38 -25
- package/src/AutomationPlugin.tsx +5 -10
- package/src/capabilities/app-graph-builder.ts +72 -17
- 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 +6 -5
- package/src/components/AutomationPanel/AutomationPanel.tsx +77 -73
- 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/FunctionInputEditor.tsx +77 -0
- package/src/components/TriggerEditor/SpecSelector.tsx +59 -0
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +19 -10
- package/src/components/TriggerEditor/TriggerEditor.tsx +64 -102
- package/src/components/index.ts +3 -0
- package/src/meta.ts +1 -1
- 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 +0 -139
- package/dist/lib/browser/AutomationPanel-YAHFXQX6.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-K3BIQFWW.mjs +0 -40
- 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 +0 -161
- package/dist/lib/node/AutomationPanel-ZKAMIU6O.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-HO4FPGZ5.cjs +0 -56
- 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 +0 -140
- package/dist/lib/node-esm/AutomationPanel-XF7YPSKM.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-XCJR33VS.mjs +0 -41
- 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
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TriggerEditor
|
|
3
|
+
} from "./chunk-4QTXMPBC.mjs";
|
|
4
|
+
import {
|
|
5
|
+
AUTOMATION_PLUGIN
|
|
6
|
+
} from "./chunk-IHAKPP5A.mjs";
|
|
7
|
+
|
|
8
|
+
// packages/plugins/plugin-automation/src/components/AutomationPanel/AutomationPanel.tsx
|
|
9
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
10
|
+
import { Schema } from "effect";
|
|
11
|
+
import React, { useState } from "react";
|
|
12
|
+
import { FunctionType, FunctionTrigger, FunctionTriggerSchema, TriggerKind, ScriptType } from "@dxos/functions";
|
|
13
|
+
import { useClient } from "@dxos/react-client";
|
|
14
|
+
import { live, Filter, useQuery, getSpace } from "@dxos/react-client/echo";
|
|
15
|
+
import { Clipboard, IconButton, Input, Separator, useTranslation } from "@dxos/react-ui";
|
|
16
|
+
import { ControlItem, controlItemClasses } from "@dxos/react-ui-form";
|
|
17
|
+
import { List } from "@dxos/react-ui-list";
|
|
18
|
+
import { ghostHover, mx } from "@dxos/react-ui-theme";
|
|
19
|
+
var grid = "grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]";
|
|
20
|
+
var AutomationPanel = ({ space, object, initialTrigger, onDone }) => {
|
|
21
|
+
var _effect = _useSignals();
|
|
22
|
+
try {
|
|
23
|
+
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
24
|
+
const client = useClient();
|
|
25
|
+
const triggers = useQuery(space, Filter.type(FunctionTrigger));
|
|
26
|
+
const functions = useQuery(space, Filter.type(FunctionType));
|
|
27
|
+
const scripts = useQuery(space, Filter.type(ScriptType));
|
|
28
|
+
const [trigger, setTrigger] = useState(initialTrigger);
|
|
29
|
+
const [selected, setSelected] = useState();
|
|
30
|
+
const handleSelect = (trigger2) => {
|
|
31
|
+
const { id: _, ...values } = trigger2;
|
|
32
|
+
setTrigger(values);
|
|
33
|
+
setSelected(trigger2);
|
|
34
|
+
};
|
|
35
|
+
const handleAdd = () => {
|
|
36
|
+
setTrigger(live(FunctionTriggerSchema, {}));
|
|
37
|
+
setSelected(void 0);
|
|
38
|
+
};
|
|
39
|
+
const handleDelete = (trigger2) => {
|
|
40
|
+
space.db.remove(trigger2);
|
|
41
|
+
setTrigger(void 0);
|
|
42
|
+
setSelected(void 0);
|
|
43
|
+
};
|
|
44
|
+
const handleSave = (trigger2) => {
|
|
45
|
+
if (selected) {
|
|
46
|
+
Object.assign(selected, trigger2);
|
|
47
|
+
} else {
|
|
48
|
+
space.db.add(live(FunctionTrigger, trigger2));
|
|
49
|
+
}
|
|
50
|
+
setTrigger(void 0);
|
|
51
|
+
setSelected(void 0);
|
|
52
|
+
onDone?.();
|
|
53
|
+
};
|
|
54
|
+
const handleCancel = () => {
|
|
55
|
+
setTrigger(void 0);
|
|
56
|
+
onDone?.();
|
|
57
|
+
};
|
|
58
|
+
if (trigger) {
|
|
59
|
+
return /* @__PURE__ */ React.createElement(ControlItem, {
|
|
60
|
+
title: t("trigger editor title")
|
|
61
|
+
}, /* @__PURE__ */ React.createElement(TriggerEditor, {
|
|
62
|
+
space,
|
|
63
|
+
trigger,
|
|
64
|
+
onSave: handleSave,
|
|
65
|
+
onCancel: handleCancel
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
69
|
+
className: "flex flex-col w-full"
|
|
70
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
71
|
+
role: "none",
|
|
72
|
+
className: controlItemClasses
|
|
73
|
+
}, triggers.length > 0 && /* @__PURE__ */ React.createElement(List.Root, {
|
|
74
|
+
items: triggers,
|
|
75
|
+
isItem: Schema.is(FunctionTrigger),
|
|
76
|
+
getId: (field) => field.id
|
|
77
|
+
}, ({ items: triggers2 }) => /* @__PURE__ */ React.createElement("div", {
|
|
78
|
+
role: "list",
|
|
79
|
+
className: "flex flex-col w-full"
|
|
80
|
+
}, triggers2?.map((trigger2) => {
|
|
81
|
+
const copyAction = getCopyAction(client, trigger2);
|
|
82
|
+
return /* @__PURE__ */ React.createElement(List.Item, {
|
|
83
|
+
key: trigger2.id,
|
|
84
|
+
item: trigger2,
|
|
85
|
+
classNames: mx(grid, ghostHover, "items-center", "px-2")
|
|
86
|
+
}, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.Switch, {
|
|
87
|
+
checked: trigger2.enabled,
|
|
88
|
+
onCheckedChange: (checked) => trigger2.enabled = checked
|
|
89
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
90
|
+
className: "flex"
|
|
91
|
+
}, /* @__PURE__ */ React.createElement(List.ItemTitle, {
|
|
92
|
+
classNames: "px-1 cursor-pointer w-0 shrink truncate",
|
|
93
|
+
onClick: () => handleSelect(trigger2)
|
|
94
|
+
}, getFunctionName(scripts, functions, trigger2) ?? "\u2205"), copyAction && /* @__PURE__ */ React.createElement(Clipboard.IconButton, {
|
|
95
|
+
label: t(copyAction.translationKey),
|
|
96
|
+
value: copyAction.contentProvider()
|
|
97
|
+
})), /* @__PURE__ */ React.createElement(List.ItemDeleteButton, {
|
|
98
|
+
onClick: () => handleDelete(trigger2)
|
|
99
|
+
}));
|
|
100
|
+
}))), triggers.length > 0 && /* @__PURE__ */ React.createElement(Separator, {
|
|
101
|
+
classNames: "mlb-4"
|
|
102
|
+
}), /* @__PURE__ */ React.createElement(IconButton, {
|
|
103
|
+
icon: "ph--plus--regular",
|
|
104
|
+
label: t("new trigger label"),
|
|
105
|
+
onClick: handleAdd
|
|
106
|
+
})));
|
|
107
|
+
} finally {
|
|
108
|
+
_effect.f();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
var getCopyAction = (client, trigger) => {
|
|
112
|
+
if (trigger?.spec?.kind === TriggerKind.Email) {
|
|
113
|
+
return {
|
|
114
|
+
translationKey: "trigger copy email",
|
|
115
|
+
contentProvider: () => `${getSpace(trigger).id}@dxos.network`
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (trigger?.spec?.kind === TriggerKind.Webhook) {
|
|
119
|
+
return {
|
|
120
|
+
translationKey: "trigger copy url",
|
|
121
|
+
contentProvider: () => getWebhookUrl(client, trigger)
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return void 0;
|
|
125
|
+
};
|
|
126
|
+
var getWebhookUrl = (client, trigger) => {
|
|
127
|
+
const spaceId = getSpace(trigger).id;
|
|
128
|
+
const edgeUrl = new URL(client.config.values.runtime.services.edge.url);
|
|
129
|
+
const isSecure = edgeUrl.protocol.startsWith("https") || edgeUrl.protocol.startsWith("wss");
|
|
130
|
+
edgeUrl.protocol = isSecure ? "https" : "http";
|
|
131
|
+
return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();
|
|
132
|
+
};
|
|
133
|
+
var getFunctionName = (scripts, functions, trigger) => {
|
|
134
|
+
const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}\u2026`;
|
|
135
|
+
const functionObject = functions.find((fn) => fn === trigger.function?.target);
|
|
136
|
+
if (!functionObject) {
|
|
137
|
+
return shortId;
|
|
138
|
+
}
|
|
139
|
+
return scripts.find((s) => functionObject.source?.target?.id === s.id)?.name ?? shortId;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// packages/plugins/plugin-automation/src/components/AutomationPanel/index.ts
|
|
143
|
+
var AutomationPanel_default = AutomationPanel;
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
AutomationPanel,
|
|
147
|
+
AutomationPanel_default
|
|
148
|
+
};
|
|
149
|
+
//# sourceMappingURL=chunk-D2ESAYQD.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/AutomationPanel/AutomationPanel.tsx", "../../../src/components/AutomationPanel/index.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { Schema } from 'effect';\nimport React, { useState } from 'react';\n\nimport {\n FunctionType,\n FunctionTrigger,\n FunctionTriggerSchema,\n TriggerKind,\n type FunctionTriggerType,\n ScriptType,\n} from '@dxos/functions';\nimport { type Client, useClient } from '@dxos/react-client';\nimport { live, Filter, useQuery, type Space, type Live, getSpace } from '@dxos/react-client/echo';\nimport { Clipboard, IconButton, Input, Separator, useTranslation } from '@dxos/react-ui';\nimport { ControlItem, controlItemClasses } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/react-ui-theme';\n\nimport { AUTOMATION_PLUGIN } from '../../meta';\nimport { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';\n\nconst grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';\n\nexport type AutomationPanelProps = {\n space: Space;\n object?: Live<any>;\n initialTrigger?: FunctionTriggerType;\n onDone?: () => void;\n};\n\n// TODO(burdon): Factor out common layout with ViewEditor.\nexport const AutomationPanel = ({ space, object, initialTrigger, onDone }: AutomationPanelProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const client = useClient();\n const triggers = useQuery(space, Filter.type(FunctionTrigger));\n const functions = useQuery(space, Filter.type(FunctionType));\n const scripts = useQuery(space, Filter.type(ScriptType));\n\n const [trigger, setTrigger] = useState<FunctionTriggerType | undefined>(initialTrigger);\n const [selected, setSelected] = useState<FunctionTrigger>();\n\n const handleSelect = (trigger: FunctionTrigger) => {\n const { id: _, ...values } = trigger;\n setTrigger(values);\n setSelected(trigger);\n };\n\n const handleAdd = () => {\n setTrigger(live(FunctionTriggerSchema, {}));\n setSelected(undefined);\n };\n\n const handleDelete = (trigger: FunctionTrigger) => {\n space.db.remove(trigger);\n setTrigger(undefined);\n setSelected(undefined);\n };\n\n const handleSave: TriggerEditorProps['onSave'] = (trigger) => {\n if (selected) {\n Object.assign(selected, trigger);\n } else {\n space.db.add(live(FunctionTrigger, trigger));\n }\n\n setTrigger(undefined);\n setSelected(undefined);\n onDone?.();\n };\n\n const handleCancel: TriggerEditorProps['onCancel'] = () => {\n setTrigger(undefined);\n onDone?.();\n };\n\n if (trigger) {\n return (\n <ControlItem title={t('trigger editor title')}>\n <TriggerEditor space={space} trigger={trigger} onSave={handleSave} onCancel={handleCancel} />\n </ControlItem>\n );\n }\n\n return (\n <div className='flex flex-col w-full'>\n <div role='none' className={controlItemClasses}>\n {triggers.length > 0 && (\n <List.Root<FunctionTrigger> items={triggers} isItem={Schema.is(FunctionTrigger)} getId={(field) => field.id}>\n {({ items: triggers }) => (\n <div role='list' className='flex flex-col w-full'>\n {triggers?.map((trigger) => {\n const copyAction = getCopyAction(client, trigger);\n return (\n <List.Item<FunctionTrigger>\n key={trigger.id}\n item={trigger}\n classNames={mx(grid, ghostHover, 'items-center', 'px-2')}\n >\n <Input.Root>\n <Input.Switch\n checked={trigger.enabled}\n onCheckedChange={(checked) => (trigger.enabled = checked)}\n />\n </Input.Root>\n\n <div className={'flex'}>\n <List.ItemTitle\n classNames='px-1 cursor-pointer w-0 shrink truncate'\n onClick={() => handleSelect(trigger)}\n >\n {getFunctionName(scripts, functions, trigger) ?? '∅'}\n </List.ItemTitle>\n\n {/* TODO: a better way to expose copy action */}\n {copyAction && (\n <Clipboard.IconButton\n label={t(copyAction.translationKey)}\n value={copyAction.contentProvider()}\n />\n )}\n </div>\n\n <List.ItemDeleteButton onClick={() => handleDelete(trigger)} />\n </List.Item>\n );\n })}\n </div>\n )}\n </List.Root>\n )}\n {triggers.length > 0 && <Separator classNames='mlb-4' />}\n <IconButton icon='ph--plus--regular' label={t('new trigger label')} onClick={handleAdd} />\n </div>\n </div>\n );\n};\n\nconst getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) => {\n if (trigger?.spec?.kind === TriggerKind.Email) {\n return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };\n }\n\n if (trigger?.spec?.kind === TriggerKind.Webhook) {\n return { translationKey: 'trigger copy url', contentProvider: () => getWebhookUrl(client, trigger) };\n }\n\n return undefined;\n};\n\nconst getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {\n const spaceId = getSpace(trigger)!.id;\n const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);\n const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');\n edgeUrl.protocol = isSecure ? 'https' : 'http';\n return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();\n};\n\nconst getFunctionName = (scripts: ScriptType[], functions: FunctionType[], trigger: FunctionTriggerType) => {\n // TODO(wittjosiah): Truncation should be done in the UI.\n // Warning that the List component is currently a can of worms.\n const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}…`;\n const functionObject = functions.find((fn) => fn === trigger.function?.target);\n if (!functionObject) {\n return shortId;\n }\n\n return scripts.find((s) => functionObject.source?.target?.id === s.id)?.name ?? shortId;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { AutomationPanel } from './AutomationPanel';\n\nexport * from './AutomationPanel';\n\nexport default AutomationPanel;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAIA,SAASA,cAAc;AACvB,OAAOC,SAASC,gBAAgB;AAEhC,SACEC,cACAC,iBACAC,uBACAC,aAEAC,kBACK;AACP,SAAsBC,iBAAiB;AACvC,SAASC,MAAMC,QAAQC,UAAiCC,gBAAgB;AACxE,SAASC,WAAWC,YAAYC,OAAOC,WAAWC,sBAAsB;AACxE,SAASC,aAAaC,0BAA0B;AAChD,SAASC,YAAY;AACrB,SAASC,YAAYC,UAAU;AAK/B,IAAMC,OAAO;AAUN,IAAM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"FunctionTrigger", "FunctionTriggerSchema", "TriggerKind", "ScriptType", "useClient", "live", "Filter", "useQuery", "getSpace", "Clipboard", "IconButton", "Input", "Separator", "useTranslation", "ControlItem", "controlItemClasses", "List", "ghostHover", "mx", "grid", "AutomationPanel", "space", "object", "initialTrigger", "onDone", "t", "useTranslation", "AUTOMATION_PLUGIN", "client", "useClient", "triggers", "useQuery", "Filter", "type", "FunctionTrigger", "functions", "FunctionType", "scripts", "ScriptType", "trigger", "setTrigger", "useState", "selected", "setSelected", "handleSelect", "id", "_", "values", "handleAdd", "live", "FunctionTriggerSchema", "undefined", "handleDelete", "db", "remove", "handleSave", "Object", "assign", "add", "handleCancel", "ControlItem", "title", "TriggerEditor", "onSave", "onCancel", "div", "className", "role", "controlItemClasses", "length", "List", "Root", "items", "isItem", "Schema", "is", "getId", "field", "map", "copyAction", "getCopyAction", "Item", "key", "item", "classNames", "mx", "ghostHover", "Input", "Switch", "checked", "enabled", "onCheckedChange", "ItemTitle", "onClick", "getFunctionName", "Clipboard", "IconButton", "label", "translationKey", "value", "contentProvider", "ItemDeleteButton", "Separator", "icon", "spec", "kind", "TriggerKind", "Email", "getSpace", "Webhook", "getWebhookUrl", "spaceId", "edgeUrl", "URL", "config", "runtime", "services", "edge", "url", "isSecure", "protocol", "startsWith", "toString", "shortId", "function", "dxn", "slice", "functionObject", "find", "fn", "target", "s", "source", "name", "AutomationPanel"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// packages/plugins/plugin-automation/src/components/index.ts
|
|
2
|
+
import { lazy } from "react";
|
|
3
|
+
var AutomationContainer = lazy(() => import("./AutomationContainer-HQK7FTN6.mjs"));
|
|
4
|
+
var AutomationPanel = lazy(() => import("./AutomationPanel-GU37N5LO.mjs"));
|
|
5
|
+
var FunctionsContainer = lazy(() => import("./FunctionsContainer-B7RDWVMX.mjs"));
|
|
6
|
+
var FunctionsPanel = lazy(() => import("./FunctionsPanel-LCCPDIT6.mjs"));
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
AutomationContainer,
|
|
10
|
+
AutomationPanel,
|
|
11
|
+
FunctionsContainer,
|
|
12
|
+
FunctionsPanel
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-ELQ2FX5G.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
|
+
}
|
|
@@ -5,11 +5,11 @@ var meta = {
|
|
|
5
5
|
name: "Automation",
|
|
6
6
|
description: "The Automation tab allows you to trigger pre-defined workflows related to the element you are interacting with inside of Composer.",
|
|
7
7
|
icon: "ph--robot--regular",
|
|
8
|
-
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/
|
|
8
|
+
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation"
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
12
|
AUTOMATION_PLUGIN,
|
|
13
13
|
meta
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=chunk-
|
|
15
|
+
//# sourceMappingURL=chunk-IHAKPP5A.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';\n\nexport const meta: PluginMeta = {\n id: AUTOMATION_PLUGIN,\n name: 'Automation',\n description:\n 'The Automation tab allows you to trigger pre-defined workflows related to the element you are interacting with inside of Composer.',\n icon: 'ph--robot--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';\n\nexport const meta: PluginMeta = {\n id: AUTOMATION_PLUGIN,\n name: 'Automation',\n description:\n 'The Automation tab allows you to trigger pre-defined workflows related to the element you are interacting with inside of Composer.',\n icon: 'ph--robot--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',\n};\n"],
|
|
5
5
|
"mappings": ";AAMO,IAAMA,oBAAoB;AAE1B,IAAMC,OAAmB;EAC9BC,IAAIF;EACJG,MAAM;EACNC,aACE;EACFC,MAAM;EACNC,QAAQ;AACV;",
|
|
6
6
|
"names": ["AUTOMATION_PLUGIN", "meta", "id", "name", "description", "icon", "source"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTOMATION_PLUGIN
|
|
3
|
+
} from "./chunk-IHAKPP5A.mjs";
|
|
4
|
+
|
|
5
|
+
// packages/plugins/plugin-automation/src/components/FunctionsPanel/FunctionsPanel.tsx
|
|
6
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
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
|
+
var _effect = _useSignals();
|
|
19
|
+
try {
|
|
20
|
+
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
21
|
+
const functions = useQuery(space, Filter.type(FunctionType));
|
|
22
|
+
const scripts = useQuery(space, Filter.type(ScriptType));
|
|
23
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
24
|
+
const functionToScriptMap = useMemo(() => functions.reduce((map, func) => {
|
|
25
|
+
const scriptId = func.source?.target?.id;
|
|
26
|
+
if (scriptId) {
|
|
27
|
+
const script = scripts.find((s) => s.id === scriptId);
|
|
28
|
+
if (script) {
|
|
29
|
+
map[func.id] = script;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return map;
|
|
33
|
+
}, {}), [
|
|
34
|
+
functions,
|
|
35
|
+
scripts
|
|
36
|
+
]);
|
|
37
|
+
const getScriptName = useCallback((func) => {
|
|
38
|
+
const script = functionToScriptMap[func.id];
|
|
39
|
+
return script?.name;
|
|
40
|
+
}, [
|
|
41
|
+
functionToScriptMap
|
|
42
|
+
]);
|
|
43
|
+
const handleGoToScript = useCallback((func) => {
|
|
44
|
+
const script = functionToScriptMap[func.id];
|
|
45
|
+
if (script) {
|
|
46
|
+
void dispatch(createIntent(LayoutAction.Open, {
|
|
47
|
+
part: "main",
|
|
48
|
+
subject: [
|
|
49
|
+
fullyQualifiedId(script)
|
|
50
|
+
]
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
}, [
|
|
54
|
+
functionToScriptMap,
|
|
55
|
+
dispatch
|
|
56
|
+
]);
|
|
57
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
58
|
+
role: "none",
|
|
59
|
+
className: mx(controlItemClasses)
|
|
60
|
+
}, /* @__PURE__ */ React.createElement(List.Root, {
|
|
61
|
+
items: functions,
|
|
62
|
+
isItem: Schema.is(FunctionType),
|
|
63
|
+
getId: (func) => func.id
|
|
64
|
+
}, ({ items }) => /* @__PURE__ */ React.createElement("div", {
|
|
65
|
+
role: "list",
|
|
66
|
+
className: "flex flex-col w-full"
|
|
67
|
+
}, items?.map((func) => /* @__PURE__ */ React.createElement(List.Item, {
|
|
68
|
+
key: func.id,
|
|
69
|
+
item: func,
|
|
70
|
+
classNames: mx(grid, ghostHover, "items-center", "pli-2", "min-bs-[3rem]")
|
|
71
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
72
|
+
className: "flex flex-col truncate"
|
|
73
|
+
}, /* @__PURE__ */ React.createElement(List.ItemTitle, {
|
|
74
|
+
classNames: "truncate"
|
|
75
|
+
}, func.name), getScriptName(func) && /* @__PURE__ */ React.createElement("div", {
|
|
76
|
+
className: "text-xs text-description truncate"
|
|
77
|
+
}, getScriptName(func))), functionToScriptMap[func.id] && /* @__PURE__ */ React.createElement(Button, {
|
|
78
|
+
onClick: () => handleGoToScript(func)
|
|
79
|
+
}, t("go to function source button label")))))), functions.length === 0 && /* @__PURE__ */ React.createElement("div", {
|
|
80
|
+
className: "text-center plb-4 text-gray-500"
|
|
81
|
+
}, t("no functions found")));
|
|
82
|
+
} finally {
|
|
83
|
+
_effect.f();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// packages/plugins/plugin-automation/src/components/FunctionsPanel/index.ts
|
|
88
|
+
var FunctionsPanel_default = FunctionsPanel;
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
FunctionsPanel,
|
|
92
|
+
FunctionsPanel_default
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=chunk-ZTRYR6RJ.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.type(FunctionType));\n const scripts = useQuery(space, Filter.type(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,UAAM,EAAEC,EAAC,IAAKC,eAAeC,iBAAAA;AAC7B,U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,KAAKI;MACV4B,MAAMhC;MACNiC,YAAYZ,GAAGzC,MAAMsD,YAAY,gBAAgB,SAAS,eAAA;OAE1D,sBAAA,cAAChB,OAAAA;MAAIE,WAAU;OACb,sBAAA,cAACG,KAAKY,WAAS;MAACF,YAAW;OAAYjC,KAAKU,IAAI,GAC/CF,cAAcR,IAAAA,KACb,sBAAA,cAACkB,OAAAA;MAAIE,WAAU;OAAqCZ,cAAcR,IAAAA,CAAAA,CAAAA,GAGrEJ,oBAAoBI,KAAKI,EAAE,KAC1B,sBAAA,cAACgC,QAAAA;MAAOC,SAAS,MAAM1B,iBAAiBX,IAAAA;OAAQjB,EAAE,oCAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAQ7DG,UAAUoD,WAAW,KAAK,sBAAA,cAACpB,OAAAA;MAAIE,WAAU;OAAmCrC,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", "type", "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,24 +1,27 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
AutomationContainer,
|
|
3
|
+
AutomationPanel,
|
|
4
|
+
FunctionsContainer,
|
|
5
|
+
FunctionsPanel
|
|
6
|
+
} from "./chunk-ELQ2FX5G.mjs";
|
|
4
7
|
import {
|
|
5
8
|
TriggerEditor
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4QTXMPBC.mjs";
|
|
7
10
|
import {
|
|
8
11
|
AUTOMATION_PLUGIN,
|
|
9
12
|
meta
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-IHAKPP5A.mjs";
|
|
11
14
|
|
|
12
15
|
// packages/plugins/plugin-automation/src/AutomationPlugin.tsx
|
|
13
16
|
import { Capabilities, contributes, defineModule, definePlugin, Events } from "@dxos/app-framework";
|
|
14
|
-
import { FunctionType, FunctionTrigger } from "@dxos/functions
|
|
17
|
+
import { FunctionType, FunctionTrigger } from "@dxos/functions";
|
|
15
18
|
import { ClientCapabilities, ClientEvents } from "@dxos/plugin-client";
|
|
16
|
-
import { SpaceCapabilities, SpaceEvents } from "@dxos/plugin-space";
|
|
17
19
|
|
|
18
20
|
// packages/plugins/plugin-automation/src/capabilities/index.ts
|
|
19
21
|
import { lazy } from "@dxos/app-framework";
|
|
20
|
-
var AppGraphBuilder = lazy(() => import("./app-graph-builder-
|
|
21
|
-
var
|
|
22
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-BYECL42X.mjs"));
|
|
23
|
+
var IntentResolver = lazy(() => import("./intent-resolver-ZRBBYZUX.mjs"));
|
|
24
|
+
var ReactSurface = lazy(() => import("./react-surface-VKO6PA2P.mjs"));
|
|
22
25
|
|
|
23
26
|
// packages/plugins/plugin-automation/src/translations.ts
|
|
24
27
|
var translations_default = [
|
|
@@ -28,7 +31,15 @@ var translations_default = [
|
|
|
28
31
|
"plugin name": "Automation",
|
|
29
32
|
"automation panel label": "Automations",
|
|
30
33
|
"script automation label": "Automation",
|
|
31
|
-
"
|
|
34
|
+
"automation verbose label": "Manage automations",
|
|
35
|
+
"automation description": "You can manage all the triggers which automate your space here.",
|
|
36
|
+
"functions panel label": "Functions",
|
|
37
|
+
"functions verbose label": "Manage deployed functions",
|
|
38
|
+
"functions description": "You can manage all the functions deployed from your space on EDGE here.",
|
|
39
|
+
"function copy id": "Copy Function ID",
|
|
40
|
+
"no functions found": "No functions found",
|
|
41
|
+
"go to function source button label": "Show function source",
|
|
42
|
+
"trigger editor title": "Configure Trigger",
|
|
32
43
|
"new trigger label": "Add Trigger",
|
|
33
44
|
"trigger type timer": "Timer",
|
|
34
45
|
"trigger type webhook": "Webhook",
|
|
@@ -67,17 +78,9 @@ var AutomationPlugin = () => definePlugin(meta, [
|
|
|
67
78
|
activate: AppGraphBuilder
|
|
68
79
|
}),
|
|
69
80
|
defineModule({
|
|
70
|
-
id: `${meta.id}/module/
|
|
71
|
-
activatesOn:
|
|
72
|
-
activate:
|
|
73
|
-
id: "automation",
|
|
74
|
-
label: [
|
|
75
|
-
"automation panel label",
|
|
76
|
-
{
|
|
77
|
-
ns: meta.id
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
})
|
|
81
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
82
|
+
activatesOn: Events.SetupIntentResolver,
|
|
83
|
+
activate: IntentResolver
|
|
81
84
|
}),
|
|
82
85
|
defineModule({
|
|
83
86
|
id: `${meta.id}/module/react-surface`,
|
|
@@ -87,8 +90,11 @@ var AutomationPlugin = () => definePlugin(meta, [
|
|
|
87
90
|
]);
|
|
88
91
|
export {
|
|
89
92
|
AUTOMATION_PLUGIN,
|
|
93
|
+
AutomationContainer,
|
|
90
94
|
AutomationPanel,
|
|
91
95
|
AutomationPlugin,
|
|
96
|
+
FunctionsContainer,
|
|
97
|
+
FunctionsPanel,
|
|
92
98
|
TriggerEditor,
|
|
93
99
|
meta
|
|
94
100
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/AutomationPlugin.tsx", "../../../src/capabilities/index.ts", "../../../src/translations.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Capabilities, contributes, defineModule, definePlugin, Events } from '@dxos/app-framework';\nimport { FunctionType, FunctionTrigger } from '@dxos/functions
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["Capabilities", "contributes", "defineModule", "definePlugin", "Events", "FunctionType", "FunctionTrigger", "ClientCapabilities", "ClientEvents", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Capabilities, contributes, defineModule, definePlugin, Events } from '@dxos/app-framework';\nimport { FunctionType, FunctionTrigger } from '@dxos/functions';\nimport { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';\n\nimport { AppGraphBuilder, IntentResolver, ReactSurface } from './capabilities';\nimport { meta } from './meta';\nimport translations from './translations';\n\nexport const AutomationPlugin = () =>\n definePlugin(meta, [\n defineModule({\n id: `${meta.id}/module/translations`,\n activatesOn: Events.SetupTranslations,\n activate: () => contributes(Capabilities.Translations, translations),\n }),\n defineModule({\n id: `${meta.id}/module/schema`,\n activatesOn: ClientEvents.SetupSchema,\n activate: () => contributes(ClientCapabilities.Schema, [FunctionType, FunctionTrigger]),\n }),\n defineModule({\n id: `${meta.id}/module/app-graph-builder`,\n activatesOn: Events.SetupAppGraph,\n activate: AppGraphBuilder,\n }),\n defineModule({\n id: `${meta.id}/module/intent-resolver`,\n activatesOn: Events.SetupIntentResolver,\n activate: IntentResolver,\n }),\n defineModule({\n id: `${meta.id}/module/react-surface`,\n activatesOn: Events.SetupReactSurface,\n activate: ReactSurface,\n }),\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 IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { AUTOMATION_PLUGIN } from './meta';\n\nexport default [\n {\n 'en-US': {\n [AUTOMATION_PLUGIN]: {\n 'plugin name': 'Automation',\n 'automation panel label': 'Automations',\n 'script automation label': 'Automation',\n 'automation verbose label': 'Manage automations',\n 'automation description': 'You can manage all the triggers which automate your space here.',\n\n 'functions panel label': 'Functions',\n 'functions verbose label': 'Manage deployed functions',\n 'functions description': 'You can manage all the functions deployed from your space on EDGE here.',\n 'function copy id': 'Copy Function ID',\n 'no functions found': 'No functions found',\n 'go to function source button label': 'Show function source',\n\n 'trigger editor title': 'Configure Trigger',\n 'new trigger label': 'Add Trigger',\n 'trigger type timer': 'Timer',\n 'trigger type webhook': 'Webhook',\n 'trigger type websocket': 'Websocket',\n 'trigger type subscription': 'Subscription',\n 'trigger type email': 'Email',\n 'trigger type queue': 'Queue',\n\n 'trigger copy url': 'Copy URL',\n 'trigger copy email': 'Copy Email',\n\n 'trigger payload add': 'Add',\n 'trigger payload remove': 'Remove',\n 'trigger payload prop name placeholder': 'New payload property name',\n },\n },\n },\n];\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAIA,SAASA,cAAcC,aAAaC,cAAcC,cAAcC,cAAc;AAC9E,SAASC,cAAcC,uBAAuB;AAC9C,SAASC,oBAAoBC,oBAAoB;;;ACFjD,SAASC,YAAY;AAEd,IAAMC,kBAAkBC,KAAK,MAAM,OAAO,kCAAA,CAAA;AAC1C,IAAMC,iBAAiBD,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAME,eAAeF,KAAK,MAAM,OAAO,8BAAA,CAAA;;;ACF9C,IAAA,uBAAe;EACb;IACE,SAAS;MACP,CAACG,iBAAAA,GAAoB;QACnB,eAAe;QACf,0BAA0B;QAC1B,2BAA2B;QAC3B,4BAA4B;QAC5B,0BAA0B;QAE1B,yBAAyB;QACzB,2BAA2B;QAC3B,yBAAyB;QACzB,oBAAoB;QACpB,sBAAsB;QACtB,sCAAsC;QAEtC,wBAAwB;QACxB,qBAAqB;QACrB,sBAAsB;QACtB,wBAAwB;QACxB,0BAA0B;QAC1B,6BAA6B;QAC7B,sBAAsB;QACtB,sBAAsB;QAEtB,oBAAoB;QACpB,sBAAsB;QAEtB,uBAAuB;QACvB,0BAA0B;QAC1B,yCAAyC;MAC3C;IACF;EACF;;;;AF5BK,IAAMC,mBAAmB,MAC9BC,aAAaC,MAAM;EACjBC,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOC;IACpBC,UAAU,MAAMC,YAAYC,aAAaC,cAAcC,oBAAAA;EACzD,CAAA;EACAT,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaQ,aAAaC;IAC1BN,UAAU,MAAMC,YAAYM,mBAAmBC,QAAQ;MAACC;MAAcC;KAAgB;EACxF,CAAA;EACAf,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOa;IACpBX,UAAUY;EACZ,CAAA;EACAjB,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOe;IACpBb,UAAUc;EACZ,CAAA;EACAnB,aAAa;IACXC,IAAI,GAAGF,KAAKE,EAAE;IACdC,aAAaC,OAAOiB;IACpBf,UAAUgB;EACZ,CAAA;CACD;",
|
|
6
|
+
"names": ["Capabilities", "contributes", "defineModule", "definePlugin", "Events", "FunctionType", "FunctionTrigger", "ClientCapabilities", "ClientEvents", "lazy", "AppGraphBuilder", "lazy", "IntentResolver", "ReactSurface", "AUTOMATION_PLUGIN", "AutomationPlugin", "definePlugin", "meta", "defineModule", "id", "activatesOn", "Events", "SetupTranslations", "activate", "contributes", "Capabilities", "Translations", "translations", "ClientEvents", "SetupSchema", "ClientCapabilities", "Schema", "FunctionType", "FunctionTrigger", "SetupAppGraph", "AppGraphBuilder", "SetupIntentResolver", "IntentResolver", "SetupReactSurface", "ReactSurface"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutomationAction
|
|
3
|
+
} from "./chunk-4E2KPMLB.mjs";
|
|
4
|
+
import "./chunk-IHAKPP5A.mjs";
|
|
5
|
+
|
|
6
|
+
// packages/plugins/plugin-automation/src/capabilities/intent-resolver.ts
|
|
7
|
+
import { contributes, Capabilities, createResolver, createIntent, LayoutAction } from "@dxos/app-framework";
|
|
8
|
+
import { Ref } from "@dxos/echo";
|
|
9
|
+
import { FunctionTrigger, FunctionType, ScriptType, TriggerKind } from "@dxos/functions";
|
|
10
|
+
import { live } from "@dxos/live-object";
|
|
11
|
+
import { ATTENDABLE_PATH_SEPARATOR } from "@dxos/plugin-deck/types";
|
|
12
|
+
import { SpaceAction } from "@dxos/plugin-space/types";
|
|
13
|
+
import { Filter } from "@dxos/react-client/echo";
|
|
14
|
+
var intent_resolver_default = (context) => contributes(Capabilities.IntentResolver, [
|
|
15
|
+
createResolver({
|
|
16
|
+
intent: AutomationAction.CreateTriggerFromTemplate,
|
|
17
|
+
resolve: async ({ space, template, enabled = false, scriptName, input }) => {
|
|
18
|
+
const trigger = live(FunctionTrigger, {
|
|
19
|
+
enabled,
|
|
20
|
+
input
|
|
21
|
+
});
|
|
22
|
+
if (scriptName) {
|
|
23
|
+
const { objects: [script] } = await space.db.query(Filter.type(ScriptType, {
|
|
24
|
+
name: scriptName
|
|
25
|
+
})).run();
|
|
26
|
+
if (script) {
|
|
27
|
+
const { objects: [fn] } = await space.db.query(Filter.type(FunctionType, {
|
|
28
|
+
source: Ref.make(script)
|
|
29
|
+
})).run();
|
|
30
|
+
if (fn) {
|
|
31
|
+
trigger.function = Ref.make(fn);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
switch (template.type) {
|
|
36
|
+
case "timer": {
|
|
37
|
+
trigger.spec = {
|
|
38
|
+
kind: TriggerKind.Timer,
|
|
39
|
+
cron: template.cron
|
|
40
|
+
};
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
case "queue": {
|
|
44
|
+
trigger.spec = {
|
|
45
|
+
kind: TriggerKind.Queue,
|
|
46
|
+
queue: template.queueDXN.toString()
|
|
47
|
+
};
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
default: {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
intents: [
|
|
56
|
+
createIntent(SpaceAction.AddObject, {
|
|
57
|
+
object: trigger,
|
|
58
|
+
target: space
|
|
59
|
+
}),
|
|
60
|
+
createIntent(LayoutAction.Open, {
|
|
61
|
+
part: "main",
|
|
62
|
+
subject: [
|
|
63
|
+
`automation-settings${ATTENDABLE_PATH_SEPARATOR}${space.id}`
|
|
64
|
+
],
|
|
65
|
+
options: {
|
|
66
|
+
workspace: space.id
|
|
67
|
+
}
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
]);
|
|
74
|
+
export {
|
|
75
|
+
intent_resolver_default as default
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=intent-resolver-ZRBBYZUX.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/intent-resolver.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport {\n contributes,\n Capabilities,\n createResolver,\n type PluginContext,\n createIntent,\n LayoutAction,\n} from '@dxos/app-framework';\nimport { Ref } from '@dxos/echo';\nimport { FunctionTrigger, FunctionType, ScriptType, TriggerKind } from '@dxos/functions';\nimport { type DXN } from '@dxos/keys';\nimport { live } from '@dxos/live-object';\nimport { ATTENDABLE_PATH_SEPARATOR } from '@dxos/plugin-deck/types';\nimport { SpaceAction } from '@dxos/plugin-space/types';\nimport { Filter } from '@dxos/react-client/echo';\n\nimport { AutomationAction } from '../types';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.IntentResolver, [\n createResolver({\n intent: AutomationAction.CreateTriggerFromTemplate,\n resolve: async ({ space, template, enabled = false, scriptName, input }) => {\n const trigger = live(FunctionTrigger, { enabled, input });\n\n // TODO(wittjosiah): Factor out function lookup by script name?\n if (scriptName) {\n const {\n objects: [script],\n } = await space.db.query(Filter.type(ScriptType, { name: scriptName })).run();\n if (script) {\n const {\n objects: [fn],\n } = await space.db.query(Filter.type(FunctionType, { source: Ref.make(script) })).run();\n if (fn) {\n trigger.function = Ref.make(fn);\n }\n }\n }\n\n switch (template.type) {\n case 'timer': {\n trigger.spec = { kind: TriggerKind.Timer, cron: template.cron };\n break;\n }\n case 'queue': {\n trigger.spec = { kind: TriggerKind.Queue, queue: (template.queueDXN as DXN).toString() };\n break;\n }\n default: {\n break;\n }\n }\n\n return {\n intents: [\n createIntent(SpaceAction.AddObject, { object: trigger, target: space }),\n createIntent(LayoutAction.Open, {\n part: 'main',\n subject: [`automation-settings${ATTENDABLE_PATH_SEPARATOR}${space.id}`],\n options: {\n workspace: space.id,\n },\n }),\n ],\n };\n },\n }),\n ]);\n"],
|
|
5
|
+
"mappings": ";;;;;;AAIA,SACEA,aACAC,cACAC,gBAEAC,cACAC,oBACK;AACP,SAASC,WAAW;AACpB,SAASC,iBAAiBC,cAAcC,YAAYC,mBAAmB;AAEvE,SAASC,YAAY;AACrB,SAASC,iCAAiC;AAC1C,SAASC,mBAAmB;AAC5B,SAASC,cAAc;AAIvB,IAAA,0BAAe,CAACC,YACdC,YAAYC,aAAaC,gBAAgB;EACvCC,eAAe;IACbC,QAAQC,iBAAiBC;IACzBC,SAAS,OAAO,EAAEC,OAAOC,UAAUC,UAAU,OAAOC,YAAYC,MAAK,MAAE;AACrE,YAAMC,UAAUC,KAAKC,iBAAiB;QAAEL;QAASE;MAAM,CAAA;AAGvD,UAAID,YAAY;AACd,cAAM,EACJK,SAAS,CAACC,MAAAA,EAAO,IACf,MAAMT,MAAMU,GAAGC,MAAMC,OAAOC,KAAKC,YAAY;UAAEC,MAAMZ;QAAW,CAAA,CAAA,EAAIa,IAAG;AAC3E,YAAIP,QAAQ;AACV,gBAAM,EACJD,SAAS,CAACS,EAAAA,EAAG,IACX,MAAMjB,MAAMU,GAAGC,MAAMC,OAAOC,KAAKK,cAAc;YAAEC,QAAQC,IAAIC,KAAKZ,MAAAA;UAAQ,CAAA,CAAA,EAAIO,IAAG;AACrF,cAAIC,IAAI;AACNZ,oBAAQiB,WAAWF,IAAIC,KAAKJ,EAAAA;UAC9B;QACF;MACF;AAEA,cAAQhB,SAASY,MAAI;QACnB,KAAK,SAAS;AACZR,kBAAQkB,OAAO;YAAEC,MAAMC,YAAYC;YAAOC,MAAM1B,SAAS0B;UAAK;AAC9D;QACF;QACA,KAAK,SAAS;AACZtB,kBAAQkB,OAAO;YAAEC,MAAMC,YAAYG;YAAOC,OAAQ5B,SAAS6B,SAAiBC,SAAQ;UAAG;AACvF;QACF;QACA,SAAS;AACP;QACF;MACF;AAEA,aAAO;QACLC,SAAS;UACPC,aAAaC,YAAYC,WAAW;YAAEC,QAAQ/B;YAASgC,QAAQrC;UAAM,CAAA;UACrEiC,aAAaK,aAAaC,MAAM;YAC9BC,MAAM;YACNC,SAAS;cAAC,sBAAsBC,yBAAAA,GAA4B1C,MAAM2C,EAAE;;YACpEC,SAAS;cACPC,WAAW7C,MAAM2C;YACnB;UACF,CAAA;;MAEJ;IACF;EACF,CAAA;CACD;",
|
|
6
|
+
"names": ["contributes", "Capabilities", "createResolver", "createIntent", "LayoutAction", "Ref", "FunctionTrigger", "FunctionType", "ScriptType", "TriggerKind", "live", "ATTENDABLE_PATH_SEPARATOR", "SpaceAction", "Filter", "context", "contributes", "Capabilities", "IntentResolver", "createResolver", "intent", "AutomationAction", "CreateTriggerFromTemplate", "resolve", "space", "template", "enabled", "scriptName", "input", "trigger", "live", "FunctionTrigger", "objects", "script", "db", "query", "Filter", "type", "ScriptType", "name", "run", "fn", "FunctionType", "source", "Ref", "make", "function", "spec", "kind", "TriggerKind", "Timer", "cron", "Queue", "queue", "queueDXN", "toString", "intents", "createIntent", "SpaceAction", "AddObject", "object", "target", "LayoutAction", "Open", "part", "subject", "ATTENDABLE_PATH_SEPARATOR", "id", "options", "workspace"]
|
|
7
|
+
}
|