@aiqa/sdk 2.1.0-develop.1 → 2.1.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.
package/README.md CHANGED
@@ -140,14 +140,33 @@ change.
140
140
  **Parameters:**
141
141
 
142
142
  - `input: UpdateConversationInput` - partial set of conversation fields to update
143
- - `policyNumber?: string` - non-empty; surrounding whitespace is trimmed
143
+
144
+ | field | type | max | notes |
145
+ | --------------------------- | ---------- | -------- | ------------------------------------------- |
146
+ | `policyNumber` | `string` | 128 | |
147
+ | `insuredPhone` | `string` | 32 | the insured, who may differ from the caller |
148
+ | `clientName` | `string` | 128 | |
149
+ | `clientPhone` | `string` | 32 | |
150
+ | `clientEmail` | `string` | 254 | must be a valid email address |
151
+ | `clientId` | `string` | 64 | your own CRM identifier |
152
+ | `agentId` / `agentName` | `string` | 64/128 | |
153
+ | `advisorId` / `advisorName` | `string` | 64/128 | |
154
+ | `agentGroups` | `string[]` | 32 × 128 | entries cannot contain a comma |
155
+
156
+ Every string (including each `agentGroups` entry) must be non-empty;
157
+ surrounding whitespace is trimmed. `null` is rejected — omit the field
158
+ instead. At least one field is required.
144
159
 
145
160
  **Returns:**
146
161
 
147
- - `Promise<{ success: boolean; conversation: { policy_number?: string } }>`
162
+ - `Promise<UpdateConversationResult>` - `conversation` echoes only the fields
163
+ you sent.
148
164
 
149
165
  ```typescript
150
- const result = await sdk.updateConversation({ policyNumber: "POL-123" });
166
+ const result = await sdk.updateConversation({
167
+ policyNumber: "POL-123",
168
+ clientEmail: "jane@example.com",
169
+ });
151
170
  console.log(result.success, result.conversation.policy_number);
152
171
  ```
153
172
 
@@ -592,18 +611,39 @@ Partial set of conversation fields accepted by `updateConversation()`.
592
611
  ```typescript
593
612
  type UpdateConversationInput = {
594
613
  policyNumber?: string;
614
+ insuredPhone?: string;
615
+ clientName?: string;
616
+ clientPhone?: string;
617
+ clientEmail?: string;
618
+ clientId?: string;
619
+ agentId?: string;
620
+ agentName?: string;
621
+ advisorId?: string;
622
+ advisorName?: string;
623
+ agentGroups?: string[];
595
624
  };
596
625
  ```
597
626
 
598
627
  ### UpdateConversationResult
599
628
 
600
- Returned by `updateConversation()`.
629
+ Returned by `updateConversation()`. `conversation` echoes only the fields you
630
+ sent.
601
631
 
602
632
  ```typescript
603
633
  type UpdateConversationResult = {
604
634
  success: boolean;
605
635
  conversation: {
606
636
  policy_number?: string;
637
+ insured_phone?: string;
638
+ client_name?: string;
639
+ client_phone?: string;
640
+ client_email?: string;
641
+ client_id?: string;
642
+ agent_id?: string;
643
+ agent_name?: string;
644
+ advisor_id?: string;
645
+ advisor_name?: string;
646
+ agent_groups?: string[];
607
647
  };
608
648
  };
609
649
  ```
@@ -30,11 +30,32 @@ type SetConversationLanguageResult = {
30
30
  };
31
31
  type UpdateConversationInput = {
32
32
  policyNumber?: string;
33
+ insuredPhone?: string;
34
+ clientName?: string;
35
+ clientPhone?: string;
36
+ clientEmail?: string;
37
+ clientId?: string;
38
+ agentId?: string;
39
+ agentName?: string;
40
+ advisorId?: string;
41
+ advisorName?: string;
42
+ agentGroups?: string[];
33
43
  };
44
+ /** Echo of the patched subset — only the fields you sent come back. */
34
45
  type UpdateConversationResult = {
35
46
  success: boolean;
36
47
  conversation: {
37
48
  policy_number?: string;
49
+ insured_phone?: string;
50
+ client_name?: string;
51
+ client_phone?: string;
52
+ client_email?: string;
53
+ client_id?: string;
54
+ agent_id?: string;
55
+ agent_name?: string;
56
+ advisor_id?: string;
57
+ advisor_name?: string;
58
+ agent_groups?: string[];
38
59
  };
39
60
  };
40
61
  declare enum ConversationLanguage {
@@ -285,13 +306,6 @@ declare class AiQaSdk implements IAiqaSdk {
285
306
  internalListeners: Map<SdkEvent, Set<(...args: any[]) => void>>;
286
307
  internalEvents: Set<SdkEvent>;
287
308
  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
309
  constructor(applicationId: string, applicationSecret: string, url?: string);
296
310
  on(name: SdkEvent, callback: (...args: any[]) => any): void;
297
311
  off(name: SdkEvent, callback?: (...args: any[]) => any): void;
@@ -301,8 +315,6 @@ declare class AiQaSdk implements IAiqaSdk {
301
315
  getApplication(): Promise<Application>;
302
316
  getFacts(): Promise<ApplicationFact[]>;
303
317
  addFact(fact: ApplicationFactInput): Promise<AddFactResult>;
304
- private flushAddFact;
305
- private sendAddFact;
306
318
  flagFact(factId: string): Promise<FlagFactResult>;
307
319
  setConversationProduct(product: string): Promise<SetConversationProductResult>;
308
320
  setConversationLanguage(language: ConversationLanguage): Promise<SetConversationLanguageResult>;
@@ -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.0.0",
3400
+ version: "2.1.0-develop.2",
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,