@adminide-stack/yantra-mobile 12.0.162-alpha.1 → 12.0.162-alpha.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/lib/components/CustomDrawer.js +70 -3
- package/lib/components/CustomDrawer.js.map +1 -1
- package/lib/compute.js +3 -1
- package/lib/config/env-config.js +4 -0
- package/lib/config/env-config.js.map +1 -1
- package/lib/features/credits/credits.js +151 -0
- package/lib/features/credits/credits.js.map +1 -0
- package/lib/features/credits/useLlmCredits.js +87 -0
- package/lib/features/credits/useLlmCredits.js.map +1 -0
- package/lib/features/design/surface/agentWriter.js +39 -0
- package/lib/features/design/surface/agentWriter.js.map +1 -0
- package/lib/features/design/surface/brandKit.js +9 -3
- package/lib/features/design/surface/brandKit.js.map +1 -1
- package/lib/features/design/surface/useBrandKitInUse.js.map +1 -1
- package/lib/features/design/surface/useDesignSurface.js +5 -39
- package/lib/features/design/surface/useDesignSurface.js.map +1 -1
- package/lib/features/webbuilder/WebBuilderExperience.js +64 -23
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/brandKitMove.js +52 -0
- package/lib/features/webbuilder/brandKitMove.js.map +1 -0
- package/lib/features/webbuilder/codeToolbox.js +129 -0
- package/lib/features/webbuilder/codeToolbox.js.map +1 -0
- package/lib/features/webbuilder/components/CloudSheet.js +1451 -0
- package/lib/features/webbuilder/components/CloudSheet.js.map +1 -0
- package/lib/features/webbuilder/components/CodeActionsSheet.js +125 -0
- package/lib/features/webbuilder/components/CodeActionsSheet.js.map +1 -0
- package/lib/features/webbuilder/components/CodeView.js +10 -3
- package/lib/features/webbuilder/components/CodeView.js.map +1 -1
- package/lib/features/webbuilder/components/Composer.js.map +1 -1
- package/lib/features/webbuilder/components/IntegrationsPanel.js +643 -0
- package/lib/features/webbuilder/components/IntegrationsPanel.js.map +1 -0
- package/lib/features/webbuilder/components/ProjectChat.js +57 -44
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/SecretsSheet.js +235 -0
- package/lib/features/webbuilder/components/SecretsSheet.js.map +1 -0
- package/lib/features/webbuilder/components/StudioHome.js +38 -1
- package/lib/features/webbuilder/components/StudioHome.js.map +1 -1
- package/lib/features/webbuilder/studioCatalog.js +4 -19
- package/lib/features/webbuilder/studioCatalog.js.map +1 -1
- package/lib/features/webbuilder/web/data/cloud.js +387 -0
- package/lib/features/webbuilder/web/data/cloud.js.map +1 -0
- package/lib/features/webbuilder/web/data/dataApi.js +227 -0
- package/lib/features/webbuilder/web/data/dataApi.js.map +1 -0
- package/lib/features/webbuilder/web/data/database.js +190 -0
- package/lib/features/webbuilder/web/data/database.js.map +1 -0
- package/lib/features/webbuilder/web/data/graphql.js +95 -0
- package/lib/features/webbuilder/web/data/graphql.js.map +1 -0
- package/lib/features/webbuilder/web/design/directions.js +343 -0
- package/lib/features/webbuilder/web/design/directions.js.map +1 -0
- package/lib/features/webbuilder/web/integrations/appToken.js +165 -0
- package/lib/features/webbuilder/web/integrations/appToken.js.map +1 -0
- package/lib/features/webbuilder/web/integrations/catalog.js +238 -0
- package/lib/features/webbuilder/web/integrations/catalog.js.map +1 -0
- package/lib/features/webbuilder/web/integrations/siteBilling.js +67 -0
- package/lib/features/webbuilder/web/integrations/siteBilling.js.map +1 -0
- package/lib/features/webbuilder/web/integrations/siteMail.js +190 -0
- package/lib/features/webbuilder/web/integrations/siteMail.js.map +1 -0
- package/lib/features/webbuilder/web/project/projectSettings.js +11 -0
- package/lib/features/webbuilder/web/project/projectSettings.js.map +1 -0
- package/lib/features/webbuilder/web/project/restorePoint.js +16 -0
- package/lib/features/webbuilder/web/project/restorePoint.js.map +1 -0
- package/lib/features/webbuilder/web/project/serverSettings.js +157 -0
- package/lib/features/webbuilder/web/project/serverSettings.js.map +1 -0
- package/lib/features/webbuilder/web/secrets/secrets.js +162 -0
- package/lib/features/webbuilder/web/secrets/secrets.js.map +1 -0
- package/lib/features/webbuilder/web/secrets/secretsApi.js +302 -0
- package/lib/features/webbuilder/web/secrets/secretsApi.js.map +1 -0
- package/lib/features/webbuilder/web/secrets/secretsStore.js +39 -0
- package/lib/features/webbuilder/web/secrets/secretsStore.js.map +1 -0
- package/lib/features/webbuilder/web/sharing/okResult.js +40 -0
- package/lib/features/webbuilder/web/sharing/okResult.js.map +1 -0
- package/lib/features/webbuilder/web/sharing/roles.js +3 -0
- package/lib/features/webbuilder/web/sharing/roles.js.map +1 -0
- package/lib/features/webbuilder/web/state/storageKeys.js +59 -0
- package/lib/features/webbuilder/web/state/storageKeys.js.map +1 -0
- package/lib/features/webbuilder/web/webServices.js +282 -0
- package/lib/features/webbuilder/web/webServices.js.map +1 -0
- package/lib/features/webbuilder/workflow.js +1 -1
- package/lib/features/webbuilder/workflow.js.map +1 -1
- package/lib/routes.json +3 -1
- package/lib/screens/Account/AccountSheets.js +1049 -0
- package/lib/screens/Account/AccountSheets.js.map +1 -0
- package/lib/screens/Account/WorkspaceSection.js +271 -0
- package/lib/screens/Account/WorkspaceSection.js.map +1 -0
- package/lib/screens/Account/accountRules.js +103 -0
- package/lib/screens/Account/accountRules.js.map +1 -0
- package/lib/screens/Account/index.js +563 -259
- package/lib/screens/Account/index.js.map +1 -1
- package/lib/screens/Account/useAccountPreferences.js +87 -0
- package/lib/screens/Account/useAccountPreferences.js.map +1 -0
- package/lib/screens/WebBuilderNative/index.js +1 -1
- package/lib/screens/WebBuilderNative/index.js.map +1 -1
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +122 -12
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/lib/utils/authUserDisplay.js +1 -9
- package/lib/utils/authUserDisplay.js.map +1 -1
- package/package.json +4 -4
- package/lib/features/webbuilder/brandKitStorage.js +0 -69
- package/lib/features/webbuilder/brandKitStorage.js.map +0 -1
- package/lib/features/webbuilder/components/BrandKitSheet.js +0 -197
- package/lib/features/webbuilder/components/BrandKitSheet.js.map +0 -1
- package/lib/screens/Account/splitDisplayName.js +0 -15
- package/lib/screens/Account/splitDisplayName.js.map +0 -1
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
import {jsxs,jsx,Fragment}from'react/jsx-runtime';import {useState,useMemo,useCallback,useEffect}from'react';import {StyleSheet,ScrollView,Text,View,TextInput,Linking,ActivityIndicator,Image,Clipboard}from'react-native';import {MaterialCommunityIcons}from'@expo/vector-icons';import {Tap,DIM}from'../../inbox/components/Tap.js';import {groupCatalog,API_KEY_CONNECT,checkApiKey,needsConnection,integrationRequest,credentialFor,aiRequest,integrationLimitMessage,withIntegration}from'../web/integrations/catalog.js';import {CODE_TOOLBOX_ACTIONS,codeActionTurn}from'../codeToolbox.js';import {SecondaryButton,PrimaryButton,Sheet}from'./ui.js';function copy(text) {
|
|
2
|
+
try {
|
|
3
|
+
Clipboard.setString(text);
|
|
4
|
+
} catch (e) {
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
function Card({
|
|
8
|
+
icon,
|
|
9
|
+
title,
|
|
10
|
+
detail,
|
|
11
|
+
onPress,
|
|
12
|
+
theme,
|
|
13
|
+
testID
|
|
14
|
+
}) {
|
|
15
|
+
return /* @__PURE__ */ jsxs(Tap, { onPress, accessibilityRole: "button", accessibilityLabel: title, style: [styles.card, {
|
|
16
|
+
backgroundColor: theme.chip,
|
|
17
|
+
borderColor: theme.border
|
|
18
|
+
}], pressedStyle: DIM, testID, children: [
|
|
19
|
+
/* @__PURE__ */ jsx(View, { style: [styles.logo, styles.logoBlank, {
|
|
20
|
+
backgroundColor: theme.accentSoft
|
|
21
|
+
}], children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: icon, size: 18, color: theme.accent }) }),
|
|
22
|
+
/* @__PURE__ */ jsxs(View, { style: styles.grow, children: [
|
|
23
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.rowLabel, {
|
|
24
|
+
color: theme.ink
|
|
25
|
+
}], children: title }),
|
|
26
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.hint, {
|
|
27
|
+
color: theme.muted
|
|
28
|
+
}], children: detail })
|
|
29
|
+
] })
|
|
30
|
+
] });
|
|
31
|
+
}
|
|
32
|
+
function EntryRow({
|
|
33
|
+
entry,
|
|
34
|
+
connected,
|
|
35
|
+
onPress,
|
|
36
|
+
theme
|
|
37
|
+
}) {
|
|
38
|
+
return /* @__PURE__ */ jsxs(Tap, { onPress, accessibilityRole: "button", accessibilityLabel: entry.title, style: styles.row, pressedStyle: DIM, children: [
|
|
39
|
+
entry.logo ? /* @__PURE__ */ jsx(Image, { source: {
|
|
40
|
+
uri: entry.logo
|
|
41
|
+
}, style: styles.logo, resizeMode: "contain" }) : /* @__PURE__ */ jsx(View, { style: [styles.logo, styles.logoBlank, {
|
|
42
|
+
backgroundColor: theme.chip
|
|
43
|
+
}], children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "power-plug-outline", size: 18, color: theme.muted }) }),
|
|
44
|
+
/* @__PURE__ */ jsxs(View, { style: styles.grow, children: [
|
|
45
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.rowLabel, {
|
|
46
|
+
color: theme.ink
|
|
47
|
+
}], children: entry.title }),
|
|
48
|
+
entry.description ? /* @__PURE__ */ jsx(Text, { style: [styles.hint, {
|
|
49
|
+
color: theme.muted
|
|
50
|
+
}], numberOfLines: 2, children: entry.description }) : null
|
|
51
|
+
] }),
|
|
52
|
+
connected ? /* @__PURE__ */ jsx(Text, { style: [styles.badge, {
|
|
53
|
+
color: theme.good,
|
|
54
|
+
borderColor: theme.good
|
|
55
|
+
}], children: "Connected" }) : null,
|
|
56
|
+
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-right", size: 20, color: theme.faint })
|
|
57
|
+
] });
|
|
58
|
+
}
|
|
59
|
+
function BackRow({
|
|
60
|
+
onBack,
|
|
61
|
+
theme
|
|
62
|
+
}) {
|
|
63
|
+
return /* @__PURE__ */ jsxs(Tap, { onPress: onBack, accessibilityRole: "button", accessibilityLabel: "Back to Integrations", style: styles.back, pressedStyle: DIM, children: [
|
|
64
|
+
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "chevron-left", size: 22, color: theme.ink }),
|
|
65
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.rowLabel, {
|
|
66
|
+
color: theme.ink
|
|
67
|
+
}], children: "Integrations" })
|
|
68
|
+
] });
|
|
69
|
+
}
|
|
70
|
+
function SiteEmail({
|
|
71
|
+
services,
|
|
72
|
+
channelId,
|
|
73
|
+
theme
|
|
74
|
+
}) {
|
|
75
|
+
const project = useMemo(() => ({
|
|
76
|
+
channelId
|
|
77
|
+
}), [channelId]);
|
|
78
|
+
const [state, setState] = useState(null);
|
|
79
|
+
const [loading, setLoading] = useState(true);
|
|
80
|
+
const [domain, setDomain] = useState("");
|
|
81
|
+
const [notifyTo, setNotifyTo] = useState("");
|
|
82
|
+
const [working, setWorking] = useState(false);
|
|
83
|
+
const [error, setError] = useState(null);
|
|
84
|
+
const read = useCallback(async (diagnose = false) => {
|
|
85
|
+
var _a;
|
|
86
|
+
setError(null);
|
|
87
|
+
const r = await services.integrations.siteMail.status(project, diagnose);
|
|
88
|
+
if (r.ok) setState((_a = r.state) != null ? _a : null);
|
|
89
|
+
else setError(r.message || "The email status couldn't be read.");
|
|
90
|
+
}, [services, project]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
read().catch(() => void 0).finally(() => setLoading(false));
|
|
93
|
+
}, [read]);
|
|
94
|
+
const enable = async () => {
|
|
95
|
+
var _a;
|
|
96
|
+
setWorking(true);
|
|
97
|
+
setError(null);
|
|
98
|
+
try {
|
|
99
|
+
const r = await services.integrations.siteMail.enable(project, domain.trim(), notifyTo.trim());
|
|
100
|
+
if (r.ok) setState((_a = r.state) != null ? _a : null);
|
|
101
|
+
else setError(r.message || "Email couldn't be set up.");
|
|
102
|
+
} finally {
|
|
103
|
+
setWorking(false);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const disable = async () => {
|
|
107
|
+
setWorking(true);
|
|
108
|
+
const r = await services.integrations.siteMail.disable(project);
|
|
109
|
+
setWorking(false);
|
|
110
|
+
if (r.ok) setState({
|
|
111
|
+
configured: false,
|
|
112
|
+
proved: false,
|
|
113
|
+
sendingVerified: false,
|
|
114
|
+
records: []
|
|
115
|
+
});
|
|
116
|
+
else setError(r.message || "Email couldn't be turned off.");
|
|
117
|
+
};
|
|
118
|
+
if (loading) return /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent, style: styles.spin });
|
|
119
|
+
if (!(state == null ? void 0 : state.configured)) {
|
|
120
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.body, children: [
|
|
121
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
122
|
+
color: theme.muted
|
|
123
|
+
}], children: "Contact forms on the site email you from your own domain, with a copy kept in your database." }),
|
|
124
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.label, {
|
|
125
|
+
color: theme.ink
|
|
126
|
+
}], children: "Your domain" }),
|
|
127
|
+
/* @__PURE__ */ jsx(TextInput, { value: domain, onChangeText: setDomain, placeholder: "yourstudio.com", placeholderTextColor: theme.faint, autoCapitalize: "none", autoCorrect: false, keyboardType: "url", style: [styles.input, {
|
|
128
|
+
color: theme.ink,
|
|
129
|
+
borderColor: theme.border,
|
|
130
|
+
backgroundColor: theme.screen
|
|
131
|
+
}], accessibilityLabel: "Your domain" }),
|
|
132
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.label, {
|
|
133
|
+
color: theme.ink
|
|
134
|
+
}], children: "Where messages go" }),
|
|
135
|
+
/* @__PURE__ */ jsx(TextInput, { value: notifyTo, onChangeText: setNotifyTo, placeholder: "you@yourstudio.com", placeholderTextColor: theme.faint, autoCapitalize: "none", autoCorrect: false, keyboardType: "email-address", style: [styles.input, {
|
|
136
|
+
color: theme.ink,
|
|
137
|
+
borderColor: theme.border,
|
|
138
|
+
backgroundColor: theme.screen
|
|
139
|
+
}], accessibilityLabel: "Where messages go" }),
|
|
140
|
+
error ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
141
|
+
color: theme.crit
|
|
142
|
+
}], children: error }) : null,
|
|
143
|
+
/* @__PURE__ */ jsx(PrimaryButton, { label: "Set up email", onPress: () => {
|
|
144
|
+
enable().catch(() => void 0);
|
|
145
|
+
}, theme, busy: working, disabled: !/\./.test(domain) || !/@/.test(notifyTo) })
|
|
146
|
+
] });
|
|
147
|
+
}
|
|
148
|
+
const ready = state.proved && state.sendingVerified;
|
|
149
|
+
const purposeLabel = {
|
|
150
|
+
proof: "Proves the domain is yours",
|
|
151
|
+
dkim: "Signs your mail",
|
|
152
|
+
spf: "Allows Yantra to send for you (recommended)",
|
|
153
|
+
dmarc: "Tells inboxes what to do with fakes (recommended)",
|
|
154
|
+
other: ""
|
|
155
|
+
};
|
|
156
|
+
return /* @__PURE__ */ jsxs(View, { style: styles.body, children: [
|
|
157
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.rowLabel, {
|
|
158
|
+
color: theme.ink
|
|
159
|
+
}], children: state.domain }),
|
|
160
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
161
|
+
color: ready ? theme.good : theme.muted
|
|
162
|
+
}], children: ready ? `Email is on: messages go to ${state.notifyTo || "you"}.` : "Waiting for DNS. Add these records where you bought the domain, then check again. DNS can take up to an hour." }),
|
|
163
|
+
state.explanation ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
164
|
+
color: theme.muted
|
|
165
|
+
}], children: state.explanation }) : null,
|
|
166
|
+
!ready ? state.records.map((r) => /* @__PURE__ */ jsxs(View, { style: [styles.record, {
|
|
167
|
+
borderColor: theme.border
|
|
168
|
+
}], children: [
|
|
169
|
+
/* @__PURE__ */ jsxs(Text, { style: [styles.hint, {
|
|
170
|
+
color: theme.muted
|
|
171
|
+
}], children: [
|
|
172
|
+
r.type,
|
|
173
|
+
" \xB7 ",
|
|
174
|
+
purposeLabel[r.purpose] || "Record"
|
|
175
|
+
] }),
|
|
176
|
+
[r.name, r.value].map((v, i) => /* @__PURE__ */ jsxs(View, { style: styles.recordLine, children: [
|
|
177
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.mono, {
|
|
178
|
+
color: theme.ink
|
|
179
|
+
}], selectable: true, numberOfLines: 2, children: v }),
|
|
180
|
+
/* @__PURE__ */ jsx(Tap, { onPress: () => copy(v), accessibilityRole: "button", accessibilityLabel: i ? "Copy value" : "Copy name", hitSlop: 8, pressedStyle: DIM, children: /* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "content-copy", size: 16, color: theme.muted }) })
|
|
181
|
+
] }, i))
|
|
182
|
+
] }, `${r.type}-${r.name}`)) : null,
|
|
183
|
+
error ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
184
|
+
color: theme.crit
|
|
185
|
+
}], children: error }) : null,
|
|
186
|
+
!ready ? /* @__PURE__ */ jsx(PrimaryButton, { label: "Check again", icon: "refresh", onPress: () => {
|
|
187
|
+
setWorking(true);
|
|
188
|
+
read(true).catch(() => void 0).finally(() => setWorking(false));
|
|
189
|
+
}, theme, busy: working }) : null,
|
|
190
|
+
/* @__PURE__ */ jsx(SecondaryButton, { label: "Turn off email", onPress: () => {
|
|
191
|
+
disable().catch(() => void 0);
|
|
192
|
+
}, theme })
|
|
193
|
+
] });
|
|
194
|
+
}
|
|
195
|
+
function IntegrationsPanel({
|
|
196
|
+
visible,
|
|
197
|
+
channelId,
|
|
198
|
+
services,
|
|
199
|
+
aiBusy,
|
|
200
|
+
onRequest,
|
|
201
|
+
onClose,
|
|
202
|
+
theme
|
|
203
|
+
}) {
|
|
204
|
+
var _a;
|
|
205
|
+
const [catalog, setCatalog] = useState([]);
|
|
206
|
+
const [connections, setConnections] = useState(null);
|
|
207
|
+
const [connLoading, setConnLoading] = useState(false);
|
|
208
|
+
const [loading, setLoading] = useState(false);
|
|
209
|
+
const [failed, setFailed] = useState(false);
|
|
210
|
+
const [search, setSearch] = useState("");
|
|
211
|
+
const [picked, setPicked] = useState(null);
|
|
212
|
+
const [purpose, setPurpose] = useState("");
|
|
213
|
+
const [tokenStatus, setTokenStatus] = useState(null);
|
|
214
|
+
const [tokenOffer, setTokenOffer] = useState(false);
|
|
215
|
+
const [key, setKey] = useState("");
|
|
216
|
+
const [working, setWorking] = useState(null);
|
|
217
|
+
const [error, setError] = useState(null);
|
|
218
|
+
const [warning, setWarning] = useState(null);
|
|
219
|
+
const project = useMemo(() => channelId ? {
|
|
220
|
+
channelId
|
|
221
|
+
} : null, [channelId]);
|
|
222
|
+
const loadConnections = useCallback(() => {
|
|
223
|
+
setConnLoading(true);
|
|
224
|
+
return services.integrations.loadConnections().then(setConnections).catch(() => setConnections(null)).finally(() => setConnLoading(false));
|
|
225
|
+
}, [services]);
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
if (!visible) return;
|
|
228
|
+
setPicked(null);
|
|
229
|
+
setSearch("");
|
|
230
|
+
setError(null);
|
|
231
|
+
setWarning(null);
|
|
232
|
+
setLoading(true);
|
|
233
|
+
setFailed(false);
|
|
234
|
+
services.integrations.loadCatalog().then(setCatalog).catch(() => setFailed(true)).finally(() => setLoading(false));
|
|
235
|
+
loadConnections().catch(() => void 0);
|
|
236
|
+
if (project) {
|
|
237
|
+
services.integrations.appTokenStatus(project).then(setTokenStatus).catch(() => setTokenStatus("unavailable"));
|
|
238
|
+
}
|
|
239
|
+
}, [visible, services, loadConnections, project]);
|
|
240
|
+
const {
|
|
241
|
+
featured,
|
|
242
|
+
groups
|
|
243
|
+
} = useMemo(() => groupCatalog(catalog, search), [catalog, search]);
|
|
244
|
+
const isConnected = (entry) => {
|
|
245
|
+
var _a2;
|
|
246
|
+
if (!needsConnection(entry)) return true;
|
|
247
|
+
if (!connections) return null;
|
|
248
|
+
return ((_a2 = credentialFor(entry.id, connections)) == null ? void 0 : _a2.status) === "active";
|
|
249
|
+
};
|
|
250
|
+
const finishAdd = async (target) => {
|
|
251
|
+
var _a2;
|
|
252
|
+
if (!project) return;
|
|
253
|
+
setError(null);
|
|
254
|
+
if (target.kind === "ai") {
|
|
255
|
+
onClose();
|
|
256
|
+
onRequest(aiRequest(purpose));
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (target.kind !== "connector") return;
|
|
260
|
+
setWorking("Adding\u2026");
|
|
261
|
+
try {
|
|
262
|
+
const cred = connections ? credentialFor(target.entry.id, connections) : null;
|
|
263
|
+
const base = (_a2 = await services.integrations.projectIntegrations(project.channelId).catch(() => null)) != null ? _a2 : [];
|
|
264
|
+
const full = integrationLimitMessage(base, target.entry);
|
|
265
|
+
if (full) {
|
|
266
|
+
setError(full);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const next = withIntegration(base, target.entry, {
|
|
270
|
+
credentialId: cred == null ? void 0 : cred.id,
|
|
271
|
+
purpose
|
|
272
|
+
});
|
|
273
|
+
const saved = await services.data.updateSettings(project.channelId, {
|
|
274
|
+
integrations: next
|
|
275
|
+
});
|
|
276
|
+
if (!saved.ok) setWarning(saved.message || "The integration wasn't saved to the project.");
|
|
277
|
+
if (target.entry.id === "stripe" && (cred == null ? void 0 : cred.id)) {
|
|
278
|
+
const billing = await services.integrations.enableSiteBilling(project, cred.id);
|
|
279
|
+
if (!billing.ok) setWarning(billing.message || "Billing couldn't be turned on for this site.");
|
|
280
|
+
}
|
|
281
|
+
const billingAction = target.entry.id === "stripe" ? CODE_TOOLBOX_ACTIONS.find((a) => a.id === "add-billing") : void 0;
|
|
282
|
+
const text = billingAction ? codeActionTurn(billingAction, purpose.trim() ? `It sells ${purpose.trim()}.` : void 0) : integrationRequest(target.entry, purpose);
|
|
283
|
+
onClose();
|
|
284
|
+
onRequest(text);
|
|
285
|
+
} finally {
|
|
286
|
+
setWorking(null);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
const add = () => {
|
|
290
|
+
if (!picked) return;
|
|
291
|
+
if (aiBusy) {
|
|
292
|
+
setError("The AI is busy. Try again when it finishes.");
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const billingOnly = picked.kind === "connector" && picked.entry.id === "stripe";
|
|
296
|
+
if (tokenStatus === "missing" && !billingOnly && picked.kind === "connector") {
|
|
297
|
+
setTokenOffer(true);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
finishAdd(picked).catch(() => setError("Couldn't add it. Try again."));
|
|
301
|
+
};
|
|
302
|
+
const createToken = async () => {
|
|
303
|
+
if (!project || !picked) return;
|
|
304
|
+
setWorking("Creating the app token\u2026");
|
|
305
|
+
setError(null);
|
|
306
|
+
try {
|
|
307
|
+
const r = await services.integrations.createAppToken(project);
|
|
308
|
+
if (!r.ok) {
|
|
309
|
+
setError(r.message || "Couldn't create the app token.");
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
setTokenStatus("present");
|
|
313
|
+
setTokenOffer(false);
|
|
314
|
+
if (r.message) setWarning(r.message);
|
|
315
|
+
} finally {
|
|
316
|
+
setWorking(null);
|
|
317
|
+
}
|
|
318
|
+
await finishAdd(picked);
|
|
319
|
+
};
|
|
320
|
+
const saveKey = async (entry) => {
|
|
321
|
+
setWorking("Saving the key\u2026");
|
|
322
|
+
setError(null);
|
|
323
|
+
try {
|
|
324
|
+
const r = await services.integrations.connectApiKey(entry.id, key);
|
|
325
|
+
if (!r.ok) {
|
|
326
|
+
setError(r.message || `${entry.title} couldn't be connected.`);
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
setKey("");
|
|
330
|
+
await loadConnections();
|
|
331
|
+
} finally {
|
|
332
|
+
setWorking(null);
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
let body;
|
|
336
|
+
if ((picked == null ? void 0 : picked.kind) === "email" && channelId) {
|
|
337
|
+
body = /* @__PURE__ */ jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.body, keyboardShouldPersistTaps: "handled", children: [
|
|
338
|
+
/* @__PURE__ */ jsx(BackRow, { onBack: () => setPicked(null), theme }),
|
|
339
|
+
/* @__PURE__ */ jsx(SiteEmail, { services, channelId, theme })
|
|
340
|
+
] });
|
|
341
|
+
} else if (picked) {
|
|
342
|
+
const entry = picked.kind === "connector" ? picked.entry : null;
|
|
343
|
+
const connected = entry ? isConnected(entry) : true;
|
|
344
|
+
const keySpec = entry ? API_KEY_CONNECT[entry.id] : void 0;
|
|
345
|
+
const keyCheck = entry && key ? checkApiKey(entry.id, key) : null;
|
|
346
|
+
body = /* @__PURE__ */ jsxs(ScrollView, { style: styles.scroll, contentContainerStyle: styles.body, keyboardShouldPersistTaps: "handled", children: [
|
|
347
|
+
/* @__PURE__ */ jsx(BackRow, { onBack: () => setPicked(null), theme }),
|
|
348
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
349
|
+
color: theme.muted
|
|
350
|
+
}], children: entry ? entry.description || `Add ${entry.title} to your site.` : "A chat assistant, smart search, writing help - runs on your site's server." }),
|
|
351
|
+
entry && needsConnection(entry) ? /* @__PURE__ */ jsxs(View, { style: [styles.status, {
|
|
352
|
+
borderColor: theme.border
|
|
353
|
+
}], children: [
|
|
354
|
+
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: connected ? "check-circle" : "link-variant-off", size: 18, color: connected ? theme.good : theme.muted }),
|
|
355
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.hint, styles.grow, {
|
|
356
|
+
color: theme.ink
|
|
357
|
+
}], children: connected ? `${entry.title} is connected in this workspace.` : `${entry.title} isn't connected yet.` })
|
|
358
|
+
] }) : null,
|
|
359
|
+
entry && keySpec ? /* @__PURE__ */ jsxs(View, { style: styles.body, children: [
|
|
360
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.label, {
|
|
361
|
+
color: theme.ink
|
|
362
|
+
}], children: connected ? "Use a different key" : `${keySpec.label} secret key` }),
|
|
363
|
+
/* @__PURE__ */ jsx(TextInput, { value: key, onChangeText: setKey, placeholder: keySpec.placeholder, placeholderTextColor: theme.faint, autoCapitalize: "none", autoCorrect: false, secureTextEntry: true, style: [styles.input, {
|
|
364
|
+
color: theme.ink,
|
|
365
|
+
borderColor: theme.border,
|
|
366
|
+
backgroundColor: theme.screen
|
|
367
|
+
}], accessibilityLabel: `${keySpec.label} secret key` }),
|
|
368
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.hint, {
|
|
369
|
+
color: theme.muted
|
|
370
|
+
}], children: keySpec.help }),
|
|
371
|
+
(keyCheck == null ? void 0 : keyCheck.live) ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
372
|
+
color: theme.warn
|
|
373
|
+
}], children: "This is a live key: real payments will be taken." }) : null,
|
|
374
|
+
key && keyCheck && !keyCheck.ok ? /* @__PURE__ */ jsxs(Text, { style: [styles.help, {
|
|
375
|
+
color: theme.crit
|
|
376
|
+
}], children: [
|
|
377
|
+
"That doesn't look like a ",
|
|
378
|
+
keySpec.label,
|
|
379
|
+
" secret key."
|
|
380
|
+
] }) : null,
|
|
381
|
+
/* @__PURE__ */ jsx(SecondaryButton, { label: "Save key", onPress: () => {
|
|
382
|
+
saveKey(entry).catch(() => void 0);
|
|
383
|
+
}, theme })
|
|
384
|
+
] }) : null,
|
|
385
|
+
entry && needsConnection(entry) && !keySpec && !connected ? /* @__PURE__ */ jsx(SecondaryButton, { label: "Connect in the app", icon: "open-in-new", onPress: () => {
|
|
386
|
+
const url = services.integrations.connectUrl(entry.id);
|
|
387
|
+
if (url) Linking.openURL(url).catch(() => void 0);
|
|
388
|
+
else setError("Can't open the connect page here.");
|
|
389
|
+
}, theme }) : null,
|
|
390
|
+
entry && needsConnection(entry) && !connected ? /* @__PURE__ */ jsx(Tap, { onPress: () => {
|
|
391
|
+
loadConnections().catch(() => void 0);
|
|
392
|
+
}, accessibilityRole: "button", pressedStyle: DIM, children: /* @__PURE__ */ jsx(Text, { style: [styles.link, {
|
|
393
|
+
color: theme.accent
|
|
394
|
+
}], children: "I've connected it - check again" }) }) : null,
|
|
395
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.label, {
|
|
396
|
+
color: theme.ink
|
|
397
|
+
}], children: (entry == null ? void 0 : entry.id) === "stripe" ? "What does the site sell? (optional)" : "What should it do? (optional)" }),
|
|
398
|
+
/* @__PURE__ */ jsx(TextInput, { value: purpose, onChangeText: setPurpose, placeholder: entry ? "e.g. the products on my site" : "An assistant that answers visitors' questions", placeholderTextColor: theme.faint, style: [styles.input, {
|
|
399
|
+
color: theme.ink,
|
|
400
|
+
borderColor: theme.border,
|
|
401
|
+
backgroundColor: theme.screen
|
|
402
|
+
}], accessibilityLabel: "What it should do" }),
|
|
403
|
+
entry ? /* @__PURE__ */ jsxs(Text, { style: [styles.hint, {
|
|
404
|
+
color: theme.muted
|
|
405
|
+
}], children: [
|
|
406
|
+
"We'll ask the AI: \u201C",
|
|
407
|
+
integrationRequest(entry, purpose),
|
|
408
|
+
"\u201D"
|
|
409
|
+
] }) : null,
|
|
410
|
+
tokenOffer ? /* @__PURE__ */ jsxs(View, { style: [styles.status, styles.column, {
|
|
411
|
+
borderColor: theme.border
|
|
412
|
+
}], children: [
|
|
413
|
+
/* @__PURE__ */ jsxs(Text, { style: [styles.hint, {
|
|
414
|
+
color: theme.ink
|
|
415
|
+
}], children: [
|
|
416
|
+
"Your site needs an app token to call ",
|
|
417
|
+
(_a = entry == null ? void 0 : entry.title) != null ? _a : "this",
|
|
418
|
+
" from its server. Create one now?"
|
|
419
|
+
] }),
|
|
420
|
+
/* @__PURE__ */ jsx(PrimaryButton, { label: "Create the app token", onPress: () => {
|
|
421
|
+
createToken().catch(() => void 0);
|
|
422
|
+
}, theme, busy: working === "Creating the app token\u2026" }),
|
|
423
|
+
/* @__PURE__ */ jsx(SecondaryButton, { label: "Skip", onPress: () => {
|
|
424
|
+
setTokenOffer(false);
|
|
425
|
+
finishAdd(picked).catch(() => void 0);
|
|
426
|
+
}, theme })
|
|
427
|
+
] }) : /* @__PURE__ */ jsx(
|
|
428
|
+
PrimaryButton,
|
|
429
|
+
{
|
|
430
|
+
label: working || "Add to my site",
|
|
431
|
+
icon: "plus",
|
|
432
|
+
onPress: add,
|
|
433
|
+
theme,
|
|
434
|
+
busy: Boolean(working),
|
|
435
|
+
disabled: aiBusy || connLoading || Boolean(keySpec && key.trim()) || entry && needsConnection(entry) && connected === false,
|
|
436
|
+
testID: "webbuilder-integration-add"
|
|
437
|
+
}
|
|
438
|
+
),
|
|
439
|
+
warning ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
440
|
+
color: theme.warn
|
|
441
|
+
}], children: warning }) : null,
|
|
442
|
+
error ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
443
|
+
color: theme.crit
|
|
444
|
+
}], children: error }) : null
|
|
445
|
+
] });
|
|
446
|
+
} else {
|
|
447
|
+
const pick = (p) => {
|
|
448
|
+
setPurpose("");
|
|
449
|
+
setKey("");
|
|
450
|
+
setTokenOffer(false);
|
|
451
|
+
setError(null);
|
|
452
|
+
setPicked(p);
|
|
453
|
+
};
|
|
454
|
+
body = /* @__PURE__ */ jsxs(View, { style: styles.body, children: [
|
|
455
|
+
/* @__PURE__ */ jsxs(View, { style: [styles.search, {
|
|
456
|
+
borderColor: theme.accent,
|
|
457
|
+
backgroundColor: theme.screen
|
|
458
|
+
}], children: [
|
|
459
|
+
/* @__PURE__ */ jsx(MaterialCommunityIcons, { name: "magnify", size: 18, color: theme.muted }),
|
|
460
|
+
/* @__PURE__ */ jsx(TextInput, { value: search, onChangeText: setSearch, placeholder: "Search integrations", placeholderTextColor: theme.faint, autoCapitalize: "none", autoCorrect: false, style: [styles.searchInput, {
|
|
461
|
+
color: theme.ink
|
|
462
|
+
}], accessibilityLabel: "Search integrations" })
|
|
463
|
+
] }),
|
|
464
|
+
/* @__PURE__ */ jsxs(ScrollView, { style: styles.list, keyboardShouldPersistTaps: "handled", children: [
|
|
465
|
+
!search.trim() ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
466
|
+
/* @__PURE__ */ jsx(Card, { icon: "creation", title: "Add AI to my site", detail: "A chat assistant, smart search, writing help - runs on your site's server.", onPress: () => pick({
|
|
467
|
+
kind: "ai"
|
|
468
|
+
}), theme, testID: "webbuilder-integration-ai" }),
|
|
469
|
+
channelId ? /* @__PURE__ */ jsx(Card, { icon: "email-outline", title: "Email from my domain", detail: "Contact forms that email you from your own domain.", onPress: () => pick({
|
|
470
|
+
kind: "email"
|
|
471
|
+
}), theme, testID: "webbuilder-integration-email" }) : null
|
|
472
|
+
] }) : null,
|
|
473
|
+
loading ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent, style: styles.spin }) : null,
|
|
474
|
+
!loading && failed ? /* @__PURE__ */ jsx(Text, { style: [styles.help, {
|
|
475
|
+
color: theme.muted
|
|
476
|
+
}], children: "Couldn't load the integrations." }) : null,
|
|
477
|
+
featured.length ? /* @__PURE__ */ jsx(Text, { style: [styles.section, {
|
|
478
|
+
color: theme.muted
|
|
479
|
+
}], children: "POPULAR" }) : null,
|
|
480
|
+
featured.map((e) => /* @__PURE__ */ jsx(EntryRow, { entry: e, connected: isConnected(e), onPress: () => pick({
|
|
481
|
+
kind: "connector",
|
|
482
|
+
entry: e
|
|
483
|
+
}), theme }, e.id)),
|
|
484
|
+
groups.map((g) => /* @__PURE__ */ jsxs(View, { children: [
|
|
485
|
+
/* @__PURE__ */ jsx(Text, { style: [styles.section, {
|
|
486
|
+
color: theme.muted
|
|
487
|
+
}], children: g.category.toUpperCase() }),
|
|
488
|
+
g.entries.map((e) => /* @__PURE__ */ jsx(EntryRow, { entry: e, connected: isConnected(e), onPress: () => pick({
|
|
489
|
+
kind: "connector",
|
|
490
|
+
entry: e
|
|
491
|
+
}), theme }, e.id))
|
|
492
|
+
] }, g.category)),
|
|
493
|
+
!loading && !failed && !featured.length && !groups.length ? /* @__PURE__ */ jsx(Text, { style: [styles.help, styles.center, {
|
|
494
|
+
color: theme.muted
|
|
495
|
+
}], children: search.trim() ? "No integrations match." : "More integrations show up here when your organization adds them." }) : null
|
|
496
|
+
] })
|
|
497
|
+
] });
|
|
498
|
+
}
|
|
499
|
+
let title = "Integrations";
|
|
500
|
+
if ((picked == null ? void 0 : picked.kind) === "ai") title = "Add AI to my site";
|
|
501
|
+
else if ((picked == null ? void 0 : picked.kind) === "email") title = "Email from my domain";
|
|
502
|
+
else if ((picked == null ? void 0 : picked.kind) === "connector") title = picked.entry.title;
|
|
503
|
+
return /* @__PURE__ */ jsx(Sheet, { visible, title, onClose, theme, testID: "webbuilder-integrations", children: body });
|
|
504
|
+
}
|
|
505
|
+
const styles = StyleSheet.create({
|
|
506
|
+
scroll: {
|
|
507
|
+
flexGrow: 0,
|
|
508
|
+
flexShrink: 1
|
|
509
|
+
},
|
|
510
|
+
body: {
|
|
511
|
+
gap: 10,
|
|
512
|
+
paddingBottom: 12
|
|
513
|
+
},
|
|
514
|
+
list: {
|
|
515
|
+
flexGrow: 0,
|
|
516
|
+
flexShrink: 1
|
|
517
|
+
},
|
|
518
|
+
help: {
|
|
519
|
+
fontSize: 13,
|
|
520
|
+
lineHeight: 18
|
|
521
|
+
},
|
|
522
|
+
hint: {
|
|
523
|
+
fontSize: 13,
|
|
524
|
+
lineHeight: 18
|
|
525
|
+
},
|
|
526
|
+
label: {
|
|
527
|
+
fontSize: 14,
|
|
528
|
+
fontWeight: "600",
|
|
529
|
+
marginTop: 6
|
|
530
|
+
},
|
|
531
|
+
rowLabel: {
|
|
532
|
+
fontSize: 16,
|
|
533
|
+
fontWeight: "500"
|
|
534
|
+
},
|
|
535
|
+
row: {
|
|
536
|
+
flexDirection: "row",
|
|
537
|
+
alignItems: "center",
|
|
538
|
+
gap: 12,
|
|
539
|
+
paddingVertical: 11
|
|
540
|
+
},
|
|
541
|
+
card: {
|
|
542
|
+
flexDirection: "row",
|
|
543
|
+
alignItems: "center",
|
|
544
|
+
gap: 12,
|
|
545
|
+
padding: 12,
|
|
546
|
+
borderRadius: 12,
|
|
547
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
548
|
+
marginBottom: 6
|
|
549
|
+
},
|
|
550
|
+
grow: {
|
|
551
|
+
flex: 1
|
|
552
|
+
},
|
|
553
|
+
logo: {
|
|
554
|
+
width: 34,
|
|
555
|
+
height: 34,
|
|
556
|
+
borderRadius: 8
|
|
557
|
+
},
|
|
558
|
+
logoBlank: {
|
|
559
|
+
alignItems: "center",
|
|
560
|
+
justifyContent: "center"
|
|
561
|
+
},
|
|
562
|
+
badge: {
|
|
563
|
+
fontSize: 11,
|
|
564
|
+
fontWeight: "700",
|
|
565
|
+
borderWidth: 1,
|
|
566
|
+
borderRadius: 6,
|
|
567
|
+
paddingHorizontal: 6,
|
|
568
|
+
paddingVertical: 1
|
|
569
|
+
},
|
|
570
|
+
section: {
|
|
571
|
+
fontSize: 12,
|
|
572
|
+
fontWeight: "700",
|
|
573
|
+
letterSpacing: 0.6,
|
|
574
|
+
paddingTop: 10,
|
|
575
|
+
paddingBottom: 2
|
|
576
|
+
},
|
|
577
|
+
search: {
|
|
578
|
+
flexDirection: "row",
|
|
579
|
+
alignItems: "center",
|
|
580
|
+
gap: 8,
|
|
581
|
+
borderWidth: 1.5,
|
|
582
|
+
borderRadius: 12,
|
|
583
|
+
paddingHorizontal: 12,
|
|
584
|
+
minHeight: 48
|
|
585
|
+
},
|
|
586
|
+
searchInput: {
|
|
587
|
+
flex: 1,
|
|
588
|
+
fontSize: 16,
|
|
589
|
+
paddingVertical: 10
|
|
590
|
+
},
|
|
591
|
+
input: {
|
|
592
|
+
borderWidth: 1,
|
|
593
|
+
borderRadius: 12,
|
|
594
|
+
paddingHorizontal: 14,
|
|
595
|
+
paddingVertical: 12,
|
|
596
|
+
fontSize: 16
|
|
597
|
+
},
|
|
598
|
+
status: {
|
|
599
|
+
flexDirection: "row",
|
|
600
|
+
alignItems: "center",
|
|
601
|
+
gap: 8,
|
|
602
|
+
padding: 10,
|
|
603
|
+
borderRadius: 10,
|
|
604
|
+
borderWidth: StyleSheet.hairlineWidth
|
|
605
|
+
},
|
|
606
|
+
column: {
|
|
607
|
+
flexDirection: "column",
|
|
608
|
+
alignItems: "stretch"
|
|
609
|
+
},
|
|
610
|
+
link: {
|
|
611
|
+
fontSize: 14,
|
|
612
|
+
fontWeight: "600"
|
|
613
|
+
},
|
|
614
|
+
record: {
|
|
615
|
+
gap: 6,
|
|
616
|
+
padding: 10,
|
|
617
|
+
borderRadius: 10,
|
|
618
|
+
borderWidth: StyleSheet.hairlineWidth
|
|
619
|
+
},
|
|
620
|
+
recordLine: {
|
|
621
|
+
flexDirection: "row",
|
|
622
|
+
alignItems: "center",
|
|
623
|
+
gap: 8
|
|
624
|
+
},
|
|
625
|
+
mono: {
|
|
626
|
+
flex: 1,
|
|
627
|
+
fontSize: 13,
|
|
628
|
+
fontFamily: "Menlo"
|
|
629
|
+
},
|
|
630
|
+
back: {
|
|
631
|
+
flexDirection: "row",
|
|
632
|
+
alignItems: "center",
|
|
633
|
+
gap: 2,
|
|
634
|
+
alignSelf: "flex-start",
|
|
635
|
+
paddingVertical: 4
|
|
636
|
+
},
|
|
637
|
+
spin: {
|
|
638
|
+
paddingVertical: 20
|
|
639
|
+
},
|
|
640
|
+
center: {
|
|
641
|
+
textAlign: "center"
|
|
642
|
+
}
|
|
643
|
+
});export{IntegrationsPanel};//# sourceMappingURL=IntegrationsPanel.js.map
|