@envive-ai/react-hooks 0.1.2 → 0.1.4
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/adapters/amplitude/index.cjs +8 -8
- package/dist/adapters/amplitude/index.d.cts +5 -3
- package/dist/adapters/amplitude/index.d.ts +5 -3
- package/dist/adapters/amplitude/index.js +5 -5
- package/dist/api-B2euFL-5.cjs +2 -1
- package/dist/api-XRr_lAG6.js +2 -1
- package/dist/application/config/index.cjs +14 -5
- package/dist/application/config/index.d.cts +2 -1
- package/dist/application/config/index.d.ts +2 -1
- package/dist/application/config/index.js +14 -5
- package/dist/application/models/graphql/index.cjs +7 -7
- package/dist/application/models/graphql/index.d.cts +1 -1
- package/dist/application/models/graphql/index.d.ts +1 -1
- package/dist/application/models/graphql/index.js +5 -5
- 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/index.cjs +49 -49
- package/dist/application/models/index.d.cts +8 -9
- package/dist/application/models/index.d.ts +8 -9
- package/dist/application/models/index.js +5 -5
- package/dist/application/models/utilityTypes/index.d.cts +1 -1
- package/dist/application/models/utilityTypes/index.d.ts +1 -1
- package/dist/application/models/variantInfo/index.d.cts +1 -1
- package/dist/application/models/variantInfo/index.d.ts +1 -1
- package/dist/application/service/customerService/index.cjs +1 -1
- package/dist/application/service/customerService/index.d.cts +2 -2
- package/dist/application/service/customerService/index.d.ts +2 -2
- package/dist/application/service/customerService/index.js +1 -1
- package/dist/application/service/index.cjs +30 -750
- package/dist/application/service/index.d.cts +14 -22
- package/dist/application/service/index.d.ts +14 -22
- package/dist/application/service/index.js +7 -722
- package/dist/application/utils/index.cjs +32 -32
- package/dist/application/utils/index.d.cts +13 -13
- package/dist/application/utils/index.d.ts +11 -11
- package/dist/application/utils/index.js +5 -5
- package/dist/atomStore-B1cgmbP0.js +32 -0
- package/dist/atomStore-JwGb7pcy.cjs +58 -0
- package/dist/atoms/app/index.cjs +11 -11
- package/dist/atoms/app/index.d.cts +11 -11
- package/dist/atoms/app/index.d.ts +11 -11
- package/dist/atoms/app/index.js +5 -5
- package/dist/atoms/atomStore/index.cjs +1 -2
- package/dist/atoms/atomStore/index.d.cts +2 -1
- package/dist/atoms/atomStore/index.d.ts +2 -1
- package/dist/atoms/atomStore/index.js +1 -2
- package/dist/atoms/chat/index.cjs +35 -35
- package/dist/atoms/chat/index.d.cts +37 -37
- package/dist/atoms/chat/index.d.ts +10 -10
- package/dist/atoms/chat/index.js +5 -5
- package/dist/atoms/globalSearch/index.cjs +1 -1
- package/dist/atoms/globalSearch/index.d.cts +7 -6
- package/dist/atoms/globalSearch/index.d.ts +7 -6
- package/dist/atoms/globalSearch/index.js +1 -1
- package/dist/atoms/org/index.cjs +32 -35
- package/dist/atoms/org/index.d.cts +32 -53
- package/dist/atoms/org/index.d.ts +31 -52
- package/dist/atoms/org/index.js +6 -7
- package/dist/atoms/search/index.cjs +36 -38
- package/dist/atoms/search/index.d.cts +9 -10
- package/dist/atoms/search/index.d.ts +9 -10
- package/dist/atoms/search/index.js +5 -7
- package/dist/bandolier-B76-OE75.cjs +1230 -0
- package/dist/bandolier-DRn_x1g1.js +1230 -0
- package/dist/carpe-kHi4RLB5.cjs +608 -0
- package/dist/carpe-qrSU99gq.js +606 -0
- package/dist/{chat-CCgyDehy.cjs → chat-BgONoYU7.cjs} +2 -1
- package/dist/chat-CLJ4NWcN.js +26 -0
- package/dist/{components-CScS7Ii-.cjs → components-BKZbet67.cjs} +2 -1
- package/dist/components-CV1fhAkj.js +11 -0
- package/dist/config/locators/components/chat/index.cjs +1 -1
- 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/index.js +1 -1
- package/dist/config/locators/components/chat/variants/index.cjs +2 -1
- package/dist/config/locators/components/chat/variants/index.d.cts +2 -1
- package/dist/config/locators/components/chat/variants/index.d.ts +2 -1
- package/dist/config/locators/components/chat/variants/index.js +2 -1
- package/dist/config/locators/components/index.cjs +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/index.js +1 -1
- package/dist/config/locators/components/search/index.cjs +2 -1
- package/dist/config/locators/components/search/index.d.cts +2 -1
- package/dist/config/locators/components/search/index.d.ts +2 -1
- package/dist/config/locators/components/search/index.js +2 -1
- package/dist/config/locators/index.cjs +4 -4
- package/dist/config/locators/index.d.cts +4 -3
- package/dist/config/locators/index.d.ts +4 -3
- package/dist/config/locators/index.js +4 -4
- package/dist/contexts/index.cjs +10 -13
- package/dist/contexts/index.d.cts +41 -22
- package/dist/contexts/index.d.ts +41 -22
- package/dist/contexts/index.js +6 -12
- package/dist/contexts-CQDwe3rK.cjs +14333 -0
- package/dist/contexts-e2sM-B9g.js +12919 -0
- package/dist/coterie-mMirPcHP.js +240 -0
- package/dist/coterie-yQ-_JXSw.cjs +240 -0
- package/dist/customerService-BG1uNZZ1.cjs +36 -0
- package/dist/customerService-BHQRnLhC.js +23 -0
- package/dist/custservice-types-C83itZmy.cjs +35 -0
- package/dist/custservice-types-DPQ-4TI6.js +23 -0
- package/dist/default-8Jfv8ehQ.cjs +199 -0
- package/dist/default-C8PQf-38.js +176 -0
- package/dist/default-LukSiCz1.js +4 -0
- package/dist/default-rJSJ887P.cjs +4 -0
- package/dist/divIds-CWkntTsx.js +23 -0
- package/dist/{divIds-CFyAjjp3.cjs → divIds-DEL_-qU0.cjs} +2 -1
- package/dist/dreamlandBaby-DHltv12Z.cjs +347 -0
- package/dist/dreamlandBaby-cG0HM9bt.js +347 -0
- package/dist/{embedded-BlXJUbik.cjs → embedded--2L0F4b5.cjs} +2 -1
- package/dist/embedded-C5uJqmuD.js +23 -0
- package/dist/entrypoints-CNUvSgnk.js +7 -0
- package/dist/entrypoints-DM9Sm18O.cjs +19 -0
- package/dist/events/index.d.cts +2 -1
- package/dist/events/index.d.ts +2 -1
- package/dist/events-ClCDFK7t.js +2 -1
- package/dist/events-Da7gpmGv.cjs +2 -1
- package/dist/featureFlagService-5wdmW02z.d.ts +18 -0
- package/dist/featureFlagService-DaelrXEk.d.cts +18 -0
- package/dist/fiveCbd-Cvnwh03g.cjs +614 -0
- package/dist/fiveCbd-DhYMlsf9.js +614 -0
- package/dist/forLoveAndLemons-C8DuUexW.js +666 -0
- package/dist/forLoveAndLemons-DR6a1zjJ.cjs +668 -0
- package/dist/{globalSearch-hxbXekus.cjs → globalSearch-BTeZxvk1.cjs} +2 -1
- package/dist/globalSearch-b0wC7ZEO.js +14 -0
- package/dist/greenpan-B4Pu65kV.js +398 -0
- package/dist/greenpan-BL5p6j7f.cjs +398 -0
- package/dist/grooveLife-DjKWHoN3.cjs +343 -0
- package/dist/grooveLife-JK0TyaPz.js +343 -0
- package/dist/homegrownCannabis-DxqSDkmS.js +411 -0
- package/dist/homegrownCannabis-ZnfCqW-m.cjs +411 -0
- package/dist/hooks/index.cjs +11 -11
- package/dist/hooks/index.d.cts +30 -21
- package/dist/hooks/index.d.ts +30 -21
- package/dist/hooks/index.js +6 -12
- package/dist/index-BTK5uzs6.d.cts +98 -0
- package/dist/index-BfuO9b0Q.d.ts +749 -0
- package/dist/index-BzgkfbNO.d.cts +228 -0
- package/dist/index-C62lPpy4.d.cts +25 -0
- package/dist/index-CExtydIH.d.ts +9 -0
- package/dist/index-CKKkTsms.d.ts +39 -0
- package/dist/index-CNsGWfS6.d.cts +749 -0
- package/dist/index-CYtsPztZ.d.cts +203 -0
- package/dist/index-C_C0tLeD.d.ts +203 -0
- package/dist/index-ClJ0nMsR.d.cts +184 -0
- package/dist/index-Cx9e-fRi.d.ts +184 -0
- package/dist/index-D2VaMPA3.d.ts +98 -0
- package/dist/index-D46Rd0io.d.cts +39 -0
- package/dist/index-DFL1dIT_.d.ts +7 -0
- package/dist/index-DPx8s5YH.d.ts +25 -0
- package/dist/index-Dxpscrvz.d.ts +228 -0
- package/dist/index-MFbPQ8Ji.d.ts +95 -0
- package/dist/index-VSFakgAI.d.cts +95 -0
- package/dist/index-jBATkcc_.d.cts +9 -0
- package/dist/index-zZjcds15.d.cts +7 -0
- package/dist/interceptors/index.cjs +7 -8
- package/dist/interceptors/index.d.cts +10 -10
- package/dist/interceptors/index.d.ts +10 -10
- package/dist/interceptors/index.js +5 -6
- package/dist/jackArcher-CXf_IAmC.js +728 -0
- package/dist/jackArcher-mGkojXek.cjs +728 -0
- package/dist/jordanCraig-BvCvPRoR.js +1787 -0
- package/dist/jordanCraig-Dv8pVCiS.cjs +1787 -0
- package/dist/kindredBravely-UQP7wiNu.cjs +491 -0
- package/dist/kindredBravely-X8F_LNph.js +491 -0
- package/dist/kutFromTheKloth-BhYKk3CN.cjs +370 -0
- package/dist/kutFromTheKloth-D1xsTSJr.js +370 -0
- package/dist/larryAndSerges-1411NuZa.cjs +262 -0
- package/dist/larryAndSerges-DVIRLItu.js +262 -0
- package/dist/leapsAndRebounds-BJ8mwr33.js +361 -0
- package/dist/leapsAndRebounds-UcP9EJVO.cjs +361 -0
- package/dist/logger-Dln20ans.cjs +2 -1
- package/dist/logger-pdEEY8T2.js +2 -1
- package/dist/longevityrx-BFSv9GF5.cjs +321 -0
- package/dist/longevityrx-Cp6wleWr.js +321 -0
- package/dist/lookOptic-BGhU4910.js +283 -0
- package/dist/lookOptic-KieSqskd.cjs +283 -0
- package/dist/mantraBrand-CHQw-0nw.cjs +751 -0
- package/dist/mantraBrand-DrqG9uqO.js +751 -0
- package/dist/medterra-CLG6Co1C.cjs +584 -0
- package/dist/medterra-D8ZX9NZC.js +584 -0
- package/dist/modells-BzyPwN2m.cjs +485 -0
- package/dist/modells-CAfqOCW4.js +485 -0
- package/dist/nodeSelector-B3bPtEjX.d.cts +31 -0
- package/dist/nodeSelector-BiCDowlK.d.ts +31 -0
- package/dist/orgConfigResults--dAwtw3W.d.ts +881 -0
- package/dist/orgConfigResults-BL0XBA6x.d.cts +881 -0
- package/dist/pressedFloral-DULBuQwR.cjs +662 -0
- package/dist/pressedFloral-Dp-7Fk3S.js +662 -0
- package/dist/search-filter-types-BNTLVXqQ.d.cts +102 -0
- package/dist/search-filter-types-DkmH1TxJ.d.ts +102 -0
- package/dist/skinPerfection-BxuYCeJX.js +335 -0
- package/dist/skinPerfection-Cd3XZ6By.cjs +335 -0
- package/dist/snapSupplements-Bf6htPM0.js +286 -0
- package/dist/snapSupplements-ZFnXyMuZ.cjs +286 -0
- package/dist/socialProofClasses-DdzG1tZy.js +10 -0
- package/dist/socialProofClasses-ky69yppk.cjs +40 -0
- package/dist/spanx-CwDPQaGj.js +662 -0
- package/dist/spanx-Cyd4qDlK.cjs +664 -0
- package/dist/spanxStaging-D43nyAGy.js +846 -0
- package/dist/spanxStaging-ijbYnHzr.cjs +849 -0
- package/dist/suggestionBarV2-types-CwOXzIKq.js +10 -0
- package/dist/{suggestionBarV2-types-DG3Ekk44.cjs → suggestionBarV2-types-Dc4-zJlV.cjs} +2 -1
- package/dist/supergoop-BnbFG7hm.cjs +338 -0
- package/dist/supergoop-CY043wIg.js +336 -0
- package/dist/test-types-CXVJxTeu.d.ts +40 -0
- package/dist/test-types-CuOq25VT.d.cts +40 -0
- package/dist/types/index.cjs +2 -2
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +2 -2
- package/dist/types-BF_CJeck.js +177 -0
- package/dist/types-CD4LFta-.d.cts +33 -0
- package/dist/types-CNH4sfF-.cjs +231 -0
- package/dist/types-DBdI0j89.d.ts +33 -0
- package/dist/uniqueVintage-Cui74mlJ.js +1212 -0
- package/dist/uniqueVintage-R2Jcu1y1.cjs +1214 -0
- package/dist/variant-CKVRF2-W.d.ts +13 -0
- package/dist/variant-raYuOP4L.d.cts +13 -0
- package/dist/venaCbd-o5_vOp4e.js +366 -0
- package/dist/venaCbd-r-IxEVc1.cjs +366 -0
- package/dist/westonJonBoucher-C95EuCl-.js +423 -0
- package/dist/westonJonBoucher-DjGEW3ZB.cjs +423 -0
- package/dist/wineEnthusiast-DeTFY8Gm.js +941 -0
- package/dist/wineEnthusiast-DvfcV5B3.cjs +941 -0
- package/dist/wolfMattress-6xPfOJt3.js +373 -0
- package/dist/wolfMattress-BjGnGKjP.cjs +373 -0
- package/dist/wolfTactical-Bi3WZu0m.cjs +350 -0
- package/dist/wolfTactical-C_F9-oPX.js +350 -0
- package/package.json +1 -1
- package/src/adapters/amplitude/amplitudeAdapter.ts +32 -9
- package/src/adapters/spiffy/commerce/api.ts +17 -8
- package/src/adapters/spiffy/commerce/graphql.ts +16 -5
- package/src/application/config/generalStaticConfig.ts +5 -2
- package/src/application/models/api/orgConfigResults.ts +6 -2
- package/src/application/models/validators/validateGraphQLColorsConfig.ts +23 -21
- package/src/application/service/cdnService.ts +4 -2
- package/src/application/service/index.ts +0 -1
- package/src/application/service/pageVariantService.ts +5 -5
- package/src/application/service/searchService.ts +9 -2
- package/src/application/service/windowChatToggleService.ts +28 -19
- package/src/application/service/windowFrontendConfigService.ts +7 -4
- package/src/atoms/app/index.ts +26 -17
- package/src/atoms/app/variant.ts +1 -0
- package/src/atoms/chat/messageQueue.ts +1 -1
- package/src/atoms/envive/enviveConfig.ts +81 -0
- package/src/atoms/org/graphqlConfig.ts +29 -11
- package/src/atoms/org/merchantCss.ts +114 -0
- package/src/atoms/org/org.ts +101 -64
- package/src/atoms/org/orgPageConfig.ts +9 -6
- package/src/atoms/org/orgUIConfig.ts +22 -9
- package/src/atoms/search/chatSearch.ts +85 -67
- package/src/contexts/chatContext.tsx +4 -1
- package/src/contexts/enviveConfigContext.tsx +37 -26
- package/src/contexts/enviveCssContext.tsx +20 -0
- package/src/contexts/index.ts +2 -0
- package/src/contexts/orgConfigContext.tsx +106 -0
- package/src/contexts/systemSettingsContext.tsx +22 -9
- package/src/contexts/types.ts +12 -9
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useSearch.tsx +16 -9
- package/src/hooks/utils.ts +1 -1
- package/src/interceptors/useFormEscalation.ts +26 -9
- package/src/types/search-filter-types.ts +7 -7
- package/src/types.ts +0 -2
- package/dist/api-CxGedDxj.cjs +0 -5057
- package/dist/api-NJEaveju.js +0 -4113
- package/dist/atomStore-BFtpknLM.js +0 -31
- package/dist/atomStore-CeJm9Llb.cjs +0 -57
- package/dist/bandolier-C7PAIw02.js +0 -1230
- package/dist/bandolier-oMkFDJMF.cjs +0 -1230
- package/dist/carpe-C0ccKuR9.cjs +0 -608
- package/dist/carpe-DFc78_lJ.js +0 -606
- package/dist/cdnService-DvDSpfVJ.js +0 -18
- package/dist/cdnService-dJU3sHpF.cjs +0 -23
- package/dist/chat-Dk6KPb1K.js +0 -25
- package/dist/components-DAQxVIn9.js +0 -10
- package/dist/contexts-DO75-Kmx.js +0 -7152
- package/dist/contexts-iAzSvZjb.cjs +0 -7331
- package/dist/coterie-BGT8hqFR.js +0 -240
- package/dist/coterie-Cp9FAJTQ.cjs +0 -240
- package/dist/customerService-CUyZzowx.js +0 -22
- package/dist/customerService-DqPw_XKf.cjs +0 -35
- package/dist/custservice-types-D8Npo-5Z.js +0 -22
- package/dist/custservice-types-E9_OSaZ7.cjs +0 -34
- package/dist/default-BAXPatxf.cjs +0 -198
- package/dist/default-BR3225LZ.js +0 -4
- package/dist/default-DR6YjE9B.cjs +0 -4
- package/dist/default-wf_IORgo.js +0 -175
- package/dist/divIds-BWvq-i6I.js +0 -22
- package/dist/dreamlandBaby-BzuMvUFS.cjs +0 -347
- package/dist/dreamlandBaby-DZvM81LQ.js +0 -347
- package/dist/embedded-C1jvFj3v.js +0 -22
- package/dist/entrypoints-CmmOszXO.js +0 -6
- package/dist/entrypoints-fowCLUT2.cjs +0 -18
- package/dist/enviveConfigContext-CUGLpPGU.js +0 -34
- package/dist/enviveConfigContext-Dfr2VH6u.cjs +0 -48
- package/dist/featureFlagService-CroFRxvD.d.cts +0 -17
- package/dist/featureFlagService-NkJ2fuEj.d.ts +0 -17
- package/dist/featureGates-BMWXU0dS.d.ts +0 -90
- package/dist/featureGates-N_gyHCTn.d.cts +0 -90
- package/dist/fiveCbd-DE-tDY3d.cjs +0 -614
- package/dist/fiveCbd-HNBPqPtX.js +0 -614
- package/dist/forLoveAndLemons-BKmJJ9pq.js +0 -666
- package/dist/forLoveAndLemons-BeVEBOiu.cjs +0 -668
- package/dist/frontendConfig-KeNqU1wa.d.cts +0 -790
- package/dist/frontendConfig-cPvCTWm6.d.ts +0 -790
- package/dist/globalSearch-BC0rOX3E.js +0 -13
- package/dist/greenpan-BX1viAZB.js +0 -398
- package/dist/greenpan-chd3aa5I.cjs +0 -398
- package/dist/grooveLife-CHot3rZw.js +0 -343
- package/dist/grooveLife-DEob7rK0.cjs +0 -343
- package/dist/homegrownCannabis-CoIjcehi.cjs +0 -411
- package/dist/homegrownCannabis-CwkS1qDA.js +0 -411
- package/dist/index-BdNKc2ix.d.cts +0 -8
- package/dist/index-BkhvV8RZ.d.cts +0 -202
- package/dist/index-BrXuc_Ck.d.cts +0 -24
- package/dist/index-C4zjAR1c.d.cts +0 -227
- package/dist/index-CGB6CAmr.d.ts +0 -6
- package/dist/index-CIco0cCQ.d.ts +0 -183
- package/dist/index-COG1kOZG.d.ts +0 -749
- package/dist/index-CVxe7FpL.d.cts +0 -6
- package/dist/index-Cn1SeI5y.d.cts +0 -183
- package/dist/index-Cqg6ltII.d.ts +0 -38
- package/dist/index-CzMrMKx-.d.ts +0 -202
- package/dist/index-DE_7Q8qK.d.ts +0 -94
- package/dist/index-Da0UzyI9.d.ts +0 -24
- package/dist/index-DbWWcYax.d.cts +0 -749
- package/dist/index-DtoVXd6O.d.cts +0 -97
- package/dist/index-JClBRnSX.d.cts +0 -94
- package/dist/index-ghzD_356.d.ts +0 -8
- package/dist/index-hdbCEjYy.d.cts +0 -38
- package/dist/index-luJrHgPN.d.ts +0 -97
- package/dist/index-tfRj22E1.d.ts +0 -227
- package/dist/jackArcher-BA-pkB4A.js +0 -728
- package/dist/jackArcher-bewC0q1T.cjs +0 -728
- package/dist/jordanCraig-B5k9nlAw.cjs +0 -1787
- package/dist/jordanCraig-BsQ1mYbt.js +0 -1787
- package/dist/kindredBravely-BxYkCpGY.js +0 -491
- package/dist/kindredBravely-DsN0fo3s.cjs +0 -491
- package/dist/kutFromTheKloth-BQTCu3ct.cjs +0 -370
- package/dist/kutFromTheKloth-bukOQM3P.js +0 -370
- package/dist/larryAndSerges-D1ecaT5a.js +0 -261
- package/dist/larryAndSerges-bj7fgy9b.cjs +0 -261
- package/dist/leapsAndRebounds-BfneG_0c.cjs +0 -361
- package/dist/leapsAndRebounds-DhNpZETg.js +0 -361
- package/dist/locators-C2DX_nX6.js +0 -1
- package/dist/locators-CUpyd9Wt.cjs +0 -0
- package/dist/longevityrx-CnoGcw0w.js +0 -321
- package/dist/longevityrx-D0goIuX0.cjs +0 -321
- package/dist/lookOptic-C4afLPZP.cjs +0 -283
- package/dist/lookOptic-uJWIKpER.js +0 -283
- package/dist/mantraBrand-8JUlYtCE.cjs +0 -751
- package/dist/mantraBrand-DuwKHM26.js +0 -751
- package/dist/medterra-BQec8rzn.js +0 -584
- package/dist/medterra-DH067P-V.cjs +0 -584
- package/dist/modells-DAgLE2xo.js +0 -485
- package/dist/modells-DUFnLmAz.cjs +0 -485
- package/dist/nodeSelector-DpKXszfU.d.ts +0 -30
- package/dist/nodeSelector-vKB44CDB.d.cts +0 -30
- package/dist/org-C11APG3v.js +0 -63
- package/dist/org-CnHL2I9B.cjs +0 -106
- package/dist/pressedFloral-DVZVfOSQ.cjs +0 -662
- package/dist/pressedFloral-MdbuoRyA.js +0 -662
- package/dist/search-CvHb1M3S.js +0 -542
- package/dist/search-bSYdOBhY.cjs +0 -743
- package/dist/search-filter-types-BsJjrxk0.d.ts +0 -101
- package/dist/search-filter-types-CqaGK3nM.d.cts +0 -101
- package/dist/skinPerfection-BcEWICQN.cjs +0 -335
- package/dist/skinPerfection-bGiYxq1i.js +0 -335
- package/dist/snapSupplements-BXSXTjqF.cjs +0 -286
- package/dist/snapSupplements-D7hHhdC9.js +0 -286
- package/dist/socialProofClasses-BYLiEXpU.cjs +0 -39
- package/dist/socialProofClasses-CkJufEGb.js +0 -9
- package/dist/spanx-5-0yX3iK.js +0 -662
- package/dist/spanx-lUzP6Lva.cjs +0 -664
- package/dist/spanxStaging-HglCMJag.js +0 -846
- package/dist/spanxStaging-hreMR0MS.cjs +0 -849
- package/dist/suggestionBarV2-types-B0RbMStE.js +0 -9
- package/dist/supergoop-C9DDT3lY.js +0 -335
- package/dist/supergoop-CkjtuRck.cjs +0 -337
- package/dist/test-types-C9b_OdfO.d.ts +0 -39
- package/dist/test-types-CpKCxk8U.d.cts +0 -39
- package/dist/types-BE4faOO_.d.cts +0 -32
- package/dist/types-BUjohkXp.cjs +0 -230
- package/dist/types-BVsTRyxL.js +0 -176
- package/dist/types-TD8g7LnH.d.ts +0 -32
- package/dist/uniqueVintage-DIMGtYAU.cjs +0 -1214
- package/dist/uniqueVintage-DPWA5Ed6.js +0 -1212
- package/dist/useMessageInterceptor-B-P_rw73.cjs +0 -72
- package/dist/useMessageInterceptor-C2RZM-fo.js +0 -57
- package/dist/variant-BGjOVpY3.d.cts +0 -12
- package/dist/variant-XITncuI3.d.ts +0 -12
- package/dist/venaCbd-B-znfAsl.js +0 -366
- package/dist/venaCbd-BOwOtpOz.cjs +0 -366
- package/dist/westonJonBoucher-CraTzRVt.cjs +0 -423
- package/dist/westonJonBoucher-DCRagGu3.js +0 -423
- package/dist/wineEnthusiast-Bv7umajk.js +0 -941
- package/dist/wineEnthusiast-sVuATrq6.cjs +0 -941
- package/dist/wolfMattress-BUH-Rhov.js +0 -373
- package/dist/wolfMattress-DpVHIEnJ.cjs +0 -373
- package/dist/wolfTactical-BcvF_sy-.cjs +0 -350
- package/dist/wolfTactical-Q14A1fpw.js +0 -350
- package/src/application/service/environmentService.ts +0 -51
- package/src/extension.ts +0 -63
- package/src/initialize.ts +0 -163
- package/src/main.tsx +0 -108
- package/src/merchants/uniqueVintage/views/useUniqueVintageChatSearch.ts +0 -147
- /package/dist/{atomStore-FSZd_20F.js → locators-Dc5ZT0aF.js} +0 -0
- /package/dist/{atomStore-B3tsg6mF.cjs → locators-lQMJj830.cjs} +0 -0
package/src/atoms/org/org.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
2
|
+
import Logger from "src/application/logging/logger";
|
|
2
3
|
import { ContextSourceEnum } from "@spiffy-ai/commerce-api-client";
|
|
3
4
|
import { atom } from "jotai";
|
|
4
5
|
import { atomWithStorage, createJSONStorage } from "jotai/utils";
|
|
5
6
|
import CommerceApiClient from "src/adapters/spiffy/commerce/api";
|
|
6
7
|
import { GraphQLClient } from "src/adapters/spiffy/commerce/graphql";
|
|
7
8
|
import { OrgConfig } from "src/application/models/api/orgConfigResults";
|
|
8
|
-
import { EnvironmentService } from "src/application/service/environmentService";
|
|
9
9
|
import { FeatureFlagService } from "src/application/service/featureFlagService";
|
|
10
10
|
import { UserIdentityService } from "src/application/service/userIdentityService";
|
|
11
11
|
import { AtomStore, getAtomStore } from "src/atoms/atomStore/atomStore";
|
|
@@ -13,13 +13,16 @@ import { PerfMetricsEvents, logPerfMetricAtom } from "src/atoms/chat";
|
|
|
13
13
|
import { orgAnalyticsConfigAtom } from "src/atoms/org/orgAnalyticsConfig";
|
|
14
14
|
import { colorsConfigAtom, frontendConfigAtom } from "./graphqlConfig";
|
|
15
15
|
import { getOrgUIConfig } from "./orgUIConfig";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
orgLevelApiKeyAtom,
|
|
18
|
+
orgShortNameAtom as enviveOrgShortNameAtom,
|
|
19
|
+
contextSourceAtom,
|
|
20
|
+
baseUrlAtom,
|
|
21
|
+
} from "src/atoms/envive/enviveConfig";
|
|
17
22
|
|
|
18
23
|
const internalApiKeyAtom = atom<string | undefined>(undefined);
|
|
19
24
|
const internalEndpointURLAtom = atom<string | undefined>(undefined);
|
|
20
|
-
const internalSourceAtom = atom<ContextSourceEnum>(
|
|
21
|
-
EnvironmentService.getContextSource()
|
|
22
|
-
);
|
|
25
|
+
const internalSourceAtom = atom<ContextSourceEnum | undefined>(undefined);
|
|
23
26
|
|
|
24
27
|
export const getApiKeyEnvVar = (shortName: string): string =>
|
|
25
28
|
`VITE_${shortName.replace(/-/g, "_").toUpperCase()}_API_KEY`;
|
|
@@ -32,7 +35,8 @@ export const apiKeyAtom = atom(
|
|
|
32
35
|
return apiKey;
|
|
33
36
|
}
|
|
34
37
|
|
|
35
|
-
const
|
|
38
|
+
const orgLevelApiKey = get(orgLevelApiKeyAtom);
|
|
39
|
+
const orgShortName = get(enviveOrgShortNameAtom);
|
|
36
40
|
|
|
37
41
|
if (orgLevelApiKey) {
|
|
38
42
|
return orgLevelApiKey;
|
|
@@ -45,8 +49,14 @@ export const apiKeyAtom = atom(
|
|
|
45
49
|
return window._spiffy.publicKey;
|
|
46
50
|
}
|
|
47
51
|
|
|
52
|
+
// During initial render, orgShortName might not be set yet
|
|
53
|
+
// Return undefined instead of throwing to allow for lazy initialization
|
|
48
54
|
if (!orgShortName) {
|
|
49
|
-
|
|
55
|
+
Logger.logWarn(
|
|
56
|
+
"[spiffy-ai] orgShortName not yet available, returning undefined for apiKey",
|
|
57
|
+
undefined
|
|
58
|
+
);
|
|
59
|
+
return undefined;
|
|
50
60
|
}
|
|
51
61
|
|
|
52
62
|
// The merchant probably forgot to set the apiKey
|
|
@@ -56,18 +66,6 @@ export const apiKeyAtom = atom(
|
|
|
56
66
|
set(internalApiKeyAtom, newVal);
|
|
57
67
|
}
|
|
58
68
|
);
|
|
59
|
-
export const endpointURLAtom = atom(
|
|
60
|
-
(get) => get(internalEndpointURLAtom) ?? EnvironmentService.getApiEndpoint(),
|
|
61
|
-
(_, set, newVal: string | undefined) => {
|
|
62
|
-
set(internalEndpointURLAtom, newVal);
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
export const sourceAtom = atom(
|
|
66
|
-
(get) => get(internalSourceAtom),
|
|
67
|
-
(_, set, newVal: ContextSourceEnum) => {
|
|
68
|
-
set(internalSourceAtom, newVal);
|
|
69
|
-
}
|
|
70
|
-
);
|
|
71
69
|
|
|
72
70
|
const orgConfigStorageUtil = createJSONStorage<
|
|
73
71
|
Record<string, OrgConfig> | undefined
|
|
@@ -100,7 +98,7 @@ export const featureFlagServiceAtom = atom(
|
|
|
100
98
|
return new FeatureFlagService(orgConfig.gates);
|
|
101
99
|
}
|
|
102
100
|
|
|
103
|
-
|
|
101
|
+
return undefined; // Return undefined instead of throwing
|
|
104
102
|
},
|
|
105
103
|
(_, set, value: FeatureFlagService) => {
|
|
106
104
|
set(internalFeatureFlagServiceAtom, value);
|
|
@@ -109,11 +107,7 @@ export const featureFlagServiceAtom = atom(
|
|
|
109
107
|
export const orgConfigAtom = atom(
|
|
110
108
|
(get) => {
|
|
111
109
|
const orgConfig = get(internalOrgConfigAtom);
|
|
112
|
-
|
|
113
|
-
return orgConfig;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
throw new Error("OrgConfig is referenced before it is set");
|
|
110
|
+
return orgConfig; // Return undefined if not set instead of throwing
|
|
117
111
|
},
|
|
118
112
|
(_, set, value: OrgConfig) => {
|
|
119
113
|
set(internalOrgConfigAtom, value);
|
|
@@ -122,11 +116,7 @@ export const orgConfigAtom = atom(
|
|
|
122
116
|
export const orgShortNameAtom = atom(
|
|
123
117
|
(get) => {
|
|
124
118
|
const orgShortName = get(internalOrgShortNameAtom);
|
|
125
|
-
|
|
126
|
-
return orgShortName;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
throw new Error("Org short name is referenced before it is set");
|
|
119
|
+
return orgShortName; // Return undefined if not set instead of throwing
|
|
130
120
|
},
|
|
131
121
|
(_, set, value: string) => {
|
|
132
122
|
set(internalOrgShortNameAtom, value);
|
|
@@ -135,11 +125,7 @@ export const orgShortNameAtom = atom(
|
|
|
135
125
|
export const orgDomainAtom = atom(
|
|
136
126
|
(get) => {
|
|
137
127
|
const orgDomain = get(internalOrgDomainAtom);
|
|
138
|
-
|
|
139
|
-
return orgDomain;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
throw new Error("Org domain is referenced before it is set");
|
|
128
|
+
return orgDomain; // Return undefined if not set instead of throwing
|
|
143
129
|
},
|
|
144
130
|
(_, set, value: string) => {
|
|
145
131
|
set(internalOrgDomainAtom, value);
|
|
@@ -148,11 +134,7 @@ export const orgDomainAtom = atom(
|
|
|
148
134
|
export const orgIdAtom = atom(
|
|
149
135
|
(get) => {
|
|
150
136
|
const orgId = get(internalOrgIdAtom);
|
|
151
|
-
|
|
152
|
-
return orgId;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
throw new Error("Org id is referenced before it is set");
|
|
137
|
+
return orgId; // Return undefined if not set instead of throwing
|
|
156
138
|
},
|
|
157
139
|
(_, set, value: string) => {
|
|
158
140
|
set(internalOrgIdAtom, value);
|
|
@@ -166,24 +148,41 @@ export const resetStoredOrgConfigAtom = () => {
|
|
|
166
148
|
|
|
167
149
|
// eslint-disable-next-line
|
|
168
150
|
const getGraphQLConfig = async (atomStore: AtomStore) => {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
151
|
+
try {
|
|
152
|
+
Logger.logDebug("getGraphQLConfig: Starting GraphQL client fetch");
|
|
153
|
+
const { colorsConfig, frontendConfig } =
|
|
154
|
+
(await GraphQLClient.getColorsAndFrontendConfig()) ?? {};
|
|
155
|
+
|
|
156
|
+
Logger.logDebug("getGraphQLConfig: GraphQL fetch completed", {
|
|
157
|
+
hasColorsConfig: !!colorsConfig,
|
|
158
|
+
hasFrontendConfig: !!frontendConfig,
|
|
159
|
+
frontendConfigKeys: frontendConfig ? Object.keys(frontendConfig) : [],
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const rawFrontendConfig = atomStore.get(frontendConfigAtom);
|
|
163
|
+
|
|
164
|
+
atomStore.set(colorsConfigAtom, colorsConfig);
|
|
165
|
+
|
|
166
|
+
atomStore.set(frontendConfigAtom, {
|
|
167
|
+
...rawFrontendConfig,
|
|
168
|
+
pageVariants: frontendConfig?.pageVariants,
|
|
169
|
+
mountingConfigs: frontendConfig?.mountingConfigs,
|
|
170
|
+
widgetConfigs: frontendConfig?.widgetConfigs,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
Logger.logDebug("getGraphQLConfig: Starting UI config fetch");
|
|
174
|
+
await getOrgUIConfig(
|
|
175
|
+
frontendConfig?.uiConfigs,
|
|
176
|
+
frontendConfig?.merchantOverrideCss
|
|
177
|
+
);
|
|
178
|
+
Logger.logDebug("getGraphQLConfig: UI config fetch completed");
|
|
179
|
+
} catch (error) {
|
|
180
|
+
Logger.logError(
|
|
181
|
+
"getGraphQLConfig: Error during GraphQL config fetch",
|
|
182
|
+
error
|
|
183
|
+
);
|
|
184
|
+
throw error; // Re-throw to be caught by the caller
|
|
185
|
+
}
|
|
187
186
|
};
|
|
188
187
|
|
|
189
188
|
/**
|
|
@@ -198,9 +197,16 @@ export const getAsyncOrgConfig = async (
|
|
|
198
197
|
): Promise<OrgConfig> => {
|
|
199
198
|
const atomStore = getAtomStore();
|
|
200
199
|
const apiKey = apiKeyOverride ?? atomStore.get(apiKeyAtom);
|
|
200
|
+
|
|
201
|
+
// If apiKey is still undefined, we need to wait or throw an error
|
|
202
|
+
if (!apiKey) {
|
|
203
|
+
throw new Error(
|
|
204
|
+
"[spiffy-ai] API key is required but not available. Ensure EnviveConfigProvider is properly set up with orgLevelApiKey or orgShortName."
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
201
208
|
atomStore.set(apiKeyAtom, apiKey);
|
|
202
|
-
|
|
203
|
-
atomStore.set(sourceAtom, EnvironmentService.getContextSource());
|
|
209
|
+
|
|
204
210
|
atomStore.set(logPerfMetricAtom, PerfMetricsEvents.OrgConfigLoadStarted);
|
|
205
211
|
const maybeOrgConfigByApiKey = atomStore.get(storedOrgConfigAtom);
|
|
206
212
|
let maybeOrgConfig = maybeOrgConfigByApiKey?.[apiKey];
|
|
@@ -214,7 +220,7 @@ export const getAsyncOrgConfig = async (
|
|
|
214
220
|
}
|
|
215
221
|
|
|
216
222
|
const latestConfig = maybeOrgConfig.configs?.find(
|
|
217
|
-
(config) => config.isLatest
|
|
223
|
+
(config: any) => config.isLatest
|
|
218
224
|
);
|
|
219
225
|
|
|
220
226
|
if (!latestConfig) {
|
|
@@ -248,7 +254,38 @@ export const getAsyncOrgConfig = async (
|
|
|
248
254
|
new FeatureFlagService(orgConfig.gates)
|
|
249
255
|
);
|
|
250
256
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
257
|
+
try {
|
|
258
|
+
Logger.logDebug("getAsyncOrgConfig: Starting GraphQL config fetch");
|
|
259
|
+
await getGraphQLConfig(atomStore);
|
|
260
|
+
Logger.logDebug(
|
|
261
|
+
"getAsyncOrgConfig: GraphQL config fetch completed successfully"
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
// Get the GraphQL config data that was just fetched and stored in atoms
|
|
265
|
+
// Note: colorsConfigAtom is async, so we need to await it
|
|
266
|
+
const colorsConfig = await atomStore.get(colorsConfigAtom);
|
|
267
|
+
const frontendConfig = atomStore.get(frontendConfigAtom);
|
|
268
|
+
|
|
269
|
+
// Merge the GraphQL config data into the orgConfig
|
|
270
|
+
const enhancedOrgConfig = {
|
|
271
|
+
...orgConfig,
|
|
272
|
+
colorsConfig,
|
|
273
|
+
frontendConfig,
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
Logger.logDebug("getAsyncOrgConfig: Enhanced orgConfig with GraphQL data", {
|
|
277
|
+
hasColorsConfig: !!colorsConfig,
|
|
278
|
+
hasFrontendConfig: !!frontendConfig,
|
|
279
|
+
frontendConfigKeys: frontendConfig ? Object.keys(frontendConfig) : [],
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
return enhancedOrgConfig;
|
|
283
|
+
} catch (graphqlError) {
|
|
284
|
+
Logger.logError(
|
|
285
|
+
"getAsyncOrgConfig: GraphQL config fetch failed",
|
|
286
|
+
graphqlError
|
|
287
|
+
);
|
|
288
|
+
// Don't throw here - the main org config is still valid even if GraphQL config fails
|
|
289
|
+
return orgConfig;
|
|
290
|
+
}
|
|
254
291
|
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { atom } from
|
|
2
|
-
import { getOrgInfo } from
|
|
3
|
-
import { frontendConfigAtom } from
|
|
4
|
-
import { orgConfigAtom } from
|
|
5
|
-
import { PageVariantConfig } from
|
|
1
|
+
import { atom } from "jotai";
|
|
2
|
+
import { getOrgInfo } from "src/application/models";
|
|
3
|
+
import { frontendConfigAtom } from "src/atoms/org/graphqlConfig";
|
|
4
|
+
import { orgConfigAtom } from "src/atoms/org/org";
|
|
5
|
+
import { PageVariantConfig } from "src/contexts/types";
|
|
6
6
|
|
|
7
7
|
const internalInjectedPageVariantsAtom = atom<PageVariantConfig[]>([]);
|
|
8
8
|
|
|
9
9
|
export const orgPageConfigAtom = atom(
|
|
10
10
|
async (get) => {
|
|
11
11
|
const orgConfig = get(orgConfigAtom);
|
|
12
|
+
if (!orgConfig) {
|
|
13
|
+
throw new Error("orgConfig is not available");
|
|
14
|
+
}
|
|
12
15
|
const orgInfo = await getOrgInfo(orgConfig.org.org.shortName);
|
|
13
16
|
const frontendConfig = get(frontendConfigAtom);
|
|
14
17
|
const injectedPageVariants = get(internalInjectedPageVariantsAtom);
|
|
@@ -34,5 +37,5 @@ export const orgPageConfigAtom = atom(
|
|
|
34
37
|
},
|
|
35
38
|
(_, set, pageVariants: PageVariantConfig[]) => {
|
|
36
39
|
set(internalInjectedPageVariantsAtom, pageVariants);
|
|
37
|
-
}
|
|
40
|
+
}
|
|
38
41
|
);
|
|
@@ -28,11 +28,7 @@ const internalOrgUIConfigAtom = atom<OrgUIConfig | undefined>(undefined);
|
|
|
28
28
|
export const orgUIConfigAtom = atom(
|
|
29
29
|
(get) => {
|
|
30
30
|
const orgUIConfig = get(internalOrgUIConfigAtom);
|
|
31
|
-
|
|
32
|
-
return orgUIConfig;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
throw new Error("OrgUIConfig is referenced before it is set");
|
|
31
|
+
return orgUIConfig; // Return undefined if not set instead of throwing
|
|
36
32
|
},
|
|
37
33
|
(_, set, value: OrgUIConfig) => {
|
|
38
34
|
set(internalOrgUIConfigAtom, value);
|
|
@@ -45,9 +41,22 @@ export const getOrgUIConfig = async (
|
|
|
45
41
|
) => {
|
|
46
42
|
const atomStore = getAtomStore();
|
|
47
43
|
const orgShortName = atomStore.get(orgShortNameAtom);
|
|
44
|
+
if (!orgShortName) {
|
|
45
|
+
Logger.logWarn("orgShortName is undefined, cannot get org info", undefined);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
48
49
|
const orgInfo = await getOrgInfo(orgShortName);
|
|
49
|
-
|
|
50
|
+
|
|
50
51
|
const featureFlagService = atomStore.get(featureFlagServiceAtom);
|
|
52
|
+
if (!featureFlagService) {
|
|
53
|
+
Logger.logWarn(
|
|
54
|
+
"featureFlagService is undefined, cannot get feature flags",
|
|
55
|
+
undefined
|
|
56
|
+
);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
const isNewFeatureEnabled = featureFlagService.isFeatureGateEnabled(
|
|
52
61
|
FeatureGates.IsNewFeatureEnabled
|
|
53
62
|
);
|
|
@@ -65,6 +74,7 @@ export const getOrgUIConfig = async (
|
|
|
65
74
|
FeatureGates.IsGraphQLComponentConfigsEnabled
|
|
66
75
|
);
|
|
67
76
|
|
|
77
|
+
const localOrgUIConfig = orgInfo.orgUIConfig();
|
|
68
78
|
let orgUIConfig: Partial<OrgUIConfig> = { ...localOrgUIConfig };
|
|
69
79
|
|
|
70
80
|
if (isGraphQLUIConfigsEnabled && graphqlMerchantOverrideCss) {
|
|
@@ -120,10 +130,13 @@ export const getOrgUIConfig = async (
|
|
|
120
130
|
};
|
|
121
131
|
|
|
122
132
|
export const orgCustomerServiceConfig = atom(
|
|
123
|
-
(get) => get(orgUIConfigAtom)
|
|
133
|
+
(get) => get(orgUIConfigAtom)?.customerServiceIntegration
|
|
124
134
|
);
|
|
125
135
|
|
|
126
136
|
export const orgCustomerServiceService = atom((get) => {
|
|
127
|
-
const
|
|
128
|
-
|
|
137
|
+
const config = get(orgCustomerServiceConfig);
|
|
138
|
+
if (!config?.provider) {
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
return findCustomerServiceImpl(config.provider);
|
|
129
142
|
});
|
|
@@ -1,55 +1,63 @@
|
|
|
1
|
-
import { UserEventCategory } from
|
|
2
|
-
import { v4 as uuid } from
|
|
3
|
-
import { atom } from
|
|
1
|
+
import { UserEventCategory } from "@spiffy-ai/commerce-api-client";
|
|
2
|
+
import { v4 as uuid } from "uuid";
|
|
3
|
+
import { atom } from "jotai";
|
|
4
4
|
import {
|
|
5
5
|
Message,
|
|
6
6
|
MessageRole,
|
|
7
7
|
MessageType,
|
|
8
8
|
ProductResponseAttributes,
|
|
9
|
-
} from
|
|
9
|
+
} from "src/application/models";
|
|
10
10
|
import {
|
|
11
11
|
messagesAtom,
|
|
12
12
|
replyEventCategoryAtom,
|
|
13
13
|
userHasRepliedAtom,
|
|
14
14
|
userQueryAtom,
|
|
15
|
-
} from
|
|
16
|
-
import { queueUserEventAtom } from
|
|
17
|
-
import { orgUIConfigAtom } from
|
|
18
|
-
import { ProductFilters } from
|
|
19
|
-
import { ProductSorter } from
|
|
20
|
-
import { ChatSearchStateType, ProductSorting } from
|
|
15
|
+
} from "src/atoms/chat";
|
|
16
|
+
import { queueUserEventAtom } from "../chat/messageQueue";
|
|
17
|
+
import { orgUIConfigAtom } from "../org";
|
|
18
|
+
import { ProductFilters } from "./productFilters";
|
|
19
|
+
import { ProductSorter } from "./productSorter";
|
|
20
|
+
import { ChatSearchStateType, ProductSorting } from "./types";
|
|
21
21
|
|
|
22
22
|
// NOTE:
|
|
23
23
|
// This is a legacy version of search that needs to be decoupled and removed.
|
|
24
24
|
// the new search.ts file in this directory is likely what you're looking for.
|
|
25
25
|
|
|
26
|
-
export const chatSearchStateAtom = atom<ChatSearchStateType>(
|
|
26
|
+
export const chatSearchStateAtom = atom<ChatSearchStateType>("entrypoint");
|
|
27
27
|
export const chatSearchHasProductsAtom = atom<boolean>(false);
|
|
28
|
-
export const chatSearchProductSortingAtom = atom<ProductSorting>(
|
|
28
|
+
export const chatSearchProductSortingAtom = atom<ProductSorting>(
|
|
29
|
+
ProductSorting.FEATURED
|
|
30
|
+
);
|
|
29
31
|
|
|
30
32
|
const filterProductList = (message: Message) =>
|
|
31
33
|
message.type === MessageType.Product && message.metadata.isForGrid === true;
|
|
32
|
-
const filterFilterList = (message: Message) =>
|
|
34
|
+
const filterFilterList = (message: Message) =>
|
|
35
|
+
message.type === MessageType.ProductSearchFilter;
|
|
33
36
|
|
|
34
37
|
export type ChatSearchTurn = {
|
|
35
38
|
id: string;
|
|
36
39
|
generatedQuery?: string;
|
|
37
40
|
productCount: number;
|
|
38
|
-
productList: ProductResponseAttributes[
|
|
41
|
+
productList: ProductResponseAttributes["attributes"][];
|
|
39
42
|
filterList: string[];
|
|
40
43
|
messages: Message[];
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
export const chatSearchIsLoadingAtom = atom(false);
|
|
44
47
|
|
|
45
|
-
const buildChatSearchTurn = (
|
|
46
|
-
|
|
48
|
+
const buildChatSearchTurn = (
|
|
49
|
+
messages: Message[]
|
|
50
|
+
): [string, ChatSearchTurn] | null => {
|
|
51
|
+
const queryMessage = messages.find(
|
|
52
|
+
(message) => message.type === MessageType.ProductSearch
|
|
53
|
+
);
|
|
47
54
|
if (!queryMessage) {
|
|
48
55
|
return null;
|
|
49
56
|
}
|
|
50
57
|
const { generatedQuery, productCount } = queryMessage.metadata ?? {};
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
const productList = messages
|
|
59
|
+
.filter(filterProductList)
|
|
60
|
+
.map((message) => (message as any).metadata);
|
|
53
61
|
const filterList = messages
|
|
54
62
|
.filter(filterFilterList)
|
|
55
63
|
.map((message) => message.metadata.filterName);
|
|
@@ -67,13 +75,15 @@ const buildChatSearchTurn = (messages: Message[]): [string, ChatSearchTurn] | nu
|
|
|
67
75
|
};
|
|
68
76
|
|
|
69
77
|
const chatSearchFilterConfigAtom = atom((get) => {
|
|
70
|
-
const
|
|
71
|
-
return searchConfig
|
|
78
|
+
const orgUIConfig = get(orgUIConfigAtom);
|
|
79
|
+
return orgUIConfig?.searchConfig?.searchFilterConfig || [];
|
|
72
80
|
});
|
|
73
81
|
|
|
74
82
|
const searchMapAtom = atom((get) => {
|
|
75
83
|
const messages = get(messagesAtom);
|
|
76
|
-
return Object.fromEntries(
|
|
84
|
+
return Object.fromEntries(
|
|
85
|
+
messages.map(buildChatSearchTurn).filter((v) => v !== null)
|
|
86
|
+
);
|
|
77
87
|
});
|
|
78
88
|
|
|
79
89
|
const internalChatSearchParamsAtom = atom<{
|
|
@@ -92,17 +102,19 @@ export type SelectedChatSearchFilterOption = {
|
|
|
92
102
|
filterItemId: string; // Filter value
|
|
93
103
|
};
|
|
94
104
|
|
|
95
|
-
export const selectedFilterOptionsAtom = atom<SelectedChatSearchFilterOption[]>(
|
|
105
|
+
export const selectedFilterOptionsAtom = atom<SelectedChatSearchFilterOption[]>(
|
|
106
|
+
[]
|
|
107
|
+
);
|
|
96
108
|
|
|
97
109
|
export const additiveDynamicFiltersAtom = atom((get) => {
|
|
98
|
-
const
|
|
99
|
-
return searchConfig
|
|
110
|
+
const orgUIConfig = get(orgUIConfigAtom);
|
|
111
|
+
return orgUIConfig?.searchConfig?.additiveDynamicFilters ?? false;
|
|
100
112
|
});
|
|
101
113
|
|
|
102
114
|
export const createChatSearchFilterOption = (
|
|
103
115
|
filterId: string,
|
|
104
116
|
filterItemId: string,
|
|
105
|
-
displayName: string
|
|
117
|
+
displayName: string
|
|
106
118
|
): SelectedChatSearchFilterOption => ({
|
|
107
119
|
id: `${filterId}:${filterItemId}`,
|
|
108
120
|
displayName,
|
|
@@ -138,7 +150,7 @@ export const chatSearchParamsAtom = atom(
|
|
|
138
150
|
(get) => get(internalChatSearchParamsAtom),
|
|
139
151
|
(_, set, value: { id: string | null; query: string | null }) => {
|
|
140
152
|
set(internalChatSearchParamsAtom, value);
|
|
141
|
-
}
|
|
153
|
+
}
|
|
142
154
|
);
|
|
143
155
|
|
|
144
156
|
export const chatSearchQueryAtom = atom(
|
|
@@ -146,7 +158,7 @@ export const chatSearchQueryAtom = atom(
|
|
|
146
158
|
(get, set, value: string | null) => {
|
|
147
159
|
const searchParams = get(chatSearchParamsAtom);
|
|
148
160
|
set(chatSearchParamsAtom, { id: searchParams.id, query: value });
|
|
149
|
-
}
|
|
161
|
+
}
|
|
150
162
|
);
|
|
151
163
|
|
|
152
164
|
export const chatSearchIdAtom = atom(
|
|
@@ -154,7 +166,7 @@ export const chatSearchIdAtom = atom(
|
|
|
154
166
|
(get, set, value: string | null) => {
|
|
155
167
|
const searchParams = get(chatSearchParamsAtom);
|
|
156
168
|
set(chatSearchParamsAtom, { id: value, query: searchParams.query });
|
|
157
|
-
}
|
|
169
|
+
}
|
|
158
170
|
);
|
|
159
171
|
|
|
160
172
|
export const ChatSearchTurnAtom = atom((get) => {
|
|
@@ -175,10 +187,13 @@ export const ChatSearchTurnAtom = atom((get) => {
|
|
|
175
187
|
ChatSearchTurn.productList,
|
|
176
188
|
searchFilterConfig,
|
|
177
189
|
selectedFilterOptions,
|
|
178
|
-
additiveDynamicFilters
|
|
190
|
+
additiveDynamicFilters
|
|
179
191
|
);
|
|
180
192
|
|
|
181
|
-
const filteredAndSortedProducts = ProductSorter.sort(
|
|
193
|
+
const filteredAndSortedProducts = ProductSorter.sort(
|
|
194
|
+
filteredProducts,
|
|
195
|
+
productSorting
|
|
196
|
+
);
|
|
182
197
|
|
|
183
198
|
return {
|
|
184
199
|
...searchMap[chatSearchId],
|
|
@@ -204,7 +219,7 @@ export const chatSearchFiltersAtom = atom((get) => {
|
|
|
204
219
|
return ProductFilters.getFiltersForProducts(
|
|
205
220
|
products,
|
|
206
221
|
searchFilterConfig,
|
|
207
|
-
selectedFilterOptions
|
|
222
|
+
selectedFilterOptions
|
|
208
223
|
);
|
|
209
224
|
}
|
|
210
225
|
return [];
|
|
@@ -217,16 +232,16 @@ export const chatSearchFiltersAtom = atom((get) => {
|
|
|
217
232
|
|
|
218
233
|
export const setSearchParams = (query: string) => {
|
|
219
234
|
const url = new URL(window.location.href);
|
|
220
|
-
url.searchParams.set(
|
|
221
|
-
url.searchParams.set(
|
|
222
|
-
window.history.pushState({},
|
|
235
|
+
url.searchParams.set("es", "true");
|
|
236
|
+
url.searchParams.set("esq", query);
|
|
237
|
+
window.history.pushState({}, "", url);
|
|
223
238
|
};
|
|
224
239
|
|
|
225
240
|
export const getSearchParamsAtom = atom(() => {
|
|
226
241
|
const params = new URLSearchParams(window.location.search);
|
|
227
242
|
return {
|
|
228
|
-
es: params.get(
|
|
229
|
-
esq: params.get(
|
|
243
|
+
es: params.get("es"),
|
|
244
|
+
esq: params.get("esq"),
|
|
230
245
|
};
|
|
231
246
|
});
|
|
232
247
|
|
|
@@ -234,13 +249,13 @@ export const initiateChatSearchAtom = atom(null, (_, set, query: string) => {
|
|
|
234
249
|
set(chatSearchIsLoadingAtom, true);
|
|
235
250
|
// Update URL and manually trigger state change (since pushState doesn't trigger popstate)
|
|
236
251
|
const url = new URL(window.location.href);
|
|
237
|
-
url.searchParams.set(
|
|
238
|
-
url.searchParams.set(
|
|
239
|
-
window.history.pushState({},
|
|
252
|
+
url.searchParams.set("es", "true");
|
|
253
|
+
url.searchParams.set("esq", query);
|
|
254
|
+
window.history.pushState({}, "", url);
|
|
240
255
|
|
|
241
256
|
// Manually trigger page variant re-evaluation by dispatching a popstate event
|
|
242
257
|
// This ensures the page variant system detects the URL change and mounts search results
|
|
243
|
-
window.dispatchEvent(new PopStateEvent(
|
|
258
|
+
window.dispatchEvent(new PopStateEvent("popstate", { state: {} }));
|
|
244
259
|
|
|
245
260
|
set(chatSearchParamsAtom, { id: null, query });
|
|
246
261
|
set(handleSearchAtom, {
|
|
@@ -256,38 +271,41 @@ export const initiateChatSearchAtom = atom(null, (_, set, query: string) => {
|
|
|
256
271
|
});
|
|
257
272
|
});
|
|
258
273
|
|
|
259
|
-
export const handleSearchResultsAtom = atom(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
274
|
+
export const handleSearchResultsAtom = atom(
|
|
275
|
+
null,
|
|
276
|
+
(get, set, message: Message | undefined) => {
|
|
277
|
+
if (!message || message.type !== MessageType.ProductSearch) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
263
280
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
281
|
+
const { productCount, generatedQuery } = message.metadata;
|
|
282
|
+
if (productCount !== 0) {
|
|
283
|
+
// Clear the filter options when we get new products
|
|
284
|
+
set(selectedFilterOptionsAtom, []);
|
|
285
|
+
// TODO: Should we still do any of these things?
|
|
286
|
+
set(chatSearchStateAtom, "product-page");
|
|
287
|
+
const currentSearchParams = get(chatSearchParamsAtom);
|
|
288
|
+
const url = new URL(window.location.href);
|
|
289
|
+
url.searchParams.set("es", "true");
|
|
290
|
+
url.searchParams.set("esq", generatedQuery);
|
|
291
|
+
url.searchParams.set("esi", message.id);
|
|
292
|
+
window.history.pushState({}, "", url);
|
|
293
|
+
if (currentSearchParams.id === null) {
|
|
294
|
+
// If the id is null, we need to replace the state
|
|
295
|
+
window.history.replaceState(null, "", url);
|
|
296
|
+
} else {
|
|
297
|
+
// If the query is different, we need to push a new state
|
|
298
|
+
window.history.pushState(null, "", url);
|
|
299
|
+
}
|
|
300
|
+
set(chatSearchParamsAtom, { id: message.id, query: generatedQuery });
|
|
282
301
|
}
|
|
283
|
-
set(chatSearchParamsAtom, { id: message.id, query: generatedQuery });
|
|
284
302
|
}
|
|
285
|
-
|
|
303
|
+
);
|
|
286
304
|
|
|
287
305
|
export const setChatSearchParamsAtom = atom(null, (_, set, query: string) => {
|
|
288
306
|
const url = new URL(window.location.href);
|
|
289
|
-
url.searchParams.set(
|
|
290
|
-
url.searchParams.set(
|
|
291
|
-
window.history.pushState({},
|
|
307
|
+
url.searchParams.set("es", "true");
|
|
308
|
+
url.searchParams.set("esq", query);
|
|
309
|
+
window.history.pushState({}, "", url);
|
|
292
310
|
set(chatSearchParamsAtom, { id: null, query });
|
|
293
311
|
});
|
|
@@ -421,6 +421,9 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
421
421
|
`[spiffy-ai] initializeWidget is_currently_streaming=${responseStreaming} is_initialized=${widgetInitialized}`
|
|
422
422
|
);
|
|
423
423
|
// on mount, try to get the responses from an active session if one exists
|
|
424
|
+
if (!orgId) {
|
|
425
|
+
throw new Error("orgId is not available");
|
|
426
|
+
}
|
|
424
427
|
const { messages: existingMessages, userEvents } =
|
|
425
428
|
await CommerceApiClient.getResponses(orgId, chatId, userId);
|
|
426
429
|
setMessages([...existingMessages]);
|
|
@@ -455,7 +458,7 @@ const ChatContextProvider = ({ children }: { children: ReactNode }) => {
|
|
|
455
458
|
|
|
456
459
|
const onFocus = useCallback(async () => {
|
|
457
460
|
try {
|
|
458
|
-
if (!responseStreaming && !suggestionsLoading) {
|
|
461
|
+
if (!responseStreaming && !suggestionsLoading && orgId) {
|
|
459
462
|
const { messages: existingMessages } =
|
|
460
463
|
await CommerceApiClient.getResponses(orgId, chatId, userId);
|
|
461
464
|
|