@thrillee/aegischat 0.1.5 → 0.1.7
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/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +590 -352
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +590 -352
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useChat.ts +721 -389
- package/src/services/api.ts +22 -22
package/src/services/api.ts
CHANGED
|
@@ -68,7 +68,7 @@ export const chatApi = {
|
|
|
68
68
|
params: ChatConnectParams,
|
|
69
69
|
signal?: AbortSignal
|
|
70
70
|
): Promise<ApiResponse<ChatSession>> {
|
|
71
|
-
return fetchWithAuth('/
|
|
71
|
+
return fetchWithAuth('/chat/connect', {
|
|
72
72
|
method: 'POST',
|
|
73
73
|
body: JSON.stringify(params),
|
|
74
74
|
signal,
|
|
@@ -82,7 +82,7 @@ export const chatApi = {
|
|
|
82
82
|
refreshToken: string,
|
|
83
83
|
signal?: AbortSignal
|
|
84
84
|
): Promise<ApiResponse<{ access_token: string; expires_in: number }>> {
|
|
85
|
-
return fetchWithAuth('/
|
|
85
|
+
return fetchWithAuth('/chat/refresh', {
|
|
86
86
|
method: 'POST',
|
|
87
87
|
body: JSON.stringify({ refresh_token: refreshToken }),
|
|
88
88
|
signal,
|
|
@@ -102,14 +102,14 @@ export const channelsApi = {
|
|
|
102
102
|
if (options.type) params.append('type', options.type);
|
|
103
103
|
if (options.limit) params.append('limit', String(options.limit));
|
|
104
104
|
const query = params.toString() ? `?${params.toString()}` : '';
|
|
105
|
-
return fetchWithAuth(`/
|
|
105
|
+
return fetchWithAuth(`/channels${query}`, { signal });
|
|
106
106
|
},
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Get channel by ID
|
|
110
110
|
*/
|
|
111
111
|
async get(channelId: string, signal?: AbortSignal): Promise<ApiResponse<Channel>> {
|
|
112
|
-
return fetchWithAuth(`/
|
|
112
|
+
return fetchWithAuth(`/channels/${channelId}`, { signal });
|
|
113
113
|
},
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -119,7 +119,7 @@ export const channelsApi = {
|
|
|
119
119
|
userId: string,
|
|
120
120
|
signal?: AbortSignal
|
|
121
121
|
): Promise<ApiResponse<Channel>> {
|
|
122
|
-
return fetchWithAuth('/
|
|
122
|
+
return fetchWithAuth('/channels/dm', {
|
|
123
123
|
method: 'POST',
|
|
124
124
|
body: JSON.stringify({ user_id: userId }),
|
|
125
125
|
signal,
|
|
@@ -133,7 +133,7 @@ export const channelsApi = {
|
|
|
133
133
|
data: { name: string; type?: string; description?: string; metadata?: Record<string, unknown> },
|
|
134
134
|
signal?: AbortSignal
|
|
135
135
|
): Promise<ApiResponse<Channel>> {
|
|
136
|
-
return fetchWithAuth('/
|
|
136
|
+
return fetchWithAuth('/channels', {
|
|
137
137
|
method: 'POST',
|
|
138
138
|
body: JSON.stringify(data),
|
|
139
139
|
signal,
|
|
@@ -147,7 +147,7 @@ export const channelsApi = {
|
|
|
147
147
|
channelId: string,
|
|
148
148
|
signal?: AbortSignal
|
|
149
149
|
): Promise<ApiResponse<{ unread_count: number }>> {
|
|
150
|
-
return fetchWithAuth(`/
|
|
150
|
+
return fetchWithAuth(`/channels/${channelId}/read`, {
|
|
151
151
|
method: 'POST',
|
|
152
152
|
signal,
|
|
153
153
|
});
|
|
@@ -160,7 +160,7 @@ export const channelsApi = {
|
|
|
160
160
|
channelId: string,
|
|
161
161
|
signal?: AbortSignal
|
|
162
162
|
): Promise<ApiResponse<{ members: UserSummary[] }>> {
|
|
163
|
-
return fetchWithAuth(`/
|
|
163
|
+
return fetchWithAuth(`/channels/${channelId}/members`, { signal });
|
|
164
164
|
},
|
|
165
165
|
|
|
166
166
|
/**
|
|
@@ -171,7 +171,7 @@ export const channelsApi = {
|
|
|
171
171
|
data: { name?: string; description?: string; metadata?: Record<string, unknown> },
|
|
172
172
|
signal?: AbortSignal
|
|
173
173
|
): Promise<ApiResponse<Channel>> {
|
|
174
|
-
return fetchWithAuth(`/
|
|
174
|
+
return fetchWithAuth(`/channels/${channelId}`, {
|
|
175
175
|
method: 'PATCH',
|
|
176
176
|
body: JSON.stringify(data),
|
|
177
177
|
signal,
|
|
@@ -192,7 +192,7 @@ export const messagesApi = {
|
|
|
192
192
|
if (options.limit) params.append('limit', String(options.limit));
|
|
193
193
|
if (options.before) params.append('before', options.before);
|
|
194
194
|
const query = params.toString() ? `?${params.toString()}` : '';
|
|
195
|
-
return fetchWithAuth(`/
|
|
195
|
+
return fetchWithAuth(`/channels/${channelId}/messages${query}`, { signal });
|
|
196
196
|
},
|
|
197
197
|
|
|
198
198
|
/**
|
|
@@ -203,7 +203,7 @@ export const messagesApi = {
|
|
|
203
203
|
data: { content: string; type?: string; parent_id?: string; metadata?: Record<string, unknown>; file_ids?: string[] },
|
|
204
204
|
signal?: AbortSignal
|
|
205
205
|
): Promise<ApiResponse<Message>> {
|
|
206
|
-
return fetchWithAuth(`/
|
|
206
|
+
return fetchWithAuth(`/channels/${channelId}/messages`, {
|
|
207
207
|
method: 'POST',
|
|
208
208
|
body: JSON.stringify(data),
|
|
209
209
|
signal,
|
|
@@ -219,7 +219,7 @@ export const messagesApi = {
|
|
|
219
219
|
data: { content?: string; metadata?: Record<string, unknown> },
|
|
220
220
|
signal?: AbortSignal
|
|
221
221
|
): Promise<ApiResponse<Message>> {
|
|
222
|
-
return fetchWithAuth(`/
|
|
222
|
+
return fetchWithAuth(`/channels/${channelId}/messages/${messageId}`, {
|
|
223
223
|
method: 'PATCH',
|
|
224
224
|
body: JSON.stringify(data),
|
|
225
225
|
signal,
|
|
@@ -234,7 +234,7 @@ export const messagesApi = {
|
|
|
234
234
|
messageId: string,
|
|
235
235
|
signal?: AbortSignal
|
|
236
236
|
): Promise<ApiResponse<{ success: boolean }>> {
|
|
237
|
-
return fetchWithAuth(`/
|
|
237
|
+
return fetchWithAuth(`/channels/${channelId}/messages/${messageId}`, {
|
|
238
238
|
method: 'DELETE',
|
|
239
239
|
signal,
|
|
240
240
|
});
|
|
@@ -247,7 +247,7 @@ export const messagesApi = {
|
|
|
247
247
|
channelId: string,
|
|
248
248
|
signal?: AbortSignal
|
|
249
249
|
): Promise<ApiResponse<{ success: boolean }>> {
|
|
250
|
-
return fetchWithAuth(`/
|
|
250
|
+
return fetchWithAuth(`/channels/${channelId}/messages/delivered`, {
|
|
251
251
|
method: 'POST',
|
|
252
252
|
signal,
|
|
253
253
|
});
|
|
@@ -260,7 +260,7 @@ export const messagesApi = {
|
|
|
260
260
|
channelId: string,
|
|
261
261
|
signal?: AbortSignal
|
|
262
262
|
): Promise<ApiResponse<{ success: boolean }>> {
|
|
263
|
-
return fetchWithAuth(`/
|
|
263
|
+
return fetchWithAuth(`/channels/${channelId}/messages/read`, {
|
|
264
264
|
method: 'POST',
|
|
265
265
|
signal,
|
|
266
266
|
});
|
|
@@ -277,7 +277,7 @@ export const reactionsApi = {
|
|
|
277
277
|
emoji: string,
|
|
278
278
|
signal?: AbortSignal
|
|
279
279
|
): Promise<ApiResponse<{ reactions: ReactionSummary[] }>> {
|
|
280
|
-
return fetchWithAuth(`/
|
|
280
|
+
return fetchWithAuth(`/channels/${channelId}/messages/${messageId}/reactions`, {
|
|
281
281
|
method: 'POST',
|
|
282
282
|
body: JSON.stringify({ emoji }),
|
|
283
283
|
signal,
|
|
@@ -294,7 +294,7 @@ export const reactionsApi = {
|
|
|
294
294
|
signal?: AbortSignal
|
|
295
295
|
): Promise<ApiResponse<{ reactions: ReactionSummary[] }>> {
|
|
296
296
|
return fetchWithAuth(
|
|
297
|
-
`/
|
|
297
|
+
`/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}`,
|
|
298
298
|
{ method: 'DELETE', signal }
|
|
299
299
|
);
|
|
300
300
|
},
|
|
@@ -308,7 +308,7 @@ export const filesApi = {
|
|
|
308
308
|
data: { file_name: string; file_type: string; file_size: number },
|
|
309
309
|
signal?: AbortSignal
|
|
310
310
|
): Promise<ApiResponse<UploadUrlResponse>> {
|
|
311
|
-
return fetchWithAuth('/
|
|
311
|
+
return fetchWithAuth('/files/upload-url', {
|
|
312
312
|
method: 'POST',
|
|
313
313
|
body: JSON.stringify(data),
|
|
314
314
|
signal,
|
|
@@ -322,7 +322,7 @@ export const filesApi = {
|
|
|
322
322
|
fileId: string,
|
|
323
323
|
signal?: AbortSignal
|
|
324
324
|
): Promise<ApiResponse<{ file: FileAttachment }>> {
|
|
325
|
-
return fetchWithAuth('/
|
|
325
|
+
return fetchWithAuth('/files', {
|
|
326
326
|
method: 'POST',
|
|
327
327
|
body: JSON.stringify({ file_id: fileId }),
|
|
328
328
|
signal,
|
|
@@ -336,7 +336,7 @@ export const filesApi = {
|
|
|
336
336
|
fileId: string,
|
|
337
337
|
signal?: AbortSignal
|
|
338
338
|
): Promise<ApiResponse<{ url: string; expires_at: string }>> {
|
|
339
|
-
return fetchWithAuth(`/
|
|
339
|
+
return fetchWithAuth(`/files/${fileId}/download`, { signal });
|
|
340
340
|
},
|
|
341
341
|
};
|
|
342
342
|
|
|
@@ -348,14 +348,14 @@ export const usersApi = {
|
|
|
348
348
|
query: string,
|
|
349
349
|
signal?: AbortSignal
|
|
350
350
|
): Promise<ApiResponse<{ users: UserSummary[] }>> {
|
|
351
|
-
return fetchWithAuth(`/
|
|
351
|
+
return fetchWithAuth(`/users/search?q=${encodeURIComponent(query)}`, { signal });
|
|
352
352
|
},
|
|
353
353
|
|
|
354
354
|
/**
|
|
355
355
|
* Get user by ID
|
|
356
356
|
*/
|
|
357
357
|
async get(userId: string, signal?: AbortSignal): Promise<ApiResponse<UserSummary>> {
|
|
358
|
-
return fetchWithAuth(`/
|
|
358
|
+
return fetchWithAuth(`/users/${userId}`, { signal });
|
|
359
359
|
},
|
|
360
360
|
};
|
|
361
361
|
|