@botpress/webchat 1.3.9 → 1.3.12

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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @botpress/webchat@1.3.9 build /home/runner/work/echo/echo/packages/webchat-frontend
2
+ > @botpress/webchat@1.3.12 build /home/runner/work/echo/echo/packages/webchat-frontend
3
3
  > vite build
4
4
 
5
5
  vite v4.4.11 building for production...
@@ -11,15 +11,15 @@ transforming...
11
11
  [plugin:vite:resolve] Module "path" has been externalized for browser compatibility, imported by "/home/runner/work/echo/echo/node_modules/.pnpm/@apidevtools+json-schema-ref-parser@11.6.1/node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/convert-path-to-posix.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
12
12
  [plugin:vite:resolve] Module "util" has been externalized for browser compatibility, imported by "/home/runner/work/echo/echo/node_modules/.pnpm/@jsdevtools+ono@7.1.3/node_modules/@jsdevtools/ono/esm/types.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
13
13
  ../../node_modules/.pnpm/@jsdevtools+ono@7.1.3/node_modules/@jsdevtools/ono/esm/types.js (1:9) "inspect" is not exported by "__vite-browser-external", imported by "../../node_modules/.pnpm/@jsdevtools+ono@7.1.3/node_modules/@jsdevtools/ono/esm/types.js".
14
- ✓ 2426 modules transformed.
14
+ ✓ 2428 modules transformed.
15
15
  rendering chunks...
16
16
  
17
17
  [vite:dts] Start generate declaration files...
18
18
  computing gzip size...
19
- [vite:dts] Declaration files built in 13751ms.
19
+ [vite:dts] Declaration files built in 14689ms.
20
20
  
21
21
  dist/index.js  1.09 kB │ gzip: 0.52 kB
22
- dist/index-de8cc2d3.js  118.52 kB │ gzip: 31.78 kB
23
- dist/index-8e9a70c6.js 1,297.30 kB │ gzip: 318.23 kB
24
- dist/index.umd.cjs 987.65 kB │ gzip: 291.31 kB
25
- ✓ built in 22.86s
22
+ dist/index-d84f2e5e.js  118.52 kB │ gzip: 31.78 kB
23
+ dist/index-aa13a347.js 1,298.84 kB │ gzip: 318.49 kB
24
+ dist/index.umd.cjs 988.97 kB │ gzip: 291.50 kB
25
+ ✓ built in 23.76s
@@ -1,10 +1,11 @@
1
1
  import { type MessagingSocketOptions, type UserCredentials } from '@botpress/messaging-socket';
2
2
  import { EventEmitter } from '../../utils';
3
- import { Events, UserData, WebchatClient } from '../types';
3
+ import { Events, UserData, WebchatClient, type User } from '../types';
4
4
  export type MessagingClientProps = MessagingSocketOptions;
5
5
  export declare class MessagingClient implements WebchatClient {
6
6
  private socket;
7
- clientId: string | undefined;
7
+ clientId: string;
8
+ apiUrl: string;
8
9
  userId: string | undefined;
9
10
  conversationId: string | undefined;
10
11
  private userToken;
@@ -15,6 +16,8 @@ export declare class MessagingClient implements WebchatClient {
15
16
  readonly mode = "messaging";
16
17
  connect(creds?: UserCredentials, data?: UserData): Promise<UserCredentials | undefined>;
17
18
  disconnect(): Promise<void>;
19
+ getUser(): Promise<User>;
20
+ updateUser(): Promise<User>;
18
21
  sendMessage(message: string): Promise<void>;
19
22
  sendEvent(event: Record<string, any>): Promise<void>;
20
23
  switchConversation(id: string): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from '../../utils';
2
- import { Events, Message, UserCredentials, UserData, WebchatClient } from '../types';
2
+ import { Events, Message, UserCredentials, UserData, WebchatClient, type User } from '../types';
3
3
  export type PushpinClientProps = {
4
4
  apiUrl: string;
5
5
  clientId: string;
@@ -7,11 +7,19 @@ export type PushpinClientProps = {
7
7
  export declare class PushpinClient extends EventEmitter<Events> implements WebchatClient {
8
8
  private _client;
9
9
  private _webhookId;
10
+ private _apiUrl;
10
11
  private _state;
11
12
  constructor(props: PushpinClientProps);
12
13
  readonly mode = "pushpin";
14
+ get apiUrl(): string;
13
15
  get clientId(): string;
14
16
  get userId(): string | undefined;
17
+ getUser(): Promise<{
18
+ data: {
19
+ [k: string]: any;
20
+ } | undefined;
21
+ }>;
22
+ updateUser(user: User): Promise<User>;
15
23
  get conversationId(): string | undefined;
16
24
  connect(creds?: UserCredentials, data?: UserData): Promise<UserCredentials | undefined>;
17
25
  private _initialConnect;
@@ -4,7 +4,10 @@ export type UserCredentials = {
4
4
  userId: string;
5
5
  userToken: string;
6
6
  };
7
- export type UserData = Record<string, string>;
7
+ export type UserData = Record<string, unknown>;
8
+ export type User = {
9
+ data?: UserData;
10
+ };
8
11
  export type Message = {
9
12
  id: string;
10
13
  conversationId: string;
@@ -13,7 +16,7 @@ export type Message = {
13
16
  disableInput?: boolean;
14
17
  payload: BlockObject;
15
18
  };
16
- export type Events = {
19
+ export type WebchatEvents = {
17
20
  conversation: string | undefined;
18
21
  message: Message;
19
22
  messageSent: string;
@@ -22,14 +25,27 @@ export type Events = {
22
25
  webchatConfig: Record<string, any>;
23
26
  customEvent: Record<string, any>;
24
27
  };
28
+ type ValueOf<T> = T[keyof T];
29
+ type AnyEvent = ValueOf<{
30
+ [K in keyof WebchatEvents]: {
31
+ type: K;
32
+ payload: WebchatEvents[K];
33
+ };
34
+ }>;
35
+ export type Events = WebchatEvents & {
36
+ '*': AnyEvent;
37
+ };
25
38
  export type WebchatClient = {
26
39
  mode: 'messaging' | 'pushpin';
27
- clientId: string | undefined;
40
+ clientId: string;
41
+ apiUrl: string;
28
42
  userId: string | undefined;
29
43
  conversationId: string | undefined;
30
44
  on: EventEmitter<Events>['on'];
31
45
  connect(creds?: UserCredentials, data?: UserData): Promise<UserCredentials | undefined>;
32
46
  disconnect(): Promise<void>;
47
+ getUser(): Promise<User>;
48
+ updateUser(user: User): Promise<User>;
33
49
  sendMessage(message: string): Promise<void>;
34
50
  sendEvent(event: Record<string, any>): Promise<void>;
35
51
  switchConversation(id: string): Promise<void>;
@@ -37,3 +53,4 @@ export type WebchatClient = {
37
53
  newConversation(): Promise<void>;
38
54
  listMessages(): Promise<Message[]>;
39
55
  };
56
+ export {};
@@ -1,4 +1,5 @@
1
- import { AxiosInstance, AxiosRequestConfig } from 'axios';
1
+ import { AxiosInstance } from 'axios';
2
+ import { toAxiosRequest } from './to-axios';
2
3
  import * as addParticipant from './operations/addParticipant';
3
4
  import * as createConversation from './operations/createConversation';
4
5
  import * as deleteConversation from './operations/deleteConversation';
@@ -38,9 +39,13 @@ export * as getUser from './operations/getUser';
38
39
  export * as updateUser from './operations/updateUser';
39
40
  export * as createEvent from './operations/createEvent';
40
41
  export * as getEvent from './operations/getEvent';
42
+ export type ClientProps = {
43
+ toAxiosRequest: typeof toAxiosRequest;
44
+ };
41
45
  export declare class Client {
42
46
  private axiosInstance;
43
- constructor(axiosInstance: AxiosInstance);
47
+ private props;
48
+ constructor(axiosInstance: AxiosInstance, props?: Partial<ClientProps>);
44
49
  readonly addParticipant: (input: addParticipant.AddParticipantInput) => Promise<addParticipant.AddParticipantResponse>;
45
50
  readonly createConversation: (input: createConversation.CreateConversationInput) => Promise<createConversation.CreateConversationResponse>;
46
51
  readonly deleteConversation: (input: deleteConversation.DeleteConversationInput) => Promise<deleteConversation.DeleteConversationResponse>;
@@ -61,18 +66,3 @@ export declare class Client {
61
66
  readonly createEvent: (input: createEvent.CreateEventInput) => Promise<createEvent.CreateEventResponse>;
62
67
  readonly getEvent: (input: getEvent.GetEventInput) => Promise<getEvent.GetEventResponse>;
63
68
  }
64
- type Primitive = string | number | boolean;
65
- type Value<P extends Primitive> = P | P[] | Record<string, P>;
66
- type QueryValue = Value<string> | Value<boolean> | Value<number> | undefined;
67
- type AnyQueryParams = Record<string, QueryValue>;
68
- type HeaderValue = string | undefined;
69
- type AnyHeaderParams = Record<string, HeaderValue>;
70
- type AnyBodyParams = Record<string, any>;
71
- type ParsedRequest = {
72
- method: string;
73
- path: string;
74
- query: AnyQueryParams;
75
- headers: AnyHeaderParams;
76
- body: AnyBodyParams;
77
- };
78
- export declare const toAxiosRequest: (req: ParsedRequest) => AxiosRequestConfig;
@@ -10,6 +10,12 @@ export interface User {
10
10
  * Picture url of the [User](#schema_user)
11
11
  */
12
12
  pictureUrl?: string;
13
+ /**
14
+ * User data
15
+ */
16
+ data?: {
17
+ [k: string]: any;
18
+ };
13
19
  /**
14
20
  * Id of the [User](#schema_user)
15
21
  */
@@ -35,6 +35,12 @@ export interface AddParticipantResponse {
35
35
  * Picture url of the [User](#schema_user)
36
36
  */
37
37
  pictureUrl?: string;
38
+ /**
39
+ * User data
40
+ */
41
+ data?: {
42
+ [k: string]: any;
43
+ };
38
44
  /**
39
45
  * Id of the [User](#schema_user)
40
46
  */
@@ -43,6 +43,12 @@ export interface CreateUserResponse {
43
43
  * Picture url of the [User](#schema_user)
44
44
  */
45
45
  pictureUrl?: string;
46
+ /**
47
+ * User data
48
+ */
49
+ data?: {
50
+ [k: string]: any;
51
+ };
46
52
  /**
47
53
  * Id of the [User](#schema_user)
48
54
  */
@@ -32,6 +32,12 @@ export interface GetParticipantResponse {
32
32
  * Picture url of the [User](#schema_user)
33
33
  */
34
34
  pictureUrl?: string;
35
+ /**
36
+ * User data
37
+ */
38
+ data?: {
39
+ [k: string]: any;
40
+ };
35
41
  /**
36
42
  * Id of the [User](#schema_user)
37
43
  */
@@ -30,6 +30,12 @@ export interface GetUserResponse {
30
30
  * Picture url of the [User](#schema_user)
31
31
  */
32
32
  pictureUrl?: string;
33
+ /**
34
+ * User data
35
+ */
36
+ data?: {
37
+ [k: string]: any;
38
+ };
33
39
  /**
34
40
  * Id of the [User](#schema_user)
35
41
  */
@@ -29,6 +29,12 @@ export interface ListParticipantsResponse {
29
29
  * Picture url of the [User](#schema_user)
30
30
  */
31
31
  pictureUrl?: string;
32
+ /**
33
+ * User data
34
+ */
35
+ data?: {
36
+ [k: string]: any;
37
+ };
32
38
  /**
33
39
  * Id of the [User](#schema_user)
34
40
  */
@@ -19,7 +19,7 @@ export interface UpdateUserRequestBody {
19
19
  */
20
20
  userData?: {
21
21
  [k: string]: any;
22
- };
22
+ } | null;
23
23
  }
24
24
  export type UpdateUserInput = UpdateUserRequestBody & UpdateUserRequestHeaders & UpdateUserRequestQuery & UpdateUserRequestParams;
25
25
  export type UpdateUserRequest = {
@@ -44,6 +44,12 @@ export interface UpdateUserResponse {
44
44
  * Picture url of the [User](#schema_user)
45
45
  */
46
46
  pictureUrl?: string;
47
+ /**
48
+ * User data
49
+ */
50
+ data?: {
51
+ [k: string]: any;
52
+ };
47
53
  /**
48
54
  * Id of the [User](#schema_user)
49
55
  */
@@ -0,0 +1,16 @@
1
+ import { AxiosRequestConfig } from "axios";
2
+ export type Primitive = string | number | boolean;
3
+ export type Value<P extends Primitive> = P | P[] | Record<string, P>;
4
+ export type QueryValue = Value<string> | Value<boolean> | Value<number> | undefined;
5
+ export type AnyQueryParams = Record<string, QueryValue>;
6
+ export type HeaderValue = string | undefined;
7
+ export type AnyHeaderParams = Record<string, HeaderValue>;
8
+ export type AnyBodyParams = Record<string, any>;
9
+ export type ParsedRequest = {
10
+ method: string;
11
+ path: string;
12
+ query: AnyQueryParams;
13
+ headers: AnyHeaderParams;
14
+ body: AnyBodyParams;
15
+ };
16
+ export declare const toAxiosRequest: (req: ParsedRequest) => AxiosRequestConfig;
@@ -1,8 +1,7 @@
1
- import { WebchatClient } from '../client';
2
1
  type UseClientOptions = {
3
2
  mode?: 'messaging' | 'pushpin';
4
3
  clientId: string;
5
4
  apiUrl?: string;
6
5
  };
7
- export declare const useClient: ({ clientId, apiUrl, mode, }: UseClientOptions) => WebchatClient | undefined;
6
+ export declare const useClient: ({ clientId, apiUrl, mode, }: UseClientOptions) => import("..").WebchatClient;
8
7
  export {};