@insure-os/client 0.0.61 → 0.0.63

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
@@ -1,4 +1,5 @@
1
- import { QuoteIntentResponse, Product, ClientSettings, CalculationResponse, PaymentInitiationRequest, PaymentGateway, CreateQuotePaymentLinkRequest, PaymentLink, FormDefinition, FormData, FormField, FormPage, PaymentOption, CalculationExcessOption } from '@insure-os/types';
1
+ import * as _insure_os_types from '@insure-os/types';
2
+ import { QuoteIntentResponse, Product, ClientSettings, CalculationResponse, CalculationResultV2, RepriceRequestV2, RepriceResponseV2, BindRequestV2, BindResponseV2, PaymentInitiationRequest, PaymentGateway, CreateQuotePaymentLinkRequest, PaymentLink, FormDefinition, FormData, FormField, FormPage, PaymentOption, Selection, CalculationExcessOption } from '@insure-os/types';
2
3
  export { FieldValidation, FormData, FormDefinition, FormError, FormErrorType, FormField, FormPage, FormSettings, PageValidation, SelectOption } from '@insure-os/types';
3
4
  import * as Sentry from '@sentry/browser';
4
5
 
@@ -40,6 +41,22 @@ declare class EnhancedHttpClient {
40
41
  updateQuoteIntent(url: string, data: any): Promise<QuoteIntentResponse>;
41
42
  deleteQuoteIntent(url: string): Promise<void>;
42
43
  calculateQuoteIntent(url: string): Promise<CalculationResponse>;
44
+ /**
45
+ * v2 calculator — full priced variant grid.
46
+ * URL shape: ${apiBaseUrl}/v2/quote-intents/:id/calculate
47
+ */
48
+ calculateQuoteIntentV2(url: string): Promise<CalculationResultV2>;
49
+ /**
50
+ * v2 calculator — reprice for a specific selection (non-deterministic option toggle).
51
+ * URL shape: ${apiBaseUrl}/v2/quote-intents/:id/reprice
52
+ */
53
+ repriceQuoteIntentV2(url: string, request: RepriceRequestV2): Promise<RepriceResponseV2>;
54
+ /**
55
+ * v2 calculator — verify and bind. Server re-runs the calculation and
56
+ * compares to `client_claimed_total`.
57
+ * URL shape: ${apiBaseUrl}/v2/quote-intents/:id/bind
58
+ */
59
+ bindQuoteIntentV2(url: string, request: BindRequestV2): Promise<BindResponseV2>;
43
60
  deleteCalculations(deleteCalculationsUrl: string): Promise<{
44
61
  message: string;
45
62
  }>;
@@ -715,6 +732,11 @@ type QuoteIntentState = {
715
732
  url: string;
716
733
  calculate_url: string;
717
734
  delete_calculations_url: string;
735
+ /** v2 calculator — present when the product uses calculator_version=2 */
736
+ calculate_url_v2?: string;
737
+ reprice_url_v2?: string;
738
+ bind_url_v2?: string;
739
+ calculator_version?: number;
718
740
  status: string;
719
741
  reference?: string | null;
720
742
  product_id?: string;
@@ -901,10 +923,13 @@ declare class FormStateManager {
901
923
  private pendingChanges;
902
924
  private config;
903
925
  private isCalculating;
926
+ private isRepricing;
904
927
  private isSaving;
905
928
  private selectedExcessId;
906
929
  private selectedPaymentOption;
907
930
  private calculationResult;
931
+ private calculationResultV2;
932
+ private selectionV2;
908
933
  private validationErrors;
909
934
  private serverValidationErrors;
910
935
  private generalErrors;
@@ -913,6 +938,7 @@ declare class FormStateManager {
913
938
  private persistenceManager;
914
939
  private navigationManager;
915
940
  private calculationManager;
941
+ private calculationManagerV2;
916
942
  private quoteIntentStore?;
917
943
  constructor(quoteIntent: QuoteIntentState, httpClient: EnhancedHttpClient, quoteIntentStore?: QuoteIntentStore, config?: FormStateManagerConfig);
918
944
  subscribe(callback: SubscriptionCallback): () => boolean;
@@ -949,6 +975,7 @@ declare class FormStateManager {
949
975
  isAutoSavePaused(): boolean;
950
976
  isUserTyping(): boolean;
951
977
  getIsCalculating(): boolean;
978
+ getIsRepricing(): boolean;
952
979
  getIsSaving(): boolean;
953
980
  hasCalculationResponse(): boolean;
954
981
  getCalculationResult(): CalculationResponse | undefined;
@@ -981,6 +1008,44 @@ declare class FormStateManager {
981
1008
  private filterHiddenFieldsAndSave;
982
1009
  calculateQuote(): Promise<CalculationResponse | undefined>;
983
1010
  clearCalculationResults(): Promise<void>;
1011
+ getCalculationResultV2(): CalculationResultV2 | undefined;
1012
+ getSelectionV2(): Selection | null;
1013
+ /**
1014
+ * Change the selected cover type / excess on the v2 variant grid.
1015
+ * No network call — the grid is pre-computed. Notifies subscribers.
1016
+ */
1017
+ setV2Selection(patch: Partial<Selection>): void;
1018
+ /**
1019
+ * Toggle a v2 coverage option. For deterministic options this updates
1020
+ * the selection locally; for round-trip options it calls /v2/reprice
1021
+ * and updates the grid. The new price comes from deriving it against
1022
+ * the updated variants grid.
1023
+ */
1024
+ toggleV2CoverageOption(optionId: string): Promise<void>;
1025
+ /**
1026
+ * Current total the widget displays for the active v2 selection.
1027
+ * Used as `client_claimed_total` on bind.
1028
+ *
1029
+ * The variant grid is authoritative — /reprice has already applied
1030
+ * every selected option's effects, so there's no client-side delta
1031
+ * math. The delta_total on each option card is purely a UI hint
1032
+ * showing what that option contributes.
1033
+ */
1034
+ getV2DisplayedTotal(): number;
1035
+ /**
1036
+ * Verify and bind the current v2 selection. On match the server
1037
+ * returns `status: 'verified'`. On mismatch the widget should re-read
1038
+ * the returned server_total and show a confirm banner before retrying.
1039
+ */
1040
+ bindV2(email?: string): Promise<_insure_os_types.BindResponseV2>;
1041
+ /**
1042
+ * Collapse a v2 variant grid into a v1-shaped CalculationResponse so
1043
+ * existing code paths (CartSummary, analytics, referral-page) can keep
1044
+ * rendering during the v1→v2 transition. Produces one
1045
+ * CalculationExcessOption per excess option (within the current cover
1046
+ * type) with the pricing from the matching variant.
1047
+ */
1048
+ private buildV1CompatResponseFromV2;
984
1049
  private notify;
985
1050
  /**
986
1051
  * Flattens all page data into a single object for cross-page visibility checks