@aiqa/sdk 1.0.0-develop.2 → 1.0.0-develop.3

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.
@@ -0,0 +1,112 @@
1
+ import { Socket } from 'socket.io-client';
2
+
3
+ type Application = {
4
+ application_id: string;
5
+ client_name: string;
6
+ client_phone_number: string;
7
+ agent_id: string;
8
+ agent_first_name: string;
9
+ agent_last_name: string;
10
+ };
11
+ declare enum Methods {
12
+ AUTHENTICATE = "AUTHENTICATE",
13
+ GET_FACTS = "GET_FACTS",
14
+ START_RECORDING = "START_RECORDING",
15
+ STOP_RECORDING = "STOP_RECORDING",
16
+ IS_RECORDING = "IS_RECORDING",
17
+ ADD_FACT = "ADD_FACT",
18
+ SET_CONVERSATION_PRODUCT = "SET_CONVERSATION_PRODUCT"
19
+ }
20
+ type SetConversationProductResult = {
21
+ success: boolean;
22
+ product: string;
23
+ };
24
+ type SdkEvent = Methods | "connect" | "disconnect" | "close" | "error" | "reconnect_attempt" | "reconnect_error" | "reconnect_failed" | "authenticated" | "app_version";
25
+ declare enum FactAnswerFormatType {
26
+ string = "STRING",
27
+ number = "NUMBER",
28
+ integer = "INT",
29
+ float = "FLOAT",
30
+ bool = "BOOL",
31
+ list = "LIST",
32
+ strict = "STRICT",
33
+ single_choice = "SINGLE_CHOICE",
34
+ multiple_choices = "MULTIPLE_CHOICES"
35
+ }
36
+ type ApplicationFactAnswerChoice = {
37
+ key: string;
38
+ text: string;
39
+ };
40
+ type ApplicationFactAnswerFormat = {
41
+ type: FactAnswerFormatType;
42
+ choices?: ApplicationFactAnswerChoice[];
43
+ };
44
+ type ApplicationFactInput = {
45
+ id: string;
46
+ question: string;
47
+ expected_answer: any;
48
+ answer_format: ApplicationFactAnswerFormat;
49
+ category_id?: string;
50
+ category_name?: string;
51
+ language?: string;
52
+ critical?: boolean;
53
+ is_skipped?: boolean;
54
+ };
55
+ type QuestionStatus = "searching" | "asked" | "not_asked";
56
+ type VerificationStatus = "processing" | "matched" | "unmatched";
57
+ type ApplicationFact = ApplicationFactInput & {
58
+ ai_answer?: any;
59
+ question_status: QuestionStatus;
60
+ verification_status: VerificationStatus;
61
+ };
62
+ interface AddFactResult {
63
+ agent_answer?: string;
64
+ ai_answer?: string;
65
+ is_valid_answer: boolean;
66
+ question_asked?: boolean;
67
+ }
68
+ type SdkError = {
69
+ code: "INVALID_CONFIG" | "CONNECTION_ERROR" | "TIMEOUT" | "SERVER_ERROR" | "UNEXPECTED_RESPONSE";
70
+ message: string;
71
+ details?: any;
72
+ };
73
+ declare abstract class IAiqaSdk {
74
+ abstract connect(): void;
75
+ abstract disconnect(): void;
76
+ abstract on(eventName: string, callback: (...args: any[]) => any): void;
77
+ abstract off(eventName: string): void;
78
+ abstract getApplication(): Promise<Application>;
79
+ abstract addFact(fact: ApplicationFactInput): Promise<AddFactResult>;
80
+ abstract getFacts(): Promise<ApplicationFact[]>;
81
+ abstract setConversationProduct(product: string): Promise<SetConversationProductResult>;
82
+ }
83
+
84
+ declare class AiQaSdk implements IAiqaSdk {
85
+ socket: Socket | null;
86
+ url: string;
87
+ applicationId: string;
88
+ applicationSecretKey: string;
89
+ cachedApplication?: Application;
90
+ internalListeners: Map<SdkEvent, Set<(...args: any[]) => void>>;
91
+ internalEvents: Set<SdkEvent>;
92
+ constructor(applicationId: string, applicationSecret: string, url?: string);
93
+ on(name: SdkEvent, callback: (...args: any[]) => any): void;
94
+ off(name: SdkEvent, callback?: (...args: any[]) => any): void;
95
+ connect(): void;
96
+ disconnect(): void;
97
+ sendMessage(method: Methods, data?: any): Promise<any>;
98
+ getApplication(): Promise<Application>;
99
+ getFacts(): Promise<ApplicationFact[]>;
100
+ addFact(fact: ApplicationFactInput): Promise<AddFactResult>;
101
+ setConversationProduct(product: string): Promise<SetConversationProductResult>;
102
+ authenticate(): Promise<void>;
103
+ startRecording(): Promise<boolean>;
104
+ stopRecording(): Promise<boolean>;
105
+ isRecordingNow(): Promise<boolean>;
106
+ private compareVersions;
107
+ private emitInternal;
108
+ private createRequestId;
109
+ private isManagerEvent;
110
+ }
111
+
112
+ export { type AddFactResult, AiQaSdk, type Application, type ApplicationFact, type ApplicationFactAnswerChoice, type ApplicationFactAnswerFormat, type ApplicationFactInput, FactAnswerFormatType, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationProductResult, type VerificationStatus };