@sudobility/sider_client 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks.d.ts +22 -10
- package/dist/hooks.js +47 -10
- package/dist/network/SiderClient.d.ts +28 -0
- package/dist/network/SiderClient.js +22 -0
- package/package.json +1 -1
- package/src/hooks.ts +64 -10
- package/src/network/SiderClient.ts +45 -0
package/dist/hooks.d.ts
CHANGED
|
@@ -3,21 +3,33 @@ import type { NetworkClient } from "@sudobility/types";
|
|
|
3
3
|
import type { CaptureRequest } from "@sudobility/sider_types";
|
|
4
4
|
import { SiderClient } from "./network/SiderClient";
|
|
5
5
|
type QueryOpts<T> = Omit<UseQueryOptions<T>, "queryKey" | "queryFn">;
|
|
6
|
-
export declare function useSiteLookup(networkClient: NetworkClient, baseUrl: string,
|
|
7
|
-
export declare function useSites(networkClient: NetworkClient, baseUrl: string,
|
|
8
|
-
export declare function useSite(networkClient: NetworkClient, baseUrl: string,
|
|
9
|
-
export declare function useStats(networkClient: NetworkClient, baseUrl: string,
|
|
10
|
-
export declare function useToolCatalog(networkClient: NetworkClient, baseUrl: string,
|
|
6
|
+
export declare function useSiteLookup(networkClient: NetworkClient, baseUrl: string, origin: string | null, options?: QueryOpts<Awaited<ReturnType<SiderClient["lookup"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").SiteLookupResult>, Error>;
|
|
7
|
+
export declare function useSites(networkClient: NetworkClient, baseUrl: string, options?: QueryOpts<Awaited<ReturnType<SiderClient["listSites"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").Site[]>, Error>;
|
|
8
|
+
export declare function useSite(networkClient: NetworkClient, baseUrl: string, siteId: string | null, options?: QueryOpts<Awaited<ReturnType<SiderClient["getSite"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").Site>, Error>;
|
|
9
|
+
export declare function useStats(networkClient: NetworkClient, baseUrl: string, options?: QueryOpts<Awaited<ReturnType<SiderClient["getStats"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").StatsResponse>, Error>;
|
|
10
|
+
export declare function useToolCatalog(networkClient: NetworkClient, baseUrl: string, siteId: string | null, opts?: {
|
|
11
11
|
includeProvisional?: boolean;
|
|
12
12
|
includeFlagged?: boolean;
|
|
13
13
|
}, options?: QueryOpts<Awaited<ReturnType<SiderClient["getTools"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").ToolCatalog>, Error>;
|
|
14
|
-
export declare function useSiteTemplates(networkClient: NetworkClient, baseUrl: string,
|
|
15
|
-
export declare function useSiteSlots(networkClient: NetworkClient, baseUrl: string,
|
|
16
|
-
export declare function useSiteGraph(networkClient: NetworkClient, baseUrl: string,
|
|
17
|
-
export declare function useToolDetail(networkClient: NetworkClient, baseUrl: string,
|
|
14
|
+
export declare function useSiteTemplates(networkClient: NetworkClient, baseUrl: string, siteId: string | null, options?: QueryOpts<Awaited<ReturnType<SiderClient["getSiteTemplates"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").EndpointTemplate[]>, Error>;
|
|
15
|
+
export declare function useSiteSlots(networkClient: NetworkClient, baseUrl: string, siteId: string | null, options?: QueryOpts<Awaited<ReturnType<SiderClient["getSiteSlots"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").SecretSlot[]>, Error>;
|
|
16
|
+
export declare function useSiteGraph(networkClient: NetworkClient, baseUrl: string, siteId: string | null, options?: QueryOpts<Awaited<ReturnType<SiderClient["getSiteGraph"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").EndpointGraphEdge[]>, Error>;
|
|
17
|
+
export declare function useToolDetail(networkClient: NetworkClient, baseUrl: string, toolId: string | null, options?: QueryOpts<Awaited<ReturnType<SiderClient["getToolDetail"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").ToolDetailResponse>, Error>;
|
|
18
18
|
export declare function useMe(networkClient: NetworkClient, baseUrl: string, token: string, options?: QueryOpts<Awaited<ReturnType<SiderClient["getMe"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").MeResponse>, Error>;
|
|
19
19
|
export declare function useMyCaptureBatches(networkClient: NetworkClient, baseUrl: string, token: string, siteId?: string, options?: QueryOpts<Awaited<ReturnType<SiderClient["getMyCaptureBatches"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").MyCaptureBatchSummary[]>, Error>;
|
|
20
20
|
export declare function useMyCaptureBatch(networkClient: NetworkClient, baseUrl: string, token: string, batchId: string | null, options?: QueryOpts<Awaited<ReturnType<SiderClient["getMyCaptureBatch"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").MyCaptureBatchDetail>, Error>;
|
|
21
21
|
export declare function useMyTools(networkClient: NetworkClient, baseUrl: string, token: string, options?: QueryOpts<Awaited<ReturnType<SiderClient["getMyTools"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("@sudobility/sider_types").MyToolEntry[]>, Error>;
|
|
22
|
-
export declare function useCaptureUpload(networkClient: NetworkClient, baseUrl: string
|
|
22
|
+
export declare function useCaptureUpload(networkClient: NetworkClient, baseUrl: string): import("@tanstack/react-query").UseMutationResult<import("@sudobility/sider_types").CaptureResponse, Error, CaptureRequest, unknown>;
|
|
23
|
+
export declare function useMcpList(networkClient: NetworkClient, baseUrl: string, params: {
|
|
24
|
+
limit?: number;
|
|
25
|
+
offset?: number;
|
|
26
|
+
q?: string;
|
|
27
|
+
}, options?: QueryOpts<Awaited<ReturnType<SiderClient["listMcp"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("./network/SiderClient").DirectoryPage>, Error>;
|
|
28
|
+
export declare function useMcpManifest(networkClient: NetworkClient, baseUrl: string, host: string | null, options?: QueryOpts<Awaited<ReturnType<SiderClient["mcpManifest"]>>>): import("@tanstack/react-query").UseQueryResult<unknown, Error>;
|
|
29
|
+
export declare function useGraphList(networkClient: NetworkClient, baseUrl: string, params: {
|
|
30
|
+
limit?: number;
|
|
31
|
+
offset?: number;
|
|
32
|
+
q?: string;
|
|
33
|
+
}, options?: QueryOpts<Awaited<ReturnType<SiderClient["listGraphs"]>>>): import("@tanstack/react-query").UseQueryResult<NoInfer<import("./network/SiderClient").DirectoryPage>, Error>;
|
|
34
|
+
export declare function useGraphDetail(networkClient: NetworkClient, baseUrl: string, appKey: string | null, options?: QueryOpts<Awaited<ReturnType<SiderClient["graphDetail"]>>>): import("@tanstack/react-query").UseQueryResult<unknown, Error>;
|
|
23
35
|
export {};
|
package/dist/hooks.js
CHANGED
|
@@ -3,8 +3,14 @@ import { SiderClient } from "./network/SiderClient";
|
|
|
3
3
|
function client(networkClient, baseUrl) {
|
|
4
4
|
return new SiderClient(networkClient, baseUrl);
|
|
5
5
|
}
|
|
6
|
+
// No token parameter on these: auth travels on the injected NetworkClient, which
|
|
7
|
+
// is what SiderClient's contract says. They used to accept a `_token` they
|
|
8
|
+
// ignored, so a caller could pass a real token and believe it had authenticated.
|
|
9
|
+
//
|
|
10
|
+
// The per-user hooks below DO keep a `token` — not as a credential, but as the
|
|
11
|
+
// signed-in signal that stops a private query firing for nobody.
|
|
6
12
|
// --- public data: enabled regardless of token ------------------------------
|
|
7
|
-
export function useSiteLookup(networkClient, baseUrl,
|
|
13
|
+
export function useSiteLookup(networkClient, baseUrl, origin, options) {
|
|
8
14
|
return useQuery({
|
|
9
15
|
queryKey: ["sider", "lookup", origin],
|
|
10
16
|
queryFn: () => client(networkClient, baseUrl).lookup(origin),
|
|
@@ -12,14 +18,14 @@ export function useSiteLookup(networkClient, baseUrl, _token, origin, options) {
|
|
|
12
18
|
enabled: !!origin && (options?.enabled ?? true),
|
|
13
19
|
});
|
|
14
20
|
}
|
|
15
|
-
export function useSites(networkClient, baseUrl,
|
|
21
|
+
export function useSites(networkClient, baseUrl, options) {
|
|
16
22
|
return useQuery({
|
|
17
23
|
queryKey: ["sider", "sites"],
|
|
18
24
|
queryFn: () => client(networkClient, baseUrl).listSites(),
|
|
19
25
|
...options,
|
|
20
26
|
});
|
|
21
27
|
}
|
|
22
|
-
export function useSite(networkClient, baseUrl,
|
|
28
|
+
export function useSite(networkClient, baseUrl, siteId, options) {
|
|
23
29
|
return useQuery({
|
|
24
30
|
queryKey: ["sider", "site", siteId],
|
|
25
31
|
queryFn: () => client(networkClient, baseUrl).getSite(siteId),
|
|
@@ -27,14 +33,14 @@ export function useSite(networkClient, baseUrl, _token, siteId, options) {
|
|
|
27
33
|
enabled: !!siteId && (options?.enabled ?? true),
|
|
28
34
|
});
|
|
29
35
|
}
|
|
30
|
-
export function useStats(networkClient, baseUrl,
|
|
36
|
+
export function useStats(networkClient, baseUrl, options) {
|
|
31
37
|
return useQuery({
|
|
32
38
|
queryKey: ["sider", "stats"],
|
|
33
39
|
queryFn: () => client(networkClient, baseUrl).getStats(),
|
|
34
40
|
...options,
|
|
35
41
|
});
|
|
36
42
|
}
|
|
37
|
-
export function useToolCatalog(networkClient, baseUrl,
|
|
43
|
+
export function useToolCatalog(networkClient, baseUrl, siteId, opts, options) {
|
|
38
44
|
return useQuery({
|
|
39
45
|
queryKey: [
|
|
40
46
|
"sider",
|
|
@@ -48,7 +54,7 @@ export function useToolCatalog(networkClient, baseUrl, _token, siteId, opts, opt
|
|
|
48
54
|
enabled: !!siteId && (options?.enabled ?? true),
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
|
-
export function useSiteTemplates(networkClient, baseUrl,
|
|
57
|
+
export function useSiteTemplates(networkClient, baseUrl, siteId, options) {
|
|
52
58
|
return useQuery({
|
|
53
59
|
queryKey: ["sider", "templates", siteId],
|
|
54
60
|
queryFn: () => client(networkClient, baseUrl).getSiteTemplates(siteId),
|
|
@@ -56,7 +62,7 @@ export function useSiteTemplates(networkClient, baseUrl, _token, siteId, options
|
|
|
56
62
|
enabled: !!siteId && (options?.enabled ?? true),
|
|
57
63
|
});
|
|
58
64
|
}
|
|
59
|
-
export function useSiteSlots(networkClient, baseUrl,
|
|
65
|
+
export function useSiteSlots(networkClient, baseUrl, siteId, options) {
|
|
60
66
|
return useQuery({
|
|
61
67
|
queryKey: ["sider", "slots", siteId],
|
|
62
68
|
queryFn: () => client(networkClient, baseUrl).getSiteSlots(siteId),
|
|
@@ -64,7 +70,7 @@ export function useSiteSlots(networkClient, baseUrl, _token, siteId, options) {
|
|
|
64
70
|
enabled: !!siteId && (options?.enabled ?? true),
|
|
65
71
|
});
|
|
66
72
|
}
|
|
67
|
-
export function useSiteGraph(networkClient, baseUrl,
|
|
73
|
+
export function useSiteGraph(networkClient, baseUrl, siteId, options) {
|
|
68
74
|
return useQuery({
|
|
69
75
|
queryKey: ["sider", "graph", siteId],
|
|
70
76
|
queryFn: () => client(networkClient, baseUrl).getSiteGraph(siteId),
|
|
@@ -72,7 +78,7 @@ export function useSiteGraph(networkClient, baseUrl, _token, siteId, options) {
|
|
|
72
78
|
enabled: !!siteId && (options?.enabled ?? true),
|
|
73
79
|
});
|
|
74
80
|
}
|
|
75
|
-
export function useToolDetail(networkClient, baseUrl,
|
|
81
|
+
export function useToolDetail(networkClient, baseUrl, toolId, options) {
|
|
76
82
|
return useQuery({
|
|
77
83
|
queryKey: ["sider", "tool", toolId],
|
|
78
84
|
queryFn: () => client(networkClient, baseUrl).getToolDetail(toolId),
|
|
@@ -113,8 +119,39 @@ export function useMyTools(networkClient, baseUrl, token, options) {
|
|
|
113
119
|
enabled: !!token && (options?.enabled ?? true),
|
|
114
120
|
});
|
|
115
121
|
}
|
|
116
|
-
export function useCaptureUpload(networkClient, baseUrl
|
|
122
|
+
export function useCaptureUpload(networkClient, baseUrl) {
|
|
117
123
|
return useMutation({
|
|
118
124
|
mutationFn: (body) => client(networkClient, baseUrl).uploadCapture(body),
|
|
119
125
|
});
|
|
120
126
|
}
|
|
127
|
+
// --- public directories: what the graph knows ------------------------------
|
|
128
|
+
export function useMcpList(networkClient, baseUrl, params, options) {
|
|
129
|
+
return useQuery({
|
|
130
|
+
queryKey: ["sider", "mcp", params],
|
|
131
|
+
queryFn: () => client(networkClient, baseUrl).listMcp(params),
|
|
132
|
+
...options,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
export function useMcpManifest(networkClient, baseUrl, host, options) {
|
|
136
|
+
return useQuery({
|
|
137
|
+
queryKey: ["sider", "mcp", "manifest", host],
|
|
138
|
+
queryFn: () => client(networkClient, baseUrl).mcpManifest(host),
|
|
139
|
+
...options,
|
|
140
|
+
enabled: !!host && (options?.enabled ?? true),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
export function useGraphList(networkClient, baseUrl, params, options) {
|
|
144
|
+
return useQuery({
|
|
145
|
+
queryKey: ["sider", "graph", params],
|
|
146
|
+
queryFn: () => client(networkClient, baseUrl).listGraphs(params),
|
|
147
|
+
...options,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
export function useGraphDetail(networkClient, baseUrl, appKey, options) {
|
|
151
|
+
return useQuery({
|
|
152
|
+
queryKey: ["sider", "graph", "detail", appKey],
|
|
153
|
+
queryFn: () => client(networkClient, baseUrl).graphDetail(appKey),
|
|
154
|
+
...options,
|
|
155
|
+
enabled: !!appKey && (options?.enabled ?? true),
|
|
156
|
+
});
|
|
157
|
+
}
|
|
@@ -28,4 +28,32 @@ export declare class SiderClient {
|
|
|
28
28
|
getSiteSlots(siteId: string): Promise<SecretSlot[]>;
|
|
29
29
|
getSiteGraph(siteId: string): Promise<EndpointGraphEdge[]>;
|
|
30
30
|
getToolDetail(toolId: string): Promise<ToolDetailResponse>;
|
|
31
|
+
listMcp(params: {
|
|
32
|
+
limit?: number;
|
|
33
|
+
offset?: number;
|
|
34
|
+
q?: string;
|
|
35
|
+
}): Promise<DirectoryPage>;
|
|
36
|
+
mcpManifest(host: string): Promise<unknown>;
|
|
37
|
+
listGraphs(params: {
|
|
38
|
+
limit?: number;
|
|
39
|
+
offset?: number;
|
|
40
|
+
q?: string;
|
|
41
|
+
}): Promise<DirectoryPage>;
|
|
42
|
+
graphDetail(appKey: string): Promise<unknown>;
|
|
43
|
+
}
|
|
44
|
+
/** One row of the public directories. */
|
|
45
|
+
export interface DirectoryApp {
|
|
46
|
+
id: number;
|
|
47
|
+
key: string;
|
|
48
|
+
host: string | null;
|
|
49
|
+
title: string | null;
|
|
50
|
+
endpointCount: number;
|
|
51
|
+
viewCount: number;
|
|
52
|
+
lastEndpointAt: string | null;
|
|
53
|
+
lastViewAt: string | null;
|
|
54
|
+
}
|
|
55
|
+
export interface DirectoryPage {
|
|
56
|
+
apps: DirectoryApp[];
|
|
57
|
+
/** The count BEFORE the limit, so a pager knows how many pages there are. */
|
|
58
|
+
total: number;
|
|
31
59
|
}
|
|
@@ -68,4 +68,26 @@ export class SiderClient {
|
|
|
68
68
|
getToolDetail(toolId) {
|
|
69
69
|
return this.get(`/api/v1/tools/${toolId}`);
|
|
70
70
|
}
|
|
71
|
+
// --- public directories of what the graph knows -------------------------
|
|
72
|
+
listMcp(params) {
|
|
73
|
+
return this.get(`/api/v1/mcp${queryString(params)}`);
|
|
74
|
+
}
|
|
75
|
+
mcpManifest(host) {
|
|
76
|
+
return this.get(`/api/v1/mcp/${encodeURIComponent(host)}`);
|
|
77
|
+
}
|
|
78
|
+
listGraphs(params) {
|
|
79
|
+
return this.get(`/api/v1/graph${queryString(params)}`);
|
|
80
|
+
}
|
|
81
|
+
graphDetail(appKey) {
|
|
82
|
+
return this.get(`/api/v1/graph/${encodeURIComponent(appKey)}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function queryString(params) {
|
|
86
|
+
const qs = new URLSearchParams();
|
|
87
|
+
for (const [k, v] of Object.entries(params)) {
|
|
88
|
+
if (v !== undefined && v !== null && v !== "")
|
|
89
|
+
qs.set(k, String(v));
|
|
90
|
+
}
|
|
91
|
+
const s = qs.toString();
|
|
92
|
+
return s ? `?${s}` : "";
|
|
71
93
|
}
|
package/package.json
CHANGED
package/src/hooks.ts
CHANGED
|
@@ -9,12 +9,18 @@ function client(networkClient: NetworkClient, baseUrl: string): SiderClient {
|
|
|
9
9
|
return new SiderClient(networkClient, baseUrl);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// No token parameter on these: auth travels on the injected NetworkClient, which
|
|
13
|
+
// is what SiderClient's contract says. They used to accept a `_token` they
|
|
14
|
+
// ignored, so a caller could pass a real token and believe it had authenticated.
|
|
15
|
+
//
|
|
16
|
+
// The per-user hooks below DO keep a `token` — not as a credential, but as the
|
|
17
|
+
// signed-in signal that stops a private query firing for nobody.
|
|
18
|
+
|
|
12
19
|
// --- public data: enabled regardless of token ------------------------------
|
|
13
20
|
|
|
14
21
|
export function useSiteLookup(
|
|
15
22
|
networkClient: NetworkClient,
|
|
16
23
|
baseUrl: string,
|
|
17
|
-
_token: string,
|
|
18
24
|
origin: string | null,
|
|
19
25
|
options?: QueryOpts<Awaited<ReturnType<SiderClient["lookup"]>>>,
|
|
20
26
|
) {
|
|
@@ -29,7 +35,6 @@ export function useSiteLookup(
|
|
|
29
35
|
export function useSites(
|
|
30
36
|
networkClient: NetworkClient,
|
|
31
37
|
baseUrl: string,
|
|
32
|
-
_token: string,
|
|
33
38
|
options?: QueryOpts<Awaited<ReturnType<SiderClient["listSites"]>>>,
|
|
34
39
|
) {
|
|
35
40
|
return useQuery({
|
|
@@ -42,7 +47,6 @@ export function useSites(
|
|
|
42
47
|
export function useSite(
|
|
43
48
|
networkClient: NetworkClient,
|
|
44
49
|
baseUrl: string,
|
|
45
|
-
_token: string,
|
|
46
50
|
siteId: string | null,
|
|
47
51
|
options?: QueryOpts<Awaited<ReturnType<SiderClient["getSite"]>>>,
|
|
48
52
|
) {
|
|
@@ -57,7 +61,6 @@ export function useSite(
|
|
|
57
61
|
export function useStats(
|
|
58
62
|
networkClient: NetworkClient,
|
|
59
63
|
baseUrl: string,
|
|
60
|
-
_token: string,
|
|
61
64
|
options?: QueryOpts<Awaited<ReturnType<SiderClient["getStats"]>>>,
|
|
62
65
|
) {
|
|
63
66
|
return useQuery({
|
|
@@ -70,7 +73,6 @@ export function useStats(
|
|
|
70
73
|
export function useToolCatalog(
|
|
71
74
|
networkClient: NetworkClient,
|
|
72
75
|
baseUrl: string,
|
|
73
|
-
_token: string,
|
|
74
76
|
siteId: string | null,
|
|
75
77
|
opts?: { includeProvisional?: boolean; includeFlagged?: boolean },
|
|
76
78
|
options?: QueryOpts<Awaited<ReturnType<SiderClient["getTools"]>>>,
|
|
@@ -92,7 +94,6 @@ export function useToolCatalog(
|
|
|
92
94
|
export function useSiteTemplates(
|
|
93
95
|
networkClient: NetworkClient,
|
|
94
96
|
baseUrl: string,
|
|
95
|
-
_token: string,
|
|
96
97
|
siteId: string | null,
|
|
97
98
|
options?: QueryOpts<Awaited<ReturnType<SiderClient["getSiteTemplates"]>>>,
|
|
98
99
|
) {
|
|
@@ -107,7 +108,6 @@ export function useSiteTemplates(
|
|
|
107
108
|
export function useSiteSlots(
|
|
108
109
|
networkClient: NetworkClient,
|
|
109
110
|
baseUrl: string,
|
|
110
|
-
_token: string,
|
|
111
111
|
siteId: string | null,
|
|
112
112
|
options?: QueryOpts<Awaited<ReturnType<SiderClient["getSiteSlots"]>>>,
|
|
113
113
|
) {
|
|
@@ -122,7 +122,6 @@ export function useSiteSlots(
|
|
|
122
122
|
export function useSiteGraph(
|
|
123
123
|
networkClient: NetworkClient,
|
|
124
124
|
baseUrl: string,
|
|
125
|
-
_token: string,
|
|
126
125
|
siteId: string | null,
|
|
127
126
|
options?: QueryOpts<Awaited<ReturnType<SiderClient["getSiteGraph"]>>>,
|
|
128
127
|
) {
|
|
@@ -137,7 +136,6 @@ export function useSiteGraph(
|
|
|
137
136
|
export function useToolDetail(
|
|
138
137
|
networkClient: NetworkClient,
|
|
139
138
|
baseUrl: string,
|
|
140
|
-
_token: string,
|
|
141
139
|
toolId: string | null,
|
|
142
140
|
options?: QueryOpts<Awaited<ReturnType<SiderClient["getToolDetail"]>>>,
|
|
143
141
|
) {
|
|
@@ -209,8 +207,64 @@ export function useMyTools(
|
|
|
209
207
|
});
|
|
210
208
|
}
|
|
211
209
|
|
|
212
|
-
export function useCaptureUpload(networkClient: NetworkClient, baseUrl: string
|
|
210
|
+
export function useCaptureUpload(networkClient: NetworkClient, baseUrl: string) {
|
|
213
211
|
return useMutation({
|
|
214
212
|
mutationFn: (body: CaptureRequest) => client(networkClient, baseUrl).uploadCapture(body),
|
|
215
213
|
});
|
|
216
214
|
}
|
|
215
|
+
|
|
216
|
+
// --- public directories: what the graph knows ------------------------------
|
|
217
|
+
|
|
218
|
+
export function useMcpList(
|
|
219
|
+
networkClient: NetworkClient,
|
|
220
|
+
baseUrl: string,
|
|
221
|
+
params: { limit?: number; offset?: number; q?: string },
|
|
222
|
+
options?: QueryOpts<Awaited<ReturnType<SiderClient["listMcp"]>>>,
|
|
223
|
+
) {
|
|
224
|
+
return useQuery({
|
|
225
|
+
queryKey: ["sider", "mcp", params],
|
|
226
|
+
queryFn: () => client(networkClient, baseUrl).listMcp(params),
|
|
227
|
+
...options,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function useMcpManifest(
|
|
232
|
+
networkClient: NetworkClient,
|
|
233
|
+
baseUrl: string,
|
|
234
|
+
host: string | null,
|
|
235
|
+
options?: QueryOpts<Awaited<ReturnType<SiderClient["mcpManifest"]>>>,
|
|
236
|
+
) {
|
|
237
|
+
return useQuery({
|
|
238
|
+
queryKey: ["sider", "mcp", "manifest", host],
|
|
239
|
+
queryFn: () => client(networkClient, baseUrl).mcpManifest(host as string),
|
|
240
|
+
...options,
|
|
241
|
+
enabled: !!host && (options?.enabled ?? true),
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export function useGraphList(
|
|
246
|
+
networkClient: NetworkClient,
|
|
247
|
+
baseUrl: string,
|
|
248
|
+
params: { limit?: number; offset?: number; q?: string },
|
|
249
|
+
options?: QueryOpts<Awaited<ReturnType<SiderClient["listGraphs"]>>>,
|
|
250
|
+
) {
|
|
251
|
+
return useQuery({
|
|
252
|
+
queryKey: ["sider", "graph", params],
|
|
253
|
+
queryFn: () => client(networkClient, baseUrl).listGraphs(params),
|
|
254
|
+
...options,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function useGraphDetail(
|
|
259
|
+
networkClient: NetworkClient,
|
|
260
|
+
baseUrl: string,
|
|
261
|
+
appKey: string | null,
|
|
262
|
+
options?: QueryOpts<Awaited<ReturnType<SiderClient["graphDetail"]>>>,
|
|
263
|
+
) {
|
|
264
|
+
return useQuery({
|
|
265
|
+
queryKey: ["sider", "graph", "detail", appKey],
|
|
266
|
+
queryFn: () => client(networkClient, baseUrl).graphDetail(appKey as string),
|
|
267
|
+
...options,
|
|
268
|
+
enabled: !!appKey && (options?.enabled ?? true),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
@@ -106,4 +106,49 @@ export class SiderClient {
|
|
|
106
106
|
getToolDetail(toolId: string): Promise<ToolDetailResponse> {
|
|
107
107
|
return this.get(`/api/v1/tools/${toolId}`);
|
|
108
108
|
}
|
|
109
|
+
|
|
110
|
+
// --- public directories of what the graph knows -------------------------
|
|
111
|
+
|
|
112
|
+
listMcp(params: { limit?: number; offset?: number; q?: string }): Promise<DirectoryPage> {
|
|
113
|
+
return this.get(`/api/v1/mcp${queryString(params)}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
mcpManifest(host: string): Promise<unknown> {
|
|
117
|
+
return this.get(`/api/v1/mcp/${encodeURIComponent(host)}`);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
listGraphs(params: { limit?: number; offset?: number; q?: string }): Promise<DirectoryPage> {
|
|
121
|
+
return this.get(`/api/v1/graph${queryString(params)}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
graphDetail(appKey: string): Promise<unknown> {
|
|
125
|
+
return this.get(`/api/v1/graph/${encodeURIComponent(appKey)}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** One row of the public directories. */
|
|
130
|
+
export interface DirectoryApp {
|
|
131
|
+
id: number;
|
|
132
|
+
key: string;
|
|
133
|
+
host: string | null;
|
|
134
|
+
title: string | null;
|
|
135
|
+
endpointCount: number;
|
|
136
|
+
viewCount: number;
|
|
137
|
+
lastEndpointAt: string | null;
|
|
138
|
+
lastViewAt: string | null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface DirectoryPage {
|
|
142
|
+
apps: DirectoryApp[];
|
|
143
|
+
/** The count BEFORE the limit, so a pager knows how many pages there are. */
|
|
144
|
+
total: number;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function queryString(params: Record<string, unknown>): string {
|
|
148
|
+
const qs = new URLSearchParams();
|
|
149
|
+
for (const [k, v] of Object.entries(params)) {
|
|
150
|
+
if (v !== undefined && v !== null && v !== "") qs.set(k, String(v));
|
|
151
|
+
}
|
|
152
|
+
const s = qs.toString();
|
|
153
|
+
return s ? `?${s}` : "";
|
|
109
154
|
}
|