@taco_tsinghua/graphnode-sdk 0.1.17 → 0.1.21
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/README.md +91 -333
- package/dist/client.d.ts +24 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +34 -8
- package/dist/client.js.map +1 -1
- package/dist/endpoints/ai.d.ts +25 -30
- package/dist/endpoints/ai.d.ts.map +1 -1
- package/dist/endpoints/ai.js +220 -31
- package/dist/endpoints/ai.js.map +1 -1
- package/dist/endpoints/graph.d.ts +4 -1
- package/dist/endpoints/graph.d.ts.map +1 -1
- package/dist/endpoints/graph.js +10 -0
- package/dist/endpoints/graph.js.map +1 -1
- package/dist/endpoints/graphAi.d.ts +21 -0
- package/dist/endpoints/graphAi.d.ts.map +1 -1
- package/dist/endpoints/graphAi.js +24 -0
- package/dist/endpoints/graphAi.js.map +1 -1
- package/dist/endpoints/notification.d.ts +13 -0
- package/dist/endpoints/notification.d.ts.map +1 -1
- package/dist/endpoints/notification.js +17 -0
- package/dist/endpoints/notification.js.map +1 -1
- package/dist/endpoints/sync.d.ts +3 -1
- package/dist/endpoints/sync.d.ts.map +1 -1
- package/dist/endpoints/sync.js.map +1 -1
- package/dist/http-builder.d.ts +38 -0
- package/dist/http-builder.d.ts.map +1 -1
- package/dist/http-builder.js +43 -6
- package/dist/http-builder.js.map +1 -1
- package/dist/types/graph.d.ts +66 -0
- package/dist/types/graph.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/client.ts +140 -0
- package/src/config.ts +9 -0
- package/src/endpoints/agent.ts +171 -0
- package/src/endpoints/ai.ts +296 -0
- package/src/endpoints/auth.apple.ts +39 -0
- package/src/endpoints/auth.google.ts +39 -0
- package/src/endpoints/conversations.ts +362 -0
- package/src/endpoints/graph.ts +398 -0
- package/src/endpoints/graphAi.ts +111 -0
- package/src/endpoints/health.ts +40 -0
- package/src/endpoints/me.ts +97 -0
- package/src/endpoints/note.ts +351 -0
- package/src/endpoints/notification.ts +69 -0
- package/src/endpoints/sync.ts +71 -0
- package/src/http-builder.ts +290 -0
- package/src/index.ts +60 -0
- package/src/types/aiInput.ts +111 -0
- package/src/types/conversation.ts +51 -0
- package/src/types/graph.ts +201 -0
- package/src/types/graphAi.ts +21 -0
- package/src/types/me.ts +49 -0
- package/src/types/message.ts +40 -0
- package/src/types/note.ts +89 -0
- package/src/types/problem.ts +22 -0
- package/src/types/sync.ts +35 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import { RequestBuilder, type HttpResponse } from '../http-builder.js';
|
|
2
|
+
import type {
|
|
3
|
+
GraphNodeDto,
|
|
4
|
+
GraphEdgeDto,
|
|
5
|
+
GraphClusterDto,
|
|
6
|
+
GraphStatsDto,
|
|
7
|
+
GraphSnapshotDto,
|
|
8
|
+
GraphSubclusterDto,
|
|
9
|
+
CreateEdgeResponse,
|
|
10
|
+
UpdateNodePayload,
|
|
11
|
+
} from '../types/graph.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Graph API
|
|
15
|
+
*
|
|
16
|
+
* 지식 그래프(Knowledge Graph)의 노드, 엣지, 클러스터를 관리하는 API 클래스입니다.
|
|
17
|
+
* `/v1/graph` 엔드포인트 하위의 API들을 호출합니다.
|
|
18
|
+
*
|
|
19
|
+
* 주요 기능:
|
|
20
|
+
* - 노드 관리 (생성, 조회, 수정, 삭제) (`createNode`, `listNodes`, `getNode`, `updateNode`, `deleteNode`)
|
|
21
|
+
* - 엣지 관리 (생성, 조회, 삭제) (`createEdge`, `listEdges`, `deleteEdge`)
|
|
22
|
+
* - 클러스터 관리 (생성, 조회, 삭제) (`createCluster`, `listClusters`, `getCluster`, `deleteCluster`)
|
|
23
|
+
* - 그래프 통계 및 스냅샷 (`getStats`, `getSnapshot`, `saveSnapshot`)
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export class GraphApi {
|
|
28
|
+
private readonly rb: RequestBuilder;
|
|
29
|
+
|
|
30
|
+
constructor(rb: RequestBuilder) {
|
|
31
|
+
this.rb = rb.path('/v1/graph');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 새 노트를 생성하거나 기존 노드를 업데이트합니다.
|
|
36
|
+
* @param node - 생성 또는 업데이트할 노드 데이터
|
|
37
|
+
* - `id` (number): 노드 ID (정수)
|
|
38
|
+
* - `userId` (string): 사용자 ID
|
|
39
|
+
* - `origId` (string): 원본 데이터 ID (예: conversationId)
|
|
40
|
+
* - `clusterId` (string): 클러스터 ID
|
|
41
|
+
* - `clusterName` (string): 클러스터 이름
|
|
42
|
+
* - `timestamp` (string | null): 타임스탬프
|
|
43
|
+
* - `numMessages` (number): 메시지 수
|
|
44
|
+
* @returns 생성 또는 업데이트된 노드 정보
|
|
45
|
+
* @example
|
|
46
|
+
* const response = await client.graph.createNode({
|
|
47
|
+
* id: 101,
|
|
48
|
+
* userId: 'user-123',
|
|
49
|
+
* origId: 'conv-uuid-1',
|
|
50
|
+
* clusterId: 'cluster-a',
|
|
51
|
+
* clusterName: 'Project Alpha',
|
|
52
|
+
* timestamp: new Date().toISOString(),
|
|
53
|
+
* numMessages: 5
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* console.log(response.data);
|
|
57
|
+
* // Output:
|
|
58
|
+
* {
|
|
59
|
+
* id: 101,
|
|
60
|
+
* userId: 'user-123',
|
|
61
|
+
* origId: 'conv-uuid-1',
|
|
62
|
+
* clusterId: 'cluster-a',
|
|
63
|
+
* clusterName: 'Project Alpha',
|
|
64
|
+
* timestamp: '...',
|
|
65
|
+
* numMessages: 5
|
|
66
|
+
* }
|
|
67
|
+
*/
|
|
68
|
+
createNode(node: GraphNodeDto): Promise<HttpResponse<GraphNodeDto>> {
|
|
69
|
+
return this.rb.path('/nodes').post<GraphNodeDto>(node);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 사용자의 모든 노드를 가져옵니다.
|
|
74
|
+
* @returns 노드 목록 (GraphNodeDto 배열)
|
|
75
|
+
* @example
|
|
76
|
+
* const response = await client.graph.listNodes();
|
|
77
|
+
*
|
|
78
|
+
* console.log(response.data);
|
|
79
|
+
* // Output:
|
|
80
|
+
* [
|
|
81
|
+
* {
|
|
82
|
+
* id: 101,
|
|
83
|
+
* userId: 'user-123',
|
|
84
|
+
* origId: 'conv-uuid-1',
|
|
85
|
+
* clusterId: 'cluster-a',
|
|
86
|
+
* clusterName: 'Project Alpha',
|
|
87
|
+
* timestamp: '...',
|
|
88
|
+
* numMessages: 5
|
|
89
|
+
* },
|
|
90
|
+
* {
|
|
91
|
+
* id: 102,
|
|
92
|
+
* userId: 'user-123',
|
|
93
|
+
* origId: 'conv-uuid-2',
|
|
94
|
+
* clusterId: 'cluster-b',
|
|
95
|
+
* clusterName: 'Project Beta',
|
|
96
|
+
* timestamp: '...',
|
|
97
|
+
* numMessages: 3
|
|
98
|
+
* }
|
|
99
|
+
* ]
|
|
100
|
+
*/
|
|
101
|
+
listNodes(): Promise<HttpResponse<GraphNodeDto[]>> {
|
|
102
|
+
return this.rb.path('/nodes').get<GraphNodeDto[]>();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 특정 ID의 노드를 가져옵니다.
|
|
107
|
+
* @param nodeId - 가져올 노드의 ID (정수)
|
|
108
|
+
* @returns 요청한 노드 상세 정보
|
|
109
|
+
* @example
|
|
110
|
+
* const response = await client.graph.getNode(101);
|
|
111
|
+
*
|
|
112
|
+
* console.log(response.data);
|
|
113
|
+
* // Output:
|
|
114
|
+
* {
|
|
115
|
+
* id: 101,
|
|
116
|
+
* userId: 'user-123',
|
|
117
|
+
* origId: 'conv-uuid-1',
|
|
118
|
+
* clusterId: 'cluster-a',
|
|
119
|
+
* clusterName: 'Project Alpha',
|
|
120
|
+
* timestamp: '...',
|
|
121
|
+
* numMessages: 5
|
|
122
|
+
* }
|
|
123
|
+
*/
|
|
124
|
+
getNode(nodeId: number): Promise<HttpResponse<GraphNodeDto>> {
|
|
125
|
+
return this.rb.path(`/nodes/${nodeId}`).get<GraphNodeDto>();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 특정 노드를 부분적으로 업데이트합니다.
|
|
130
|
+
* @param nodeId - 업데이트할 노드의 ID
|
|
131
|
+
* @param payload - 업데이트할 데이터
|
|
132
|
+
* - `clusterId` (string, optional): 변경할 클러스터 ID
|
|
133
|
+
* - `clusterName` (string, optional): 변경할 클러스터 이름
|
|
134
|
+
* @example
|
|
135
|
+
* await client.graph.updateNode(101, {
|
|
136
|
+
* clusterName: 'Project Beta'
|
|
137
|
+
* });
|
|
138
|
+
* // Output: (No content)
|
|
139
|
+
*/
|
|
140
|
+
updateNode(nodeId: number, payload: UpdateNodePayload): Promise<HttpResponse<void>> {
|
|
141
|
+
return this.rb.path(`/nodes/${nodeId}`).patch<void>(payload);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* 특정 노드를 삭제합니다.
|
|
146
|
+
* @param nodeId - 삭제할 노드의 ID
|
|
147
|
+
* @example
|
|
148
|
+
* await client.graph.deleteNode(101);
|
|
149
|
+
* // Output: (No content)
|
|
150
|
+
*/
|
|
151
|
+
deleteNode(nodeId: number): Promise<HttpResponse<void>> {
|
|
152
|
+
return this.rb.path(`/nodes/${nodeId}`).delete<void>();
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 특정 노드와 연결된 모든 엣지를 함께 삭제합니다.
|
|
157
|
+
* @param nodeId - 삭제할 노드의 ID
|
|
158
|
+
* @example
|
|
159
|
+
* await client.graph.deleteNodeCascade(101);
|
|
160
|
+
* // Output: (No content)
|
|
161
|
+
*/
|
|
162
|
+
deleteNodeCascade(nodeId: number): Promise<HttpResponse<void>> {
|
|
163
|
+
return this.rb.path(`/nodes/${nodeId}/cascade`).delete<void>();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 새 엣지를 생성합니다.
|
|
168
|
+
* @param edge - 생성할 엣지 데이터
|
|
169
|
+
* - `source` (number): 출발 노드 ID
|
|
170
|
+
* - `target` (number): 도착 노드 ID
|
|
171
|
+
* - `weight` (number): 가중치
|
|
172
|
+
* - `type` ('hard' | 'insight'): 엣지 타입
|
|
173
|
+
* - `intraCluster` (boolean): 클러스터 내부 연결 여부
|
|
174
|
+
* @returns 생성된 엣지 ID
|
|
175
|
+
* - `id` (string): 엣지 ID
|
|
176
|
+
* @example
|
|
177
|
+
* const response = await client.graph.createEdge({
|
|
178
|
+
* source: 101,
|
|
179
|
+
* target: 102,
|
|
180
|
+
* weight: 0.85,
|
|
181
|
+
* type: 'insight',
|
|
182
|
+
* intraCluster: true
|
|
183
|
+
* });
|
|
184
|
+
*
|
|
185
|
+
* console.log(response.data);
|
|
186
|
+
* // Output:
|
|
187
|
+
* {
|
|
188
|
+
* id: 'edge-uuid-...'
|
|
189
|
+
* }
|
|
190
|
+
*/
|
|
191
|
+
createEdge(edge: GraphEdgeDto): Promise<HttpResponse<CreateEdgeResponse>> {
|
|
192
|
+
return this.rb.path('/edges').post<CreateEdgeResponse>(edge);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* 사용자의 모든 엣지를 가져옵니다.
|
|
197
|
+
* @returns 엣지 목록 (GraphEdgeDto 배열)
|
|
198
|
+
* @example
|
|
199
|
+
* const response = await client.graph.listEdges();
|
|
200
|
+
*
|
|
201
|
+
* console.log(response.data);
|
|
202
|
+
* // Output:
|
|
203
|
+
* [
|
|
204
|
+
* {
|
|
205
|
+
* id: 'edge-1',
|
|
206
|
+
* source: 101,
|
|
207
|
+
* target: 102,
|
|
208
|
+
* weight: 0.85,
|
|
209
|
+
* type: 'insight',
|
|
210
|
+
* intraCluster: true
|
|
211
|
+
* },
|
|
212
|
+
* {
|
|
213
|
+
* id: 'edge-2',
|
|
214
|
+
* source: 102,
|
|
215
|
+
* target: 103,
|
|
216
|
+
* weight: 0.5,
|
|
217
|
+
* type: 'hard',
|
|
218
|
+
* intraCluster: false
|
|
219
|
+
* }
|
|
220
|
+
* ]
|
|
221
|
+
*/
|
|
222
|
+
listEdges(): Promise<HttpResponse<GraphEdgeDto[]>> {
|
|
223
|
+
return this.rb.path('/edges').get<GraphEdgeDto[]>();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 특정 엣지를 삭제합니다.
|
|
228
|
+
* @param edgeId - 삭제할 엣지의 ID
|
|
229
|
+
* @example
|
|
230
|
+
* await client.graph.deleteEdge('edge-uuid-...');
|
|
231
|
+
* // Output: (No content)
|
|
232
|
+
*/
|
|
233
|
+
deleteEdge(edgeId: string): Promise<HttpResponse<void>> {
|
|
234
|
+
return this.rb.path(`/edges/${edgeId}`).delete<void>();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 새 클러스터를 생성하거나 기존 클러스터를 업데이트합니다.
|
|
239
|
+
* @param cluster - 생성 또는 업데이트할 클러스터 데이터
|
|
240
|
+
* @returns 생성 또는 업데이트된 클러스터
|
|
241
|
+
* @example
|
|
242
|
+
* const response = await client.graph.createCluster({
|
|
243
|
+
* id: 'cluster-a',
|
|
244
|
+
* name: 'Project Alpha',
|
|
245
|
+
* summary: 'Main project discussion'
|
|
246
|
+
* });
|
|
247
|
+
*
|
|
248
|
+
* console.log(response.data);
|
|
249
|
+
* // Output:
|
|
250
|
+
* {
|
|
251
|
+
* id: 'cluster-a',
|
|
252
|
+
* name: 'Project Alpha',
|
|
253
|
+
* summary: 'Main project discussion'
|
|
254
|
+
* }
|
|
255
|
+
*/
|
|
256
|
+
createCluster(cluster: GraphClusterDto): Promise<HttpResponse<GraphClusterDto>> {
|
|
257
|
+
return this.rb.path('/clusters').post<GraphClusterDto>(cluster);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 사용자의 모든 클러스터를 가져옵니다.
|
|
262
|
+
* @returns 클러스터 목록
|
|
263
|
+
* @example
|
|
264
|
+
* const response = await client.graph.listClusters();
|
|
265
|
+
*
|
|
266
|
+
* console.log(response.data);
|
|
267
|
+
* // Output:
|
|
268
|
+
* [
|
|
269
|
+
* {
|
|
270
|
+
* id: 'cluster-a',
|
|
271
|
+
* name: 'Project Alpha',
|
|
272
|
+
* summary: 'Main project discussion'
|
|
273
|
+
* },
|
|
274
|
+
* {
|
|
275
|
+
* id: 'cluster-b',
|
|
276
|
+
* name: 'Project Beta',
|
|
277
|
+
* summary: 'Secondary project'
|
|
278
|
+
* }
|
|
279
|
+
* ]
|
|
280
|
+
*/
|
|
281
|
+
listClusters(): Promise<HttpResponse<GraphClusterDto[]>> {
|
|
282
|
+
return this.rb.path('/clusters').get<GraphClusterDto[]>();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 특정 ID의 클러스터를 가져옵니다.
|
|
287
|
+
* @param clusterId - 가져올 클러스터의 ID
|
|
288
|
+
* @returns 요청한 클러스터
|
|
289
|
+
* @example
|
|
290
|
+
* const response = await client.graph.getCluster('cluster-a');
|
|
291
|
+
*
|
|
292
|
+
* console.log(response.data);
|
|
293
|
+
* // Output:
|
|
294
|
+
* {
|
|
295
|
+
* id: 'cluster-a',
|
|
296
|
+
* name: 'Project Alpha',
|
|
297
|
+
* summary: 'Main project discussion'
|
|
298
|
+
* }
|
|
299
|
+
*/
|
|
300
|
+
getCluster(clusterId: string): Promise<HttpResponse<GraphClusterDto>> {
|
|
301
|
+
return this.rb.path(`/clusters/${clusterId}`).get<GraphClusterDto>();
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* 특정 클러스터를 삭제합니다.
|
|
306
|
+
* @param clusterId - 삭제할 클러스터의 ID
|
|
307
|
+
* @example
|
|
308
|
+
* await client.graph.deleteCluster('cluster-a');
|
|
309
|
+
* // Output: (No content)
|
|
310
|
+
*/
|
|
311
|
+
deleteCluster(clusterId: string): Promise<HttpResponse<void>> {
|
|
312
|
+
return this.rb.path(`/clusters/${clusterId}`).delete<void>();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// --- Subclusters ---
|
|
316
|
+
|
|
317
|
+
async listSubclusters(): Promise<HttpResponse<GraphSubclusterDto[]>> {
|
|
318
|
+
return this.rb.path('/subclusters').get<GraphSubclusterDto[]>();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
async getSubcluster(subclusterId: string): Promise<HttpResponse<GraphSubclusterDto>> {
|
|
322
|
+
return this.rb.path(`/subclusters/${subclusterId}`).get<GraphSubclusterDto>();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async deleteSubcluster(subclusterId: string): Promise<HttpResponse<void>> {
|
|
326
|
+
return this.rb.path(`/subclusters/${subclusterId}`).delete<void>();
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* 특정 클러스터와 그 안의 모든 노드 및 엣지를 삭제합니다.
|
|
331
|
+
* @param clusterId - 삭제할 클러스터의 ID
|
|
332
|
+
* @example
|
|
333
|
+
* await client.graph.deleteClusterCascade('cluster-a');
|
|
334
|
+
* // Output: (No content)
|
|
335
|
+
*/
|
|
336
|
+
deleteClusterCascade(clusterId: string): Promise<HttpResponse<void>> {
|
|
337
|
+
return this.rb.path(`/clusters/${clusterId}/cascade`).delete<void>();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 그래프 통계를 가져옵니다.
|
|
342
|
+
* @returns 그래프 통계
|
|
343
|
+
* @example
|
|
344
|
+
* const response = await client.graph.getStats();
|
|
345
|
+
*
|
|
346
|
+
* console.log(response.data);
|
|
347
|
+
* // Output:
|
|
348
|
+
* {
|
|
349
|
+
* nodeCount: 100,
|
|
350
|
+
* edgeCount: 150,
|
|
351
|
+
* clusterCount: 5,
|
|
352
|
+
* density: 0.03
|
|
353
|
+
* }
|
|
354
|
+
*/
|
|
355
|
+
getStats(): Promise<HttpResponse<GraphStatsDto>> {
|
|
356
|
+
return this.rb.path('/stats').get<GraphStatsDto>();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* 전체 그래프 스냅샷을 가져옵니다.
|
|
361
|
+
* @returns 그래프 스냅샷
|
|
362
|
+
* @example
|
|
363
|
+
* const response = await client.graph.getSnapshot();
|
|
364
|
+
*
|
|
365
|
+
* console.log(response.data);
|
|
366
|
+
* // Output:
|
|
367
|
+
* {
|
|
368
|
+
* nodes: [
|
|
369
|
+
* { id: 101, ... },
|
|
370
|
+
* { id: 102, ... }
|
|
371
|
+
* ],
|
|
372
|
+
* edges: [
|
|
373
|
+
* { id: 'edge-1', ... }
|
|
374
|
+
* ],
|
|
375
|
+
* clusters: [
|
|
376
|
+
* { id: 'cluster-a', ... }
|
|
377
|
+
* ]
|
|
378
|
+
* }
|
|
379
|
+
*/
|
|
380
|
+
getSnapshot(): Promise<HttpResponse<GraphSnapshotDto>> {
|
|
381
|
+
return this.rb.path('/snapshot').get<GraphSnapshotDto>();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* 전체 그래프 스냅샷을 서버에 저장합니다.
|
|
386
|
+
* @param snapshot - 저장할 스냅샷 데이터
|
|
387
|
+
* @example
|
|
388
|
+
* await client.graph.saveSnapshot({
|
|
389
|
+
* nodes: [...],
|
|
390
|
+
* edges: [...],
|
|
391
|
+
* clusters: [...]
|
|
392
|
+
* });
|
|
393
|
+
* // Output: (No content)
|
|
394
|
+
*/
|
|
395
|
+
saveSnapshot(snapshot: GraphSnapshotDto): Promise<HttpResponse<void>> {
|
|
396
|
+
return this.rb.path('/snapshot').post<void>({ snapshot });
|
|
397
|
+
}
|
|
398
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { RequestBuilder, type HttpResponse } from '../http-builder.js';
|
|
2
|
+
import type { GraphGenerationResponseDto } from '../types/graphAi.js';
|
|
3
|
+
import type { GraphSummaryDto } from '../types/graph.js';
|
|
4
|
+
import type { AiInputData } from '../types/aiInput.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Graph AI API
|
|
8
|
+
*
|
|
9
|
+
* AI 기반 그래프 생성 및 분석 기능을 제공하는 API 클래스입니다.
|
|
10
|
+
* `/v1/graph-ai` 엔드포인트 하위의 API들을 호출합니다.
|
|
11
|
+
*
|
|
12
|
+
* 주요 기능:
|
|
13
|
+
* - 사용자 대화 기록 기반 그래프 생성 요청 (`generateGraph`)
|
|
14
|
+
* - [테스트용] JSON 데이터 기반 그래프 생성 요청 (`generateGraphTest`)
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export class GraphAiApi {
|
|
19
|
+
private readonly rb: RequestBuilder;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* GraphAiApi 인스턴스를 생성합니다.
|
|
23
|
+
* @param rb RequestBuilder 인스턴스
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
constructor(rb: RequestBuilder) {
|
|
27
|
+
this.rb = rb.path('/v1/graph-ai');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 현재 사용자의 대화 기록을 기반으로 그래프 생성 프로세스를 시작합니다.
|
|
32
|
+
*
|
|
33
|
+
* 이 작업은 서버에서 비동기 백그라운드 작업으로 수행됩니다.
|
|
34
|
+
* 요청이 성공하면 작업 ID(`taskId`)와 초기 상태(`queued`)를 즉시 반환합니다.
|
|
35
|
+
* 클라이언트는 이후 이 `taskId`를 사용하여 작업 상태를 조회하거나 완료 알림을 기다려야 합니다.
|
|
36
|
+
*
|
|
37
|
+
* **API Endpoint**: `POST /v1/graph-ai/generate`
|
|
38
|
+
*
|
|
39
|
+
* @returns 작업 ID와 상태를 포함한 응답 객체 (`GraphGenerationResponseDto`)
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const response = await client.graphAi.generateGraph();
|
|
44
|
+
*
|
|
45
|
+
* console.log(response.data);
|
|
46
|
+
* // Output:
|
|
47
|
+
* {
|
|
48
|
+
* message: 'Graph generation started',
|
|
49
|
+
* taskId: 'task-uuid-1234',
|
|
50
|
+
* status: 'queued'
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
async generateGraph(): Promise<HttpResponse<GraphGenerationResponseDto>> {
|
|
55
|
+
return this.rb.path('/generate').post();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* [테스트용] 직접 JSON 데이터를 입력하여 그래프 생성을 요청합니다.
|
|
60
|
+
*
|
|
61
|
+
* DB에 저장된 대화 기록 대신, 클라이언트가 제공한 JSON 데이터를 사용하여 AI 분석을 수행합니다.
|
|
62
|
+
* 주로 개발 및 테스트 단계에서 특정 시나리오를 검증하기 위해 사용됩니다.
|
|
63
|
+
* 입력 데이터 형식은 ChatGPT의 데이터 내보내기(Export) 포맷(`AiInputData[]`)을 따릅니다.
|
|
64
|
+
*
|
|
65
|
+
* **API Endpoint**: `POST /v1/graph-ai/test/generate-json`
|
|
66
|
+
*
|
|
67
|
+
* @param data - 분석할 대화 데이터 배열 (`AiInputData[]`)
|
|
68
|
+
* @returns 작업 ID와 상태를 포함한 응답 객체 (`GraphGenerationResponseDto`)
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const mockData = [{
|
|
73
|
+
* title: "Test Chat",
|
|
74
|
+
* create_time: 1234567890,
|
|
75
|
+
* update_time: 1234567890,
|
|
76
|
+
* mapping: { ... }
|
|
77
|
+
* }];
|
|
78
|
+
*
|
|
79
|
+
* const response = await client.graphAi.generateGraphTest(mockData);
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
async generateGraphTest(data: AiInputData[]): Promise<HttpResponse<GraphGenerationResponseDto>> {
|
|
83
|
+
return this.rb.path('/test/generate-json').post(data);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Request graph summary generation (Async)
|
|
88
|
+
*
|
|
89
|
+
* Starts a background task to generate insights and summaries for the user's graph network.
|
|
90
|
+
*
|
|
91
|
+
* **API Endpoint**: `POST /v1/graph-ai/summary`
|
|
92
|
+
*
|
|
93
|
+
* @returns Verification of task acceptance
|
|
94
|
+
*/
|
|
95
|
+
async requestSummary(): Promise<HttpResponse<GraphGenerationResponseDto>> {
|
|
96
|
+
return this.rb.path('/summary').post();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get generated graph summary
|
|
101
|
+
*
|
|
102
|
+
* Retrieves the previously generated summary. Returns 404 if not found or not ready.
|
|
103
|
+
*
|
|
104
|
+
* **API Endpoint**: `GET /v1/graph-ai/summary`
|
|
105
|
+
*
|
|
106
|
+
* @returns The graph summary DTO
|
|
107
|
+
*/
|
|
108
|
+
async getSummary(): Promise<HttpResponse<GraphSummaryDto>> {
|
|
109
|
+
return this.rb.path('/summary').get();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RequestBuilder, type HttpResponse } from '../http-builder.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 헬스 체크 응답 DTO
|
|
5
|
+
* @public
|
|
6
|
+
* @property ok 서버 상태 (true: 정상)
|
|
7
|
+
*/
|
|
8
|
+
export interface HealthResponse {
|
|
9
|
+
ok: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Health Check API
|
|
14
|
+
*
|
|
15
|
+
* 서버의 상태를 확인하는 API 클래스입니다.
|
|
16
|
+
* `/healthz` 엔드포인트를 호출합니다.
|
|
17
|
+
*
|
|
18
|
+
* 주요 기능:
|
|
19
|
+
* - 서버 헬스 체크 (`get`)
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export class HealthApi {
|
|
24
|
+
constructor(private rb: RequestBuilder) {}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 서버의 헬스 상태를 확인합니다.
|
|
28
|
+
* @returns 헬스 체크 결과
|
|
29
|
+
* @example
|
|
30
|
+
* const response = await client.health.get();
|
|
31
|
+
* console.log(response.data);
|
|
32
|
+
* // Output:
|
|
33
|
+
* {
|
|
34
|
+
* ok: true
|
|
35
|
+
* }
|
|
36
|
+
*/
|
|
37
|
+
get(): Promise<HttpResponse<HealthResponse>> {
|
|
38
|
+
return this.rb.path('/healthz').get<HealthResponse>();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { RequestBuilder, type HttpResponse } from '../http-builder.js';
|
|
2
|
+
import type { MeResponseDto, ApiKeysResponseDto, ApiKeyModel } from '../types/me.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Me API (User Profile & Settings)
|
|
6
|
+
*
|
|
7
|
+
* 현재 로그인한 사용자의 정보 및 설정을 관리하는 API 클래스입니다.
|
|
8
|
+
* `/v1/me` 및 `/auth` 관련 엔드포인트들을 호출합니다.
|
|
9
|
+
*
|
|
10
|
+
* 주요 기능:
|
|
11
|
+
* - 내 프로필 조회 (`get`)
|
|
12
|
+
* - 로그아웃 (`logout`)
|
|
13
|
+
* - API 키 관리 (조회, 업데이트, 삭제) (`getApiKeys`, `updateApiKey`, `deleteApiKey`)
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
export class MeApi {
|
|
18
|
+
constructor(private rb: RequestBuilder) {}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 내 프로필 정보를 조회합니다.
|
|
22
|
+
* @returns 내 정보
|
|
23
|
+
* - `user` (UserProfileDto): 사용자 프로필 정보
|
|
24
|
+
* - `id` (string): 사용자 ID
|
|
25
|
+
* - `email` (string, optional): 이메일
|
|
26
|
+
* - `displayName` (string): 표시 이름
|
|
27
|
+
* - `avatarUrl` (string | null): 아바타 URL
|
|
28
|
+
* - `createdAt` (string): 생성 일시 (ISO 8601)
|
|
29
|
+
* @example
|
|
30
|
+
* const response = await client.me.get();
|
|
31
|
+
* console.log(response.data);
|
|
32
|
+
* // Output:
|
|
33
|
+
* {
|
|
34
|
+
* userId: '1...',
|
|
35
|
+
* profile: {
|
|
36
|
+
* id: '1...',
|
|
37
|
+
* email: 'john.doe@example.com',
|
|
38
|
+
* displayName: 'John Doe',
|
|
39
|
+
* avatarUrl: 'https://example.com/avatar.jpg'
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
*/
|
|
43
|
+
get(): Promise<HttpResponse<MeResponseDto>> {
|
|
44
|
+
return this.rb.path('/v1/me').get<MeResponseDto>();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 로그아웃을 수행합니다.
|
|
49
|
+
* - 서버 세션을 무효화합니다.
|
|
50
|
+
* @example
|
|
51
|
+
* await client.me.logout();
|
|
52
|
+
* console.log('Logged out successfully');
|
|
53
|
+
*/
|
|
54
|
+
logout(): Promise<HttpResponse<void>> {
|
|
55
|
+
// 204 No Content 예상
|
|
56
|
+
return this.rb.path('/auth/logout').post<void>();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 특정 모델의 API 키를 조회합니다.
|
|
61
|
+
* @param model - 조회할 API 키 모델 ('openai' | 'deepseek')
|
|
62
|
+
* @returns 마스킹된 API 키 정보
|
|
63
|
+
* - `apiKey` (string | null): 마스킹된 API 키 (설정되지 않은 경우 null)
|
|
64
|
+
* @example
|
|
65
|
+
* const response = await client.me.getApiKeys('openai');
|
|
66
|
+
* console.log(response.data);
|
|
67
|
+
* // Output:
|
|
68
|
+
* {
|
|
69
|
+
* apiKey: 'sk-proj-1234...' // Masked
|
|
70
|
+
* }
|
|
71
|
+
*/
|
|
72
|
+
getApiKeys(model: ApiKeyModel): Promise<HttpResponse<ApiKeysResponseDto>> {
|
|
73
|
+
return this.rb.path(`/v1/me/api-keys/${model}`).get<ApiKeysResponseDto>();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 특정 모델의 API 키를 설정/업데이트합니다.
|
|
78
|
+
* @param model - 설정할 API 키 모델 ('openai' | 'deepseek')
|
|
79
|
+
* @param apiKey - 설정할 API 키 값 (string)
|
|
80
|
+
* @example
|
|
81
|
+
* await client.me.updateApiKey('openai', 'sk-proj-1234567890abcdef');
|
|
82
|
+
* console.log('OpenAI API key updated');
|
|
83
|
+
*/
|
|
84
|
+
updateApiKey(model: ApiKeyModel, apiKey: string): Promise<HttpResponse<void>> {
|
|
85
|
+
return this.rb.path(`/v1/me/api-keys/${model}`).patch<void>({ apiKey });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 특정 모델의 API 키를 삭제합니다.
|
|
90
|
+
* @example
|
|
91
|
+
* await client.me.deleteApiKey('openai');
|
|
92
|
+
* console.log('OpenAI API key deleted');
|
|
93
|
+
*/
|
|
94
|
+
deleteApiKey(model: ApiKeyModel): Promise<HttpResponse<void>> {
|
|
95
|
+
return this.rb.path(`/v1/me/api-keys/${model}`).delete<void>();
|
|
96
|
+
}
|
|
97
|
+
}
|