@aiqa/sdk 1.0.0-develop.2 → 1.0.0-develop.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/dist/browser/browser.d.ts +111 -0
- package/dist/browser/browser.js +3672 -0
- package/dist/browser/browser.js.map +1 -0
- package/dist/node/node.d.ts +111 -0
- package/dist/node/node.js +336 -0
- package/dist/node/node.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
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 emitInternal;
|
|
107
|
+
private createRequestId;
|
|
108
|
+
private isManagerEvent;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
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 };
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// src/shared.ts
|
|
2
|
+
import { io } from "socket.io-client";
|
|
3
|
+
|
|
4
|
+
// src/types.ts
|
|
5
|
+
var Methods = /* @__PURE__ */ ((Methods2) => {
|
|
6
|
+
Methods2["AUTHENTICATE"] = "AUTHENTICATE";
|
|
7
|
+
Methods2["GET_FACTS"] = "GET_FACTS";
|
|
8
|
+
Methods2["START_RECORDING"] = "START_RECORDING";
|
|
9
|
+
Methods2["STOP_RECORDING"] = "STOP_RECORDING";
|
|
10
|
+
Methods2["IS_RECORDING"] = "IS_RECORDING";
|
|
11
|
+
Methods2["ADD_FACT"] = "ADD_FACT";
|
|
12
|
+
Methods2["SET_CONVERSATION_PRODUCT"] = "SET_CONVERSATION_PRODUCT";
|
|
13
|
+
return Methods2;
|
|
14
|
+
})(Methods || {});
|
|
15
|
+
var FactAnswerFormatType = /* @__PURE__ */ ((FactAnswerFormatType2) => {
|
|
16
|
+
FactAnswerFormatType2["string"] = "STRING";
|
|
17
|
+
FactAnswerFormatType2["number"] = "NUMBER";
|
|
18
|
+
FactAnswerFormatType2["integer"] = "INT";
|
|
19
|
+
FactAnswerFormatType2["float"] = "FLOAT";
|
|
20
|
+
FactAnswerFormatType2["bool"] = "BOOL";
|
|
21
|
+
FactAnswerFormatType2["list"] = "LIST";
|
|
22
|
+
FactAnswerFormatType2["strict"] = "STRICT";
|
|
23
|
+
FactAnswerFormatType2["single_choice"] = "SINGLE_CHOICE";
|
|
24
|
+
FactAnswerFormatType2["multiple_choices"] = "MULTIPLE_CHOICES";
|
|
25
|
+
return FactAnswerFormatType2;
|
|
26
|
+
})(FactAnswerFormatType || {});
|
|
27
|
+
var IAiqaSdk = class {
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// src/utils/compareVersions.ts
|
|
31
|
+
var splitVersion = (value) => {
|
|
32
|
+
const [core] = value.split("-", 2);
|
|
33
|
+
return core.split(".").map((part) => Number(part));
|
|
34
|
+
};
|
|
35
|
+
var compareVersions = (left, right) => {
|
|
36
|
+
const leftParts = splitVersion(left);
|
|
37
|
+
const rightParts = splitVersion(right);
|
|
38
|
+
const maxLength = Math.max(leftParts.length, rightParts.length);
|
|
39
|
+
for (let i = 0; i < maxLength; i += 1) {
|
|
40
|
+
const l = leftParts[i] ?? 0;
|
|
41
|
+
const r = rightParts[i] ?? 0;
|
|
42
|
+
if (l > r) {
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
if (l < r) {
|
|
46
|
+
return -1;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return 0;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// package.json
|
|
53
|
+
var package_default = {
|
|
54
|
+
name: "@aiqa/sdk",
|
|
55
|
+
version: "1.0.0-develop.3",
|
|
56
|
+
main: "dist/node/node.js",
|
|
57
|
+
module: "dist/node/node.js",
|
|
58
|
+
types: "dist/node/node.d.ts",
|
|
59
|
+
engines: {
|
|
60
|
+
node: ">=18"
|
|
61
|
+
},
|
|
62
|
+
scripts: {
|
|
63
|
+
build: `tsup && node -e "const fs=require('fs');['dist/node/node','dist/browser/browser'].forEach(f=>{const mts=f+'.d.mts';const ts=f+'.d.ts';if(fs.existsSync(mts)){fs.renameSync(mts,ts);}});"`,
|
|
64
|
+
commitlint: "commitlint",
|
|
65
|
+
"dev:node": "tsx src/node.ts",
|
|
66
|
+
lint: "tsc --noEmit -p tsconfig.json",
|
|
67
|
+
format: 'prettier --check "{src,tests}/**/*.{ts,tsx,js,json,md,yml,yaml}" "*.{js,json,md,yml,yaml,ts}"',
|
|
68
|
+
release: "semantic-release",
|
|
69
|
+
"start:node": "node dist/node/node.js",
|
|
70
|
+
"serve:browser": "serve .",
|
|
71
|
+
test: "jest",
|
|
72
|
+
prepare: "husky"
|
|
73
|
+
},
|
|
74
|
+
exports: {
|
|
75
|
+
".": {
|
|
76
|
+
node: {
|
|
77
|
+
import: "./dist/node/node.js",
|
|
78
|
+
types: "./dist/node/node.d.ts"
|
|
79
|
+
},
|
|
80
|
+
browser: {
|
|
81
|
+
import: "./dist/browser/browser.js",
|
|
82
|
+
types: "./dist/browser/browser.d.ts"
|
|
83
|
+
},
|
|
84
|
+
default: "./dist/node/node.js"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
private: false,
|
|
88
|
+
license: "MIT",
|
|
89
|
+
author: "AIQA",
|
|
90
|
+
description: "TypeScript/JavaScript SDK for interacting with the AIQA.",
|
|
91
|
+
keywords: [
|
|
92
|
+
"aiqa",
|
|
93
|
+
"sdk"
|
|
94
|
+
],
|
|
95
|
+
files: [
|
|
96
|
+
"dist"
|
|
97
|
+
],
|
|
98
|
+
devDependencies: {
|
|
99
|
+
"@commitlint/cli": "^20.4.4",
|
|
100
|
+
"@commitlint/config-conventional": "^20.4.4",
|
|
101
|
+
"@jest/globals": "^29.7.0",
|
|
102
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
103
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
104
|
+
"@semantic-release/git": "^10.0.1",
|
|
105
|
+
"@semantic-release/npm": "^12.0.2",
|
|
106
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
107
|
+
"@types/node": "^22.0.0",
|
|
108
|
+
"conventional-changelog-conventionalcommits": "^9.3.0",
|
|
109
|
+
esbuild: "^0.23.0",
|
|
110
|
+
husky: "^9.1.7",
|
|
111
|
+
jest: "^29.7.0",
|
|
112
|
+
prettier: "^3.8.1",
|
|
113
|
+
"semantic-release": "^24.2.9",
|
|
114
|
+
serve: "^14.2.3",
|
|
115
|
+
"socket.io": "^4.7.5",
|
|
116
|
+
"ts-jest": "^29.2.3",
|
|
117
|
+
"ts-node": "^10.9.2",
|
|
118
|
+
tsup: "^8.0.0",
|
|
119
|
+
tsx: "^4.0.0",
|
|
120
|
+
typescript: "^5.7.0"
|
|
121
|
+
},
|
|
122
|
+
dependencies: {
|
|
123
|
+
"socket.io-client": "^4.7.5"
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// src/shared.ts
|
|
128
|
+
var SDK_VERSION = package_default.version ?? "0.0.1";
|
|
129
|
+
var DEFAULT_URL = "ws://localhost:3025/ws";
|
|
130
|
+
var DEFAULT_TIMEOUT_MS = 6e4;
|
|
131
|
+
var AiQaSdk = class {
|
|
132
|
+
constructor(applicationId, applicationSecret, url) {
|
|
133
|
+
this.socket = null;
|
|
134
|
+
this.url = url ?? DEFAULT_URL;
|
|
135
|
+
this.internalListeners = /* @__PURE__ */ new Map();
|
|
136
|
+
this.internalEvents = /* @__PURE__ */ new Set(["authenticated"]);
|
|
137
|
+
if (applicationId && applicationSecret) {
|
|
138
|
+
this.applicationId = applicationId;
|
|
139
|
+
this.applicationSecretKey = applicationSecret;
|
|
140
|
+
} else {
|
|
141
|
+
throw new Error("Application id and application secret are required");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
on(name, callback) {
|
|
145
|
+
if (this.internalEvents.has(name)) {
|
|
146
|
+
if (!this.internalListeners.has(name)) {
|
|
147
|
+
this.internalListeners.set(name, /* @__PURE__ */ new Set());
|
|
148
|
+
}
|
|
149
|
+
this.internalListeners.get(name).add(callback);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (!this.socket) {
|
|
153
|
+
throw new Error("Not connected");
|
|
154
|
+
}
|
|
155
|
+
if (this.isManagerEvent(name)) {
|
|
156
|
+
this.socket.io.on(name, callback);
|
|
157
|
+
} else {
|
|
158
|
+
this.socket.on(name, callback);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
off(name, callback) {
|
|
162
|
+
if (this.internalEvents.has(name)) {
|
|
163
|
+
if (!callback) {
|
|
164
|
+
this.internalListeners.delete(name);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const handlers = this.internalListeners.get(name);
|
|
168
|
+
if (handlers) {
|
|
169
|
+
handlers.delete(callback);
|
|
170
|
+
if (handlers.size === 0) {
|
|
171
|
+
this.internalListeners.delete(name);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!this.socket) {
|
|
177
|
+
throw new Error("Not connected");
|
|
178
|
+
}
|
|
179
|
+
if (this.isManagerEvent(name)) {
|
|
180
|
+
this.socket.io.off(name, callback);
|
|
181
|
+
} else {
|
|
182
|
+
this.socket.off(name, callback);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
connect() {
|
|
186
|
+
if (!this.url) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const url = new URL(this.url);
|
|
190
|
+
const socketOptions = {
|
|
191
|
+
reconnectionDelayMax: 1e4,
|
|
192
|
+
path: url.pathname
|
|
193
|
+
};
|
|
194
|
+
this.socket = io(url.origin, socketOptions);
|
|
195
|
+
this.socket.on("connect", () => {
|
|
196
|
+
this.authenticate();
|
|
197
|
+
});
|
|
198
|
+
this.socket.on("app_version", (payload) => {
|
|
199
|
+
let versionRange = payload;
|
|
200
|
+
if (typeof payload === "string") {
|
|
201
|
+
try {
|
|
202
|
+
versionRange = JSON.parse(payload);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
versionRange = payload;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
const minVersion = versionRange?.min;
|
|
208
|
+
const maxVersion = versionRange?.max;
|
|
209
|
+
if (minVersion || maxVersion) {
|
|
210
|
+
const tooLow = minVersion ? compareVersions(SDK_VERSION, minVersion) < 0 : false;
|
|
211
|
+
const tooHigh = maxVersion ? compareVersions(SDK_VERSION, maxVersion) > 0 : false;
|
|
212
|
+
if (tooLow || tooHigh) {
|
|
213
|
+
const error = new Error(
|
|
214
|
+
`SDK version ${SDK_VERSION} is not supported. Supported range: ${minVersion || "-"} to ${maxVersion || "-"}.`
|
|
215
|
+
);
|
|
216
|
+
this.socket.disconnect();
|
|
217
|
+
this.socket.emit("error", error);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
disconnect() {
|
|
223
|
+
if (this.socket) {
|
|
224
|
+
this.socket.disconnect();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
sendMessage(method, data) {
|
|
228
|
+
return new Promise((resolve, reject) => {
|
|
229
|
+
if (!this.socket || !this.socket.connected) {
|
|
230
|
+
reject(new Error("Socket is not connected"));
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
const requestId = this.createRequestId();
|
|
234
|
+
let timeout;
|
|
235
|
+
const handler = (payload2) => {
|
|
236
|
+
if (timeout) {
|
|
237
|
+
clearTimeout(timeout);
|
|
238
|
+
}
|
|
239
|
+
this.socket.off(requestId, handler);
|
|
240
|
+
let parsed = payload2;
|
|
241
|
+
if (typeof payload2 === "string") {
|
|
242
|
+
try {
|
|
243
|
+
parsed = JSON.parse(payload2);
|
|
244
|
+
} catch (error) {
|
|
245
|
+
parsed = payload2;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (parsed && parsed.error !== void 0) {
|
|
249
|
+
reject(parsed.error);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
resolve(parsed && parsed.data !== void 0 ? parsed.data : parsed);
|
|
253
|
+
};
|
|
254
|
+
this.socket.on(requestId, handler);
|
|
255
|
+
const payload = data && typeof data === "object" ? { ...data, requestId } : { requestId, data };
|
|
256
|
+
this.socket.emit(method, JSON.stringify(payload));
|
|
257
|
+
timeout = setTimeout(() => {
|
|
258
|
+
this.socket.off(requestId, handler);
|
|
259
|
+
reject(new Error(`Request timed out for ${method}`));
|
|
260
|
+
}, DEFAULT_TIMEOUT_MS);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
async getApplication() {
|
|
264
|
+
if (this.cachedApplication) {
|
|
265
|
+
return this.cachedApplication;
|
|
266
|
+
}
|
|
267
|
+
throw new Error(
|
|
268
|
+
"Application is not available yet. Wait for authentication to complete."
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
async getFacts() {
|
|
272
|
+
const result = await this.sendMessage("GET_FACTS" /* GET_FACTS */);
|
|
273
|
+
return result && result.data !== void 0 ? result.data : result;
|
|
274
|
+
}
|
|
275
|
+
async addFact(fact) {
|
|
276
|
+
const payload = {
|
|
277
|
+
...fact,
|
|
278
|
+
critical: fact.critical ?? false,
|
|
279
|
+
is_skipped: fact.is_skipped ?? false
|
|
280
|
+
};
|
|
281
|
+
const result = await this.sendMessage("ADD_FACT" /* ADD_FACT */, payload);
|
|
282
|
+
return result && result.data !== void 0 ? result.data : result;
|
|
283
|
+
}
|
|
284
|
+
async setConversationProduct(product) {
|
|
285
|
+
const result = await this.sendMessage("SET_CONVERSATION_PRODUCT" /* SET_CONVERSATION_PRODUCT */, {
|
|
286
|
+
product
|
|
287
|
+
});
|
|
288
|
+
return result && result.data !== void 0 ? result.data : result;
|
|
289
|
+
}
|
|
290
|
+
async authenticate() {
|
|
291
|
+
try {
|
|
292
|
+
const result = await this.sendMessage("AUTHENTICATE" /* AUTHENTICATE */, {
|
|
293
|
+
applicationId: this.applicationId,
|
|
294
|
+
applicationSecretKey: this.applicationSecretKey
|
|
295
|
+
});
|
|
296
|
+
const application = result && result.data !== void 0 ? result.data : result;
|
|
297
|
+
this.cachedApplication = application;
|
|
298
|
+
this.emitInternal("authenticated", application);
|
|
299
|
+
} catch (error) {
|
|
300
|
+
this.socket.emit("error", error);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
async startRecording() {
|
|
304
|
+
const result = await this.sendMessage("START_RECORDING" /* START_RECORDING */);
|
|
305
|
+
return result && result.data !== void 0 ? result.data : result;
|
|
306
|
+
}
|
|
307
|
+
async stopRecording() {
|
|
308
|
+
const result = await this.sendMessage("STOP_RECORDING" /* STOP_RECORDING */);
|
|
309
|
+
return result && result.data !== void 0 ? result.data : result;
|
|
310
|
+
}
|
|
311
|
+
async isRecordingNow() {
|
|
312
|
+
const result = await this.sendMessage("IS_RECORDING" /* IS_RECORDING */);
|
|
313
|
+
return result && result.data !== void 0 ? result.data : result;
|
|
314
|
+
}
|
|
315
|
+
emitInternal(name, ...args) {
|
|
316
|
+
const handlers = this.internalListeners.get(name);
|
|
317
|
+
if (!handlers) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
handlers.forEach((handler) => handler(...args));
|
|
321
|
+
}
|
|
322
|
+
createRequestId() {
|
|
323
|
+
return `req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
324
|
+
}
|
|
325
|
+
isManagerEvent(name) {
|
|
326
|
+
return name === "reconnect_attempt" || name === "reconnect_error" || name === "reconnect_failed" || name === "error";
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
var shared_default = AiQaSdk;
|
|
330
|
+
export {
|
|
331
|
+
shared_default as AiQaSdk,
|
|
332
|
+
FactAnswerFormatType,
|
|
333
|
+
IAiqaSdk,
|
|
334
|
+
Methods
|
|
335
|
+
};
|
|
336
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/shared.ts","../../src/types.ts","../../src/utils/compareVersions.ts","../../package.json"],"sourcesContent":["import { io, Socket } from \"socket.io-client\";\nimport {\n Methods,\n Application,\n ApplicationFact,\n ApplicationFactInput,\n SdkEvent,\n IAiqaSdk,\n AddFactResult,\n SetConversationProductResult,\n} from \"./types.js\";\nimport { compareVersions } from \"./utils/compareVersions.js\";\n// @ts-ignore - compiled builds resolve this at build time\nimport pkg from \"../package.json\";\n\nconst SDK_VERSION = (pkg as { version?: string }).version ?? \"0.0.1\";\nconst DEFAULT_URL = \"ws://localhost:3025/ws\";\nconst DEFAULT_TIMEOUT_MS = 60000; // 1 minute\n\nclass AiQaSdk implements IAiqaSdk {\n socket: Socket | null = null;\n url: string;\n applicationId: string;\n applicationSecretKey: string;\n cachedApplication?: Application;\n internalListeners: Map<SdkEvent, Set<(...args: any[]) => void>>;\n internalEvents: Set<SdkEvent>;\n\n constructor(applicationId: string, applicationSecret: string, url?: string) {\n this.url = url ?? DEFAULT_URL;\n this.internalListeners = new Map();\n this.internalEvents = new Set([\"authenticated\"]);\n\n if (applicationId && applicationSecret) {\n this.applicationId = applicationId;\n this.applicationSecretKey = applicationSecret;\n } else {\n throw new Error(\"Application id and application secret are required\");\n }\n }\n\n on(name: SdkEvent, callback: (...args: any[]) => any) {\n if (this.internalEvents.has(name)) {\n if (!this.internalListeners.has(name)) {\n this.internalListeners.set(name, new Set());\n }\n this.internalListeners.get(name)!.add(callback);\n return;\n }\n\n if (!this.socket) {\n throw new Error(\"Not connected\");\n }\n\n if (this.isManagerEvent(name)) {\n this.socket.io.on(name, callback);\n } else {\n this.socket.on(name, callback);\n }\n }\n\n off(name: SdkEvent, callback?: (...args: any[]) => any) {\n if (this.internalEvents.has(name)) {\n if (!callback) {\n this.internalListeners.delete(name);\n return;\n }\n const handlers = this.internalListeners.get(name);\n if (handlers) {\n handlers.delete(callback);\n if (handlers.size === 0) {\n this.internalListeners.delete(name);\n }\n }\n return;\n }\n\n if (!this.socket) {\n throw new Error(\"Not connected\");\n }\n\n if (this.isManagerEvent(name)) {\n this.socket.io.off(name, callback);\n } else {\n this.socket.off(name, callback);\n }\n }\n\n connect() {\n if (!this.url) {\n return;\n }\n\n const url = new URL(this.url);\n\n const socketOptions: any = {\n reconnectionDelayMax: 10000,\n path: url.pathname,\n };\n\n this.socket = io(url.origin, socketOptions);\n\n this.socket.on(\"connect\", () => {\n this.authenticate();\n });\n\n this.socket.on(\"app_version\", (payload: any) => {\n let versionRange = payload;\n if (typeof payload === \"string\") {\n try {\n versionRange = JSON.parse(payload);\n } catch (error) {\n versionRange = payload;\n }\n }\n\n const minVersion = versionRange?.min;\n const maxVersion = versionRange?.max;\n\n if (minVersion || maxVersion) {\n const tooLow = minVersion\n ? compareVersions(SDK_VERSION, minVersion) < 0\n : false;\n const tooHigh = maxVersion\n ? compareVersions(SDK_VERSION, maxVersion) > 0\n : false;\n if (tooLow || tooHigh) {\n const error = new Error(\n `SDK version ${SDK_VERSION} is not supported. Supported range: ${minVersion || \"-\"} to ${maxVersion || \"-\"}.`,\n );\n this.socket!.disconnect();\n this.socket!.emit(\"error\", error);\n }\n }\n });\n }\n\n disconnect() {\n if (this.socket) {\n this.socket.disconnect();\n }\n }\n\n sendMessage(method: Methods, data?: any): Promise<any> {\n return new Promise((resolve, reject) => {\n if (!this.socket || !this.socket.connected) {\n reject(new Error(\"Socket is not connected\"));\n return;\n }\n\n const requestId = this.createRequestId();\n let timeout: ReturnType<typeof setTimeout> | undefined;\n const handler = (payload: any) => {\n if (timeout) {\n clearTimeout(timeout);\n }\n this.socket!.off(requestId, handler);\n let parsed = payload;\n if (typeof payload === \"string\") {\n try {\n parsed = JSON.parse(payload);\n } catch (error) {\n parsed = payload;\n }\n }\n\n if (parsed && parsed.error !== undefined) {\n reject(parsed.error);\n return;\n }\n\n resolve(parsed && parsed.data !== undefined ? parsed.data : parsed);\n };\n\n this.socket.on(requestId, handler);\n\n const payload =\n data && typeof data === \"object\"\n ? { ...data, requestId }\n : { requestId, data };\n this.socket.emit(method, JSON.stringify(payload));\n\n timeout = setTimeout(() => {\n this.socket!.off(requestId, handler);\n reject(new Error(`Request timed out for ${method}`));\n }, DEFAULT_TIMEOUT_MS);\n });\n }\n\n async getApplication(): Promise<Application> {\n if (this.cachedApplication) {\n return this.cachedApplication;\n }\n throw new Error(\n \"Application is not available yet. Wait for authentication to complete.\",\n );\n }\n\n async getFacts(): Promise<ApplicationFact[]> {\n const result = await this.sendMessage(Methods.GET_FACTS);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async addFact(fact: ApplicationFactInput): Promise<AddFactResult> {\n const payload = {\n ...fact,\n critical: fact.critical ?? false,\n is_skipped: fact.is_skipped ?? false,\n };\n const result = await this.sendMessage(Methods.ADD_FACT, payload);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async setConversationProduct(\n product: string,\n ): Promise<SetConversationProductResult> {\n const result = await this.sendMessage(Methods.SET_CONVERSATION_PRODUCT, {\n product,\n });\n return result && result.data !== undefined ? result.data : result;\n }\n\n async authenticate(): Promise<void> {\n try {\n const result = await this.sendMessage(Methods.AUTHENTICATE, {\n applicationId: this.applicationId,\n applicationSecretKey: this.applicationSecretKey,\n });\n\n const application =\n result && result.data !== undefined ? result.data : result;\n\n this.cachedApplication = application;\n\n this.emitInternal(\"authenticated\", application);\n } catch (error) {\n this.socket!.emit(\"error\", error);\n }\n }\n\n async startRecording(): Promise<boolean> {\n const result = await this.sendMessage(Methods.START_RECORDING);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async stopRecording(): Promise<boolean> {\n const result = await this.sendMessage(Methods.STOP_RECORDING);\n return result && result.data !== undefined ? result.data : result;\n }\n\n async isRecordingNow(): Promise<boolean> {\n // @TODO: track it from the server, should be sent on successfull connect\n const result = await this.sendMessage(Methods.IS_RECORDING);\n return result && result.data !== undefined ? result.data : result;\n }\n\n private emitInternal(name: SdkEvent, ...args: any[]) {\n const handlers = this.internalListeners.get(name);\n if (!handlers) {\n return;\n }\n handlers.forEach((handler) => handler(...args));\n }\n\n private createRequestId() {\n return `req_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;\n }\n\n private isManagerEvent(name: SdkEvent) {\n return (\n name === \"reconnect_attempt\" ||\n name === \"reconnect_error\" ||\n name === \"reconnect_failed\" ||\n name === \"error\"\n );\n }\n}\n\nexport default AiQaSdk;\n","export type Application = {\n application_id: string;\n client_name: string;\n client_phone_number: string;\n agent_id: string;\n agent_first_name: string;\n agent_last_name: string;\n};\n\nexport enum Methods {\n AUTHENTICATE = \"AUTHENTICATE\",\n GET_FACTS = \"GET_FACTS\",\n START_RECORDING = \"START_RECORDING\",\n STOP_RECORDING = \"STOP_RECORDING\",\n IS_RECORDING = \"IS_RECORDING\",\n ADD_FACT = \"ADD_FACT\",\n SET_CONVERSATION_PRODUCT = \"SET_CONVERSATION_PRODUCT\",\n}\n\nexport type SetConversationProductResult = {\n success: boolean;\n product: string;\n};\n\nexport type SdkEvent =\n | Methods\n | \"connect\"\n | \"disconnect\"\n | \"close\"\n | \"error\"\n | \"reconnect_attempt\"\n | \"reconnect_error\"\n | \"reconnect_failed\"\n | \"authenticated\"\n | \"app_version\";\n\nexport enum FactAnswerFormatType {\n string = \"STRING\",\n number = \"NUMBER\",\n integer = \"INT\",\n float = \"FLOAT\",\n bool = \"BOOL\",\n list = \"LIST\",\n strict = \"STRICT\",\n single_choice = \"SINGLE_CHOICE\",\n multiple_choices = \"MULTIPLE_CHOICES\",\n}\n\nexport type ApplicationFactAnswerChoice = {\n key: string;\n text: string;\n};\n\nexport type ApplicationFactAnswerFormat = {\n type: FactAnswerFormatType;\n choices?: ApplicationFactAnswerChoice[];\n};\n\nexport type ApplicationFactInput = {\n id: string;\n question: string;\n expected_answer: any;\n answer_format: ApplicationFactAnswerFormat;\n\n category_id?: string;\n category_name?: string;\n language?: string;\n\n critical?: boolean;\n is_skipped?: boolean;\n};\n\nexport type QuestionStatus = \"searching\" | \"asked\" | \"not_asked\";\n\nexport type VerificationStatus = \"processing\" | \"matched\" | \"unmatched\";\n\nexport type ApplicationFact = ApplicationFactInput & {\n ai_answer?: any;\n question_status: QuestionStatus;\n verification_status: VerificationStatus;\n};\n\nexport interface AddFactResult {\n agent_answer?: string;\n ai_answer?: string;\n is_valid_answer: boolean;\n question_asked?: boolean;\n}\n\nexport type SdkError = {\n code:\n | \"INVALID_CONFIG\"\n | \"CONNECTION_ERROR\"\n | \"TIMEOUT\"\n | \"SERVER_ERROR\"\n | \"UNEXPECTED_RESPONSE\";\n message: string;\n details?: any;\n};\n\nexport abstract class IAiqaSdk {\n abstract connect(): void;\n abstract disconnect(): void;\n\n abstract on(eventName: string, callback: (...args: any[]) => any): void;\n abstract off(eventName: string): void;\n\n abstract getApplication(): Promise<Application>;\n abstract addFact(fact: ApplicationFactInput): Promise<AddFactResult>;\n abstract getFacts(): Promise<ApplicationFact[]>;\n abstract setConversationProduct(\n product: string,\n ): Promise<SetConversationProductResult>;\n}\n","const splitVersion = (value: string) => {\n const [core] = value.split(\"-\", 2);\n return core.split(\".\").map((part) => Number(part));\n};\n\nexport const compareVersions = (left: string, right: string): number => {\n const leftParts = splitVersion(left);\n const rightParts = splitVersion(right);\n const maxLength = Math.max(leftParts.length, rightParts.length);\n\n for (let i = 0; i < maxLength; i += 1) {\n const l = leftParts[i] ?? 0;\n const r = rightParts[i] ?? 0;\n if (l > r) {\n return 1;\n }\n if (l < r) {\n return -1;\n }\n }\n\n return 0;\n};\n","{\n \"name\": \"@aiqa/sdk\",\n \"version\": \"1.0.0-develop.3\",\n \"main\": \"dist/node/node.js\",\n \"module\": \"dist/node/node.js\",\n \"types\": \"dist/node/node.d.ts\",\n \"engines\": {\n \"node\": \">=18\"\n },\n \"scripts\": {\n \"build\": \"tsup && node -e \\\"const fs=require('fs');['dist/node/node','dist/browser/browser'].forEach(f=>{const mts=f+'.d.mts';const ts=f+'.d.ts';if(fs.existsSync(mts)){fs.renameSync(mts,ts);}});\\\"\",\n \"commitlint\": \"commitlint\",\n \"dev:node\": \"tsx src/node.ts\",\n \"lint\": \"tsc --noEmit -p tsconfig.json\",\n \"format\": \"prettier --check \\\"{src,tests}/**/*.{ts,tsx,js,json,md,yml,yaml}\\\" \\\"*.{js,json,md,yml,yaml,ts}\\\"\",\n \"release\": \"semantic-release\",\n \"start:node\": \"node dist/node/node.js\",\n \"serve:browser\": \"serve .\",\n \"test\": \"jest\",\n \"prepare\": \"husky\"\n },\n \"exports\": {\n \".\": {\n \"node\": {\n \"import\": \"./dist/node/node.js\",\n \"types\": \"./dist/node/node.d.ts\"\n },\n \"browser\": {\n \"import\": \"./dist/browser/browser.js\",\n \"types\": \"./dist/browser/browser.d.ts\"\n },\n \"default\": \"./dist/node/node.js\"\n }\n },\n \"private\": false,\n \"license\": \"MIT\",\n \"author\": \"AIQA\",\n \"description\": \"TypeScript/JavaScript SDK for interacting with the AIQA.\",\n \"keywords\": [\n \"aiqa\",\n \"sdk\"\n ],\n \"files\": [\n \"dist\"\n ],\n \"devDependencies\": {\n \"@commitlint/cli\": \"^20.4.4\",\n \"@commitlint/config-conventional\": \"^20.4.4\",\n \"@jest/globals\": \"^29.7.0\",\n \"@semantic-release/changelog\": \"^6.0.3\",\n \"@semantic-release/commit-analyzer\": \"^13.0.1\",\n \"@semantic-release/git\": \"^10.0.1\",\n \"@semantic-release/npm\": \"^12.0.2\",\n \"@semantic-release/release-notes-generator\": \"^14.1.0\",\n \"@types/node\": \"^22.0.0\",\n \"conventional-changelog-conventionalcommits\": \"^9.3.0\",\n \"esbuild\": \"^0.23.0\",\n \"husky\": \"^9.1.7\",\n \"jest\": \"^29.7.0\",\n \"prettier\": \"^3.8.1\",\n \"semantic-release\": \"^24.2.9\",\n \"serve\": \"^14.2.3\",\n \"socket.io\": \"^4.7.5\",\n \"ts-jest\": \"^29.2.3\",\n \"ts-node\": \"^10.9.2\",\n \"tsup\": \"^8.0.0\",\n \"tsx\": \"^4.0.0\",\n \"typescript\": \"^5.7.0\"\n },\n \"dependencies\": {\n \"socket.io-client\": \"^4.7.5\"\n }\n}\n"],"mappings":";AAAA,SAAS,UAAkB;;;ACSpB,IAAK,UAAL,kBAAKA,aAAL;AACL,EAAAA,SAAA,kBAAe;AACf,EAAAA,SAAA,eAAY;AACZ,EAAAA,SAAA,qBAAkB;AAClB,EAAAA,SAAA,oBAAiB;AACjB,EAAAA,SAAA,kBAAe;AACf,EAAAA,SAAA,cAAW;AACX,EAAAA,SAAA,8BAA2B;AAPjB,SAAAA;AAAA,GAAA;AA2BL,IAAK,uBAAL,kBAAKC,0BAAL;AACL,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,aAAU;AACV,EAAAA,sBAAA,WAAQ;AACR,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,YAAS;AACT,EAAAA,sBAAA,mBAAgB;AAChB,EAAAA,sBAAA,sBAAmB;AATT,SAAAA;AAAA,GAAA;AAgEL,IAAe,WAAf,MAAwB;AAa/B;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