@1interface/chat-core 0.19.0-dev.1 → 0.20.0

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/index.d.ts CHANGED
@@ -4,7 +4,6 @@ import { ActionCreatorWithoutPayload } from '@reduxjs/toolkit';
4
4
  import { Api } from '@reduxjs/toolkit/query';
5
5
  import { AppBrandingResponse } from '@1interface/shared-core';
6
6
  import { AppResponse } from '@1interface/shared-core';
7
- import { AtbPaymentInit } from '@1interface/shared-core';
8
7
  import { AttachedDocument } from '@1interface/shared-core';
9
8
  import { AuthApiResult } from '@1interface/shared-core';
10
9
  import { AuthState } from '@1interface/shared-core';
@@ -255,60 +254,6 @@ export declare const apiReducers: {
255
254
 
256
255
  export declare type AppDispatch = typeof store.dispatch;
257
256
 
258
- export declare const ATB_FAILURE_CODES: {
259
- readonly SESSION_INVALID: "session_invalid";
260
- readonly LOAD_FAILED: "load_failed";
261
- };
262
-
263
- export declare const ATB_FAILURE_MESSAGES: {
264
- readonly NOT_COMPLETED: "The payment was not completed.";
265
- readonly SESSION_INVALID: "This payment session has expired or is no longer valid. Please start a new payment.";
266
- readonly LOAD_FAILED: "The payment page failed to load.";
267
- };
268
-
269
- export declare const ATB_MESSAGE_SOURCE = "atb-pga";
270
-
271
- export declare const ATB_MESSAGE_TYPES: {
272
- readonly READY: "ready";
273
- readonly COMPLETED: "completed";
274
- readonly ERROR: "error";
275
- readonly REDIRECT: "redirect";
276
- };
277
-
278
- export declare const ATB_OUTCOMES: {
279
- readonly SUCCEEDED: "succeeded";
280
- readonly FAILED: "failed";
281
- };
282
-
283
- export declare const ATB_PAYMENT_STATUSES: {
284
- readonly DEPOSITED: "payment_deposited";
285
- readonly DECLINED: "payment_declined";
286
- };
287
-
288
- export declare interface AtbCompletion {
289
- status?: string;
290
- checkoutId?: string;
291
- }
292
-
293
- declare interface AtbMessage {
294
- source: typeof ATB_MESSAGE_SOURCE;
295
- v: number;
296
- type: AtbMessageType;
297
- data?: Record<string, unknown>;
298
- }
299
-
300
- declare type AtbMessageType = (typeof ATB_MESSAGE_TYPES)[keyof typeof ATB_MESSAGE_TYPES];
301
-
302
- export declare type AtbOutcome = (typeof ATB_OUTCOMES)[keyof typeof ATB_OUTCOMES];
303
-
304
- export declare interface AtbResultInput {
305
- outcome: AtbOutcome;
306
- init: AtbPaymentInit;
307
- message?: string;
308
- checkoutId?: string;
309
- code?: string;
310
- }
311
-
312
257
  export declare class AudioRecorder {
313
258
  private mediaRecorder;
314
259
  private audioChunks;
@@ -412,8 +357,6 @@ export declare interface BridgeRequestOptions {
412
357
  customHeaders?: Record<string, string>;
413
358
  }
414
359
 
415
- export declare function buildAtbResult({ outcome, init, message, checkoutId, code }: AtbResultInput): PaymentResult;
416
-
417
360
  export declare function buildBrandSkin(styles: ChatThemeStyles, resolvedTheme: "light" | "dark"): PaymentSkin;
418
361
 
419
362
  export declare function buildCallbackUrl(givenId?: string | null): string;
@@ -929,9 +872,14 @@ export declare function forgotPasswordApi(payload: ForgotPasswordRequest): Promi
929
872
 
930
873
  export declare function formatAmount(minorUnits: number | undefined, currency: string | undefined): string | null;
931
874
 
875
+ export declare function formatPaymentResult(result: PaymentResult): FormattedPaymentResult;
876
+
932
877
  export declare function formatResultMessage(result: PaymentResult): string;
933
878
 
934
- export declare function formatResultModelContext(result: PaymentResult): string | undefined;
879
+ export declare interface FormattedPaymentResult {
880
+ text: string;
881
+ modelText?: string;
882
+ }
935
883
 
936
884
  export declare const GENERIC_SERVER_ERROR_MESSAGE = "Something went wrong. Please try again.";
937
885
 
@@ -955,12 +903,10 @@ export declare const hasAnyExtraData: (msg: any) => boolean;
955
903
 
956
904
  export declare function isApiServerError(err: unknown): boolean;
957
905
 
958
- export declare function isAtbCheckoutUrl(value: unknown): value is string;
959
-
960
- export declare function isAtbMessage(value: unknown): value is AtbMessage;
961
-
962
906
  export declare const isEmptyMessage: (v: any) => boolean;
963
907
 
908
+ export declare function isHttpsUrl(value: unknown): value is string;
909
+
964
910
  export declare function loginApi(email: string, password: string): Promise<AuthApiResult>;
965
911
 
966
912
  export declare function logoutApi(payload: LogoutRequest, options?: {
@@ -981,6 +927,8 @@ export declare interface MessageArrival {
981
927
  lastUserMessageIndex: number;
982
928
  }
983
929
 
930
+ export declare const MODEL_CONTEXT_TEXT_MAX_LENGTH = 1000;
931
+
984
932
  export declare const MOYASAR_CALLBACK_SENTINEL = "moyasar_cb";
985
933
 
986
934
  export declare interface MoyasarCallbackResult {
@@ -1030,6 +978,11 @@ export declare const PAGINATION: {
1030
978
 
1031
979
  export declare function parseMoyasarCallbackFromUrl(search: string): MoyasarCallbackResult | null;
1032
980
 
981
+ export declare const PAYMENT_FAILURE_CODES: {
982
+ readonly SESSION_INVALID: "session_invalid";
983
+ readonly LOAD_FAILED: "load_failed";
984
+ };
985
+
1033
986
  export declare interface PaymentAdapter {
1034
987
  readonly type: PaymentProviderType;
1035
988
  readonly label: string;
@@ -1059,14 +1012,12 @@ export declare type PaymentResult = {
1059
1012
  paymentId: string;
1060
1013
  amount?: number;
1061
1014
  currency?: string;
1062
- checkoutId?: string;
1063
1015
  } | {
1064
1016
  status: "failure";
1065
1017
  provider: PaymentProviderType;
1066
1018
  code?: string;
1067
1019
  message: string;
1068
1020
  paymentId?: string;
1069
- checkoutId?: string;
1070
1021
  } | {
1071
1022
  status: "cancel";
1072
1023
  provider: PaymentProviderType;
@@ -1149,12 +1100,6 @@ export declare interface QueuedMessage {
1149
1100
  modelText?: string;
1150
1101
  }
1151
1102
 
1152
- export declare function readAtbCompletion(data: unknown): AtbCompletion;
1153
-
1154
- export declare function readAtbOutcome(status: string | undefined): AtbOutcome;
1155
-
1156
- export declare function readAtbRedirect(data: unknown): string | null;
1157
-
1158
1103
  export declare function refreshTokenApi(payload: RefreshRequest): Promise<RefreshApiResult>;
1159
1104
 
1160
1105
  export declare function resendVerificationApi(payload: ResendVerificationRequest): Promise<string | undefined>;
@@ -1167,15 +1112,9 @@ export declare const resetChatState: ActionCreatorWithoutPayload<"chat/resetChat
1167
1112
 
1168
1113
  export declare function resetPasswordApi(payload: ResetPasswordRequest): Promise<string | undefined>;
1169
1114
 
1170
- export declare function resolveAtbOrigin(url: string): string | null;
1171
-
1172
1115
  export declare type RootState = ReturnType<typeof store.getState>;
1173
1116
 
1174
- declare type SendMessageFn = (text?: string, transcriptionIds?: string[], options?: SendMessageOptions) => Promise<void>;
1175
-
1176
- declare type SendMessageFn_2 = (text?: string) => Promise<void>;
1177
-
1178
- declare type SendMessageFn_3 = (text?: string, transcriptionIds?: string[], options?: SendMessageOptions) => Promise<void>;
1117
+ export declare type SendMessageFn = (inputMsg?: string, transcriptionIds?: string[], options?: SendMessageOptions) => Promise<void>;
1179
1118
 
1180
1119
  export declare interface SendMessageOptions {
1181
1120
  messageType?: string[];
@@ -1240,6 +1179,7 @@ export declare interface StandardApiError {
1240
1179
 
1241
1180
  export declare interface StartConversationBody {
1242
1181
  client_metadata?: StartConversationMetadata;
1182
+ locale?: string;
1243
1183
  }
1244
1184
 
1245
1185
  export declare interface StartConversationMetadata {
@@ -1551,11 +1491,11 @@ export declare const useAuth: () => {
1551
1491
 
1552
1492
  export declare const useChatCallbacks: () => ChatCallbacks;
1553
1493
 
1554
- export declare const useChatConnection: ({ conversationId, messages, setMessages, enableTts, userLocation, startSession, debugMode, onPaymentInit, onSignInInit, onRequestDocuments, onConversationTitle, }: UseChatConnectionParams) => UseChatConnectionReturn;
1494
+ export declare const useChatConnection: ({ conversationId, setMessages, enableTts, userLocation, startSession, debugMode, onPaymentInit, onSignInInit, onRequestDocuments, onConversationTitle, initialMessage, locale, }: UseChatConnectionParams) => UseChatConnectionReturn;
1555
1495
 
1556
1496
  declare interface UseChatConnectionParams {
1557
1497
  conversationId: string | null;
1558
- messages: Message[];
1498
+ messages?: Message[];
1559
1499
  setMessages: React.Dispatch<React.SetStateAction<Message[]>>;
1560
1500
  enableTts?: boolean;
1561
1501
  userLocation?: UserLocation | null;
@@ -1565,10 +1505,12 @@ declare interface UseChatConnectionParams {
1565
1505
  onSignInInit?: (init: SignInInitPayload) => void;
1566
1506
  onRequestDocuments?: (payload: RequestDocumentsPayload) => void;
1567
1507
  onConversationTitle?: (title: string) => void;
1508
+ initialMessage?: string | null;
1509
+ locale?: string | null;
1568
1510
  }
1569
1511
 
1570
1512
  declare interface UseChatConnectionReturn {
1571
- sendMessage: (inputMsg?: string, transcriptionIds?: string[], options?: SendMessageOptions) => Promise<void>;
1513
+ sendMessage: SendMessageFn;
1572
1514
  startInitialStream: (conversationId: string, location?: UserLocation | null) => Promise<void>;
1573
1515
  setThinkingState: (thinking: boolean) => void;
1574
1516
  abortStream: () => void;
@@ -4148,7 +4090,7 @@ export declare function useOAuthPopup({ signInInit, sendMessageRef, clearSignInI
4148
4090
 
4149
4091
  declare interface UseOAuthPopupArgs {
4150
4092
  signInInit: SignInInitPayload | null;
4151
- sendMessageRef: RefObject<SendMessageFn_2 | null>;
4093
+ sendMessageRef: RefObject<SendMessageFn | null>;
4152
4094
  clearSignInInit: () => void;
4153
4095
  sendResumeMessage?: boolean;
4154
4096
  }
@@ -4156,7 +4098,7 @@ declare interface UseOAuthPopupArgs {
4156
4098
  export declare function usePayment({ sendMessageRef }: UsePaymentArgs): UsePaymentResult;
4157
4099
 
4158
4100
  export declare interface UsePaymentArgs {
4159
- sendMessageRef: MutableRefObject<SendMessageFn_3 | null>;
4101
+ sendMessageRef: MutableRefObject<SendMessageFn | null>;
4160
4102
  }
4161
4103
 
4162
4104
  export declare const usePaymentFlow: ({ sendMessageRef, }: UsePaymentFlowArgs) => UsePaymentFlowReturn;