@thrillee/aegischat 0.1.11 → 0.1.14
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 +35 -34
- package/dist/index.d.ts +35 -34
- package/dist/index.js +19 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +19 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useAutoRead.ts +1 -15
- package/src/hooks/useChannels.ts +3 -3
- package/src/hooks/useChat.ts +24 -19
- package/src/services/api.ts +25 -26
package/src/services/api.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// ============================================================================
|
|
4
4
|
|
|
5
5
|
import type {
|
|
6
|
-
ApiResponse,
|
|
7
6
|
ChatSession,
|
|
8
7
|
ChatConnectParams,
|
|
9
8
|
Channel,
|
|
@@ -67,7 +66,7 @@ export const chatApi = {
|
|
|
67
66
|
async connect(
|
|
68
67
|
params: ChatConnectParams,
|
|
69
68
|
signal?: AbortSignal,
|
|
70
|
-
): Promise<
|
|
69
|
+
): Promise<ChatSession> {
|
|
71
70
|
return fetchWithAuth("/chat/connect", {
|
|
72
71
|
method: "POST",
|
|
73
72
|
body: JSON.stringify(params),
|
|
@@ -81,7 +80,7 @@ export const chatApi = {
|
|
|
81
80
|
async refreshToken(
|
|
82
81
|
refreshToken: string,
|
|
83
82
|
signal?: AbortSignal,
|
|
84
|
-
): Promise<
|
|
83
|
+
): Promise<{ access_token: string; expires_in: number }> {
|
|
85
84
|
return fetchWithAuth("/chat/refresh", {
|
|
86
85
|
method: "POST",
|
|
87
86
|
body: JSON.stringify({ refresh_token: refreshToken }),
|
|
@@ -97,7 +96,7 @@ export const channelsApi = {
|
|
|
97
96
|
async list(
|
|
98
97
|
options: { type?: string; limit?: number } = {},
|
|
99
98
|
signal?: AbortSignal,
|
|
100
|
-
): Promise<
|
|
99
|
+
): Promise<{ channels: ChannelListItem[] }> {
|
|
101
100
|
const params = new URLSearchParams();
|
|
102
101
|
if (options.type) params.append("type", options.type);
|
|
103
102
|
if (options.limit) params.append("limit", String(options.limit));
|
|
@@ -111,7 +110,7 @@ export const channelsApi = {
|
|
|
111
110
|
async get(
|
|
112
111
|
channelId: string,
|
|
113
112
|
signal?: AbortSignal,
|
|
114
|
-
): Promise<
|
|
113
|
+
): Promise<Channel> {
|
|
115
114
|
return fetchWithAuth(`/channels/${channelId}`, { signal });
|
|
116
115
|
},
|
|
117
116
|
|
|
@@ -121,7 +120,7 @@ export const channelsApi = {
|
|
|
121
120
|
async getOrCreateDM(
|
|
122
121
|
userId: string,
|
|
123
122
|
signal?: AbortSignal,
|
|
124
|
-
): Promise<
|
|
123
|
+
): Promise<Channel> {
|
|
125
124
|
return fetchWithAuth("/channels/dm", {
|
|
126
125
|
method: "POST",
|
|
127
126
|
body: JSON.stringify({ user_id: userId }),
|
|
@@ -140,8 +139,8 @@ export const channelsApi = {
|
|
|
140
139
|
metadata?: Record<string, unknown>;
|
|
141
140
|
},
|
|
142
141
|
signal?: AbortSignal,
|
|
143
|
-
): Promise<
|
|
144
|
-
return fetchWithAuth("/
|
|
142
|
+
): Promise<Channel> {
|
|
143
|
+
return fetchWithAuth("/channels", {
|
|
145
144
|
method: "POST",
|
|
146
145
|
body: JSON.stringify(data),
|
|
147
146
|
signal,
|
|
@@ -154,8 +153,8 @@ export const channelsApi = {
|
|
|
154
153
|
async markAsRead(
|
|
155
154
|
channelId: string,
|
|
156
155
|
signal?: AbortSignal,
|
|
157
|
-
): Promise<
|
|
158
|
-
return fetchWithAuth(`/
|
|
156
|
+
): Promise<{ unread_count: number }> {
|
|
157
|
+
return fetchWithAuth(`/channels/${channelId}/read`, {
|
|
159
158
|
method: "POST",
|
|
160
159
|
signal,
|
|
161
160
|
});
|
|
@@ -167,7 +166,7 @@ export const channelsApi = {
|
|
|
167
166
|
async getMembers(
|
|
168
167
|
channelId: string,
|
|
169
168
|
signal?: AbortSignal,
|
|
170
|
-
): Promise<
|
|
169
|
+
): Promise<{ members: UserSummary[] }> {
|
|
171
170
|
return fetchWithAuth(`/channels/${channelId}/members`, { signal });
|
|
172
171
|
},
|
|
173
172
|
|
|
@@ -182,8 +181,8 @@ export const channelsApi = {
|
|
|
182
181
|
metadata?: Record<string, unknown>;
|
|
183
182
|
},
|
|
184
183
|
signal?: AbortSignal,
|
|
185
|
-
): Promise<
|
|
186
|
-
return fetchWithAuth(`/
|
|
184
|
+
): Promise<Channel> {
|
|
185
|
+
return fetchWithAuth(`/channels/${channelId}`, {
|
|
187
186
|
method: "PATCH",
|
|
188
187
|
body: JSON.stringify(data),
|
|
189
188
|
signal,
|
|
@@ -199,7 +198,7 @@ export const messagesApi = {
|
|
|
199
198
|
channelId: string,
|
|
200
199
|
options: { limit?: number; before?: string } = {},
|
|
201
200
|
signal?: AbortSignal,
|
|
202
|
-
): Promise<
|
|
201
|
+
): Promise<MessagesResponse> {
|
|
203
202
|
const params = new URLSearchParams();
|
|
204
203
|
if (options.limit) params.append("limit", String(options.limit));
|
|
205
204
|
if (options.before) params.append("before", options.before);
|
|
@@ -222,7 +221,7 @@ export const messagesApi = {
|
|
|
222
221
|
file_ids?: string[];
|
|
223
222
|
},
|
|
224
223
|
signal?: AbortSignal,
|
|
225
|
-
): Promise<
|
|
224
|
+
): Promise<Message> {
|
|
226
225
|
return fetchWithAuth(`/channels/${channelId}/messages`, {
|
|
227
226
|
method: "POST",
|
|
228
227
|
body: JSON.stringify(data),
|
|
@@ -238,7 +237,7 @@ export const messagesApi = {
|
|
|
238
237
|
messageId: string,
|
|
239
238
|
data: { content?: string; metadata?: Record<string, unknown> },
|
|
240
239
|
signal?: AbortSignal,
|
|
241
|
-
): Promise<
|
|
240
|
+
): Promise<Message> {
|
|
242
241
|
return fetchWithAuth(`/channels/${channelId}/messages/${messageId}`, {
|
|
243
242
|
method: "PATCH",
|
|
244
243
|
body: JSON.stringify(data),
|
|
@@ -253,7 +252,7 @@ export const messagesApi = {
|
|
|
253
252
|
channelId: string,
|
|
254
253
|
messageId: string,
|
|
255
254
|
signal?: AbortSignal,
|
|
256
|
-
): Promise<
|
|
255
|
+
): Promise<{ success: boolean }> {
|
|
257
256
|
return fetchWithAuth(`/channels/${channelId}/messages/${messageId}`, {
|
|
258
257
|
method: "DELETE",
|
|
259
258
|
signal,
|
|
@@ -266,7 +265,7 @@ export const messagesApi = {
|
|
|
266
265
|
async markDelivered(
|
|
267
266
|
channelId: string,
|
|
268
267
|
signal?: AbortSignal,
|
|
269
|
-
): Promise<
|
|
268
|
+
): Promise<{ success: boolean }> {
|
|
270
269
|
return fetchWithAuth(`/channels/${channelId}/messages/delivered`, {
|
|
271
270
|
method: "POST",
|
|
272
271
|
signal,
|
|
@@ -279,7 +278,7 @@ export const messagesApi = {
|
|
|
279
278
|
async markRead(
|
|
280
279
|
channelId: string,
|
|
281
280
|
signal?: AbortSignal,
|
|
282
|
-
): Promise<
|
|
281
|
+
): Promise<{ success: boolean }> {
|
|
283
282
|
return fetchWithAuth(`/channels/${channelId}/messages/read`, {
|
|
284
283
|
method: "POST",
|
|
285
284
|
signal,
|
|
@@ -296,7 +295,7 @@ export const reactionsApi = {
|
|
|
296
295
|
messageId: string,
|
|
297
296
|
emoji: string,
|
|
298
297
|
signal?: AbortSignal,
|
|
299
|
-
): Promise<
|
|
298
|
+
): Promise<{ reactions: ReactionSummary[] }> {
|
|
300
299
|
return fetchWithAuth(
|
|
301
300
|
`/channels/${channelId}/messages/${messageId}/reactions`,
|
|
302
301
|
{
|
|
@@ -315,7 +314,7 @@ export const reactionsApi = {
|
|
|
315
314
|
messageId: string,
|
|
316
315
|
emoji: string,
|
|
317
316
|
signal?: AbortSignal,
|
|
318
|
-
): Promise<
|
|
317
|
+
): Promise<{ reactions: ReactionSummary[] }> {
|
|
319
318
|
return fetchWithAuth(
|
|
320
319
|
`/channels/${channelId}/messages/${messageId}/reactions/${encodeURIComponent(emoji)}`,
|
|
321
320
|
{ method: "DELETE", signal },
|
|
@@ -330,7 +329,7 @@ export const filesApi = {
|
|
|
330
329
|
async getUploadUrl(
|
|
331
330
|
data: { file_name: string; file_type: string; file_size: number },
|
|
332
331
|
signal?: AbortSignal,
|
|
333
|
-
): Promise<
|
|
332
|
+
): Promise<UploadUrlResponse> {
|
|
334
333
|
return fetchWithAuth("/files/upload-url", {
|
|
335
334
|
method: "POST",
|
|
336
335
|
body: JSON.stringify(data),
|
|
@@ -344,7 +343,7 @@ export const filesApi = {
|
|
|
344
343
|
async confirm(
|
|
345
344
|
fileId: string,
|
|
346
345
|
signal?: AbortSignal,
|
|
347
|
-
): Promise<
|
|
346
|
+
): Promise<{ file: FileAttachment }> {
|
|
348
347
|
return fetchWithAuth("/files", {
|
|
349
348
|
method: "POST",
|
|
350
349
|
body: JSON.stringify({ file_id: fileId }),
|
|
@@ -358,7 +357,7 @@ export const filesApi = {
|
|
|
358
357
|
async getDownloadUrl(
|
|
359
358
|
fileId: string,
|
|
360
359
|
signal?: AbortSignal,
|
|
361
|
-
): Promise<
|
|
360
|
+
): Promise<{ url: string; expires_at: string }> {
|
|
362
361
|
return fetchWithAuth(`/files/${fileId}/download`, { signal });
|
|
363
362
|
},
|
|
364
363
|
};
|
|
@@ -370,7 +369,7 @@ export const usersApi = {
|
|
|
370
369
|
async search(
|
|
371
370
|
query: string,
|
|
372
371
|
signal?: AbortSignal,
|
|
373
|
-
): Promise<
|
|
372
|
+
): Promise<{ users: UserSummary[] }> {
|
|
374
373
|
return fetchWithAuth(`/users/search?q=${encodeURIComponent(query)}`, {
|
|
375
374
|
signal,
|
|
376
375
|
});
|
|
@@ -382,7 +381,7 @@ export const usersApi = {
|
|
|
382
381
|
async get(
|
|
383
382
|
userId: string,
|
|
384
383
|
signal?: AbortSignal,
|
|
385
|
-
): Promise<
|
|
384
|
+
): Promise<UserSummary> {
|
|
386
385
|
return fetchWithAuth(`/users/${userId}`, { signal });
|
|
387
386
|
},
|
|
388
387
|
};
|