@botpress/webchat 2.3.1 → 2.3.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.
Files changed (37) hide show
  1. package/.eslintrc.js +11 -0
  2. package/.turbo/turbo-build.log +15 -14
  3. package/dist/adapters/index.d.ts +1 -6
  4. package/dist/adapters/target.d.ts +1 -6
  5. package/dist/adapters/typings.d.ts +1 -6
  6. package/dist/adapters/webchat-to-target.d.ts +8 -0
  7. package/dist/adapters/webchat.d.ts +3 -1986
  8. package/dist/client/state-machine.d.ts +1 -1
  9. package/dist/client/types.d.ts +1 -0
  10. package/dist/components/MessageList/MessageList.d.ts +1 -1
  11. package/dist/components/renderers/Audio/Audio.d.ts +1 -0
  12. package/dist/components/renderers/Carousel/Carousel.d.ts +1 -0
  13. package/dist/components/renderers/File/File.d.ts +1 -0
  14. package/dist/components/renderers/Image/Image.d.ts +1 -0
  15. package/dist/components/renderers/Location/Location.d.ts +1 -0
  16. package/dist/components/renderers/Video/Video.d.ts +1 -0
  17. package/dist/gen/signals/index.d.ts +34 -34
  18. package/dist/gen/signals/messageCreated.z.d.ts +34 -34
  19. package/dist/index.js +23994 -21803
  20. package/dist/index.umd.cjs +117 -113
  21. package/dist/schemas/init.d.ts +14 -14
  22. package/dist/schemas/theme.d.ts +8 -8
  23. package/dist/stores/offlineStore.d.ts +1 -1
  24. package/dist/stores/webchatStore.d.ts +2 -2
  25. package/dist/types/block-type.d.ts +2 -0
  26. package/package.json +21 -22
  27. package/dist/adapters/adapters/messaging-to-target.d.ts +0 -184
  28. package/dist/adapters/adapters/messaging-to-webchat.d.ts +0 -5
  29. package/dist/adapters/adapters/webchat-to-messaging.d.ts +0 -223
  30. package/dist/adapters/adapters/webchat-to-target.d.ts +0 -197
  31. package/dist/adapters/messaging.d.ts +0 -1455
  32. package/dist/adapters/sdk.d.ts +0 -472
  33. package/dist/client/inner-client/event-emitter.d.ts +0 -10
  34. package/dist/client/inner-client/eventsource.d.ts +0 -22
  35. package/dist/client/inner-client/index.d.ts +0 -42
  36. package/dist/client/inner-client/signal-listener.d.ts +0 -47
  37. package/openapi.ts +0 -35
@@ -1,472 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const defaults: {
3
- readonly text: {
4
- readonly schema: z.ZodObject<{
5
- text: z.ZodString;
6
- }, "strip", z.ZodTypeAny, {
7
- text: string;
8
- }, {
9
- text: string;
10
- }>;
11
- };
12
- readonly markdown: {
13
- readonly schema: z.ZodObject<{
14
- markdown: z.ZodString;
15
- }, "strip", z.ZodTypeAny, {
16
- markdown: string;
17
- }, {
18
- markdown: string;
19
- }>;
20
- };
21
- readonly image: {
22
- readonly schema: z.ZodObject<{
23
- imageUrl: z.ZodString;
24
- }, "strip", z.ZodTypeAny, {
25
- imageUrl: string;
26
- }, {
27
- imageUrl: string;
28
- }>;
29
- };
30
- readonly audio: {
31
- readonly schema: z.ZodObject<{
32
- audioUrl: z.ZodString;
33
- }, "strip", z.ZodTypeAny, {
34
- audioUrl: string;
35
- }, {
36
- audioUrl: string;
37
- }>;
38
- };
39
- readonly video: {
40
- readonly schema: z.ZodObject<{
41
- videoUrl: z.ZodString;
42
- }, "strip", z.ZodTypeAny, {
43
- videoUrl: string;
44
- }, {
45
- videoUrl: string;
46
- }>;
47
- };
48
- readonly file: {
49
- readonly schema: z.ZodObject<{
50
- fileUrl: z.ZodString;
51
- title: z.ZodOptional<z.ZodString>;
52
- }, "strip", z.ZodTypeAny, {
53
- fileUrl: string;
54
- title?: string | undefined;
55
- }, {
56
- fileUrl: string;
57
- title?: string | undefined;
58
- }>;
59
- };
60
- readonly location: {
61
- readonly schema: z.ZodObject<{
62
- latitude: z.ZodNumber;
63
- longitude: z.ZodNumber;
64
- address: z.ZodOptional<z.ZodString>;
65
- title: z.ZodOptional<z.ZodString>;
66
- }, "strip", z.ZodTypeAny, {
67
- latitude: number;
68
- longitude: number;
69
- address?: string | undefined;
70
- title?: string | undefined;
71
- }, {
72
- latitude: number;
73
- longitude: number;
74
- address?: string | undefined;
75
- title?: string | undefined;
76
- }>;
77
- };
78
- readonly carousel: {
79
- readonly schema: z.ZodObject<{
80
- items: z.ZodArray<z.ZodObject<{
81
- title: z.ZodString;
82
- subtitle: z.ZodOptional<z.ZodString>;
83
- imageUrl: z.ZodOptional<z.ZodString>;
84
- actions: z.ZodArray<z.ZodObject<{
85
- action: z.ZodEnum<["postback", "url", "say"]>;
86
- label: z.ZodString;
87
- value: z.ZodString;
88
- }, "strip", z.ZodTypeAny, {
89
- value: string;
90
- action: "postback" | "url" | "say";
91
- label: string;
92
- }, {
93
- value: string;
94
- action: "postback" | "url" | "say";
95
- label: string;
96
- }>, "many">;
97
- }, "strip", z.ZodTypeAny, {
98
- title: string;
99
- actions: {
100
- value: string;
101
- action: "postback" | "url" | "say";
102
- label: string;
103
- }[];
104
- subtitle?: string | undefined;
105
- imageUrl?: string | undefined;
106
- }, {
107
- title: string;
108
- actions: {
109
- value: string;
110
- action: "postback" | "url" | "say";
111
- label: string;
112
- }[];
113
- subtitle?: string | undefined;
114
- imageUrl?: string | undefined;
115
- }>, "many">;
116
- }, "strip", z.ZodTypeAny, {
117
- items: {
118
- title: string;
119
- actions: {
120
- value: string;
121
- action: "postback" | "url" | "say";
122
- label: string;
123
- }[];
124
- subtitle?: string | undefined;
125
- imageUrl?: string | undefined;
126
- }[];
127
- }, {
128
- items: {
129
- title: string;
130
- actions: {
131
- value: string;
132
- action: "postback" | "url" | "say";
133
- label: string;
134
- }[];
135
- subtitle?: string | undefined;
136
- imageUrl?: string | undefined;
137
- }[];
138
- }>;
139
- };
140
- readonly card: {
141
- readonly schema: z.ZodObject<{
142
- title: z.ZodString;
143
- subtitle: z.ZodOptional<z.ZodString>;
144
- imageUrl: z.ZodOptional<z.ZodString>;
145
- actions: z.ZodArray<z.ZodObject<{
146
- action: z.ZodEnum<["postback", "url", "say"]>;
147
- label: z.ZodString;
148
- value: z.ZodString;
149
- }, "strip", z.ZodTypeAny, {
150
- value: string;
151
- action: "postback" | "url" | "say";
152
- label: string;
153
- }, {
154
- value: string;
155
- action: "postback" | "url" | "say";
156
- label: string;
157
- }>, "many">;
158
- }, "strip", z.ZodTypeAny, {
159
- title: string;
160
- actions: {
161
- value: string;
162
- action: "postback" | "url" | "say";
163
- label: string;
164
- }[];
165
- subtitle?: string | undefined;
166
- imageUrl?: string | undefined;
167
- }, {
168
- title: string;
169
- actions: {
170
- value: string;
171
- action: "postback" | "url" | "say";
172
- label: string;
173
- }[];
174
- subtitle?: string | undefined;
175
- imageUrl?: string | undefined;
176
- }>;
177
- };
178
- readonly dropdown: {
179
- readonly schema: z.ZodObject<{
180
- text: z.ZodString;
181
- options: z.ZodArray<z.ZodObject<{
182
- label: z.ZodString;
183
- value: z.ZodString;
184
- }, "strip", z.ZodTypeAny, {
185
- value: string;
186
- label: string;
187
- }, {
188
- value: string;
189
- label: string;
190
- }>, "many">;
191
- }, "strip", z.ZodTypeAny, {
192
- text: string;
193
- options: {
194
- value: string;
195
- label: string;
196
- }[];
197
- }, {
198
- text: string;
199
- options: {
200
- value: string;
201
- label: string;
202
- }[];
203
- }>;
204
- };
205
- readonly choice: {
206
- readonly schema: z.ZodObject<{
207
- text: z.ZodString;
208
- options: z.ZodArray<z.ZodObject<{
209
- label: z.ZodString;
210
- value: z.ZodString;
211
- }, "strip", z.ZodTypeAny, {
212
- value: string;
213
- label: string;
214
- }, {
215
- value: string;
216
- label: string;
217
- }>, "many">;
218
- }, "strip", z.ZodTypeAny, {
219
- text: string;
220
- options: {
221
- value: string;
222
- label: string;
223
- }[];
224
- }, {
225
- text: string;
226
- options: {
227
- value: string;
228
- label: string;
229
- }[];
230
- }>;
231
- };
232
- readonly bloc: {
233
- readonly schema: z.ZodObject<{
234
- items: z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
235
- type: z.ZodLiteral<"text">;
236
- payload: z.ZodObject<{
237
- text: z.ZodString;
238
- }, "strip", z.ZodTypeAny, {
239
- text: string;
240
- }, {
241
- text: string;
242
- }>;
243
- }, "strip", z.ZodTypeAny, {
244
- type: "text";
245
- payload: {
246
- text: string;
247
- };
248
- }, {
249
- type: "text";
250
- payload: {
251
- text: string;
252
- };
253
- }>, z.ZodObject<{
254
- type: z.ZodLiteral<"markdown">;
255
- payload: z.ZodObject<{
256
- markdown: z.ZodString;
257
- }, "strip", z.ZodTypeAny, {
258
- markdown: string;
259
- }, {
260
- markdown: string;
261
- }>;
262
- }, "strip", z.ZodTypeAny, {
263
- type: "markdown";
264
- payload: {
265
- markdown: string;
266
- };
267
- }, {
268
- type: "markdown";
269
- payload: {
270
- markdown: string;
271
- };
272
- }>, z.ZodObject<{
273
- type: z.ZodLiteral<"image">;
274
- payload: z.ZodObject<{
275
- imageUrl: z.ZodString;
276
- }, "strip", z.ZodTypeAny, {
277
- imageUrl: string;
278
- }, {
279
- imageUrl: string;
280
- }>;
281
- }, "strip", z.ZodTypeAny, {
282
- type: "image";
283
- payload: {
284
- imageUrl: string;
285
- };
286
- }, {
287
- type: "image";
288
- payload: {
289
- imageUrl: string;
290
- };
291
- }>, z.ZodObject<{
292
- type: z.ZodLiteral<"audio">;
293
- payload: z.ZodObject<{
294
- audioUrl: z.ZodString;
295
- }, "strip", z.ZodTypeAny, {
296
- audioUrl: string;
297
- }, {
298
- audioUrl: string;
299
- }>;
300
- }, "strip", z.ZodTypeAny, {
301
- type: "audio";
302
- payload: {
303
- audioUrl: string;
304
- };
305
- }, {
306
- type: "audio";
307
- payload: {
308
- audioUrl: string;
309
- };
310
- }>, z.ZodObject<{
311
- type: z.ZodLiteral<"video">;
312
- payload: z.ZodObject<{
313
- videoUrl: z.ZodString;
314
- }, "strip", z.ZodTypeAny, {
315
- videoUrl: string;
316
- }, {
317
- videoUrl: string;
318
- }>;
319
- }, "strip", z.ZodTypeAny, {
320
- type: "video";
321
- payload: {
322
- videoUrl: string;
323
- };
324
- }, {
325
- type: "video";
326
- payload: {
327
- videoUrl: string;
328
- };
329
- }>, z.ZodObject<{
330
- type: z.ZodLiteral<"file">;
331
- payload: z.ZodObject<{
332
- fileUrl: z.ZodString;
333
- title: z.ZodOptional<z.ZodString>;
334
- }, "strip", z.ZodTypeAny, {
335
- fileUrl: string;
336
- title?: string | undefined;
337
- }, {
338
- fileUrl: string;
339
- title?: string | undefined;
340
- }>;
341
- }, "strip", z.ZodTypeAny, {
342
- type: "file";
343
- payload: {
344
- fileUrl: string;
345
- title?: string | undefined;
346
- };
347
- }, {
348
- type: "file";
349
- payload: {
350
- fileUrl: string;
351
- title?: string | undefined;
352
- };
353
- }>, z.ZodObject<{
354
- type: z.ZodLiteral<"location">;
355
- payload: z.ZodObject<{
356
- latitude: z.ZodNumber;
357
- longitude: z.ZodNumber;
358
- address: z.ZodOptional<z.ZodString>;
359
- title: z.ZodOptional<z.ZodString>;
360
- }, "strip", z.ZodTypeAny, {
361
- latitude: number;
362
- longitude: number;
363
- address?: string | undefined;
364
- title?: string | undefined;
365
- }, {
366
- latitude: number;
367
- longitude: number;
368
- address?: string | undefined;
369
- title?: string | undefined;
370
- }>;
371
- }, "strip", z.ZodTypeAny, {
372
- type: "location";
373
- payload: {
374
- latitude: number;
375
- longitude: number;
376
- address?: string | undefined;
377
- title?: string | undefined;
378
- };
379
- }, {
380
- type: "location";
381
- payload: {
382
- latitude: number;
383
- longitude: number;
384
- address?: string | undefined;
385
- title?: string | undefined;
386
- };
387
- }>]>, "many">;
388
- }, "strip", z.ZodTypeAny, {
389
- items: ({
390
- type: "text";
391
- payload: {
392
- text: string;
393
- };
394
- } | {
395
- type: "markdown";
396
- payload: {
397
- markdown: string;
398
- };
399
- } | {
400
- type: "image";
401
- payload: {
402
- imageUrl: string;
403
- };
404
- } | {
405
- type: "audio";
406
- payload: {
407
- audioUrl: string;
408
- };
409
- } | {
410
- type: "video";
411
- payload: {
412
- videoUrl: string;
413
- };
414
- } | {
415
- type: "file";
416
- payload: {
417
- fileUrl: string;
418
- title?: string | undefined;
419
- };
420
- } | {
421
- type: "location";
422
- payload: {
423
- latitude: number;
424
- longitude: number;
425
- address?: string | undefined;
426
- title?: string | undefined;
427
- };
428
- })[];
429
- }, {
430
- items: ({
431
- type: "text";
432
- payload: {
433
- text: string;
434
- };
435
- } | {
436
- type: "markdown";
437
- payload: {
438
- markdown: string;
439
- };
440
- } | {
441
- type: "image";
442
- payload: {
443
- imageUrl: string;
444
- };
445
- } | {
446
- type: "audio";
447
- payload: {
448
- audioUrl: string;
449
- };
450
- } | {
451
- type: "video";
452
- payload: {
453
- videoUrl: string;
454
- };
455
- } | {
456
- type: "file";
457
- payload: {
458
- fileUrl: string;
459
- title?: string | undefined;
460
- };
461
- } | {
462
- type: "location";
463
- payload: {
464
- latitude: number;
465
- longitude: number;
466
- address?: string | undefined;
467
- title?: string | undefined;
468
- };
469
- })[];
470
- }>;
471
- };
472
- };
@@ -1,10 +0,0 @@
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
- }
@@ -1,22 +0,0 @@
1
- import EventSource from 'event-source-polyfill';
2
- import { EventEmitter } from './event-emitter';
3
- type OnOpen = NonNullable<EventSource.EventSourcePolyfill['onopen']>;
4
- type OnMessage = NonNullable<EventSource.EventSourcePolyfill['onmessage']>;
5
- type OnError = NonNullable<EventSource.EventSourcePolyfill['onerror']>;
6
- export type OpenEvent = Parameters<OnOpen>[0];
7
- export type MessageEvent = Parameters<OnMessage>[0];
8
- export type ErrorEvent = Parameters<OnError>[0];
9
- export type Events = {
10
- open: OpenEvent;
11
- message: MessageEvent;
12
- error: ErrorEvent;
13
- };
14
- export type Props = {
15
- headers?: Record<string, string>;
16
- };
17
- export type EvSource = {
18
- on: EventEmitter<Events>['on'];
19
- close: () => void;
20
- };
21
- export declare const listenEventSource: (url: string, props?: Props) => Promise<EvSource>;
22
- export {};
@@ -1,42 +0,0 @@
1
- import { Client as AutoGeneratedClient } from '../../gen/client';
2
- import { SignalListener } from './signal-listener';
3
- export type { Message, Conversation, User } from '../../gen/client';
4
- export * from '../../gen/client/errors';
5
- export type Headers = Record<string, string>;
6
- export type ClientProps = {
7
- apiUrl: string;
8
- timeout?: number;
9
- headers?: Headers;
10
- };
11
- type IOf<T extends object> = {
12
- [K in keyof T]: T[K];
13
- };
14
- type IAutoClient = IOf<AutoGeneratedClient>;
15
- type IClient = Omit<IAutoClient, 'listenConversation'>;
16
- type ListenConversationOperation = IAutoClient['listenConversation'];
17
- type ListenConversationArgs = Parameters<ListenConversationOperation>[0];
18
- export declare class Client implements IClient {
19
- readonly props: Readonly<ClientProps>;
20
- private _auto;
21
- constructor(props: Readonly<ClientProps>);
22
- readonly createConversation: IAutoClient['createConversation'];
23
- readonly getConversation: IAutoClient['getConversation'];
24
- readonly deleteConversation: IAutoClient['deleteConversation'];
25
- readonly listConversations: IAutoClient['listConversations'];
26
- readonly listConversationMessages: IAutoClient['listConversationMessages'];
27
- readonly addParticipant: IAutoClient['addParticipant'];
28
- readonly removeParticipant: IAutoClient['removeParticipant'];
29
- readonly getParticipant: IAutoClient['getParticipant'];
30
- readonly listParticipants: IAutoClient['listParticipants'];
31
- readonly createMessage: IAutoClient['createMessage'];
32
- readonly getMessage: IAutoClient['getMessage'];
33
- readonly deleteMessage: IAutoClient['deleteMessage'];
34
- readonly createFile: IAutoClient['createFile'];
35
- readonly createUser: IAutoClient['createUser'];
36
- readonly getUser: IAutoClient['getUser'];
37
- readonly updateUser: IAutoClient['updateUser'];
38
- readonly deleteUser: IAutoClient['deleteUser'];
39
- readonly createEvent: IAutoClient['createEvent'];
40
- readonly getEvent: IAutoClient['getEvent'];
41
- readonly listenConversation: ({ id, "x-user-key": userKey, }: ListenConversationArgs) => Promise<SignalListener>;
42
- }
@@ -1,47 +0,0 @@
1
- import { EventEmitter } from './event-emitter';
2
- import { EvSource } from './eventsource';
3
- import { Types } from '../../gen/signals';
4
- type Signals = Types & {
5
- unknown: {
6
- type: 'unknown';
7
- data: unknown;
8
- };
9
- };
10
- type SignalMap = {
11
- [K in keyof Signals as Signals[K]['type']]: Signals[K]['data'];
12
- };
13
- type Events = SignalMap & {
14
- error: Error;
15
- };
16
- type SignalListenerState = {
17
- status: 'disconnected';
18
- } | {
19
- status: 'connecting';
20
- connectionPromise: Promise<EvSource>;
21
- } | {
22
- status: 'connected';
23
- source: EvSource;
24
- };
25
- export type SignalListenerStatus = SignalListenerState['status'];
26
- export type SignalListenerProps = {
27
- url: string;
28
- userKey: string;
29
- conversationId: string;
30
- };
31
- export declare class SignalListener extends EventEmitter<Events> {
32
- private _props;
33
- private _state;
34
- constructor(_props: SignalListenerProps);
35
- static listen: (props: SignalListenerProps) => Promise<SignalListener>;
36
- get status(): SignalListenerStatus;
37
- readonly connect: () => Promise<void>;
38
- readonly disconnect: () => Promise<void>;
39
- private _connect;
40
- private _disconnectSync;
41
- private _handleMessage;
42
- private _handleError;
43
- private _parseSignal;
44
- private _safeJsonParse;
45
- private _toError;
46
- }
47
- export {};
package/openapi.ts DELETED
@@ -1,35 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- import type { default as yargs } from '@bpinternal/yargs-extra'
3
- import { parseEnv, YargsSchema } from '@bpinternal/yargs-extra'
4
- import { api } from 'webchat-api'
5
- import pathlib from 'path'
6
-
7
- const yargsExtra = require('@bpinternal/yargs-extra') // running script from an esm module
8
- const yargz = yargsExtra.default as ReturnType<typeof yargs>
9
-
10
- const configSchema = {
11
- outDir: {
12
- type: 'string' as const,
13
- },
14
- } satisfies YargsSchema
15
-
16
- const description = 'Generate OpenAPI client'
17
-
18
- void yargz
19
- .command('$0', description, configSchema, async (argv) => {
20
- const config = { ...argv, ...parseEnv(configSchema) }
21
- if (!config.outDir) {
22
- throw new Error('outDir is required')
23
- }
24
-
25
- const clientDir = pathlib.join(config.outDir, 'client')
26
- await api.exportClient(clientDir, {
27
- generator: 'opapi',
28
- })
29
-
30
- const signalsDir = pathlib.join(config.outDir, 'signals')
31
- await api.signals.exportSchemas(signalsDir, { includeJsonSchemas: false })
32
- })
33
- .showHelpOnFail(false)
34
- .help()
35
- .parse()