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

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
@@ -89,6 +89,42 @@ If authentication hasn't completed yet, this throws. Use the `authenticated` eve
89
89
  const application = await sdk.getApplication();
90
90
  ```
91
91
 
92
+ #### `setConversationProduct(product)`
93
+
94
+ Sets the conversation product using a valid product code.
95
+
96
+ **Parameters:**
97
+
98
+ - `product: string` - product code (from the `service.code` catalog)
99
+
100
+ **Returns:**
101
+
102
+ - `Promise<{ success: boolean; product: string }>`
103
+
104
+ ```typescript
105
+ const result = await sdk.setConversationProduct("life_insurance");
106
+ console.log(result.success, result.product);
107
+ ```
108
+
109
+ #### `setConversationLanguage(language)`
110
+
111
+ Sets the conversation language.
112
+
113
+ **Parameters:**
114
+
115
+ - `language: ConversationLanguage` - only valid enum values are accepted
116
+
117
+ **Returns:**
118
+
119
+ - `Promise<{ success: boolean; language: string }>`
120
+
121
+ ```typescript
122
+ import { ConversationLanguage } from "@aiqa/sdk";
123
+
124
+ const result = await sdk.setConversationLanguage(ConversationLanguage.EN);
125
+ console.log(result.success, result.language);
126
+ ```
127
+
92
128
  ### Fact Management
93
129
 
94
130
  #### `addFact(fact)`
@@ -242,6 +278,16 @@ type ApplicationFactInput = {
242
278
  };
243
279
  ```
244
280
 
281
+ ### ConversationLanguage
282
+
283
+ ```typescript
284
+ enum ConversationLanguage {
285
+ EN = "en",
286
+ ES = "es",
287
+ FR = "fr",
288
+ }
289
+ ```
290
+
245
291
  ### FactUpdateEvent
246
292
 
247
293
  ```typescript
@@ -15,12 +15,22 @@ declare enum Methods {
15
15
  STOP_RECORDING = "STOP_RECORDING",
16
16
  IS_RECORDING = "IS_RECORDING",
17
17
  ADD_FACT = "ADD_FACT",
18
- SET_CONVERSATION_PRODUCT = "SET_CONVERSATION_PRODUCT"
18
+ SET_CONVERSATION_PRODUCT = "SET_CONVERSATION_PRODUCT",
19
+ SET_CONVERSATION_LANGUAGE = "SET_CONVERSATION_LANGUAGE"
19
20
  }
20
21
  type SetConversationProductResult = {
21
22
  success: boolean;
22
23
  product: string;
23
24
  };
25
+ type SetConversationLanguageResult = {
26
+ success: boolean;
27
+ language: string;
28
+ };
29
+ declare enum ConversationLanguage {
30
+ EN = "en",
31
+ ES = "es",
32
+ FR = "fr"
33
+ }
24
34
  type SdkEvent = Methods | "connect" | "disconnect" | "close" | "error" | "reconnect_attempt" | "reconnect_error" | "reconnect_failed" | "authenticated" | "app_version";
25
35
  declare enum FactAnswerFormatType {
26
36
  string = "STRING",
@@ -79,6 +89,7 @@ declare abstract class IAiqaSdk {
79
89
  abstract addFact(fact: ApplicationFactInput): Promise<AddFactResult>;
80
90
  abstract getFacts(): Promise<ApplicationFact[]>;
81
91
  abstract setConversationProduct(product: string): Promise<SetConversationProductResult>;
92
+ abstract setConversationLanguage(language: ConversationLanguage): Promise<SetConversationLanguageResult>;
82
93
  }
83
94
 
84
95
  declare class AiQaSdk implements IAiqaSdk {
@@ -99,14 +110,14 @@ declare class AiQaSdk implements IAiqaSdk {
99
110
  getFacts(): Promise<ApplicationFact[]>;
100
111
  addFact(fact: ApplicationFactInput): Promise<AddFactResult>;
101
112
  setConversationProduct(product: string): Promise<SetConversationProductResult>;
113
+ setConversationLanguage(language: ConversationLanguage): Promise<SetConversationLanguageResult>;
102
114
  authenticate(): Promise<void>;
103
115
  startRecording(): Promise<boolean>;
104
116
  stopRecording(): Promise<boolean>;
105
117
  isRecordingNow(): Promise<boolean>;
106
- private compareVersions;
107
118
  private emitInternal;
108
119
  private createRequestId;
109
120
  private isManagerEvent;
110
121
  }
111
122
 
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 };
123
+ export { type AddFactResult, AiQaSdk, type Application, type ApplicationFact, type ApplicationFactAnswerChoice, type ApplicationFactAnswerFormat, type ApplicationFactInput, ConversationLanguage, FactAnswerFormatType, IAiqaSdk, Methods, type QuestionStatus, type SdkError, type SdkEvent, type SetConversationLanguageResult, type SetConversationProductResult, type VerificationStatus };
@@ -3346,8 +3346,15 @@ var Methods = /* @__PURE__ */ ((Methods2) => {
3346
3346
  Methods2["IS_RECORDING"] = "IS_RECORDING";
3347
3347
  Methods2["ADD_FACT"] = "ADD_FACT";
3348
3348
  Methods2["SET_CONVERSATION_PRODUCT"] = "SET_CONVERSATION_PRODUCT";
3349
+ Methods2["SET_CONVERSATION_LANGUAGE"] = "SET_CONVERSATION_LANGUAGE";
3349
3350
  return Methods2;
3350
3351
  })(Methods || {});
3352
+ var ConversationLanguage = /* @__PURE__ */ ((ConversationLanguage3) => {
3353
+ ConversationLanguage3["EN"] = "en";
3354
+ ConversationLanguage3["ES"] = "es";
3355
+ ConversationLanguage3["FR"] = "fr";
3356
+ return ConversationLanguage3;
3357
+ })(ConversationLanguage || {});
3351
3358
  var FactAnswerFormatType = /* @__PURE__ */ ((FactAnswerFormatType2) => {
3352
3359
  FactAnswerFormatType2["string"] = "STRING";
3353
3360
  FactAnswerFormatType2["number"] = "NUMBER";
@@ -3363,10 +3370,32 @@ var FactAnswerFormatType = /* @__PURE__ */ ((FactAnswerFormatType2) => {
3363
3370
  var IAiqaSdk = class {
3364
3371
  };
3365
3372
 
3373
+ // src/utils/compareVersions.ts
3374
+ var splitVersion = (value2) => {
3375
+ const [core] = value2.split("-", 2);
3376
+ return core.split(".").map((part) => Number(part));
3377
+ };
3378
+ var compareVersions = (left, right) => {
3379
+ const leftParts = splitVersion(left);
3380
+ const rightParts = splitVersion(right);
3381
+ const maxLength = Math.max(leftParts.length, rightParts.length);
3382
+ for (let i2 = 0; i2 < maxLength; i2 += 1) {
3383
+ const l = leftParts[i2] ?? 0;
3384
+ const r = rightParts[i2] ?? 0;
3385
+ if (l > r) {
3386
+ return 1;
3387
+ }
3388
+ if (l < r) {
3389
+ return -1;
3390
+ }
3391
+ }
3392
+ return 0;
3393
+ };
3394
+
3366
3395
  // package.json
3367
3396
  var package_default = {
3368
3397
  name: "@aiqa/sdk",
3369
- version: "1.0.0-develop.2",
3398
+ version: "1.0.0-develop.4",
3370
3399
  main: "dist/node/node.js",
3371
3400
  module: "dist/node/node.js",
3372
3401
  types: "dist/node/node.d.ts",
@@ -3521,8 +3550,8 @@ var AiQaSdk = class {
3521
3550
  const minVersion = versionRange?.min;
3522
3551
  const maxVersion = versionRange?.max;
3523
3552
  if (minVersion || maxVersion) {
3524
- const tooLow = minVersion ? this.compareVersions(SDK_VERSION, minVersion) < 0 : false;
3525
- const tooHigh = maxVersion ? this.compareVersions(SDK_VERSION, maxVersion) > 0 : false;
3553
+ const tooLow = minVersion ? compareVersions(SDK_VERSION, minVersion) < 0 : false;
3554
+ const tooHigh = maxVersion ? compareVersions(SDK_VERSION, maxVersion) > 0 : false;
3526
3555
  if (tooLow || tooHigh) {
3527
3556
  const error = new Error(
3528
3557
  `SDK version ${SDK_VERSION} is not supported. Supported range: ${minVersion || "-"} to ${maxVersion || "-"}.`
@@ -3601,6 +3630,12 @@ var AiQaSdk = class {
3601
3630
  });
3602
3631
  return result && result.data !== void 0 ? result.data : result;
3603
3632
  }
3633
+ async setConversationLanguage(language) {
3634
+ const result = await this.sendMessage("SET_CONVERSATION_LANGUAGE" /* SET_CONVERSATION_LANGUAGE */, {
3635
+ language
3636
+ });
3637
+ return result && result.data !== void 0 ? result.data : result;
3638
+ }
3604
3639
  async authenticate() {
3605
3640
  try {
3606
3641
  const result = await this.sendMessage("AUTHENTICATE" /* AUTHENTICATE */, {
@@ -3626,22 +3661,6 @@ var AiQaSdk = class {
3626
3661
  const result = await this.sendMessage("IS_RECORDING" /* IS_RECORDING */);
3627
3662
  return result && result.data !== void 0 ? result.data : result;
3628
3663
  }
3629
- compareVersions(left, right) {
3630
- const leftParts = left.split(".").map((part) => Number(part));
3631
- const rightParts = right.split(".").map((part) => Number(part));
3632
- const maxLength = Math.max(leftParts.length, rightParts.length);
3633
- for (let i2 = 0; i2 < maxLength; i2 += 1) {
3634
- const l = leftParts[i2] ?? 0;
3635
- const r = rightParts[i2] ?? 0;
3636
- if (l > r) {
3637
- return 1;
3638
- }
3639
- if (l < r) {
3640
- return -1;
3641
- }
3642
- }
3643
- return 0;
3644
- }
3645
3664
  emitInternal(name, ...args) {
3646
3665
  const handlers = this.internalListeners.get(name);
3647
3666
  if (!handlers) {
@@ -3659,6 +3678,7 @@ var AiQaSdk = class {
3659
3678
  var shared_default = AiQaSdk;
3660
3679
  export {
3661
3680
  shared_default as AiQaSdk,
3681
+ ConversationLanguage,
3662
3682
  FactAnswerFormatType,
3663
3683
  IAiqaSdk,
3664
3684
  Methods