@envive-ai/react-hooks 0.2.6-alpha-arthur-2 → 0.2.6-alpha.11
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/{NewOrgConfig-C_1T1iOt.js → NewOrgConfig-BZCP9E7v.js} +2 -2
- package/dist/{NewOrgConfig-D2Kvqa1z.cjs → NewOrgConfig-DWLMI1ga.cjs} +2 -2
- package/dist/SystemSettingsContext-CO5c1L62.cjs +20 -0
- package/dist/SystemSettingsContext-CXmUlH8i.js +13 -0
- package/dist/TrackComponentVisibleEvent-BJgNOypY.js +52 -0
- package/dist/TrackComponentVisibleEvent-BRC2FTp-.cjs +59 -0
- package/dist/amplitudeContext-CCVyp5RU.d.cts +52 -0
- package/dist/amplitudeContext-DFYBDc0h.d.ts +52 -0
- package/dist/api-BWSsazAG.js +166 -0
- package/dist/api-DeW6rHj3.cjs +239 -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 +3 -2
- 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 +23 -7
- package/dist/application/models/index.d.cts +12 -167
- package/dist/application/models/index.d.ts +13 -168
- package/dist/application/models/index.js +11 -7
- package/dist/application/models/utilityTypes/index.cjs +1 -0
- package/dist/application/models/utilityTypes/index.d.cts +2 -0
- package/dist/application/models/utilityTypes/index.d.ts +2 -0
- package/dist/application/models/utilityTypes/index.js +3 -0
- package/dist/application/models/variantInfo/index.cjs +3 -0
- package/dist/application/models/variantInfo/index.d.cts +2 -0
- package/dist/application/models/variantInfo/index.d.ts +2 -0
- package/dist/application/models/variantInfo/index.js +3 -0
- package/dist/application/utils/index.cjs +19 -10
- package/dist/application/utils/index.d.cts +62 -11
- package/dist/application/utils/index.d.ts +64 -13
- package/dist/application/utils/index.js +19 -10
- package/dist/{atomStore-BQVO5haU.cjs → atomStore-DNji91Im.cjs} +1 -1
- package/dist/{atomStore-CfzCqWB9.js → atomStore-DXTVqiKc.js} +1 -1
- package/dist/atoms/app/index.cjs +24 -22
- package/dist/atoms/app/index.d.cts +21 -9
- package/dist/atoms/app/index.d.ts +20 -8
- package/dist/atoms/app/index.js +19 -17
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +21 -20
- package/dist/atoms/chat/index.d.cts +46 -36
- package/dist/atoms/chat/index.d.ts +44 -34
- package/dist/atoms/chat/index.js +21 -20
- package/dist/atoms/globalSearch/index.cjs +2 -1
- package/dist/atoms/globalSearch/index.d.cts +6 -6
- package/dist/atoms/globalSearch/index.d.ts +1 -1
- package/dist/atoms/globalSearch/index.js +2 -1
- package/dist/atoms/org/index.cjs +11 -10
- package/dist/atoms/org/index.d.cts +32 -19
- package/dist/atoms/org/index.d.ts +32 -19
- package/dist/atoms/org/index.js +3 -2
- package/dist/atoms/search/index.cjs +47 -7
- package/dist/atoms/search/index.d.cts +15 -76
- package/dist/atoms/search/index.d.ts +15 -76
- package/dist/atoms/search/index.js +29 -7
- package/dist/atoms/search/types.cjs +5 -0
- package/dist/atoms/search/types.d.cts +2 -0
- package/dist/atoms/search/types.d.ts +2 -0
- package/dist/atoms/search/types.js +3 -0
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/search/utils.d.ts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/cdnContext-BnqmnEvR.js +38 -0
- package/dist/cdnContext-CnYcBOr9.cjs +53 -0
- package/dist/chat-CqPuT9_V.cjs +393 -0
- package/dist/chat-DH70QqJp.js +257 -0
- package/dist/chatElementDisplayLocation-CpgV2wR1.d.ts +25 -0
- package/dist/chatElementDisplayLocation-DWmfNX_u.d.cts +25 -0
- package/dist/chatSearch-ChyGuHbu.js +295 -0
- package/dist/chatSearch-DpnpRWAW.cjs +418 -0
- package/dist/chatState-CcFtSqJT.cjs +120 -0
- package/dist/chatState-DKnNHmwe.js +34 -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 +22 -23
- package/dist/contexts/amplitudeContext/index.d.cts +2 -11
- package/dist/contexts/amplitudeContext/index.d.ts +2 -11
- package/dist/contexts/amplitudeContext/index.js +20 -22
- package/dist/contexts/cdnContext/index.cjs +4 -4
- package/dist/contexts/cdnContext/index.d.cts +6 -2
- package/dist/contexts/cdnContext/index.d.ts +6 -2
- package/dist/contexts/cdnContext/index.js +4 -4
- package/dist/contexts/chatContext/index.cjs +326 -0
- package/dist/contexts/chatContext/index.d.cts +15 -0
- package/dist/contexts/chatContext/index.d.ts +15 -0
- package/dist/contexts/chatContext/index.js +319 -0
- package/dist/contexts/enviveConfigContext/index.cjs +4 -4
- package/dist/contexts/enviveConfigContext/index.d.cts +25 -3
- package/dist/contexts/enviveConfigContext/index.d.ts +25 -3
- package/dist/contexts/enviveConfigContext/index.js +4 -4
- package/dist/contexts/enviveCssContext/index.cjs +19 -15
- package/dist/contexts/enviveCssContext/index.d.cts +5 -3
- package/dist/contexts/enviveCssContext/index.d.ts +5 -3
- package/dist/contexts/enviveCssContext/index.js +19 -15
- package/dist/contexts/featureFlagContext/index.cjs +10 -9
- package/dist/contexts/featureFlagContext/index.d.cts +12 -3
- package/dist/contexts/featureFlagContext/index.d.ts +12 -3
- package/dist/contexts/featureFlagContext/index.js +7 -6
- package/dist/contexts/featureFlagServiceContext/index.cjs +3 -4
- package/dist/contexts/featureFlagServiceContext/index.d.cts +5 -1
- package/dist/contexts/featureFlagServiceContext/index.d.ts +5 -1
- package/dist/contexts/featureFlagServiceContext/index.js +3 -4
- package/dist/contexts/graphqlContext/index.cjs +13 -8
- package/dist/contexts/graphqlContext/index.d.cts +15 -11
- package/dist/contexts/graphqlContext/index.d.ts +15 -11
- package/dist/contexts/graphqlContext/index.js +13 -8
- package/dist/contexts/localStorageContext/index.cjs +3 -3
- package/dist/contexts/localStorageContext/index.d.cts +22 -3
- package/dist/contexts/localStorageContext/index.d.ts +22 -3
- package/dist/contexts/localStorageContext/index.js +3 -4
- package/dist/contexts/newOrgConfigContext/index.cjs +17 -13
- package/dist/contexts/newOrgConfigContext/index.d.cts +16 -12
- package/dist/contexts/newOrgConfigContext/index.d.ts +16 -12
- package/dist/contexts/newOrgConfigContext/index.js +17 -13
- package/dist/contexts/searchContext/index.cjs +24 -23
- package/dist/contexts/searchContext/index.d.cts +7 -2
- package/dist/contexts/searchContext/index.d.ts +7 -2
- package/dist/contexts/searchContext/index.js +24 -23
- package/dist/contexts/sessionStorageContext/index.cjs +2 -2
- package/dist/contexts/sessionStorageContext/index.d.cts +6 -2
- package/dist/contexts/sessionStorageContext/index.d.ts +6 -2
- package/dist/contexts/sessionStorageContext/index.js +2 -2
- package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
- package/dist/contexts/shopifyUrlContext/index.d.cts +12 -2
- package/dist/contexts/shopifyUrlContext/index.d.ts +12 -2
- package/dist/contexts/shopifyUrlContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +4 -4
- package/dist/contexts/systemSettingsContext/index.d.cts +13 -2
- package/dist/contexts/systemSettingsContext/index.d.ts +15 -4
- package/dist/contexts/systemSettingsContext/index.js +4 -4
- package/dist/contexts/types.cjs +7 -0
- package/dist/contexts/types.d.cts +5 -0
- package/dist/contexts/types.d.ts +5 -0
- package/dist/contexts/types.js +3 -0
- package/dist/contexts/userIdentityContext/index.cjs +21 -19
- package/dist/contexts/userIdentityContext/index.d.cts +2 -11
- package/dist/contexts/userIdentityContext/index.d.ts +2 -11
- package/dist/contexts/userIdentityContext/index.js +19 -17
- package/dist/custservice-types-CcPnAJ5k.d.ts +29 -0
- package/dist/custservice-types-_Dnz4sMy.d.cts +29 -0
- package/dist/domObserver-Bqf3ooj8.cjs +304 -0
- package/dist/{domObserver-C2oQO8vi.cjs → domObserver-v9ODTyfT.js} +4 -23
- package/dist/enviveConfig-DZBohDpc.js +62 -0
- package/dist/enviveConfig-Dv9-esGV.cjs +130 -0
- package/dist/enviveConfigContext-D2OELZDR.cjs +60 -0
- package/dist/enviveConfigContext-DrDjCems.js +45 -0
- package/dist/events/index.cjs +3 -2
- package/dist/events/index.d.cts +15 -2
- package/dist/events/index.d.ts +15 -2
- package/dist/events/index.js +2 -2
- package/dist/events-DYY4l817.cjs +90 -0
- package/dist/events-DyUix-Bn.js +78 -0
- package/dist/featureFlagServiceContext-B01ZkIwj.d.cts +23 -0
- package/dist/featureFlagServiceContext-CJyYItqu.cjs +62 -0
- package/dist/featureFlagServiceContext-FBM6DdMJ.js +42 -0
- package/dist/featureFlagServiceContext-jZzoym5C.d.ts +23 -0
- package/dist/featureGates-KEwAL8p_.js +26 -0
- package/dist/featureGates-qU_ulhpC.cjs +32 -0
- package/dist/frontendConfig-BIq8r6nC.d.cts +858 -0
- package/dist/frontendConfig-CixANNjw.d.ts +858 -0
- package/dist/{globalSearch-Cpc8egsM.cjs → globalSearch-Ba342VVG.cjs} +1 -1
- package/dist/globalSearch-DQCMamhv.js +1 -0
- package/dist/globalSearch-DYxPE02f.cjs +0 -0
- package/dist/{globalSearch-nmrfGLOn.js → globalSearch-eGx-9JQz.js} +1 -1
- package/dist/graphql-3PxNRFOc.js +36 -0
- package/dist/graphql-DGYfelZp.cjs +53 -0
- package/dist/graphqlConfig-GHZ1UgCw.cjs +73 -0
- package/dist/graphqlConfig-mDg6J44N.js +24 -0
- package/dist/graphqlContext-B4twVCqw.d.ts +28 -0
- package/dist/graphqlContext-BZPEAFSR.cjs +111 -0
- package/dist/graphqlContext-W6iEyEkv.d.cts +28 -0
- package/dist/graphqlContext-eaZPxgRE.js +96 -0
- package/dist/hooks/AmplitudeOperations/index.cjs +22 -23
- package/dist/hooks/AmplitudeOperations/index.d.cts +2 -2
- package/dist/hooks/AmplitudeOperations/index.d.ts +2 -2
- package/dist/hooks/AmplitudeOperations/index.js +21 -22
- package/dist/hooks/AppDetails/index.cjs +22 -20
- package/dist/hooks/AppDetails/index.d.cts +24 -3
- package/dist/hooks/AppDetails/index.d.ts +24 -3
- package/dist/hooks/AppDetails/index.js +22 -20
- package/dist/hooks/CdnOperations/index.cjs +4 -4
- package/dist/hooks/CdnOperations/index.js +4 -4
- package/dist/hooks/ChatToggle/index.cjs +25 -28
- package/dist/hooks/ChatToggle/index.d.cts +2 -2
- package/dist/hooks/ChatToggle/index.d.ts +2 -2
- package/dist/hooks/ChatToggle/index.js +22 -25
- package/dist/hooks/ChatToggleAnalytics/index.cjs +24 -25
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.d.ts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.js +23 -24
- package/dist/hooks/CustomerSupportHandoff/index.cjs +2 -2
- package/dist/hooks/CustomerSupportHandoff/index.js +2 -2
- package/dist/hooks/Debounce/index.cjs +2 -20
- package/dist/hooks/Debounce/index.js +2 -18
- package/dist/hooks/ElementObserver/index.cjs +6 -4
- package/dist/hooks/ElementObserver/index.d.cts +25 -4
- package/dist/hooks/ElementObserver/index.d.ts +25 -4
- package/dist/hooks/ElementObserver/index.js +6 -4
- package/dist/hooks/FloatingButtonVisibility/index.cjs +73 -0
- package/dist/hooks/FloatingButtonVisibility/index.d.cts +7 -0
- package/dist/hooks/FloatingButtonVisibility/index.d.ts +7 -0
- package/dist/hooks/FloatingButtonVisibility/index.js +69 -0
- 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 +14 -9
- package/dist/hooks/GraphQLConfig/index.d.cts +14 -2
- package/dist/hooks/GraphQLConfig/index.d.ts +14 -2
- package/dist/hooks/GraphQLConfig/index.js +14 -9
- package/dist/hooks/IdentifyUser/index.cjs +21 -19
- package/dist/hooks/IdentifyUser/index.js +20 -18
- package/dist/hooks/ImageResolver/index.cjs +29 -20
- package/dist/hooks/ImageResolver/index.js +29 -20
- package/dist/hooks/Intersection/index.cjs +1 -1
- package/dist/hooks/Intersection/index.d.cts +1 -1
- package/dist/hooks/Intersection/index.js +1 -1
- package/dist/hooks/LastInteraction/index.cjs +34 -0
- package/dist/hooks/LastInteraction/index.d.cts +7 -0
- package/dist/hooks/LastInteraction/index.d.ts +7 -0
- package/dist/hooks/LastInteraction/index.js +32 -0
- package/dist/hooks/LocalStorageOperations/index.cjs +7 -8
- package/dist/hooks/LocalStorageOperations/index.js +3 -4
- package/dist/hooks/MessageFilter/index.cjs +12 -3
- package/dist/hooks/MessageFilter/index.d.cts +18 -2
- package/dist/hooks/MessageFilter/index.d.ts +18 -2
- package/dist/hooks/MessageFilter/index.js +11 -2
- package/dist/hooks/NewOrgConfig/index.cjs +18 -14
- package/dist/hooks/NewOrgConfig/index.d.cts +17 -3
- package/dist/hooks/NewOrgConfig/index.d.ts +17 -3
- package/dist/hooks/NewOrgConfig/index.js +18 -14
- package/dist/hooks/Search/index.cjs +173 -314
- package/dist/hooks/Search/index.d.cts +58 -3
- package/dist/hooks/Search/index.d.ts +58 -3
- package/dist/hooks/Search/index.js +162 -302
- package/dist/hooks/SearchOperations/index.cjs +25 -24
- package/dist/hooks/SearchOperations/index.d.cts +3 -2
- package/dist/hooks/SearchOperations/index.d.ts +3 -2
- package/dist/hooks/SearchOperations/index.js +25 -24
- 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 +5 -2
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +5 -2
- package/dist/hooks/ShopifyUrlOperations/index.js +3 -3
- package/dist/hooks/SnapCalculator/index.cjs +1 -1
- package/dist/hooks/SnapCalculator/index.d.cts +3 -4
- package/dist/hooks/SnapCalculator/index.d.ts +3 -4
- package/dist/hooks/SnapCalculator/index.js +1 -1
- package/dist/hooks/SystemSettingsContext/index.cjs +6 -17
- package/dist/hooks/SystemSettingsContext/index.d.cts +16 -5
- package/dist/hooks/SystemSettingsContext/index.d.ts +16 -5
- package/dist/hooks/SystemSettingsContext/index.js +6 -15
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +21 -23
- package/dist/hooks/TrackComponentVisibleEvent/index.d.cts +3 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.d.ts +3 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.js +21 -23
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +24 -26
- package/dist/hooks/UpdateAnalyticsProps/index.js +20 -22
- package/dist/hooks/utils.cjs +1 -1
- package/dist/hooks/utils.d.cts +14 -20
- package/dist/hooks/utils.d.ts +14 -20
- package/dist/hooks/utils.js +1 -1
- package/dist/index-9oqgeOVC.d.cts +186 -0
- package/dist/index-A0HvA68Y.d.cts +1 -0
- package/dist/index-BC93l5Th.d.ts +1 -0
- package/dist/index-BEzmil_W.d.ts +44 -0
- package/dist/{index-DtzPIcQp.d.ts → index-BdjH4aRG.d.ts} +1 -1
- package/dist/{index-CsmO1rDH.d.ts → index-BfM7zKRO.d.ts} +1 -1
- package/dist/index-Bmub8e38.d.cts +98 -0
- package/dist/{index-mv7KvWDq.d.ts → index-CA1Eo7DA.d.ts} +1 -1
- package/dist/index-CCa4tZuO.d.ts +184 -0
- package/dist/{index-ChiZg0yw.d.cts → index-CCboEuTO.d.cts} +1 -1
- package/dist/index-CESxqFso.d.cts +228 -0
- package/dist/{index-BbqT4BQv.d.cts → index-COXkY78t.d.cts} +1 -1
- package/dist/index-CboygwjO.d.ts +676 -0
- package/dist/index-CiWEYzXl.d.cts +184 -0
- package/dist/{index-jFQefHda.d.ts → index-Cw9oYJnq.d.ts} +1 -1
- package/dist/index-D5lw0cMx.d.ts +186 -0
- package/dist/{index-CAJq_8bO.d.cts → index-DZtnHhlr.d.cts} +1 -1
- package/dist/index-Dfwnna1j.d.ts +228 -0
- package/dist/index-Dt_C-I-2.d.cts +676 -0
- package/dist/index-OkKEOL6H.d.cts +44 -0
- package/dist/index-bjMvkcBF.d.ts +98 -0
- package/dist/{index-npqPeJ1g.d.cts → index-hAqp0oYb.d.cts} +1 -1
- package/dist/interceptors/index.cjs +3 -28
- package/dist/interceptors/index.d.cts +16 -4
- package/dist/interceptors/index.d.ts +16 -4
- package/dist/interceptors/index.js +3 -25
- package/dist/interceptors/types.cjs +1 -0
- package/dist/interceptors/types.d.cts +14 -0
- package/dist/interceptors/types.d.ts +14 -0
- package/dist/interceptors/types.js +3 -0
- package/dist/localStorageContext-BPZ82q-G.js +95 -0
- package/dist/localStorageContext-NRP-CdmF.cjs +115 -0
- package/dist/{logger-BqHq67zN.cjs → logger-TBIl4uIH.cjs} +1 -1
- package/dist/{logger-BMVdhQOV.js → logger-W3lqg-4b.js} +1 -1
- package/dist/models-D-4db7XW.cjs +1537 -0
- package/dist/models-c86hYW-F.js +1296 -0
- package/dist/{newOrgConfigAtom-rrYHmp1b.cjs → newOrgConfigAtom-D6R-7HCk.cjs} +1 -1
- package/dist/newOrgConfigAtom-bn1lnljf.js +8 -0
- package/dist/newOrgConfigContext-BC79qoiV.d.ts +16 -0
- package/dist/newOrgConfigContext-BqZwD8-B.cjs +68 -0
- package/dist/newOrgConfigContext-DbcDClwd.js +53 -0
- package/dist/newOrgConfigContext-eS4ZLo58.d.cts +16 -0
- package/dist/nodeSelector-DybpVr-i.d.ts +31 -0
- package/dist/nodeSelector-vKB44CDB.d.cts +31 -0
- package/dist/org-CIhjzxWr.cjs +43 -0
- package/dist/org-CeWXnpwF.js +12 -0
- package/dist/search-6RrxBXD6.d.cts +20 -0
- package/dist/search-BBu5YeQa.js +126 -0
- package/dist/search-D23INSNg.cjs +205 -0
- package/dist/search-filter-types-BItKtezf.d.cts +102 -0
- package/dist/search-filter-types-fZf91Pdw.d.ts +102 -0
- package/dist/search-nuWWnRRV.d.ts +20 -0
- package/dist/searchContext-BPT44uk-.js +129 -0
- package/dist/searchContext-CwRRiXQ3.cjs +145 -0
- package/dist/searchServiceAdapter-DEv1tTn0.cjs +34 -0
- package/dist/searchServiceAdapter-WyCU55NV.js +16 -0
- package/dist/sessionStorageContext-1Ks_d4Z0.cjs +66 -0
- package/dist/sessionStorageContext-CDcl7NVl.js +52 -0
- package/dist/shopifyUrlContext-CejRZfj7.js +61 -0
- package/dist/shopifyUrlContext-lnHoAOEf.cjs +75 -0
- package/dist/spiffyWidgets-CdxRcXhW.d.ts +20 -0
- package/dist/spiffyWidgets-eNbU1gMc.d.cts +20 -0
- package/dist/systemSettingsContext-Ba-wi2NZ.cjs +60 -0
- package/dist/systemSettingsContext-DumUaV0m.js +39 -0
- package/dist/test-types-B3YQpECG.d.cts +13 -0
- package/dist/test-types-C8NHqaUS.d.ts +13 -0
- package/dist/types/index.cjs +48 -3
- package/dist/types/index.d.cts +18 -2
- package/dist/types/index.d.ts +18 -2
- package/dist/types/index.js +44 -2
- package/dist/types-BGqrvAsw.d.ts +10 -0
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-CS0Hrzja.js +30 -0
- package/dist/types-CtUb63bt.js +76 -0
- package/dist/types-CxObxLKs.cjs +48 -0
- package/dist/types-DIiH_5gL.d.cts +10 -0
- package/dist/types-Dc6hx6ei.js +1 -0
- package/dist/types-UUvB6h05.cjs +106 -0
- package/dist/types-aQTzSrH1.d.cts +51 -0
- package/dist/types-kAjmR2du.d.ts +51 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +16 -0
- package/dist/types.d.ts +16 -0
- package/dist/types.js +1 -0
- package/dist/urlsParser-COzMdJaX.cjs +78 -0
- package/dist/urlsParser-DxjoLj98.js +42 -0
- package/dist/useAmplitudeOperations-Cv0fi3uj.cjs +41 -0
- package/dist/useAmplitudeOperations-Ti6phPPq.js +34 -0
- package/dist/useAppDetails-CsXHPAh1.cjs +38 -0
- package/dist/useAppDetails-PUfYwCjK.js +30 -0
- package/dist/useDebounce-DZ8Cgiwc.cjs +26 -0
- package/dist/useDebounce-v9cezyjn.js +19 -0
- package/dist/useGraphQLConfig-BizpCw23.cjs +76 -0
- package/dist/useGraphQLConfig-DFWl9Z89.js +63 -0
- package/dist/{useIntersection-BkMkuJcZ.js → useIntersection-Cncgxdmy.js} +1 -1
- package/dist/{useIntersection-BcBCa890.cjs → useIntersection-m4PEpvG7.cjs} +1 -1
- package/dist/useMessageInterceptor-BjGP_uXm.js +25 -0
- package/dist/useMessageInterceptor-arAqUq1Q.cjs +33 -0
- package/dist/userIdentityContext-W1OWF3cG.d.ts +20 -0
- package/dist/userIdentityContext-kU1PIo8K.d.cts +20 -0
- package/dist/utilityTypes-B2KuRn37.js +1 -0
- package/dist/utilityTypes-BGbL2WTP.cjs +0 -0
- package/dist/{utils-CqVRbvfN.cjs → utils-2SWrJ12w.cjs} +1 -1
- package/dist/utils-BewguHW0.d.cts +22 -0
- package/dist/{utils-CiJLDPjY.cjs → utils-CDw74BCO.cjs} +1 -1
- package/dist/utils-CLGXsOwE.cjs +1591 -0
- package/dist/{utils-DQhbbAnt.js → utils-CqBxIpEV.js} +1 -1
- package/dist/{utils-B1LVzQYK.js → utils-DIvMgPe8.js} +1 -1
- package/dist/utils-D_kATUj6.js +92 -0
- package/dist/{utils-BitIIghf.d.ts → utils-DpneNSJf.d.ts} +1 -1
- package/dist/utils-hKYwSBo9.d.ts +22 -0
- package/dist/utils-hYTjy7hJ.cjs +130 -0
- package/dist/utils-jYtD3hmA.js +1385 -0
- package/dist/variantInfo-BfKlkaWU.js +11 -0
- package/dist/variantInfo-DpLn4nHz.cjs +17 -0
- package/package.json +36 -9
- package/src/application/commerce-api.ts +37 -40
- package/src/application/models/api/context.ts +4 -0
- package/src/application/models/api/generationParams.ts +4 -0
- package/src/application/models/api/nextMessageRequest.ts +11 -0
- package/src/application/models/api/orgAnalyticsConfig.ts +19 -0
- package/src/application/models/api/orgConfigResults.ts +44 -0
- package/src/application/models/api/organizationConfig.ts +12 -0
- package/src/{types/ApiResponse.ts → application/models/api/response.ts} +29 -35
- package/src/application/models/api/responseGenerics.ts +67 -0
- package/src/application/models/api/search.ts +26 -0
- package/src/application/models/api/suggestion.ts +4 -0
- package/src/application/models/api/supportedEventRequest.ts +8 -0
- package/src/application/models/api/userEvent.ts +101 -0
- package/src/application/models/cachedValue.ts +8 -0
- package/src/application/models/chatElementDisplayLocation.ts +22 -0
- package/src/application/models/clientDetails.ts +18 -0
- package/src/application/models/colorsConfig.ts +28 -0
- package/src/application/models/conversationalSearchIds.ts +5 -0
- package/src/application/models/dataLayer.ts +45 -0
- package/src/application/models/events.ts +5 -0
- package/src/application/models/featureGates.ts +21 -0
- package/src/application/models/frontendConfig.ts +14 -0
- package/src/application/models/googleAnalyticsEvents.ts +8 -0
- package/src/application/models/graphql/index.ts +0 -1
- package/src/application/models/graphql/queries/getMerchantColorsQuery.ts +23 -1
- package/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.ts +89 -1
- 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 +20 -2
- package/src/application/models/guards/api/isApiOrgConfigResults.ts +9 -3
- package/src/application/models/guards/api/isApiOrganizationConfig.ts +32 -8
- package/src/application/models/guards/api/isApiPDPEventAttributes.ts +5 -8
- package/src/application/models/guards/api/isApiPLPEventAttributes.ts +10 -14
- package/src/application/models/guards/api/isApiPageResponseAttributes.ts +1 -1
- package/src/application/models/guards/api/isApiProductResponseAttributes.ts +4 -2
- package/src/application/models/guards/api/isApiProductSearchAttributes.ts +6 -9
- package/src/application/models/guards/api/isApiProductSearchFilterAttributes.ts +4 -7
- package/src/application/models/guards/api/isApiQueryTypedEventAttributes.ts +3 -8
- package/src/application/models/guards/api/isApiResponse.ts +15 -22
- 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 +2 -1
- 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 +3 -1
- package/src/application/models/guards/isSpanxTakeAQuizCtaParameter.ts +3 -5
- package/src/application/models/guards/isVariantInfo.ts +1 -6
- package/src/application/models/index.ts +95 -30
- package/src/application/models/localStorageEventListener.ts +4 -0
- package/src/{types/Message.ts → application/models/message.ts} +34 -38
- package/src/application/models/mobilePLPChatPlacementParameter.ts +3 -0
- package/src/application/models/orgsEnum.ts +36 -0
- package/src/application/models/productExperiment.ts +5 -0
- package/src/application/models/spanxTakeAQuizCtaParameter.ts +4 -0
- package/src/application/models/spiffyWidgets.ts +16 -0
- package/src/application/models/utilityTypes/camelCase.ts +87 -0
- package/src/application/models/utilityTypes/camelCasedPropertiesDeep.ts +80 -0
- package/src/application/models/utilityTypes/delimiterCase.ts +121 -0
- package/src/application/models/utilityTypes/delimiterCasedPropertiesDeep.ts +98 -0
- package/src/application/models/utilityTypes/index.ts +1 -0
- package/src/application/models/utilityTypes/internal.ts +93 -0
- package/src/application/models/utilityTypes/primitive.ts +8 -0
- package/src/application/models/utilityTypes/snakeCasedPropertiesDeep.ts +49 -0
- package/src/application/models/utilityTypes/splitWords.ts +76 -0
- package/src/application/models/utilityTypes/trim.ts +28 -0
- package/src/application/models/utilityTypes/unknownArray.ts +25 -0
- package/src/application/models/utils/snakeToCamelTransformer.ts +8 -8
- package/src/application/models/validators/validateGraphQLColorsConfig.ts +2 -6
- package/src/application/models/validators/validateGraphQLFrontendConfig.ts +6 -6
- package/src/application/models/validators/validateMobilePLPChatPlacementParameter.ts +3 -5
- package/src/application/models/validators/validateOrgConfigResults.ts +5 -6
- package/src/application/models/validators/validateOrganizationConfig.ts +8 -11
- package/src/application/models/validators/validateResponse.ts +44 -66
- package/src/application/models/validators/validateSuggestion.ts +1 -1
- package/src/application/models/validators/validateUserEvent.ts +12 -23
- package/src/application/models/variantInfo/index.ts +1 -0
- package/src/application/models/variantInfo/pageVisitInfo.ts +6 -0
- package/src/application/models/variantInfo/plpInfo.ts +3 -0
- package/src/application/models/variantInfo/productInfo.ts +5 -0
- package/src/application/models/variantInfo/variantInfo.ts +29 -0
- package/src/application/utils/__tests__/divideArrays.test.ts +14 -0
- package/src/application/utils/analyticsUtils.ts +8 -1
- package/src/application/utils/cdnUtils.ts +11 -0
- package/src/application/utils/coreContextToApiContext.ts +1 -3
- package/src/application/utils/coreUserEventToApiUserEvent.ts +2 -2
- package/src/application/utils/elementObserver.ts +1 -1
- package/src/application/utils/imageFilter.ts +2 -5
- package/src/application/utils/index.ts +21 -20
- package/src/application/utils/messageFromFormSubmittedEvent.ts +1 -1
- package/src/application/utils/messageFromQueryEvent.ts +1 -1
- package/src/application/utils/messageFromResponse.ts +10 -14
- package/src/application/utils/messageFromSuggestionEvent.ts +4 -6
- package/src/application/utils/mouseEventTypes.ts +1 -1
- package/src/application/utils/nextMessageRequestToApiRequest.ts +1 -1
- package/src/application/utils/overrides.ts +49 -1
- package/src/application/utils/supportedEventRequestToApiRequest.ts +1 -3
- package/src/application/utils/urlsParser.ts +7 -1
- package/src/atoms/amplitude/amplitudeTrackEventAtom.ts +1 -1
- package/src/atoms/app/index.ts +25 -15
- 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 +50 -25
- package/src/atoms/chat/replies.ts +2 -1
- package/src/atoms/chat/suggestions.ts +29 -34
- package/src/atoms/envive/enviveConfig.ts +20 -14
- package/src/atoms/org/customerService.ts +8 -4
- package/src/atoms/org/graphqlConfig.ts +15 -7
- package/src/atoms/org/index.ts +6 -4
- package/src/atoms/org/newOrgConfigAtom.ts +2 -2
- package/src/atoms/org/orgAnalyticsConfig.ts +1 -1
- package/src/atoms/search/chatSearch.ts +317 -0
- package/src/atoms/search/index.ts +1 -0
- package/src/atoms/search/productFilters.ts +52 -72
- package/src/atoms/search/productSorter.ts +2 -2
- package/src/atoms/search/searchAPI.ts +60 -42
- package/src/atoms/search/searchServiceAdapter.ts +1 -1
- package/src/atoms/search/types.ts +55 -0
- package/src/config/divIds.ts +27 -0
- package/src/config/socialProofClasses.ts +17 -0
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +57 -19
- package/src/contexts/cdnContext/cdnContext.tsx +6 -1
- package/src/contexts/chatContext/chatContext.tsx +509 -0
- package/src/contexts/chatContext/index.ts +1 -0
- package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +26 -12
- package/src/contexts/enviveCssContext/enviveCssContext.tsx +12 -5
- package/src/contexts/featureFlagContext/featureFlagContext.tsx +48 -27
- package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +3 -11
- package/src/contexts/graphqlContext/graphqlContext.tsx +95 -40
- package/src/contexts/localStorageContext/localStorageContext.tsx +60 -26
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +22 -10
- package/src/contexts/searchContext/searchContext.tsx +49 -29
- package/src/contexts/sessionStorageContext/sessionStorageContext.tsx +33 -12
- package/src/contexts/shopifyUrlContext/shopifyUrlContext.tsx +37 -20
- package/src/contexts/systemSettingsContext/systemSettingsContext.tsx +21 -8
- package/src/contexts/types.ts +1067 -0
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +77 -33
- package/src/events/event-types.ts +11 -0
- package/src/events/index.ts +5 -8
- package/src/events/registerAnalyticsListeners.ts +13 -10
- package/src/hooks/AmplitudeOperations/useAmplitudeOperations.ts +11 -6
- package/src/hooks/AppDetails/useAppDetails.ts +24 -10
- package/src/hooks/ChatToggle/useChatToggle.ts +19 -7
- package/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.ts +4 -4
- package/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.ts +1 -1
- package/src/hooks/ElementObserver/useElementObserver.ts +32 -14
- package/src/hooks/FloatingButtonVisibility/index.ts +1 -0
- package/src/hooks/FloatingButtonVisibility/useFloatingButtonVisibility.ts +99 -0
- package/src/hooks/GrabAndScroll/useGrabAndScroll.ts +124 -125
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +7 -5
- package/src/hooks/ImageResolver/useImageResolver.ts +31 -24
- package/src/hooks/LastInteraction/index.ts +1 -0
- package/src/hooks/LastInteraction/useLastInteraction.ts +42 -0
- package/src/hooks/LocalStorageOperations/useLocalStorageOperations.ts +19 -12
- package/src/hooks/MessageFilter/useMessageFilter.ts +7 -1
- package/src/hooks/Search/useSearch.tsx +217 -87
- package/src/hooks/SearchOperations/useSearchOperations.ts +12 -8
- package/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.ts +14 -8
- package/src/hooks/SnapCalculator/useSnapCalculator.ts +2 -1
- package/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.ts +11 -8
- package/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.ts +25 -11
- package/src/hooks/utils.ts +29 -19
- package/src/interceptors/index.ts +2 -1
- package/src/interceptors/types.ts +6 -0
- package/src/interceptors/useMessageInterceptor.ts +6 -10
- package/src/merchants/domInsertion.ts +30 -0
- package/src/merchants/gridInsertion.ts +19 -0
- package/src/types/config-versions.ts +6 -0
- package/src/types/customerService.ts +31 -0
- package/src/types/custservice-types.ts +28 -0
- package/src/{exceptions → types/exceptions}/unsupportedProductExceptions.ts +2 -2
- package/src/types/floatingbuttonoverrides-types.ts +10 -0
- package/src/types/index.ts +5 -4
- package/src/types/search-filter-types.ts +111 -0
- package/src/types/suggestionBarV2-types.ts +4 -0
- package/src/types/test-types.ts +3 -0
- package/src/types.ts +11 -0
- package/dist/AmplitudeOperations-6Y7GejD-.cjs +0 -41
- package/dist/AmplitudeOperations-DOEgdx-a.js +0 -34
- package/dist/TrackComponentVisibleEvent-BvDOoSsc.js +0 -53
- package/dist/TrackComponentVisibleEvent-CcZ6l_cs.cjs +0 -60
- package/dist/amplitudeContext-CH-Rtn8y.js +0 -236
- package/dist/amplitudeContext-CZXdr3HG.cjs +0 -252
- package/dist/amplitudeTrackEventAtom-D66l5oFp.js +0 -8
- package/dist/amplitudeTrackEventAtom-f22P2U0u.cjs +0 -15
- package/dist/api-D4HaU2Gf.js +0 -166
- package/dist/api-D4Xoibs9.cjs +0 -239
- package/dist/app-DEnOfim0.js +0 -515
- package/dist/app-DOEeLKrt.cjs +0 -570
- package/dist/cdnContext-CJ2BNLAD.js +0 -38
- package/dist/cdnContext-lkC-AE6A.cjs +0 -53
- package/dist/chat-ChbwDr7k.js +0 -226
- package/dist/chat-FCaaEJvJ.cjs +0 -326
- package/dist/chatState-BbI93m6r.js +0 -33
- package/dist/chatState-DlJpHAsW.cjs +0 -119
- package/dist/dist-C38adNK1.js +0 -5923
- package/dist/dist-VxRI6eQv.cjs +0 -6019
- package/dist/domObserver-DNeeSh1F.js +0 -285
- package/dist/enviveConfig-Ciq4ASoV.js +0 -62
- package/dist/enviveConfig-Dp80h9yu.cjs +0 -130
- package/dist/enviveConfigContext-0PQkfMQ6.cjs +0 -62
- package/dist/enviveConfigContext-CMDiVsln.js +0 -47
- package/dist/events-CgFGtanE.cjs +0 -69
- package/dist/events-WOOrnUAx.js +0 -63
- package/dist/exceptions/index.cjs +0 -4
- package/dist/exceptions/index.d.cts +0 -12
- package/dist/exceptions/index.d.ts +0 -12
- package/dist/exceptions/index.js +0 -3
- package/dist/exceptions-BjDgLzGi.cjs +0 -32
- package/dist/exceptions-CUGY31Ua.js +0 -20
- package/dist/featureFlagServiceContext-ClnlCJV5.d.cts +0 -24
- package/dist/featureFlagServiceContext-Cvp7NlpC.js +0 -46
- package/dist/featureFlagServiceContext-CyPGEe2d.d.ts +0 -24
- package/dist/featureFlagServiceContext-DHtkQAtq.cjs +0 -66
- package/dist/graphql-CvAHWmel.js +0 -46
- package/dist/graphql-JaGqsToc.cjs +0 -70
- package/dist/graphqlContext-0cg9fEUw.js +0 -96
- package/dist/graphqlContext-ChXlE8Ul.cjs +0 -111
- package/dist/index-5li6ZMDu.d.ts +0 -11
- package/dist/index-BVZbvpx_.d.cts +0 -11
- package/dist/index-CMZcE7pk.d.cts +0 -224
- package/dist/index-CuihhoIF.d.ts +0 -42
- package/dist/index-bEjLKG_Q.d.ts +0 -224
- package/dist/index-qOBU4GEh.d.cts +0 -42
- package/dist/localStorageContext-BFwvuEcf.js +0 -90
- package/dist/localStorageContext-CWc5xJ6U.cjs +0 -104
- package/dist/models-Cw0QcbQv.js +0 -1118
- package/dist/models-Dl0_Ujgj.cjs +0 -1305
- package/dist/newOrgConfigAtom-BuQE_zPK.js +0 -8
- package/dist/newOrgConfigContext-D-gU5ppl.js +0 -53
- package/dist/newOrgConfigContext-d3RHl430.cjs +0 -68
- package/dist/nodeSelector-BAKg1h_y.d.ts +0 -28
- package/dist/nodeSelector-BYEAyrsj.d.cts +0 -28
- package/dist/org-15F128Ah.js +0 -32
- package/dist/org-CIFgIcO4.cjs +0 -111
- package/dist/search--80x6CfL.js +0 -233
- package/dist/search-Ch6LKNh4.cjs +0 -312
- package/dist/searchContext-CSmiMhhs.js +0 -129
- package/dist/searchContext-DuB2drQx.cjs +0 -145
- package/dist/searchServiceAdapter-B0h7psvh.js +0 -16
- package/dist/searchServiceAdapter-BclWy4fE.cjs +0 -34
- package/dist/sessionStorageContext-BuWrJQwc.cjs +0 -66
- package/dist/sessionStorageContext-DvFHbk81.js +0 -52
- package/dist/shopifyUrlContext-Bw1kAZ2P.cjs +0 -75
- package/dist/shopifyUrlContext-DnJiUmMA.js +0 -61
- package/dist/systemSettingsContext-CyanI1pd.js +0 -39
- package/dist/systemSettingsContext-sM46G65r.cjs +0 -60
- package/dist/types-1iJ_FnQQ.cjs +0 -39
- package/dist/types-D5du68Vp.js +0 -27
- package/dist/urlsParser-bb8ciRFg.cjs +0 -78
- package/dist/urlsParser-v_1DKvyf.js +0 -42
- package/dist/useAppDetails-Ce_siNC2.js +0 -30
- package/dist/useAppDetails-Dyn-dAJJ.cjs +0 -38
- package/dist/useGraphQLConfig-Btszi6cG.js +0 -63
- package/dist/useGraphQLConfig-v9veUbvJ.cjs +0 -76
- package/dist/utils-BZT_oZ3n.js +0 -92
- package/dist/utils-BzR9AjY0.js +0 -607
- package/dist/utils-CLANMl4P.cjs +0 -716
- package/dist/utils-qtHPLFby.cjs +0 -130
- package/src/atoms/search/productRetrievalAPI.ts +0 -72
- package/src/atoms/search/productRetrievalAdapter.ts +0 -28
- package/src/exceptions/index.ts +0 -2
- package/src/global.d.ts +0 -8
- package/src/hooks/Search/useRecommendedProducts.ts +0 -50
- package/src/hooks/Search/useSearchInput.ts +0 -237
- package/src/types/FilterAttribute.ts +0 -35
- package/src/types/Suggestion.ts +0 -6
- package/src/util/colorVar.ts +0 -4
- package/src/util/configVersion.ts +0 -4
- package/src/util/domInsertion.ts +0 -17
- /package/dist/{featureFlagServiceContext-Csgo-MUv.cjs → AmplitudeOperations-DxQnurSG.cjs} +0 -0
- /package/dist/{featureFlagServiceContext-CISyb90N.js → AmplitudeOperations-ni7wVevx.js} +0 -0
- /package/src/{exceptions → types/exceptions}/sessionExceptions.ts +0 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
OrgAnalyticsAmplitudeConfig,
|
|
5
5
|
OrgAnalyticsCustomerServiceConfig,
|
|
6
6
|
OrgAnalyticsGoogleAnalyticsConfig,
|
|
7
|
-
} from '
|
|
7
|
+
} from 'src/application/models/api/orgAnalyticsConfig';
|
|
8
8
|
|
|
9
9
|
const internalOrgAnalyticsConfigAtom = atom<OrgAnalyticsConfig | undefined>(undefined);
|
|
10
10
|
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
import { UserEventCategory } from "@spiffy-ai/commerce-api-client";
|
|
2
|
+
import { v4 as uuid } from "uuid";
|
|
3
|
+
import { atom } from "jotai";
|
|
4
|
+
import {
|
|
5
|
+
Message,
|
|
6
|
+
MessageRole,
|
|
7
|
+
MessageType,
|
|
8
|
+
ProductResponseAttributes,
|
|
9
|
+
} from "src/application/models";
|
|
10
|
+
import {
|
|
11
|
+
messagesAtom,
|
|
12
|
+
replyEventCategoryAtom,
|
|
13
|
+
userHasRepliedAtom,
|
|
14
|
+
userQueryAtom,
|
|
15
|
+
} from "src/atoms/chat";
|
|
16
|
+
import { queueUserEventAtom } from "../chat/messageQueue";
|
|
17
|
+
import { newOrgConfigAtom } from "../org";
|
|
18
|
+
import { ProductFilters } from "./productFilters";
|
|
19
|
+
import { ProductSorter } from "./productSorter";
|
|
20
|
+
import { ChatSearchStateType, ProductSorting } from "./types";
|
|
21
|
+
|
|
22
|
+
// NOTE:
|
|
23
|
+
// This is a legacy version of search that needs to be decoupled and removed.
|
|
24
|
+
// the new search.ts file in this directory is likely what you're looking for.
|
|
25
|
+
|
|
26
|
+
export const chatSearchStateAtom = atom<ChatSearchStateType>("entrypoint");
|
|
27
|
+
export const chatSearchHasProductsAtom = atom<boolean>(false);
|
|
28
|
+
export const chatSearchProductSortingAtom = atom<ProductSorting>(
|
|
29
|
+
ProductSorting.FEATURED
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const filterProductList = (message: Message) =>
|
|
33
|
+
message.type === MessageType.Product && message.metadata.isForGrid === true;
|
|
34
|
+
const filterFilterList = (message: Message) =>
|
|
35
|
+
message.type === MessageType.ProductSearchFilter;
|
|
36
|
+
|
|
37
|
+
export type ChatSearchTurn = {
|
|
38
|
+
id: string;
|
|
39
|
+
generatedQuery?: string;
|
|
40
|
+
productCount: number;
|
|
41
|
+
productList: ProductResponseAttributes["attributes"][];
|
|
42
|
+
filterList: string[];
|
|
43
|
+
messages: Message[];
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const chatSearchIsLoadingAtom = atom(false);
|
|
47
|
+
|
|
48
|
+
const buildChatSearchTurn = (
|
|
49
|
+
messages: Message[]
|
|
50
|
+
): [string, ChatSearchTurn] | null => {
|
|
51
|
+
const queryMessage = messages.find(
|
|
52
|
+
(message) => message.type === MessageType.ProductSearch
|
|
53
|
+
);
|
|
54
|
+
if (!queryMessage) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const { generatedQuery, productCount } = queryMessage.metadata ?? {};
|
|
58
|
+
const productList = messages
|
|
59
|
+
.filter(filterProductList)
|
|
60
|
+
.map((message) => (message as any).metadata);
|
|
61
|
+
const filterList = messages
|
|
62
|
+
.filter(filterFilterList)
|
|
63
|
+
.map((message) => message.metadata.filterName);
|
|
64
|
+
return [
|
|
65
|
+
queryMessage.id,
|
|
66
|
+
{
|
|
67
|
+
id: queryMessage.id,
|
|
68
|
+
generatedQuery,
|
|
69
|
+
productCount: productCount || productList.length,
|
|
70
|
+
productList,
|
|
71
|
+
filterList,
|
|
72
|
+
messages,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const chatSearchFilterConfigAtom = atom((get) => {
|
|
78
|
+
const newOrgConfig = get(newOrgConfigAtom);
|
|
79
|
+
return (
|
|
80
|
+
newOrgConfig?.frontendConfig?.uiConfigs?.searchConfig?.searchFilterConfig ||
|
|
81
|
+
[]
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const searchMapAtom = atom((get) => {
|
|
86
|
+
const messages = get(messagesAtom);
|
|
87
|
+
return Object.fromEntries(
|
|
88
|
+
messages.map(buildChatSearchTurn).filter((v) => v !== null)
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const internalChatSearchParamsAtom = atom<{
|
|
93
|
+
id: string | null;
|
|
94
|
+
query: string | null;
|
|
95
|
+
}>({
|
|
96
|
+
id: null,
|
|
97
|
+
query: null,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Selected filter options with compound objects for better type safety and display
|
|
101
|
+
export type SelectedChatSearchFilterOption = {
|
|
102
|
+
id: string; // "filterId:filterItemId" - maintains backward compatibility for comparisons
|
|
103
|
+
displayName: string;
|
|
104
|
+
filterId: string; // Filter category
|
|
105
|
+
filterItemId: string; // Filter value
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const selectedFilterOptionsAtom = atom<SelectedChatSearchFilterOption[]>(
|
|
109
|
+
[]
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
export const additiveDynamicFiltersAtom = atom((get) => {
|
|
113
|
+
const newOrgConfig = get(newOrgConfigAtom);
|
|
114
|
+
return (
|
|
115
|
+
newOrgConfig?.frontendConfig?.uiConfigs?.searchConfig
|
|
116
|
+
?.additiveDynamicFilters ?? false
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
export const createChatSearchFilterOption = (
|
|
121
|
+
filterId: string,
|
|
122
|
+
filterItemId: string,
|
|
123
|
+
displayName: string
|
|
124
|
+
): SelectedChatSearchFilterOption => ({
|
|
125
|
+
id: `${filterId}:${filterItemId}`,
|
|
126
|
+
displayName,
|
|
127
|
+
filterId,
|
|
128
|
+
filterItemId,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const handleSearchAtom = atom(null, (get, set, message: Message) => {
|
|
132
|
+
if (message.type !== MessageType.Search) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const querySearch = message.metadata.searchTerm;
|
|
137
|
+
|
|
138
|
+
set(replyEventCategoryAtom, UserEventCategory.Search);
|
|
139
|
+
set(userQueryAtom, querySearch);
|
|
140
|
+
set(messagesAtom, [...get(messagesAtom), [message]]);
|
|
141
|
+
set(userHasRepliedAtom, true);
|
|
142
|
+
|
|
143
|
+
set(queueUserEventAtom, {
|
|
144
|
+
eventId: message.id,
|
|
145
|
+
category: UserEventCategory.Search,
|
|
146
|
+
createdAt: message.createdAt,
|
|
147
|
+
attributes: {
|
|
148
|
+
searchTerm: message.metadata.searchTerm,
|
|
149
|
+
selectedFilters: message.metadata.selectedFilters,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// This internal atom is used to store the search params
|
|
155
|
+
export const chatSearchParamsAtom = atom(
|
|
156
|
+
(get) => get(internalChatSearchParamsAtom),
|
|
157
|
+
(_, set, value: { id: string | null; query: string | null }) => {
|
|
158
|
+
set(internalChatSearchParamsAtom, value);
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
export const chatSearchQueryAtom = atom(
|
|
163
|
+
(get) => get(chatSearchParamsAtom)?.query ?? null,
|
|
164
|
+
(get, set, value: string | null) => {
|
|
165
|
+
const searchParams = get(chatSearchParamsAtom);
|
|
166
|
+
set(chatSearchParamsAtom, { id: searchParams.id, query: value });
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
export const chatSearchIdAtom = atom(
|
|
171
|
+
(get) => get(chatSearchParamsAtom)?.id ?? null,
|
|
172
|
+
(get, set, value: string | null) => {
|
|
173
|
+
const searchParams = get(chatSearchParamsAtom);
|
|
174
|
+
set(chatSearchParamsAtom, { id: value, query: searchParams.query });
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
export const ChatSearchTurnAtom = atom((get) => {
|
|
179
|
+
const searchFilterConfig = get(chatSearchFilterConfigAtom);
|
|
180
|
+
const searchMap = get(searchMapAtom);
|
|
181
|
+
const chatSearchId = get(chatSearchIdAtom);
|
|
182
|
+
if (!chatSearchId) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
const ChatSearchTurn = searchMap[chatSearchId];
|
|
186
|
+
if (!ChatSearchTurn) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
const productSorting = get(chatSearchProductSortingAtom);
|
|
190
|
+
const selectedFilterOptions = get(selectedFilterOptionsAtom);
|
|
191
|
+
const additiveDynamicFilters = get(additiveDynamicFiltersAtom);
|
|
192
|
+
const filteredProducts = ProductFilters.filterProducts(
|
|
193
|
+
ChatSearchTurn.productList,
|
|
194
|
+
searchFilterConfig,
|
|
195
|
+
selectedFilterOptions,
|
|
196
|
+
additiveDynamicFilters
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
const filteredAndSortedProducts = ProductSorter.sort(
|
|
200
|
+
filteredProducts,
|
|
201
|
+
productSorting
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
...searchMap[chatSearchId],
|
|
206
|
+
productList: filteredAndSortedProducts,
|
|
207
|
+
productCount: filteredAndSortedProducts.length,
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// TODO: Work on deprecating this atom in favor of using ChatSearchTurnAtom directly
|
|
212
|
+
export const chatSearchProducts = atom((get) => {
|
|
213
|
+
const ChatSearchTurn = get(ChatSearchTurnAtom);
|
|
214
|
+
return ChatSearchTurn?.productList ?? [];
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
export const chatSearchFiltersAtom = atom((get) => {
|
|
218
|
+
const searchFilterConfig = get(chatSearchFilterConfigAtom);
|
|
219
|
+
const searchMap = get(searchMapAtom);
|
|
220
|
+
const chatSearchId = get(chatSearchIdAtom);
|
|
221
|
+
|
|
222
|
+
if (chatSearchId && searchMap[chatSearchId]) {
|
|
223
|
+
const products = searchMap[chatSearchId].productList;
|
|
224
|
+
const selectedFilterOptions = get(selectedFilterOptionsAtom);
|
|
225
|
+
return ProductFilters.getFiltersForProducts(
|
|
226
|
+
products,
|
|
227
|
+
searchFilterConfig,
|
|
228
|
+
selectedFilterOptions
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
return [];
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// For search we use the following query params:
|
|
235
|
+
// es: true - this indicates that we are in a search state
|
|
236
|
+
// esq: query - this is the current search query
|
|
237
|
+
// esi: search id - this is the unique id for the search results that we are displaying. It is pulled from the message id from the turn that includes the search results
|
|
238
|
+
|
|
239
|
+
export const setSearchParams = (query: string) => {
|
|
240
|
+
const url = new URL(window.location.href);
|
|
241
|
+
url.searchParams.set("es", "true");
|
|
242
|
+
url.searchParams.set("esq", query);
|
|
243
|
+
window.history.pushState({}, "", url);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
export const getSearchParamsAtom = atom(() => {
|
|
247
|
+
const params = new URLSearchParams(window.location.search);
|
|
248
|
+
return {
|
|
249
|
+
es: params.get("es"),
|
|
250
|
+
esq: params.get("esq"),
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
export const initiateChatSearchAtom = atom(null, (_, set, query: string) => {
|
|
255
|
+
set(chatSearchIsLoadingAtom, true);
|
|
256
|
+
// Update URL and manually trigger state change (since pushState doesn't trigger popstate)
|
|
257
|
+
const url = new URL(window.location.href);
|
|
258
|
+
url.searchParams.set("es", "true");
|
|
259
|
+
url.searchParams.set("esq", query);
|
|
260
|
+
window.history.pushState({}, "", url);
|
|
261
|
+
|
|
262
|
+
// Manually trigger page variant re-evaluation by dispatching a popstate event
|
|
263
|
+
// This ensures the page variant system detects the URL change and mounts search results
|
|
264
|
+
window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
265
|
+
|
|
266
|
+
set(chatSearchParamsAtom, { id: null, query });
|
|
267
|
+
set(handleSearchAtom, {
|
|
268
|
+
id: uuid(),
|
|
269
|
+
role: MessageRole.User,
|
|
270
|
+
type: MessageType.Search,
|
|
271
|
+
createdAt: new Date().toISOString(),
|
|
272
|
+
metadata: {
|
|
273
|
+
searchTerm: query,
|
|
274
|
+
// Enabling this will enable the new backend search
|
|
275
|
+
selectedFilters: [],
|
|
276
|
+
},
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
export const handleSearchResultsAtom = atom(
|
|
281
|
+
null,
|
|
282
|
+
(get, set, message: Message | undefined) => {
|
|
283
|
+
if (!message || message.type !== MessageType.ProductSearch) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const { productCount, generatedQuery } = message.metadata;
|
|
288
|
+
if (productCount !== 0) {
|
|
289
|
+
// Clear the filter options when we get new products
|
|
290
|
+
set(selectedFilterOptionsAtom, []);
|
|
291
|
+
// TODO: Should we still do any of these things?
|
|
292
|
+
set(chatSearchStateAtom, "product-page");
|
|
293
|
+
const currentSearchParams = get(chatSearchParamsAtom);
|
|
294
|
+
const url = new URL(window.location.href);
|
|
295
|
+
url.searchParams.set("es", "true");
|
|
296
|
+
url.searchParams.set("esq", generatedQuery);
|
|
297
|
+
url.searchParams.set("esi", message.id);
|
|
298
|
+
window.history.pushState({}, "", url);
|
|
299
|
+
if (currentSearchParams.id === null) {
|
|
300
|
+
// If the id is null, we need to replace the state
|
|
301
|
+
window.history.replaceState(null, "", url);
|
|
302
|
+
} else {
|
|
303
|
+
// If the query is different, we need to push a new state
|
|
304
|
+
window.history.pushState(null, "", url);
|
|
305
|
+
}
|
|
306
|
+
set(chatSearchParamsAtom, { id: message.id, query: generatedQuery });
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
export const setChatSearchParamsAtom = atom(null, (_, set, query: string) => {
|
|
312
|
+
const url = new URL(window.location.href);
|
|
313
|
+
url.searchParams.set("es", "true");
|
|
314
|
+
url.searchParams.set("esq", query);
|
|
315
|
+
window.history.pushState({}, "", url);
|
|
316
|
+
set(chatSearchParamsAtom, { id: null, query });
|
|
317
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FilterAttribute
|
|
3
|
-
import { SelectedFilterOption } from
|
|
4
|
-
import {
|
|
1
|
+
import { ProductResponseAttributes } from 'src/application/models';
|
|
2
|
+
import { FilterAttribute } from 'src/contexts/types';
|
|
3
|
+
import { SelectedFilterOption } from 'src/atoms/search/searchAPI';
|
|
4
|
+
import { ChatSearchFilter, ChatSearchFilterItem } from './types';
|
|
5
|
+
import { formatFilterDisplayName } from './utils';
|
|
5
6
|
|
|
6
7
|
const getPriceBucket = (price: number, bucketSize: number) => {
|
|
7
8
|
const bucket = Math.floor(price / bucketSize);
|
|
@@ -12,30 +13,27 @@ const isStringArray = (value: unknown): value is string[] => {
|
|
|
12
13
|
if (!Array.isArray(value)) {
|
|
13
14
|
return false;
|
|
14
15
|
}
|
|
15
|
-
return value.every((item) => typeof item ===
|
|
16
|
+
return value.every((item) => typeof item === 'string');
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
type FilterSortFunction = (
|
|
19
|
-
a: ChatSearchFilterItem,
|
|
20
|
-
b: ChatSearchFilterItem
|
|
21
|
-
) => number;
|
|
19
|
+
type FilterSortFunction = (a: ChatSearchFilterItem, b: ChatSearchFilterItem) => number;
|
|
22
20
|
|
|
23
21
|
const sortFilter = (filterConfig: FilterAttribute): FilterSortFunction => {
|
|
24
|
-
if (filterConfig.type ===
|
|
22
|
+
if (filterConfig.type === 'price') {
|
|
25
23
|
return (a, b) => Number(a.filterItemId) - Number(b.filterItemId);
|
|
26
24
|
}
|
|
27
|
-
if (filterConfig.type ===
|
|
28
|
-
if (filterConfig.sorting.type ===
|
|
25
|
+
if (filterConfig.type === 'dynamic') {
|
|
26
|
+
if (filterConfig.sorting.type === 'alphabetic') {
|
|
29
27
|
return (a, b) => a.displayName.localeCompare(b.displayName);
|
|
30
28
|
}
|
|
31
29
|
// Sort by the number of products, if they match, sort by alphabetical
|
|
32
|
-
if (filterConfig.sorting.type ===
|
|
30
|
+
if (filterConfig.sorting.type === 'productCount') {
|
|
33
31
|
return (a, b) =>
|
|
34
32
|
a.productCount === b.productCount
|
|
35
33
|
? a.displayName.localeCompare(b.displayName)
|
|
36
34
|
: b.productCount - a.productCount;
|
|
37
35
|
}
|
|
38
|
-
if (filterConfig.sorting.type ===
|
|
36
|
+
if (filterConfig.sorting.type === 'custom') {
|
|
39
37
|
const sortedKeys = filterConfig.sorting.map;
|
|
40
38
|
return (a, b) => {
|
|
41
39
|
if (sortedKeys[a.displayName] && sortedKeys[b.displayName]) {
|
|
@@ -55,14 +53,14 @@ const sortFilter = (filterConfig: FilterAttribute): FilterSortFunction => {
|
|
|
55
53
|
};
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
|
-
throw new Error(
|
|
56
|
+
throw new Error('Invaalid search filter configuration');
|
|
59
57
|
};
|
|
60
58
|
|
|
61
59
|
export class ProductFilters {
|
|
62
60
|
static getFiltersForProducts(
|
|
63
|
-
products: ProductResponseAttributes[
|
|
61
|
+
products: ProductResponseAttributes['attributes'][],
|
|
64
62
|
filterConfigs: FilterAttribute[],
|
|
65
|
-
selectedFilterOptions: SelectedFilterOption[]
|
|
63
|
+
selectedFilterOptions: SelectedFilterOption[],
|
|
66
64
|
): ChatSearchFilter[] {
|
|
67
65
|
if (!products || products.length === 0) {
|
|
68
66
|
return [];
|
|
@@ -72,29 +70,23 @@ export class ProductFilters {
|
|
|
72
70
|
products.reduce(
|
|
73
71
|
(acc, product) => {
|
|
74
72
|
// Price has special handling for the filters
|
|
75
|
-
if (filterConfig.type ===
|
|
73
|
+
if (filterConfig.type === 'price') {
|
|
76
74
|
const priceBucket = getPriceBucket(
|
|
77
75
|
product.salePrice ?? product.originalPrice ?? 0,
|
|
78
|
-
filterConfig.bucketSize
|
|
76
|
+
filterConfig.bucketSize,
|
|
79
77
|
);
|
|
80
78
|
const current = acc.map[priceBucket] ?? {
|
|
81
79
|
filterItemId: priceBucket,
|
|
82
|
-
displayName: `$${priceBucket}-$${
|
|
83
|
-
priceBucket + filterConfig.bucketSize
|
|
84
|
-
}`,
|
|
80
|
+
displayName: `$${priceBucket}-$${priceBucket + filterConfig.bucketSize}`,
|
|
85
81
|
productCount: 0,
|
|
86
82
|
};
|
|
87
|
-
acc.map[priceBucket] = {
|
|
88
|
-
...current,
|
|
89
|
-
productCount: current.productCount + 1,
|
|
90
|
-
};
|
|
83
|
+
acc.map[priceBucket] = { ...current, productCount: current.productCount + 1 };
|
|
91
84
|
return acc;
|
|
92
85
|
}
|
|
93
86
|
|
|
94
87
|
// Assume that the "attribute" is an array of values
|
|
95
88
|
const attributeValues =
|
|
96
|
-
(product.filters && product.filters?.[filterConfig.attribute]) ??
|
|
97
|
-
[];
|
|
89
|
+
(product.filters && product.filters?.[filterConfig.attribute]) ?? [];
|
|
98
90
|
if (isStringArray(attributeValues)) {
|
|
99
91
|
attributeValues.forEach((val) => {
|
|
100
92
|
const normalizedVal = val.toLowerCase();
|
|
@@ -103,10 +95,7 @@ export class ProductFilters {
|
|
|
103
95
|
displayName: formatFilterDisplayName(val), // Keep original case for display
|
|
104
96
|
productCount: 0,
|
|
105
97
|
};
|
|
106
|
-
acc.map[normalizedVal] = {
|
|
107
|
-
...current,
|
|
108
|
-
productCount: current.productCount + 1,
|
|
109
|
-
};
|
|
98
|
+
acc.map[normalizedVal] = { ...current, productCount: current.productCount + 1 };
|
|
110
99
|
});
|
|
111
100
|
}
|
|
112
101
|
|
|
@@ -115,44 +104,40 @@ export class ProductFilters {
|
|
|
115
104
|
{
|
|
116
105
|
filterConfig,
|
|
117
106
|
map: {} as Record<string, ChatSearchFilterItem>,
|
|
118
|
-
}
|
|
119
|
-
)
|
|
107
|
+
},
|
|
108
|
+
),
|
|
120
109
|
);
|
|
121
110
|
|
|
122
|
-
const transformedFilters: ChatSearchFilter[] = filters.map(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
.
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}))
|
|
138
|
-
.sort(sortFilter(filterConfig)),
|
|
139
|
-
})
|
|
140
|
-
);
|
|
111
|
+
const transformedFilters: ChatSearchFilter[] = filters.map(({ filterConfig, map }) => ({
|
|
112
|
+
filterId: filterConfig.filterId,
|
|
113
|
+
displayName: filterConfig.displayName,
|
|
114
|
+
items: Object.values(map)
|
|
115
|
+
.map((filter) => ({
|
|
116
|
+
filterItemId: filter.filterItemId,
|
|
117
|
+
displayName: filter.displayName,
|
|
118
|
+
productCount: filter.productCount,
|
|
119
|
+
isSelected:
|
|
120
|
+
selectedFilterOptions.some(
|
|
121
|
+
(option) => option.id === `${filterConfig.filterId}:${filter.filterItemId}`,
|
|
122
|
+
) ?? false,
|
|
123
|
+
}))
|
|
124
|
+
.sort(sortFilter(filterConfig)),
|
|
125
|
+
}));
|
|
141
126
|
|
|
142
127
|
return [...transformedFilters];
|
|
143
128
|
}
|
|
144
129
|
|
|
145
130
|
static filterProducts(
|
|
146
|
-
products: ProductResponseAttributes[
|
|
131
|
+
products: ProductResponseAttributes['attributes'][],
|
|
147
132
|
filterConfigs: FilterAttribute[],
|
|
148
133
|
selectedFilterOptions: SelectedFilterOption[],
|
|
149
|
-
additiveDynamicFilters = false // Set this to true to restore the original behavior where stacking filters has OR logic.
|
|
134
|
+
additiveDynamicFilters = false, // Set this to true to restore the original behavior where stacking filters has OR logic.
|
|
150
135
|
) {
|
|
151
136
|
const selectedFilters = filterConfigs
|
|
152
137
|
.map((filterConfig) => ({
|
|
153
138
|
filterConfig,
|
|
154
139
|
hasSelectedOptions: selectedFilterOptions.some(
|
|
155
|
-
(option) => option.filterId === filterConfig.filterId
|
|
140
|
+
(option) => option.filterId === filterConfig.filterId,
|
|
156
141
|
),
|
|
157
142
|
}))
|
|
158
143
|
.filter(({ hasSelectedOptions }) => hasSelectedOptions);
|
|
@@ -165,20 +150,20 @@ export class ProductFilters {
|
|
|
165
150
|
return acc;
|
|
166
151
|
}
|
|
167
152
|
// Price is special
|
|
168
|
-
if (selectedFilter.filterConfig.type ===
|
|
153
|
+
if (selectedFilter.filterConfig.type === 'price') {
|
|
169
154
|
const priceBucket = getPriceBucket(
|
|
170
155
|
product.salePrice ?? product.originalPrice ?? 0,
|
|
171
|
-
selectedFilter.filterConfig.bucketSize
|
|
156
|
+
selectedFilter.filterConfig.bucketSize,
|
|
172
157
|
);
|
|
173
158
|
const matchesPriceFilter = selectedFilterOptions.some(
|
|
174
|
-
(option) => option.id === `price:${priceBucket}
|
|
159
|
+
(option) => option.id === `price:${priceBucket}`,
|
|
175
160
|
);
|
|
176
161
|
if (!matchesPriceFilter) {
|
|
177
162
|
return false;
|
|
178
163
|
}
|
|
179
164
|
}
|
|
180
165
|
|
|
181
|
-
if (selectedFilter.filterConfig.type ===
|
|
166
|
+
if (selectedFilter.filterConfig.type === 'dynamic') {
|
|
182
167
|
// dynamic is misleading here. Its not just dynamic filters, but static filters because the config counts static filters as type: dynamic.
|
|
183
168
|
const { filterId, attribute } = selectedFilter.filterConfig;
|
|
184
169
|
const attributeValues = product.filters?.[attribute];
|
|
@@ -187,10 +172,8 @@ export class ProductFilters {
|
|
|
187
172
|
return false;
|
|
188
173
|
}
|
|
189
174
|
|
|
190
|
-
const isDynamicFilter =
|
|
191
|
-
|
|
192
|
-
const isSubtractiveLogic =
|
|
193
|
-
isDynamicFilter && !additiveDynamicFilters;
|
|
175
|
+
const isDynamicFilter = selectedFilter.filterConfig.attribute === 'dynamic'; // True dynamic filters (the ones that appear beneath the search input)
|
|
176
|
+
const isSubtractiveLogic = isDynamicFilter && !additiveDynamicFilters;
|
|
194
177
|
|
|
195
178
|
if (isSubtractiveLogic) {
|
|
196
179
|
// AND logic for subtractive dynamic filters and between static filter categories
|
|
@@ -198,11 +181,8 @@ export class ProductFilters {
|
|
|
198
181
|
.filter((option) => option.filterId === filterId)
|
|
199
182
|
.map((option) => option.filterItemId.toLowerCase());
|
|
200
183
|
|
|
201
|
-
const hasAllSelectedValues = selectedOptionsForThisFilter.every(
|
|
202
|
-
(
|
|
203
|
-
attributeValues.some(
|
|
204
|
-
(val) => val.toLowerCase() === selectedValue
|
|
205
|
-
)
|
|
184
|
+
const hasAllSelectedValues = selectedOptionsForThisFilter.every((selectedValue) =>
|
|
185
|
+
attributeValues.some((val) => val.toLowerCase() === selectedValue),
|
|
206
186
|
);
|
|
207
187
|
|
|
208
188
|
if (!hasAllSelectedValues) {
|
|
@@ -212,8 +192,8 @@ export class ProductFilters {
|
|
|
212
192
|
// OR logic for static filters in the sidebar within a category.
|
|
213
193
|
const matches = attributeValues.some((val) =>
|
|
214
194
|
selectedFilterOptions.some(
|
|
215
|
-
(option) => option.id === `${filterId}:${val.toLowerCase()}
|
|
216
|
-
)
|
|
195
|
+
(option) => option.id === `${filterId}:${val.toLowerCase()}`,
|
|
196
|
+
),
|
|
217
197
|
);
|
|
218
198
|
if (!matches) {
|
|
219
199
|
return false;
|
|
@@ -221,7 +201,7 @@ export class ProductFilters {
|
|
|
221
201
|
}
|
|
222
202
|
}
|
|
223
203
|
return true;
|
|
224
|
-
}, true)
|
|
204
|
+
}, true),
|
|
225
205
|
);
|
|
226
206
|
}
|
|
227
207
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ProductResponseAttributes } from '
|
|
2
|
-
import { ProductSorting } from '
|
|
1
|
+
import { ProductResponseAttributes } from 'src/application/models';
|
|
2
|
+
import { ProductSorting } from './types';
|
|
3
3
|
|
|
4
4
|
export class ProductSorter {
|
|
5
5
|
static sort(products: ProductResponseAttributes['attributes'][], sorting: ProductSorting) {
|