@gemies/sdk 4.0.0 → 5.0.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/CHANGELOG.md +27 -0
- package/package.json +2 -2
- package/src/components/GemieGroupWelcome.tsx +1 -1
- package/src/components/connectors/GemieConnectorsStore.tsx +208 -78
- package/src/connectors.ts +14 -5
- package/src/lib/copy-en.ts +28 -1
- package/src/lib/copy-es.ts +28 -1
- package/src/runtime/api.ts +4 -2
- package/src/runtime/connectors.ts +101 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @gemies/sdk
|
|
2
2
|
|
|
3
|
+
## 5.0.0
|
|
4
|
+
|
|
5
|
+
- **The connectors store grows to hundreds of servers.** Beside the providers' servers Gemies curates,
|
|
6
|
+
the store lists the remote MCP servers synced from the official MCP Registry once their health check
|
|
7
|
+
passed (Gemies API, `lib/connector-catalogue/`). `GemieConnectorsStore` searches, filters and sorts
|
|
8
|
+
on the API and pages through the results (Show more): categories with their counts, the Official,
|
|
9
|
+
Verified and No sign-in filters, and Featured, Name or Recently updated. Each card carries its badge
|
|
10
|
+
(`official`, `verified`, `community`) and says when it connects without a sign-in.
|
|
11
|
+
- **Breaking:** `useConnectorCatalogue` is replaced by `useConnectorStore(query)`, an infinite query of
|
|
12
|
+
`GET /mcp/registry` pages (`ConnectorStorePage`: `servers`, `total`, `nextOffset`, `categories`).
|
|
13
|
+
`ConnectorEntry` gains `trust`, `source`, `signIn` and `toolCount`, and its `docsUrl` may be `null`.
|
|
14
|
+
`CONNECTOR_CATEGORIES` gains `design`, `finance`, `marketing`, `commerce`, `search` and `other`;
|
|
15
|
+
`CONNECTOR_TRUST`, `CONNECTOR_SORTS`, `CONNECTOR_STORE_PAGE_SIZE` and `connectorStoreParams` are new.
|
|
16
|
+
- `useConnectorActions().connect` resolves with the connection at once for a server that needs no
|
|
17
|
+
sign-in (`POST /mcp/connect` answers `{ server }`), and opens the provider's sign-in otherwise.
|
|
18
|
+
- New copy: `gemie.connectors.trust.*`, `gemie.connectors.category.{design,finance,marketing,commerce,search,other}`,
|
|
19
|
+
`gemie.connectors.store.{allCount,results,more,filters,filter.*,sort,sortBy.*}`; the store's
|
|
20
|
+
description says where its servers come from.
|
|
21
|
+
|
|
22
|
+
## 4.1.0
|
|
23
|
+
|
|
24
|
+
- **The group welcome no longer links Bloom's whole multi-agent template.** `GemieGroupWelcome`
|
|
25
|
+
imports `SelectedAgentPreview` from `@oxy.so/bloom/multi-agent-chat/selected-agent-preview`
|
|
26
|
+
instead of the `multi-agent-chat` barrel: in Gemies' web export that took `multi-agent-chat` from
|
|
27
|
+
149,484 to 9,309 bytes of the chunk every route loads first. The Bloom peer floor is
|
|
28
|
+
`>=21.1.0`, the first Bloom with that entry.
|
|
29
|
+
|
|
3
30
|
## 4.0.0
|
|
4
31
|
|
|
5
32
|
- **Breaking: a connected account is the person's, granted to their gemies (Gemies ADR 0035 as
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gemies/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "The Gemies SDK: the conversation runtime, chat UI, voice calls and dictation for Oxy apps that talk to a gemie",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"react-native": "src/index.ts",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"react": "^19.2.3",
|
|
60
60
|
"react-native": "^0.86.0 || ^0.88.0",
|
|
61
61
|
"@expo/vector-icons": "^15.1.1",
|
|
62
|
-
"@oxy.so/bloom": ">=
|
|
62
|
+
"@oxy.so/bloom": ">=21.1.0",
|
|
63
63
|
"@oxy.so/core": ">=7.1.0 <8",
|
|
64
64
|
"@oxy.so/services": ">=14.19.1 <15",
|
|
65
65
|
"@tanstack/react-query": "^5.101",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useAvatarFlights } from '@oxy.so/bloom/avatar-flight';
|
|
2
|
-
import { SelectedAgentPreview } from '@oxy.so/bloom/multi-agent-chat';
|
|
2
|
+
import { SelectedAgentPreview } from '@oxy.so/bloom/multi-agent-chat/selected-agent-preview';
|
|
3
3
|
import { Text, View } from 'react-native';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { useGemieFlights } from '../lib/flights';
|
|
@@ -4,26 +4,42 @@ import {
|
|
|
4
4
|
AccordionItem,
|
|
5
5
|
AccordionTrigger,
|
|
6
6
|
} from '@oxy.so/bloom/accordion';
|
|
7
|
+
import { Badge } from '@oxy.so/bloom/badge';
|
|
7
8
|
import { Button } from '@oxy.so/bloom/button';
|
|
8
9
|
import { Chip, ChipRow } from '@oxy.so/bloom/chip';
|
|
9
10
|
import { Dialog } from '@oxy.so/bloom/dialog';
|
|
10
11
|
import { RiAddLine } from '@oxy.so/bloom/icons/RiAddLine';
|
|
12
|
+
import { RiLockUnlockLine } from '@oxy.so/bloom/icons/RiLockUnlockLine';
|
|
13
|
+
import { RiShieldCheckFill } from '@oxy.so/bloom/icons/RiShieldCheckFill';
|
|
14
|
+
import { RiShieldCheckLine } from '@oxy.so/bloom/icons/RiShieldCheckLine';
|
|
15
|
+
import { RiUserCommunityLine } from '@oxy.so/bloom/icons/RiUserCommunityLine';
|
|
11
16
|
import { Search } from '@oxy.so/bloom/search';
|
|
17
|
+
import {
|
|
18
|
+
Select,
|
|
19
|
+
SelectContent,
|
|
20
|
+
SelectIcon,
|
|
21
|
+
SelectItem,
|
|
22
|
+
SelectItemText,
|
|
23
|
+
SelectTrigger,
|
|
24
|
+
SelectValue,
|
|
25
|
+
} from '@oxy.so/bloom/select';
|
|
12
26
|
import * as Skeleton from '@oxy.so/bloom/skeleton';
|
|
13
27
|
import { TextFieldInput, TextFieldLabel } from '@oxy.so/bloom/text-field';
|
|
14
28
|
import { toast } from '@oxy.so/bloom/toast';
|
|
15
29
|
import { Text } from '@oxy.so/bloom/typography';
|
|
16
30
|
import * as WebBrowser from 'expo-web-browser';
|
|
17
|
-
import { useMemo, useState } from 'react';
|
|
31
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
18
32
|
import { Pressable, View } from 'react-native';
|
|
19
33
|
import { englishCopy, type Translate } from '../../lib/copy';
|
|
20
34
|
import {
|
|
21
|
-
|
|
35
|
+
CONNECTOR_SORTS,
|
|
22
36
|
type ConnectorCategory,
|
|
23
37
|
type ConnectorEntry,
|
|
38
|
+
type ConnectorSort,
|
|
39
|
+
type ConnectorTrust,
|
|
24
40
|
useConnections,
|
|
25
41
|
useConnectorActions,
|
|
26
|
-
|
|
42
|
+
useConnectorStore,
|
|
27
43
|
connectorReturnTo,
|
|
28
44
|
signInErrorKey,
|
|
29
45
|
useWebSignInReturn,
|
|
@@ -33,6 +49,9 @@ import { ConnectorLogo } from './ConnectorLogo';
|
|
|
33
49
|
/** This component's own strings. */
|
|
34
50
|
const K = 'gemie.connectors';
|
|
35
51
|
|
|
52
|
+
/** How long typing settles before the store is searched. */
|
|
53
|
+
const SEARCH_DEBOUNCE_MS = 250;
|
|
54
|
+
|
|
36
55
|
export interface GemieConnectorsStoreProps {
|
|
37
56
|
/**
|
|
38
57
|
* The native app's URL scheme (`gemies`, `alia`): a provider's sign-in returns to the store at
|
|
@@ -45,18 +64,56 @@ export interface GemieConnectorsStoreProps {
|
|
|
45
64
|
onConnected?: () => void;
|
|
46
65
|
}
|
|
47
66
|
|
|
67
|
+
const TRUST_ICON = {
|
|
68
|
+
official: RiShieldCheckFill,
|
|
69
|
+
verified: RiShieldCheckLine,
|
|
70
|
+
community: RiUserCommunityLine,
|
|
71
|
+
} as const;
|
|
72
|
+
const TRUST_COLOR = { official: 'primary', verified: 'info', community: 'default' } as const;
|
|
73
|
+
|
|
74
|
+
/** The filters a person can turn on, each a chip. */
|
|
75
|
+
const FILTERS = ['official', 'verified', 'noSignIn'] as const;
|
|
76
|
+
type StoreFilter = (typeof FILTERS)[number];
|
|
77
|
+
|
|
78
|
+
/** The value of `text` once it stopped changing for `ms`. */
|
|
79
|
+
function useSettled(text: string, ms: number): string {
|
|
80
|
+
const [settled, setSettled] = useState(text);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const timer = setTimeout(() => setSettled(text), ms);
|
|
83
|
+
return () => clearTimeout(timer);
|
|
84
|
+
}, [text, ms]);
|
|
85
|
+
return settled;
|
|
86
|
+
}
|
|
87
|
+
|
|
48
88
|
/**
|
|
49
|
-
* The connectors store: every
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
89
|
+
* The connectors store: every remote MCP server this deployment can connect — the providers'
|
|
90
|
+
* servers Gemies curates and the hundreds synced from the official MCP Registry — searched,
|
|
91
|
+
* filtered by category, badge and sign-in, sorted and paged by the API. Each shows its real logo,
|
|
92
|
+
* its badge (official, verified, community), what it does and a Connect button; connecting again
|
|
93
|
+
* adds another account. A person can also add their own MCP server by URL. What the person
|
|
94
|
+
* connected is managed in Settings (`GemieConnectedConnectors`), not here.
|
|
53
95
|
*/
|
|
54
96
|
export function GemieConnectorsStore({
|
|
55
97
|
nativeScheme,
|
|
56
98
|
t = englishCopy,
|
|
57
99
|
onConnected,
|
|
58
100
|
}: GemieConnectorsStoreProps) {
|
|
59
|
-
const
|
|
101
|
+
const [query, setQuery] = useState('');
|
|
102
|
+
const [category, setCategory] = useState<ConnectorCategory | null>(null);
|
|
103
|
+
const [filters, setFilters] = useState<ReadonlySet<StoreFilter>>(new Set());
|
|
104
|
+
const [sort, setSort] = useState<ConnectorSort>('featured');
|
|
105
|
+
const [pending, setPending] = useState<string | null>(null);
|
|
106
|
+
const [customOpen, setCustomOpen] = useState(false);
|
|
107
|
+
const q = useSettled(query.trim(), SEARCH_DEBOUNCE_MS);
|
|
108
|
+
|
|
109
|
+
const trust = (['official', 'verified'] as const).filter((badge) => filters.has(badge));
|
|
110
|
+
const store = useConnectorStore({
|
|
111
|
+
q,
|
|
112
|
+
category: category ?? undefined,
|
|
113
|
+
trust: trust as ConnectorTrust[],
|
|
114
|
+
noSignIn: filters.has('noSignIn'),
|
|
115
|
+
sort,
|
|
116
|
+
});
|
|
60
117
|
const connections = useConnections();
|
|
61
118
|
const actions = useConnectorActions({ returnTo: connectorReturnTo(nativeScheme) });
|
|
62
119
|
useWebSignInReturn((outcome) => {
|
|
@@ -66,10 +123,6 @@ export function GemieConnectorsStore({
|
|
|
66
123
|
toast.error(t(signInErrorKey(outcome.error)));
|
|
67
124
|
}
|
|
68
125
|
});
|
|
69
|
-
const [query, setQuery] = useState('');
|
|
70
|
-
const [category, setCategory] = useState<ConnectorCategory | null>(null);
|
|
71
|
-
const [pending, setPending] = useState<string | null>(null);
|
|
72
|
-
const [customOpen, setCustomOpen] = useState(false);
|
|
73
126
|
|
|
74
127
|
const accountsOf = useMemo(() => {
|
|
75
128
|
const counts = new Map<string, number>();
|
|
@@ -81,23 +134,21 @@ export function GemieConnectorsStore({
|
|
|
81
134
|
return counts;
|
|
82
135
|
}, [connections.data]);
|
|
83
136
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
entry.description.toLowerCase().includes(words)),
|
|
92
|
-
);
|
|
93
|
-
}, [catalogue.data, query, category]);
|
|
137
|
+
const pages = store.data?.pages ?? [];
|
|
138
|
+
const entries = pages.flatMap((page) => page.servers);
|
|
139
|
+
const total = pages[0]?.total ?? 0;
|
|
140
|
+
const categories = pages[0]?.categories ?? [];
|
|
141
|
+
const browsing = !q && category === null && filters.size === 0 && sort === 'featured';
|
|
142
|
+
const featured = browsing ? entries.filter((entry) => entry.featured) : [];
|
|
143
|
+
const rest = browsing ? entries.filter((entry) => !entry.featured) : entries;
|
|
94
144
|
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
145
|
+
const toggle = (filter: StoreFilter) =>
|
|
146
|
+
setFilters((current) => {
|
|
147
|
+
const next = new Set(current);
|
|
148
|
+
if (next.has(filter)) next.delete(filter);
|
|
149
|
+
else next.add(filter);
|
|
150
|
+
return next;
|
|
151
|
+
});
|
|
101
152
|
|
|
102
153
|
const connect = async (entry: ConnectorEntry) => {
|
|
103
154
|
setPending(entry.id);
|
|
@@ -114,6 +165,17 @@ export function GemieConnectorsStore({
|
|
|
114
165
|
}
|
|
115
166
|
};
|
|
116
167
|
|
|
168
|
+
const card = (entry: ConnectorEntry) => (
|
|
169
|
+
<StoreCard
|
|
170
|
+
key={entry.id}
|
|
171
|
+
entry={entry}
|
|
172
|
+
accounts={accountsOf.get(entry.id) ?? 0}
|
|
173
|
+
pending={pending === entry.id}
|
|
174
|
+
onConnect={connect}
|
|
175
|
+
t={t}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
|
|
117
179
|
return (
|
|
118
180
|
<View className="gap-4">
|
|
119
181
|
<Search
|
|
@@ -122,7 +184,7 @@ export function GemieConnectorsStore({
|
|
|
122
184
|
onChangeText={setQuery}
|
|
123
185
|
onClearText={() => setQuery('')}
|
|
124
186
|
/>
|
|
125
|
-
{categories.length > 1 ? (
|
|
187
|
+
{categories.length > 1 || category !== null ? (
|
|
126
188
|
<ChipRow role="radiogroup" accessibilityLabel={t(`${K}.store.categories`)}>
|
|
127
189
|
<Chip
|
|
128
190
|
size="sm"
|
|
@@ -132,68 +194,81 @@ export function GemieConnectorsStore({
|
|
|
132
194
|
>
|
|
133
195
|
{t(`${K}.store.all`)}
|
|
134
196
|
</Chip>
|
|
135
|
-
{categories.map((
|
|
197
|
+
{categories.map(({ id, count }) => (
|
|
136
198
|
<Chip
|
|
137
|
-
key={
|
|
199
|
+
key={id}
|
|
138
200
|
size="sm"
|
|
139
201
|
role="radio"
|
|
140
|
-
selected={category ===
|
|
141
|
-
onPress={() => setCategory(category ===
|
|
202
|
+
selected={category === id}
|
|
203
|
+
onPress={() => setCategory(category === id ? null : id)}
|
|
142
204
|
>
|
|
143
|
-
{t(`${K}.category.${
|
|
205
|
+
{`${t(`${K}.category.${id}`)} ${count}`}
|
|
144
206
|
</Chip>
|
|
145
207
|
))}
|
|
146
208
|
</ChipRow>
|
|
147
209
|
) : null}
|
|
210
|
+
<View className="flex-row flex-wrap items-center justify-between gap-3">
|
|
211
|
+
<ChipRow role="group" accessibilityLabel={t(`${K}.store.filters`)}>
|
|
212
|
+
{FILTERS.map((filter) => (
|
|
213
|
+
<Chip
|
|
214
|
+
key={filter}
|
|
215
|
+
size="sm"
|
|
216
|
+
role="checkbox"
|
|
217
|
+
selected={filters.has(filter)}
|
|
218
|
+
onPress={() => toggle(filter)}
|
|
219
|
+
>
|
|
220
|
+
{t(`${K}.store.filter.${filter}`)}
|
|
221
|
+
</Chip>
|
|
222
|
+
))}
|
|
223
|
+
</ChipRow>
|
|
224
|
+
<SortSelect value={sort} onChange={setSort} t={t} />
|
|
225
|
+
</View>
|
|
148
226
|
|
|
149
|
-
{
|
|
227
|
+
{store.isPending ? (
|
|
150
228
|
<StoreSkeleton />
|
|
151
|
-
) :
|
|
229
|
+
) : store.isError && entries.length === 0 ? (
|
|
152
230
|
<View className="items-start gap-2 py-4">
|
|
153
231
|
<Text variant="body-2-regular" className="text-text-secondary">
|
|
154
232
|
{t(`${K}.store.loadFailed`)}
|
|
155
233
|
</Text>
|
|
156
|
-
<Button size="sm" appearance="outline" tone="neutral" onPress={() =>
|
|
234
|
+
<Button size="sm" appearance="outline" tone="neutral" onPress={() => store.refetch()}>
|
|
157
235
|
{t(`${K}.store.retry`)}
|
|
158
236
|
</Button>
|
|
159
237
|
</View>
|
|
160
238
|
) : (
|
|
161
239
|
<>
|
|
162
240
|
{featured.length > 0 ? (
|
|
163
|
-
<StoreGroup title={t(`${K}.store.featured`)}>
|
|
164
|
-
{featured.map((entry) => (
|
|
165
|
-
<StoreCard
|
|
166
|
-
key={entry.id}
|
|
167
|
-
entry={entry}
|
|
168
|
-
accounts={accountsOf.get(entry.id) ?? 0}
|
|
169
|
-
pending={pending === entry.id}
|
|
170
|
-
onConnect={connect}
|
|
171
|
-
t={t}
|
|
172
|
-
/>
|
|
173
|
-
))}
|
|
174
|
-
</StoreGroup>
|
|
241
|
+
<StoreGroup title={t(`${K}.store.featured`)}>{featured.map(card)}</StoreGroup>
|
|
175
242
|
) : null}
|
|
176
243
|
{rest.length > 0 ? (
|
|
177
|
-
<StoreGroup
|
|
178
|
-
{
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
t={t}
|
|
186
|
-
/>
|
|
187
|
-
))}
|
|
244
|
+
<StoreGroup
|
|
245
|
+
title={
|
|
246
|
+
browsing
|
|
247
|
+
? t(`${K}.store.allCount`, { count: total })
|
|
248
|
+
: t(`${K}.store.results`, { count: total })
|
|
249
|
+
}
|
|
250
|
+
>
|
|
251
|
+
{rest.map(card)}
|
|
188
252
|
</StoreGroup>
|
|
189
253
|
) : null}
|
|
190
|
-
{
|
|
254
|
+
{entries.length === 0 ? (
|
|
191
255
|
<Text variant="body-2-regular" className="py-4 text-text-secondary">
|
|
192
|
-
{query.
|
|
193
|
-
? t(`${K}.store.noResults`, { query: query.trim() })
|
|
194
|
-
: t(`${K}.store.empty`)}
|
|
256
|
+
{q ? t(`${K}.store.noResults`, { query: q }) : t(`${K}.store.empty`)}
|
|
195
257
|
</Text>
|
|
196
258
|
) : null}
|
|
259
|
+
{store.hasNextPage ? (
|
|
260
|
+
<View className="items-center">
|
|
261
|
+
<Button
|
|
262
|
+
size="sm"
|
|
263
|
+
appearance="outline"
|
|
264
|
+
tone="neutral"
|
|
265
|
+
loading={store.isFetchingNextPage}
|
|
266
|
+
onPress={() => void store.fetchNextPage()}
|
|
267
|
+
>
|
|
268
|
+
{t(`${K}.store.more`, { count: total - entries.length })}
|
|
269
|
+
</Button>
|
|
270
|
+
</View>
|
|
271
|
+
) : null}
|
|
197
272
|
</>
|
|
198
273
|
)}
|
|
199
274
|
|
|
@@ -227,6 +302,41 @@ export function GemieConnectorsStore({
|
|
|
227
302
|
);
|
|
228
303
|
}
|
|
229
304
|
|
|
305
|
+
function SortSelect({
|
|
306
|
+
value,
|
|
307
|
+
onChange,
|
|
308
|
+
t,
|
|
309
|
+
}: {
|
|
310
|
+
value: ConnectorSort;
|
|
311
|
+
onChange: (sort: ConnectorSort) => void;
|
|
312
|
+
t: Translate;
|
|
313
|
+
}) {
|
|
314
|
+
const label = t(`${K}.store.sort`);
|
|
315
|
+
const items = CONNECTOR_SORTS.map((sort) => ({
|
|
316
|
+
id: sort,
|
|
317
|
+
label: t(`${K}.store.sortBy.${sort}`),
|
|
318
|
+
}));
|
|
319
|
+
return (
|
|
320
|
+
<Select size="sm" value={value} onValueChange={(next) => onChange(next as ConnectorSort)}>
|
|
321
|
+
<SelectTrigger label={label}>
|
|
322
|
+
<SelectValue placeholder={label} />
|
|
323
|
+
<SelectIcon />
|
|
324
|
+
</SelectTrigger>
|
|
325
|
+
<SelectContent
|
|
326
|
+
label={label}
|
|
327
|
+
items={items}
|
|
328
|
+
width={220}
|
|
329
|
+
valueExtractor={(item) => item.id}
|
|
330
|
+
renderItem={(item) => (
|
|
331
|
+
<SelectItem value={item.id} label={item.label}>
|
|
332
|
+
<SelectItemText>{item.label}</SelectItemText>
|
|
333
|
+
</SelectItem>
|
|
334
|
+
)}
|
|
335
|
+
/>
|
|
336
|
+
</Select>
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
230
340
|
function StoreGroup({ title, children }: { title?: string; children: React.ReactNode }) {
|
|
231
341
|
return (
|
|
232
342
|
<View className="gap-2">
|
|
@@ -253,15 +363,33 @@ function StoreCard({
|
|
|
253
363
|
<View className="min-w-[260px] flex-1 basis-[260px] gap-3 rounded-2xl border border-border p-4">
|
|
254
364
|
<View className="flex-row items-center gap-3">
|
|
255
365
|
<ConnectorLogo name={entry.name} logoUrl={entry.logoUrl} size={40} />
|
|
256
|
-
<View className="flex-1">
|
|
366
|
+
<View className="flex-1 gap-1">
|
|
257
367
|
<Text variant="body-2-semibold" numberOfLines={1}>
|
|
258
368
|
{entry.name}
|
|
259
369
|
</Text>
|
|
260
|
-
<
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
370
|
+
<View className="flex-row flex-wrap items-center gap-1.5">
|
|
371
|
+
<Badge
|
|
372
|
+
size="label-small"
|
|
373
|
+
variant="subtle"
|
|
374
|
+
color={TRUST_COLOR[entry.trust]}
|
|
375
|
+
icon={TRUST_ICON[entry.trust]}
|
|
376
|
+
content={t(`${K}.trust.${entry.trust}`)}
|
|
377
|
+
/>
|
|
378
|
+
{entry.signIn === 'none' ? (
|
|
379
|
+
<Badge
|
|
380
|
+
size="label-small"
|
|
381
|
+
variant="subtle"
|
|
382
|
+
color="success"
|
|
383
|
+
icon={RiLockUnlockLine}
|
|
384
|
+
content={t(`${K}.store.filter.noSignIn`)}
|
|
385
|
+
/>
|
|
386
|
+
) : null}
|
|
387
|
+
<Text variant="body-2-regular" className="text-text-secondary" numberOfLines={1}>
|
|
388
|
+
{accounts > 0
|
|
389
|
+
? t(`${K}.store.connectedCount`, { count: accounts })
|
|
390
|
+
: t(`${K}.category.${entry.category}`)}
|
|
391
|
+
</Text>
|
|
392
|
+
</View>
|
|
265
393
|
</View>
|
|
266
394
|
</View>
|
|
267
395
|
<Text variant="body-2-regular" className="text-text-secondary" numberOfLines={2}>
|
|
@@ -277,14 +405,16 @@ function StoreCard({
|
|
|
277
405
|
>
|
|
278
406
|
{accounts > 0 ? t(`${K}.store.connectAnother`) : t(`${K}.store.connect`)}
|
|
279
407
|
</Button>
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
408
|
+
{entry.docsUrl ? (
|
|
409
|
+
<Button
|
|
410
|
+
size="sm"
|
|
411
|
+
appearance="plain"
|
|
412
|
+
tone="neutral"
|
|
413
|
+
onPress={() => void WebBrowser.openBrowserAsync(entry.docsUrl as string)}
|
|
414
|
+
>
|
|
415
|
+
{t(`${K}.store.docs`)}
|
|
416
|
+
</Button>
|
|
417
|
+
) : null}
|
|
288
418
|
</View>
|
|
289
419
|
</View>
|
|
290
420
|
);
|
package/src/connectors.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="nativewind/types" />
|
|
2
2
|
/**
|
|
3
|
-
* The connectors leaf entry: the
|
|
4
|
-
* Linear, Slack…)
|
|
5
|
-
*
|
|
6
|
-
* the
|
|
3
|
+
* The connectors leaf entry: the remote MCP servers a person connects — the providers' own
|
|
4
|
+
* (Notion, Linear, Slack…), the hundreds synced from the official MCP Registry — and their own MCP
|
|
5
|
+
* servers by URL. The store where they are found and connected, the Settings list of what was
|
|
6
|
+
* connected, the one logo every screen draws for a connector, and the switch every list that grants
|
|
7
|
+
* a connected account to a gemie draws (`GrantSwitchRow`).
|
|
7
8
|
* The Gemies and the Alia apps both draw these; neither keeps a copy.
|
|
8
9
|
*/
|
|
9
10
|
export { ConnectorLogo } from './components/connectors/ConnectorLogo';
|
|
@@ -17,16 +18,20 @@ export type { GrantSwitchRowProps } from './components/connectors/GrantSwitchRow
|
|
|
17
18
|
export {
|
|
18
19
|
CONNECTOR_CATEGORIES,
|
|
19
20
|
CONNECTOR_ROUTES,
|
|
21
|
+
CONNECTOR_SORTS,
|
|
22
|
+
CONNECTOR_STORE_PAGE_SIZE,
|
|
23
|
+
CONNECTOR_TRUST,
|
|
20
24
|
CONNECTORS_PATH,
|
|
21
25
|
connectionOfTool,
|
|
22
26
|
connectorQueryKeys,
|
|
23
27
|
connectorReturnTo,
|
|
28
|
+
connectorStoreParams,
|
|
24
29
|
signInResult,
|
|
25
30
|
useConnectionOfTool,
|
|
26
31
|
useConnections,
|
|
27
32
|
useConnectorActions,
|
|
28
|
-
useConnectorCatalogue,
|
|
29
33
|
useConnectorLogoUrl,
|
|
34
|
+
useConnectorStore,
|
|
30
35
|
useWebSignInReturn,
|
|
31
36
|
} from './runtime/connectors';
|
|
32
37
|
export type {
|
|
@@ -34,4 +39,8 @@ export type {
|
|
|
34
39
|
ConnectionStatus,
|
|
35
40
|
ConnectorCategory,
|
|
36
41
|
ConnectorEntry,
|
|
42
|
+
ConnectorSort,
|
|
43
|
+
ConnectorStorePage,
|
|
44
|
+
ConnectorStoreQuery,
|
|
45
|
+
ConnectorTrust,
|
|
37
46
|
} from './runtime/connectors';
|
package/src/lib/copy-en.ts
CHANGED
|
@@ -151,10 +151,16 @@ export const COPY_EN: Readonly<Record<string, CopyEntry>> = {
|
|
|
151
151
|
'faircoin.updated': 'Updated %{time}',
|
|
152
152
|
'faircoin.volume': '24h volume',
|
|
153
153
|
'gemie.connectors.cancel': 'Cancel',
|
|
154
|
+
'gemie.connectors.category.commerce': 'Commerce',
|
|
154
155
|
'gemie.connectors.category.communication': 'Communication',
|
|
155
156
|
'gemie.connectors.category.data': 'Data',
|
|
157
|
+
'gemie.connectors.category.design': 'Design',
|
|
156
158
|
'gemie.connectors.category.development': 'Development',
|
|
159
|
+
'gemie.connectors.category.finance': 'Finance',
|
|
160
|
+
'gemie.connectors.category.marketing': 'Marketing',
|
|
161
|
+
'gemie.connectors.category.other': 'Other',
|
|
157
162
|
'gemie.connectors.category.productivity': 'Productivity',
|
|
163
|
+
'gemie.connectors.category.search': 'Search and research',
|
|
158
164
|
'gemie.connectors.connected.browse': 'Browse connectors',
|
|
159
165
|
'gemie.connectors.connected.description':
|
|
160
166
|
'The accounts you connected. Alia can use every one; other gemies only the ones you give them in their editor.',
|
|
@@ -200,6 +206,10 @@ export const COPY_EN: Readonly<Record<string, CopyEntry>> = {
|
|
|
200
206
|
'gemie.connectors.status.installed': 'Not connected yet',
|
|
201
207
|
'gemie.connectors.status.running': 'Connected',
|
|
202
208
|
'gemie.connectors.store.all': 'All',
|
|
209
|
+
'gemie.connectors.store.allCount': {
|
|
210
|
+
one: 'All connectors · 1',
|
|
211
|
+
other: 'All connectors · {{count}}',
|
|
212
|
+
},
|
|
203
213
|
'gemie.connectors.store.categories': 'Categories',
|
|
204
214
|
'gemie.connectors.store.connect': 'Connect',
|
|
205
215
|
'gemie.connectors.store.connectAnother': 'Add account',
|
|
@@ -208,16 +218,33 @@ export const COPY_EN: Readonly<Record<string, CopyEntry>> = {
|
|
|
208
218
|
other: '{{count}} accounts connected',
|
|
209
219
|
},
|
|
210
220
|
'gemie.connectors.store.description':
|
|
211
|
-
'Connect the apps you work with.
|
|
221
|
+
'Connect the apps you work with: the providers’ own MCP servers, and hundreds more from the official MCP Registry. Official means the provider publishes it; Community means a developer does. When one asks you to sign in, you sign in with them, and Gemies never sees your password.',
|
|
212
222
|
'gemie.connectors.store.docs': 'About',
|
|
213
223
|
'gemie.connectors.store.empty': 'No connector is available right now.',
|
|
214
224
|
'gemie.connectors.store.featured': 'Featured',
|
|
225
|
+
'gemie.connectors.store.filter.noSignIn': 'No sign-in',
|
|
226
|
+
'gemie.connectors.store.filter.official': 'Official',
|
|
227
|
+
'gemie.connectors.store.filter.verified': 'Verified',
|
|
228
|
+
'gemie.connectors.store.filters': 'Filters',
|
|
215
229
|
'gemie.connectors.store.loadFailed': 'Connectors could not be loaded.',
|
|
230
|
+
'gemie.connectors.store.more': { one: 'Show 1 more', other: 'Show more ({{count}} left)' },
|
|
216
231
|
'gemie.connectors.store.noResults': 'No connector matches “{{query}}”.',
|
|
232
|
+
'gemie.connectors.store.results': {
|
|
233
|
+
zero: 'No results',
|
|
234
|
+
one: '1 result',
|
|
235
|
+
other: '{{count}} results',
|
|
236
|
+
},
|
|
217
237
|
'gemie.connectors.store.retry': 'Retry',
|
|
218
238
|
'gemie.connectors.store.search': 'Search connectors',
|
|
239
|
+
'gemie.connectors.store.sort': 'Sort by',
|
|
240
|
+
'gemie.connectors.store.sortBy.featured': 'Featured',
|
|
241
|
+
'gemie.connectors.store.sortBy.name': 'Name',
|
|
242
|
+
'gemie.connectors.store.sortBy.recent': 'Recently updated',
|
|
219
243
|
'gemie.connectors.store.title': 'Connectors',
|
|
220
244
|
'gemie.connectors.toolCount': { zero: 'No tools', one: '1 tool', other: '{{count}} tools' },
|
|
245
|
+
'gemie.connectors.trust.community': 'Community',
|
|
246
|
+
'gemie.connectors.trust.official': 'Official',
|
|
247
|
+
'gemie.connectors.trust.verified': 'Verified',
|
|
221
248
|
'gemie.connectors.usedBy': 'Used by {{names}}',
|
|
222
249
|
'gemie.accounts.answerChat': 'Answer {{name}}',
|
|
223
250
|
'gemie.accounts.answeringLabel': 'Answers on its own',
|
package/src/lib/copy-es.ts
CHANGED
|
@@ -147,10 +147,16 @@ export const COPY_ES: Readonly<Record<string, CopyEntry>> = {
|
|
|
147
147
|
'faircoin.updated': 'Actualizado %{time}',
|
|
148
148
|
'faircoin.volume': 'Volumen 24 h',
|
|
149
149
|
'gemie.connectors.cancel': 'Cancelar',
|
|
150
|
+
'gemie.connectors.category.commerce': 'Comercio',
|
|
150
151
|
'gemie.connectors.category.communication': 'Comunicación',
|
|
151
152
|
'gemie.connectors.category.data': 'Datos',
|
|
153
|
+
'gemie.connectors.category.design': 'Diseño',
|
|
152
154
|
'gemie.connectors.category.development': 'Desarrollo',
|
|
155
|
+
'gemie.connectors.category.finance': 'Finanzas',
|
|
156
|
+
'gemie.connectors.category.marketing': 'Marketing',
|
|
157
|
+
'gemie.connectors.category.other': 'Otros',
|
|
153
158
|
'gemie.connectors.category.productivity': 'Productividad',
|
|
159
|
+
'gemie.connectors.category.search': 'Búsqueda e investigación',
|
|
154
160
|
'gemie.connectors.connected.browse': 'Explorar conectores',
|
|
155
161
|
'gemie.connectors.connected.description':
|
|
156
162
|
'Las cuentas que conectaste. Alia puede usarlas todas; los demás gemies solo las que les des en su editor.',
|
|
@@ -196,6 +202,10 @@ export const COPY_ES: Readonly<Record<string, CopyEntry>> = {
|
|
|
196
202
|
'gemie.connectors.status.installed': 'Aún sin conectar',
|
|
197
203
|
'gemie.connectors.status.running': 'Conectado',
|
|
198
204
|
'gemie.connectors.store.all': 'Todos',
|
|
205
|
+
'gemie.connectors.store.allCount': {
|
|
206
|
+
one: 'Todos los conectores · 1',
|
|
207
|
+
other: 'Todos los conectores · {{count}}',
|
|
208
|
+
},
|
|
199
209
|
'gemie.connectors.store.categories': 'Categorías',
|
|
200
210
|
'gemie.connectors.store.connect': 'Conectar',
|
|
201
211
|
'gemie.connectors.store.connectAnother': 'Añadir cuenta',
|
|
@@ -204,20 +214,37 @@ export const COPY_ES: Readonly<Record<string, CopyEntry>> = {
|
|
|
204
214
|
other: '{{count}} cuentas conectadas',
|
|
205
215
|
},
|
|
206
216
|
'gemie.connectors.store.description':
|
|
207
|
-
'Conecta las apps con las que trabajas
|
|
217
|
+
'Conecta las apps con las que trabajas: los servidores MCP de los propios proveedores y cientos más del registro oficial de MCP. Oficial significa que lo publica el proveedor; Comunidad, que lo publica un desarrollador. Si alguno te pide iniciar sesión, la inicias con ellos y Gemies nunca ve tu contraseña.',
|
|
208
218
|
'gemie.connectors.store.docs': 'Más información',
|
|
209
219
|
'gemie.connectors.store.empty': 'Ahora mismo no hay conectores disponibles.',
|
|
210
220
|
'gemie.connectors.store.featured': 'Destacados',
|
|
221
|
+
'gemie.connectors.store.filter.noSignIn': 'Sin inicio de sesión',
|
|
222
|
+
'gemie.connectors.store.filter.official': 'Oficiales',
|
|
223
|
+
'gemie.connectors.store.filter.verified': 'Verificados',
|
|
224
|
+
'gemie.connectors.store.filters': 'Filtros',
|
|
211
225
|
'gemie.connectors.store.loadFailed': 'No se pudieron cargar los conectores.',
|
|
226
|
+
'gemie.connectors.store.more': { one: 'Mostrar 1 más', other: 'Mostrar más (quedan {{count}})' },
|
|
212
227
|
'gemie.connectors.store.noResults': 'Ningún conector coincide con «{{query}}».',
|
|
228
|
+
'gemie.connectors.store.results': {
|
|
229
|
+
zero: 'Sin resultados',
|
|
230
|
+
one: '1 resultado',
|
|
231
|
+
other: '{{count}} resultados',
|
|
232
|
+
},
|
|
213
233
|
'gemie.connectors.store.retry': 'Reintentar',
|
|
214
234
|
'gemie.connectors.store.search': 'Buscar conectores',
|
|
235
|
+
'gemie.connectors.store.sort': 'Ordenar por',
|
|
236
|
+
'gemie.connectors.store.sortBy.featured': 'Destacados',
|
|
237
|
+
'gemie.connectors.store.sortBy.name': 'Nombre',
|
|
238
|
+
'gemie.connectors.store.sortBy.recent': 'Actualizados recientemente',
|
|
215
239
|
'gemie.connectors.store.title': 'Conectores',
|
|
216
240
|
'gemie.connectors.toolCount': {
|
|
217
241
|
zero: 'Sin herramientas',
|
|
218
242
|
one: '1 herramienta',
|
|
219
243
|
other: '{{count}} herramientas',
|
|
220
244
|
},
|
|
245
|
+
'gemie.connectors.trust.community': 'Comunidad',
|
|
246
|
+
'gemie.connectors.trust.official': 'Oficial',
|
|
247
|
+
'gemie.connectors.trust.verified': 'Verificado',
|
|
221
248
|
'gemie.connectors.usedBy': 'Lo usan {{names}}',
|
|
222
249
|
'gemie.accounts.answerChat': 'Responder a {{name}}',
|
|
223
250
|
'gemie.accounts.answeringLabel': 'Responde por su cuenta',
|
package/src/runtime/api.ts
CHANGED
|
@@ -71,7 +71,7 @@ async function readBody(response: Response): Promise<unknown> {
|
|
|
71
71
|
|
|
72
72
|
/** The structural slice of `OxyServices` the API layer needs. */
|
|
73
73
|
export interface LinkableOxy {
|
|
74
|
-
createLinkedClient(config: { baseURL: string }): {
|
|
74
|
+
createLinkedClient(config: { baseURL: string; receiverSendsNoStore?: boolean }): {
|
|
75
75
|
client: {
|
|
76
76
|
requestAuthenticatedResponse(config: {
|
|
77
77
|
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
@@ -102,7 +102,9 @@ export function createGemieApi(
|
|
|
102
102
|
request: GemieApiRequest = {},
|
|
103
103
|
): Promise<GemieApiResult<T>> {
|
|
104
104
|
const assertion = await appAssertionHeaders();
|
|
105
|
-
|
|
105
|
+
// The Gemies API sends `Cache-Control: no-store` on every response, so the browser may use its
|
|
106
|
+
// CORS preflight cache (`@oxy.so/core` >= 7.50; an older core ignores the flag).
|
|
107
|
+
const linked = oxyServices.createLinkedClient({ baseURL: apiUrl, receiverSendsNoStore: true });
|
|
106
108
|
try {
|
|
107
109
|
const headers = {
|
|
108
110
|
...assertion,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { useOxy } from '@oxy.so/services/ui/client';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
keepPreviousData,
|
|
4
|
+
useInfiniteQuery,
|
|
5
|
+
useMutation,
|
|
6
|
+
useQuery,
|
|
7
|
+
useQueryClient,
|
|
8
|
+
} from '@tanstack/react-query';
|
|
3
9
|
import * as WebBrowser from 'expo-web-browser';
|
|
4
10
|
import { useCallback, useEffect, useRef } from 'react';
|
|
5
11
|
import { Platform } from 'react-native';
|
|
@@ -13,9 +19,11 @@ import { useGemieRuntime } from './config';
|
|
|
13
19
|
* (`mcp_notion__…`, `mcp_notion_2__…`) and its own grants to gemies, so which account a tool acts
|
|
14
20
|
* on is always explicit.
|
|
15
21
|
*
|
|
16
|
-
* The store (`GemieConnectorsStore`) is where a person finds and connects one
|
|
17
|
-
*
|
|
18
|
-
* (`
|
|
22
|
+
* The store (`GemieConnectorsStore`) is where a person finds and connects one: the providers'
|
|
23
|
+
* servers Gemies curates, and the remote servers synced from the official MCP Registry, each with
|
|
24
|
+
* its badge (`official`, `verified`, `community`). Settings (`GemieConnectedConnectors`) lists only
|
|
25
|
+
* what they connected. Both, and every logo (`ConnectorLogo`), are the same in the Gemies and the
|
|
26
|
+
* Alia apps.
|
|
19
27
|
*/
|
|
20
28
|
|
|
21
29
|
/** The routes, on the Gemies API (credentialed, the Gemies and Alia origins). */
|
|
@@ -31,6 +39,7 @@ export const CONNECTOR_ROUTES = {
|
|
|
31
39
|
|
|
32
40
|
export const connectorQueryKeys = {
|
|
33
41
|
catalogue: ['gemie-connectors', 'catalogue'] as const,
|
|
42
|
+
store: (query: ConnectorStoreQuery) => ['gemie-connectors', 'catalogue', query] as const,
|
|
34
43
|
connected: ['gemie-connectors', 'connected'] as const,
|
|
35
44
|
};
|
|
36
45
|
|
|
@@ -39,21 +48,63 @@ export const CONNECTOR_CATEGORIES = [
|
|
|
39
48
|
'development',
|
|
40
49
|
'communication',
|
|
41
50
|
'data',
|
|
51
|
+
'design',
|
|
52
|
+
'finance',
|
|
53
|
+
'marketing',
|
|
54
|
+
'commerce',
|
|
55
|
+
'search',
|
|
56
|
+
'other',
|
|
42
57
|
] as const;
|
|
43
58
|
export type ConnectorCategory = (typeof CONNECTOR_CATEGORIES)[number];
|
|
44
59
|
|
|
45
|
-
/**
|
|
60
|
+
/**
|
|
61
|
+
* Who stands behind a connector: `official` is the provider's own server (curated by Gemies, or
|
|
62
|
+
* published by a domain its publisher proved and reached on it), `verified` a proven domain's server
|
|
63
|
+
* reached elsewhere, `community` a server published by a GitHub account.
|
|
64
|
+
*/
|
|
65
|
+
export const CONNECTOR_TRUST = ['official', 'verified', 'community'] as const;
|
|
66
|
+
export type ConnectorTrust = (typeof CONNECTOR_TRUST)[number];
|
|
67
|
+
|
|
68
|
+
export const CONNECTOR_SORTS = ['featured', 'name', 'recent'] as const;
|
|
69
|
+
export type ConnectorSort = (typeof CONNECTOR_SORTS)[number];
|
|
70
|
+
|
|
71
|
+
/** A connector of the store: a remote MCP server this deployment can connect. */
|
|
46
72
|
export interface ConnectorEntry {
|
|
47
73
|
id: string;
|
|
48
74
|
name: string;
|
|
49
75
|
description: string;
|
|
50
76
|
category: ConnectorCategory;
|
|
51
77
|
featured: boolean;
|
|
52
|
-
|
|
78
|
+
trust: ConnectorTrust;
|
|
79
|
+
/** `curated` by Gemies, or synced from the official MCP Registry. */
|
|
80
|
+
source: 'curated' | 'mcp_registry';
|
|
81
|
+
/** `oauth` opens the provider's sign-in; `none` connects at once. */
|
|
82
|
+
signIn: 'oauth' | 'none';
|
|
83
|
+
/** How many tools it offers, when known before connecting. */
|
|
84
|
+
toolCount: number | null;
|
|
85
|
+
/** Where to read about it; `null` when its publisher gave no page. */
|
|
86
|
+
docsUrl: string | null;
|
|
53
87
|
/** On the API's origin; `null` draws a monogram. */
|
|
54
88
|
logoUrl: string | null;
|
|
55
89
|
}
|
|
56
90
|
|
|
91
|
+
/** What the store shows: a search, a category, badges, only what needs no sign-in, an order. */
|
|
92
|
+
export interface ConnectorStoreQuery {
|
|
93
|
+
q?: string;
|
|
94
|
+
category?: ConnectorCategory;
|
|
95
|
+
trust?: readonly ConnectorTrust[];
|
|
96
|
+
noSignIn?: boolean;
|
|
97
|
+
sort?: ConnectorSort;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** One page of the store, and each category's count under the same search and filters. */
|
|
101
|
+
export interface ConnectorStorePage {
|
|
102
|
+
servers: ConnectorEntry[];
|
|
103
|
+
total: number;
|
|
104
|
+
nextOffset: number | null;
|
|
105
|
+
categories: { id: ConnectorCategory; count: number }[];
|
|
106
|
+
}
|
|
107
|
+
|
|
57
108
|
export type ConnectionStatus = 'installed' | 'running' | 'error';
|
|
58
109
|
|
|
59
110
|
/** One account a person connected. */
|
|
@@ -77,16 +128,46 @@ export interface Connection {
|
|
|
77
128
|
usedBy: { id: string; name: string }[];
|
|
78
129
|
}
|
|
79
130
|
|
|
80
|
-
/**
|
|
81
|
-
export
|
|
131
|
+
/** How many entries one page of the store asks for. */
|
|
132
|
+
export const CONNECTOR_STORE_PAGE_SIZE = 30;
|
|
133
|
+
|
|
134
|
+
/** The query string the store route reads (`GET /mcp/registry`). */
|
|
135
|
+
export function connectorStoreParams(
|
|
136
|
+
query: ConnectorStoreQuery,
|
|
137
|
+
offset: number,
|
|
138
|
+
limit = CONNECTOR_STORE_PAGE_SIZE,
|
|
139
|
+
): Record<string, string | number> {
|
|
140
|
+
return {
|
|
141
|
+
...(query.q?.trim() ? { q: query.q.trim() } : {}),
|
|
142
|
+
...(query.category ? { category: query.category } : {}),
|
|
143
|
+
...(query.trust?.length ? { trust: query.trust.join(',') } : {}),
|
|
144
|
+
...(query.noSignIn ? { signIn: 'none' } : {}),
|
|
145
|
+
...(query.sort ? { sort: query.sort } : {}),
|
|
146
|
+
offset,
|
|
147
|
+
limit,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The store, a page at a time: hundreds of connectors are searched, filtered and sorted by the API,
|
|
153
|
+
* and a new search keeps the previous results on screen until the next arrive.
|
|
154
|
+
*/
|
|
155
|
+
export function useConnectorStore(query: ConnectorStoreQuery) {
|
|
82
156
|
const api = useGemieApi();
|
|
83
157
|
const { isAuthenticated } = useOxy();
|
|
84
|
-
return
|
|
85
|
-
queryKey: connectorQueryKeys.
|
|
86
|
-
|
|
87
|
-
|
|
158
|
+
return useInfiniteQuery({
|
|
159
|
+
queryKey: connectorQueryKeys.store(query),
|
|
160
|
+
initialPageParam: 0,
|
|
161
|
+
queryFn: async ({ pageParam }) =>
|
|
162
|
+
(
|
|
163
|
+
await api.get<ConnectorStorePage>(CONNECTOR_ROUTES.catalogue, {
|
|
164
|
+
params: connectorStoreParams(query, pageParam),
|
|
165
|
+
})
|
|
166
|
+
).data,
|
|
167
|
+
getNextPageParam: (last) => last.nextOffset ?? undefined,
|
|
88
168
|
enabled: isAuthenticated,
|
|
89
169
|
staleTime: 5 * 60_000,
|
|
170
|
+
placeholderData: keepPreviousData,
|
|
90
171
|
});
|
|
91
172
|
}
|
|
92
173
|
|
|
@@ -179,13 +260,16 @@ export function useConnectorActions({ returnTo }: ConnectorActionsOptions) {
|
|
|
179
260
|
return complete.mutateAsync(result);
|
|
180
261
|
};
|
|
181
262
|
|
|
263
|
+
/** A new account: through the provider's sign-in, or at once for a server that needs none. */
|
|
182
264
|
const connect = useMutation({
|
|
183
265
|
mutationFn: async (registryId: string) => {
|
|
184
|
-
const { data } = await api.post<{ authorizationUrl
|
|
185
|
-
|
|
186
|
-
returnTo,
|
|
187
|
-
|
|
188
|
-
return signIn(data.authorizationUrl);
|
|
266
|
+
const { data } = await api.post<{ authorizationUrl?: string; server?: Connection }>(
|
|
267
|
+
CONNECTOR_ROUTES.connect,
|
|
268
|
+
{ registryId, returnTo },
|
|
269
|
+
);
|
|
270
|
+
if (data.authorizationUrl) return signIn(data.authorizationUrl);
|
|
271
|
+
await refresh();
|
|
272
|
+
return data.server ?? null;
|
|
189
273
|
},
|
|
190
274
|
});
|
|
191
275
|
|