@xpert-ai/chatkit-react 0.0.4 → 0.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.
- package/README.md +11 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +0 -1248
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -29,7 +29,10 @@ function App() {
|
|
|
29
29
|
headers: { 'Content-Type': 'application/json' },
|
|
30
30
|
});
|
|
31
31
|
const data = await response.json();
|
|
32
|
-
return
|
|
32
|
+
return {
|
|
33
|
+
secret: data.client_secret,
|
|
34
|
+
organizationId: data.organization_id,
|
|
35
|
+
};
|
|
33
36
|
}
|
|
34
37
|
},
|
|
35
38
|
onReady: () => {
|
|
@@ -59,7 +62,9 @@ interface UseChatKitOptions extends Partial<ChatKitOptions> {
|
|
|
59
62
|
api: {
|
|
60
63
|
apiUrl: string;
|
|
61
64
|
xpertId: string;
|
|
62
|
-
getClientSecret: (
|
|
65
|
+
getClientSecret: (
|
|
66
|
+
currentClientSecret: string | null,
|
|
67
|
+
) => Promise<string | { secret: string; organizationId?: string }>;
|
|
63
68
|
};
|
|
64
69
|
locale?: SupportedLocale; // 'en-US' | 'zh-Hans'
|
|
65
70
|
theme?: ThemeOptions;
|
|
@@ -84,6 +89,10 @@ interface ChatKitInstance {
|
|
|
84
89
|
}
|
|
85
90
|
```
|
|
86
91
|
|
|
92
|
+
`getClientSecret` may keep returning the legacy `string`, or return
|
|
93
|
+
`{ secret, organizationId }` to have ChatKit send `organization-id` on hosted
|
|
94
|
+
API requests.
|
|
95
|
+
|
|
87
96
|
### `<ChatKit />` Component
|
|
88
97
|
|
|
89
98
|
The main UI component that renders the chat interface.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ChatKitEvents } from '
|
|
2
|
-
import { ChatKitOptions } from '
|
|
1
|
+
import { ChatKitEvents } from '../../chatkit/src/index.ts';
|
|
2
|
+
import { ChatKitOptions } from '../../chatkit/src/index.ts';
|
|
3
3
|
import * as React_2 from 'react';
|
|
4
|
-
import { XpertAIChatKit } from '
|
|
4
|
+
import { XpertAIChatKit } from '../../chatkit/src/index.ts';
|
|
5
5
|
|
|
6
6
|
export declare const ChatKit: React_2.ForwardRefExoticComponent<ChatKitProps & React_2.RefAttributes<XpertAIChatKit>>;
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ declare type ChatKitControl = {
|
|
|
13
13
|
handlers: ChatKitEventHandlers;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
declare type ChatKitEventHandlers = Partial<{
|
|
16
|
+
export declare type ChatKitEventHandlers = Partial<{
|
|
17
17
|
[K in keyof ChatKitEvents as ToEventHandlerKey<K>]: ChatKitEvents[K] extends CustomEvent<infer Detail> ? Detail extends undefined ? () => void : (event: Detail) => void : never;
|
|
18
18
|
}>;
|
|
19
19
|
|
|
@@ -29,7 +29,7 @@ declare interface ChatKitProps extends React_2.HTMLAttributes<XpertAIChatKit> {
|
|
|
29
29
|
|
|
30
30
|
declare type DotToCamelCase<S extends string> = S extends `${infer Head}.${infer Tail}` ? `${Head}${Capitalize<DotToCamelCase<Tail>>}` : S;
|
|
31
31
|
|
|
32
|
-
declare type ToEventHandlerKey<K extends keyof ChatKitEvents> = DotToCamelCase<K> extends `chatkit${infer EventName}` ? `on${Capitalize<EventName>}` : never;
|
|
32
|
+
export declare type ToEventHandlerKey<K extends keyof ChatKitEvents> = DotToCamelCase<K> extends `chatkit${infer EventName}` ? `on${Capitalize<EventName>}` : never;
|
|
33
33
|
|
|
34
34
|
export declare function useChatKit(options: UseChatKitOptions): UseChatKitReturn;
|
|
35
35
|
|