@manonero/chat-client-sdk 1.0.0-beta.1 → 1.0.0-beta.10
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 +384 -81
- package/dist/ChatClient.d.ts +67 -8
- package/dist/ChatClient.d.ts.map +1 -1
- package/dist/ChatClient.js +82 -9
- package/dist/ChatClient.js.map +1 -1
- package/dist/errors/ChatApiError.d.ts +21 -4
- package/dist/errors/ChatApiError.d.ts.map +1 -1
- package/dist/errors/ChatApiError.js +12 -6
- package/dist/errors/ChatApiError.js.map +1 -1
- package/dist/http/BotApi.d.ts +6 -13
- package/dist/http/BotApi.d.ts.map +1 -1
- package/dist/http/BotApi.js +4 -11
- package/dist/http/BotApi.js.map +1 -1
- package/dist/http/ConversationApi.d.ts +38 -5
- package/dist/http/ConversationApi.d.ts.map +1 -1
- package/dist/http/ConversationApi.js +55 -7
- package/dist/http/ConversationApi.js.map +1 -1
- package/dist/http/FileApi.d.ts +16 -4
- package/dist/http/FileApi.d.ts.map +1 -1
- package/dist/http/FileApi.js +29 -6
- package/dist/http/FileApi.js.map +1 -1
- package/dist/http/HttpClient.d.ts +20 -2
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +76 -14
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/MessageApi.d.ts +2 -1
- package/dist/http/MessageApi.d.ts.map +1 -1
- package/dist/http/MessageApi.js +15 -3
- package/dist/http/MessageApi.js.map +1 -1
- package/dist/http/ProxyApi.d.ts +18 -2
- package/dist/http/ProxyApi.d.ts.map +1 -1
- package/dist/http/ProxyApi.js +33 -6
- package/dist/http/ProxyApi.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/realtime/ChatHubClient.d.ts +58 -1
- package/dist/realtime/ChatHubClient.d.ts.map +1 -1
- package/dist/realtime/ChatHubClient.js +202 -15
- package/dist/realtime/ChatHubClient.js.map +1 -1
- package/dist/realtime/NotificationHubClient.d.ts +43 -1
- package/dist/realtime/NotificationHubClient.d.ts.map +1 -1
- package/dist/realtime/NotificationHubClient.js +134 -29
- package/dist/realtime/NotificationHubClient.js.map +1 -1
- package/dist/realtime/ReconnectionManager.d.ts +2 -1
- package/dist/realtime/ReconnectionManager.d.ts.map +1 -1
- package/dist/realtime/ReconnectionManager.js +13 -3
- package/dist/realtime/ReconnectionManager.js.map +1 -1
- package/dist/types/auth.d.ts +2 -2
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/types/block.d.ts +16 -1
- package/dist/types/block.d.ts.map +1 -1
- package/dist/types/block.js +30 -0
- package/dist/types/block.js.map +1 -1
- package/dist/types/bot.d.ts +2 -8
- package/dist/types/bot.d.ts.map +1 -1
- package/dist/types/chat-events.d.ts +25 -3
- package/dist/types/chat-events.d.ts.map +1 -1
- package/dist/types/common.d.ts +19 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/conversation.d.ts +58 -8
- package/dist/types/conversation.d.ts.map +1 -1
- package/dist/types/message.d.ts +9 -5
- package/dist/types/message.d.ts.map +1 -1
- package/dist/types/notification-events.d.ts +34 -7
- package/dist/types/notification-events.d.ts.map +1 -1
- package/dist/types/participant.d.ts +2 -2
- package/dist/types/participant.d.ts.map +1 -1
- package/dist/types/signalr.d.ts +4 -1
- package/dist/types/signalr.d.ts.map +1 -1
- package/package.json +4 -2
package/dist/ChatClient.d.ts
CHANGED
|
@@ -24,10 +24,25 @@ export interface ChatClientOptions {
|
|
|
24
24
|
token?: string;
|
|
25
25
|
/**
|
|
26
26
|
* Optional external token provider function.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
*
|
|
28
|
+
* Resolution order on every request / connect:
|
|
29
|
+
* 1. If `tokenProvider` is set AND returns a non-empty string, that value
|
|
30
|
+
* is used (so external rotation systems are honored on each call).
|
|
31
|
+
* 2. Otherwise the internal token (constructor `token`, `setToken()`, or
|
|
32
|
+
* auto-set after a successful login) is used.
|
|
33
|
+
* 3. Otherwise null (no Authorization header sent).
|
|
34
|
+
*
|
|
35
|
+
* Note: this is reversed from the previous beta — previously a one-time
|
|
36
|
+
* setToken() would shadow the provider permanently. Now the provider always
|
|
37
|
+
* wins when it returns a value. Use `clearToken()` if you want to make sure
|
|
38
|
+
* the provider takes over after using setToken().
|
|
29
39
|
*/
|
|
30
40
|
tokenProvider?: () => string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Per-request HTTP timeout in milliseconds. Default 30000 (30s).
|
|
43
|
+
* Pass `null` to disable the timeout — useful when uploading large files.
|
|
44
|
+
*/
|
|
45
|
+
requestTimeoutMs?: number | null;
|
|
31
46
|
/** Options for SignalR hub connections */
|
|
32
47
|
signalrOptions?: ChatClientSignalrOptions;
|
|
33
48
|
}
|
|
@@ -67,8 +82,13 @@ export interface ChatClientRealtime {
|
|
|
67
82
|
*/
|
|
68
83
|
export declare class ChatClient {
|
|
69
84
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
85
|
+
* Internally held JWT token (set via constructor `token`, `setToken()`, or
|
|
86
|
+
* after a successful login).
|
|
87
|
+
*
|
|
88
|
+
* Acts as the fallback when no `tokenProvider` is configured, or when the
|
|
89
|
+
* configured `tokenProvider` returns null. The external `tokenProvider`
|
|
90
|
+
* always wins when it returns a non-empty value — see
|
|
91
|
+
* {@link ChatClientOptions.tokenProvider}.
|
|
72
92
|
*/
|
|
73
93
|
private _token;
|
|
74
94
|
/**
|
|
@@ -101,16 +121,55 @@ export declare class ChatClient {
|
|
|
101
121
|
/**
|
|
102
122
|
* Update the JWT token.
|
|
103
123
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
124
|
+
* Effect on requests:
|
|
125
|
+
* - HTTP: takes effect on the very next request.
|
|
126
|
+
* - SignalR: existing active connections keep using the token they were
|
|
127
|
+
* opened with. To apply the new token immediately to active hubs, call
|
|
128
|
+
* `refreshConnections()` after `setToken()`.
|
|
129
|
+
*
|
|
130
|
+
* Pass `null` to clear the internally held token (same as `clearToken()`):
|
|
131
|
+
* both `_token` and `currentUser` are cleared so the SDK no longer reports
|
|
132
|
+
* stale identity. If a `tokenProvider` is configured and still returns a
|
|
133
|
+
* value, it will continue to be used regardless of this call.
|
|
134
|
+
*/
|
|
135
|
+
setToken(token: string | null): void;
|
|
136
|
+
/**
|
|
137
|
+
* Clear the internally held JWT token and authenticated user.
|
|
138
|
+
*
|
|
139
|
+
* After this, the configured `tokenProvider` (if any) becomes the only
|
|
140
|
+
* source of tokens. Use `logout()` instead when you also want to disconnect
|
|
141
|
+
* SignalR hubs.
|
|
107
142
|
*/
|
|
108
|
-
|
|
143
|
+
clearToken(): void;
|
|
144
|
+
/**
|
|
145
|
+
* Disconnect any active SignalR hub and reconnect it with the latest token.
|
|
146
|
+
*
|
|
147
|
+
* Useful right after `setToken()` to propagate the new token to live hubs.
|
|
148
|
+
* Hubs that are not currently connected are left untouched.
|
|
149
|
+
*
|
|
150
|
+
* Re-joins of conversations / re-subscriptions of presence are NOT performed
|
|
151
|
+
* automatically here — `disconnect()` clears that local tracking by design.
|
|
152
|
+
* The application is responsible for re-issuing those after a manual refresh
|
|
153
|
+
* (or for using `ReconnectionManager` for transparent recovery).
|
|
154
|
+
*/
|
|
155
|
+
refreshConnections(): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* Log the current user out: clear the internal token + currentUser and
|
|
158
|
+
* disconnect both SignalR hubs.
|
|
159
|
+
*
|
|
160
|
+
* Note: there is no server-side logout endpoint — this only clears local
|
|
161
|
+
* SDK state. If a `tokenProvider` is configured and still returns a token,
|
|
162
|
+
* subsequent requests can authenticate again with that token.
|
|
163
|
+
*/
|
|
164
|
+
logout(): Promise<void>;
|
|
109
165
|
/**
|
|
110
166
|
* Disconnect all SignalR hubs (ChatHub + NotificationHub).
|
|
111
167
|
*
|
|
112
168
|
* Resolves after both hubs have finished disconnecting. Individual hub
|
|
113
169
|
* disconnect failures do not prevent the other hub from disconnecting.
|
|
170
|
+
*
|
|
171
|
+
* Both hubs set their `intentionallyClosed` flag, so a `ReconnectionManager`
|
|
172
|
+
* attached to them will skip auto-reconnect for the resulting close.
|
|
114
173
|
*/
|
|
115
174
|
disconnect(): Promise<void>;
|
|
116
175
|
/**
|
package/dist/ChatClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatClient.d.ts","sourceRoot":"","sources":["../src/ChatClient.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"ChatClient.d.ts","sourceRoot":"","sources":["../src/ChatClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,KAAK,EAAgB,YAAY,EAAgB,MAAM,iBAAiB,CAAC;AAoDhF,MAAM,WAAW,wBAAwB;IACvC,wEAAwE;IACxE,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC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;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAOpC;;;;;;OAMG;IACH,UAAU,IAAI,IAAI;IAKlB;;;;;;;;;;OAUG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAqBzC;;;;;;;OAOG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7B;;;;;;;;OAQG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAWjC;;;OAGG;IACH,OAAO,CAAC,eAAe;CAIxB"}
|
package/dist/ChatClient.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ChatClient.ts — Main SDK facade
|
|
2
|
-
import { LogLevel } from '@microsoft/signalr';
|
|
2
|
+
import { HubConnectionState, LogLevel } from '@microsoft/signalr';
|
|
3
3
|
import { HttpClient } from './http/HttpClient.js';
|
|
4
4
|
import { AuthApi } from './http/AuthApi.js';
|
|
5
5
|
import { ParticipantApi } from './http/ParticipantApi.js';
|
|
@@ -94,16 +94,26 @@ export class ChatClient {
|
|
|
94
94
|
// ---------------------------------------------------------------------------
|
|
95
95
|
this._currentUser = null;
|
|
96
96
|
this._token = options.token ?? null;
|
|
97
|
-
// Build the combined token provider
|
|
98
|
-
//
|
|
99
|
-
//
|
|
100
|
-
//
|
|
97
|
+
// Build the combined token provider — see ChatClientOptions.tokenProvider
|
|
98
|
+
// for the rationale. The external provider takes priority when it returns
|
|
99
|
+
// a non-empty value so refresh-token rotation systems keep working even
|
|
100
|
+
// after setToken() has been called.
|
|
101
101
|
const externalProvider = options.tokenProvider;
|
|
102
|
-
this._internalTokenProvider = () =>
|
|
102
|
+
this._internalTokenProvider = () => {
|
|
103
|
+
if (externalProvider) {
|
|
104
|
+
const fromProvider = externalProvider();
|
|
105
|
+
if (fromProvider)
|
|
106
|
+
return fromProvider;
|
|
107
|
+
}
|
|
108
|
+
return this._token;
|
|
109
|
+
};
|
|
103
110
|
// Shared HTTP client used by all REST API modules
|
|
104
111
|
const http = new HttpClient({
|
|
105
112
|
baseUrl: options.baseUrl,
|
|
106
113
|
tokenProvider: this._internalTokenProvider,
|
|
114
|
+
...(options.requestTimeoutMs !== undefined
|
|
115
|
+
? { requestTimeoutMs: options.requestTimeoutMs }
|
|
116
|
+
: {}),
|
|
107
117
|
});
|
|
108
118
|
// Instantiate REST API modules
|
|
109
119
|
this.participants = new ParticipantApi(http);
|
|
@@ -139,18 +149,81 @@ export class ChatClient {
|
|
|
139
149
|
/**
|
|
140
150
|
* Update the JWT token.
|
|
141
151
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
152
|
+
* Effect on requests:
|
|
153
|
+
* - HTTP: takes effect on the very next request.
|
|
154
|
+
* - SignalR: existing active connections keep using the token they were
|
|
155
|
+
* opened with. To apply the new token immediately to active hubs, call
|
|
156
|
+
* `refreshConnections()` after `setToken()`.
|
|
157
|
+
*
|
|
158
|
+
* Pass `null` to clear the internally held token (same as `clearToken()`):
|
|
159
|
+
* both `_token` and `currentUser` are cleared so the SDK no longer reports
|
|
160
|
+
* stale identity. If a `tokenProvider` is configured and still returns a
|
|
161
|
+
* value, it will continue to be used regardless of this call.
|
|
145
162
|
*/
|
|
146
163
|
setToken(token) {
|
|
147
164
|
this._token = token;
|
|
165
|
+
if (token === null) {
|
|
166
|
+
this._currentUser = null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Clear the internally held JWT token and authenticated user.
|
|
171
|
+
*
|
|
172
|
+
* After this, the configured `tokenProvider` (if any) becomes the only
|
|
173
|
+
* source of tokens. Use `logout()` instead when you also want to disconnect
|
|
174
|
+
* SignalR hubs.
|
|
175
|
+
*/
|
|
176
|
+
clearToken() {
|
|
177
|
+
this._token = null;
|
|
178
|
+
this._currentUser = null;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Disconnect any active SignalR hub and reconnect it with the latest token.
|
|
182
|
+
*
|
|
183
|
+
* Useful right after `setToken()` to propagate the new token to live hubs.
|
|
184
|
+
* Hubs that are not currently connected are left untouched.
|
|
185
|
+
*
|
|
186
|
+
* Re-joins of conversations / re-subscriptions of presence are NOT performed
|
|
187
|
+
* automatically here — `disconnect()` clears that local tracking by design.
|
|
188
|
+
* The application is responsible for re-issuing those after a manual refresh
|
|
189
|
+
* (or for using `ReconnectionManager` for transparent recovery).
|
|
190
|
+
*/
|
|
191
|
+
async refreshConnections() {
|
|
192
|
+
const tasks = [];
|
|
193
|
+
if (this.realtime.chat.state === HubConnectionState.Connected) {
|
|
194
|
+
tasks.push((async () => {
|
|
195
|
+
await this.realtime.chat.disconnect();
|
|
196
|
+
await this.realtime.chat.connect();
|
|
197
|
+
})());
|
|
198
|
+
}
|
|
199
|
+
if (this.realtime.notifications.state === HubConnectionState.Connected) {
|
|
200
|
+
tasks.push((async () => {
|
|
201
|
+
await this.realtime.notifications.disconnect();
|
|
202
|
+
await this.realtime.notifications.connect();
|
|
203
|
+
})());
|
|
204
|
+
}
|
|
205
|
+
await Promise.all(tasks);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Log the current user out: clear the internal token + currentUser and
|
|
209
|
+
* disconnect both SignalR hubs.
|
|
210
|
+
*
|
|
211
|
+
* Note: there is no server-side logout endpoint — this only clears local
|
|
212
|
+
* SDK state. If a `tokenProvider` is configured and still returns a token,
|
|
213
|
+
* subsequent requests can authenticate again with that token.
|
|
214
|
+
*/
|
|
215
|
+
async logout() {
|
|
216
|
+
this.clearToken();
|
|
217
|
+
await this.disconnect();
|
|
148
218
|
}
|
|
149
219
|
/**
|
|
150
220
|
* Disconnect all SignalR hubs (ChatHub + NotificationHub).
|
|
151
221
|
*
|
|
152
222
|
* Resolves after both hubs have finished disconnecting. Individual hub
|
|
153
223
|
* disconnect failures do not prevent the other hub from disconnecting.
|
|
224
|
+
*
|
|
225
|
+
* Both hubs set their `intentionallyClosed` flag, so a `ReconnectionManager`
|
|
226
|
+
* attached to them will skip auto-reconnect for the resulting close.
|
|
154
227
|
*/
|
|
155
228
|
async disconnect() {
|
|
156
229
|
await Promise.allSettled([
|
package/dist/ChatClient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatClient.js","sourceRoot":"","sources":["../src/ChatClient.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatClient.js","sourceRoot":"","sources":["../src/ChatClient.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAElC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAG5E,8EAA8E;AAC9E,uEAAuE;AACvE,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,mBAAoB,SAAQ,OAAO;IAGvC,YAAY,IAAgB,EAAE,SAAsC;QAClE,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAA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AA8E;IAC9E,kBAAkB;IAClB,8EAA8E;IAE9E;;;OAGG;IACK,eAAe,CAAC,QAAsB;QAC5C,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,IAAI,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
import type { ProblemDetails } from '../types/common.js';
|
|
1
|
+
import type { ProblemDetails, ProblemError } from '../types/common.js';
|
|
2
2
|
/**
|
|
3
3
|
* Custom error thrown for all HTTP API failures.
|
|
4
4
|
*
|
|
5
5
|
* Handles two error formats from the server:
|
|
6
|
-
* 1. RFC 7807 full: { status, title, detail } — standard REST endpoints
|
|
7
|
-
* 2. Proxy error simple: { detail }
|
|
6
|
+
* 1. RFC 7807 full: { status, title, detail?, errors?, traceId? } — standard REST endpoints
|
|
7
|
+
* 2. Proxy error simple: { detail } — /api/proxy/* endpoints
|
|
8
8
|
*/
|
|
9
9
|
export declare class ChatApiError extends Error {
|
|
10
10
|
readonly status: number;
|
|
11
11
|
readonly title: string;
|
|
12
12
|
readonly detail: string | undefined;
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* RFC 7807 problem `type` URI (e.g. "https://tools.ietf.org/html/rfc9110#section-15.5.1").
|
|
15
|
+
* Set when the server emits a typed problem document; `undefined` for proxy errors
|
|
16
|
+
* and synthetic SDK errors (timeouts, network failures, parse errors).
|
|
17
|
+
*/
|
|
18
|
+
readonly type: string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Array of structured error details returned by handler endpoints (ErrorOr path).
|
|
21
|
+
* Each entry has `code`, `description`, and `type` (ErrorType enum value).
|
|
22
|
+
* `undefined` for middleware/filter errors and proxy errors.
|
|
23
|
+
*/
|
|
24
|
+
readonly errors: ProblemError[] | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* W3C trace ID for log correlation.
|
|
27
|
+
* Added automatically by the framework; `undefined` for synthetic SDK errors.
|
|
28
|
+
*/
|
|
29
|
+
readonly traceId: string | undefined;
|
|
30
|
+
constructor(status: number, title: string, detail?: string, type?: string, errors?: ProblemError[], traceId?: string);
|
|
14
31
|
/**
|
|
15
32
|
* Parse a ChatApiError from a failed HTTP response.
|
|
16
33
|
* Tries to parse the body as JSON; falls back to status text.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatApiError.d.ts","sourceRoot":"","sources":["../../src/errors/ChatApiError.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatApiError.d.ts","sourceRoot":"","sources":["../../src/errors/ChatApiError.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvE;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC;IAC5C;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;gBAGnC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,YAAY,EAAE,EACvB,OAAO,CAAC,EAAE,MAAM;IAclB;;;OAGG;WACU,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAoCpE,gEAAgE;IAChE,MAAM,CAAC,kBAAkB,CAAC,EAAE,EAAE,cAAc,GAAG,YAAY;CAG5D"}
|
|
@@ -3,16 +3,19 @@
|
|
|
3
3
|
* Custom error thrown for all HTTP API failures.
|
|
4
4
|
*
|
|
5
5
|
* Handles two error formats from the server:
|
|
6
|
-
* 1. RFC 7807 full: { status, title, detail } — standard REST endpoints
|
|
7
|
-
* 2. Proxy error simple: { detail }
|
|
6
|
+
* 1. RFC 7807 full: { status, title, detail?, errors?, traceId? } — standard REST endpoints
|
|
7
|
+
* 2. Proxy error simple: { detail } — /api/proxy/* endpoints
|
|
8
8
|
*/
|
|
9
9
|
export class ChatApiError extends Error {
|
|
10
|
-
constructor(status, title, detail) {
|
|
10
|
+
constructor(status, title, detail, type, errors, traceId) {
|
|
11
11
|
super(detail ?? title);
|
|
12
12
|
this.name = 'ChatApiError';
|
|
13
13
|
this.status = status;
|
|
14
14
|
this.title = title;
|
|
15
15
|
this.detail = detail;
|
|
16
|
+
this.type = type;
|
|
17
|
+
this.errors = errors;
|
|
18
|
+
this.traceId = traceId;
|
|
16
19
|
// Maintain proper prototype chain for instanceof checks
|
|
17
20
|
Object.setPrototypeOf(this, ChatApiError.prototype);
|
|
18
21
|
}
|
|
@@ -31,9 +34,12 @@ export class ChatApiError extends Error {
|
|
|
31
34
|
}
|
|
32
35
|
if (body !== null && typeof body === 'object') {
|
|
33
36
|
const obj = body;
|
|
34
|
-
// RFC 7807 full format: { status, title, detail }
|
|
37
|
+
// RFC 7807 full format: { type?, status, title, detail?, errors?, traceId? }
|
|
35
38
|
if (typeof obj['title'] === 'string') {
|
|
36
|
-
|
|
39
|
+
const errors = Array.isArray(obj['errors'])
|
|
40
|
+
? obj['errors']
|
|
41
|
+
: undefined;
|
|
42
|
+
return new ChatApiError(typeof obj['status'] === 'number' ? obj['status'] : response.status, obj['title'], typeof obj['detail'] === 'string' ? obj['detail'] : undefined, typeof obj['type'] === 'string' ? obj['type'] : undefined, errors, typeof obj['traceId'] === 'string' ? obj['traceId'] : undefined);
|
|
37
43
|
}
|
|
38
44
|
// Proxy error simple format: { detail }
|
|
39
45
|
if (typeof obj['detail'] === 'string') {
|
|
@@ -44,7 +50,7 @@ export class ChatApiError extends Error {
|
|
|
44
50
|
}
|
|
45
51
|
/** Convenience: create from a ProblemDetails object directly */
|
|
46
52
|
static fromProblemDetails(pd) {
|
|
47
|
-
return new ChatApiError(pd.status, pd.title, pd.detail);
|
|
53
|
+
return new ChatApiError(pd.status, pd.title, pd.detail, pd.type, pd.errors, pd.traceId);
|
|
48
54
|
}
|
|
49
55
|
}
|
|
50
56
|
//# sourceMappingURL=ChatApiError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatApiError.js","sourceRoot":"","sources":["../../src/errors/ChatApiError.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D;;;;;;GAMG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"ChatApiError.js","sourceRoot":"","sources":["../../src/errors/ChatApiError.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D;;;;;;GAMG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAsBrC,YACE,MAAc,EACd,KAAa,EACb,MAAe,EACf,IAAa,EACb,MAAuB,EACvB,OAAgB;QAEhB,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,wDAAwD;QACxD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;I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AAwC;YACxC,IAAI,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACtC,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;QAED,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAChE,CAAC;IAED,gEAAgE;IAChE,MAAM,CAAC,kBAAkB,CAAC,EAAkB;QAC1C,OAAO,IAAI,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC;IAC1F,CAAC;CACF"}
|
package/dist/http/BotApi.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { HttpClient } from './HttpClient.js';
|
|
2
|
-
import type { BotDto, CreateBotRequest, UpdateBotRequest
|
|
2
|
+
import type { BotDto, CreateBotRequest, UpdateBotRequest } from '../types/bot.js';
|
|
3
3
|
import type { PagedResult } from '../types/common.js';
|
|
4
4
|
/**
|
|
5
5
|
* Bot API client.
|
|
6
6
|
*
|
|
7
7
|
* GET endpoints (list, getById) are public — no JWT required.
|
|
8
|
-
* Management endpoints (create, update, activate, deactivate,
|
|
8
|
+
* Management endpoints (create, update, activate, deactivate, delete)
|
|
9
9
|
* require JWT with claim role=dev (obtained via loginWithDev).
|
|
10
10
|
* Non-dev users receive 404 Not Found on management endpoints.
|
|
11
11
|
*/
|
|
@@ -14,22 +14,20 @@ export declare class BotApi {
|
|
|
14
14
|
constructor(http: HttpClient);
|
|
15
15
|
/**
|
|
16
16
|
* GET /api/bots?page={page}&pageSize={pageSize}
|
|
17
|
-
* List all bots (public
|
|
17
|
+
* List all bots (public).
|
|
18
18
|
* page is 1-based.
|
|
19
19
|
*/
|
|
20
20
|
list(params?: {
|
|
21
21
|
page?: number;
|
|
22
22
|
pageSize?: number;
|
|
23
23
|
}): Promise<PagedResult<BotDto>>;
|
|
24
|
-
/** GET /api/bots/{id} (public
|
|
24
|
+
/** GET /api/bots/{id} (public) */
|
|
25
25
|
getById(id: string): Promise<BotDto>;
|
|
26
26
|
/**
|
|
27
27
|
* POST /api/bots (dev-only)
|
|
28
|
-
* Register a new bot.
|
|
28
|
+
* Register a new bot.
|
|
29
29
|
*/
|
|
30
|
-
create(request: CreateBotRequest): Promise<BotDto
|
|
31
|
-
apiKey: string;
|
|
32
|
-
}>;
|
|
30
|
+
create(request: CreateBotRequest): Promise<BotDto>;
|
|
33
31
|
/**
|
|
34
32
|
* PATCH /api/bots/{id} (dev-only)
|
|
35
33
|
* Update bot metadata. kafkaTopic cannot be changed after creation.
|
|
@@ -39,11 +37,6 @@ export declare class BotApi {
|
|
|
39
37
|
activate(id: string): Promise<void>;
|
|
40
38
|
/** POST /api/bots/{id}/deactivate (dev-only) */
|
|
41
39
|
deactivate(id: string): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* POST /api/bots/{id}/regenerate-key (dev-only)
|
|
44
|
-
* Rotate the bot API key. Previous key is immediately invalidated.
|
|
45
|
-
*/
|
|
46
|
-
regenerateKey(id: string): Promise<RegenerateKeyResponse>;
|
|
47
40
|
/** DELETE /api/bots/{id} (dev-only) — soft delete */
|
|
48
41
|
delete(id: string): Promise<void>;
|
|
49
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BotApi.d.ts","sourceRoot":"","sources":["../../src/http/BotApi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"BotApi.d.ts","sourceRoot":"","sources":["../../src/http/BotApi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;GAOG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU;IAI5B;;;;OAIG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAQjF,kCAAkC;IAClC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpC;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;IAI9D,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAInC,gDAAgD;IAChD,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIrC,qDAAqD;IACrD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
package/dist/http/BotApi.js
CHANGED
|
@@ -4,7 +4,7 @@ import { HttpClient } from './HttpClient.js';
|
|
|
4
4
|
* Bot API client.
|
|
5
5
|
*
|
|
6
6
|
* GET endpoints (list, getById) are public — no JWT required.
|
|
7
|
-
* Management endpoints (create, update, activate, deactivate,
|
|
7
|
+
* Management endpoints (create, update, activate, deactivate, delete)
|
|
8
8
|
* require JWT with claim role=dev (obtained via loginWithDev).
|
|
9
9
|
* Non-dev users receive 404 Not Found on management endpoints.
|
|
10
10
|
*/
|
|
@@ -14,7 +14,7 @@ export class BotApi {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* GET /api/bots?page={page}&pageSize={pageSize}
|
|
17
|
-
* List all bots (public
|
|
17
|
+
* List all bots (public).
|
|
18
18
|
* page is 1-based.
|
|
19
19
|
*/
|
|
20
20
|
list(params) {
|
|
@@ -26,13 +26,13 @@ export class BotApi {
|
|
|
26
26
|
const q = qs.toString();
|
|
27
27
|
return this.http.get(`/api/bots${q ? `?${q}` : ''}`);
|
|
28
28
|
}
|
|
29
|
-
/** GET /api/bots/{id} (public
|
|
29
|
+
/** GET /api/bots/{id} (public) */
|
|
30
30
|
getById(id) {
|
|
31
31
|
return this.http.get(`/api/bots/${encodeURIComponent(id)}`);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* POST /api/bots (dev-only)
|
|
35
|
-
* Register a new bot.
|
|
35
|
+
* Register a new bot.
|
|
36
36
|
*/
|
|
37
37
|
create(request) {
|
|
38
38
|
return this.http.post('/api/bots', request);
|
|
@@ -52,13 +52,6 @@ export class BotApi {
|
|
|
52
52
|
deactivate(id) {
|
|
53
53
|
return this.http.post(`/api/bots/${encodeURIComponent(id)}/deactivate`);
|
|
54
54
|
}
|
|
55
|
-
/**
|
|
56
|
-
* POST /api/bots/{id}/regenerate-key (dev-only)
|
|
57
|
-
* Rotate the bot API key. Previous key is immediately invalidated.
|
|
58
|
-
*/
|
|
59
|
-
regenerateKey(id) {
|
|
60
|
-
return this.http.post(`/api/bots/${encodeURIComponent(id)}/regenerate-key`);
|
|
61
|
-
}
|
|
62
55
|
/** DELETE /api/bots/{id} (dev-only) — soft delete */
|
|
63
56
|
delete(id) {
|
|
64
57
|
return this.http.delete(`/api/bots/${encodeURIComponent(id)}`);
|
package/dist/http/BotApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BotApi.js","sourceRoot":"","sources":["../../src/http/BotApi.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C;;;;;;;GAOG;AACH,MAAM,OAAO,MAAM;IAGjB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,MAA6C;QAChD,MAAM,EAAE,GAAG,IAAI,eAAe,EAAE,CAAC;QACjC,IAAI,MAAM,EAAE,IAAI,KAAK,SAAS;YAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACpE,IAAI,MAAM,EAAE,QAAQ,KAAK,SAAS;YAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChF,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAsB,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"BotApi.js","sourceRoot":"","sources":["../../src/http/BotApi.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C;;;;;;;GAOG;AACH,MAAM,OAAO,MAAM;IAGjB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,MAA6C;QAChD,MAAM,EAAE,GAAG,IAAI,eAAe,EAAE,CAAC;QACjC,IAAI,MAAM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,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAO,aAAa,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HttpClient } from './HttpClient.js';
|
|
2
|
-
import type { ConversationDto, ConversationListItemDto, ConversationParticipantDto, CreateConversationRequest, UpdateConversationRequest, AddParticipantRequest } from '../types/conversation.js';
|
|
2
|
+
import type { ConversationDto, ConversationListItemDto, ConversationMediaItemDto, ConversationMediaKindFilter, ConversationParticipantDto, CreateConversationRequest, UpdateConversationRequest, AddParticipantRequest } from '../types/conversation.js';
|
|
3
3
|
import type { CursorPaginatedResult } from '../types/common.js';
|
|
4
|
+
import type { MarkAsReadRequest } from '../types/message.js';
|
|
4
5
|
/**
|
|
5
6
|
* Conversation API client.
|
|
6
7
|
* All endpoints require JWT Bearer token.
|
|
@@ -39,13 +40,28 @@ export declare class ConversationApi {
|
|
|
39
40
|
update(id: string, request: UpdateConversationRequest): Promise<ConversationDto>;
|
|
40
41
|
/**
|
|
41
42
|
* DELETE /api/conversations/{id}
|
|
42
|
-
*
|
|
43
|
+
* Behavior depends on conversation type:
|
|
44
|
+
* - Group → leave (same as POST .../leave). Other participants remain.
|
|
45
|
+
* - OneToOne / Self → hide the conversation from this user's list (soft-delete, not a true delete).
|
|
43
46
|
*/
|
|
44
|
-
|
|
47
|
+
delete(id: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* POST /api/conversations/{id}/leave
|
|
50
|
+
* Leave a Group conversation explicitly (Group only).
|
|
51
|
+
* Returns 403 Forbidden if the conversation is not a Group.
|
|
52
|
+
*
|
|
53
|
+
* NOTE: `delete()` (DELETE) also performs the leave action for Group conversations and
|
|
54
|
+
* additionally hides OneToOne/Self conversations. Use this method when you need the
|
|
55
|
+
* strict Group-only semantic with explicit 403 feedback for non-Group conversations.
|
|
56
|
+
*/
|
|
57
|
+
leaveGroup(id: string): Promise<void>;
|
|
45
58
|
/**
|
|
46
59
|
* GET /api/conversations/one-to-one/{otherParticipantId}
|
|
47
60
|
* Find an existing OneToOne conversation with another participant.
|
|
48
|
-
*
|
|
61
|
+
*
|
|
62
|
+
* Server returns 404 Not Found when no such conversation exists; the SDK
|
|
63
|
+
* catches that case and resolves to `null` so callers can treat "not found"
|
|
64
|
+
* as a normal value instead of an exception. All other errors are rethrown.
|
|
49
65
|
*/
|
|
50
66
|
findOneToOne(otherParticipantId: string): Promise<ConversationDto | null>;
|
|
51
67
|
/**
|
|
@@ -72,11 +88,28 @@ export declare class ConversationApi {
|
|
|
72
88
|
* POST /api/conversations/{id}/read
|
|
73
89
|
* Mark a conversation as read up to the given messageId.
|
|
74
90
|
*/
|
|
75
|
-
markAsRead(id: string,
|
|
91
|
+
markAsRead(id: string, request: MarkAsReadRequest): Promise<void>;
|
|
76
92
|
/**
|
|
77
93
|
* DELETE /api/conversations/{id}/read
|
|
78
94
|
* Mark the conversation as unread (user-initiated).
|
|
79
95
|
*/
|
|
80
96
|
markAsUnread(id: string): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* GET /api/conversations/{id}/media?kind={kind}&limit={limit}&cursor={cursor}
|
|
99
|
+
*
|
|
100
|
+
* List every media/link item that has appeared in the conversation, newest first.
|
|
101
|
+
*
|
|
102
|
+
* - `kind` — `all` (default), `attachment`, or `link` (case-insensitive on the wire).
|
|
103
|
+
* - `limit` — 1..100, default 50.
|
|
104
|
+
* - `cursor` — opaque `nextCursor` from a prior page.
|
|
105
|
+
*
|
|
106
|
+
* Participants only see items from messages created after they joined the
|
|
107
|
+
* conversation. Returns 403 if the caller is not a participant.
|
|
108
|
+
*/
|
|
109
|
+
getMedia(conversationId: string, params?: {
|
|
110
|
+
kind?: ConversationMediaKindFilter;
|
|
111
|
+
limit?: number;
|
|
112
|
+
cursor?: string;
|
|
113
|
+
}): Promise<CursorPaginatedResult<ConversationMediaItemDto>>;
|
|
81
114
|
}
|
|
82
115
|
//# sourceMappingURL=ConversationApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationApi.d.ts","sourceRoot":"","sources":["../../src/http/ConversationApi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConversationApi.d.ts","sourceRoot":"","sources":["../../src/http/ConversationApi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,2BAA2B,EAC3B,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE7D;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;OAUG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE;QACZ,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,qBAAqB,CAAC,uBAAuB,CAAC,CAAC;IAU3D,8BAA8B;IAC9B,MAAM,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,eAAe,CAAC;IAIpE;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,EAAE,CAAC;IAMzE,kCAAkC;IAClC,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAI7C;;;OAGG;IACH,MAAM,CAAC,EAAE,EA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