@1interface/chat-core 0.18.0 → 0.19.0-dev.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
@@ -17,6 +17,7 @@ import { EnhancedStore } from '@reduxjs/toolkit';
17
17
  import { FetchArgs } from '@reduxjs/toolkit/query';
18
18
  import { FetchBaseQueryError } from '@reduxjs/toolkit/query';
19
19
  import { ForgotPasswordRequest } from '@1interface/shared-core';
20
+ import { HostedPaymentPageInit } from '@1interface/shared-core';
20
21
  import { IdpHint } from '@1interface/shared-core';
21
22
  import { InheritedAuthAdapter } from '@1interface/shared-core';
22
23
  import { LoggerContextProvider } from '@1interface/shared-core';
@@ -174,7 +175,9 @@ getProfile: QueryDefinition<void, BaseQueryFn<string | FetchArgs, unknown, Fetch
174
175
  updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
175
176
  deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
176
177
  updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
177
- }, string, "profileApi">, ThunkDispatch<any, any, UnknownAction>>)[];
178
+ }, string, "profileApi">, ThunkDispatch<any, any, UnknownAction>> | Middleware< {}, RootState_2< {
179
+ getHostedPaymentStatus: QueryDefinition<HostedPaymentStatusArgs, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, HostedPaymentSettlementStatus, "paymentApi", unknown>;
180
+ }, string, "paymentApi">, ThunkDispatch<any, any, UnknownAction>>)[];
178
181
 
179
182
  export declare const apiReducers: {
180
183
  chatApi: Reducer<CombinedState< {
@@ -250,6 +253,9 @@ export declare const apiReducers: {
250
253
  deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
251
254
  updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
252
255
  }, "profile", "profileApi">, UnknownAction>;
256
+ paymentApi: Reducer<CombinedState< {
257
+ getHostedPaymentStatus: QueryDefinition<HostedPaymentStatusArgs, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, HostedPaymentSettlementStatus, "paymentApi", unknown>;
258
+ }, never, "paymentApi">, UnknownAction>;
253
259
  };
254
260
 
255
261
  export declare type AppDispatch = typeof store.dispatch;
@@ -363,6 +369,8 @@ export declare function buildCallbackUrl(givenId?: string | null): string;
363
369
 
364
370
  export declare function buildHostedPaymentPageThemeMessage(skin: PaymentSkin): HostedPaymentPageThemeMessage;
365
371
 
372
+ export declare function buildHostedPaymentResult(input: HostedPaymentResultInput): PaymentResult;
373
+
366
374
  export declare const CHAT_INPUT_MODES: {
367
375
  readonly NORMAL: "normal";
368
376
  readonly RECORDING: "recording";
@@ -543,6 +551,9 @@ updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | Fet
543
551
  deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
544
552
  updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
545
553
  }, "profile", "profileApi">;
554
+ paymentApi: CombinedState< {
555
+ getHostedPaymentStatus: QueryDefinition<HostedPaymentStatusArgs, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, HostedPaymentSettlementStatus, "paymentApi", unknown>;
556
+ }, never, "paymentApi">;
546
557
  }, UnknownAction, Partial<{
547
558
  auth: AuthState;
548
559
  chat: {
@@ -646,6 +657,9 @@ updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | Fet
646
657
  deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
647
658
  updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
648
659
  }, "profile", "profileApi">;
660
+ paymentApi: CombinedState< {
661
+ getHostedPaymentStatus: QueryDefinition<HostedPaymentStatusArgs, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, HostedPaymentSettlementStatus, "paymentApi", unknown>;
662
+ }, never, "paymentApi">;
649
663
  }>>;
650
664
 
651
665
  export declare interface ChatIndicator {
@@ -893,6 +907,8 @@ export declare function guestLoginApi(): Promise<AuthApiResult>;
893
907
 
894
908
  export declare const hasAnyExtraData: (msg: any) => boolean;
895
909
 
910
+ export declare const HOSTED_PAYMENT_DEFAULT_FAILURE_MESSAGE = "The payment was not completed.";
911
+
896
912
  export declare const HOSTED_PAYMENT_PAGE_CALLBACK_ACTIONS: {
897
913
  readonly LOADED: "loaded";
898
914
  readonly DONE: "done";
@@ -910,6 +926,18 @@ export declare const HOSTED_PAYMENT_PAGE_STATUSES: {
910
926
 
911
927
  export declare const HOSTED_PAYMENT_PAGE_THEME_MESSAGE_TYPE = "hosted-payment-page-theme";
912
928
 
929
+ export declare const HOSTED_PAYMENT_SETTLEMENT_STATUSES: {
930
+ readonly SUCCEEDED: "succeeded";
931
+ readonly FAILED: "failed";
932
+ readonly CANCELED: "canceled";
933
+ readonly PENDING: "pending";
934
+ };
935
+
936
+ export declare interface HostedPaymentCharge {
937
+ amount?: number;
938
+ currency?: string;
939
+ }
940
+
913
941
  export declare type HostedPaymentPageCallbackAction = (typeof HOSTED_PAYMENT_PAGE_CALLBACK_ACTIONS)[keyof typeof HOSTED_PAYMENT_PAGE_CALLBACK_ACTIONS];
914
942
 
915
943
  export declare interface HostedPaymentPageCallbackMessage {
@@ -934,6 +962,20 @@ export declare interface HostedPaymentPageThemeMessage {
934
962
  vars: Record<`--hpp-${string}`, string>;
935
963
  }
936
964
 
965
+ export declare interface HostedPaymentResultInput {
966
+ status: HostedPaymentPageStatus;
967
+ paymentId: string;
968
+ charge?: HostedPaymentCharge;
969
+ message?: string;
970
+ dismissed?: boolean;
971
+ }
972
+
973
+ export declare type HostedPaymentSettlementStatus = HostedPaymentPageStatus | "pending";
974
+
975
+ export declare interface HostedPaymentStatusArgs {
976
+ referenceId: string;
977
+ }
978
+
937
979
  export declare function isApiServerError(err: unknown): boolean;
938
980
 
939
981
  export declare const isEmptyMessage: (v: any) => boolean;
@@ -1131,6 +1173,8 @@ export declare interface QueuedMessage {
1131
1173
  documents?: AttachedDocument[];
1132
1174
  }
1133
1175
 
1176
+ export declare function readHostedPaymentStatus(value: unknown): HostedPaymentPageStatus | null;
1177
+
1134
1178
  export declare function refreshTokenApi(payload: RefreshRequest): Promise<RefreshApiResult>;
1135
1179
 
1136
1180
  export declare function resendVerificationApi(payload: ResendVerificationRequest): Promise<string | undefined>;
@@ -1143,6 +1187,8 @@ export declare const resetChatState: ActionCreatorWithoutPayload<"chat/resetChat
1143
1187
 
1144
1188
  export declare function resetPasswordApi(payload: ResetPasswordRequest): Promise<string | undefined>;
1145
1189
 
1190
+ export declare function resolveHostedPaymentCharge(reported: HostedPaymentCharge | null | undefined, init: HostedPaymentPageInit): HostedPaymentCharge;
1191
+
1146
1192
  export declare type RootState = ReturnType<typeof store.getState>;
1147
1193
 
1148
1194
  declare type SendMessageFn = (text?: string) => Promise<void>;
@@ -1177,6 +1223,8 @@ export declare const setStatusText: ActionCreatorWithOptionalPayload<string, "ch
1177
1223
 
1178
1224
  export declare function shouldDisableMessage(message: Message, allMessages: Message[], disableOldWidgets: boolean): boolean;
1179
1225
 
1226
+ export declare function shouldPollForSettlement(init: HostedPaymentPageInit): boolean;
1227
+
1180
1228
  export declare function signupApi(payload: SignupRequest): Promise<SignupApiResult>;
1181
1229
 
1182
1230
  export declare enum SSEEventType {
@@ -1323,6 +1371,9 @@ updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | Fet
1323
1371
  deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
1324
1372
  updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
1325
1373
  }, "profile", "profileApi">;
1374
+ paymentApi: CombinedState< {
1375
+ getHostedPaymentStatus: QueryDefinition<HostedPaymentStatusArgs, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, HostedPaymentSettlementStatus, "paymentApi", unknown>;
1376
+ }, never, "paymentApi">;
1326
1377
  }, UnknownAction, Tuple<[StoreEnhancer< {
1327
1378
  dispatch: ((action: Action<"listenerMiddleware/add">) => UnsubscribeListener) & ThunkDispatch< {
1328
1379
  auth: AuthState;
@@ -1427,6 +1478,9 @@ updateProfile: MutationDefinition<UpdateProfilePayload, BaseQueryFn<string | Fet
1427
1478
  deleteAccount: MutationDefinition<void, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", void, "profileApi", unknown>;
1428
1479
  updatePassword: MutationDefinition<UpdatePasswordPayload, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, "profile", string, "profileApi", unknown>;
1429
1480
  }, "profile", "profileApi">;
1481
+ paymentApi: CombinedState< {
1482
+ getHostedPaymentStatus: QueryDefinition<HostedPaymentStatusArgs, BaseQueryFn<string | FetchArgs, unknown, FetchBaseQueryError>, never, HostedPaymentSettlementStatus, "paymentApi", unknown>;
1483
+ }, never, "paymentApi">;
1430
1484
  }, undefined, UnknownAction>;
1431
1485
  }>, StoreEnhancer]>>;
1432
1486
 
@@ -3801,6 +3855,19 @@ export declare function useGuestLogin(): {
3801
3855
  isLoading: boolean;
3802
3856
  };
3803
3857
 
3858
+ export declare const useHostedPaymentSettlement: ({ init, enabled, }: UseHostedPaymentSettlementArgs) => UseHostedPaymentSettlementResult;
3859
+
3860
+ export declare interface UseHostedPaymentSettlementArgs {
3861
+ init: HostedPaymentPageInit;
3862
+ enabled: boolean;
3863
+ }
3864
+
3865
+ export declare interface UseHostedPaymentSettlementResult {
3866
+ polling: boolean;
3867
+ status: Exclude<HostedPaymentSettlementStatus, "pending"> | null;
3868
+ timedOut: boolean;
3869
+ }
3870
+
3804
3871
  export declare function useInfiniteScroll({ hasMore, isLoadingRef, scrollAreaRef, onLoadMore, itemCount, }: {
3805
3872
  hasMore: boolean;
3806
3873
  isLoadingRef: MutableRefObject<boolean>;
@@ -3824,6 +3891,8 @@ export declare interface UseInheritedAuthBootResult {
3824
3891
 
3825
3892
  export declare const useIsDesktop: () => boolean;
3826
3893
 
3894
+ export declare function useLatestRef<T>(value: T): MutableRefObject<T>;
3895
+
3827
3896
  export declare const useLazyGetConversationByIdQuery: <R extends Record<string, any> = TSHelpersId<(Omit<{
3828
3897
  status: QueryStatus.uninitialized;
3829
3898
  originalArgs?: undefined;