@aiqa/sdk 2.0.0-develop.4 → 2.0.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/dist/browser/browser.d.ts +0 -9
- package/dist/browser/browser.js +2 -52
- package/dist/browser/browser.js.map +1 -1
- package/dist/node/node.d.ts +0 -9
- package/dist/node/node.js +2 -52
- package/dist/node/node.js.map +1 -1
- package/package.json +1 -1
|
@@ -285,13 +285,6 @@ declare class AiQaSdk implements IAiqaSdk {
|
|
|
285
285
|
internalListeners: Map<SdkEvent, Set<(...args: any[]) => void>>;
|
|
286
286
|
internalEvents: Set<SdkEvent>;
|
|
287
287
|
private wrappersByEvent;
|
|
288
|
-
/**
|
|
289
|
-
* Trailing-debounce window (ms) applied per fact in {@link addFact}. Defaults
|
|
290
|
-
* to {@link ADD_FACT_DEBOUNCE_MS}; set to 0 to disable debouncing and send
|
|
291
|
-
* every call immediately.
|
|
292
|
-
*/
|
|
293
|
-
addFactDebounceMs: number;
|
|
294
|
-
private pendingAddFacts;
|
|
295
288
|
constructor(applicationId: string, applicationSecret: string, url?: string);
|
|
296
289
|
on(name: SdkEvent, callback: (...args: any[]) => any): void;
|
|
297
290
|
off(name: SdkEvent, callback?: (...args: any[]) => any): void;
|
|
@@ -301,8 +294,6 @@ declare class AiQaSdk implements IAiqaSdk {
|
|
|
301
294
|
getApplication(): Promise<Application>;
|
|
302
295
|
getFacts(): Promise<ApplicationFact[]>;
|
|
303
296
|
addFact(fact: ApplicationFactInput): Promise<AddFactResult>;
|
|
304
|
-
private flushAddFact;
|
|
305
|
-
private sendAddFact;
|
|
306
297
|
flagFact(factId: string): Promise<FlagFactResult>;
|
|
307
298
|
setConversationProduct(product: string): Promise<SetConversationProductResult>;
|
|
308
299
|
setConversationLanguage(language: ConversationLanguage): Promise<SetConversationLanguageResult>;
|
package/dist/browser/browser.js
CHANGED
|
@@ -3397,7 +3397,7 @@ var compareVersions = (left, right) => {
|
|
|
3397
3397
|
// package.json
|
|
3398
3398
|
var package_default = {
|
|
3399
3399
|
name: "@aiqa/sdk",
|
|
3400
|
-
version: "2.
|
|
3400
|
+
version: "2.1.0-develop.1",
|
|
3401
3401
|
main: "dist/node/node.js",
|
|
3402
3402
|
module: "dist/node/node.js",
|
|
3403
3403
|
types: "dist/node/node.d.ts",
|
|
@@ -3479,7 +3479,6 @@ var package_default = {
|
|
|
3479
3479
|
var SDK_VERSION = package_default.version ?? "0.0.1";
|
|
3480
3480
|
var DEFAULT_URL = "ws://localhost:3025/ws";
|
|
3481
3481
|
var DEFAULT_TIMEOUT_MS = 6e4;
|
|
3482
|
-
var ADD_FACT_DEBOUNCE_MS = 500;
|
|
3483
3482
|
var RUNTIME = typeof window !== "undefined" && typeof window.document !== "undefined" ? "browser" : "node";
|
|
3484
3483
|
var USER_AGENT = RUNTIME === "browser" ? typeof navigator !== "undefined" ? navigator.userAgent : "browser/unknown" : typeof process !== "undefined" ? `node ${process.version} ${process.platform}` : "node/unknown";
|
|
3485
3484
|
function isThenable(value2) {
|
|
@@ -3525,15 +3524,6 @@ var AiQaSdk = class {
|
|
|
3525
3524
|
// same fn twice registers two wrappers and two off() calls clear
|
|
3526
3525
|
// both.
|
|
3527
3526
|
this.wrappersByEvent = /* @__PURE__ */ new Map();
|
|
3528
|
-
/**
|
|
3529
|
-
* Trailing-debounce window (ms) applied per fact in {@link addFact}. Defaults
|
|
3530
|
-
* to {@link ADD_FACT_DEBOUNCE_MS}; set to 0 to disable debouncing and send
|
|
3531
|
-
* every call immediately.
|
|
3532
|
-
*/
|
|
3533
|
-
this.addFactDebounceMs = ADD_FACT_DEBOUNCE_MS;
|
|
3534
|
-
// In-flight debounce state keyed by fact id: the pending timer, the latest
|
|
3535
|
-
// payload to send when it fires, and every caller awaiting that send.
|
|
3536
|
-
this.pendingAddFacts = /* @__PURE__ */ new Map();
|
|
3537
3527
|
this.url = url2 ?? DEFAULT_URL;
|
|
3538
3528
|
this.internalListeners = /* @__PURE__ */ new Map();
|
|
3539
3529
|
this.internalEvents = /* @__PURE__ */ new Set(["authenticated"]);
|
|
@@ -3660,13 +3650,6 @@ var AiQaSdk = class {
|
|
|
3660
3650
|
this.socket.disconnect();
|
|
3661
3651
|
}
|
|
3662
3652
|
this.wrappersByEvent.clear();
|
|
3663
|
-
for (const entry of this.pendingAddFacts.values()) {
|
|
3664
|
-
clearTimeout(entry.timer);
|
|
3665
|
-
entry.waiters.forEach(
|
|
3666
|
-
(w) => w.reject(new Error("Socket disconnected before addFact was sent"))
|
|
3667
|
-
);
|
|
3668
|
-
}
|
|
3669
|
-
this.pendingAddFacts.clear();
|
|
3670
3653
|
}
|
|
3671
3654
|
sendMessage(method, data) {
|
|
3672
3655
|
return new Promise((resolve, reject) => {
|
|
@@ -3716,40 +3699,7 @@ var AiQaSdk = class {
|
|
|
3716
3699
|
const result = await this.sendMessage("GET_FACTS" /* GET_FACTS */);
|
|
3717
3700
|
return result && result.data !== void 0 ? result.data : result;
|
|
3718
3701
|
}
|
|
3719
|
-
addFact(fact) {
|
|
3720
|
-
if (this.addFactDebounceMs <= 0) {
|
|
3721
|
-
return this.sendAddFact(fact);
|
|
3722
|
-
}
|
|
3723
|
-
const key = fact.questionId ?? fact.id;
|
|
3724
|
-
return new Promise((resolve, reject) => {
|
|
3725
|
-
const existing = this.pendingAddFacts.get(key);
|
|
3726
|
-
if (existing) {
|
|
3727
|
-
clearTimeout(existing.timer);
|
|
3728
|
-
existing.latest = fact;
|
|
3729
|
-
existing.waiters.push({ resolve, reject });
|
|
3730
|
-
existing.timer = setTimeout(
|
|
3731
|
-
() => this.flushAddFact(key),
|
|
3732
|
-
this.addFactDebounceMs
|
|
3733
|
-
);
|
|
3734
|
-
return;
|
|
3735
|
-
}
|
|
3736
|
-
this.pendingAddFacts.set(key, {
|
|
3737
|
-
latest: fact,
|
|
3738
|
-
waiters: [{ resolve, reject }],
|
|
3739
|
-
timer: setTimeout(() => this.flushAddFact(key), this.addFactDebounceMs)
|
|
3740
|
-
});
|
|
3741
|
-
});
|
|
3742
|
-
}
|
|
3743
|
-
flushAddFact(key) {
|
|
3744
|
-
const entry = this.pendingAddFacts.get(key);
|
|
3745
|
-
if (!entry) return;
|
|
3746
|
-
this.pendingAddFacts.delete(key);
|
|
3747
|
-
this.sendAddFact(entry.latest).then(
|
|
3748
|
-
(result) => entry.waiters.forEach((w) => w.resolve(result)),
|
|
3749
|
-
(error) => entry.waiters.forEach((w) => w.reject(error))
|
|
3750
|
-
);
|
|
3751
|
-
}
|
|
3752
|
-
async sendAddFact(fact) {
|
|
3702
|
+
async addFact(fact) {
|
|
3753
3703
|
const payload = {
|
|
3754
3704
|
...fact,
|
|
3755
3705
|
critical: fact.critical ?? false,
|