@envive-ai/react-hooks 0.2.6-alpha-marlo.0 → 0.2.6-alpha-arthur-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/dist/AmplitudeOperations-BjC8DOqm.js +34 -0
- package/dist/AmplitudeOperations-CQs4sVHN.cjs +41 -0
- package/dist/{NewOrgConfig-BfbTlFg1.js → NewOrgConfig-CRakarmw.js} +2 -2
- package/dist/{NewOrgConfig-DJm6_abA.cjs → NewOrgConfig-D48KabOj.cjs} +2 -2
- package/dist/TrackComponentVisibleEvent-C9RvfdS9.js +53 -0
- package/dist/TrackComponentVisibleEvent-_Fb-JXkV.cjs +60 -0
- package/dist/amplitudeContext-D5HSmIWg.cjs +253 -0
- package/dist/amplitudeContext-wW37Ziq-.js +237 -0
- package/dist/amplitudeTrackEventAtom-D66l5oFp.js +8 -0
- package/dist/amplitudeTrackEventAtom-f22P2U0u.cjs +15 -0
- package/dist/api-D4HaU2Gf.js +166 -0
- package/dist/api-D4Xoibs9.cjs +239 -0
- package/dist/app-CGw4C9Bn.js +515 -0
- package/dist/app-Di_sBmzj.cjs +570 -0
- package/dist/application/models/graphql/index.cjs +3 -3
- package/dist/application/models/graphql/index.d.cts +2 -2
- package/dist/application/models/graphql/index.d.ts +2 -2
- package/dist/application/models/graphql/index.js +2 -3
- package/dist/application/models/guards/api/index.cjs +3 -3
- package/dist/application/models/guards/api/index.d.cts +2 -2
- package/dist/application/models/guards/api/index.d.ts +2 -2
- package/dist/application/models/guards/api/index.js +3 -3
- package/dist/application/models/guards/utils.cjs +1 -1
- package/dist/application/models/guards/utils.d.ts +1 -1
- package/dist/application/models/guards/utils.js +1 -1
- package/dist/application/models/index.cjs +7 -23
- package/dist/application/models/index.d.cts +167 -11
- package/dist/application/models/index.d.ts +168 -12
- package/dist/application/models/index.js +7 -11
- package/dist/application/utils/index.cjs +10 -19
- package/dist/application/utils/index.d.cts +13 -63
- package/dist/application/utils/index.d.ts +13 -63
- package/dist/application/utils/index.js +10 -19
- package/dist/{atomStore-DXTVqiKc.js → atomStore-BuopbV9k.js} +1 -1
- package/dist/{atomStore-DNji91Im.cjs → atomStore-CZKe3itM.cjs} +1 -1
- package/dist/atoms/app/index.cjs +22 -24
- package/dist/atoms/app/index.d.cts +9 -20
- package/dist/atoms/app/index.d.ts +8 -19
- package/dist/atoms/app/index.js +17 -19
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.d.cts +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +20 -21
- package/dist/atoms/chat/index.d.cts +36 -45
- package/dist/atoms/chat/index.d.ts +34 -43
- package/dist/atoms/chat/index.js +20 -21
- package/dist/atoms/globalSearch/index.cjs +1 -2
- package/dist/atoms/globalSearch/index.d.cts +5 -5
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/globalSearch/index.js +1 -2
- package/dist/atoms/org/index.cjs +10 -11
- package/dist/atoms/org/index.d.cts +19 -31
- package/dist/atoms/org/index.d.ts +19 -31
- package/dist/atoms/org/index.js +2 -3
- package/dist/atoms/search/index.cjs +7 -47
- package/dist/atoms/search/index.d.cts +76 -14
- package/dist/atoms/search/index.d.ts +76 -14
- package/dist/atoms/search/index.js +7 -29
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/cdnContext-BJT_Wn9Z.js +38 -0
- package/dist/cdnContext-BoPraJxf.cjs +53 -0
- package/dist/chat-ZaY3KY-R.js +226 -0
- package/dist/chat-rhEjVfrd.cjs +326 -0
- package/dist/chatState-BbI93m6r.js +33 -0
- package/dist/chatState-DlJpHAsW.cjs +119 -0
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/locators/components/chat/index.d.cts +1 -1
- package/dist/config/locators/components/chat/index.d.ts +1 -1
- package/dist/config/locators/components/chat/variants/index.d.cts +1 -1
- package/dist/config/locators/components/chat/variants/index.d.ts +1 -1
- package/dist/config/locators/components/common/index.d.cts +1 -1
- package/dist/config/locators/components/common/index.d.ts +1 -1
- package/dist/config/locators/components/index.d.cts +1 -1
- package/dist/config/locators/components/index.d.ts +1 -1
- package/dist/config/locators/components/search/index.d.cts +1 -1
- package/dist/config/locators/components/search/index.d.ts +1 -1
- package/dist/config/locators/index.d.cts +4 -4
- package/dist/config/locators/index.d.ts +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +23 -22
- package/dist/contexts/amplitudeContext/index.d.cts +11 -2
- package/dist/contexts/amplitudeContext/index.d.ts +11 -2
- package/dist/contexts/amplitudeContext/index.js +22 -20
- package/dist/contexts/atomProvider/index.cjs +18 -0
- package/dist/contexts/atomProvider/index.d.cts +11 -0
- package/dist/contexts/atomProvider/index.d.ts +11 -0
- package/dist/contexts/atomProvider/index.js +15 -0
- package/dist/contexts/cdnContext/index.cjs +4 -4
- package/dist/contexts/cdnContext/index.d.cts +2 -6
- package/dist/contexts/cdnContext/index.d.ts +2 -6
- package/dist/contexts/cdnContext/index.js +4 -4
- package/dist/contexts/enviveConfigContext/index.cjs +6 -4
- package/dist/contexts/enviveConfigContext/index.d.cts +5 -25
- package/dist/contexts/enviveConfigContext/index.d.ts +5 -25
- package/dist/contexts/enviveConfigContext/index.js +6 -5
- package/dist/contexts/enviveCssContext/index.cjs +17 -19
- package/dist/contexts/enviveCssContext/index.d.cts +3 -5
- package/dist/contexts/enviveCssContext/index.d.ts +3 -5
- package/dist/contexts/enviveCssContext/index.js +17 -19
- package/dist/contexts/featureFlagContext/index.cjs +9 -10
- package/dist/contexts/featureFlagContext/index.d.cts +3 -11
- package/dist/contexts/featureFlagContext/index.d.ts +3 -11
- package/dist/contexts/featureFlagContext/index.js +6 -7
- package/dist/contexts/featureFlagServiceContext/index.cjs +4 -3
- package/dist/contexts/featureFlagServiceContext/index.d.cts +1 -4
- package/dist/contexts/featureFlagServiceContext/index.d.ts +1 -4
- package/dist/contexts/featureFlagServiceContext/index.js +4 -3
- package/dist/contexts/graphqlContext/index.cjs +10 -13
- package/dist/contexts/graphqlContext/index.d.cts +11 -14
- package/dist/contexts/graphqlContext/index.d.ts +11 -14
- package/dist/contexts/graphqlContext/index.js +10 -13
- package/dist/contexts/localStorageContext/index.cjs +3 -3
- package/dist/contexts/localStorageContext/index.d.cts +3 -22
- package/dist/contexts/localStorageContext/index.d.ts +3 -22
- package/dist/contexts/localStorageContext/index.js +4 -3
- package/dist/contexts/newOrgConfigContext/index.cjs +15 -17
- package/dist/contexts/newOrgConfigContext/index.d.cts +12 -15
- package/dist/contexts/newOrgConfigContext/index.d.ts +12 -15
- package/dist/contexts/newOrgConfigContext/index.js +15 -17
- package/dist/contexts/searchContext/index.cjs +24 -24
- package/dist/contexts/searchContext/index.d.cts +2 -7
- package/dist/contexts/searchContext/index.d.ts +2 -7
- package/dist/contexts/searchContext/index.js +24 -24
- package/dist/contexts/sessionStorageContext/index.cjs +2 -2
- package/dist/contexts/sessionStorageContext/index.d.cts +2 -6
- package/dist/contexts/sessionStorageContext/index.d.ts +2 -6
- package/dist/contexts/sessionStorageContext/index.js +2 -2
- package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
- package/dist/contexts/shopifyUrlContext/index.d.cts +2 -11
- package/dist/contexts/shopifyUrlContext/index.d.ts +2 -11
- package/dist/contexts/shopifyUrlContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +4 -4
- package/dist/contexts/systemSettingsContext/index.d.cts +2 -12
- package/dist/contexts/systemSettingsContext/index.d.ts +4 -14
- package/dist/contexts/systemSettingsContext/index.js +4 -4
- package/dist/contexts/userIdentityContext/index.cjs +19 -21
- package/dist/contexts/userIdentityContext/index.d.cts +11 -2
- package/dist/contexts/userIdentityContext/index.d.ts +11 -2
- package/dist/contexts/userIdentityContext/index.js +17 -19
- package/dist/dist-C38adNK1.js +5923 -0
- package/dist/dist-VxRI6eQv.cjs +6019 -0
- package/dist/domObserver-CVhsCSkS.js +285 -0
- package/dist/{domObserver-v9ODTyfT.js → domObserver-LCBj1xw4.cjs} +23 -4
- package/dist/enviveConfig-CHXb9xwk.cjs +125 -0
- package/dist/enviveConfig-CUJgI97-.js +63 -0
- package/dist/enviveConfigContext-C91Air9z.js +48 -0
- package/dist/enviveConfigContext-zZAJwv87.cjs +69 -0
- package/dist/events/index.cjs +2 -3
- package/dist/events/index.d.cts +2 -15
- package/dist/events/index.d.ts +2 -15
- package/dist/events/index.js +2 -2
- package/dist/events-CgFGtanE.cjs +69 -0
- package/dist/events-WOOrnUAx.js +63 -0
- package/dist/exceptions/index.cjs +4 -0
- package/dist/exceptions/index.d.cts +12 -0
- package/dist/exceptions/index.d.ts +12 -0
- package/dist/exceptions/index.js +3 -0
- package/dist/exceptions-BjDgLzGi.cjs +32 -0
- package/dist/exceptions-CUGY31Ua.js +20 -0
- package/dist/featureFlagServiceContext-ClnlCJV5.d.cts +24 -0
- package/dist/featureFlagServiceContext-Cvp7NlpC.js +46 -0
- package/dist/featureFlagServiceContext-DHtkQAtq.cjs +66 -0
- package/dist/featureFlagServiceContext-x-hAAKdL.d.ts +24 -0
- package/dist/{globalSearch-FBk2epe8.cjs → globalSearch-Cpc8egsM.cjs} +1 -1
- package/dist/{globalSearch-Ccxq8hNF.js → globalSearch-nmrfGLOn.js} +1 -1
- package/dist/graphql-CvAHWmel.js +46 -0
- package/dist/graphql-JaGqsToc.cjs +70 -0
- package/dist/graphqlContext-C3T_K97L.js +94 -0
- package/dist/graphqlContext-DqWvz7Op.cjs +108 -0
- package/dist/hooks/AmplitudeOperations/index.cjs +23 -22
- package/dist/hooks/AmplitudeOperations/index.d.cts +2 -2
- package/dist/hooks/AmplitudeOperations/index.d.ts +2 -2
- package/dist/hooks/AmplitudeOperations/index.js +22 -21
- package/dist/hooks/AppDetails/index.cjs +22 -22
- package/dist/hooks/AppDetails/index.d.cts +3 -23
- package/dist/hooks/AppDetails/index.d.ts +3 -23
- package/dist/hooks/AppDetails/index.js +22 -22
- package/dist/hooks/BlockBackButton/index.d.ts +1 -1
- package/dist/hooks/CdnOperations/index.cjs +4 -4
- package/dist/hooks/CdnOperations/index.js +4 -4
- package/dist/hooks/ChatToggle/index.cjs +28 -25
- package/dist/hooks/ChatToggle/index.d.cts +2 -2
- package/dist/hooks/ChatToggle/index.d.ts +2 -2
- package/dist/hooks/ChatToggle/index.js +25 -22
- package/dist/hooks/ChatToggleAnalytics/index.cjs +25 -24
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.d.ts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.js +24 -23
- package/dist/hooks/CustomerSupportHandoff/index.cjs +2 -2
- package/dist/hooks/CustomerSupportHandoff/index.d.cts +1 -1
- package/dist/hooks/CustomerSupportHandoff/index.js +2 -2
- package/dist/hooks/Debounce/index.cjs +20 -2
- package/dist/hooks/Debounce/index.d.cts +1 -1
- package/dist/hooks/Debounce/index.js +18 -2
- package/dist/hooks/ElementObserver/index.cjs +4 -6
- package/dist/hooks/ElementObserver/index.d.cts +4 -25
- package/dist/hooks/ElementObserver/index.d.ts +4 -25
- package/dist/hooks/ElementObserver/index.js +4 -6
- package/dist/hooks/GrabAndScroll/index.cjs +1 -1
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/index.d.ts +2 -2
- package/dist/hooks/GrabAndScroll/index.js +1 -1
- package/dist/hooks/GraphQLConfig/index.cjs +11 -14
- package/dist/hooks/GraphQLConfig/index.d.cts +2 -13
- package/dist/hooks/GraphQLConfig/index.d.ts +2 -13
- package/dist/hooks/GraphQLConfig/index.js +11 -14
- package/dist/hooks/IdentifyUser/index.cjs +19 -21
- package/dist/hooks/IdentifyUser/index.js +18 -20
- package/dist/hooks/ImageResolver/index.cjs +20 -29
- package/dist/hooks/ImageResolver/index.js +20 -29
- package/dist/hooks/Intersection/index.cjs +1 -1
- package/dist/hooks/Intersection/index.d.ts +1 -1
- package/dist/hooks/Intersection/index.js +1 -1
- package/dist/hooks/IsSmallScreen/index.d.ts +1 -1
- package/dist/hooks/LocalStorageOperations/index.cjs +8 -7
- package/dist/hooks/LocalStorageOperations/index.d.cts +1 -1
- package/dist/hooks/LocalStorageOperations/index.js +4 -3
- package/dist/hooks/MessageFilter/index.cjs +3 -12
- package/dist/hooks/MessageFilter/index.d.cts +2 -17
- package/dist/hooks/MessageFilter/index.d.ts +2 -17
- package/dist/hooks/MessageFilter/index.js +2 -11
- package/dist/hooks/NewOrgConfig/index.cjs +16 -18
- package/dist/hooks/NewOrgConfig/index.d.cts +3 -16
- package/dist/hooks/NewOrgConfig/index.d.ts +3 -16
- package/dist/hooks/NewOrgConfig/index.js +16 -18
- package/dist/hooks/Search/index.cjs +314 -173
- package/dist/hooks/Search/index.d.cts +3 -57
- package/dist/hooks/Search/index.d.ts +3 -57
- package/dist/hooks/Search/index.js +302 -162
- package/dist/hooks/SearchOperations/index.cjs +25 -25
- package/dist/hooks/SearchOperations/index.d.cts +2 -3
- package/dist/hooks/SearchOperations/index.d.ts +2 -3
- package/dist/hooks/SearchOperations/index.js +25 -25
- package/dist/hooks/SessionStorageOperations/index.cjs +2 -2
- package/dist/hooks/SessionStorageOperations/index.js +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.cjs +3 -3
- package/dist/hooks/ShopifyUrlOperations/index.d.cts +2 -4
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +2 -4
- package/dist/hooks/ShopifyUrlOperations/index.js +3 -3
- package/dist/hooks/SnapCalculator/index.cjs +1 -1
- package/dist/hooks/SnapCalculator/index.d.cts +4 -3
- package/dist/hooks/SnapCalculator/index.d.ts +4 -3
- package/dist/hooks/SnapCalculator/index.js +1 -1
- package/dist/hooks/SystemSettingsContext/index.cjs +17 -6
- package/dist/hooks/SystemSettingsContext/index.d.cts +5 -15
- package/dist/hooks/SystemSettingsContext/index.d.ts +4 -14
- package/dist/hooks/SystemSettingsContext/index.js +15 -6
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +23 -21
- package/dist/hooks/TrackComponentVisibleEvent/index.d.cts +2 -3
- package/dist/hooks/TrackComponentVisibleEvent/index.d.ts +2 -3
- package/dist/hooks/TrackComponentVisibleEvent/index.js +23 -21
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +26 -24
- package/dist/hooks/UpdateAnalyticsProps/index.d.cts +1 -1
- package/dist/hooks/UpdateAnalyticsProps/index.js +22 -20
- package/dist/hooks/utils.cjs +1 -1
- package/dist/hooks/utils.d.cts +20 -13
- package/dist/hooks/utils.d.ts +20 -13
- package/dist/hooks/utils.js +1 -1
- package/dist/index--OKiRCTl.d.ts +224 -0
- package/dist/{index-h809JLbL.d.ts → index-B95cXAA4.d.ts} +1 -1
- package/dist/index-BVZbvpx_.d.cts +11 -0
- package/dist/{index-FQjyuD3D.d.cts → index-BbqT4BQv.d.cts} +1 -1
- package/dist/index-BiDHHLjr.d.ts +42 -0
- package/dist/{index-Da1s8h5C.d.cts → index-CAJq_8bO.d.cts} +1 -1
- package/dist/index-CAXM2KiM.d.ts +11 -0
- package/dist/index-CMZcE7pk.d.cts +224 -0
- package/dist/{index-DzbkQtaK.d.cts → index-ChiZg0yw.d.cts} +1 -1
- package/dist/{index-xHVrsrbz.d.ts → index-DZU7c0jP.d.ts} +1 -1
- package/dist/{index-BeYfyZ6k.d.ts → index-DywcCZdp.d.ts} +1 -1
- package/dist/{index-DJTrxIFJ.d.ts → index-dc4j0jws.d.ts} +1 -1
- package/dist/{index-9NE86em3.d.cts → index-npqPeJ1g.d.cts} +1 -1
- package/dist/index-qOBU4GEh.d.cts +42 -0
- package/dist/interceptors/index.cjs +28 -3
- package/dist/interceptors/index.d.cts +4 -15
- package/dist/interceptors/index.d.ts +4 -15
- package/dist/interceptors/index.js +25 -3
- package/dist/localStorageContext-BFwvuEcf.js +90 -0
- package/dist/localStorageContext-CWc5xJ6U.cjs +104 -0
- package/dist/{logger-W3lqg-4b.js → logger-BMVdhQOV.js} +1 -1
- package/dist/{logger-TBIl4uIH.cjs → logger-BqHq67zN.cjs} +1 -1
- package/dist/models-Cw0QcbQv.js +1118 -0
- package/dist/models-Dl0_Ujgj.cjs +1305 -0
- package/dist/newOrgConfigAtom-C8h3w_Ji.js +8 -0
- package/dist/{newOrgConfigAtom-DxILMn2I.cjs → newOrgConfigAtom-CDttTiuu.cjs} +1 -1
- package/dist/newOrgConfigContext-B_rJMpwN.js +55 -0
- package/dist/newOrgConfigContext-D1sgTmVU.cjs +70 -0
- package/dist/nodeSelector-BYEAyrsj.d.cts +28 -0
- package/dist/nodeSelector-NqW-FBED.d.ts +28 -0
- package/dist/org-BNs_maoW.cjs +111 -0
- package/dist/org-CScQqL4k.js +32 -0
- package/dist/search-CWkDtqQV.cjs +312 -0
- package/dist/search-OWKKaQQj.js +233 -0
- package/dist/searchContext-3VsAb17A.cjs +146 -0
- package/dist/searchContext-Bhhp_q_P.js +130 -0
- package/dist/searchServiceAdapter-B0h7psvh.js +16 -0
- package/dist/searchServiceAdapter-BclWy4fE.cjs +34 -0
- package/dist/sessionStorageContext-L3f_btsR.cjs +66 -0
- package/dist/sessionStorageContext-kQJRbkHL.js +52 -0
- package/dist/shopifyUrlContext-BsYGfLvw.cjs +75 -0
- package/dist/shopifyUrlContext-CB9LQU_i.js +61 -0
- package/dist/systemSettingsContext-B5plhu8S.cjs +60 -0
- package/dist/systemSettingsContext-Cac6mmfA.js +39 -0
- package/dist/types/index.cjs +3 -48
- package/dist/types/index.d.cts +2 -17
- package/dist/types/index.d.ts +2 -17
- package/dist/types/index.js +2 -44
- package/dist/types-1iJ_FnQQ.cjs +39 -0
- package/dist/types-D5du68Vp.js +27 -0
- package/dist/urlsParser-Dax4iVNC.cjs +78 -0
- package/dist/urlsParser-NAp2LwWP.js +42 -0
- package/dist/useAppDetails-B-lZpIPK.js +30 -0
- package/dist/useAppDetails-BAJjqvyF.cjs +38 -0
- package/dist/useGraphQLConfig-CeYY5maa.js +63 -0
- package/dist/useGraphQLConfig-Cm_lEb1T.cjs +76 -0
- package/dist/{useIntersection-m4PEpvG7.cjs → useIntersection-DuwPFRY9.cjs} +1 -1
- package/dist/{useIntersection-Cncgxdmy.js → useIntersection-bCSteycU.js} +1 -1
- package/dist/{utils-DIvMgPe8.js → utils-B1LVzQYK.js} +1 -1
- package/dist/utils-BZT_oZ3n.js +92 -0
- package/dist/{utils-CDw74BCO.cjs → utils-CiJLDPjY.cjs} +1 -1
- package/dist/{utils-2SWrJ12w.cjs → utils-CqVRbvfN.cjs} +1 -1
- package/dist/utils-D3MjNkd3.cjs +716 -0
- package/dist/utils-DMwh3QbT.js +607 -0
- package/dist/{utils-CqBxIpEV.js → utils-DQhbbAnt.js} +1 -1
- package/dist/{utils-DpneNSJf.d.ts → utils-DjhLO2vO.d.ts} +1 -1
- package/dist/utils-qtHPLFby.cjs +130 -0
- package/package.json +13 -36
- package/src/application/commerce-api.ts +40 -37
- package/src/application/models/graphql/index.ts +1 -0
- package/src/application/models/graphql/queries/getMerchantColorsQuery.ts +1 -23
- package/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.ts +1 -89
- package/src/application/models/guards/api/isApiFormResponse.ts +4 -4
- package/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.ts +2 -2
- package/src/application/models/guards/api/isApiOrderResponseAttributes.ts +2 -20
- package/src/application/models/guards/api/isApiOrgConfigResults.ts +3 -9
- package/src/application/models/guards/api/isApiOrganizationConfig.ts +8 -32
- package/src/application/models/guards/api/isApiPDPEventAttributes.ts +8 -5
- package/src/application/models/guards/api/isApiPLPEventAttributes.ts +14 -10
- package/src/application/models/guards/api/isApiPageResponseAttributes.ts +1 -1
- package/src/application/models/guards/api/isApiProductResponseAttributes.ts +2 -4
- package/src/application/models/guards/api/isApiProductSearchAttributes.ts +9 -6
- package/src/application/models/guards/api/isApiProductSearchFilterAttributes.ts +7 -4
- package/src/application/models/guards/api/isApiQueryTypedEventAttributes.ts +8 -3
- package/src/application/models/guards/api/isApiResponse.ts +22 -15
- package/src/application/models/guards/api/isApiReviewResponseAttributes.ts +1 -1
- package/src/application/models/guards/api/isApiReviewRichInformation.ts +1 -1
- package/src/application/models/guards/api/isApiTextResponseAttributes.ts +1 -1
- package/src/application/models/guards/graphQL/isGraphQLColorsConfig.ts +1 -1
- package/src/application/models/guards/isBaseEcommerceEvent.ts +1 -2
- package/src/application/models/guards/isGA4EcommerceEvent.ts +1 -1
- package/src/application/models/guards/isLegacyUAEcommerceEvent.ts +1 -1
- package/src/application/models/guards/isMobilePLPChatPlacementParameter.ts +1 -3
- package/src/application/models/guards/isSpanxTakeAQuizCtaParameter.ts +5 -3
- package/src/application/models/guards/isVariantInfo.ts +6 -1
- package/src/application/models/index.ts +30 -95
- package/src/application/models/utils/snakeToCamelTransformer.ts +8 -8
- package/src/application/models/validators/validateGraphQLColorsConfig.ts +6 -2
- package/src/application/models/validators/validateGraphQLFrontendConfig.ts +6 -6
- package/src/application/models/validators/validateMobilePLPChatPlacementParameter.ts +5 -3
- package/src/application/models/validators/validateOrgConfigResults.ts +6 -5
- package/src/application/models/validators/validateOrganizationConfig.ts +11 -8
- package/src/application/models/validators/validateResponse.ts +66 -44
- package/src/application/models/validators/validateSuggestion.ts +1 -1
- package/src/application/models/validators/validateUserEvent.ts +23 -12
- package/src/application/utils/analyticsUtils.ts +1 -8
- package/src/application/utils/coreContextToApiContext.ts +3 -1
- package/src/application/utils/coreUserEventToApiUserEvent.ts +2 -2
- package/src/application/utils/elementObserver.ts +1 -1
- package/src/application/utils/imageFilter.ts +5 -2
- package/src/application/utils/index.ts +20 -21
- package/src/application/utils/messageFromFormSubmittedEvent.ts +1 -1
- package/src/application/utils/messageFromQueryEvent.ts +1 -1
- package/src/application/utils/messageFromResponse.ts +14 -10
- package/src/application/utils/messageFromSuggestionEvent.ts +6 -4
- package/src/application/utils/mouseEventTypes.ts +1 -1
- package/src/application/utils/nextMessageRequestToApiRequest.ts +1 -1
- package/src/application/utils/overrides.ts +1 -49
- package/src/application/utils/supportedEventRequestToApiRequest.ts +3 -1
- package/src/application/utils/urlsParser.ts +1 -7
- package/src/atoms/amplitude/amplitudeTrackEventAtom.ts +1 -1
- package/src/atoms/app/index.ts +15 -25
- package/src/atoms/app/variant.ts +1 -1
- package/src/atoms/chat/chatState.ts +4 -4
- package/src/atoms/chat/form.ts +1 -1
- package/src/atoms/chat/messageQueue.ts +25 -50
- package/src/atoms/chat/replies.ts +1 -2
- package/src/atoms/chat/suggestions.ts +34 -29
- package/src/atoms/envive/enviveConfig.ts +15 -20
- package/src/atoms/org/customerService.ts +4 -8
- package/src/atoms/org/graphqlConfig.ts +7 -15
- package/src/atoms/org/index.ts +4 -6
- package/src/atoms/org/newOrgConfigAtom.ts +2 -2
- package/src/atoms/org/orgAnalyticsConfig.ts +1 -1
- package/src/atoms/search/index.ts +0 -1
- package/src/atoms/search/productFilters.ts +72 -52
- package/src/atoms/search/productRetrievalAPI.ts +72 -0
- package/src/atoms/search/productRetrievalAdapter.ts +28 -0
- package/src/atoms/search/productSorter.ts +2 -2
- package/src/atoms/search/searchAPI.ts +42 -60
- package/src/atoms/search/searchServiceAdapter.ts +1 -1
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +24 -62
- package/src/contexts/atomProvider/atomProvider.tsx +6 -0
- package/src/contexts/atomProvider/index.ts +1 -0
- package/src/contexts/cdnContext/cdnContext.tsx +1 -6
- package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +23 -34
- package/src/contexts/enviveCssContext/enviveCssContext.tsx +5 -12
- package/src/contexts/featureFlagContext/featureFlagContext.tsx +27 -48
- package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +11 -3
- package/src/contexts/graphqlContext/graphqlContext.tsx +45 -97
- package/src/contexts/localStorageContext/localStorageContext.tsx +26 -60
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +21 -25
- package/src/contexts/searchContext/searchContext.tsx +30 -49
- package/src/contexts/sessionStorageContext/sessionStorageContext.tsx +12 -33
- package/src/contexts/shopifyUrlContext/shopifyUrlContext.tsx +20 -37
- package/src/contexts/systemSettingsContext/systemSettingsContext.tsx +8 -21
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +33 -77
- package/src/events/index.ts +8 -5
- package/src/events/registerAnalyticsListeners.ts +10 -13
- package/src/exceptions/index.ts +2 -0
- package/src/{types/exceptions → exceptions}/unsupportedProductExceptions.ts +2 -2
- package/src/global.d.ts +8 -0
- package/src/hooks/AmplitudeOperations/useAmplitudeOperations.ts +6 -11
- package/src/hooks/AppDetails/useAppDetails.ts +10 -24
- package/src/hooks/ChatToggle/useChatToggle.ts +7 -19
- package/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.ts +4 -4
- package/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.ts +1 -1
- package/src/hooks/ElementObserver/useElementObserver.ts +14 -32
- package/src/hooks/GrabAndScroll/useGrabAndScroll.ts +125 -124
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +5 -7
- package/src/hooks/ImageResolver/useImageResolver.ts +24 -31
- package/src/hooks/LocalStorageOperations/useLocalStorageOperations.ts +12 -19
- package/src/hooks/MessageFilter/useMessageFilter.ts +1 -7
- package/src/hooks/Search/useRecommendedProducts.ts +50 -0
- package/src/hooks/Search/useSearch.tsx +87 -217
- package/src/hooks/Search/useSearchInput.ts +237 -0
- package/src/hooks/SearchOperations/useSearchOperations.ts +8 -12
- package/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.ts +8 -14
- package/src/hooks/SnapCalculator/useSnapCalculator.ts +1 -2
- package/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.ts +8 -11
- package/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.ts +11 -25
- package/src/hooks/utils.ts +19 -29
- package/src/interceptors/index.ts +1 -2
- package/src/interceptors/useMessageInterceptor.ts +10 -6
- package/src/{application/models/api/response.ts → types/ApiResponse.ts} +35 -29
- package/src/types/FilterAttribute.ts +35 -0
- package/src/{application/models/message.ts → types/Message.ts} +38 -34
- package/src/types/Suggestion.ts +6 -0
- package/src/types/index.ts +4 -5
- package/src/util/colorVar.ts +4 -0
- package/src/util/configVersion.ts +4 -0
- package/src/util/domInsertion.ts +17 -0
- package/dist/SystemSettingsContext-6ZHzQkCE.cjs +0 -20
- package/dist/SystemSettingsContext-BbTKNBvJ.js +0 -13
- package/dist/TrackComponentVisibleEvent-BJgNOypY.js +0 -52
- package/dist/TrackComponentVisibleEvent-BRC2FTp-.cjs +0 -59
- package/dist/amplitudeContext-B73xamNe.d.cts +0 -52
- package/dist/amplitudeContext-CZUzMXHl.d.ts +0 -52
- package/dist/api-BWSsazAG.js +0 -166
- package/dist/api-DeW6rHj3.cjs +0 -239
- package/dist/application/models/utilityTypes/index.cjs +0 -1
- package/dist/application/models/utilityTypes/index.d.cts +0 -2
- package/dist/application/models/utilityTypes/index.d.ts +0 -2
- package/dist/application/models/utilityTypes/index.js +0 -3
- package/dist/application/models/variantInfo/index.cjs +0 -3
- package/dist/application/models/variantInfo/index.d.cts +0 -2
- package/dist/application/models/variantInfo/index.d.ts +0 -2
- package/dist/application/models/variantInfo/index.js +0 -3
- package/dist/atoms/search/types.cjs +0 -5
- package/dist/atoms/search/types.d.cts +0 -2
- package/dist/atoms/search/types.d.ts +0 -2
- package/dist/atoms/search/types.js +0 -3
- package/dist/cdnContext-CEGBVVBU.js +0 -38
- package/dist/cdnContext-DOSIofl8.cjs +0 -53
- package/dist/chat-CqPuT9_V.cjs +0 -393
- package/dist/chat-DH70QqJp.js +0 -257
- package/dist/chatElementDisplayLocation-CpgV2wR1.d.ts +0 -25
- package/dist/chatElementDisplayLocation-DWmfNX_u.d.cts +0 -25
- package/dist/chatSearch-C7Y-hb-6.js +0 -295
- package/dist/chatSearch-DLV4BUGA.cjs +0 -418
- package/dist/chatState-CcFtSqJT.cjs +0 -120
- package/dist/chatState-DKnNHmwe.js +0 -34
- package/dist/contexts/chatContext/index.cjs +0 -326
- package/dist/contexts/chatContext/index.d.cts +0 -15
- package/dist/contexts/chatContext/index.d.ts +0 -15
- package/dist/contexts/chatContext/index.js +0 -319
- package/dist/contexts/types.cjs +0 -7
- package/dist/contexts/types.d.cts +0 -4
- package/dist/contexts/types.d.ts +0 -4
- package/dist/contexts/types.js +0 -3
- package/dist/domObserver-Bqf3ooj8.cjs +0 -304
- package/dist/enviveConfig-DZBohDpc.js +0 -62
- package/dist/enviveConfig-Dv9-esGV.cjs +0 -130
- package/dist/enviveConfigContext-D2OELZDR.cjs +0 -60
- package/dist/enviveConfigContext-DrDjCems.js +0 -45
- package/dist/events-DYY4l817.cjs +0 -90
- package/dist/events-DyUix-Bn.js +0 -78
- package/dist/featureFlagServiceContext-Be_LUbFf.d.cts +0 -23
- package/dist/featureFlagServiceContext-CJyYItqu.cjs +0 -62
- package/dist/featureFlagServiceContext-FBM6DdMJ.js +0 -42
- package/dist/featureFlagServiceContext-V0J-69ty.d.ts +0 -23
- package/dist/featureGates-KEwAL8p_.js +0 -26
- package/dist/featureGates-qU_ulhpC.cjs +0 -32
- package/dist/frontendConfig-CeWhVevA.d.ts +0 -857
- package/dist/frontendConfig-OWWJmuPc.d.cts +0 -857
- package/dist/graphql-3PxNRFOc.js +0 -36
- package/dist/graphql-DGYfelZp.cjs +0 -53
- package/dist/graphqlConfig-GHZ1UgCw.cjs +0 -73
- package/dist/graphqlConfig-mDg6J44N.js +0 -24
- package/dist/graphqlContext-BQA6gnpH.d.ts +0 -28
- package/dist/graphqlContext-Ci5GRAdH.js +0 -96
- package/dist/graphqlContext-D67VEQg3.d.cts +0 -28
- package/dist/graphqlContext-W0cZNBf1.cjs +0 -111
- package/dist/hooks/FloatingButtonVisibility/index.cjs +0 -73
- package/dist/hooks/FloatingButtonVisibility/index.d.cts +0 -7
- package/dist/hooks/FloatingButtonVisibility/index.d.ts +0 -7
- package/dist/hooks/FloatingButtonVisibility/index.js +0 -69
- package/dist/hooks/LastInteraction/index.cjs +0 -34
- package/dist/hooks/LastInteraction/index.d.cts +0 -17
- package/dist/hooks/LastInteraction/index.d.ts +0 -17
- package/dist/hooks/LastInteraction/index.js +0 -32
- package/dist/index-BeGt0Aw3.d.cts +0 -186
- package/dist/index-Bmub8e38.d.cts +0 -98
- package/dist/index-CCa4tZuO.d.ts +0 -184
- package/dist/index-CESxqFso.d.cts +0 -228
- package/dist/index-CgAfoNpB.d.ts +0 -1
- package/dist/index-CiWEYzXl.d.cts +0 -184
- package/dist/index-Cyq5HiC0.d.cts +0 -44
- package/dist/index-D4c-port.d.ts +0 -676
- package/dist/index-DazMsEy_.d.ts +0 -44
- package/dist/index-Dfwnna1j.d.ts +0 -228
- package/dist/index-O33GSSRr.d.cts +0 -676
- package/dist/index-RcVcRKH7.d.cts +0 -1
- package/dist/index-bjMvkcBF.d.ts +0 -98
- package/dist/index-xhBQ1HBx.d.ts +0 -186
- package/dist/interceptors/types.cjs +0 -1
- package/dist/interceptors/types.d.cts +0 -13
- package/dist/interceptors/types.d.ts +0 -13
- package/dist/interceptors/types.js +0 -3
- package/dist/localStorageContext-BPZ82q-G.js +0 -95
- package/dist/localStorageContext-NRP-CdmF.cjs +0 -115
- package/dist/models-D-4db7XW.cjs +0 -1537
- package/dist/models-c86hYW-F.js +0 -1296
- package/dist/newOrgConfigAtom-sqve6LZU.js +0 -8
- package/dist/newOrgConfigContext-5Bw7RwT-.d.cts +0 -16
- package/dist/newOrgConfigContext-CS8IA5Eg.d.ts +0 -16
- package/dist/newOrgConfigContext-Cl4H9c3q.cjs +0 -68
- package/dist/newOrgConfigContext-DQiuf8nd.js +0 -53
- package/dist/nodeSelector-B3bPtEjX.d.cts +0 -31
- package/dist/nodeSelector-BiCDowlK.d.ts +0 -31
- package/dist/org-DlAesvQ_.cjs +0 -43
- package/dist/org-vi0njpBh.js +0 -12
- package/dist/search-1NQLQD9d.d.ts +0 -20
- package/dist/search-CXXslzAO.cjs +0 -205
- package/dist/search-DBSMrXWv.js +0 -126
- package/dist/search-filter-types-BxaNSLs_.d.cts +0 -102
- package/dist/search-filter-types-DPgeG8FS.d.ts +0 -102
- package/dist/search-y-ioX5Mz.d.cts +0 -20
- package/dist/searchContext-DXW6xvXv.cjs +0 -145
- package/dist/searchContext-mvwUJncR.js +0 -129
- package/dist/searchServiceAdapter-DEv1tTn0.cjs +0 -34
- package/dist/searchServiceAdapter-WyCU55NV.js +0 -16
- package/dist/sessionStorageContext-1Ks_d4Z0.cjs +0 -66
- package/dist/sessionStorageContext-CDcl7NVl.js +0 -52
- package/dist/shopifyUrlContext-CejRZfj7.js +0 -61
- package/dist/shopifyUrlContext-lnHoAOEf.cjs +0 -75
- package/dist/spiffyWidgets-B1uc84_g.d.ts +0 -20
- package/dist/spiffyWidgets-BuS00VaQ.d.cts +0 -20
- package/dist/systemSettingsContext-B0Kyq7nA.cjs +0 -60
- package/dist/systemSettingsContext-CVUxEcsU.js +0 -39
- package/dist/test-types-ThQiO_cc.d.cts +0 -40
- package/dist/test-types-y6kp-tiw.d.ts +0 -40
- package/dist/types-BCz-hOvv.d.ts +0 -51
- package/dist/types-CKMMb_gX.d.cts +0 -51
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-CS0Hrzja.js +0 -30
- package/dist/types-CtUb63bt.js +0 -76
- package/dist/types-CxObxLKs.cjs +0 -48
- package/dist/types-Db5Eux6K.d.ts +0 -10
- package/dist/types-Dc6hx6ei.js +0 -1
- package/dist/types-UUvB6h05.cjs +0 -106
- package/dist/types-zQGBI-Yo.d.cts +0 -10
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +0 -34
- package/dist/types.d.ts +0 -34
- package/dist/types.js +0 -1
- package/dist/urlsParser-COzMdJaX.cjs +0 -78
- package/dist/urlsParser-DxjoLj98.js +0 -42
- package/dist/useAmplitudeOperations-DYs1h8a_.js +0 -34
- package/dist/useAmplitudeOperations-jqa7K9dH.cjs +0 -41
- package/dist/useAppDetails-BRUqZEyt.js +0 -30
- package/dist/useAppDetails-C71k0brz.cjs +0 -38
- package/dist/useDebounce-DZ8Cgiwc.cjs +0 -26
- package/dist/useDebounce-v9cezyjn.js +0 -19
- package/dist/useGraphQLConfig-5VwS9Q_Z.js +0 -63
- package/dist/useGraphQLConfig-Cj26_J9I.cjs +0 -76
- package/dist/useMessageInterceptor-BjGP_uXm.js +0 -25
- package/dist/useMessageInterceptor-arAqUq1Q.cjs +0 -33
- package/dist/userIdentityContext-BVODeTlN.d.ts +0 -20
- package/dist/userIdentityContext-D2oFVFzo.d.cts +0 -20
- package/dist/utilityTypes-B2KuRn37.js +0 -1
- package/dist/utilityTypes-BGbL2WTP.cjs +0 -0
- package/dist/utils-BxPPugeP.d.cts +0 -22
- package/dist/utils-CLGXsOwE.cjs +0 -1591
- package/dist/utils-Covisryh.d.ts +0 -22
- package/dist/utils-D_kATUj6.js +0 -92
- package/dist/utils-hYTjy7hJ.cjs +0 -130
- package/dist/utils-jYtD3hmA.js +0 -1385
- package/dist/variantInfo-BfKlkaWU.js +0 -11
- package/dist/variantInfo-DpLn4nHz.cjs +0 -17
- package/src/application/models/api/context.ts +0 -4
- package/src/application/models/api/generationParams.ts +0 -4
- package/src/application/models/api/nextMessageRequest.ts +0 -11
- package/src/application/models/api/orgAnalyticsConfig.ts +0 -19
- package/src/application/models/api/orgConfigResults.ts +0 -44
- package/src/application/models/api/organizationConfig.ts +0 -12
- package/src/application/models/api/responseGenerics.ts +0 -67
- package/src/application/models/api/search.ts +0 -26
- package/src/application/models/api/suggestion.ts +0 -4
- package/src/application/models/api/supportedEventRequest.ts +0 -8
- package/src/application/models/api/userEvent.ts +0 -101
- package/src/application/models/cachedValue.ts +0 -8
- package/src/application/models/chatElementDisplayLocation.ts +0 -22
- package/src/application/models/clientDetails.ts +0 -18
- package/src/application/models/colorsConfig.ts +0 -28
- package/src/application/models/conversationalSearchIds.ts +0 -5
- package/src/application/models/dataLayer.ts +0 -45
- package/src/application/models/events.ts +0 -5
- package/src/application/models/featureGates.ts +0 -21
- package/src/application/models/frontendConfig.ts +0 -14
- package/src/application/models/googleAnalyticsEvents.ts +0 -8
- package/src/application/models/localStorageEventListener.ts +0 -4
- package/src/application/models/mobilePLPChatPlacementParameter.ts +0 -3
- package/src/application/models/orgsEnum.ts +0 -36
- package/src/application/models/productExperiment.ts +0 -5
- package/src/application/models/spanxTakeAQuizCtaParameter.ts +0 -4
- package/src/application/models/spiffyWidgets.ts +0 -16
- package/src/application/models/utilityTypes/camelCase.ts +0 -87
- package/src/application/models/utilityTypes/camelCasedPropertiesDeep.ts +0 -80
- package/src/application/models/utilityTypes/delimiterCase.ts +0 -121
- package/src/application/models/utilityTypes/delimiterCasedPropertiesDeep.ts +0 -98
- package/src/application/models/utilityTypes/index.ts +0 -1
- package/src/application/models/utilityTypes/internal.ts +0 -93
- package/src/application/models/utilityTypes/primitive.ts +0 -8
- package/src/application/models/utilityTypes/snakeCasedPropertiesDeep.ts +0 -49
- package/src/application/models/utilityTypes/splitWords.ts +0 -76
- package/src/application/models/utilityTypes/trim.ts +0 -28
- package/src/application/models/utilityTypes/unknownArray.ts +0 -25
- package/src/application/models/variantInfo/index.ts +0 -1
- package/src/application/models/variantInfo/pageVisitInfo.ts +0 -6
- package/src/application/models/variantInfo/plpInfo.ts +0 -3
- package/src/application/models/variantInfo/productInfo.ts +0 -5
- package/src/application/models/variantInfo/variantInfo.ts +0 -29
- package/src/application/utils/__tests__/divideArrays.test.ts +0 -14
- package/src/application/utils/cdnUtils.ts +0 -11
- package/src/atoms/search/chatSearch.ts +0 -317
- package/src/atoms/search/types.ts +0 -55
- package/src/config/divIds.ts +0 -27
- package/src/config/socialProofClasses.ts +0 -17
- package/src/contexts/chatContext/chatContext.tsx +0 -509
- package/src/contexts/chatContext/index.ts +0 -1
- package/src/contexts/types.ts +0 -1067
- package/src/events/event-types.ts +0 -11
- package/src/hooks/FloatingButtonVisibility/index.ts +0 -1
- package/src/hooks/FloatingButtonVisibility/useFloatingButtonVisibility.ts +0 -99
- package/src/hooks/LastInteraction/index.ts +0 -1
- package/src/hooks/LastInteraction/useLastInteraction.ts +0 -42
- package/src/interceptors/types.ts +0 -6
- package/src/merchants/domInsertion.ts +0 -30
- package/src/merchants/gridInsertion.ts +0 -19
- package/src/types/config-versions.ts +0 -6
- package/src/types/customerService.ts +0 -31
- package/src/types/custservice-types.ts +0 -28
- package/src/types/floatingbuttonoverrides-types.ts +0 -10
- package/src/types/search-filter-types.ts +0 -111
- package/src/types/suggestionBarV2-types.ts +0 -4
- package/src/types/test-types.ts +0 -3
- package/src/types.ts +0 -27
- /package/dist/{AmplitudeOperations-DxQnurSG.cjs → enviveConfigContext-CZPfJkcS.cjs} +0 -0
- /package/dist/{AmplitudeOperations-ni7wVevx.js → enviveConfigContext-Hc1JBLu-.js} +0 -0
- /package/dist/{globalSearch-BpGfkuXz.js → featureFlagServiceContext-CISyb90N.js} +0 -0
- /package/dist/{globalSearch-B9DRBxSM.cjs → featureFlagServiceContext-Csgo-MUv.cjs} +0 -0
- /package/src/{types/exceptions → exceptions}/sessionExceptions.ts +0 -0
|
@@ -1,37 +1,17 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import Logger from "src/application/logging/logger";
|
|
9
|
-
import { LocalStorageEventListener } from "src/application/models/localStorageEventListener";
|
|
10
|
-
|
|
11
|
-
export enum LocalStorageKeys {
|
|
12
|
-
ChatId = "v1-spiffy-chat-session-id",
|
|
13
|
-
SpiffyOnOverride = "spiffy_on",
|
|
14
|
-
EnviveOnOverride = "envive_on",
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface LocalStorageContextType {
|
|
18
|
-
setItem: (key: string, value: string) => void;
|
|
19
|
-
getItem: (key: string) => string | null;
|
|
20
|
-
setSpiffyOnFeatureFlag: (value: boolean | null) => void;
|
|
21
|
-
getSpiffyOnFeatureFlag: () => string | null;
|
|
22
|
-
attachListener: (listener: LocalStorageEventListener) => void;
|
|
23
|
-
detachListener: (listener: LocalStorageEventListener) => void;
|
|
24
|
-
isAvailable: boolean;
|
|
25
|
-
}
|
|
1
|
+
import React, { createContext, useContext, useCallback, useMemo, useEffect } from 'react';
|
|
2
|
+
import Logger from '../../application/logging/logger';
|
|
3
|
+
import {
|
|
4
|
+
LocalStorageContextType,
|
|
5
|
+
LocalStorageEventListener,
|
|
6
|
+
LocalStorageKeys,
|
|
7
|
+
} from '@envive-ai/types';
|
|
26
8
|
|
|
27
9
|
const LocalStorageContext = createContext<LocalStorageContextType | null>(null);
|
|
28
10
|
|
|
29
|
-
export const LocalStorageProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
30
|
-
children,
|
|
31
|
-
}) => {
|
|
11
|
+
export const LocalStorageProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
|
32
12
|
const isAvailable = useMemo(() => {
|
|
33
13
|
try {
|
|
34
|
-
return typeof window !==
|
|
14
|
+
return typeof window !== 'undefined' && !!window.localStorage;
|
|
35
15
|
} catch {
|
|
36
16
|
return false;
|
|
37
17
|
}
|
|
@@ -39,7 +19,7 @@ export const LocalStorageProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
39
19
|
|
|
40
20
|
useEffect(() => {
|
|
41
21
|
if (!isAvailable) {
|
|
42
|
-
Logger.logError(
|
|
22
|
+
Logger.logError('localStorage is not available', undefined);
|
|
43
23
|
}
|
|
44
24
|
}, [isAvailable]);
|
|
45
25
|
|
|
@@ -47,11 +27,9 @@ export const LocalStorageProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
47
27
|
(key: string, value: string) => {
|
|
48
28
|
if (!isAvailable) return;
|
|
49
29
|
localStorage.setItem(key, value);
|
|
50
|
-
window.dispatchEvent(
|
|
51
|
-
new StorageEvent("storage", { key, newValue: value })
|
|
52
|
-
);
|
|
30
|
+
window.dispatchEvent(new StorageEvent('storage', { key, newValue: value }));
|
|
53
31
|
},
|
|
54
|
-
[isAvailable]
|
|
32
|
+
[isAvailable],
|
|
55
33
|
);
|
|
56
34
|
|
|
57
35
|
const getItem = useCallback(
|
|
@@ -59,19 +37,19 @@ export const LocalStorageProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
59
37
|
if (!isAvailable) return null;
|
|
60
38
|
return localStorage.getItem(key);
|
|
61
39
|
},
|
|
62
|
-
[isAvailable]
|
|
40
|
+
[isAvailable],
|
|
63
41
|
);
|
|
64
42
|
|
|
65
43
|
const setSpiffyOnFeatureFlag = useCallback(
|
|
66
44
|
(value: boolean | null): void => {
|
|
67
45
|
if (!isAvailable) return;
|
|
68
46
|
if (value === true) {
|
|
69
|
-
localStorage.setItem(LocalStorageKeys.SpiffyOnOverride,
|
|
47
|
+
localStorage.setItem(LocalStorageKeys.SpiffyOnOverride, 'true');
|
|
70
48
|
} else if (value === false) {
|
|
71
|
-
localStorage.setItem(LocalStorageKeys.SpiffyOnOverride,
|
|
49
|
+
localStorage.setItem(LocalStorageKeys.SpiffyOnOverride, 'false');
|
|
72
50
|
}
|
|
73
51
|
},
|
|
74
|
-
[isAvailable]
|
|
52
|
+
[isAvailable],
|
|
75
53
|
);
|
|
76
54
|
|
|
77
55
|
const getSpiffyOnFeatureFlag = useCallback((): string | null => {
|
|
@@ -79,10 +57,7 @@ export const LocalStorageProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
79
57
|
return localStorage.getItem(LocalStorageKeys.SpiffyOnOverride);
|
|
80
58
|
}, [isAvailable]);
|
|
81
59
|
|
|
82
|
-
const listenersCache = useMemo(
|
|
83
|
-
() => new Map<string, (event: StorageEvent) => void>(),
|
|
84
|
-
[]
|
|
85
|
-
);
|
|
60
|
+
const listenersCache = useMemo(() => new Map<string, (event: StorageEvent) => void>(), []);
|
|
86
61
|
|
|
87
62
|
const listenerForKey = useCallback(
|
|
88
63
|
(listener: LocalStorageEventListener): ((event: StorageEvent) => void) => {
|
|
@@ -91,33 +66,30 @@ export const LocalStorageProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
91
66
|
if (event.key !== listener.storageKey) {
|
|
92
67
|
return;
|
|
93
68
|
}
|
|
94
|
-
Logger.logDebug(
|
|
95
|
-
`[spiffy-ai] Storage event key=${event.key}, value=`,
|
|
96
|
-
event.newValue
|
|
97
|
-
);
|
|
69
|
+
Logger.logDebug(`[spiffy-ai] Storage event key=${event.key}, value=`, event.newValue);
|
|
98
70
|
listener.listener(event);
|
|
99
71
|
};
|
|
100
72
|
listenersCache.set(listener.storageKey, handler);
|
|
101
73
|
}
|
|
102
74
|
return listenersCache.get(listener.storageKey)!;
|
|
103
75
|
},
|
|
104
|
-
[listenersCache]
|
|
76
|
+
[listenersCache],
|
|
105
77
|
);
|
|
106
78
|
|
|
107
79
|
const attachListener = useCallback(
|
|
108
80
|
(listener: LocalStorageEventListener): void => {
|
|
109
81
|
if (!isAvailable) return;
|
|
110
|
-
window.addEventListener(
|
|
82
|
+
window.addEventListener('storage', listenerForKey(listener));
|
|
111
83
|
},
|
|
112
|
-
[isAvailable, listenerForKey]
|
|
84
|
+
[isAvailable, listenerForKey],
|
|
113
85
|
);
|
|
114
86
|
|
|
115
87
|
const detachListener = useCallback(
|
|
116
88
|
(listener: LocalStorageEventListener): void => {
|
|
117
89
|
if (!isAvailable) return;
|
|
118
|
-
window.removeEventListener(
|
|
90
|
+
window.removeEventListener('storage', listenerForKey(listener));
|
|
119
91
|
},
|
|
120
|
-
[isAvailable, listenerForKey]
|
|
92
|
+
[isAvailable, listenerForKey],
|
|
121
93
|
);
|
|
122
94
|
|
|
123
95
|
const value = useMemo(
|
|
@@ -138,22 +110,16 @@ export const LocalStorageProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
138
110
|
attachListener,
|
|
139
111
|
detachListener,
|
|
140
112
|
isAvailable,
|
|
141
|
-
]
|
|
113
|
+
],
|
|
142
114
|
);
|
|
143
115
|
|
|
144
|
-
return
|
|
145
|
-
<LocalStorageContext.Provider value={value}>
|
|
146
|
-
{children}
|
|
147
|
-
</LocalStorageContext.Provider>
|
|
148
|
-
);
|
|
116
|
+
return <LocalStorageContext.Provider value={value}>{children}</LocalStorageContext.Provider>;
|
|
149
117
|
};
|
|
150
118
|
|
|
151
119
|
export const useLocalStorage = () => {
|
|
152
120
|
const context = useContext(LocalStorageContext);
|
|
153
121
|
if (!context) {
|
|
154
|
-
throw new Error(
|
|
155
|
-
"useLocalStorage must be used within a LocalStorageProvider"
|
|
156
|
-
);
|
|
122
|
+
throw new Error('useLocalStorage must be used within a LocalStorageProvider');
|
|
157
123
|
}
|
|
158
124
|
return context;
|
|
159
125
|
};
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
import React, { createContext, useContext, ReactNode, useMemo } from
|
|
2
|
-
import { useAtomValue, useSetAtom } from
|
|
3
|
-
import { useColorsAndFrontendConfig } from
|
|
4
|
-
import { orgShortNameAtom } from
|
|
5
|
-
import { newOrgConfigAtom } from
|
|
6
|
-
import { OrgConfigFeatureGate } from
|
|
7
|
-
import { FeatureFlagServiceProvider } from
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
export type NewOrgConfigContextType = GraphQlConfigValues & {
|
|
11
|
-
loading: boolean;
|
|
12
|
-
error: Error | null;
|
|
13
|
-
};
|
|
1
|
+
import React, { createContext, useContext, ReactNode, useMemo, useEffect } from 'react';
|
|
2
|
+
import { useAtomValue, useSetAtom } from 'jotai';
|
|
3
|
+
import { useColorsAndFrontendConfig } from 'src/hooks/GraphQLConfig/useGraphQLConfig';
|
|
4
|
+
import { orgShortNameAtom } from 'src/atoms/envive/enviveConfig';
|
|
5
|
+
import { newOrgConfigAtom } from 'src/atoms/org/newOrgConfigAtom';
|
|
6
|
+
import { EnviveConfig, NewOrgConfigContextType, OrgConfigFeatureGate } from '@envive-ai/types';
|
|
7
|
+
import { FeatureFlagServiceProvider } from '../featureFlagServiceContext';
|
|
8
|
+
import { EnviveConfigContext } from '../enviveConfigContext';
|
|
14
9
|
|
|
15
|
-
const NewOrgConfigContext = createContext<NewOrgConfigContextType | undefined>(
|
|
16
|
-
undefined
|
|
17
|
-
);
|
|
10
|
+
const NewOrgConfigContext = createContext<NewOrgConfigContextType | undefined>(undefined);
|
|
18
11
|
|
|
19
12
|
interface NewOrgConfigProviderProps {
|
|
20
13
|
children: ReactNode;
|
|
21
14
|
}
|
|
22
15
|
|
|
23
|
-
export const NewOrgConfigProvider: React.FC<NewOrgConfigProviderProps> = ({
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
27
|
-
const setNewOrgConfig = useSetAtom(newOrgConfigAtom);
|
|
16
|
+
export const NewOrgConfigProvider: React.FC<NewOrgConfigProviderProps> = ({ children }) => {
|
|
17
|
+
|
|
18
|
+
const { orgShortName } = useContext(EnviveConfigContext) as EnviveConfig;
|
|
28
19
|
|
|
29
20
|
const { data: newConfig, loading, error } = useColorsAndFrontendConfig();
|
|
30
21
|
|
|
@@ -36,7 +27,7 @@ export const NewOrgConfigProvider: React.FC<NewOrgConfigProviderProps> = ({
|
|
|
36
27
|
if (error) {
|
|
37
28
|
return { ...newConfig, loading: false, error };
|
|
38
29
|
}
|
|
39
|
-
|
|
30
|
+
|
|
40
31
|
return { ...newConfig, loading: false, error: null };
|
|
41
32
|
}, [orgShortName, loading, error]);
|
|
42
33
|
|
|
@@ -54,10 +45,15 @@ export const NewOrgConfigProvider: React.FC<NewOrgConfigProviderProps> = ({
|
|
|
54
45
|
|
|
55
46
|
export const useNewOrgConfigContext = () => {
|
|
56
47
|
const context = useContext(NewOrgConfigContext);
|
|
48
|
+
|
|
49
|
+
const setNewOrgConfig = useSetAtom(newOrgConfigAtom);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (context) {
|
|
52
|
+
setNewOrgConfig(context);
|
|
53
|
+
}
|
|
54
|
+
}, [context, setNewOrgConfig]);
|
|
57
55
|
if (context === undefined) {
|
|
58
|
-
throw new Error(
|
|
59
|
-
"useNewOrgConfigContext must be used within a NewOrgConfigProvider"
|
|
60
|
-
);
|
|
56
|
+
throw new Error('useNewOrgConfigContext must be used within a NewOrgConfigProvider');
|
|
61
57
|
}
|
|
62
58
|
return context;
|
|
63
59
|
};
|
|
@@ -1,30 +1,23 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
useContext,
|
|
4
|
-
useCallback,
|
|
5
|
-
useMemo,
|
|
6
|
-
useEffect,
|
|
7
|
-
} from "react";
|
|
8
|
-
import { useAtomValue } from "jotai";
|
|
1
|
+
import React, { createContext, useContext, useCallback, useMemo, useEffect } from 'react';
|
|
2
|
+
import { useAtomValue } from 'jotai';
|
|
9
3
|
import {
|
|
10
4
|
Configuration,
|
|
11
5
|
ResponseCategory,
|
|
12
6
|
ResponseError,
|
|
13
7
|
SearchApi,
|
|
14
|
-
} from
|
|
15
|
-
import { baseUrlAtom } from
|
|
16
|
-
import Logger from
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import { UnsupportedProductException } from "src/types/exceptions/unsupportedProductExceptions";
|
|
21
|
-
import { SearchParams, SearchResult } from "src/application/models/api/search";
|
|
8
|
+
} from '@spiffy-ai/commerce-api-client';
|
|
9
|
+
import { baseUrlAtom } from '../../atoms/envive/enviveConfig';
|
|
10
|
+
import Logger from '../../application/logging/logger';
|
|
11
|
+
import { SessionRestartRequired, UnsupportedProductException } from '../../exceptions';
|
|
12
|
+
import { useAppDetails } from '../../hooks/AppDetails/useAppDetails';
|
|
13
|
+
import { useEnviveConfig } from '../../contexts/enviveConfigContext/enviveConfigContext';
|
|
22
14
|
import {
|
|
23
15
|
clearSearchServiceFunction,
|
|
24
16
|
setSearchServiceFunction,
|
|
25
|
-
} from
|
|
17
|
+
} from '../../atoms/search/searchServiceAdapter';
|
|
18
|
+
import { SearchContextValue, SearchParams, SearchResult } from '@envive-ai/types';
|
|
26
19
|
|
|
27
|
-
const transformProductResponses = (products: SearchResult[
|
|
20
|
+
const transformProductResponses = (products: SearchResult['products']) =>
|
|
28
21
|
products.map((data) => ({
|
|
29
22
|
id: data.id,
|
|
30
23
|
responseId: data.response_id,
|
|
@@ -61,19 +54,19 @@ async function throwSessionRestartRequiredIf(errorMsg: string, error: unknown) {
|
|
|
61
54
|
|
|
62
55
|
const errorResponse = await errorResponseBody(error);
|
|
63
56
|
if (
|
|
64
|
-
errorResponse?.message?.toLowerCase() ===
|
|
65
|
-
errorResponse?.app_code?.toUpperCase() ===
|
|
57
|
+
errorResponse?.message?.toLowerCase() === 'unsupported product' ||
|
|
58
|
+
errorResponse?.app_code?.toUpperCase() === 'PRODUCT_NOT_FOUND'
|
|
66
59
|
) {
|
|
67
60
|
throw new UnsupportedProductException();
|
|
68
61
|
} else if (
|
|
69
|
-
errorResponse?.app_code?.toUpperCase() ===
|
|
70
|
-
errorResponse?.sub_code?.toUpperCase() ===
|
|
62
|
+
errorResponse?.app_code?.toUpperCase() === 'RESTART_SESSION' ||
|
|
63
|
+
errorResponse?.sub_code?.toUpperCase() === 'NOT_FOUND'
|
|
71
64
|
) {
|
|
72
65
|
Logger.logInfo(
|
|
73
|
-
|
|
66
|
+
'Session does not exist. Re-start session',
|
|
74
67
|
error,
|
|
75
68
|
error.response,
|
|
76
|
-
errorResponse
|
|
69
|
+
errorResponse,
|
|
77
70
|
);
|
|
78
71
|
throw new SessionRestartRequired();
|
|
79
72
|
}
|
|
@@ -82,20 +75,14 @@ async function throwSessionRestartRequiredIf(errorMsg: string, error: unknown) {
|
|
|
82
75
|
throw error;
|
|
83
76
|
}
|
|
84
77
|
|
|
85
|
-
interface SearchContextValue {
|
|
86
|
-
searchProducts: (params: SearchParams) => Promise<SearchResult>;
|
|
87
|
-
isReady: boolean;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
78
|
const SearchContext = createContext<SearchContextValue | undefined>(undefined);
|
|
91
79
|
|
|
92
|
-
export const SearchProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
93
|
-
children,
|
|
94
|
-
}) => {
|
|
80
|
+
export const SearchProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
|
95
81
|
const { orgLevelApiKey, publicKey } = useEnviveConfig();
|
|
96
82
|
const apiKey = orgLevelApiKey || publicKey; // Replicate apiKeyAtom logic
|
|
97
83
|
const appDetails = useAppDetails();
|
|
98
84
|
const baseUrl = useAtomValue(baseUrlAtom);
|
|
85
|
+
console.log('SearchProvider: inside SearchProvider');
|
|
99
86
|
|
|
100
87
|
const isReady = Boolean(apiKey && appDetails && baseUrl);
|
|
101
88
|
|
|
@@ -106,8 +93,8 @@ export const SearchProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
106
93
|
accessToken: apiKey,
|
|
107
94
|
basePath: baseUrl,
|
|
108
95
|
headers: {
|
|
109
|
-
|
|
110
|
-
Accept:
|
|
96
|
+
'Content-Type': 'application/json',
|
|
97
|
+
Accept: 'application/json',
|
|
111
98
|
},
|
|
112
99
|
});
|
|
113
100
|
return new SearchApi(config);
|
|
@@ -116,7 +103,7 @@ export const SearchProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
116
103
|
const searchProducts = useCallback(
|
|
117
104
|
async (params: SearchParams): Promise<SearchResult> => {
|
|
118
105
|
if (!isReady || !searchApi) {
|
|
119
|
-
throw new Error(
|
|
106
|
+
throw new Error('SearchService not ready - missing dependencies');
|
|
120
107
|
}
|
|
121
108
|
|
|
122
109
|
try {
|
|
@@ -126,30 +113,26 @@ export const SearchProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
126
113
|
org_id: appDetails.orgId,
|
|
127
114
|
user_id: appDetails.userId,
|
|
128
115
|
});
|
|
129
|
-
const {
|
|
130
|
-
products,
|
|
131
|
-
filters,
|
|
132
|
-
search_response_id: searchResponseId,
|
|
133
|
-
} = response;
|
|
116
|
+
const { products, filters, search_response_id: searchResponseId } = response;
|
|
134
117
|
|
|
135
118
|
return {
|
|
136
119
|
products: transformProductResponses(products) || [],
|
|
137
120
|
filters: filters || [],
|
|
138
121
|
totalProductCount: products?.length || 0,
|
|
139
|
-
searchResponseId: searchResponseId ||
|
|
122
|
+
searchResponseId: searchResponseId || '',
|
|
140
123
|
};
|
|
141
124
|
} catch (error) {
|
|
142
|
-
await throwSessionRestartRequiredIf(
|
|
125
|
+
await throwSessionRestartRequiredIf('Failed to search products', error);
|
|
143
126
|
// This part will not be reached if an exception is thrown, but it's required for type safety
|
|
144
127
|
return {
|
|
145
128
|
products: [],
|
|
146
129
|
filters: [],
|
|
147
130
|
totalProductCount: 0,
|
|
148
|
-
searchResponseId:
|
|
131
|
+
searchResponseId: '',
|
|
149
132
|
};
|
|
150
133
|
}
|
|
151
134
|
},
|
|
152
|
-
[searchApi, isReady, appDetails]
|
|
135
|
+
[searchApi, isReady, appDetails],
|
|
153
136
|
);
|
|
154
137
|
|
|
155
138
|
// Register the search function with the adapter for use in atoms
|
|
@@ -170,18 +153,16 @@ export const SearchProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
170
153
|
searchProducts,
|
|
171
154
|
isReady,
|
|
172
155
|
}),
|
|
173
|
-
[searchProducts, isReady]
|
|
156
|
+
[searchProducts, isReady],
|
|
174
157
|
);
|
|
175
158
|
|
|
176
|
-
return
|
|
177
|
-
<SearchContext.Provider value={value}>{children}</SearchContext.Provider>
|
|
178
|
-
);
|
|
159
|
+
return <SearchContext.Provider value={value}>{children}</SearchContext.Provider>;
|
|
179
160
|
};
|
|
180
161
|
|
|
181
162
|
export const useSearchService = () => {
|
|
182
163
|
const context = useContext(SearchContext);
|
|
183
164
|
if (!context) {
|
|
184
|
-
throw new Error(
|
|
165
|
+
throw new Error('useSearchService must be used within a SearchProvider');
|
|
185
166
|
}
|
|
186
167
|
return context;
|
|
187
168
|
};
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
useCallback,
|
|
5
|
-
useMemo,
|
|
6
|
-
useEffect,
|
|
7
|
-
} from "react";
|
|
8
|
-
import Logger from "../../application/logging/logger";
|
|
1
|
+
import React, { createContext, useContext, useCallback, useMemo, useEffect } from 'react';
|
|
2
|
+
import Logger from '../../application/logging/logger';
|
|
3
|
+
import { SessionStorageContextType } from '@envive-ai/types';
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
setItem: (key: string, value: string) => void;
|
|
12
|
-
getItem: (key: string) => string | null;
|
|
13
|
-
isAvailable: boolean;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const SessionStorageContext = createContext<SessionStorageContextType | null>(
|
|
17
|
-
null
|
|
18
|
-
);
|
|
5
|
+
const SessionStorageContext = createContext<SessionStorageContextType | null>(null);
|
|
19
6
|
|
|
20
7
|
export const SessionStorageProvider: React.FC<{
|
|
21
8
|
children: React.ReactNode;
|
|
22
9
|
}> = ({ children }) => {
|
|
23
10
|
const isAvailable = useMemo(() => {
|
|
24
11
|
try {
|
|
25
|
-
return typeof window !==
|
|
12
|
+
return typeof window !== 'undefined' && !!window.sessionStorage;
|
|
26
13
|
} catch {
|
|
27
14
|
return false;
|
|
28
15
|
}
|
|
@@ -30,7 +17,7 @@ export const SessionStorageProvider: React.FC<{
|
|
|
30
17
|
|
|
31
18
|
useEffect(() => {
|
|
32
19
|
if (!isAvailable) {
|
|
33
|
-
Logger.logError(
|
|
20
|
+
Logger.logError('sessionStorage is not available', undefined);
|
|
34
21
|
}
|
|
35
22
|
}, [isAvailable]);
|
|
36
23
|
|
|
@@ -38,11 +25,9 @@ export const SessionStorageProvider: React.FC<{
|
|
|
38
25
|
(key: string, value: string) => {
|
|
39
26
|
if (!isAvailable) return;
|
|
40
27
|
sessionStorage.setItem(key, value);
|
|
41
|
-
window.dispatchEvent(
|
|
42
|
-
new StorageEvent("storage", { key, newValue: value })
|
|
43
|
-
);
|
|
28
|
+
window.dispatchEvent(new StorageEvent('storage', { key, newValue: value }));
|
|
44
29
|
},
|
|
45
|
-
[isAvailable]
|
|
30
|
+
[isAvailable],
|
|
46
31
|
);
|
|
47
32
|
|
|
48
33
|
const getItem = useCallback(
|
|
@@ -50,7 +35,7 @@ export const SessionStorageProvider: React.FC<{
|
|
|
50
35
|
if (!isAvailable) return null;
|
|
51
36
|
return sessionStorage.getItem(key);
|
|
52
37
|
},
|
|
53
|
-
[isAvailable]
|
|
38
|
+
[isAvailable],
|
|
54
39
|
);
|
|
55
40
|
|
|
56
41
|
const value = useMemo(
|
|
@@ -59,22 +44,16 @@ export const SessionStorageProvider: React.FC<{
|
|
|
59
44
|
getItem,
|
|
60
45
|
isAvailable,
|
|
61
46
|
}),
|
|
62
|
-
[setItem, getItem, isAvailable]
|
|
47
|
+
[setItem, getItem, isAvailable],
|
|
63
48
|
);
|
|
64
49
|
|
|
65
|
-
return
|
|
66
|
-
<SessionStorageContext.Provider value={value}>
|
|
67
|
-
{children}
|
|
68
|
-
</SessionStorageContext.Provider>
|
|
69
|
-
);
|
|
50
|
+
return <SessionStorageContext.Provider value={value}>{children}</SessionStorageContext.Provider>;
|
|
70
51
|
};
|
|
71
52
|
|
|
72
53
|
export const useSessionStorage = () => {
|
|
73
54
|
const context = useContext(SessionStorageContext);
|
|
74
55
|
if (!context) {
|
|
75
|
-
throw new Error(
|
|
76
|
-
"useSessionStorage must be used within a SessionStorageProvider"
|
|
77
|
-
);
|
|
56
|
+
throw new Error('useSessionStorage must be used within a SessionStorageProvider');
|
|
78
57
|
}
|
|
79
58
|
return context;
|
|
80
59
|
};
|
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import React, { createContext, useCallback, useContext, useMemo } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import React, { createContext, useCallback, useContext, useMemo } from 'react';
|
|
2
|
+
import { parseHref } from '../../application/utils/urlsParser';
|
|
3
|
+
import { IdExtractor, ShopifyUrlContextType } from '@envive-ai/types';
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
getTrimmedPathName: () => string | null;
|
|
7
|
-
getPlpOrPdpId: (extractor: IdExtractor) => string | null;
|
|
8
|
-
isOnPdpPage: () => boolean;
|
|
9
|
-
isOnPlpPage: () => boolean;
|
|
10
|
-
isReady: boolean;
|
|
11
|
-
}
|
|
5
|
+
const ShopifyUrlContext = createContext<ShopifyUrlContextType | undefined>(undefined);
|
|
12
6
|
|
|
13
|
-
const
|
|
14
|
-
undefined
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
export const ShopifyUrlProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
18
|
-
children,
|
|
19
|
-
}) => {
|
|
7
|
+
export const ShopifyUrlProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
|
20
8
|
const isReady = true; // No external dependencies, so always ready
|
|
21
9
|
|
|
22
10
|
const getTrimmedPathName = useCallback((): string | null => {
|
|
23
11
|
let { pathname } = window.location;
|
|
24
12
|
// strip out the proxy path so local dev still works
|
|
25
|
-
pathname = pathname.replace(
|
|
13
|
+
pathname = pathname.replace('/proxy', '');
|
|
26
14
|
// remove trailing hash if it exists
|
|
27
|
-
pathname = pathname.replace(/#.*$/,
|
|
15
|
+
pathname = pathname.replace(/#.*$/, '');
|
|
28
16
|
// remove trailing /, ie. some URLs can end with '/' like /collections/cast-iron/
|
|
29
|
-
pathname = pathname.replace(/\/$/,
|
|
17
|
+
pathname = pathname.replace(/\/$/, '');
|
|
30
18
|
|
|
31
19
|
if (pathname === undefined || pathname === null || pathname.length === 0) {
|
|
32
20
|
return null;
|
|
@@ -37,35 +25,34 @@ export const ShopifyUrlProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
37
25
|
|
|
38
26
|
const getPlpOrPdpId = useCallback(
|
|
39
27
|
(extractor: IdExtractor): string | null => {
|
|
40
|
-
if (extractor ===
|
|
28
|
+
if (extractor === 'shopify-product-variant-id') {
|
|
41
29
|
const parsedHref = parseHref(window.location.href);
|
|
42
|
-
const variantId = parsedHref?.urlSearchParams?.get(
|
|
30
|
+
const variantId = parsedHref?.urlSearchParams?.get('variant');
|
|
43
31
|
if (!variantId) {
|
|
44
|
-
return getPlpOrPdpId(
|
|
32
|
+
return getPlpOrPdpId('shopify-product-id');
|
|
45
33
|
}
|
|
46
34
|
return variantId;
|
|
47
35
|
}
|
|
48
36
|
|
|
49
|
-
const pathSegment =
|
|
50
|
-
|
|
51
|
-
const tokens = getTrimmedPathName()?.split("/");
|
|
37
|
+
const pathSegment = extractor === 'shopify-product-id' ? 'products' : 'collections';
|
|
38
|
+
const tokens = getTrimmedPathName()?.split('/');
|
|
52
39
|
const idIndex = tokens?.findIndex((token) => token === pathSegment);
|
|
53
40
|
if (idIndex !== undefined && idIndex >= 0 && tokens) {
|
|
54
41
|
return decodeURIComponent(tokens[idIndex + 1]);
|
|
55
42
|
}
|
|
56
43
|
return null;
|
|
57
44
|
},
|
|
58
|
-
[getTrimmedPathName]
|
|
45
|
+
[getTrimmedPathName],
|
|
59
46
|
);
|
|
60
47
|
|
|
61
48
|
const isOnPdpPage = useCallback((): boolean => {
|
|
62
|
-
return getTrimmedPathName()?.includes(
|
|
49
|
+
return getTrimmedPathName()?.includes('/products') ?? false;
|
|
63
50
|
}, [getTrimmedPathName]);
|
|
64
51
|
|
|
65
52
|
const isOnPlpPage = useCallback((): boolean => {
|
|
66
53
|
return (
|
|
67
|
-
(getTrimmedPathName()?.includes(
|
|
68
|
-
!getTrimmedPathName()?.includes(
|
|
54
|
+
(getTrimmedPathName()?.includes('/collections') &&
|
|
55
|
+
!getTrimmedPathName()?.includes('/products')) ??
|
|
69
56
|
false
|
|
70
57
|
);
|
|
71
58
|
}, [getTrimmedPathName]);
|
|
@@ -78,20 +65,16 @@ export const ShopifyUrlProvider: React.FC<{ children: React.ReactNode }> = ({
|
|
|
78
65
|
isOnPlpPage,
|
|
79
66
|
isReady,
|
|
80
67
|
}),
|
|
81
|
-
[getTrimmedPathName, getPlpOrPdpId, isOnPdpPage, isOnPlpPage, isReady]
|
|
68
|
+
[getTrimmedPathName, getPlpOrPdpId, isOnPdpPage, isOnPlpPage, isReady],
|
|
82
69
|
);
|
|
83
70
|
|
|
84
|
-
return
|
|
85
|
-
<ShopifyUrlContext.Provider value={value}>
|
|
86
|
-
{children}
|
|
87
|
-
</ShopifyUrlContext.Provider>
|
|
88
|
-
);
|
|
71
|
+
return <ShopifyUrlContext.Provider value={value}>{children}</ShopifyUrlContext.Provider>;
|
|
89
72
|
};
|
|
90
73
|
|
|
91
74
|
export const useShopifyUrl = () => {
|
|
92
75
|
const context = useContext(ShopifyUrlContext);
|
|
93
76
|
if (!context) {
|
|
94
|
-
throw new Error(
|
|
77
|
+
throw new Error('useShopifyUrl must be used within a ShopifyUrlProvider');
|
|
95
78
|
}
|
|
96
79
|
return context;
|
|
97
80
|
};
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
SetStateAction,
|
|
6
|
-
createContext,
|
|
7
|
-
useMemo,
|
|
8
|
-
useState,
|
|
9
|
-
} from "react";
|
|
10
|
-
import { GenerationParams } from "src/application/models";
|
|
11
|
-
import { baseUrlAtom } from "src/atoms/envive/enviveConfig";
|
|
1
|
+
import { GenerationParams } from '@envive-ai/types';
|
|
2
|
+
import { useAtomValue } from 'jotai';
|
|
3
|
+
import { Dispatch, ReactNode, SetStateAction, createContext, useMemo, useState } from 'react';
|
|
4
|
+
import { baseUrlAtom } from 'src/atoms/envive/enviveConfig';
|
|
12
5
|
|
|
13
6
|
// TODO: Refactor this to a common service that handles query params (and spiffy variables all together)
|
|
14
7
|
const getChatModelName = () => {
|
|
@@ -37,9 +30,7 @@ interface SystemSettingsContextProviderProps {
|
|
|
37
30
|
showDebugBar?: boolean;
|
|
38
31
|
}
|
|
39
32
|
|
|
40
|
-
const SystemSettingsContext = createContext<
|
|
41
|
-
SystemSettingsContextParams | undefined
|
|
42
|
-
>(undefined);
|
|
33
|
+
const SystemSettingsContext = createContext<SystemSettingsContextParams | undefined>(undefined);
|
|
43
34
|
|
|
44
35
|
const SystemSettingsContextProvider = ({
|
|
45
36
|
children,
|
|
@@ -47,7 +38,7 @@ const SystemSettingsContextProvider = ({
|
|
|
47
38
|
showDebugBar,
|
|
48
39
|
}: SystemSettingsContextProviderProps) => {
|
|
49
40
|
const [params, setParams] = useState<GenerationParams | undefined>(
|
|
50
|
-
() => generationParams ?? defaultGenerationParams
|
|
41
|
+
() => generationParams ?? defaultGenerationParams,
|
|
51
42
|
);
|
|
52
43
|
const endpointURL = useAtomValue(baseUrlAtom);
|
|
53
44
|
const settingsContextValues = useMemo(
|
|
@@ -57,7 +48,7 @@ const SystemSettingsContextProvider = ({
|
|
|
57
48
|
setGenerationParams: setParams,
|
|
58
49
|
endpointURL,
|
|
59
50
|
}),
|
|
60
|
-
[generationParams, endpointURL, showDebugBar]
|
|
51
|
+
[generationParams, endpointURL, showDebugBar],
|
|
61
52
|
);
|
|
62
53
|
|
|
63
54
|
return (
|
|
@@ -67,8 +58,4 @@ const SystemSettingsContextProvider = ({
|
|
|
67
58
|
);
|
|
68
59
|
};
|
|
69
60
|
|
|
70
|
-
export {
|
|
71
|
-
SystemSettingsContextProvider,
|
|
72
|
-
SystemSettingsContext,
|
|
73
|
-
defaultGenerationParams,
|
|
74
|
-
};
|
|
61
|
+
export { SystemSettingsContextProvider, SystemSettingsContext, defaultGenerationParams };
|