@nago730/chatbot-library 1.1.0 → 1.1.4
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 +21 -21
- package/README.md +392 -392
- package/package.json +50 -36
- package/src/engine.ts +24 -24
- package/src/examples/firebaseAdapter.example.ts +421 -421
- package/src/index.ts +2 -2
- package/src/types.ts +39 -39
- package/src/useChat.ts +338 -338
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './engine';
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './engine';
|
|
3
3
|
export * from './useChat';
|
package/src/types.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
export interface ChatNode {
|
|
2
|
-
id: string;
|
|
3
|
-
question: string;
|
|
4
|
-
type?: 'button' | 'input';
|
|
5
|
-
options?: string[];
|
|
6
|
-
next: string | ((answer: any) => string);
|
|
7
|
-
isEnd?: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface ChatMessage {
|
|
11
|
-
nodeId: string;
|
|
12
|
-
question: string;
|
|
13
|
-
answer: any;
|
|
14
|
-
timestamp: number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ChatOptions {
|
|
18
|
-
saveStrategy?: 'always' | 'onEnd';
|
|
19
|
-
scenarioId?: string;
|
|
20
|
-
/**
|
|
21
|
-
* 세션 ID 설정
|
|
22
|
-
* - 'auto': 마지막 세션 복구 또는 새 세션 생성 (기본값)
|
|
23
|
-
* - 'new': 항상 새로운 세션 생성
|
|
24
|
-
* - string: 특정 세션 ID로 복구 또는 생성
|
|
25
|
-
*/
|
|
26
|
-
sessionId?: 'auto' | 'new' | string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface ChatState {
|
|
30
|
-
answers: Record<string, any>;
|
|
31
|
-
currentStep: string;
|
|
32
|
-
messages: ChatMessage[];
|
|
33
|
-
flowHash: string;
|
|
34
|
-
updatedAt: number;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface StorageAdapter {
|
|
38
|
-
saveState: (userId: string, state: ChatState) => Promise<void>;
|
|
39
|
-
loadState: (userId: string) => Promise<ChatState | null>;
|
|
1
|
+
export interface ChatNode {
|
|
2
|
+
id: string;
|
|
3
|
+
question: string;
|
|
4
|
+
type?: 'button' | 'input';
|
|
5
|
+
options?: string[];
|
|
6
|
+
next: string | ((answer: any) => string);
|
|
7
|
+
isEnd?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ChatMessage {
|
|
11
|
+
nodeId: string;
|
|
12
|
+
question: string;
|
|
13
|
+
answer: any;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ChatOptions {
|
|
18
|
+
saveStrategy?: 'always' | 'onEnd';
|
|
19
|
+
scenarioId?: string;
|
|
20
|
+
/**
|
|
21
|
+
* 세션 ID 설정
|
|
22
|
+
* - 'auto': 마지막 세션 복구 또는 새 세션 생성 (기본값)
|
|
23
|
+
* - 'new': 항상 새로운 세션 생성
|
|
24
|
+
* - string: 특정 세션 ID로 복구 또는 생성
|
|
25
|
+
*/
|
|
26
|
+
sessionId?: 'auto' | 'new' | string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface ChatState {
|
|
30
|
+
answers: Record<string, any>;
|
|
31
|
+
currentStep: string;
|
|
32
|
+
messages: ChatMessage[];
|
|
33
|
+
flowHash: string;
|
|
34
|
+
updatedAt: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface StorageAdapter {
|
|
38
|
+
saveState: (userId: string, state: ChatState) => Promise<void>;
|
|
39
|
+
loadState: (userId: string) => Promise<ChatState | null>;
|
|
40
40
|
}
|