@sudobility/sider_client 0.1.8 → 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 CHANGED
@@ -20,4 +20,16 @@ export declare function useMyCaptureBatches(networkClient: NetworkClient, baseUr
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
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
@@ -124,3 +124,34 @@ export function useCaptureUpload(networkClient, baseUrl) {
124
124
  mutationFn: (body) => client(networkClient, baseUrl).uploadCapture(body),
125
125
  });
126
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/sider_client",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "Sider frontend network library — injected NetworkClient + React Query hooks.",
5
5
  "license": "BUSL-1.1",
6
6
  "publishConfig": {
package/src/hooks.ts CHANGED
@@ -212,3 +212,59 @@ export function useCaptureUpload(networkClient: NetworkClient, baseUrl: string)
212
212
  mutationFn: (body: CaptureRequest) => client(networkClient, baseUrl).uploadCapture(body),
213
213
  });
214
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
  }