loopable-cli 0.1.0
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/.output/nitro.json +17 -0
- package/.output/public/apple-touch-icon.png +0 -0
- package/.output/public/assets/_connectorId-BWjYn5tm.js +1 -0
- package/.output/public/assets/_loopId-Ds4RkyEc.js +1 -0
- package/.output/public/assets/_taskId-BOzICXDf.js +1 -0
- package/.output/public/assets/alert-Bn9-Zm0l.js +1 -0
- package/.output/public/assets/arrow-left-BF9juV9T.js +1 -0
- package/.output/public/assets/arrow-right-CzqvnOY1.js +1 -0
- package/.output/public/assets/button-HCY6DCY-.js +1 -0
- package/.output/public/assets/connection-status-CYZB8kLy.js +1 -0
- package/.output/public/assets/connector-icon-BZ_MUJV_.js +1 -0
- package/.output/public/assets/connectors-BvzttfSu.js +1 -0
- package/.output/public/assets/connectors-DdJNwRN_.js +1 -0
- package/.output/public/assets/external-link-D46X-bXa.js +1 -0
- package/.output/public/assets/gaps-D-I6xiDc.js +1 -0
- package/.output/public/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/.output/public/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/.output/public/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/.output/public/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/.output/public/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/.output/public/assets/inbox-BUUu9xxE.js +1 -0
- package/.output/public/assets/index-ztzex0FN.js +10 -0
- package/.output/public/assets/loader-CcBl2u8m.js +1 -0
- package/.output/public/assets/loop-form-dB3CLcZb.js +1 -0
- package/.output/public/assets/loops-DRunQrxL.js +1 -0
- package/.output/public/assets/loops-oSdqMd29.js +1 -0
- package/.output/public/assets/manifests-DNMqf7Vi.js +7 -0
- package/.output/public/assets/new-uyFxVjuB.js +1 -0
- package/.output/public/assets/preload-helper-ORbuV86A.js +3 -0
- package/.output/public/assets/runners-DSU3r5Ww.js +1 -0
- package/.output/public/assets/setting-fields-ixkpdBb-.js +3 -0
- package/.output/public/assets/styles-DZL5V1o7.css +2 -0
- package/.output/public/assets/switch-d5ummmHY.js +1 -0
- package/.output/public/assets/task-list-BpOStt9v.js +1 -0
- package/.output/public/assets/tasks-B8MsKgic.js +1 -0
- package/.output/public/assets/trash-2-D6u6NpzO.js +1 -0
- package/.output/public/favicon.svg +9 -0
- package/.output/server/_chunks/ssr-renderer.mjs +26 -0
- package/.output/server/_connectorId-8nb5yOzG.mjs +421 -0
- package/.output/server/_libs/@base-ui/react+[...].mjs +12841 -0
- package/.output/server/_libs/@tanstack/react-router+[...].mjs +14349 -0
- package/.output/server/_libs/class-variance-authority+clsx.mjs +69 -0
- package/.output/server/_libs/dijkstrajs.mjs +118 -0
- package/.output/server/_libs/drizzle-orm.mjs +4349 -0
- package/.output/server/_libs/h3+rou3+srvx.mjs +1361 -0
- package/.output/server/_libs/lucide-react.mjs +911 -0
- package/.output/server/_libs/next-themes.mjs +53 -0
- package/.output/server/_libs/pngjs.mjs +1680 -0
- package/.output/server/_libs/qrcode.mjs +2583 -0
- package/.output/server/_libs/sonner.mjs +955 -0
- package/.output/server/_libs/tailwind-merge.mjs +3380 -0
- package/.output/server/_libs/tanstack__history.mjs +341 -0
- package/.output/server/_libs/ufo.mjs +64 -0
- package/.output/server/_loopId-BsUL1SeL.mjs +272 -0
- package/.output/server/_runtime.mjs +35 -0
- package/.output/server/_ssr/access-zIl15o8y.mjs +42 -0
- package/.output/server/_ssr/agents-Btql102J.mjs +657 -0
- package/.output/server/_ssr/agents-DAOZPgO2.mjs +76 -0
- package/.output/server/_ssr/alert-NEiOCTOl.mjs +37 -0
- package/.output/server/_ssr/callback-CUINvl7M.mjs +62 -0
- package/.output/server/_ssr/client-CKkOfh-s.mjs +335 -0
- package/.output/server/_ssr/connection-status-Bi5peUAk.mjs +31 -0
- package/.output/server/_ssr/connections-qnw2GVlP.mjs +2542 -0
- package/.output/server/_ssr/connector-icon-DZXQLLFo.mjs +37 -0
- package/.output/server/_ssr/connectors-BHNwuIMj.mjs +106 -0
- package/.output/server/_ssr/connectors-C28g0i4c.mjs +83 -0
- package/.output/server/_ssr/createServerRpc-DPDrnFdH.mjs +12 -0
- package/.output/server/_ssr/empty-plugin-adapters-BJ4m9L8g.mjs +5 -0
- package/.output/server/_ssr/gaps-RAFSXLZf.mjs +53 -0
- package/.output/server/_ssr/inbox-k5zHergU.mjs +35 -0
- package/.output/server/_ssr/loop-form-DlObSewZ.mjs +412 -0
- package/.output/server/_ssr/loops-APFcP0y6.mjs +311 -0
- package/.output/server/_ssr/loops-xt2Bn7_q.mjs +222 -0
- package/.output/server/_ssr/new-DfKyd2Wa.mjs +169 -0
- package/.output/server/_ssr/router-3WmpE5b_.mjs +1553 -0
- package/.output/server/_ssr/runners-By-mwc3F.mjs +32 -0
- package/.output/server/_ssr/runners-DI_NxpHC.mjs +116 -0
- package/.output/server/_ssr/runners-DtXs4Q8a.mjs +106 -0
- package/.output/server/_ssr/secrets-Hqti-niS.mjs +199 -0
- package/.output/server/_ssr/setting-fields-8vKFj4df.mjs +92 -0
- package/.output/server/_ssr/ssr.mjs +6605 -0
- package/.output/server/_ssr/start-Bdc2GJUI.mjs +51 -0
- package/.output/server/_ssr/switch-ReNglgH6.mjs +18 -0
- package/.output/server/_ssr/task-list-CUITIqkb.mjs +186 -0
- package/.output/server/_ssr/tasks-SAjNovX6.mjs +110 -0
- package/.output/server/_ssr/tasks-vcoodp_D.mjs +533 -0
- package/.output/server/_tanstack-start-manifest_v-C0cP5F0M.mjs +125 -0
- package/.output/server/_taskId-CXS3lod0.mjs +249 -0
- package/.output/server/index.mjs +541 -0
- package/README.md +81 -0
- package/dist/cli.mjs +165 -0
- package/dist/dispatcher.mjs +9871 -0
- package/dist/runner.mjs +657 -0
- package/drizzle/0000_cold_demogoblin.sql +29 -0
- package/drizzle/0001_fancy_blonde_phantom.sql +13 -0
- package/drizzle/0002_spooky_smiling_tiger.sql +16 -0
- package/drizzle/0003_small_golden_guardian.sql +25 -0
- package/drizzle/0004_wonderful_thunderbolts.sql +39 -0
- package/drizzle/0005_named_workflows.sql +7 -0
- package/drizzle/0006_signals.sql +18 -0
- package/drizzle/0007_review_comments.sql +1 -0
- package/drizzle/0008_held_signals.sql +1 -0
- package/drizzle/0009_work_item_ref.sql +58 -0
- package/drizzle/0010_signal_payload.sql +2 -0
- package/drizzle/0011_rule_poll_cursor.sql +1 -0
- package/drizzle/0012_loops.sql +63 -0
- package/drizzle/0013_loop_owns_action_and_prompt.sql +154 -0
- package/drizzle/0014_loop_poll_every.sql +4 -0
- package/drizzle/0015_machines.sql +10 -0
- package/drizzle/0016_task_machine.sql +1 -0
- package/drizzle/0017_loop_machine.sql +1 -0
- package/drizzle/0018_runners.sql +1 -0
- package/drizzle/0019_task_runner.sql +1 -0
- package/drizzle/0020_loop_runner.sql +1 -0
- package/drizzle/0021_drop_runner_kind.sql +1 -0
- package/drizzle/0022_drop_loop_runner.sql +1 -0
- package/drizzle/0023_shared_host.sql +6 -0
- package/drizzle/meta/0000_snapshot.json +206 -0
- package/drizzle/meta/0001_snapshot.json +284 -0
- package/drizzle/meta/0002_snapshot.json +390 -0
- package/drizzle/meta/0003_snapshot.json +566 -0
- package/drizzle/meta/0004_snapshot.json +633 -0
- package/drizzle/meta/0005_snapshot.json +626 -0
- package/drizzle/meta/0006_snapshot.json +752 -0
- package/drizzle/meta/0007_snapshot.json +759 -0
- package/drizzle/meta/0008_snapshot.json +766 -0
- package/drizzle/meta/0009_snapshot.json +752 -0
- package/drizzle/meta/0010_snapshot.json +766 -0
- package/drizzle/meta/0011_snapshot.json +773 -0
- package/drizzle/meta/0012_snapshot.json +773 -0
- package/drizzle/meta/0013_snapshot.json +817 -0
- package/drizzle/meta/_journal.json +174 -0
- package/package.json +88 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { i as __toESM } from "./_runtime.mjs";
|
|
2
|
+
import { U as require_jsx_runtime, W as require_react, a as AvatarFallback$1, o as AvatarImage$1, s as AvatarRoot } from "./_libs/@base-ui/react+[...].mjs";
|
|
3
|
+
import { f as Link, m as useRouter } from "./_libs/@tanstack/react-router+[...].mjs";
|
|
4
|
+
import { a as connectorManifest } from "./_ssr/connections-qnw2GVlP.mjs";
|
|
5
|
+
import { a as registrableCallbackUrl } from "./_ssr/callback-CUINvl7M.mjs";
|
|
6
|
+
import { B as ArrowLeft, C as ExternalLink, M as CircleAlert, c as RotateCcw, g as Loader, i as Trash2, l as RefreshCw } from "./_libs/lucide-react.mjs";
|
|
7
|
+
import { n as toast } from "./_libs/sonner.mjs";
|
|
8
|
+
import { B as CardTitle, C as Button$1, F as verifyConnection, I as Badge, L as Card, M as continueQrLogin, N as disconnectConnection, P as saveConnectionSettings, R as CardContent, V as cn, j as beginQrLogin, u as Route$14, x as Separator$1, z as CardHeader } from "./_ssr/router-3WmpE5b_.mjs";
|
|
9
|
+
import { r as initialFieldValues, t as SettingFieldInputs } from "./_ssr/setting-fields-8vKFj4df.mjs";
|
|
10
|
+
import { t as ConnectionStatusBadge } from "./_ssr/connection-status-Bi5peUAk.mjs";
|
|
11
|
+
import { t as ConnectorIcon } from "./_ssr/connector-icon-DZXQLLFo.mjs";
|
|
12
|
+
import { n as AlertDescription, r as AlertTitle, t as Alert } from "./_ssr/alert-NEiOCTOl.mjs";
|
|
13
|
+
//#region node_modules/.nitro/vite/services/ssr/assets/_connectorId-8nb5yOzG.js
|
|
14
|
+
var import_react = /* @__PURE__ */ __toESM(require_react());
|
|
15
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
16
|
+
/** Renders a connector's settings from its manifest, so no page knows the fields. */
|
|
17
|
+
function ConnectionSettingsForm({ fields, connection }) {
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
const [values, setValues] = (0, import_react.useState)(() => initialFieldValues(fields, connection.settings));
|
|
20
|
+
const [saving, setSaving] = (0, import_react.useState)(false);
|
|
21
|
+
if (fields.length === 0) return null;
|
|
22
|
+
const save = async () => {
|
|
23
|
+
setSaving(true);
|
|
24
|
+
try {
|
|
25
|
+
await saveConnectionSettings({ data: {
|
|
26
|
+
id: connection.id,
|
|
27
|
+
settings: values
|
|
28
|
+
} });
|
|
29
|
+
await router.invalidate();
|
|
30
|
+
toast.success("Settings saved");
|
|
31
|
+
} catch (error) {
|
|
32
|
+
toast.error(error instanceof Error ? error.message : String(error));
|
|
33
|
+
} finally {
|
|
34
|
+
setSaving(false);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
38
|
+
className: "flex flex-col gap-5",
|
|
39
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SettingFieldInputs, {
|
|
40
|
+
fields,
|
|
41
|
+
values,
|
|
42
|
+
onChange: (key, value) => setValues((prev) => ({
|
|
43
|
+
...prev,
|
|
44
|
+
[key]: value
|
|
45
|
+
}))
|
|
46
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
47
|
+
onClick: save,
|
|
48
|
+
disabled: saving,
|
|
49
|
+
children: saving ? "Saving..." : "Save settings"
|
|
50
|
+
}) })]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
var LOOK_EVERY_MS = 2e3;
|
|
54
|
+
/**
|
|
55
|
+
* A login that finishes on a phone.
|
|
56
|
+
*
|
|
57
|
+
* The waiting is the whole component: a code lasts about two minutes, so it
|
|
58
|
+
* has to say plainly whether it is still good, and offer another the moment it
|
|
59
|
+
* is not. A dead square with no explanation is the failure to avoid.
|
|
60
|
+
*/
|
|
61
|
+
function QrConnect({ connectorId, note, onDone }) {
|
|
62
|
+
const router = useRouter();
|
|
63
|
+
const [code, setCode] = (0, import_react.useState)(null);
|
|
64
|
+
const [hint, setHint] = (0, import_react.useState)(null);
|
|
65
|
+
const [expired, setExpired] = (0, import_react.useState)(null);
|
|
66
|
+
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
67
|
+
/** Polling reads this, so a code replaced mid-flight is not polled again. */
|
|
68
|
+
const current = (0, import_react.useRef)(null);
|
|
69
|
+
const fetchCode = async () => {
|
|
70
|
+
setLoading(true);
|
|
71
|
+
setExpired(null);
|
|
72
|
+
setHint(null);
|
|
73
|
+
try {
|
|
74
|
+
const started = await beginQrLogin({ data: { connectorId } });
|
|
75
|
+
current.current = started.attempt;
|
|
76
|
+
setCode({
|
|
77
|
+
image: started.image,
|
|
78
|
+
attempt: started.attempt
|
|
79
|
+
});
|
|
80
|
+
} catch (error) {
|
|
81
|
+
setExpired(error instanceof Error ? error.message : String(error));
|
|
82
|
+
setCode(null);
|
|
83
|
+
} finally {
|
|
84
|
+
setLoading(false);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
(0, import_react.useEffect)(() => {
|
|
88
|
+
fetchCode();
|
|
89
|
+
}, [connectorId]);
|
|
90
|
+
(0, import_react.useEffect)(() => {
|
|
91
|
+
if (!code || expired) return;
|
|
92
|
+
let stop = false;
|
|
93
|
+
const look = async () => {
|
|
94
|
+
while (!stop) {
|
|
95
|
+
await new Promise((resolve) => setTimeout(resolve, LOOK_EVERY_MS));
|
|
96
|
+
if (stop || current.current === null) return;
|
|
97
|
+
try {
|
|
98
|
+
const outcome = await continueQrLogin({ data: {
|
|
99
|
+
connectorId,
|
|
100
|
+
attempt: current.current
|
|
101
|
+
} });
|
|
102
|
+
if (stop) return;
|
|
103
|
+
if (outcome.state === "connected") {
|
|
104
|
+
toast.success(`Connected ${outcome.accountLabel ?? connectorId}`);
|
|
105
|
+
await router.invalidate();
|
|
106
|
+
onDone?.();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (outcome.state === "expired") {
|
|
110
|
+
setExpired(outcome.reason ?? "The code expired before it was scanned.");
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
current.current = outcome.attempt;
|
|
114
|
+
setHint(outcome.hint ?? null);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
if (stop) return;
|
|
117
|
+
setHint(error instanceof Error ? error.message : String(error));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
look();
|
|
122
|
+
return () => {
|
|
123
|
+
stop = true;
|
|
124
|
+
};
|
|
125
|
+
}, [
|
|
126
|
+
code,
|
|
127
|
+
expired,
|
|
128
|
+
connectorId,
|
|
129
|
+
router,
|
|
130
|
+
onDone
|
|
131
|
+
]);
|
|
132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CardContent, {
|
|
133
|
+
className: "flex flex-col items-center gap-4 py-8",
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
136
|
+
className: "max-w-md text-center text-sm text-muted-foreground",
|
|
137
|
+
children: note
|
|
138
|
+
}),
|
|
139
|
+
expired ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Alert, {
|
|
140
|
+
variant: "destructive",
|
|
141
|
+
className: "max-w-md",
|
|
142
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CircleAlert, {}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDescription, { children: expired })]
|
|
143
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
144
|
+
className: "flex size-[240px] items-center justify-center rounded-lg border bg-white",
|
|
145
|
+
children: loading || !code ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loader, { className: "size-5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
|
|
146
|
+
src: code.image,
|
|
147
|
+
alt: "Scan with WeChat to connect",
|
|
148
|
+
className: "size-[240px]"
|
|
149
|
+
})
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
152
|
+
className: "text-sm text-muted-foreground",
|
|
153
|
+
children: expired ? "Ask for another and scan it this time." : hint ?? "Waiting for a scan..."
|
|
154
|
+
}),
|
|
155
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
156
|
+
variant: expired ? "default" : "outline",
|
|
157
|
+
size: "sm",
|
|
158
|
+
onClick: fetchCode,
|
|
159
|
+
disabled: loading,
|
|
160
|
+
children: expired ? "New code" : "Start over"
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
}) });
|
|
164
|
+
}
|
|
165
|
+
function Avatar$1({ className, size = "default", ...props }) {
|
|
166
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarRoot, {
|
|
167
|
+
"data-slot": "avatar",
|
|
168
|
+
"data-size": size,
|
|
169
|
+
className: cn("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten", className),
|
|
170
|
+
...props
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
function AvatarImage({ className, ...props }) {
|
|
174
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarImage$1, {
|
|
175
|
+
"data-slot": "avatar-image",
|
|
176
|
+
className: cn("aspect-square size-full rounded-full object-cover", className),
|
|
177
|
+
...props
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function AvatarFallback({ className, ...props }) {
|
|
181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarFallback$1, {
|
|
182
|
+
"data-slot": "avatar-fallback",
|
|
183
|
+
className: cn("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs", className),
|
|
184
|
+
...props
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function ConnectorDetailPage() {
|
|
188
|
+
const { connectorId } = Route$14.useParams();
|
|
189
|
+
const state = Route$14.useLoaderData();
|
|
190
|
+
const manifest = connectorManifest(connectorId);
|
|
191
|
+
const canAddAccount = manifest.allowsMultipleAccounts || state.connections.length === 0;
|
|
192
|
+
const scans = manifest.auth.kind === "qr_scan";
|
|
193
|
+
const [scanning, setScanning] = (0, import_react.useState)(false);
|
|
194
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
195
|
+
className: "flex flex-col gap-6",
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
|
|
198
|
+
to: "/connectors",
|
|
199
|
+
className: "flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",
|
|
200
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArrowLeft, { className: "size-4" }), "Connectors"]
|
|
201
|
+
}),
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
|
|
203
|
+
className: "flex items-start gap-4",
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectorIcon, {
|
|
206
|
+
icon: manifest.icon,
|
|
207
|
+
accent: manifest.accent,
|
|
208
|
+
className: "size-11"
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
211
|
+
className: "flex-1",
|
|
212
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
|
|
213
|
+
className: "text-2xl font-semibold tracking-tight",
|
|
214
|
+
children: manifest.name
|
|
215
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
216
|
+
className: "mt-1 text-sm text-muted-foreground",
|
|
217
|
+
children: manifest.tagline
|
|
218
|
+
})]
|
|
219
|
+
}),
|
|
220
|
+
state.readiness.ready && canAddAccount ? scans ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
221
|
+
onClick: () => setScanning((open) => !open),
|
|
222
|
+
children: scanning ? "Cancel" : "Connect"
|
|
223
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button$1, {
|
|
224
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: `/api/connectors/${connectorId}/authorize` }),
|
|
225
|
+
children: state.connections.length > 0 ? "Add another account" : "Connect"
|
|
226
|
+
}) : null
|
|
227
|
+
]
|
|
228
|
+
}),
|
|
229
|
+
scanning && manifest.auth.kind === "qr_scan" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(QrConnect, {
|
|
230
|
+
connectorId,
|
|
231
|
+
note: manifest.auth.note,
|
|
232
|
+
onDone: () => setScanning(false)
|
|
233
|
+
}) : null,
|
|
234
|
+
!state.readiness.ready ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Alert, {
|
|
235
|
+
variant: "destructive",
|
|
236
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AlertTitle, { children: [manifest.name, " is not available in this build"] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(AlertDescription, {
|
|
237
|
+
className: "flex flex-col gap-2",
|
|
238
|
+
children: [
|
|
239
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: state.readiness.reason }),
|
|
240
|
+
state.readiness.fixHint ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: state.readiness.fixHint }) : null,
|
|
241
|
+
manifest.auth.kind === "oauth_redirect" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
242
|
+
className: "text-xs",
|
|
243
|
+
children: ["Callback URL to register: ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: registrableCallbackUrl(connectorId) })]
|
|
244
|
+
}) : null
|
|
245
|
+
]
|
|
246
|
+
})]
|
|
247
|
+
}) : null,
|
|
248
|
+
state.connections.length === 0 && state.readiness.ready && !scanning ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Card, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CardContent, {
|
|
249
|
+
className: "py-8 text-center text-sm text-muted-foreground",
|
|
250
|
+
children: [
|
|
251
|
+
"No account connected yet.",
|
|
252
|
+
manifest.auth.kind === "oauth_redirect" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
253
|
+
" ",
|
|
254
|
+
"Connecting opens ",
|
|
255
|
+
manifest.name,
|
|
256
|
+
" and asks for",
|
|
257
|
+
" ",
|
|
258
|
+
manifest.auth.scopes.join(", "),
|
|
259
|
+
"."
|
|
260
|
+
] }) : null,
|
|
261
|
+
manifest.auth.kind === "qr_scan" ? " Connecting shows a code to scan." : null
|
|
262
|
+
]
|
|
263
|
+
}) }) : null,
|
|
264
|
+
state.connections.map((connection) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectionCard, {
|
|
265
|
+
connection,
|
|
266
|
+
manifest
|
|
267
|
+
}, connection.id)),
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CardTitle, {
|
|
269
|
+
className: "text-base",
|
|
270
|
+
children: "What this connector can do"
|
|
271
|
+
}) }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CardContent, {
|
|
272
|
+
className: "flex flex-col gap-4",
|
|
273
|
+
children: [
|
|
274
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CapabilityList, {
|
|
275
|
+
title: "Workflows it offers",
|
|
276
|
+
note: "Turn one on from the loops page.",
|
|
277
|
+
empty: "None yet. An account can be connected, but no loop can be built on it.",
|
|
278
|
+
items: manifest.workflows.map((workflow) => ({
|
|
279
|
+
id: workflow.id,
|
|
280
|
+
name: workflow.name,
|
|
281
|
+
summary: workflow.summary
|
|
282
|
+
}))
|
|
283
|
+
}),
|
|
284
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Separator$1, {}),
|
|
285
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CapabilityList, {
|
|
286
|
+
title: "What it writes",
|
|
287
|
+
note: "A loop writes these back on its own.",
|
|
288
|
+
empty: "Nothing. Loopable can read this account but cannot write to it.",
|
|
289
|
+
items: manifest.actions.map((action) => ({
|
|
290
|
+
id: action.id,
|
|
291
|
+
name: action.name,
|
|
292
|
+
summary: action.summary
|
|
293
|
+
}))
|
|
294
|
+
}),
|
|
295
|
+
manifest.docsUrl ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
|
|
296
|
+
href: manifest.docsUrl,
|
|
297
|
+
target: "_blank",
|
|
298
|
+
rel: "noreferrer",
|
|
299
|
+
className: "flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",
|
|
300
|
+
children: ["API documentation", /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ExternalLink, { className: "size-3.5" })]
|
|
301
|
+
}) : null
|
|
302
|
+
]
|
|
303
|
+
})] })
|
|
304
|
+
]
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function CapabilityList({ title, note, empty, items }) {
|
|
308
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
309
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
|
|
310
|
+
className: "text-sm font-medium",
|
|
311
|
+
children: title
|
|
312
|
+
}),
|
|
313
|
+
note && items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
314
|
+
className: "mt-0.5 text-xs text-muted-foreground",
|
|
315
|
+
children: note
|
|
316
|
+
}) : null,
|
|
317
|
+
items.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
318
|
+
className: "mt-2 text-sm text-muted-foreground",
|
|
319
|
+
children: empty
|
|
320
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
|
|
321
|
+
className: "mt-3 flex flex-col gap-2",
|
|
322
|
+
children: items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
|
|
323
|
+
className: "text-sm",
|
|
324
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
325
|
+
className: "font-medium",
|
|
326
|
+
children: item.name
|
|
327
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
328
|
+
className: "text-muted-foreground",
|
|
329
|
+
children: [" — ", item.summary]
|
|
330
|
+
})]
|
|
331
|
+
}, item.id))
|
|
332
|
+
})
|
|
333
|
+
] });
|
|
334
|
+
}
|
|
335
|
+
function ConnectionCard({ connection, manifest }) {
|
|
336
|
+
const router = useRouter();
|
|
337
|
+
const [busy, setBusy] = (0, import_react.useState)(null);
|
|
338
|
+
const broken = connection.status === "needs_reauth" || connection.status === "error";
|
|
339
|
+
const run = async (action) => {
|
|
340
|
+
setBusy(action);
|
|
341
|
+
try {
|
|
342
|
+
if (action === "verify") {
|
|
343
|
+
const updated = await verifyConnection({ data: { id: connection.id } });
|
|
344
|
+
toast[updated.status === "connected" ? "success" : "error"](updated.status === "connected" ? `${updated.accountLabel} is reachable` : updated.lastError ?? "This connection is not usable");
|
|
345
|
+
} else {
|
|
346
|
+
await disconnectConnection({ data: { id: connection.id } });
|
|
347
|
+
toast.success(`Disconnected ${connection.accountLabel}`);
|
|
348
|
+
}
|
|
349
|
+
await router.invalidate();
|
|
350
|
+
} catch (error) {
|
|
351
|
+
toast.error(error instanceof Error ? error.message : String(error));
|
|
352
|
+
} finally {
|
|
353
|
+
setBusy(null);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Card, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CardHeader, {
|
|
357
|
+
className: "flex flex-row items-center gap-3",
|
|
358
|
+
children: [
|
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Avatar$1, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarImage, {
|
|
360
|
+
src: connection.avatarUrl ?? void 0,
|
|
361
|
+
alt: connection.accountLabel
|
|
362
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarFallback, { children: connection.accountLabel.slice(0, 2).toUpperCase() })] }),
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
364
|
+
className: "flex-1",
|
|
365
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
366
|
+
className: "flex items-center gap-2",
|
|
367
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
368
|
+
className: "font-medium",
|
|
369
|
+
children: connection.accountLabel
|
|
370
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectionStatusBadge, { status: connection.status })]
|
|
371
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
372
|
+
className: "mt-0.5 text-xs text-muted-foreground",
|
|
373
|
+
children: connection.lastSyncedAt ? `Last checked ${new Date(connection.lastSyncedAt).toLocaleString()}` : "Not checked yet"
|
|
374
|
+
})]
|
|
375
|
+
}),
|
|
376
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$1, {
|
|
377
|
+
variant: "outline",
|
|
378
|
+
size: "sm",
|
|
379
|
+
onClick: () => run("verify"),
|
|
380
|
+
disabled: busy !== null,
|
|
381
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RefreshCw, { className: busy === "verify" ? "animate-spin" : void 0 }), "Verify"]
|
|
382
|
+
}),
|
|
383
|
+
broken ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$1, {
|
|
384
|
+
size: "sm",
|
|
385
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: `/api/connectors/${connection.connectorId}/authorize` }),
|
|
386
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(RotateCcw, {}), "Reconnect"]
|
|
387
|
+
}) : null,
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Button$1, {
|
|
389
|
+
variant: "outline",
|
|
390
|
+
size: "sm",
|
|
391
|
+
onClick: () => run("disconnect"),
|
|
392
|
+
disabled: busy !== null,
|
|
393
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Trash2, {}), "Disconnect"]
|
|
394
|
+
})
|
|
395
|
+
]
|
|
396
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CardContent, {
|
|
397
|
+
className: "flex flex-col gap-5 border-t pt-5",
|
|
398
|
+
children: [
|
|
399
|
+
connection.lastError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Alert, {
|
|
400
|
+
variant: "destructive",
|
|
401
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlertDescription, { children: connection.lastError })
|
|
402
|
+
}) : null,
|
|
403
|
+
connection.scopes.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
|
|
404
|
+
className: "text-sm font-medium",
|
|
405
|
+
children: "Granted access"
|
|
406
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
407
|
+
className: "mt-2 flex flex-wrap gap-1.5",
|
|
408
|
+
children: connection.scopes.map((scope) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Badge, {
|
|
409
|
+
variant: "outline",
|
|
410
|
+
children: scope
|
|
411
|
+
}, scope))
|
|
412
|
+
})] }) : null,
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConnectionSettingsForm, {
|
|
414
|
+
fields: manifest.settings,
|
|
415
|
+
connection
|
|
416
|
+
})
|
|
417
|
+
]
|
|
418
|
+
})] });
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
export { ConnectorDetailPage as component };
|