@botpress/webchat 2.0.0 → 2.1.1

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,25 +1,25 @@
1
1
 
2
- > @botpress/webchat@2.0.0 build /home/runner/work/echo/echo/packages/webchat-frontend
2
+ > @botpress/webchat@2.1.1 build /home/runner/work/echo/echo/packages/webchat-frontend
3
3
  > vite build
4
4
 
5
5
  vite v4.4.11 building for production...
6
6
  transforming...
7
7
  [plugin:vite:resolve] Module "crypto" has been externalized for browser compatibility, imported by "/home/runner/work/echo/echo/packages/webchat-frontend/src/gen/client/errors.ts". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
8
- [plugin:vite:resolve] Module "node:http" has been externalized for browser compatibility, imported by "/home/runner/work/echo/echo/node_modules/.pnpm/@botpress+sdk@0.8.5/node_modules/@botpress/sdk/dist/index.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
9
- [plugin:vite:resolve] Module "util" has been externalized for browser compatibility, imported by "/home/runner/work/echo/echo/node_modules/.pnpm/@botpress+sdk@0.8.5/node_modules/@botpress/sdk/dist/index.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
8
+ [plugin:vite:resolve] Module "node:http" has been externalized for browser compatibility, imported by "/home/runner/work/echo/echo/node_modules/.pnpm/@botpress+sdk@0.8.29_react@18.2.0/node_modules/@botpress/sdk/dist/index.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
9
+ [plugin:vite:resolve] Module "util" has been externalized for browser compatibility, imported by "/home/runner/work/echo/echo/node_modules/.pnpm/@botpress+sdk@0.8.29_react@18.2.0/node_modules/@botpress/sdk/dist/index.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
10
10
  [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/url.js". See http://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
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
- ✓ 2428 modules transformed.
14
+ ✓ 2436 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 14905ms.
19
+ [vite:dts] Declaration files built in 14756ms.
20
20
  
21
- dist/index.js  1.09 kB │ gzip: 0.52 kB
22
- dist/index-773597b6.js  118.52 kB │ gzip: 31.78 kB
23
- dist/index-c3cb8119.js 1,298.88 kB │ gzip: 318.51 kB
24
- dist/index.umd.cjs 989.01 kB │ gzip: 291.51 kB
25
- ✓ built in 24.05s
21
+ dist/index.js  1.17 kB │ gzip: 0.56 kB
22
+ dist/index-71c4fbd6.js  118.52 kB │ gzip: 31.78 kB
23
+ dist/index-37291b06.js 1,449.27 kB │ gzip: 360.65 kB
24
+ dist/index.umd.cjs 1,082.64 kB │ gzip: 327.96 kB
25
+ ✓ built in 24.49s
@@ -18,6 +18,7 @@ export declare class MessagingClient implements WebchatClient {
18
18
  disconnect(): Promise<void>;
19
19
  getUser(): Promise<User>;
20
20
  updateUser(): Promise<User>;
21
+ sendFile(_file: File): Promise<any>;
21
22
  sendMessage(message: string): Promise<void>;
22
23
  sendEvent(event: Record<string, any>): Promise<void>;
23
24
  switchConversation(id: string): Promise<void>;
@@ -1,5 +1,6 @@
1
1
  import { EventEmitter } from '../../utils';
2
2
  import { Events, Message, UserCredentials, UserData, WebchatClient, type User } from '../types';
3
+ import { type FileType } from '../../types';
3
4
  export type PushpinClientProps = {
4
5
  apiUrl: string;
5
6
  clientId: string;
@@ -25,6 +26,11 @@ export declare class PushpinClient extends EventEmitter<Events> implements Webch
25
26
  private _initialConnect;
26
27
  private _reConnect;
27
28
  disconnect(): Promise<void>;
29
+ sendFile(file: File): Promise<{
30
+ fileUrl: string;
31
+ name: string;
32
+ type: FileType;
33
+ }>;
28
34
  sendMessage(message: string): Promise<void>;
29
35
  sendEvent(event: Record<string, any>): Promise<void>;
30
36
  switchConversation(id: string): Promise<void>;
@@ -31,6 +31,7 @@ export declare class Client implements IClient {
31
31
  readonly createMessage: IAutoClient['createMessage'];
32
32
  readonly getMessage: IAutoClient['getMessage'];
33
33
  readonly deleteMessage: IAutoClient['deleteMessage'];
34
+ readonly createFile: IAutoClient['createFile'];
34
35
  readonly createUser: IAutoClient['createUser'];
35
36
  readonly getUser: IAutoClient['getUser'];
36
37
  readonly updateUser: IAutoClient['updateUser'];
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from '../utils';
2
- import { BlockObject } from '../types/block-type';
2
+ import { BlockObject, type FileType } from '../types/block-type';
3
3
  export type UserCredentials = {
4
4
  userId: string;
5
5
  userToken: string;
@@ -47,6 +47,11 @@ export type WebchatClient = {
47
47
  getUser(): Promise<User>;
48
48
  updateUser(user: User): Promise<User>;
49
49
  sendMessage(message: string): Promise<void>;
50
+ sendFile(file: File): Promise<{
51
+ fileUrl: string;
52
+ name: string;
53
+ type: FileType;
54
+ }>;
50
55
  sendEvent(event: Record<string, any>): Promise<void>;
51
56
  switchConversation(id: string): Promise<void>;
52
57
  conversationExists(id: string): Promise<boolean>;
@@ -3,10 +3,16 @@ import { ComponentProps, FC } from 'react';
3
3
  import { type StyleOptions } from '../contexts';
4
4
  declare const Composer: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>>;
5
5
  declare const ComposerInput: import("react").MemoExoticComponent<(props: ComponentProps<'textarea'>) => import("react/jsx-runtime").JSX.Element>;
6
+ type UploadButtonStyle = NonNullable<Theme['composer']>['uploadButton'];
7
+ type UploadButtonProps = {
8
+ icon?: FC<StyleOptions>;
9
+ styles?: UploadButtonStyle;
10
+ } & ComponentProps<'button'>;
11
+ declare const UploadButton: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<UploadButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>>;
6
12
  type ComposerButtonStyle = NonNullable<Theme['composer']>['button'];
7
13
  type ComposerButtonProps = {
8
14
  icon?: FC<StyleOptions>;
9
15
  styles?: ComposerButtonStyle;
10
16
  } & ComponentProps<'button'>;
11
17
  declare const ComposerButton: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<ComposerButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>>;
12
- export { Composer, ComposerInput, ComposerButton };
18
+ export { Composer, ComposerInput, ComposerButton, UploadButton };
@@ -34,10 +34,9 @@ export type ContextVaue = {
34
34
  on: WebchatClient['on'];
35
35
  sendMessage: WebchatClient['sendMessage'];
36
36
  restartConversation: () => void;
37
- } & Pick<WebchatClient, 'userId' | 'conversationId' | 'clientId'>;
37
+ } & Pick<WebchatClient, 'userId' | 'conversationId' | 'clientId' | 'sendFile'>;
38
38
  closeWindow?: () => void;
39
39
  setState: (state: Partial<ContextVaue['state']>) => void;
40
40
  setTheme: (styles: Partial<Theme>) => void;
41
41
  };
42
42
  export declare const WebchatContext: import("react").Context<ContextVaue | null>;
43
- export declare function useWebchatContext(): ContextVaue;
@@ -135,6 +135,13 @@ type ReferenceConstraintType = 'ReferenceConstraint';
135
135
  export declare class ReferenceConstraintError extends BaseApiError<409, ReferenceConstraintType, 'The resource cannot be deleted because it\'s referenced by another resource'> {
136
136
  constructor(message: string, error?: Error, id?: string);
137
137
  }
138
+ type ResourceLockedConflictType = 'ResourceLockedConflict';
139
+ /**
140
+ * The resource is current locked and cannot be operated on until the lock is released.
141
+ */
142
+ export declare class ResourceLockedConflictError extends BaseApiError<409, ResourceLockedConflictType, 'The resource is current locked and cannot be operated on until the lock is released.'> {
143
+ constructor(message: string, error?: Error, id?: string);
144
+ }
138
145
  type ReferenceNotFoundType = 'ReferenceNotFound';
139
146
  /**
140
147
  * The provided resource reference is missing. This is usually caused when providing an invalid id inside the payload of a request.
@@ -198,7 +205,7 @@ type BreakingChangesType = 'BreakingChanges';
198
205
  export declare class BreakingChangesError extends BaseApiError<400, BreakingChangesType, 'Request payload contains breaking changes which is not allowed for this resource without a version increment.'> {
199
206
  constructor(message: string, error?: Error, id?: string);
200
207
  }
201
- export type ErrorType = 'Unknown' | 'Internal' | 'Unauthorized' | 'Forbidden' | 'PayloadTooLarge' | 'InvalidPayload' | 'UnsupportedMediaType' | 'MethodNotFound' | 'ResourceNotFound' | 'InvalidJsonSchema' | 'InvalidDataFormat' | 'InvalidIdentifier' | 'RelationConflict' | 'ReferenceConstraint' | 'ReferenceNotFound' | 'InvalidQuery' | 'Runtime' | 'AlreadyExists' | 'RateLimited' | 'PaymentRequired' | 'QuotaExceeded' | 'LimitExceeded' | 'BreakingChanges';
202
- export type ApiError = UnknownError | InternalError | UnauthorizedError | ForbiddenError | PayloadTooLargeError | InvalidPayloadError | UnsupportedMediaTypeError | MethodNotFoundError | ResourceNotFoundError | InvalidJsonSchemaError | InvalidDataFormatError | InvalidIdentifierError | RelationConflictError | ReferenceConstraintError | ReferenceNotFoundError | InvalidQueryError | RuntimeError | AlreadyExistsError | RateLimitedError | PaymentRequiredError | QuotaExceededError | LimitExceededError | BreakingChangesError;
208
+ export type ErrorType = 'Unknown' | 'Internal' | 'Unauthorized' | 'Forbidden' | 'PayloadTooLarge' | 'InvalidPayload' | 'UnsupportedMediaType' | 'MethodNotFound' | 'ResourceNotFound' | 'InvalidJsonSchema' | 'InvalidDataFormat' | 'InvalidIdentifier' | 'RelationConflict' | 'ReferenceConstraint' | 'ResourceLockedConflict' | 'ReferenceNotFound' | 'InvalidQuery' | 'Runtime' | 'AlreadyExists' | 'RateLimited' | 'PaymentRequired' | 'QuotaExceeded' | 'LimitExceeded' | 'BreakingChanges';
209
+ export type ApiError = UnknownError | InternalError | UnauthorizedError | ForbiddenError | PayloadTooLargeError | InvalidPayloadError | UnsupportedMediaTypeError | MethodNotFoundError | ResourceNotFoundError | InvalidJsonSchemaError | InvalidDataFormatError | InvalidIdentifierError | RelationConflictError | ReferenceConstraintError | ResourceLockedConflictError | ReferenceNotFoundError | InvalidQueryError | RuntimeError | AlreadyExistsError | RateLimitedError | PaymentRequiredError | QuotaExceededError | LimitExceededError | BreakingChangesError;
203
210
  export declare const errorFrom: (err: unknown) => ApiError;
204
211
  export {};
@@ -19,6 +19,7 @@ import * as getUser from './operations/getUser';
19
19
  import * as updateUser from './operations/updateUser';
20
20
  import * as createEvent from './operations/createEvent';
21
21
  import * as getEvent from './operations/getEvent';
22
+ import * as createFile from './operations/createFile';
22
23
  export * from './models';
23
24
  export * as addParticipant from './operations/addParticipant';
24
25
  export * as createConversation from './operations/createConversation';
@@ -39,6 +40,7 @@ export * as getUser from './operations/getUser';
39
40
  export * as updateUser from './operations/updateUser';
40
41
  export * as createEvent from './operations/createEvent';
41
42
  export * as getEvent from './operations/getEvent';
43
+ export * as createFile from './operations/createFile';
42
44
  export type ClientProps = {
43
45
  toAxiosRequest: typeof toAxiosRequest;
44
46
  };
@@ -65,4 +67,5 @@ export declare class Client {
65
67
  readonly updateUser: (input: updateUser.UpdateUserInput) => Promise<updateUser.UpdateUserResponse>;
66
68
  readonly createEvent: (input: createEvent.CreateEventInput) => Promise<createEvent.CreateEventResponse>;
67
69
  readonly getEvent: (input: getEvent.GetEventInput) => Promise<getEvent.GetEventResponse>;
70
+ readonly createFile: (input: createFile.CreateFileInput) => Promise<createFile.CreateFileResponse>;
68
71
  }
@@ -214,3 +214,21 @@ export interface Event {
214
214
  */
215
215
  userId: string;
216
216
  }
217
+ export interface File {
218
+ id: string;
219
+ botId: string;
220
+ key: string;
221
+ size: number | null;
222
+ contentType: string;
223
+ tags: {
224
+ [k: string]: string;
225
+ };
226
+ createdAt: string;
227
+ updatedAt: string;
228
+ accessPolicies: ("integrations" | "public_content")[];
229
+ index: boolean;
230
+ url: string;
231
+ status: "upload_pending" | "upload_failed" | "upload_completed" | "indexing_pending" | "indexing_failed" | "indexing_completed";
232
+ failedStatusReason?: string;
233
+ uploadUrl: string;
234
+ }
@@ -0,0 +1,65 @@
1
+ export interface CreateFileRequestHeaders {
2
+ "x-user-key": string;
3
+ }
4
+ export interface CreateFileRequestQuery {
5
+ }
6
+ export interface CreateFileRequestParams {
7
+ }
8
+ export interface CreateFileRequestBody {
9
+ /**
10
+ * Unique key for the file. Must be unique across the bot (and the integration, when applicable).
11
+ */
12
+ key: string;
13
+ /**
14
+ * File size in bytes. This will count against your File Storage quota. If the index parameter is set to true, this will also count against your Vector DB Storage quota.
15
+ */
16
+ size: number;
17
+ /**
18
+ * File access policies. Add "public_content" to allow public access to the file content. Add "integrations" to allow read, search and list operations for any integration installed in the bot.
19
+ */
20
+ accessPolicies?: ("integrations" | "public_content")[];
21
+ /**
22
+ * Whether the file should be indexed. If true, the file content will be searchable in the Vector DB. This will count against your Vector DB Storage quota.
23
+ */
24
+ index?: boolean;
25
+ /**
26
+ * File content type. If omitted, the content type will be inferred from the file extension (if any) specified in key. If a content type cannot be inferred, the default is "application/octet-stream".
27
+ */
28
+ contentType?: string;
29
+ /**
30
+ * File tags. These are used for search and filtering operations.
31
+ */
32
+ tags?: {
33
+ [k: string]: string;
34
+ };
35
+ }
36
+ export type CreateFileInput = CreateFileRequestBody & CreateFileRequestHeaders & CreateFileRequestQuery & CreateFileRequestParams;
37
+ export type CreateFileRequest = {
38
+ headers: CreateFileRequestHeaders;
39
+ query: CreateFileRequestQuery;
40
+ params: CreateFileRequestParams;
41
+ body: CreateFileRequestBody;
42
+ };
43
+ export declare const parseReq: (input: CreateFileInput) => CreateFileRequest & {
44
+ path: string;
45
+ };
46
+ export interface CreateFileResponse {
47
+ file: {
48
+ id: string;
49
+ botId: string;
50
+ key: string;
51
+ size: number | null;
52
+ contentType: string;
53
+ tags: {
54
+ [k: string]: string;
55
+ };
56
+ createdAt: string;
57
+ updatedAt: string;
58
+ accessPolicies: ("integrations" | "public_content")[];
59
+ index: boolean;
60
+ url: string;
61
+ status: "upload_pending" | "upload_failed" | "upload_completed" | "indexing_pending" | "indexing_failed" | "indexing_completed";
62
+ failedStatusReason?: string;
63
+ uploadUrl: string;
64
+ };
65
+ }
@@ -1,5 +1,5 @@
1
+ export * from './useAutosizeTextArea';
2
+ export * from './useClient';
1
3
  export * from './useImageSize';
4
+ export * from './useRefresh';
2
5
  export * from './useWebchatStore';
3
- export * from './useRefresh.ts';
4
- export * from './useClient.ts';
5
- export * from './useAutosizeTextArea.ts';
@@ -1,33 +1,2 @@
1
- import { UserCredentials } from '@botpress/messaging-socket';
2
- type WebchatState = {
3
- messageHistory: {
4
- [key: string]: string[];
5
- };
6
- user?: UserCredentials;
7
- conversationId?: string;
8
- clientMode: string;
9
- addMessageToHistory: (props: {
10
- userId: string;
11
- message: string;
12
- }) => void;
13
- setClientMode: (clientMode: string) => void;
14
- setUser: (userId?: UserCredentials) => void;
15
- setConversationId: (conversationId?: string) => void;
16
- clearAll: () => void;
17
- };
18
- export declare const useWebchatStore: import("zustand").UseBoundStore<Omit<Omit<import("zustand").StoreApi<WebchatState>, "setState"> & {
19
- setState<A extends string | {
20
- type: unknown;
21
- }>(partial: WebchatState | Partial<WebchatState> | ((state: WebchatState) => WebchatState | Partial<WebchatState>), replace?: boolean | undefined, action?: A | undefined): void;
22
- }, "persist"> & {
23
- persist: {
24
- setOptions: (options: Partial<import("zustand/middleware").PersistOptions<WebchatState, WebchatState>>) => void;
25
- clearStorage: () => void;
26
- rehydrate: () => void | Promise<void>;
27
- hasHydrated: () => boolean;
28
- onHydrate: (fn: (state: WebchatState) => void) => () => void;
29
- onFinishHydration: (fn: (state: WebchatState) => void) => () => void;
30
- getOptions: () => Partial<import("zustand/middleware").PersistOptions<WebchatState, WebchatState>>;
31
- };
32
- }>;
33
- export {};
1
+ import { type WebchatState } from '../stores';
2
+ export declare function useWebchatStore<T>(selector: (state: WebchatState) => T): T;