@holocronlab/botruntime-chat 0.5.5
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/LICENSE +8 -0
- package/README.md +64 -0
- package/dist/client.d.ts +363 -0
- package/dist/consts.d.ts +1 -0
- package/dist/errors.d.ts +20 -0
- package/dist/event-emitter.d.ts +10 -0
- package/dist/eventsource.d.ts +32 -0
- package/dist/gen/client/errors.d.ts +229 -0
- package/dist/gen/client/index.d.ts +77 -0
- package/dist/gen/client/models.d.ts +212 -0
- package/dist/gen/client/operations/addParticipant.d.ts +55 -0
- package/dist/gen/client/operations/createConversation.d.ts +39 -0
- package/dist/gen/client/operations/createEvent.d.ts +55 -0
- package/dist/gen/client/operations/createMessage.d.ts +294 -0
- package/dist/gen/client/operations/createUser.d.ts +66 -0
- package/dist/gen/client/operations/deleteConversation.d.ts +22 -0
- package/dist/gen/client/operations/deleteMessage.d.ts +22 -0
- package/dist/gen/client/operations/deleteUser.d.ts +21 -0
- package/dist/gen/client/operations/getConversation.d.ts +36 -0
- package/dist/gen/client/operations/getEvent.d.ts +46 -0
- package/dist/gen/client/operations/getMessage.d.ts +167 -0
- package/dist/gen/client/operations/getOrCreateConversation.d.ts +39 -0
- package/dist/gen/client/operations/getOrCreateUser.d.ts +62 -0
- package/dist/gen/client/operations/getParticipant.d.ts +52 -0
- package/dist/gen/client/operations/getUser.d.ts +50 -0
- package/dist/gen/client/operations/listConversations.d.ts +42 -0
- package/dist/gen/client/operations/listMessages.d.ts +171 -0
- package/dist/gen/client/operations/listParticipants.d.ts +55 -0
- package/dist/gen/client/operations/listenConversation.d.ts +22 -0
- package/dist/gen/client/operations/removeParticipant.d.ts +23 -0
- package/dist/gen/client/operations/updateUser.d.ts +62 -0
- package/dist/gen/client/to-axios.d.ts +16 -0
- package/dist/gen/signals/eventCreated.j.d.ts +3 -0
- package/dist/gen/signals/eventCreated.t.d.ts +28 -0
- package/dist/gen/signals/eventCreated.z.d.ts +47 -0
- package/dist/gen/signals/index.d.ts +924 -0
- package/dist/gen/signals/messageCreated.j.d.ts +3 -0
- package/dist/gen/signals/messageCreated.t.d.ts +149 -0
- package/dist/gen/signals/messageCreated.z.d.ts +780 -0
- package/dist/gen/signals/messageDeleted.j.d.ts +3 -0
- package/dist/gen/signals/messageDeleted.t.d.ts +8 -0
- package/dist/gen/signals/messageDeleted.z.d.ts +32 -0
- package/dist/gen/signals/participantAdded.j.d.ts +3 -0
- package/dist/gen/signals/participantAdded.t.d.ts +7 -0
- package/dist/gen/signals/participantAdded.z.d.ts +27 -0
- package/dist/gen/signals/participantRemoved.j.d.ts +3 -0
- package/dist/gen/signals/participantRemoved.t.d.ts +7 -0
- package/dist/gen/signals/participantRemoved.z.d.ts +27 -0
- package/dist/index.cjs +1660 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.mjs +138836 -0
- package/dist/index.mjs.map +7 -0
- package/dist/jsonwebtoken.d.ts +3 -0
- package/dist/listing.d.ts +16 -0
- package/dist/signal-listener.d.ts +51 -0
- package/dist/types.d.ts +41 -0
- package/dist/watchdog.d.ts +11 -0
- package/package.json +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright 2023 Botpress Technologies, Inc.
|
|
2
|
+
Portions Copyright (c) 2026 HolocronLab.
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# @holocronlab/botruntime-chat
|
|
2
|
+
|
|
3
|
+
Chat API client consumed by the `brt` CLI to power `brt chat` (an interactive
|
|
4
|
+
terminal chat session against a bot's Chat integration webhook).
|
|
5
|
+
|
|
6
|
+
## Provenance
|
|
7
|
+
|
|
8
|
+
This package vendors the published npm **dist** of `@botpress/chat@0.5.5`
|
|
9
|
+
verbatim (`dist/index.cjs`, `dist/index.mjs`, `dist/index.d.ts`, and the
|
|
10
|
+
generated `.d.ts` files under `dist/gen`). It is a fork of Botpress
|
|
11
|
+
Technologies, Inc.'s MIT-licensed `@botpress/chat` package — see `LICENSE`.
|
|
12
|
+
|
|
13
|
+
The upstream package's *source* is codegenerated from an OpenAPI spec via a
|
|
14
|
+
`chat-api` codegen chain that is not published to npm. Because `@botpress/chat`
|
|
15
|
+
is not the byte-exact oracle crux for this fork (that role belongs to
|
|
16
|
+
`@botpress/client`), vendoring its dist is the deliberate Phase-2 choice here.
|
|
17
|
+
A source-level fork (owning the codegen chain / OpenAPI spec, analogous to
|
|
18
|
+
`@botpress/client`'s ADR-0005 migration) is deferred to that same
|
|
19
|
+
openapi -> owned-source migration effort.
|
|
20
|
+
|
|
21
|
+
No source changes were made to the vendored dist — this package only renames
|
|
22
|
+
the npm package identity (`name`, `repository`) so it can be published
|
|
23
|
+
independently under the `@holocronlab` scope. The runtime behavior, wire
|
|
24
|
+
contract (HTTP paths, headers), and public API surface are unchanged from
|
|
25
|
+
`@botpress/chat@0.5.5`.
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @holocronlab/botruntime-chat
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import * as chat from '@holocronlab/botruntime-chat'
|
|
37
|
+
|
|
38
|
+
const client = await chat.Client.connect({ webhookId: process.env.WEBHOOK_ID! })
|
|
39
|
+
|
|
40
|
+
const { conversation } = await client.createConversation({})
|
|
41
|
+
await client.createMessage({
|
|
42
|
+
conversationId: conversation.id,
|
|
43
|
+
payload: { type: 'text', text: 'hello world' },
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const listener = await client.listenConversation({ id: conversation.id })
|
|
47
|
+
listener.on('message_created', (message: chat.Signals['message_created']) => {
|
|
48
|
+
console.log(message.payload)
|
|
49
|
+
})
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
See upstream `@botpress/chat` documentation for the full API (conversations,
|
|
53
|
+
messages, participants, users, events, realtime listening via SSE/websocket).
|
|
54
|
+
|
|
55
|
+
## Dependencies
|
|
56
|
+
|
|
57
|
+
Runtime dependencies are unchanged from upstream: `axios`, `browser-or-node`,
|
|
58
|
+
`event-source-polyfill`, `eventsource`, `jsonwebtoken`, `qs`, `verror`, `zod`.
|
|
59
|
+
Zero `@botpress/*` or `@bpinternal/*` runtime dependencies.
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT (see `LICENSE`). Derived from Botpress Technologies, Inc.'s
|
|
64
|
+
`@botpress/chat` package.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { AsyncCollection } from './listing';
|
|
2
|
+
import { SignalListener } from './signal-listener';
|
|
3
|
+
import * as types from './types';
|
|
4
|
+
declare const _createAuthClient: unique symbol;
|
|
5
|
+
type Merge<A, B> = Omit<A, keyof B> & B;
|
|
6
|
+
type IClient = Merge<{
|
|
7
|
+
[K in types.ClientOperation]: (x: types.ClientRequests[K]) => Promise<types.ClientResponses[K]>;
|
|
8
|
+
}, {
|
|
9
|
+
listenConversation: (args: types.ClientRequests['listenConversation']) => Promise<SignalListener>;
|
|
10
|
+
}>;
|
|
11
|
+
type IAuthenticatedClient = Merge<{
|
|
12
|
+
[K in types.AuthenticatedOperation]: (x: types.AuthenticatedClientRequests[K]) => Promise<types.ClientResponses[K]>;
|
|
13
|
+
}, {
|
|
14
|
+
listenConversation: (args: types.AuthenticatedClientRequests['listenConversation']) => Promise<SignalListener>;
|
|
15
|
+
}>;
|
|
16
|
+
export declare class Client implements IClient {
|
|
17
|
+
readonly props: Readonly<types.ClientProps>;
|
|
18
|
+
private _connectionTested;
|
|
19
|
+
private _auto;
|
|
20
|
+
constructor(props: Readonly<types.ClientProps>);
|
|
21
|
+
get apiVersion(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Gets or creates a user based on the provided props and returns an authenticated client.
|
|
24
|
+
*/
|
|
25
|
+
static connect(props: types.ConnectProps): Promise<AuthenticatedClient>;
|
|
26
|
+
readonly createConversation: IClient['createConversation'];
|
|
27
|
+
readonly getConversation: IClient['getConversation'];
|
|
28
|
+
readonly getOrCreateConversation: IClient['getOrCreateConversation'];
|
|
29
|
+
readonly deleteConversation: IClient['deleteConversation'];
|
|
30
|
+
readonly listConversations: IClient['listConversations'];
|
|
31
|
+
readonly listMessages: IClient['listMessages'];
|
|
32
|
+
readonly addParticipant: IClient['addParticipant'];
|
|
33
|
+
readonly removeParticipant: IClient['removeParticipant'];
|
|
34
|
+
readonly getParticipant: IClient['getParticipant'];
|
|
35
|
+
readonly listParticipants: IClient['listParticipants'];
|
|
36
|
+
readonly createMessage: IClient['createMessage'];
|
|
37
|
+
readonly getMessage: IClient['getMessage'];
|
|
38
|
+
readonly deleteMessage: IClient['deleteMessage'];
|
|
39
|
+
readonly createUser: IClient['createUser'];
|
|
40
|
+
readonly getUser: IClient['getUser'];
|
|
41
|
+
readonly getOrCreateUser: IClient['getOrCreateUser'];
|
|
42
|
+
readonly updateUser: IClient['updateUser'];
|
|
43
|
+
readonly deleteUser: IClient['deleteUser'];
|
|
44
|
+
readonly createEvent: IClient['createEvent'];
|
|
45
|
+
readonly getEvent: IClient['getEvent'];
|
|
46
|
+
get list(): {
|
|
47
|
+
conversations: (props: types.ClientRequests["listConversations"]) => AsyncCollection<{
|
|
48
|
+
id: string;
|
|
49
|
+
createdAt: string;
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
}>;
|
|
52
|
+
messages: (props: types.ClientRequests["listMessages"]) => AsyncCollection<{
|
|
53
|
+
id: string;
|
|
54
|
+
createdAt: string;
|
|
55
|
+
payload: {
|
|
56
|
+
[x: string]: any;
|
|
57
|
+
type: "audio";
|
|
58
|
+
audioUrl: string;
|
|
59
|
+
} | {
|
|
60
|
+
[x: string]: any;
|
|
61
|
+
type: "card";
|
|
62
|
+
title: string;
|
|
63
|
+
subtitle?: string | undefined;
|
|
64
|
+
imageUrl?: string | undefined;
|
|
65
|
+
actions: {
|
|
66
|
+
[x: string]: any;
|
|
67
|
+
action: "postback" | "url" | "say";
|
|
68
|
+
label: string;
|
|
69
|
+
value: string;
|
|
70
|
+
}[];
|
|
71
|
+
} | {
|
|
72
|
+
[x: string]: any;
|
|
73
|
+
type: "carousel";
|
|
74
|
+
items: {
|
|
75
|
+
[x: string]: any;
|
|
76
|
+
type: "card";
|
|
77
|
+
title: string;
|
|
78
|
+
subtitle?: string | undefined;
|
|
79
|
+
imageUrl?: string | undefined;
|
|
80
|
+
actions: {
|
|
81
|
+
[x: string]: any;
|
|
82
|
+
action: "postback" | "url" | "say";
|
|
83
|
+
label: string;
|
|
84
|
+
value: string;
|
|
85
|
+
}[];
|
|
86
|
+
}[];
|
|
87
|
+
} | {
|
|
88
|
+
[x: string]: any;
|
|
89
|
+
text: string;
|
|
90
|
+
options: {
|
|
91
|
+
[x: string]: any;
|
|
92
|
+
label: string;
|
|
93
|
+
value: string;
|
|
94
|
+
}[];
|
|
95
|
+
type: "choice";
|
|
96
|
+
} | {
|
|
97
|
+
[x: string]: any;
|
|
98
|
+
text: string;
|
|
99
|
+
options: {
|
|
100
|
+
[x: string]: any;
|
|
101
|
+
label: string;
|
|
102
|
+
value: string;
|
|
103
|
+
}[];
|
|
104
|
+
type: "dropdown";
|
|
105
|
+
} | {
|
|
106
|
+
[x: string]: any;
|
|
107
|
+
type: "file";
|
|
108
|
+
fileUrl: string;
|
|
109
|
+
title?: string | undefined;
|
|
110
|
+
} | {
|
|
111
|
+
[x: string]: any;
|
|
112
|
+
type: "image";
|
|
113
|
+
imageUrl: string;
|
|
114
|
+
} | {
|
|
115
|
+
[x: string]: any;
|
|
116
|
+
type: "location";
|
|
117
|
+
latitude: number;
|
|
118
|
+
longitude: number;
|
|
119
|
+
address?: string | undefined;
|
|
120
|
+
title?: string | undefined;
|
|
121
|
+
} | {
|
|
122
|
+
[x: string]: any;
|
|
123
|
+
type: "text";
|
|
124
|
+
text: string;
|
|
125
|
+
} | {
|
|
126
|
+
[x: string]: any;
|
|
127
|
+
type: "video";
|
|
128
|
+
videoUrl: string;
|
|
129
|
+
} | {
|
|
130
|
+
[x: string]: any;
|
|
131
|
+
type: "markdown";
|
|
132
|
+
markdown: string;
|
|
133
|
+
} | {
|
|
134
|
+
[x: string]: any;
|
|
135
|
+
type: "bloc";
|
|
136
|
+
items: ({
|
|
137
|
+
[x: string]: any;
|
|
138
|
+
type: "text";
|
|
139
|
+
text: string;
|
|
140
|
+
} | {
|
|
141
|
+
[x: string]: any;
|
|
142
|
+
type: "markdown";
|
|
143
|
+
markdown: string;
|
|
144
|
+
} | {
|
|
145
|
+
[x: string]: any;
|
|
146
|
+
type: "image";
|
|
147
|
+
imageUrl: string;
|
|
148
|
+
} | {
|
|
149
|
+
[x: string]: any;
|
|
150
|
+
type: "audio";
|
|
151
|
+
audioUrl: string;
|
|
152
|
+
} | {
|
|
153
|
+
[x: string]: any;
|
|
154
|
+
type: "video";
|
|
155
|
+
videoUrl: string;
|
|
156
|
+
} | {
|
|
157
|
+
[x: string]: any;
|
|
158
|
+
type: "file";
|
|
159
|
+
fileUrl: string;
|
|
160
|
+
title?: string | undefined;
|
|
161
|
+
} | {
|
|
162
|
+
[x: string]: any;
|
|
163
|
+
type: "location";
|
|
164
|
+
latitude: number;
|
|
165
|
+
longitude: number;
|
|
166
|
+
address?: string | undefined;
|
|
167
|
+
title?: string | undefined;
|
|
168
|
+
})[];
|
|
169
|
+
};
|
|
170
|
+
userId: string;
|
|
171
|
+
conversationId: string;
|
|
172
|
+
metadata?: {
|
|
173
|
+
[x: string]: any;
|
|
174
|
+
} | undefined;
|
|
175
|
+
}>;
|
|
176
|
+
participants: (props: types.ClientRequests["listParticipants"]) => AsyncCollection<{
|
|
177
|
+
id: string;
|
|
178
|
+
name?: string | undefined;
|
|
179
|
+
pictureUrl?: string | undefined;
|
|
180
|
+
profile?: string | undefined;
|
|
181
|
+
createdAt: string;
|
|
182
|
+
updatedAt: string;
|
|
183
|
+
}>;
|
|
184
|
+
};
|
|
185
|
+
readonly listenConversation: IClient['listenConversation'];
|
|
186
|
+
private _call;
|
|
187
|
+
/**
|
|
188
|
+
* The Chat-API is called like any other integrations by sending requests to the bridge webhook endpoint.
|
|
189
|
+
* This endpoint may return a successful status code even when the payload contains an error.
|
|
190
|
+
* This method parses the payload to check for an error and throws an error if one is found.
|
|
191
|
+
*/
|
|
192
|
+
private _checkPayloadForError;
|
|
193
|
+
private static _createAxios;
|
|
194
|
+
private get _apiUrl();
|
|
195
|
+
private static _getApiUrl;
|
|
196
|
+
private _testConnection;
|
|
197
|
+
}
|
|
198
|
+
export declare class AuthenticatedClient implements IAuthenticatedClient {
|
|
199
|
+
private _client;
|
|
200
|
+
readonly user: types.AuthenticatedUser;
|
|
201
|
+
private constructor();
|
|
202
|
+
static [_createAuthClient]: (client: Client, user: types.AuthenticatedUser) => AuthenticatedClient;
|
|
203
|
+
get apiVersion(): string;
|
|
204
|
+
readonly createConversation: IAuthenticatedClient['createConversation'];
|
|
205
|
+
readonly getConversation: IAuthenticatedClient['getConversation'];
|
|
206
|
+
readonly getOrCreateConversation: IAuthenticatedClient['getOrCreateConversation'];
|
|
207
|
+
readonly deleteConversation: IAuthenticatedClient['deleteConversation'];
|
|
208
|
+
readonly listConversations: IAuthenticatedClient['listConversations'];
|
|
209
|
+
readonly listMessages: IAuthenticatedClient['listMessages'];
|
|
210
|
+
readonly listenConversation: IAuthenticatedClient['listenConversation'];
|
|
211
|
+
readonly addParticipant: IAuthenticatedClient['addParticipant'];
|
|
212
|
+
readonly removeParticipant: IAuthenticatedClient['removeParticipant'];
|
|
213
|
+
readonly getParticipant: IAuthenticatedClient['getParticipant'];
|
|
214
|
+
readonly listParticipants: IAuthenticatedClient['listParticipants'];
|
|
215
|
+
readonly createMessage: IAuthenticatedClient['createMessage'];
|
|
216
|
+
readonly getMessage: IAuthenticatedClient['getMessage'];
|
|
217
|
+
readonly deleteMessage: IAuthenticatedClient['deleteMessage'];
|
|
218
|
+
readonly getUser: IAuthenticatedClient['getUser'];
|
|
219
|
+
readonly updateUser: IAuthenticatedClient['updateUser'];
|
|
220
|
+
readonly deleteUser: IAuthenticatedClient['deleteUser'];
|
|
221
|
+
readonly createEvent: IAuthenticatedClient['createEvent'];
|
|
222
|
+
readonly getEvent: IAuthenticatedClient['getEvent'];
|
|
223
|
+
get list(): {
|
|
224
|
+
conversations: (x: types.AuthenticatedClientRequests["listConversations"]) => AsyncCollection<{
|
|
225
|
+
id: string;
|
|
226
|
+
createdAt: string;
|
|
227
|
+
updatedAt: string;
|
|
228
|
+
}>;
|
|
229
|
+
messages: (x: types.AuthenticatedClientRequests["listMessages"]) => AsyncCollection<{
|
|
230
|
+
id: string;
|
|
231
|
+
createdAt: string;
|
|
232
|
+
payload: {
|
|
233
|
+
[x: string]: any;
|
|
234
|
+
type: "audio";
|
|
235
|
+
audioUrl: string;
|
|
236
|
+
} | {
|
|
237
|
+
[x: string]: any;
|
|
238
|
+
type: "card";
|
|
239
|
+
title: string;
|
|
240
|
+
subtitle?: string | undefined;
|
|
241
|
+
imageUrl?: string | undefined;
|
|
242
|
+
actions: {
|
|
243
|
+
[x: string]: any;
|
|
244
|
+
action: "postback" | "url" | "say";
|
|
245
|
+
label: string;
|
|
246
|
+
value: string;
|
|
247
|
+
}[];
|
|
248
|
+
} | {
|
|
249
|
+
[x: string]: any;
|
|
250
|
+
type: "carousel";
|
|
251
|
+
items: {
|
|
252
|
+
[x: string]: any;
|
|
253
|
+
type: "card";
|
|
254
|
+
title: string;
|
|
255
|
+
subtitle?: string | undefined;
|
|
256
|
+
imageUrl?: string | undefined;
|
|
257
|
+
actions: {
|
|
258
|
+
[x: string]: any;
|
|
259
|
+
action: "postback" | "url" | "say";
|
|
260
|
+
label: string;
|
|
261
|
+
value: string;
|
|
262
|
+
}[];
|
|
263
|
+
}[];
|
|
264
|
+
} | {
|
|
265
|
+
[x: string]: any;
|
|
266
|
+
text: string;
|
|
267
|
+
options: {
|
|
268
|
+
[x: string]: any;
|
|
269
|
+
label: string;
|
|
270
|
+
value: string;
|
|
271
|
+
}[];
|
|
272
|
+
type: "choice";
|
|
273
|
+
} | {
|
|
274
|
+
[x: string]: any;
|
|
275
|
+
text: string;
|
|
276
|
+
options: {
|
|
277
|
+
[x: string]: any;
|
|
278
|
+
label: string;
|
|
279
|
+
value: string;
|
|
280
|
+
}[];
|
|
281
|
+
type: "dropdown";
|
|
282
|
+
} | {
|
|
283
|
+
[x: string]: any;
|
|
284
|
+
type: "file";
|
|
285
|
+
fileUrl: string;
|
|
286
|
+
title?: string | undefined;
|
|
287
|
+
} | {
|
|
288
|
+
[x: string]: any;
|
|
289
|
+
type: "image";
|
|
290
|
+
imageUrl: string;
|
|
291
|
+
} | {
|
|
292
|
+
[x: string]: any;
|
|
293
|
+
type: "location";
|
|
294
|
+
latitude: number;
|
|
295
|
+
longitude: number;
|
|
296
|
+
address?: string | undefined;
|
|
297
|
+
title?: string | undefined;
|
|
298
|
+
} | {
|
|
299
|
+
[x: string]: any;
|
|
300
|
+
type: "text";
|
|
301
|
+
text: string;
|
|
302
|
+
} | {
|
|
303
|
+
[x: string]: any;
|
|
304
|
+
type: "video";
|
|
305
|
+
videoUrl: string;
|
|
306
|
+
} | {
|
|
307
|
+
[x: string]: any;
|
|
308
|
+
type: "markdown";
|
|
309
|
+
markdown: string;
|
|
310
|
+
} | {
|
|
311
|
+
[x: string]: any;
|
|
312
|
+
type: "bloc";
|
|
313
|
+
items: ({
|
|
314
|
+
[x: string]: any;
|
|
315
|
+
type: "text";
|
|
316
|
+
text: string;
|
|
317
|
+
} | {
|
|
318
|
+
[x: string]: any;
|
|
319
|
+
type: "markdown";
|
|
320
|
+
markdown: string;
|
|
321
|
+
} | {
|
|
322
|
+
[x: string]: any;
|
|
323
|
+
type: "image";
|
|
324
|
+
imageUrl: string;
|
|
325
|
+
} | {
|
|
326
|
+
[x: string]: any;
|
|
327
|
+
type: "audio";
|
|
328
|
+
audioUrl: string;
|
|
329
|
+
} | {
|
|
330
|
+
[x: string]: any;
|
|
331
|
+
type: "video";
|
|
332
|
+
videoUrl: string;
|
|
333
|
+
} | {
|
|
334
|
+
[x: string]: any;
|
|
335
|
+
type: "file";
|
|
336
|
+
fileUrl: string;
|
|
337
|
+
title?: string | undefined;
|
|
338
|
+
} | {
|
|
339
|
+
[x: string]: any;
|
|
340
|
+
type: "location";
|
|
341
|
+
latitude: number;
|
|
342
|
+
longitude: number;
|
|
343
|
+
address?: string | undefined;
|
|
344
|
+
title?: string | undefined;
|
|
345
|
+
})[];
|
|
346
|
+
};
|
|
347
|
+
userId: string;
|
|
348
|
+
conversationId: string;
|
|
349
|
+
metadata?: {
|
|
350
|
+
[x: string]: any;
|
|
351
|
+
} | undefined;
|
|
352
|
+
}>;
|
|
353
|
+
participants: (x: types.AuthenticatedClientRequests["listParticipants"]) => AsyncCollection<{
|
|
354
|
+
id: string;
|
|
355
|
+
name?: string | undefined;
|
|
356
|
+
pictureUrl?: string | undefined;
|
|
357
|
+
profile?: string | undefined;
|
|
358
|
+
createdAt: string;
|
|
359
|
+
updatedAt: string;
|
|
360
|
+
}>;
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
export {};
|
package/dist/consts.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const defaultBaseApiUrl = "https://botruntime.ru";
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { VError } from 'verror';
|
|
3
|
+
export * from './gen/client/errors';
|
|
4
|
+
export declare class ChatClientError extends VError {
|
|
5
|
+
static wrap(thrown: unknown, message: string): ChatClientError;
|
|
6
|
+
static map(thrown: unknown): ChatClientError;
|
|
7
|
+
constructor(error: ChatClientError, message: string);
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class ChatHTTPError extends ChatClientError {
|
|
11
|
+
readonly status: number | undefined;
|
|
12
|
+
constructor(status: number | undefined, message: string);
|
|
13
|
+
static fromAxios(e: AxiosError<{
|
|
14
|
+
message?: string;
|
|
15
|
+
}>): ChatHTTPError;
|
|
16
|
+
private static _axiosMsg;
|
|
17
|
+
}
|
|
18
|
+
export declare class ChatConfigError extends ChatClientError {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ListenStatus = 'keep-listening' | 'stop-listening';
|
|
2
|
+
export declare class EventEmitter<E extends object> {
|
|
3
|
+
private _listeners;
|
|
4
|
+
emit<K extends keyof E>(type: K, event: E[K]): void;
|
|
5
|
+
onceOrMore<K extends keyof E>(type: K, listener: (event: E[K]) => ListenStatus): void;
|
|
6
|
+
once<K extends keyof E>(type: K, listener: (event: E[K]) => void): void;
|
|
7
|
+
on<K extends keyof E>(type: K, listener: (event: E[K]) => void): void;
|
|
8
|
+
off<K extends keyof E>(type: K, listener: (event: E[K]) => void): void;
|
|
9
|
+
cleanup(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type EventSourceBrowser from 'event-source-polyfill';
|
|
2
|
+
import type EventSourceNodeJs from 'eventsource';
|
|
3
|
+
import { EventEmitter } from './event-emitter';
|
|
4
|
+
type NodeOnOpen = EventSourceNodeJs['onopen'];
|
|
5
|
+
type NodeOnMessage = EventSourceNodeJs['onmessage'];
|
|
6
|
+
type NodeOnError = EventSourceNodeJs['onerror'];
|
|
7
|
+
type NodeOpenEvent = Parameters<NodeOnOpen>[0];
|
|
8
|
+
type NodeMessageEvent = Parameters<NodeOnMessage>[0];
|
|
9
|
+
type NodeErrorEvent = Parameters<NodeOnError>[0];
|
|
10
|
+
type BrowserOnOpen = NonNullable<EventSourceBrowser.EventSourcePolyfill['onopen']>;
|
|
11
|
+
type BrowserOnMessage = NonNullable<EventSourceBrowser.EventSourcePolyfill['onmessage']>;
|
|
12
|
+
type BrowserOnError = NonNullable<EventSourceBrowser.EventSourcePolyfill['onerror']>;
|
|
13
|
+
type BrowserOpenEvent = Parameters<BrowserOnOpen>[0];
|
|
14
|
+
type BrowserMessageEvent = Parameters<BrowserOnMessage>[0];
|
|
15
|
+
type BrowserErrorEvent = Parameters<BrowserOnError>[0];
|
|
16
|
+
export type OpenEvent = NodeOpenEvent | BrowserOpenEvent;
|
|
17
|
+
export type MessageEvent = NodeMessageEvent | BrowserMessageEvent;
|
|
18
|
+
export type ErrorEvent = NodeErrorEvent | BrowserErrorEvent;
|
|
19
|
+
export type Events = {
|
|
20
|
+
open: OpenEvent;
|
|
21
|
+
message: MessageEvent;
|
|
22
|
+
error: ErrorEvent;
|
|
23
|
+
};
|
|
24
|
+
export type Props = {
|
|
25
|
+
headers?: Record<string, string>;
|
|
26
|
+
};
|
|
27
|
+
export type EventSourceEmitter = {
|
|
28
|
+
on: EventEmitter<Events>['on'];
|
|
29
|
+
close: () => void;
|
|
30
|
+
};
|
|
31
|
+
export declare const listenEventSource: (url: string, props?: Props) => Promise<EventSourceEmitter>;
|
|
32
|
+
export {};
|