@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,362 @@
|
|
|
1
|
+
import { RequestBuilder, type HttpResponse } from '../http-builder.js';
|
|
2
|
+
import type {
|
|
3
|
+
ConversationDto,
|
|
4
|
+
ConversationCreateDto,
|
|
5
|
+
ConversationUpdateDto,
|
|
6
|
+
ConversationBulkCreateDto,
|
|
7
|
+
} from '../types/conversation.ts';
|
|
8
|
+
import type { MessageCreateDto, MessageUpdateDto, MessageDto } from '../types/message.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Conversations API
|
|
12
|
+
*
|
|
13
|
+
* AI와의 대화(Conversation) 및 메시지(Message)를 관리하는 API 클래스입니다.
|
|
14
|
+
* `/v1/ai/conversations` 엔드포인트 하위의 API들을 호출합니다.
|
|
15
|
+
*
|
|
16
|
+
* 주요 기능:
|
|
17
|
+
* - 대화 생성, 조회, 수정, 삭제 (`create`, `get`, `list`, `update`, `delete`)
|
|
18
|
+
* - 대화 일괄 생성 (`bulkCreate`)
|
|
19
|
+
* - 삭제된 대화 복원 (`restore`)
|
|
20
|
+
* - 메시지 추가 (`createMessage`)
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export class ConversationsApi {
|
|
25
|
+
constructor(private rb: RequestBuilder) {}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 새로운 대화를 생성합니다.
|
|
29
|
+
* @param dto 대화 생성 요청 데이터
|
|
30
|
+
* - `title` (string): 대화 제목
|
|
31
|
+
* - `id` (string, optional): 대화 ID (클라이언트 생성 시)
|
|
32
|
+
* - `messages` (MessageCreateDto[], optional): 초기 메시지 목록
|
|
33
|
+
* @returns 생성된 대화 정보
|
|
34
|
+
* - `id` (string): 대화 ID
|
|
35
|
+
* - `title` (string): 제목
|
|
36
|
+
* - `messages` (MessageDto[]): 메시지 목록
|
|
37
|
+
* - `createdAt` (string): 생성 일시
|
|
38
|
+
* - `updatedAt` (string): 수정 일시
|
|
39
|
+
* @example
|
|
40
|
+
* const response = await client.conversations.create({
|
|
41
|
+
* title: 'Project Brainstorming',
|
|
42
|
+
* messages: [
|
|
43
|
+
* { role: 'system', content: 'You are a helpful assistant.' },
|
|
44
|
+
* { role: 'user', content: 'Let\'s brainstorm some ideas.' }
|
|
45
|
+
* ]
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* console.log(response.data);
|
|
49
|
+
* // Output:
|
|
50
|
+
* {
|
|
51
|
+
* id: 'conv-123',
|
|
52
|
+
* title: 'Project Brainstorming',
|
|
53
|
+
* messages: [
|
|
54
|
+
* { id: 'msg-1', role: 'system', content: '...', createdAt: '...' },
|
|
55
|
+
* { id: 'msg-2', role: 'user', content: '...', createdAt: '...' }
|
|
56
|
+
* ],
|
|
57
|
+
* createdAt: '2023-10-27T10:00:00Z',
|
|
58
|
+
* updatedAt: '2023-10-27T10:00:00Z'
|
|
59
|
+
* }
|
|
60
|
+
*/
|
|
61
|
+
create(dto: ConversationCreateDto): Promise<HttpResponse<ConversationDto>> {
|
|
62
|
+
return this.rb.path('/v1/ai/conversations').post<ConversationDto>(dto);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 여러 대화를 일괄 생성합니다.
|
|
67
|
+
* @param dto 일괄 생성 요청 데이터
|
|
68
|
+
* - `conversations` (ConversationCreateDto[]): 생성할 대화 목록
|
|
69
|
+
* @returns 생성된 대화 목록
|
|
70
|
+
* @example
|
|
71
|
+
* const response = await client.conversations.bulkCreate({
|
|
72
|
+
* conversations: [
|
|
73
|
+
* {
|
|
74
|
+
* title: 'Chat 1',
|
|
75
|
+
* messages: [{ role: 'user', content: 'Hello' }]
|
|
76
|
+
* },
|
|
77
|
+
* {
|
|
78
|
+
* title: 'Chat 2',
|
|
79
|
+
* messages: [{ role: 'user', content: 'Hi there' }]
|
|
80
|
+
* }
|
|
81
|
+
* ]
|
|
82
|
+
* });
|
|
83
|
+
*
|
|
84
|
+
* console.log(response.data);
|
|
85
|
+
* // Output:
|
|
86
|
+
* {
|
|
87
|
+
* conversations: [
|
|
88
|
+
* {
|
|
89
|
+
* id: 'conv-1',
|
|
90
|
+
* title: 'Chat 1',
|
|
91
|
+
* messages: [{ id: 'msg-1', role: 'user', content: 'Hello', ... }],
|
|
92
|
+
* createdAt: '2023-10-27T10:00:00Z',
|
|
93
|
+
* updatedAt: '2023-10-27T10:00:00Z'
|
|
94
|
+
* },
|
|
95
|
+
* {
|
|
96
|
+
* id: 'conv-2',
|
|
97
|
+
* title: 'Chat 2',
|
|
98
|
+
* messages: [{ id: 'msg-2', role: 'assistant', content: 'Hi there', ... }],
|
|
99
|
+
* createdAt: '2023-10-27T10:00:00Z',
|
|
100
|
+
* updatedAt: '2023-10-27T10:00:00Z'
|
|
101
|
+
* }
|
|
102
|
+
* ]
|
|
103
|
+
* }
|
|
104
|
+
*/
|
|
105
|
+
bulkCreate(
|
|
106
|
+
dto: ConversationBulkCreateDto
|
|
107
|
+
): Promise<HttpResponse<{ conversations: ConversationDto[] }>> {
|
|
108
|
+
return this.rb
|
|
109
|
+
.path('/v1/ai/conversations/bulk')
|
|
110
|
+
.post<{ conversations: ConversationDto[] }>(dto);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 대화 목록을 조회합니다.
|
|
115
|
+
* @returns 대화 목록 (ConversationDto 배열)
|
|
116
|
+
* @example
|
|
117
|
+
* const response = await client.conversations.list();
|
|
118
|
+
*
|
|
119
|
+
* console.log(response.data);
|
|
120
|
+
* // Output:
|
|
121
|
+
* [
|
|
122
|
+
* {
|
|
123
|
+
* id: 'conv-123',
|
|
124
|
+
* title: 'Project Brainstorming',
|
|
125
|
+
* messages: [],
|
|
126
|
+
* createdAt: '2023-10-27T10:00:00Z',
|
|
127
|
+
* updatedAt: '2023-10-27T10:00:00Z'
|
|
128
|
+
* },
|
|
129
|
+
* {
|
|
130
|
+
* id: 'conv-124',
|
|
131
|
+
* title: 'Another Chat',
|
|
132
|
+
* messages: [],
|
|
133
|
+
* createdAt: '2023-10-28T10:00:00Z',
|
|
134
|
+
* updatedAt: '2023-10-28T10:00:00Z'
|
|
135
|
+
* }
|
|
136
|
+
* ]
|
|
137
|
+
*/
|
|
138
|
+
list(): Promise<HttpResponse<ConversationDto[]>> {
|
|
139
|
+
return this.rb.path('/v1/ai/conversations').get<ConversationDto[]>();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 특정 대화를 조회합니다.
|
|
144
|
+
* @param conversationId 대화 ID
|
|
145
|
+
* @returns 대화 상세 정보
|
|
146
|
+
* - `id` (string): 대화 ID
|
|
147
|
+
* - `title` (string): 제목
|
|
148
|
+
* - `messages` (MessageDto[]): 메시지 목록
|
|
149
|
+
* - `createdAt` (string): 생성 일시
|
|
150
|
+
* - `updatedAt` (string): 수정 일시
|
|
151
|
+
* @example
|
|
152
|
+
* const response = await client.conversations.get('conv-123');
|
|
153
|
+
*
|
|
154
|
+
* console.log(response.data);
|
|
155
|
+
* // Output:
|
|
156
|
+
* {
|
|
157
|
+
* id: 'conv-123',
|
|
158
|
+
* title: 'Project Brainstorming',
|
|
159
|
+
* messages: [
|
|
160
|
+
* { id: 'msg-1', role: 'user', content: 'Hello', createdAt: '...' }
|
|
161
|
+
* ],
|
|
162
|
+
* createdAt: '2023-10-27T10:00:00Z',
|
|
163
|
+
* updatedAt: '2023-10-27T10:00:00Z'
|
|
164
|
+
* }
|
|
165
|
+
*/
|
|
166
|
+
get(conversationId: string): Promise<HttpResponse<ConversationDto>> {
|
|
167
|
+
return this.rb.path(`/v1/ai/conversations/${conversationId}`).get<ConversationDto>();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 대화 정보를 수정합니다 (제목 등).
|
|
172
|
+
* @param conversationId 대화 ID
|
|
173
|
+
* @param patch 수정할 데이터
|
|
174
|
+
* - `title` (string, optional): 변경할 제목
|
|
175
|
+
* @returns 수정된 대화 정보
|
|
176
|
+
* @example
|
|
177
|
+
* const response = await client.conversations.update('conv-123', {
|
|
178
|
+
* title: 'Renamed Conversation'
|
|
179
|
+
* });
|
|
180
|
+
*
|
|
181
|
+
* console.log(response.data);
|
|
182
|
+
* // Output:
|
|
183
|
+
* {
|
|
184
|
+
* id: 'conv-123',
|
|
185
|
+
* title: 'Renamed Conversation',
|
|
186
|
+
* messages: [...],
|
|
187
|
+
* createdAt: '...',
|
|
188
|
+
* updatedAt: '...'
|
|
189
|
+
* }
|
|
190
|
+
*/
|
|
191
|
+
update(
|
|
192
|
+
conversationId: string,
|
|
193
|
+
patch: ConversationUpdateDto
|
|
194
|
+
): Promise<HttpResponse<ConversationDto>> {
|
|
195
|
+
return this.rb.path(`/v1/ai/conversations/${conversationId}`).patch<ConversationDto>(patch);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* 대화를 삭제합니다.
|
|
200
|
+
* @param conversationId 대화 ID
|
|
201
|
+
* @param permanent 영구 삭제 여부 (true: 영구 삭제, false: soft delete)
|
|
202
|
+
* @example
|
|
203
|
+
* const response = await client.conversations.delete('conv-123');
|
|
204
|
+
*
|
|
205
|
+
* console.log(response.data);
|
|
206
|
+
* // Output:
|
|
207
|
+
* {
|
|
208
|
+
* ok: true
|
|
209
|
+
* }
|
|
210
|
+
*/
|
|
211
|
+
delete(conversationId: string, permanent?: boolean): Promise<HttpResponse<{ ok: true }>> {
|
|
212
|
+
return this.rb
|
|
213
|
+
.path(`/v1/ai/conversations/${conversationId}`)
|
|
214
|
+
.query({ permanent })
|
|
215
|
+
.delete<{ ok: true }>();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* 모든 대화를 삭제합니다.
|
|
220
|
+
* @returns 삭제된 대화 수
|
|
221
|
+
* @example
|
|
222
|
+
* const response = await client.conversations.deleteAll();
|
|
223
|
+
* console.log(response.data.deletedCount); // 5
|
|
224
|
+
*/
|
|
225
|
+
async deleteAll(): Promise<HttpResponse<{ deletedCount: number }>> {
|
|
226
|
+
return this.rb.path('/v1/ai/conversations').delete<{ deletedCount: number }>();
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* 삭제된 대화를 복구합니다.
|
|
231
|
+
* @param conversationId 대화 ID
|
|
232
|
+
* @returns 복구된 대화 정보
|
|
233
|
+
* @example
|
|
234
|
+
* const response = await client.conversations.restore('conv-123');
|
|
235
|
+
*
|
|
236
|
+
* console.log(response.data);
|
|
237
|
+
* // Output:
|
|
238
|
+
* {
|
|
239
|
+
* id: 'conv-123',
|
|
240
|
+
* title: 'Restored Conversation',
|
|
241
|
+
* messages: [...],
|
|
242
|
+
* createdAt: '...',
|
|
243
|
+
* updatedAt: '...'
|
|
244
|
+
* }
|
|
245
|
+
*/
|
|
246
|
+
restore(conversationId: string): Promise<HttpResponse<ConversationDto>> {
|
|
247
|
+
return this.rb.path(`/v1/ai/conversations/${conversationId}/restore`).post<ConversationDto>({});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// Messages nested under conversation
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 대화에 메시지를 추가합니다.
|
|
254
|
+
* @param conversationId 대화 ID
|
|
255
|
+
* @param dto 메시지 생성 요청 데이터
|
|
256
|
+
* - `role` ('user' | 'assistant' | 'system'): 메시지 역할
|
|
257
|
+
* - `content` (string): 메시지 내용
|
|
258
|
+
* - `id` (string, optional): 메시지 ID (클라이언트 생성 시)
|
|
259
|
+
* @returns 생성된 메시지 정보
|
|
260
|
+
* - `id` (string): 메시지 ID
|
|
261
|
+
* - `role` (string): 역할
|
|
262
|
+
* - `content` (string): 내용
|
|
263
|
+
* - `createdAt` (string): 생성 일시
|
|
264
|
+
* @example
|
|
265
|
+
* const response = await client.conversations.createMessage('conv-123', {
|
|
266
|
+
* role: 'user',
|
|
267
|
+
* content: 'Tell me a joke about programming.'
|
|
268
|
+
* });
|
|
269
|
+
*
|
|
270
|
+
* console.log(response.data);
|
|
271
|
+
* // Output:
|
|
272
|
+
* {
|
|
273
|
+
* id: 'msg-999',
|
|
274
|
+
* role: 'user',
|
|
275
|
+
* content: 'Tell me a joke about programming.',
|
|
276
|
+
* createdAt: '...'
|
|
277
|
+
* }
|
|
278
|
+
*/
|
|
279
|
+
createMessage(conversationId: string, dto: MessageCreateDto): Promise<HttpResponse<MessageDto>> {
|
|
280
|
+
return this.rb.path(`/v1/ai/conversations/${conversationId}/messages`).post<MessageDto>(dto);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* 메시지를 수정합니다.
|
|
285
|
+
* @param conversationId 대화 ID
|
|
286
|
+
* @param messageId 메시지 ID
|
|
287
|
+
* @param patch 수정할 데이터
|
|
288
|
+
* - `content` (string, optional): 변경할 내용
|
|
289
|
+
* @returns 수정된 메시지 정보
|
|
290
|
+
* @example
|
|
291
|
+
* const response = await client.conversations.updateMessage('conv-123', 'msg-999', {
|
|
292
|
+
* content: 'Tell me a joke about Python.'
|
|
293
|
+
* });
|
|
294
|
+
*
|
|
295
|
+
* console.log(response.data);
|
|
296
|
+
* // Output:
|
|
297
|
+
* {
|
|
298
|
+
* id: 'msg-999',
|
|
299
|
+
* role: 'user',
|
|
300
|
+
* content: 'Tell me a joke about Python.',
|
|
301
|
+
* createdAt: '...'
|
|
302
|
+
* }
|
|
303
|
+
*/
|
|
304
|
+
updateMessage(
|
|
305
|
+
conversationId: string,
|
|
306
|
+
messageId: string,
|
|
307
|
+
patch: MessageUpdateDto
|
|
308
|
+
): Promise<HttpResponse<MessageDto>> {
|
|
309
|
+
return this.rb
|
|
310
|
+
.path(`/v1/ai/conversations/${conversationId}/messages/${messageId}`)
|
|
311
|
+
.patch<MessageDto>(patch);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* 메시지를 삭제합니다.
|
|
316
|
+
* @param conversationId 대화 ID
|
|
317
|
+
* @param messageId 메시지 ID
|
|
318
|
+
* @param permanent 영구 삭제 여부 (true: 영구 삭제, false: soft delete)
|
|
319
|
+
* @returns 성공 시 빈 응답
|
|
320
|
+
* @example
|
|
321
|
+
* const response = await client.conversations.deleteMessage('conv-123', 'msg-999');
|
|
322
|
+
*
|
|
323
|
+
* console.log(response.data);
|
|
324
|
+
* // Output:
|
|
325
|
+
* {
|
|
326
|
+
* ok: true
|
|
327
|
+
* }
|
|
328
|
+
*/
|
|
329
|
+
deleteMessage(
|
|
330
|
+
conversationId: string,
|
|
331
|
+
messageId: string,
|
|
332
|
+
permanent?: boolean
|
|
333
|
+
): Promise<HttpResponse<{ ok: true }>> {
|
|
334
|
+
return this.rb
|
|
335
|
+
.path(`/v1/ai/conversations/${conversationId}/messages/${messageId}`)
|
|
336
|
+
.query({ permanent })
|
|
337
|
+
.delete<{ ok: true }>();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* 삭제된 메시지를 복구합니다.
|
|
342
|
+
* @param conversationId 대화 ID
|
|
343
|
+
* @param messageId 메시지 ID
|
|
344
|
+
* @returns 복구된 메시지 정보
|
|
345
|
+
* @example
|
|
346
|
+
* const response = await client.conversations.restoreMessage('conv-123', 'msg-999');
|
|
347
|
+
*
|
|
348
|
+
* console.log(response.data);
|
|
349
|
+
* // Output:
|
|
350
|
+
* {
|
|
351
|
+
* id: 'msg-999',
|
|
352
|
+
* role: 'user',
|
|
353
|
+
* content: '...',
|
|
354
|
+
* createdAt: '...'
|
|
355
|
+
* }
|
|
356
|
+
*/
|
|
357
|
+
restoreMessage(conversationId: string, messageId: string): Promise<HttpResponse<MessageDto>> {
|
|
358
|
+
return this.rb
|
|
359
|
+
.path(`/v1/ai/conversations/${conversationId}/messages/${messageId}/restore`)
|
|
360
|
+
.post<MessageDto>({});
|
|
361
|
+
}
|
|
362
|
+
}
|