@manonero/chat-client-sdk 1.0.0-beta.0

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.
Files changed (110) hide show
  1. package/README.md +2343 -0
  2. package/dist/ChatClient.d.ts +122 -0
  3. package/dist/ChatClient.d.ts.map +1 -0
  4. package/dist/ChatClient.js +173 -0
  5. package/dist/ChatClient.js.map +1 -0
  6. package/dist/errors/ChatApiError.d.ts +22 -0
  7. package/dist/errors/ChatApiError.d.ts.map +1 -0
  8. package/dist/errors/ChatApiError.js +50 -0
  9. package/dist/errors/ChatApiError.js.map +1 -0
  10. package/dist/http/AuthApi.d.ts +26 -0
  11. package/dist/http/AuthApi.d.ts.map +1 -0
  12. package/dist/http/AuthApi.js +35 -0
  13. package/dist/http/AuthApi.js.map +1 -0
  14. package/dist/http/BotApi.d.ts +50 -0
  15. package/dist/http/BotApi.d.ts.map +1 -0
  16. package/dist/http/BotApi.js +67 -0
  17. package/dist/http/BotApi.js.map +1 -0
  18. package/dist/http/ConversationApi.d.ts +81 -0
  19. package/dist/http/ConversationApi.d.ts.map +1 -0
  20. package/dist/http/ConversationApi.js +115 -0
  21. package/dist/http/ConversationApi.js.map +1 -0
  22. package/dist/http/FileApi.d.ts +48 -0
  23. package/dist/http/FileApi.d.ts.map +1 -0
  24. package/dist/http/FileApi.js +68 -0
  25. package/dist/http/FileApi.js.map +1 -0
  26. package/dist/http/HealthApi.d.ts +26 -0
  27. package/dist/http/HealthApi.d.ts.map +1 -0
  28. package/dist/http/HealthApi.js +31 -0
  29. package/dist/http/HealthApi.js.map +1 -0
  30. package/dist/http/HttpClient.d.ts +51 -0
  31. package/dist/http/HttpClient.d.ts.map +1 -0
  32. package/dist/http/HttpClient.js +182 -0
  33. package/dist/http/HttpClient.js.map +1 -0
  34. package/dist/http/MessageApi.d.ts +67 -0
  35. package/dist/http/MessageApi.d.ts.map +1 -0
  36. package/dist/http/MessageApi.js +91 -0
  37. package/dist/http/MessageApi.js.map +1 -0
  38. package/dist/http/ParticipantApi.d.ts +28 -0
  39. package/dist/http/ParticipantApi.d.ts.map +1 -0
  40. package/dist/http/ParticipantApi.js +37 -0
  41. package/dist/http/ParticipantApi.js.map +1 -0
  42. package/dist/http/ProxyApi.d.ts +41 -0
  43. package/dist/http/ProxyApi.d.ts.map +1 -0
  44. package/dist/http/ProxyApi.js +57 -0
  45. package/dist/http/ProxyApi.js.map +1 -0
  46. package/dist/index.d.ts +26 -0
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +18 -0
  49. package/dist/index.js.map +1 -0
  50. package/dist/realtime/ChatHubClient.d.ts +87 -0
  51. package/dist/realtime/ChatHubClient.d.ts.map +1 -0
  52. package/dist/realtime/ChatHubClient.js +182 -0
  53. package/dist/realtime/ChatHubClient.js.map +1 -0
  54. package/dist/realtime/NotificationHubClient.d.ts +73 -0
  55. package/dist/realtime/NotificationHubClient.d.ts.map +1 -0
  56. package/dist/realtime/NotificationHubClient.js +162 -0
  57. package/dist/realtime/NotificationHubClient.js.map +1 -0
  58. package/dist/realtime/ReconnectionManager.d.ts +65 -0
  59. package/dist/realtime/ReconnectionManager.d.ts.map +1 -0
  60. package/dist/realtime/ReconnectionManager.js +118 -0
  61. package/dist/realtime/ReconnectionManager.js.map +1 -0
  62. package/dist/types/auth.d.ts +28 -0
  63. package/dist/types/auth.d.ts.map +1 -0
  64. package/dist/types/auth.js +3 -0
  65. package/dist/types/auth.js.map +1 -0
  66. package/dist/types/block.d.ts +148 -0
  67. package/dist/types/block.d.ts.map +1 -0
  68. package/dist/types/block.js +47 -0
  69. package/dist/types/block.js.map +1 -0
  70. package/dist/types/bot.d.ts +48 -0
  71. package/dist/types/bot.d.ts.map +1 -0
  72. package/dist/types/bot.js +3 -0
  73. package/dist/types/bot.js.map +1 -0
  74. package/dist/types/chat-events.d.ts +153 -0
  75. package/dist/types/chat-events.d.ts.map +1 -0
  76. package/dist/types/chat-events.js +3 -0
  77. package/dist/types/chat-events.js.map +1 -0
  78. package/dist/types/common.d.ts +57 -0
  79. package/dist/types/common.d.ts.map +1 -0
  80. package/dist/types/common.js +3 -0
  81. package/dist/types/common.js.map +1 -0
  82. package/dist/types/conversation.d.ts +70 -0
  83. package/dist/types/conversation.d.ts.map +1 -0
  84. package/dist/types/conversation.js +3 -0
  85. package/dist/types/conversation.js.map +1 -0
  86. package/dist/types/file.d.ts +31 -0
  87. package/dist/types/file.d.ts.map +1 -0
  88. package/dist/types/file.js +3 -0
  89. package/dist/types/file.js.map +1 -0
  90. package/dist/types/message.d.ts +83 -0
  91. package/dist/types/message.d.ts.map +1 -0
  92. package/dist/types/message.js +3 -0
  93. package/dist/types/message.js.map +1 -0
  94. package/dist/types/notification-events.d.ts +97 -0
  95. package/dist/types/notification-events.d.ts.map +1 -0
  96. package/dist/types/notification-events.js +3 -0
  97. package/dist/types/notification-events.js.map +1 -0
  98. package/dist/types/participant.d.ts +25 -0
  99. package/dist/types/participant.d.ts.map +1 -0
  100. package/dist/types/participant.js +3 -0
  101. package/dist/types/participant.js.map +1 -0
  102. package/dist/types/signalr.d.ts +87 -0
  103. package/dist/types/signalr.d.ts.map +1 -0
  104. package/dist/types/signalr.js +3 -0
  105. package/dist/types/signalr.js.map +1 -0
  106. package/dist/utils/TypedEventEmitter.d.ts +32 -0
  107. package/dist/utils/TypedEventEmitter.d.ts.map +1 -0
  108. package/dist/utils/TypedEventEmitter.js +60 -0
  109. package/dist/utils/TypedEventEmitter.js.map +1 -0
  110. package/package.json +40 -0
@@ -0,0 +1,122 @@
1
+ import { LogLevel } from '@microsoft/signalr';
2
+ import { AuthApi } from './http/AuthApi.js';
3
+ import { ParticipantApi } from './http/ParticipantApi.js';
4
+ import { ConversationApi } from './http/ConversationApi.js';
5
+ import { MessageApi } from './http/MessageApi.js';
6
+ import { FileApi } from './http/FileApi.js';
7
+ import { BotApi } from './http/BotApi.js';
8
+ import { ProxyApi } from './http/ProxyApi.js';
9
+ import { HealthApi } from './http/HealthApi.js';
10
+ import { ChatHubClient } from './realtime/ChatHubClient.js';
11
+ import { NotificationHubClient } from './realtime/NotificationHubClient.js';
12
+ import type { AuthUserInfo } from './types/auth.js';
13
+ export interface ChatClientSignalrOptions {
14
+ /** Minimum log level for SignalR internal logging (default: Warning) */
15
+ logLevel?: LogLevel;
16
+ }
17
+ export interface ChatClientOptions {
18
+ /** Base URL of the API server, e.g. "https://chat-api.example.com" */
19
+ baseUrl: string;
20
+ /**
21
+ * Initial JWT token (if already authenticated).
22
+ * Can be updated later via setToken().
23
+ */
24
+ token?: string;
25
+ /**
26
+ * Optional external token provider function.
27
+ * When both `token` and `tokenProvider` are provided, the internal `_token`
28
+ * (set via constructor or setToken()) takes priority over the external provider.
29
+ */
30
+ tokenProvider?: () => string | null;
31
+ /** Options for SignalR hub connections */
32
+ signalrOptions?: ChatClientSignalrOptions;
33
+ }
34
+ export interface ChatClientRealtime {
35
+ /** ChatHub real-time client for conversation-level events */
36
+ readonly chat: ChatHubClient;
37
+ /** NotificationHub real-time client for user-level notifications */
38
+ readonly notifications: NotificationHubClient;
39
+ }
40
+ /**
41
+ * Main SDK facade.
42
+ *
43
+ * Integrates all HTTP API modules and SignalR hub clients into a single
44
+ * ergonomic entry point. Manages a shared JWT token that is automatically
45
+ * propagated to all HTTP requests and new SignalR connections.
46
+ *
47
+ * Usage:
48
+ * ```ts
49
+ * const client = new ChatClient({ baseUrl: 'https://chat-api.example.com' });
50
+ *
51
+ * const auth = await client.auth.loginWithGoogle(idToken);
52
+ * // token and currentUser are automatically set after login
53
+ *
54
+ * await client.realtime.notifications.connect();
55
+ * await client.realtime.chat.connect();
56
+ *
57
+ * client.realtime.chat.on('messageReceived', (msg) => console.log(msg));
58
+ * await client.realtime.chat.joinConversation('conv-id');
59
+ *
60
+ * await client.disconnect(); // Disconnect all hubs
61
+ * ```
62
+ *
63
+ * Note on token propagation for SignalR:
64
+ * Calling setToken() updates HTTP requests immediately, but active SignalR
65
+ * connections must be reconnected (disconnect() → connect()) for the new
66
+ * token to take effect.
67
+ */
68
+ export declare class ChatClient {
69
+ /**
70
+ * The current JWT token held by the SDK.
71
+ * Overrides any external tokenProvider when non-null.
72
+ */
73
+ private _token;
74
+ /**
75
+ * Combined internal token provider. Returns _token if set, otherwise falls
76
+ * back to any externally supplied tokenProvider, otherwise null.
77
+ */
78
+ private readonly _internalTokenProvider;
79
+ /** Authentication endpoints */
80
+ readonly auth: AuthApi;
81
+ /** Participant management */
82
+ readonly participants: ParticipantApi;
83
+ /** Conversation management */
84
+ readonly conversations: ConversationApi;
85
+ /** Message operations */
86
+ readonly messages: MessageApi;
87
+ /** File upload / download */
88
+ readonly files: FileApi;
89
+ /** Bot management */
90
+ readonly bots: BotApi;
91
+ /** Dynamic backend proxy */
92
+ readonly proxy: ProxyApi;
93
+ /** Health check endpoints */
94
+ readonly health: HealthApi;
95
+ /** SignalR hub clients */
96
+ readonly realtime: ChatClientRealtime;
97
+ private _currentUser;
98
+ /** The authenticated user populated automatically after a successful login. */
99
+ get currentUser(): AuthUserInfo | null;
100
+ constructor(options: ChatClientOptions);
101
+ /**
102
+ * Update the JWT token.
103
+ *
104
+ * The new token takes effect immediately for all subsequent HTTP requests.
105
+ * Active SignalR connections are NOT updated — they must be reconnected
106
+ * (disconnect() then connect()) for the new token to be used.
107
+ */
108
+ setToken(token: string): void;
109
+ /**
110
+ * Disconnect all SignalR hubs (ChatHub + NotificationHub).
111
+ *
112
+ * Resolves after both hubs have finished disconnecting. Individual hub
113
+ * disconnect failures do not prevent the other hub from disconnecting.
114
+ */
115
+ disconnect(): Promise<void>;
116
+ /**
117
+ * Called automatically after every successful login.
118
+ * Sets the token and populates currentUser from the auth response.
119
+ */
120
+ private _onLoginSuccess;
121
+ }
122
+ //# sourceMappingURL=ChatClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatClient.d.ts","sourceRoot":"","sources":["../src/ChatClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB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AAsB,CAAsB;IAM7D,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAEvB,6BAA6B;IAC7B,QAAQ,CAAC,YAAY,EAAE,cAAc,CAAC;IAEtC,8BAA8B;IAC9B,QAAQ,CAAC,aAAa,EAAE,eAAe,CAAC;IAExC,yBAAyB;IACzB,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAE9B,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAExB,qBAAqB;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,4BAA4B;IAC5B,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC;IAEzB,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAM3B,0BAA0B;IAC1B,QAAQ,CAAC,QAAQ,EAAE,kBAAkB,CAAC;IAMtC,OAAO,CAAC,YAAY,CAA6B;IAEjD,+EAA+E;IAC/E,IAAI,WAAW,IAAI,YAAY,GAAG,IAAI,CAErC;gBAMW,OAAO,EAAE,iBAAiB;IAuDtC;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAI7B;;;;;OAKG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAWjC;;;OAGG;IACH,OAAO,CAAC,eAAe;CAIxB"}
@@ -0,0 +1,173 @@
1
+ // ChatClient.ts — Main SDK facade
2
+ import { LogLevel } from '@microsoft/signalr';
3
+ import { HttpClient } from './http/HttpClient.js';
4
+ import { AuthApi } from './http/AuthApi.js';
5
+ import { ParticipantApi } from './http/ParticipantApi.js';
6
+ import { ConversationApi } from './http/ConversationApi.js';
7
+ import { MessageApi } from './http/MessageApi.js';
8
+ import { FileApi } from './http/FileApi.js';
9
+ import { BotApi } from './http/BotApi.js';
10
+ import { ProxyApi } from './http/ProxyApi.js';
11
+ import { HealthApi } from './http/HealthApi.js';
12
+ import { ChatHubClient } from './realtime/ChatHubClient.js';
13
+ import { NotificationHubClient } from './realtime/NotificationHubClient.js';
14
+ // ---------------------------------------------------------------------------
15
+ // AuthApi subclass that auto-sets token + currentUser on login success
16
+ // ---------------------------------------------------------------------------
17
+ /**
18
+ * Internal subclass of AuthApi.
19
+ * Overrides each login method to call onSuccess with the AuthResponse,
20
+ * allowing ChatClient to update its token and currentUser automatically.
21
+ */
22
+ class InterceptingAuthApi extends AuthApi {
23
+ constructor(http, onSuccess) {
24
+ super(http);
25
+ this._onSuccess = onSuccess;
26
+ }
27
+ login(provider, body) {
28
+ return super.login(provider, body).then((res) => {
29
+ this._onSuccess(res);
30
+ return res;
31
+ });
32
+ }
33
+ loginWithGoogle(idToken) {
34
+ return super.loginWithGoogle(idToken).then((res) => {
35
+ this._onSuccess(res);
36
+ return res;
37
+ });
38
+ }
39
+ loginWithDsAccount(token) {
40
+ return super.loginWithDsAccount(token).then((res) => {
41
+ this._onSuccess(res);
42
+ return res;
43
+ });
44
+ }
45
+ loginWithDev(username, password) {
46
+ return super.loginWithDev(username, password).then((res) => {
47
+ this._onSuccess(res);
48
+ return res;
49
+ });
50
+ }
51
+ }
52
+ // ---------------------------------------------------------------------------
53
+ // ChatClient
54
+ // ---------------------------------------------------------------------------
55
+ /**
56
+ * Main SDK facade.
57
+ *
58
+ * Integrates all HTTP API modules and SignalR hub clients into a single
59
+ * ergonomic entry point. Manages a shared JWT token that is automatically
60
+ * propagated to all HTTP requests and new SignalR connections.
61
+ *
62
+ * Usage:
63
+ * ```ts
64
+ * const client = new ChatClient({ baseUrl: 'https://chat-api.example.com' });
65
+ *
66
+ * const auth = await client.auth.loginWithGoogle(idToken);
67
+ * // token and currentUser are automatically set after login
68
+ *
69
+ * await client.realtime.notifications.connect();
70
+ * await client.realtime.chat.connect();
71
+ *
72
+ * client.realtime.chat.on('messageReceived', (msg) => console.log(msg));
73
+ * await client.realtime.chat.joinConversation('conv-id');
74
+ *
75
+ * await client.disconnect(); // Disconnect all hubs
76
+ * ```
77
+ *
78
+ * Note on token propagation for SignalR:
79
+ * Calling setToken() updates HTTP requests immediately, but active SignalR
80
+ * connections must be reconnected (disconnect() → connect()) for the new
81
+ * token to take effect.
82
+ */
83
+ export class ChatClient {
84
+ /** The authenticated user populated automatically after a successful login. */
85
+ get currentUser() {
86
+ return this._currentUser;
87
+ }
88
+ // ---------------------------------------------------------------------------
89
+ // Constructor
90
+ // ---------------------------------------------------------------------------
91
+ constructor(options) {
92
+ // ---------------------------------------------------------------------------
93
+ // State
94
+ // ---------------------------------------------------------------------------
95
+ this._currentUser = null;
96
+ this._token = options.token ?? null;
97
+ // Build the combined token provider:
98
+ // 1. Return _token if it has been set (via constructor or setToken()).
99
+ // 2. Fall back to the external tokenProvider if provided.
100
+ // 3. Return null otherwise.
101
+ const externalProvider = options.tokenProvider;
102
+ this._internalTokenProvider = () => this._token ?? (externalProvider ? externalProvider() : null);
103
+ // Shared HTTP client used by all REST API modules
104
+ const http = new HttpClient({
105
+ baseUrl: options.baseUrl,
106
+ tokenProvider: this._internalTokenProvider,
107
+ });
108
+ // Instantiate REST API modules
109
+ this.participants = new ParticipantApi(http);
110
+ this.conversations = new ConversationApi(http);
111
+ this.messages = new MessageApi(http);
112
+ this.files = new FileApi(http);
113
+ this.bots = new BotApi(http);
114
+ this.proxy = new ProxyApi(http);
115
+ this.health = new HealthApi(http);
116
+ // AuthApi is wrapped in InterceptingAuthApi to auto-set token + currentUser
117
+ this.auth = new InterceptingAuthApi(http, (res) => this._onLoginSuccess(res));
118
+ // Build SignalR hub URLs from baseUrl (strip trailing slash already done by HttpClient)
119
+ const baseUrl = http.baseUrl; // already has trailing slash stripped
120
+ const { logLevel } = options.signalrOptions ?? {};
121
+ const chatHubOptions = {
122
+ hubUrl: `${baseUrl}/hubs/chat`,
123
+ tokenProvider: this._internalTokenProvider,
124
+ ...(logLevel !== undefined ? { logLevel } : {}),
125
+ };
126
+ const notificationHubOptions = {
127
+ hubUrl: `${baseUrl}/hubs/notifications`,
128
+ tokenProvider: this._internalTokenProvider,
129
+ ...(logLevel !== undefined ? { logLevel } : {}),
130
+ };
131
+ this.realtime = {
132
+ chat: new ChatHubClient(chatHubOptions),
133
+ notifications: new NotificationHubClient(notificationHubOptions),
134
+ };
135
+ }
136
+ // ---------------------------------------------------------------------------
137
+ // Public methods
138
+ // ---------------------------------------------------------------------------
139
+ /**
140
+ * Update the JWT token.
141
+ *
142
+ * The new token takes effect immediately for all subsequent HTTP requests.
143
+ * Active SignalR connections are NOT updated — they must be reconnected
144
+ * (disconnect() then connect()) for the new token to be used.
145
+ */
146
+ setToken(token) {
147
+ this._token = token;
148
+ }
149
+ /**
150
+ * Disconnect all SignalR hubs (ChatHub + NotificationHub).
151
+ *
152
+ * Resolves after both hubs have finished disconnecting. Individual hub
153
+ * disconnect failures do not prevent the other hub from disconnecting.
154
+ */
155
+ async disconnect() {
156
+ await Promise.allSettled([
157
+ this.realtime.chat.disconnect(),
158
+ this.realtime.notifications.disconnect(),
159
+ ]);
160
+ }
161
+ // ---------------------------------------------------------------------------
162
+ // Private helpers
163
+ // ---------------------------------------------------------------------------
164
+ /**
165
+ * Called automatically after every successful login.
166
+ * Sets the token and populates currentUser from the auth response.
167
+ */
168
+ _onLoginSuccess(response) {
169
+ this._token = response.token;
170
+ this._currentUser = response.user;
171
+ }
172
+ }
173
+ //# sourceMappingURL=ChatClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatClient.js","sourceRoot":"","sources":["../src/ChatClient.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,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,EA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;SACjE,CAAC;IACJ,CAAC;IAED,8EAA8E;IAC9E,iBAAiB;IACjB,8EAA8E;IAE9E;;;;;;OAMG;IACH,QAAQ,CAAC,KAAa;QACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,OAAO,CAAC,UAAU,CAAC;YACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE;YAC/B,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,EAAE;SACzC,CAAC,CAAC;IACL,CAAC;IAED,8EAA8E;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"}
@@ -0,0 +1,22 @@
1
+ import type { ProblemDetails } from '../types/common.js';
2
+ /**
3
+ * Custom error thrown for all HTTP API failures.
4
+ *
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 } — /api/proxy/* endpoints
8
+ */
9
+ export declare class ChatApiError extends Error {
10
+ readonly status: number;
11
+ readonly title: string;
12
+ readonly detail: string | undefined;
13
+ constructor(status: number, title: string, detail?: string);
14
+ /**
15
+ * Parse a ChatApiError from a failed HTTP response.
16
+ * Tries to parse the body as JSON; falls back to status text.
17
+ */
18
+ static fromResponse(response: Response): Promise<ChatApiError>;
19
+ /** Convenience: create from a ProblemDetails object directly */
20
+ static fromProblemDetails(pd: ProblemDetails): ChatApiError;
21
+ }
22
+ //# sourceMappingURL=ChatApiError.d.ts.map
@@ -0,0 +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;AAEzD;;;;;;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;gBAExB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAU1D;;;OAGG;WACU,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IA8BpE,gEAAgE;IAChE,MAAM,CAAC,kBAAkB,CAAC,EAAE,EAAE,cAAc,GAAG,YAAY;CAG5D"}
@@ -0,0 +1,50 @@
1
+ // ChatApiError.ts — Custom error class (RFC 7807 compatible)
2
+ /**
3
+ * Custom error thrown for all HTTP API failures.
4
+ *
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 } — /api/proxy/* endpoints
8
+ */
9
+ export class ChatApiError extends Error {
10
+ constructor(status, title, detail) {
11
+ super(detail ?? title);
12
+ this.name = 'ChatApiError';
13
+ this.status = status;
14
+ this.title = title;
15
+ this.detail = detail;
16
+ // Maintain proper prototype chain for instanceof checks
17
+ Object.setPrototypeOf(this, ChatApiError.prototype);
18
+ }
19
+ /**
20
+ * Parse a ChatApiError from a failed HTTP response.
21
+ * Tries to parse the body as JSON; falls back to status text.
22
+ */
23
+ static async fromResponse(response) {
24
+ let body;
25
+ try {
26
+ body = await response.json();
27
+ }
28
+ catch {
29
+ // Body is not JSON (e.g. plain text or empty)
30
+ return new ChatApiError(response.status, response.statusText);
31
+ }
32
+ if (body !== null && typeof body === 'object') {
33
+ const obj = body;
34
+ // RFC 7807 full format: { status, title, detail }
35
+ if (typeof obj['title'] === 'string') {
36
+ return new ChatApiError(typeof obj['status'] === 'number' ? obj['status'] : response.status, obj['title'], typeof obj['detail'] === 'string' ? obj['detail'] : undefined);
37
+ }
38
+ // Proxy error simple format: { detail }
39
+ if (typeof obj['detail'] === 'string') {
40
+ return new ChatApiError(response.status, 'Proxy Error', obj['detail']);
41
+ }
42
+ }
43
+ return new ChatApiError(response.status, response.statusText);
44
+ }
45
+ /** Convenience: create from a ProblemDetails object directly */
46
+ static fromProblemDetails(pd) {
47
+ return new ChatApiError(pd.status, pd.title, pd.detail);
48
+ }
49
+ }
50
+ //# sourceMappingURL=ChatApiError.js.map
@@ -0,0 +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;IAKrC,YAAY,MAAc,EAAE,KAAa,EAAE,MAAe;QACxD,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,wDAAwD;QACxD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,QAAkB;QAC1C,IAAI,IAAa,CAAC;QAClB,IAAI,CAAC;YACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,8CAA8C;YAC9C,OAAO,IAAI,YAAY,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,GAAG,GAAG,IAA+B,CAAC;YAE5C,kDAAkD;YAClD,IAAI,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACrC,OAAO,IAAI,YAAY,CACrB,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,EACnE,GAAG,CAAC,OAAO,CAAC,EACZ,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAC9D,CAAC;YACJ,CAAC;YAED,wCAAwC;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,CAAC,CAAC;IAC1D,CAAC;CACF"}
@@ -0,0 +1,26 @@
1
+ import { HttpClient } from './HttpClient.js';
2
+ import type { AuthResponse, LoginRequest } from '../types/auth.js';
3
+ /**
4
+ * Auth API client.
5
+ * All endpoints are public (no JWT required).
6
+ */
7
+ export declare class AuthApi {
8
+ private readonly http;
9
+ constructor(http: HttpClient);
10
+ /**
11
+ * Generic login — POST /api/auth/{provider}
12
+ * Use this when you need a runtime-determined provider name.
13
+ */
14
+ login(provider: string, body: LoginRequest): Promise<AuthResponse>;
15
+ /** POST /api/auth/google */
16
+ loginWithGoogle(idToken: string): Promise<AuthResponse>;
17
+ /** POST /api/auth/dsaccount */
18
+ loginWithDsAccount(token: string): Promise<AuthResponse>;
19
+ /**
20
+ * POST /api/auth/dev
21
+ * Only available in development environments.
22
+ * Grants role=dev in JWT, unlocking bot management endpoints.
23
+ */
24
+ loginWithDev(username: string, password: string): Promise<AuthResponse>;
25
+ }
26
+ //# sourceMappingURL=AuthApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthApi.d.ts","sourceRoot":"","sources":["../../src/http/AuthApi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;;GAGG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,IAAI,EAAE,UAAU;IAI5B;;;OAGG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IAIlE,4BAA4B;IAC5B,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAIvD,+BAA+B;IAC/B,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAIxD;;;;OAIG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAGxE"}
@@ -0,0 +1,35 @@
1
+ // AuthApi.ts — Authentication endpoints
2
+ import { HttpClient } from './HttpClient.js';
3
+ /**
4
+ * Auth API client.
5
+ * All endpoints are public (no JWT required).
6
+ */
7
+ export class AuthApi {
8
+ constructor(http) {
9
+ this.http = http;
10
+ }
11
+ /**
12
+ * Generic login — POST /api/auth/{provider}
13
+ * Use this when you need a runtime-determined provider name.
14
+ */
15
+ login(provider, body) {
16
+ return this.http.post(`/api/auth/${encodeURIComponent(provider)}`, body);
17
+ }
18
+ /** POST /api/auth/google */
19
+ loginWithGoogle(idToken) {
20
+ return this.http.post('/api/auth/google', { idToken });
21
+ }
22
+ /** POST /api/auth/dsaccount */
23
+ loginWithDsAccount(token) {
24
+ return this.http.post('/api/auth/dsaccount', { token });
25
+ }
26
+ /**
27
+ * POST /api/auth/dev
28
+ * Only available in development environments.
29
+ * Grants role=dev in JWT, unlocking bot management endpoints.
30
+ */
31
+ loginWithDev(username, password) {
32
+ return this.http.post('/api/auth/dev', { username, password });
33
+ }
34
+ }
35
+ //# sourceMappingURL=AuthApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthApi.js","sourceRoot":"","sources":["../../src/http/AuthApi.ts"],"names":[],"mappings":"AAAA,wCAAwC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C;;;GAGG;AACH,MAAM,OAAO,OAAO;IAGlB,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAgB,EAAE,IAAkB;QACxC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAe,aAAa,kBAAkB,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACzF,CAAC;IAED,4BAA4B;IAC5B,eAAe,CAAC,OAAe;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAe,kBAAkB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,+BAA+B;IAC/B,kBAAkB,CAAC,KAAa;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAe,qBAAqB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IACxE,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,QAAgB,EAAE,QAAgB;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAe,eAAe,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC/E,CAAC;CACF"}
@@ -0,0 +1,50 @@
1
+ import { HttpClient } from './HttpClient.js';
2
+ import type { BotDto, CreateBotRequest, UpdateBotRequest, RegenerateKeyResponse } from '../types/bot.js';
3
+ import type { PagedResult } from '../types/common.js';
4
+ /**
5
+ * Bot API client.
6
+ *
7
+ * GET endpoints (list, getById) are public — no JWT required.
8
+ * Management endpoints (create, update, activate, deactivate, regenerateKey, delete)
9
+ * require JWT with claim role=dev (obtained via loginWithDev).
10
+ * Non-dev users receive 404 Not Found on management endpoints.
11
+ */
12
+ export declare class BotApi {
13
+ private readonly http;
14
+ constructor(http: HttpClient);
15
+ /**
16
+ * GET /api/bots?page={page}&pageSize={pageSize}
17
+ * List all bots (public, cached 5 minutes server-side).
18
+ * page is 1-based.
19
+ */
20
+ list(params?: {
21
+ page?: number;
22
+ pageSize?: number;
23
+ }): Promise<PagedResult<BotDto>>;
24
+ /** GET /api/bots/{id} (public, cached 5 minutes server-side) */
25
+ getById(id: string): Promise<BotDto>;
26
+ /**
27
+ * POST /api/bots (dev-only)
28
+ * Register a new bot. Returns BotDto plus a one-time apiKey — save it immediately.
29
+ */
30
+ create(request: CreateBotRequest): Promise<BotDto & {
31
+ apiKey: string;
32
+ }>;
33
+ /**
34
+ * PATCH /api/bots/{id} (dev-only)
35
+ * Update bot metadata. kafkaTopic cannot be changed after creation.
36
+ */
37
+ update(id: string, request: UpdateBotRequest): Promise<BotDto>;
38
+ /** POST /api/bots/{id}/activate (dev-only) */
39
+ activate(id: string): Promise<void>;
40
+ /** POST /api/bots/{id}/deactivate (dev-only) */
41
+ 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
+ /** DELETE /api/bots/{id} (dev-only) — soft delete */
48
+ delete(id: string): Promise<void>;
49
+ }
50
+ //# sourceMappingURL=BotApi.d.ts.map
@@ -0,0 +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,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACzG,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,gEAAgE;IAChE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIpC;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAIvE;;;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;;;OAGG;IACH,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAMzD,qDAAqD;IACrD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlC"}
@@ -0,0 +1,67 @@
1
+ // BotApi.ts — Bot management endpoints
2
+ import { HttpClient } from './HttpClient.js';
3
+ /**
4
+ * Bot API client.
5
+ *
6
+ * GET endpoints (list, getById) are public — no JWT required.
7
+ * Management endpoints (create, update, activate, deactivate, regenerateKey, delete)
8
+ * require JWT with claim role=dev (obtained via loginWithDev).
9
+ * Non-dev users receive 404 Not Found on management endpoints.
10
+ */
11
+ export class BotApi {
12
+ constructor(http) {
13
+ this.http = http;
14
+ }
15
+ /**
16
+ * GET /api/bots?page={page}&pageSize={pageSize}
17
+ * List all bots (public, cached 5 minutes server-side).
18
+ * page is 1-based.
19
+ */
20
+ list(params) {
21
+ const qs = new URLSearchParams();
22
+ if (params?.page !== undefined)
23
+ qs.set('page', String(params.page));
24
+ if (params?.pageSize !== undefined)
25
+ qs.set('pageSize', String(params.pageSize));
26
+ const q = qs.toString();
27
+ return this.http.get(`/api/bots${q ? `?${q}` : ''}`);
28
+ }
29
+ /** GET /api/bots/{id} (public, cached 5 minutes server-side) */
30
+ getById(id) {
31
+ return this.http.get(`/api/bots/${encodeURIComponent(id)}`);
32
+ }
33
+ /**
34
+ * POST /api/bots (dev-only)
35
+ * Register a new bot. Returns BotDto plus a one-time apiKey — save it immediately.
36
+ */
37
+ create(request) {
38
+ return this.http.post('/api/bots', request);
39
+ }
40
+ /**
41
+ * PATCH /api/bots/{id} (dev-only)
42
+ * Update bot metadata. kafkaTopic cannot be changed after creation.
43
+ */
44
+ update(id, request) {
45
+ return this.http.patch(`/api/bots/${encodeURIComponent(id)}`, request);
46
+ }
47
+ /** POST /api/bots/{id}/activate (dev-only) */
48
+ activate(id) {
49
+ return this.http.post(`/api/bots/${encodeURIComponent(id)}/activate`);
50
+ }
51
+ /** POST /api/bots/{id}/deactivate (dev-only) */
52
+ deactivate(id) {
53
+ return this.http.post(`/api/bots/${encodeURIComponent(id)}/deactivate`);
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
+ /** DELETE /api/bots/{id} (dev-only) — soft delete */
63
+ delete(id) {
64
+ return this.http.delete(`/api/bots/${encodeURIComponent(id)}`);
65
+ }
66
+ }
67
+ //# sourceMappingURL=BotApi.js.map
@@ -0,0 +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,gEAAg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