@envive-ai/react-hooks 0.2.6-alpha-7 → 0.2.6-alpha-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AmplitudeOperations-DjqOM3uE.js → AmplitudeOperations-D2r56Ptr.js} +2 -2
- package/dist/{AmplitudeOperations-DbUiR0N_.cjs → AmplitudeOperations-SkndCrhj.cjs} +2 -2
- package/dist/{NewOrgConfig-C_1T1iOt.js → NewOrgConfig-C9aQqGsb.js} +2 -2
- package/dist/{NewOrgConfig-D2Kvqa1z.cjs → NewOrgConfig-CHkHRqHx.cjs} +2 -2
- package/dist/{TrackComponentVisibleEvent-BxOhr9Da.js → TrackComponentVisibleEvent-BIGvzk4f.js} +2 -2
- package/dist/{TrackComponentVisibleEvent-CDbecFPM.cjs → TrackComponentVisibleEvent-DjZUt7LR.cjs} +2 -2
- package/dist/amplitudeContext-B3DsV6IO.cjs +248 -0
- package/dist/amplitudeContext-S3JYCxr4.js +232 -0
- package/dist/{app-Bs2KxG_8.js → app-BT3g-mDp.js} +5 -5
- package/dist/{app-DSnDDqcW.cjs → app-DxwdFQlv.cjs} +5 -5
- package/dist/application/utils/index.cjs +4 -4
- package/dist/application/utils/index.d.cts +2 -2
- package/dist/application/utils/index.js +4 -4
- package/dist/{atomStore-CfzCqWB9.js → atomStore-BuopbV9k.js} +1 -1
- package/dist/{atomStore-BQVO5haU.cjs → atomStore-CZKe3itM.cjs} +1 -1
- package/dist/atoms/app/index.cjs +9 -9
- package/dist/atoms/app/index.d.cts +7 -7
- package/dist/atoms/app/index.d.ts +7 -7
- package/dist/atoms/app/index.js +9 -9
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.d.ts +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +10 -10
- package/dist/atoms/chat/index.d.cts +32 -32
- package/dist/atoms/chat/index.d.ts +32 -32
- package/dist/atoms/chat/index.js +10 -10
- package/dist/atoms/globalSearch/index.d.cts +6 -6
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/org/index.cjs +2 -2
- package/dist/atoms/org/index.d.cts +15 -15
- package/dist/atoms/org/index.d.ts +16 -16
- package/dist/atoms/org/index.js +2 -2
- package/dist/atoms/search/index.cjs +3 -3
- package/dist/atoms/search/index.d.cts +15 -15
- package/dist/atoms/search/index.d.ts +14 -14
- package/dist/atoms/search/index.js +3 -3
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/cdnContext-i5iYA8ig.cjs +53 -0
- package/dist/cdnContext-td-gAam0.js +38 -0
- package/dist/{chat-EJbfGWRr.js → chat-ClvJ9xEj.js} +1 -1
- package/dist/{chat-CJ9D8n7g.cjs → chat-DCGriB7h.cjs} +1 -1
- package/dist/{chat-C5afTKUY.js → chat-ZaY3KY-R.js} +3 -3
- package/dist/{chat-CCjM6fS_.cjs → chat-rhEjVfrd.cjs} +3 -3
- package/dist/{common-CuwWqIJ1.cjs → common-DQPvV_S_.cjs} +1 -1
- package/dist/{common-Df2bwzd2.js → common-c_4eX0qn.js} +1 -1
- package/dist/{components-QGCWJ26c.js → components-CDpaMUjK.js} +1 -1
- package/dist/{components-BCfFLf9X.cjs → components-DKwVHIjq.cjs} +1 -1
- package/dist/config/index.cjs +4 -4
- package/dist/config/index.js +4 -4
- package/dist/config/locators/components/chat/index.cjs +1 -1
- package/dist/config/locators/components/chat/index.js +1 -1
- package/dist/config/locators/components/common/index.cjs +1 -1
- package/dist/config/locators/components/common/index.js +1 -1
- package/dist/config/locators/components/index.cjs +1 -1
- package/dist/config/locators/components/index.js +1 -1
- package/dist/config/locators/index.cjs +4 -4
- package/dist/config/locators/index.js +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +12 -12
- package/dist/contexts/amplitudeContext/index.d.cts +1 -1
- package/dist/contexts/amplitudeContext/index.js +12 -12
- package/dist/contexts/cdnContext/index.cjs +2 -2
- package/dist/contexts/cdnContext/index.d.cts +1 -1
- package/dist/contexts/cdnContext/index.d.ts +1 -1
- package/dist/contexts/cdnContext/index.js +2 -2
- package/dist/contexts/enviveConfigContext/index.cjs +2 -2
- package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
- package/dist/contexts/enviveConfigContext/index.js +2 -2
- package/dist/contexts/enviveCssContext/index.cjs +6 -6
- package/dist/contexts/enviveCssContext/index.js +6 -6
- package/dist/contexts/featureFlagContext/index.cjs +2 -2
- package/dist/contexts/featureFlagContext/index.js +2 -2
- package/dist/contexts/graphqlContext/index.cjs +2 -2
- package/dist/contexts/graphqlContext/index.js +2 -2
- package/dist/contexts/localStorageContext/index.d.cts +1 -1
- package/dist/contexts/newOrgConfigContext/index.cjs +5 -5
- package/dist/contexts/newOrgConfigContext/index.js +5 -5
- package/dist/contexts/searchContext/index.cjs +14 -14
- package/dist/contexts/searchContext/index.js +14 -14
- package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
- package/dist/contexts/shopifyUrlContext/index.d.cts +1 -1
- package/dist/contexts/shopifyUrlContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +2 -2
- package/dist/contexts/systemSettingsContext/index.d.cts +1 -1
- package/dist/contexts/systemSettingsContext/index.d.ts +2 -2
- package/dist/contexts/systemSettingsContext/index.js +2 -2
- package/dist/contexts/userIdentityContext/index.cjs +9 -9
- package/dist/contexts/userIdentityContext/index.js +9 -9
- package/dist/{domObserver-DNeeSh1F.js → domObserver-CVhsCSkS.js} +1 -1
- package/dist/{domObserver-C2oQO8vi.cjs → domObserver-LCBj1xw4.cjs} +1 -1
- package/dist/{enviveConfig-Dp80h9yu.cjs → enviveConfig-CQ_8mT-g.cjs} +1 -1
- package/dist/{enviveConfig-Ciq4ASoV.js → enviveConfig-Cwlp7-Qz.js} +1 -1
- package/dist/{enviveConfigContext-CCjJUmwp.js → enviveConfigContext-BZbGEgOW.js} +2 -2
- package/dist/{enviveConfigContext-DoYP8KSw.cjs → enviveConfigContext-BinpxTCy.cjs} +2 -2
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.js +1 -1
- package/dist/{events-DBin1Z7o.cjs → events-CgFGtanE.cjs} +1 -1
- package/dist/{events-CXiS1aTc.js → events-WOOrnUAx.js} +1 -1
- package/dist/exceptions/index.d.ts +1 -1
- package/dist/{graphqlContext-ChXlE8Ul.cjs → graphqlContext-B8wuRZcp.cjs} +2 -2
- package/dist/{graphqlContext-0cg9fEUw.js → graphqlContext-CpHMbKoX.js} +2 -2
- package/dist/hooks/AmplitudeOperations/index.cjs +13 -13
- package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
- package/dist/hooks/AmplitudeOperations/index.js +13 -13
- package/dist/hooks/AppDetails/index.cjs +12 -12
- package/dist/hooks/AppDetails/index.d.cts +1 -1
- package/dist/hooks/AppDetails/index.js +12 -12
- package/dist/hooks/BlockBackButton/index.d.cts +1 -1
- package/dist/hooks/CdnOperations/index.cjs +2 -2
- package/dist/hooks/CdnOperations/index.d.ts +1 -1
- package/dist/hooks/CdnOperations/index.js +2 -2
- package/dist/hooks/ChatToggle/index.cjs +13 -13
- package/dist/hooks/ChatToggle/index.d.cts +1 -1
- package/dist/hooks/ChatToggle/index.js +13 -13
- package/dist/hooks/ChatToggleAnalytics/index.cjs +13 -13
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
- package/dist/hooks/ChatToggleAnalytics/index.js +13 -13
- package/dist/hooks/Debounce/index.d.cts +1 -1
- package/dist/hooks/ElementObserver/index.cjs +1 -1
- package/dist/hooks/ElementObserver/index.js +1 -1
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GraphQLConfig/index.cjs +3 -3
- package/dist/hooks/GraphQLConfig/index.d.cts +1 -1
- package/dist/hooks/GraphQLConfig/index.js +3 -3
- package/dist/hooks/IdentifyUser/index.cjs +9 -9
- package/dist/hooks/IdentifyUser/index.d.cts +1 -1
- package/dist/hooks/IdentifyUser/index.js +9 -9
- package/dist/hooks/ImageResolver/index.cjs +1 -1
- package/dist/hooks/ImageResolver/index.d.cts +1 -1
- package/dist/hooks/ImageResolver/index.js +1 -1
- package/dist/hooks/LocalStorageOperations/index.d.cts +1 -1
- package/dist/hooks/MessageFilter/index.d.cts +1 -1
- package/dist/hooks/MessageScrollObserver/index.d.cts +1 -1
- package/dist/hooks/NewOrgConfig/index.cjs +6 -6
- package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
- package/dist/hooks/NewOrgConfig/index.d.ts +2 -2
- package/dist/hooks/NewOrgConfig/index.js +6 -6
- package/dist/hooks/Search/index.cjs +15 -15
- package/dist/hooks/Search/index.js +15 -15
- package/dist/hooks/SearchOperations/index.cjs +14 -14
- package/dist/hooks/SearchOperations/index.js +14 -14
- package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
- package/dist/hooks/SystemSettingsContext/index.cjs +2 -2
- package/dist/hooks/SystemSettingsContext/index.d.cts +3 -3
- package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
- package/dist/hooks/SystemSettingsContext/index.js +2 -2
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +13 -13
- package/dist/hooks/TrackComponentVisibleEvent/index.js +13 -13
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +12 -12
- package/dist/hooks/UpdateAnalyticsProps/index.js +12 -12
- package/dist/hooks/utils.cjs +1 -1
- package/dist/hooks/utils.d.cts +1 -1
- package/dist/hooks/utils.js +1 -1
- package/dist/index-CMZcE7pk.d.cts +1 -1
- package/dist/index-ChiZg0yw.d.cts +1 -1
- package/dist/index-CsmO1rDH.d.ts +1 -1
- package/dist/index-DtzPIcQp.d.ts +1 -1
- package/dist/index-bEjLKG_Q.d.ts +1 -1
- package/dist/index-mv7KvWDq.d.ts +1 -1
- package/dist/{locators-C2fWd-74.js → locators-BMQGmGLq.js} +1 -1
- package/dist/{locators-Cx3q6Z_h.cjs → locators-DxYdak1F.cjs} +1 -1
- package/dist/{newOrgConfigAtom-BuQE_zPK.js → newOrgConfigAtom-C8h3w_Ji.js} +1 -1
- package/dist/{newOrgConfigAtom-rrYHmp1b.cjs → newOrgConfigAtom-CDttTiuu.cjs} +1 -1
- package/dist/{newOrgConfigContext-d3RHl430.cjs → newOrgConfigContext-Brsggue9.cjs} +4 -4
- package/dist/{newOrgConfigContext-D-gU5ppl.js → newOrgConfigContext-Dt_W-wlK.js} +4 -4
- package/dist/{org-CIFgIcO4.cjs → org-BNs_maoW.cjs} +1 -1
- package/dist/{org-15F128Ah.js → org-CScQqL4k.js} +1 -1
- package/dist/{search-Ch6LKNh4.cjs → search-CWkDtqQV.cjs} +2 -2
- package/dist/{search--80x6CfL.js → search-OWKKaQQj.js} +2 -2
- package/dist/{searchContext-BkPoTq1o.js → searchContext-B-rEZixl.js} +4 -4
- package/dist/{searchContext-B0qEUoKb.cjs → searchContext-JCUBg-lA.cjs} +4 -4
- package/dist/{shopifyUrlContext-Bw1kAZ2P.cjs → shopifyUrlContext-COc1eDR_.cjs} +2 -2
- package/dist/{shopifyUrlContext-DnJiUmMA.js → shopifyUrlContext-CToAt_98.js} +2 -2
- package/dist/{systemSettingsContext-DPdDfVhj.js → systemSettingsContext-D9iNGz5v.js} +2 -2
- package/dist/{systemSettingsContext-068vQuP2.cjs → systemSettingsContext-DdV7Yte8.cjs} +2 -2
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +1 -1
- package/dist/{types-B8HZYWV3.cjs → types-1iJ_FnQQ.cjs} +1 -1
- package/dist/{types-y3mhxOUA.js → types-D5du68Vp.js} +1 -1
- package/dist/{urlsParser-bb8ciRFg.cjs → urlsParser-Dax4iVNC.cjs} +1 -1
- package/dist/{urlsParser-v_1DKvyf.js → urlsParser-NAp2LwWP.js} +1 -1
- package/dist/{useAppDetails-eP2hBuid.cjs → useAppDetails-D3T6kJY_.cjs} +4 -4
- package/dist/{useAppDetails-BPXln8UE.js → useAppDetails-xPVs6fW7.js} +4 -4
- package/dist/{useGraphQLConfig-v9veUbvJ.cjs → useGraphQLConfig-B1DaVvFx.cjs} +2 -2
- package/dist/{useGraphQLConfig-Btszi6cG.js → useGraphQLConfig-BtPxjtxw.js} +2 -2
- package/dist/{utils-D_nGHczN.js → utils-BZT_oZ3n.js} +1 -1
- package/dist/{utils-SjlIHajO.cjs → utils-D3MjNkd3.cjs} +2 -2
- package/dist/{utils-CWzuvlOR.js → utils-DMwh3QbT.js} +2 -2
- package/dist/{utils-CJk5iwQI.cjs → utils-qtHPLFby.cjs} +1 -1
- package/package.json +1 -1
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +11 -3
- package/src/contexts/cdnContext/cdnContext.tsx +11 -9
- package/dist/amplitudeContext-BWmXliMI.cjs +0 -243
- package/dist/amplitudeContext-BjMlg5RV.js +0 -227
- package/dist/cdnContext-CJ2BNLAD.js +0 -38
- package/dist/cdnContext-lkC-AE6A.cjs +0 -53
- package/dist/src/application/commerce-api.js +0 -408
- package/dist/src/application/logging/logger.js +0 -16
- package/dist/src/application/models/graphql/index.js +0 -3
- package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +0 -13
- package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +0 -13
- package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +0 -10
- package/dist/src/application/models/guards/api/index.js +0 -12
- package/dist/src/application/models/guards/api/isApiFormResponse.js +0 -59
- package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +0 -22
- package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +0 -91
- package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +0 -188
- package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +0 -115
- package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +0 -16
- package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +0 -26
- package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +0 -15
- package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +0 -65
- package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +0 -15
- package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +0 -10
- package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +0 -4
- package/dist/src/application/models/guards/api/isApiResponse.js +0 -33
- package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +0 -22
- package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +0 -23
- package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +0 -20
- package/dist/src/application/models/guards/api/isApiSuggestion.js +0 -24
- package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +0 -4
- package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +0 -4
- package/dist/src/application/models/guards/api/isApiUserEvent.js +0 -18
- package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +0 -41
- package/dist/src/application/models/guards/isBaseEcommerceEvent.js +0 -14
- package/dist/src/application/models/guards/isGA4EcommerceEvent.js +0 -14
- package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +0 -14
- package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +0 -4
- package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +0 -1
- package/dist/src/application/models/guards/isVariantInfo.js +0 -28
- package/dist/src/application/models/guards/utils.js +0 -34
- package/dist/src/application/models/index.js +0 -34
- package/dist/src/application/models/utils/snakeToCamelTransformer.js +0 -71
- package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +0 -65
- package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +0 -9
- package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +0 -420
- package/dist/src/application/models/validators/validateGraphQLOrgId.js +0 -6
- package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +0 -9
- package/dist/src/application/models/validators/validateOrgConfigResults.js +0 -44
- package/dist/src/application/models/validators/validateOrganizationConfig.js +0 -34
- package/dist/src/application/models/validators/validateResponse.js +0 -173
- package/dist/src/application/models/validators/validateSuggestion.js +0 -13
- package/dist/src/application/models/validators/validateUserEvent.js +0 -91
- package/dist/src/application/utils/analyticsUtils.js +0 -95
- package/dist/src/application/utils/coreContextToApiContext.js +0 -8
- package/dist/src/application/utils/coreUserEventToApiUserEvent.js +0 -90
- package/dist/src/application/utils/divideArray.js +0 -7
- package/dist/src/application/utils/domObserver.js +0 -85
- package/dist/src/application/utils/elementObserver.js +0 -186
- package/dist/src/application/utils/imageFilter.js +0 -11
- package/dist/src/application/utils/index.js +0 -21
- package/dist/src/application/utils/merchantUtils.js +0 -15
- package/dist/src/application/utils/messageFromFormSubmittedEvent.js +0 -19
- package/dist/src/application/utils/messageFromQueryEvent.js +0 -35
- package/dist/src/application/utils/messageFromResponse.js +0 -123
- package/dist/src/application/utils/messageFromSuggestionEvent.js +0 -27
- package/dist/src/application/utils/mouseEventTypes.js +0 -1
- package/dist/src/application/utils/mutationHelper.js +0 -33
- package/dist/src/application/utils/nextMessageRequestToApiRequest.js +0 -29
- package/dist/src/application/utils/nodeSelector.js +0 -101
- package/dist/src/application/utils/overrides.js +0 -144
- package/dist/src/application/utils/stringUtils.js +0 -47
- package/dist/src/application/utils/supportedEventRequestToApiRequest.js +0 -7
- package/dist/src/application/utils/urlsParser.js +0 -33
- package/dist/src/application/utils/validation.js +0 -5
- package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +0 -4
- package/dist/src/atoms/app/index.js +0 -23
- package/dist/src/atoms/app/variant.js +0 -102
- package/dist/src/atoms/atomStore/atomStore.js +0 -28
- package/dist/src/atoms/atomStore/index.js +0 -1
- package/dist/src/atoms/chat/chatState.js +0 -32
- package/dist/src/atoms/chat/form.js +0 -16
- package/dist/src/atoms/chat/index.js +0 -23
- package/dist/src/atoms/chat/lastMessage.js +0 -10
- package/dist/src/atoms/chat/messageQueue.js +0 -68
- package/dist/src/atoms/chat/performanceMetrics.js +0 -70
- package/dist/src/atoms/chat/renderedWidgetRefs.js +0 -24
- package/dist/src/atoms/chat/replies.js +0 -42
- package/dist/src/atoms/chat/suggestions.js +0 -29
- package/dist/src/atoms/envive/enviveConfig.js +0 -67
- package/dist/src/atoms/globalSearch/globalSearch.js +0 -8
- package/dist/src/atoms/globalSearch/index.js +0 -1
- package/dist/src/atoms/org/customerService.js +0 -6
- package/dist/src/atoms/org/graphqlConfig.js +0 -8
- package/dist/src/atoms/org/index.js +0 -4
- package/dist/src/atoms/org/newOrgConfigAtom.js +0 -2
- package/dist/src/atoms/org/orgAnalyticsConfig.js +0 -8
- package/dist/src/atoms/search/index.js +0 -1
- package/dist/src/atoms/search/productFilters.js +0 -163
- package/dist/src/atoms/search/productRetrievalAPI.js +0 -50
- package/dist/src/atoms/search/productRetrievalAdapter.js +0 -14
- package/dist/src/atoms/search/productSorter.js +0 -13
- package/dist/src/atoms/search/searchAPI.js +0 -140
- package/dist/src/atoms/search/searchServiceAdapter.js +0 -14
- package/dist/src/atoms/search/utils.js +0 -15
- package/dist/src/config/index.js +0 -1
- package/dist/src/config/locators/components/chat/entrypoints.js +0 -10
- package/dist/src/config/locators/components/chat/index.js +0 -21
- package/dist/src/config/locators/components/chat/preview.js +0 -11
- package/dist/src/config/locators/components/chat/variants/index.js +0 -12
- package/dist/src/config/locators/components/common/buttons.js +0 -6
- package/dist/src/config/locators/components/common/cards.js +0 -17
- package/dist/src/config/locators/components/common/index.js +0 -4
- package/dist/src/config/locators/components/common/links.js +0 -1
- package/dist/src/config/locators/components/common/tables.js +0 -1
- package/dist/src/config/locators/components/floating-button.js +0 -2
- package/dist/src/config/locators/components/index.js +0 -3
- package/dist/src/config/locators/components/report-issue.js +0 -13
- package/dist/src/config/locators/components/search/index.js +0 -5
- package/dist/src/config/locators/components/shadow-dom.js +0 -1
- package/dist/src/config/locators/embedded.js +0 -20
- package/dist/src/config/locators/index.js +0 -4
- package/dist/src/contexts/amplitudeContext/amplitudeContext.js +0 -271
- package/dist/src/contexts/amplitudeContext/index.js +0 -1
- package/dist/src/contexts/cdnContext/cdnContext.js +0 -28
- package/dist/src/contexts/cdnContext/index.js +0 -1
- package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +0 -37
- package/dist/src/contexts/enviveConfigContext/index.js +0 -1
- package/dist/src/contexts/enviveCssContext/enviveCssContext.js +0 -31
- package/dist/src/contexts/enviveCssContext/index.js +0 -1
- package/dist/src/contexts/featureFlagContext/featureFlagContext.js +0 -109
- package/dist/src/contexts/featureFlagContext/index.js +0 -1
- package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +0 -47
- package/dist/src/contexts/featureFlagServiceContext/index.js +0 -1
- package/dist/src/contexts/graphqlContext/graphqlContext.js +0 -87
- package/dist/src/contexts/graphqlContext/index.js +0 -1
- package/dist/src/contexts/localStorageContext/index.js +0 -1
- package/dist/src/contexts/localStorageContext/localStorageContext.js +0 -95
- package/dist/src/contexts/newOrgConfigContext/index.js +0 -1
- package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +0 -33
- package/dist/src/contexts/searchContext/index.js +0 -1
- package/dist/src/contexts/searchContext/searchContext.js +0 -131
- package/dist/src/contexts/sessionStorageContext/index.js +0 -1
- package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +0 -43
- package/dist/src/contexts/shopifyUrlContext/index.js +0 -1
- package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +0 -62
- package/dist/src/contexts/systemSettingsContext/index.js +0 -1
- package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +0 -29
- package/dist/src/contexts/userIdentityContext/index.js +0 -1
- package/dist/src/contexts/userIdentityContext/userIdentityContext.js +0 -118
- package/dist/src/events/index.js +0 -51
- package/dist/src/events/registerAnalyticsListeners.js +0 -32
- package/dist/src/exceptions/index.js +0 -2
- package/dist/src/exceptions/sessionExceptions.js +0 -6
- package/dist/src/exceptions/unsupportedProductExceptions.js +0 -6
- package/dist/src/hooks/AmplitudeOperations/index.js +0 -1
- package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +0 -24
- package/dist/src/hooks/AppDetails/index.js +0 -1
- package/dist/src/hooks/AppDetails/useAppDetails.js +0 -26
- package/dist/src/hooks/BlockBackButton/index.js +0 -1
- package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +0 -23
- package/dist/src/hooks/CdnOperations/index.js +0 -1
- package/dist/src/hooks/CdnOperations/useCdnOperations.js +0 -13
- package/dist/src/hooks/ChatToggle/index.js +0 -1
- package/dist/src/hooks/ChatToggle/useChatToggle.js +0 -50
- package/dist/src/hooks/ChatToggleAnalytics/index.js +0 -1
- package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +0 -11
- package/dist/src/hooks/CustomerSupportHandoff/index.js +0 -1
- package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +0 -32
- package/dist/src/hooks/Debounce/index.js +0 -1
- package/dist/src/hooks/Debounce/useDebounce.js +0 -13
- package/dist/src/hooks/ElementObserver/index.js +0 -1
- package/dist/src/hooks/ElementObserver/useElementObserver.js +0 -208
- package/dist/src/hooks/GrabAndScroll/index.js +0 -1
- package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +0 -105
- package/dist/src/hooks/GraphQLConfig/index.js +0 -1
- package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +0 -54
- package/dist/src/hooks/IdentifyUser/index.js +0 -1
- package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +0 -28
- package/dist/src/hooks/ImageResolver/index.js +0 -1
- package/dist/src/hooks/ImageResolver/useImageResolver.js +0 -45
- package/dist/src/hooks/Intersection/index.js +0 -1
- package/dist/src/hooks/Intersection/useIntersection.js +0 -20
- package/dist/src/hooks/IsSmallScreen/index.js +0 -1
- package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +0 -16
- package/dist/src/hooks/LocalStorageOperations/index.js +0 -1
- package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +0 -64
- package/dist/src/hooks/MessageFilter/index.js +0 -1
- package/dist/src/hooks/MessageFilter/useMessageFilter.js +0 -37
- package/dist/src/hooks/MessageScrollObserver/index.js +0 -1
- package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +0 -35
- package/dist/src/hooks/NewOrgConfig/index.js +0 -1
- package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +0 -5
- package/dist/src/hooks/Search/index.js +0 -1
- package/dist/src/hooks/Search/useRecommendedProducts.js +0 -35
- package/dist/src/hooks/Search/useSearch.js +0 -224
- package/dist/src/hooks/Search/useSearchInput.js +0 -192
- package/dist/src/hooks/SearchOperations/index.js +0 -1
- package/dist/src/hooks/SearchOperations/useSearchOperations.js +0 -78
- package/dist/src/hooks/SessionStorageOperations/index.js +0 -1
- package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +0 -20
- package/dist/src/hooks/ShopifyUrlOperations/index.js +0 -1
- package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +0 -34
- package/dist/src/hooks/SnapCalculator/index.js +0 -1
- package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +0 -22
- package/dist/src/hooks/SystemSettingsContext/index.js +0 -1
- package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +0 -9
- package/dist/src/hooks/TrackComponentVisibleEvent/index.js +0 -1
- package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +0 -45
- package/dist/src/hooks/UpdateAnalyticsProps/index.js +0 -1
- package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +0 -43
- package/dist/src/hooks/utils.js +0 -116
- package/dist/src/interceptors/index.js +0 -1
- package/dist/src/interceptors/useMessageInterceptor.js +0 -24
- package/dist/src/types/ApiResponse.js +0 -1
- package/dist/src/types/FilterAttribute.js +0 -3
- package/dist/src/types/Message.js +0 -24
- package/dist/src/types/Suggestion.js +0 -3
- package/dist/src/types/index.js +0 -4
- package/dist/src/util/colorVar.js +0 -3
- package/dist/src/util/configVersion.js +0 -4
- package/dist/src/util/domInsertion.js +0 -16
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useMemo } from "react";
|
|
3
|
-
import { FeatureGates } from "@envive-ai/types";
|
|
4
|
-
import Logger from "src/application/logging/logger";
|
|
5
|
-
// This is the class that was previously implicitly used or defined elsewhere
|
|
6
|
-
export class FeatureFlagService {
|
|
7
|
-
constructor(featureGates) {
|
|
8
|
-
this.isFeatureGateEnabled = (featureGate) => {
|
|
9
|
-
const gateValue = this.featureGates.find((gate) => gate.name === featureGate);
|
|
10
|
-
// TODO: Add logic for overrides (query params, window, stored) if needed, similar to the old FeatureFlagContext.tsx
|
|
11
|
-
// For now, direct value from config is used.
|
|
12
|
-
if (gateValue == null || gateValue.value == null) {
|
|
13
|
-
Logger.logDebug(`[spiffy-ai] isFeatureGateEnabled featureGate:${featureGate} value is undefined - returning false`);
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return gateValue.value;
|
|
17
|
-
};
|
|
18
|
-
this.isClientSessionEnabled = () => {
|
|
19
|
-
const isEnabled = this.featureGates.filter((gate) => gate.name === FeatureGates.IsClientSessionEnabled &&
|
|
20
|
-
gate.value === true).length > 0;
|
|
21
|
-
return isEnabled;
|
|
22
|
-
};
|
|
23
|
-
this.getFeatureFlags = () => {
|
|
24
|
-
return Object.fromEntries(Object.values(FeatureGates).map((featureGate) => [
|
|
25
|
-
featureGate,
|
|
26
|
-
this.isFeatureGateEnabled(featureGate),
|
|
27
|
-
]));
|
|
28
|
-
};
|
|
29
|
-
this.featureGates = featureGates;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const FeatureFlagServiceContext = createContext(undefined);
|
|
33
|
-
export const FeatureFlagServiceProvider = ({ featureGates, children }) => {
|
|
34
|
-
const featureFlagService = useMemo(() => new FeatureFlagService(featureGates), [featureGates]);
|
|
35
|
-
const contextValue = useMemo(() => ({
|
|
36
|
-
featureFlagService,
|
|
37
|
-
isFeatureGateEnabled: featureFlagService.isFeatureGateEnabled,
|
|
38
|
-
}), [featureFlagService]);
|
|
39
|
-
return (_jsx(FeatureFlagServiceContext.Provider, { value: contextValue, children: children }));
|
|
40
|
-
};
|
|
41
|
-
export const useFeatureFlagService = () => {
|
|
42
|
-
const context = useContext(FeatureFlagServiceContext);
|
|
43
|
-
if (context === undefined) {
|
|
44
|
-
throw new Error("useFeatureFlagService must be used within a FeatureFlagServiceProvider");
|
|
45
|
-
}
|
|
46
|
-
return context;
|
|
47
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./featureFlagServiceContext";
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useCallback, useMemo } from 'react';
|
|
3
|
-
import { useAtomValue } from 'jotai';
|
|
4
|
-
import { baseUrlAtom, orgLevelApiKeyAtom } from '../../atoms/envive/enviveConfig';
|
|
5
|
-
import { getMerchantOrgIdQuery } from '../../application/models/graphql/queries/getMerchantOrgIdQuery';
|
|
6
|
-
import { validateGraphQLOrgId } from '../../application/models/validators/validateGraphQLOrgId';
|
|
7
|
-
import Logger from '../../application/logging/logger';
|
|
8
|
-
import { transformSnakeToCamel } from '../../application/models';
|
|
9
|
-
import { configVersion } from '../../util/configVersion';
|
|
10
|
-
const GraphQLContext = createContext(null);
|
|
11
|
-
const colorsAndFrontendConfigQuery = () => `
|
|
12
|
-
query ($version: String = "${configVersion()}") {
|
|
13
|
-
me {
|
|
14
|
-
getProductsConfigByVersion(version: $version) {
|
|
15
|
-
frontend { values }
|
|
16
|
-
colors { values }
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
21
|
-
export const GraphQLProvider = ({ children }) => {
|
|
22
|
-
const apiKey = useAtomValue(orgLevelApiKeyAtom);
|
|
23
|
-
const baseUrl = useAtomValue(baseUrlAtom);
|
|
24
|
-
const isReady = Boolean(apiKey && baseUrl);
|
|
25
|
-
const executeQuery = useCallback(async (query, variables) => {
|
|
26
|
-
if (!isReady) {
|
|
27
|
-
throw new Error('GraphQL client not ready - missing apiKey or baseUrl');
|
|
28
|
-
}
|
|
29
|
-
const response = await fetch(`${baseUrl}/v1/graphql`, {
|
|
30
|
-
method: 'POST',
|
|
31
|
-
headers: {
|
|
32
|
-
'Content-Type': 'application/json',
|
|
33
|
-
Authorization: `Bearer ${apiKey}`,
|
|
34
|
-
},
|
|
35
|
-
body: JSON.stringify({ query, variables }),
|
|
36
|
-
});
|
|
37
|
-
if (!response.ok) {
|
|
38
|
-
throw new Error(`GraphQL request failed: ${response.statusText}`);
|
|
39
|
-
}
|
|
40
|
-
const result = await response.json();
|
|
41
|
-
if (result.errors) {
|
|
42
|
-
throw new Error(`GraphQL errors: ${JSON.stringify(result.errors)}`);
|
|
43
|
-
}
|
|
44
|
-
return result.data;
|
|
45
|
-
}, [apiKey, baseUrl, isReady]);
|
|
46
|
-
const getOrgId = useCallback(async () => {
|
|
47
|
-
var _a;
|
|
48
|
-
const response = await executeQuery(getMerchantOrgIdQuery);
|
|
49
|
-
return validateGraphQLOrgId((_a = response.me.org) === null || _a === void 0 ? void 0 : _a.id);
|
|
50
|
-
}, [executeQuery]);
|
|
51
|
-
const getColorsAndFrontendConfig = useCallback(async () => {
|
|
52
|
-
var _a, _b, _c, _d;
|
|
53
|
-
try {
|
|
54
|
-
const query = await colorsAndFrontendConfigQuery();
|
|
55
|
-
if (!query) {
|
|
56
|
-
throw new Error('Colors and frontend config query is not defined');
|
|
57
|
-
}
|
|
58
|
-
const response = await executeQuery(query);
|
|
59
|
-
const colorsConfig = (_b = (_a = response.me.getProductsConfigByVersion) === null || _a === void 0 ? void 0 : _a.colors) === null || _b === void 0 ? void 0 : _b.values;
|
|
60
|
-
const frontendConfig = (_d = (_c = response.me.getProductsConfigByVersion) === null || _c === void 0 ? void 0 : _c.frontend) === null || _d === void 0 ? void 0 : _d.values;
|
|
61
|
-
const transformedColorConfig = transformSnakeToCamel(colorsConfig);
|
|
62
|
-
const transformedFrontendConfig = transformSnakeToCamel(frontendConfig);
|
|
63
|
-
return {
|
|
64
|
-
colorsConfig: transformedColorConfig,
|
|
65
|
-
frontendConfig: transformedFrontendConfig,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
Logger.logError('Error fetching graphql colors and frontend config', err);
|
|
70
|
-
return { colorsConfig: undefined, frontendConfig: undefined };
|
|
71
|
-
}
|
|
72
|
-
}, [executeQuery]);
|
|
73
|
-
const value = useMemo(() => ({
|
|
74
|
-
executeQuery,
|
|
75
|
-
getOrgId,
|
|
76
|
-
getColorsAndFrontendConfig,
|
|
77
|
-
isReady,
|
|
78
|
-
}), [executeQuery, getOrgId, getColorsAndFrontendConfig, isReady]);
|
|
79
|
-
return _jsx(GraphQLContext.Provider, { value: value, children: children });
|
|
80
|
-
};
|
|
81
|
-
export const useGraphQLClient = () => {
|
|
82
|
-
const context = useContext(GraphQLContext);
|
|
83
|
-
if (!context) {
|
|
84
|
-
throw new Error('useGraphQLClient must be used within a GraphQLProvider');
|
|
85
|
-
}
|
|
86
|
-
return context;
|
|
87
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./graphqlContext";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./localStorageContext";
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useCallback, useMemo, useEffect } from 'react';
|
|
3
|
-
import Logger from '../../application/logging/logger';
|
|
4
|
-
import { LocalStorageKeys, } from '@envive-ai/types';
|
|
5
|
-
const LocalStorageContext = createContext(null);
|
|
6
|
-
export const LocalStorageProvider = ({ children }) => {
|
|
7
|
-
const isAvailable = useMemo(() => {
|
|
8
|
-
try {
|
|
9
|
-
return typeof window !== 'undefined' && !!window.localStorage;
|
|
10
|
-
}
|
|
11
|
-
catch {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
}, []);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (!isAvailable) {
|
|
17
|
-
Logger.logError('localStorage is not available', undefined);
|
|
18
|
-
}
|
|
19
|
-
}, [isAvailable]);
|
|
20
|
-
const setItem = useCallback((key, value) => {
|
|
21
|
-
if (!isAvailable)
|
|
22
|
-
return;
|
|
23
|
-
localStorage.setItem(key, value);
|
|
24
|
-
window.dispatchEvent(new StorageEvent('storage', { key, newValue: value }));
|
|
25
|
-
}, [isAvailable]);
|
|
26
|
-
const getItem = useCallback((key) => {
|
|
27
|
-
if (!isAvailable)
|
|
28
|
-
return null;
|
|
29
|
-
return localStorage.getItem(key);
|
|
30
|
-
}, [isAvailable]);
|
|
31
|
-
const setSpiffyOnFeatureFlag = useCallback((value) => {
|
|
32
|
-
if (!isAvailable)
|
|
33
|
-
return;
|
|
34
|
-
if (value === true) {
|
|
35
|
-
localStorage.setItem(LocalStorageKeys.SpiffyOnOverride, 'true');
|
|
36
|
-
}
|
|
37
|
-
else if (value === false) {
|
|
38
|
-
localStorage.setItem(LocalStorageKeys.SpiffyOnOverride, 'false');
|
|
39
|
-
}
|
|
40
|
-
}, [isAvailable]);
|
|
41
|
-
const getSpiffyOnFeatureFlag = useCallback(() => {
|
|
42
|
-
if (!isAvailable)
|
|
43
|
-
return null;
|
|
44
|
-
return localStorage.getItem(LocalStorageKeys.SpiffyOnOverride);
|
|
45
|
-
}, [isAvailable]);
|
|
46
|
-
const listenersCache = useMemo(() => new Map(), []);
|
|
47
|
-
const listenerForKey = useCallback((listener) => {
|
|
48
|
-
if (!listenersCache.has(listener.storageKey)) {
|
|
49
|
-
const handler = (event) => {
|
|
50
|
-
if (event.key !== listener.storageKey) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
Logger.logDebug(`[spiffy-ai] Storage event key=${event.key}, value=`, event.newValue);
|
|
54
|
-
listener.listener(event);
|
|
55
|
-
};
|
|
56
|
-
listenersCache.set(listener.storageKey, handler);
|
|
57
|
-
}
|
|
58
|
-
return listenersCache.get(listener.storageKey);
|
|
59
|
-
}, [listenersCache]);
|
|
60
|
-
const attachListener = useCallback((listener) => {
|
|
61
|
-
if (!isAvailable)
|
|
62
|
-
return;
|
|
63
|
-
window.addEventListener('storage', listenerForKey(listener));
|
|
64
|
-
}, [isAvailable, listenerForKey]);
|
|
65
|
-
const detachListener = useCallback((listener) => {
|
|
66
|
-
if (!isAvailable)
|
|
67
|
-
return;
|
|
68
|
-
window.removeEventListener('storage', listenerForKey(listener));
|
|
69
|
-
}, [isAvailable, listenerForKey]);
|
|
70
|
-
const value = useMemo(() => ({
|
|
71
|
-
setItem,
|
|
72
|
-
getItem,
|
|
73
|
-
setSpiffyOnFeatureFlag,
|
|
74
|
-
getSpiffyOnFeatureFlag,
|
|
75
|
-
attachListener,
|
|
76
|
-
detachListener,
|
|
77
|
-
isAvailable,
|
|
78
|
-
}), [
|
|
79
|
-
setItem,
|
|
80
|
-
getItem,
|
|
81
|
-
setSpiffyOnFeatureFlag,
|
|
82
|
-
getSpiffyOnFeatureFlag,
|
|
83
|
-
attachListener,
|
|
84
|
-
detachListener,
|
|
85
|
-
isAvailable,
|
|
86
|
-
]);
|
|
87
|
-
return _jsx(LocalStorageContext.Provider, { value: value, children: children });
|
|
88
|
-
};
|
|
89
|
-
export const useLocalStorage = () => {
|
|
90
|
-
const context = useContext(LocalStorageContext);
|
|
91
|
-
if (!context) {
|
|
92
|
-
throw new Error('useLocalStorage must be used within a LocalStorageProvider');
|
|
93
|
-
}
|
|
94
|
-
return context;
|
|
95
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./newOrgConfigContext";
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
-
import { useAtomValue, useSetAtom } from 'jotai';
|
|
4
|
-
import { useColorsAndFrontendConfig } from 'src/hooks/GraphQLConfig/useGraphQLConfig';
|
|
5
|
-
import { orgShortNameAtom } from 'src/atoms/envive/enviveConfig';
|
|
6
|
-
import { newOrgConfigAtom } from 'src/atoms/org/newOrgConfigAtom';
|
|
7
|
-
import { FeatureFlagServiceProvider } from '../featureFlagServiceContext';
|
|
8
|
-
const NewOrgConfigContext = createContext(undefined);
|
|
9
|
-
export const NewOrgConfigProvider = ({ children }) => {
|
|
10
|
-
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
11
|
-
const setNewOrgConfig = useSetAtom(newOrgConfigAtom);
|
|
12
|
-
const { data: newConfig, loading, error } = useColorsAndFrontendConfig();
|
|
13
|
-
const contextValue = useMemo(() => {
|
|
14
|
-
if (!orgShortName || loading) {
|
|
15
|
-
return { ...newConfig, loading: true, error: null };
|
|
16
|
-
}
|
|
17
|
-
if (error) {
|
|
18
|
-
return { ...newConfig, loading: false, error };
|
|
19
|
-
}
|
|
20
|
-
setNewOrgConfig(newConfig);
|
|
21
|
-
return { ...newConfig, loading: false, error: null };
|
|
22
|
-
}, [orgShortName, loading, error]);
|
|
23
|
-
// TODO: Provide actual featureGates when available in combinedConfig
|
|
24
|
-
const featureGates = [];
|
|
25
|
-
return (_jsx(NewOrgConfigContext.Provider, { value: contextValue, children: _jsx(FeatureFlagServiceProvider, { featureGates: featureGates, children: children }) }));
|
|
26
|
-
};
|
|
27
|
-
export const useNewOrgConfigContext = () => {
|
|
28
|
-
const context = useContext(NewOrgConfigContext);
|
|
29
|
-
if (context === undefined) {
|
|
30
|
-
throw new Error('useNewOrgConfigContext must be used within a NewOrgConfigProvider');
|
|
31
|
-
}
|
|
32
|
-
return context;
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./searchContext";
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useCallback, useMemo, useEffect } from 'react';
|
|
3
|
-
import { useAtomValue } from 'jotai';
|
|
4
|
-
import { Configuration, ResponseCategory, ResponseError, SearchApi, } from '@spiffy-ai/commerce-api-client';
|
|
5
|
-
import { baseUrlAtom } from '../../atoms/envive/enviveConfig';
|
|
6
|
-
import Logger from '../../application/logging/logger';
|
|
7
|
-
import { SessionRestartRequired, UnsupportedProductException } from '../../exceptions';
|
|
8
|
-
import { useAppDetails } from '../../hooks/AppDetails/useAppDetails';
|
|
9
|
-
import { useEnviveConfig } from '../../contexts/enviveConfigContext/enviveConfigContext';
|
|
10
|
-
import { clearSearchServiceFunction, setSearchServiceFunction, } from '../../atoms/search/searchServiceAdapter';
|
|
11
|
-
const transformProductResponses = (products) => products.map((data) => ({
|
|
12
|
-
id: data.id,
|
|
13
|
-
responseId: data.response_id,
|
|
14
|
-
category: ResponseCategory.Product,
|
|
15
|
-
description: data.description,
|
|
16
|
-
imageUrl: data.image_url,
|
|
17
|
-
imageUrls: data.image_urls,
|
|
18
|
-
title: data.title,
|
|
19
|
-
url: data.url,
|
|
20
|
-
originalPrice: data.original_price,
|
|
21
|
-
salePrice: data.sale_price,
|
|
22
|
-
averageRating: data.average_rating,
|
|
23
|
-
numberReviews: data.number_reviews,
|
|
24
|
-
metadata: data.metadata,
|
|
25
|
-
isForGrid: data.is_for_grid,
|
|
26
|
-
colors: data.colors,
|
|
27
|
-
sizes: data.sizes,
|
|
28
|
-
filters: data.filters,
|
|
29
|
-
}));
|
|
30
|
-
async function errorResponseBody(error) {
|
|
31
|
-
try {
|
|
32
|
-
return await error.response.json();
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
return {};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
async function throwSessionRestartRequiredIf(errorMsg, error) {
|
|
39
|
-
var _a, _b, _c, _d;
|
|
40
|
-
if (!(error instanceof ResponseError)) {
|
|
41
|
-
Logger.logInfo(errorMsg, error);
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
const errorResponse = await errorResponseBody(error);
|
|
45
|
-
if (((_a = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'unsupported product' ||
|
|
46
|
-
((_b = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.app_code) === null || _b === void 0 ? void 0 : _b.toUpperCase()) === 'PRODUCT_NOT_FOUND') {
|
|
47
|
-
throw new UnsupportedProductException();
|
|
48
|
-
}
|
|
49
|
-
else if (((_c = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.app_code) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === 'RESTART_SESSION' ||
|
|
50
|
-
((_d = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.sub_code) === null || _d === void 0 ? void 0 : _d.toUpperCase()) === 'NOT_FOUND') {
|
|
51
|
-
Logger.logInfo('Session does not exist. Re-start session', error, error.response, errorResponse);
|
|
52
|
-
throw new SessionRestartRequired();
|
|
53
|
-
}
|
|
54
|
-
Logger.logInfo(errorMsg, error);
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
const SearchContext = createContext(undefined);
|
|
58
|
-
export const SearchProvider = ({ children }) => {
|
|
59
|
-
const { orgLevelApiKey, publicKey } = useEnviveConfig();
|
|
60
|
-
const apiKey = orgLevelApiKey || publicKey; // Replicate apiKeyAtom logic
|
|
61
|
-
const appDetails = useAppDetails();
|
|
62
|
-
const baseUrl = useAtomValue(baseUrlAtom);
|
|
63
|
-
const isReady = Boolean(apiKey && appDetails && baseUrl);
|
|
64
|
-
const searchApi = useMemo(() => {
|
|
65
|
-
if (!isReady)
|
|
66
|
-
return null;
|
|
67
|
-
const config = new Configuration({
|
|
68
|
-
accessToken: apiKey,
|
|
69
|
-
basePath: baseUrl,
|
|
70
|
-
headers: {
|
|
71
|
-
'Content-Type': 'application/json',
|
|
72
|
-
Accept: 'application/json',
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
return new SearchApi(config);
|
|
76
|
-
}, [apiKey, baseUrl, isReady]);
|
|
77
|
-
const searchProducts = useCallback(async (params) => {
|
|
78
|
-
if (!isReady || !searchApi) {
|
|
79
|
-
throw new Error('SearchService not ready - missing dependencies');
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
const response = await searchApi.v1SearchQueryGet({
|
|
83
|
-
query: params.query,
|
|
84
|
-
limit: params.limit,
|
|
85
|
-
org_id: appDetails.orgId,
|
|
86
|
-
user_id: appDetails.userId,
|
|
87
|
-
});
|
|
88
|
-
const { products, filters, search_response_id: searchResponseId } = response;
|
|
89
|
-
return {
|
|
90
|
-
products: transformProductResponses(products) || [],
|
|
91
|
-
filters: filters || [],
|
|
92
|
-
totalProductCount: (products === null || products === void 0 ? void 0 : products.length) || 0,
|
|
93
|
-
searchResponseId: searchResponseId || '',
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
catch (error) {
|
|
97
|
-
await throwSessionRestartRequiredIf('Failed to search products', error);
|
|
98
|
-
// This part will not be reached if an exception is thrown, but it's required for type safety
|
|
99
|
-
return {
|
|
100
|
-
products: [],
|
|
101
|
-
filters: [],
|
|
102
|
-
totalProductCount: 0,
|
|
103
|
-
searchResponseId: '',
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}, [searchApi, isReady, appDetails]);
|
|
107
|
-
// Register the search function with the adapter for use in atoms
|
|
108
|
-
useEffect(() => {
|
|
109
|
-
if (isReady) {
|
|
110
|
-
setSearchServiceFunction(searchProducts);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
clearSearchServiceFunction();
|
|
114
|
-
}
|
|
115
|
-
return () => {
|
|
116
|
-
clearSearchServiceFunction();
|
|
117
|
-
};
|
|
118
|
-
}, [searchProducts, isReady]);
|
|
119
|
-
const value = useMemo(() => ({
|
|
120
|
-
searchProducts,
|
|
121
|
-
isReady,
|
|
122
|
-
}), [searchProducts, isReady]);
|
|
123
|
-
return _jsx(SearchContext.Provider, { value: value, children: children });
|
|
124
|
-
};
|
|
125
|
-
export const useSearchService = () => {
|
|
126
|
-
const context = useContext(SearchContext);
|
|
127
|
-
if (!context) {
|
|
128
|
-
throw new Error('useSearchService must be used within a SearchProvider');
|
|
129
|
-
}
|
|
130
|
-
return context;
|
|
131
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./sessionStorageContext";
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useCallback, useMemo, useEffect } from 'react';
|
|
3
|
-
import Logger from '../../application/logging/logger';
|
|
4
|
-
const SessionStorageContext = createContext(null);
|
|
5
|
-
export const SessionStorageProvider = ({ children }) => {
|
|
6
|
-
const isAvailable = useMemo(() => {
|
|
7
|
-
try {
|
|
8
|
-
return typeof window !== 'undefined' && !!window.sessionStorage;
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}, []);
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (!isAvailable) {
|
|
16
|
-
Logger.logError('sessionStorage is not available', undefined);
|
|
17
|
-
}
|
|
18
|
-
}, [isAvailable]);
|
|
19
|
-
const setItem = useCallback((key, value) => {
|
|
20
|
-
if (!isAvailable)
|
|
21
|
-
return;
|
|
22
|
-
sessionStorage.setItem(key, value);
|
|
23
|
-
window.dispatchEvent(new StorageEvent('storage', { key, newValue: value }));
|
|
24
|
-
}, [isAvailable]);
|
|
25
|
-
const getItem = useCallback((key) => {
|
|
26
|
-
if (!isAvailable)
|
|
27
|
-
return null;
|
|
28
|
-
return sessionStorage.getItem(key);
|
|
29
|
-
}, [isAvailable]);
|
|
30
|
-
const value = useMemo(() => ({
|
|
31
|
-
setItem,
|
|
32
|
-
getItem,
|
|
33
|
-
isAvailable,
|
|
34
|
-
}), [setItem, getItem, isAvailable]);
|
|
35
|
-
return _jsx(SessionStorageContext.Provider, { value: value, children: children });
|
|
36
|
-
};
|
|
37
|
-
export const useSessionStorage = () => {
|
|
38
|
-
const context = useContext(SessionStorageContext);
|
|
39
|
-
if (!context) {
|
|
40
|
-
throw new Error('useSessionStorage must be used within a SessionStorageProvider');
|
|
41
|
-
}
|
|
42
|
-
return context;
|
|
43
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./shopifyUrlContext";
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useCallback, useContext, useMemo } from 'react';
|
|
3
|
-
import { parseHref } from '../../application/utils/urlsParser';
|
|
4
|
-
const ShopifyUrlContext = createContext(undefined);
|
|
5
|
-
export const ShopifyUrlProvider = ({ children }) => {
|
|
6
|
-
const isReady = true; // No external dependencies, so always ready
|
|
7
|
-
const getTrimmedPathName = useCallback(() => {
|
|
8
|
-
let { pathname } = window.location;
|
|
9
|
-
// strip out the proxy path so local dev still works
|
|
10
|
-
pathname = pathname.replace('/proxy', '');
|
|
11
|
-
// remove trailing hash if it exists
|
|
12
|
-
pathname = pathname.replace(/#.*$/, '');
|
|
13
|
-
// remove trailing /, ie. some URLs can end with '/' like /collections/cast-iron/
|
|
14
|
-
pathname = pathname.replace(/\/$/, '');
|
|
15
|
-
if (pathname === undefined || pathname === null || pathname.length === 0) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
return pathname;
|
|
19
|
-
}, []);
|
|
20
|
-
const getPlpOrPdpId = useCallback((extractor) => {
|
|
21
|
-
var _a, _b;
|
|
22
|
-
if (extractor === 'shopify-product-variant-id') {
|
|
23
|
-
const parsedHref = parseHref(window.location.href);
|
|
24
|
-
const variantId = (_a = parsedHref === null || parsedHref === void 0 ? void 0 : parsedHref.urlSearchParams) === null || _a === void 0 ? void 0 : _a.get('variant');
|
|
25
|
-
if (!variantId) {
|
|
26
|
-
return getPlpOrPdpId('shopify-product-id');
|
|
27
|
-
}
|
|
28
|
-
return variantId;
|
|
29
|
-
}
|
|
30
|
-
const pathSegment = extractor === 'shopify-product-id' ? 'products' : 'collections';
|
|
31
|
-
const tokens = (_b = getTrimmedPathName()) === null || _b === void 0 ? void 0 : _b.split('/');
|
|
32
|
-
const idIndex = tokens === null || tokens === void 0 ? void 0 : tokens.findIndex((token) => token === pathSegment);
|
|
33
|
-
if (idIndex !== undefined && idIndex >= 0 && tokens) {
|
|
34
|
-
return decodeURIComponent(tokens[idIndex + 1]);
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}, [getTrimmedPathName]);
|
|
38
|
-
const isOnPdpPage = useCallback(() => {
|
|
39
|
-
var _a, _b;
|
|
40
|
-
return (_b = (_a = getTrimmedPathName()) === null || _a === void 0 ? void 0 : _a.includes('/products')) !== null && _b !== void 0 ? _b : false;
|
|
41
|
-
}, [getTrimmedPathName]);
|
|
42
|
-
const isOnPlpPage = useCallback(() => {
|
|
43
|
-
var _a, _b, _c;
|
|
44
|
-
return ((_c = (((_a = getTrimmedPathName()) === null || _a === void 0 ? void 0 : _a.includes('/collections')) &&
|
|
45
|
-
!((_b = getTrimmedPathName()) === null || _b === void 0 ? void 0 : _b.includes('/products')))) !== null && _c !== void 0 ? _c : false);
|
|
46
|
-
}, [getTrimmedPathName]);
|
|
47
|
-
const value = useMemo(() => ({
|
|
48
|
-
getTrimmedPathName,
|
|
49
|
-
getPlpOrPdpId,
|
|
50
|
-
isOnPdpPage,
|
|
51
|
-
isOnPlpPage,
|
|
52
|
-
isReady,
|
|
53
|
-
}), [getTrimmedPathName, getPlpOrPdpId, isOnPdpPage, isOnPlpPage, isReady]);
|
|
54
|
-
return _jsx(ShopifyUrlContext.Provider, { value: value, children: children });
|
|
55
|
-
};
|
|
56
|
-
export const useShopifyUrl = () => {
|
|
57
|
-
const context = useContext(ShopifyUrlContext);
|
|
58
|
-
if (!context) {
|
|
59
|
-
throw new Error('useShopifyUrl must be used within a ShopifyUrlProvider');
|
|
60
|
-
}
|
|
61
|
-
return context;
|
|
62
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./systemSettingsContext";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useAtomValue } from 'jotai';
|
|
3
|
-
import { createContext, useMemo, useState } from 'react';
|
|
4
|
-
import { baseUrlAtom } from 'src/atoms/envive/enviveConfig';
|
|
5
|
-
// TODO: Refactor this to a common service that handles query params (and spiffy variables all together)
|
|
6
|
-
const getChatModelName = () => {
|
|
7
|
-
const urlObj = new URL(window.location.href);
|
|
8
|
-
const params = new URLSearchParams(urlObj.search);
|
|
9
|
-
const paramsObj = Object.fromEntries(params.entries());
|
|
10
|
-
return paramsObj.llm_model_name;
|
|
11
|
-
};
|
|
12
|
-
const defaultGenerationParams = {
|
|
13
|
-
stream: true,
|
|
14
|
-
numSuggestions: 3,
|
|
15
|
-
model: getChatModelName(),
|
|
16
|
-
};
|
|
17
|
-
const SystemSettingsContext = createContext(undefined);
|
|
18
|
-
const SystemSettingsContextProvider = ({ children, generationParams, showDebugBar, }) => {
|
|
19
|
-
const [params, setParams] = useState(() => generationParams !== null && generationParams !== void 0 ? generationParams : defaultGenerationParams);
|
|
20
|
-
const endpointURL = useAtomValue(baseUrlAtom);
|
|
21
|
-
const settingsContextValues = useMemo(() => ({
|
|
22
|
-
generationParams: params,
|
|
23
|
-
showDebugBar,
|
|
24
|
-
setGenerationParams: setParams,
|
|
25
|
-
endpointURL,
|
|
26
|
-
}), [generationParams, endpointURL, showDebugBar]);
|
|
27
|
-
return (_jsx(SystemSettingsContext.Provider, { value: settingsContextValues, children: children }));
|
|
28
|
-
};
|
|
29
|
-
export { SystemSettingsContextProvider, SystemSettingsContext, defaultGenerationParams };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./userIdentityContext";
|