@envive-ai/react-hooks 0.2.6-alpha → 0.2.6-alpha-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AmplitudeOperations-zFjk1Mkm.js → AmplitudeOperations-C3i2q2Bn.js} +2 -2
- package/dist/{AmplitudeOperations-CDe6oRn4.cjs → AmplitudeOperations-DcuLn1Zk.cjs} +2 -2
- package/dist/{NewOrgConfig-ChNJ3ZtC.js → NewOrgConfig-BtvujFC8.js} +2 -2
- package/dist/{NewOrgConfig-KHz61ikr.cjs → NewOrgConfig-CHt7Xg4t.cjs} +2 -2
- package/dist/{TrackComponentVisibleEvent-f8ahqV1g.js → TrackComponentVisibleEvent-Be7wfXXY.js} +3 -3
- package/dist/{TrackComponentVisibleEvent-uEzgBXb9.cjs → TrackComponentVisibleEvent-KUihr_y4.cjs} +3 -3
- package/dist/{api-1-73JxnF.js → api-D4HaU2Gf.js} +3 -3
- package/dist/{api-ZNG6wObS.cjs → api-D4Xoibs9.cjs} +3 -3
- package/dist/application/models/graphql/index.cjs +1 -1
- package/dist/application/models/graphql/index.js +1 -1
- package/dist/application/models/guards/api/index.cjs +3 -3
- package/dist/application/models/guards/api/index.js +3 -3
- package/dist/application/models/guards/utils.cjs +1 -1
- package/dist/application/models/guards/utils.js +1 -1
- package/dist/application/models/index.cjs +6 -6
- package/dist/application/models/index.js +6 -6
- package/dist/application/utils/index.cjs +17 -17
- package/dist/application/utils/index.d.cts +1 -1
- package/dist/application/utils/index.d.ts +2 -2
- package/dist/application/utils/index.js +17 -17
- package/dist/{atomStore-DAQvNPkh.js → atomStore-BuopbV9k.js} +1 -1
- package/dist/{atomStore-DD9g7Zw2.cjs → atomStore-CZKe3itM.cjs} +1 -1
- package/dist/atoms/app/index.cjs +17 -17
- package/dist/atoms/app/index.d.cts +7 -7
- package/dist/atoms/app/index.d.ts +6 -6
- package/dist/atoms/app/index.js +17 -17
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +19 -19
- package/dist/atoms/chat/index.d.cts +32 -32
- package/dist/atoms/chat/index.d.ts +32 -32
- package/dist/atoms/chat/index.js +19 -19
- package/dist/atoms/globalSearch/index.cjs +1 -1
- package/dist/atoms/globalSearch/index.d.cts +6 -6
- package/dist/atoms/globalSearch/index.d.ts +6 -6
- package/dist/atoms/globalSearch/index.js +1 -1
- package/dist/atoms/org/index.cjs +2 -2
- package/dist/atoms/org/index.d.cts +16 -16
- package/dist/atoms/org/index.d.ts +16 -16
- package/dist/atoms/org/index.js +2 -2
- package/dist/atoms/search/index.cjs +6 -6
- package/dist/atoms/search/index.d.cts +15 -15
- package/dist/atoms/search/index.d.ts +14 -14
- package/dist/atoms/search/index.js +6 -6
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/{cdnContext-DT6J5nCw.js → cdnContext-B2-NiEiW.js} +2 -2
- package/dist/{cdnContext-BLNiW2HT.cjs → cdnContext-CdhppNeT.cjs} +2 -2
- package/dist/{chat-C0cgfkL8.js → chat-C9KdnT5V.js} +7 -7
- package/dist/{chat-DULmjtx1.cjs → chat-bImNRcnQ.cjs} +7 -7
- package/dist/{chatState-BrSfXIV4.cjs → chatState-DqWSgmjC.cjs} +3 -3
- package/dist/{chatState-Cn8JGAlH.js → chatState-DxG0t4fK.js} +3 -3
- package/dist/contexts/amplitudeContext/index.cjs +17 -17
- package/dist/contexts/amplitudeContext/index.js +17 -17
- package/dist/contexts/cdnContext/index.cjs +4 -4
- package/dist/contexts/cdnContext/index.d.cts +1 -1
- package/dist/contexts/cdnContext/index.js +4 -4
- package/dist/contexts/enviveConfigContext/index.cjs +4 -4
- package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
- package/dist/contexts/enviveConfigContext/index.js +4 -4
- package/dist/contexts/enviveCssContext/index.cjs +14 -14
- package/dist/contexts/enviveCssContext/index.js +14 -14
- package/dist/contexts/featureFlagContext/index.cjs +5 -5
- package/dist/contexts/featureFlagContext/index.js +5 -5
- package/dist/contexts/featureFlagServiceContext/index.cjs +4 -4
- package/dist/contexts/featureFlagServiceContext/index.js +4 -4
- package/dist/contexts/graphqlContext/index.cjs +8 -8
- package/dist/contexts/graphqlContext/index.js +8 -8
- package/dist/contexts/localStorageContext/index.cjs +3 -3
- package/dist/contexts/localStorageContext/index.js +3 -3
- package/dist/contexts/newOrgConfigContext/index.cjs +13 -13
- package/dist/contexts/newOrgConfigContext/index.d.cts +1 -1
- package/dist/contexts/newOrgConfigContext/index.js +13 -13
- package/dist/contexts/searchContext/index.cjs +22 -22
- package/dist/contexts/searchContext/index.js +22 -22
- package/dist/contexts/sessionStorageContext/index.cjs +2 -2
- package/dist/contexts/sessionStorageContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +4 -4
- package/dist/contexts/systemSettingsContext/index.js +4 -4
- package/dist/contexts/userIdentityContext/index.cjs +17 -17
- package/dist/contexts/userIdentityContext/index.js +17 -17
- package/dist/{dist-BZX_Mgfn.cjs → dist-B7BErEyV.cjs} +1 -1
- package/dist/{dist-CIM4YRqp.js → dist-CtkINi1R.js} +1 -1
- package/dist/{domObserver-DKcas6tl.js → domObserver-B19-69gW.js} +1 -1
- package/dist/{domObserver-Do6RAJdf.cjs → domObserver-CwieVNgj.cjs} +1 -1
- package/dist/{enviveConfig-DrvYlCYG.js → enviveConfig-Be2kZE7j.js} +3 -3
- package/dist/{enviveConfig-DaotBKMS.cjs → enviveConfig-u50Rpz-G.cjs} +3 -3
- package/dist/{enviveConfigContext-BCnzgk4M.js → enviveConfigContext-1oiQuocd.js} +3 -3
- package/dist/{enviveConfigContext--89ejDs5.cjs → enviveConfigContext-kQfHEGdJ.cjs} +3 -3
- package/dist/exceptions/index.cjs +1 -1
- package/dist/exceptions/index.js +1 -1
- package/dist/{exceptions-BiSWJEl2.cjs → exceptions-BjDgLzGi.cjs} +1 -1
- package/dist/{exceptions-DSv0ZaH0.js → exceptions-CUGY31Ua.js} +1 -1
- package/dist/{featureFlagServiceContext-DpdlcjNb.js → featureFlagServiceContext-CPsygiHO.js} +3 -3
- package/dist/{featureFlagServiceContext-BztKnBPk.cjs → featureFlagServiceContext-pPneufeB.cjs} +3 -3
- package/dist/{globalSearch-nmrfGLOn.js → globalSearch-B_v9qfCT.js} +1 -1
- package/dist/{globalSearch-Cpc8egsM.cjs → globalSearch-OiF96VLG.cjs} +1 -1
- package/dist/{graphql-CWNkUHFV.js → graphql-CvAHWmel.js} +1 -1
- package/dist/{graphql-DT-H-lta.cjs → graphql-JaGqsToc.cjs} +1 -1
- package/dist/{graphqlContext-CWulFxxC.js → graphqlContext-BuXJ5DiW.js} +5 -5
- package/dist/{graphqlContext-B181y-sa.cjs → graphqlContext-CU7NIJo7.cjs} +5 -5
- package/dist/hooks/AmplitudeOperations/index.cjs +18 -18
- package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
- package/dist/hooks/AmplitudeOperations/index.js +18 -18
- package/dist/hooks/AppDetails/index.cjs +20 -20
- package/dist/hooks/AppDetails/index.d.cts +1 -1
- package/dist/hooks/AppDetails/index.js +20 -20
- package/dist/hooks/CdnOperations/index.cjs +4 -4
- package/dist/hooks/CdnOperations/index.d.cts +1 -1
- package/dist/hooks/CdnOperations/index.js +4 -4
- package/dist/hooks/ChatToggle/index.cjs +19 -19
- package/dist/hooks/ChatToggle/index.js +19 -19
- package/dist/hooks/ChatToggleAnalytics/index.cjs +19 -19
- package/dist/hooks/ChatToggleAnalytics/index.js +19 -19
- package/dist/hooks/CustomerSupportHandoff/index.cjs +1 -1
- package/dist/hooks/CustomerSupportHandoff/index.js +1 -1
- package/dist/hooks/ElementObserver/index.cjs +1 -1
- package/dist/hooks/ElementObserver/index.js +1 -1
- package/dist/hooks/GraphQLConfig/index.cjs +9 -9
- package/dist/hooks/GraphQLConfig/index.js +9 -9
- package/dist/hooks/IdentifyUser/index.cjs +17 -17
- package/dist/hooks/IdentifyUser/index.js +17 -17
- package/dist/hooks/ImageResolver/index.cjs +3 -3
- package/dist/hooks/ImageResolver/index.js +3 -3
- package/dist/hooks/LocalStorageOperations/index.cjs +3 -3
- package/dist/hooks/LocalStorageOperations/index.js +3 -3
- package/dist/hooks/MessageFilter/index.cjs +1 -1
- package/dist/hooks/MessageFilter/index.js +1 -1
- package/dist/hooks/NewOrgConfig/index.cjs +14 -14
- package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
- package/dist/hooks/NewOrgConfig/index.d.ts +2 -2
- package/dist/hooks/NewOrgConfig/index.js +14 -14
- package/dist/hooks/Search/index.cjs +31 -31
- package/dist/hooks/Search/index.js +31 -31
- package/dist/hooks/SearchOperations/index.cjs +22 -22
- package/dist/hooks/SearchOperations/index.js +22 -22
- package/dist/hooks/SessionStorageOperations/index.cjs +2 -2
- package/dist/hooks/SessionStorageOperations/index.js +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.d.cts +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +2 -2
- package/dist/hooks/SystemSettingsContext/index.cjs +4 -4
- package/dist/hooks/SystemSettingsContext/index.d.cts +3 -3
- package/dist/hooks/SystemSettingsContext/index.d.ts +4 -4
- package/dist/hooks/SystemSettingsContext/index.js +4 -4
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +18 -18
- package/dist/hooks/TrackComponentVisibleEvent/index.js +18 -18
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +17 -17
- package/dist/hooks/UpdateAnalyticsProps/index.js +17 -17
- package/dist/index-B4cSHxVN.d.ts +1 -1
- package/dist/index-Dzv6WwSZ.d.ts +1 -1
- package/dist/interceptors/index.cjs +1 -1
- package/dist/interceptors/index.js +1 -1
- package/dist/{localStorageContext-DbWl7Row.cjs → localStorageContext-Bb2b_3ue.cjs} +3 -3
- package/dist/{localStorageContext-DSpmlfyr.js → localStorageContext-D2uXKahw.js} +3 -3
- package/dist/{logger-DCs3_11o.js → logger-BMVdhQOV.js} +1 -1
- package/dist/{logger-BF6iGSVd.cjs → logger-BqHq67zN.cjs} +1 -1
- package/dist/{models-DEJUuKYQ.js → models-DmsMlaHT.js} +5 -5
- package/dist/{models-158fyHt9.cjs → models-wh2gh_Qz.cjs} +5 -5
- package/dist/{newOrgConfigAtom-BuQE_zPK.js → newOrgConfigAtom-Dsk0fJNR.js} +1 -1
- package/dist/{newOrgConfigAtom-rrYHmp1b.cjs → newOrgConfigAtom-hs5A1pbZ.cjs} +1 -1
- package/dist/{newOrgConfigContext-C0LzIRJ7.js → newOrgConfigContext-DPUxIF2G.js} +5 -5
- package/dist/{newOrgConfigContext-BVrzYatq.cjs → newOrgConfigContext-lw85mMS-.cjs} +5 -5
- package/dist/nodeSelector-Cj-Xl1LP.d.cts +1 -1
- package/dist/{org-CVjyv-gv.cjs → org-C2kLSSe9.cjs} +1 -1
- package/dist/{org-Ct9Vjv1J.js → org-CIczyLRP.js} +1 -1
- package/dist/{search-DLHzcbfP.js → search-BzXoTgRx.js} +5 -5
- package/dist/{search-C0TAcTeY.cjs → search-D1cU29CV.cjs} +5 -5
- package/dist/{searchContext-Dmtue5QO.js → searchContext-C8DpjnqD.js} +7 -7
- package/dist/{searchContext-l_23fiuP.cjs → searchContext-R_XuFzYe.cjs} +7 -7
- package/dist/{searchServiceAdapter-B0h7psvh.js → searchServiceAdapter-CKc7UXKi.js} +1 -1
- package/dist/{searchServiceAdapter-BclWy4fE.cjs → searchServiceAdapter-pROGm3Rf.cjs} +1 -1
- package/dist/{sessionStorageContext-BOyr7mIM.cjs → sessionStorageContext-ByaTsDUC.cjs} +2 -2
- package/dist/{sessionStorageContext-ClXN9eX4.js → sessionStorageContext-DKE97oMv.js} +2 -2
- package/dist/{systemSettingsContext-CksCdpiU.js → systemSettingsContext-B-FZ8UAg.js} +2 -2
- package/dist/{systemSettingsContext-Cb5kczBD.cjs → systemSettingsContext-J1sny8W8.cjs} +2 -2
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +1 -1
- package/dist/{types-18QXD2rd.cjs → types-1iJ_FnQQ.cjs} +1 -1
- package/dist/{types-DQC1pHqD.js → types-D5du68Vp.js} +1 -1
- package/dist/{useAppDetails-BJFRSYbI.js → useAppDetails-BtK9ZZJs.js} +4 -4
- package/dist/{useAppDetails-Czn-5FzP.cjs → useAppDetails-Bw2jJ39H.cjs} +4 -4
- package/dist/{useGraphQLConfig-BEtX5pDM.cjs → useGraphQLConfig-Dc8h2yyN.cjs} +2 -2
- package/dist/{useGraphQLConfig-Dkcrz1YL.js → useGraphQLConfig-DuLB3tdv.js} +2 -2
- package/dist/{utils-CEKzBcN2.js → utils-B1LVzQYK.js} +1 -1
- package/dist/{utils-CqVRbvfN.cjs → utils-BivlGkeU.cjs} +1 -1
- package/dist/{utils-DQhbbAnt.js → utils-CExht7Uj.js} +1 -1
- package/dist/{utils-CsMbZmRw.cjs → utils-CiJLDPjY.cjs} +1 -1
- package/dist/{utils-CPvqOk0g.cjs → utils-DqNhRm2b.cjs} +14 -14
- package/dist/{utils-N47VsL9W.js → utils-IogJwDB9.js} +13 -13
- package/package.json +1 -1
- package/src/hooks/Search/useSearch.tsx +11 -11
- package/src/hooks/Search/useSearchInput.ts +19 -9
- package/dist/src/application/commerce-api.js +0 -406
- 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 -94
- 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 -33
- 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 -43
- 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 -292
- 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 -183
- 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
- /package/dist/{featureFlagServiceContext-bI7ZLz4r.js → featureFlagServiceContext-CbUOAw5l.js} +0 -0
- /package/dist/{featureFlagServiceContext-B4ash4vz.cjs → featureFlagServiceContext-DSo2brno.cjs} +0 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
2
|
-
import { useCallback, useEffect, useMemo, useRef
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import {
|
|
4
4
|
SearchResultsHocProps,
|
|
5
5
|
ProductSorting,
|
|
@@ -24,18 +24,18 @@ import {
|
|
|
24
24
|
} from "../../atoms/search";
|
|
25
25
|
import { isFilterOpenAtom } from "../../atoms/globalSearch/globalSearch";
|
|
26
26
|
import { formatFilterDisplayName } from "../../atoms/search/utils";
|
|
27
|
-
import {
|
|
27
|
+
import { amplitudeTrackEventAtom } from "../../atoms/amplitude/amplitudeTrackEventAtom";
|
|
28
28
|
import { orgShortNameAtom } from "../../atoms/envive/enviveConfig";
|
|
29
|
-
import {
|
|
29
|
+
import { newOrgConfigAtom } from "../../atoms/org/newOrgConfigAtom";
|
|
30
|
+
import { retrievedProductsAtom } from "../../atoms/search/productRetrievalAPI";
|
|
30
31
|
import { useTrackComponentVisibleEvent } from "../TrackComponentVisibleEvent";
|
|
31
32
|
import { getSearchResultsState } from "../utils";
|
|
32
|
-
import { useRecommendedProducts } from "./useRecommendedProducts";
|
|
33
33
|
import { useSearchInput } from "./useSearchInput";
|
|
34
34
|
|
|
35
35
|
export const useSearch = (): SearchResultsHocProps => {
|
|
36
36
|
// Atoms
|
|
37
|
-
const
|
|
38
|
-
const config =
|
|
37
|
+
const trackEvent = useAtomValue(amplitudeTrackEventAtom);
|
|
38
|
+
const config = useAtomValue(newOrgConfigAtom);
|
|
39
39
|
const orgShortName = useAtomValue(orgShortNameAtom);
|
|
40
40
|
const { data: searchData, loading: isLoadingSearch } =
|
|
41
41
|
useAtomValue(searchAtom);
|
|
@@ -49,7 +49,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
49
49
|
const [productSorting, setProductSorting] = useAtom(searchProductSortingAtom);
|
|
50
50
|
const clearFilters = useSetAtom(clearSearchFiltersAtom);
|
|
51
51
|
const searchFilters = useAtomValue(searchFiltersAtom);
|
|
52
|
-
const recommendedProducts =
|
|
52
|
+
const recommendedProducts = useAtomValue(retrievedProductsAtom);
|
|
53
53
|
|
|
54
54
|
// Refs
|
|
55
55
|
const searchResultsRef = useRef<HTMLDivElement>(null);
|
|
@@ -164,7 +164,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
164
164
|
filter: string;
|
|
165
165
|
dynamicFilterDisplayName: string;
|
|
166
166
|
}) => {
|
|
167
|
-
trackEvent({
|
|
167
|
+
trackEvent?.({
|
|
168
168
|
eventName: SpiffyMetricsEventName.SearchFilterClicked,
|
|
169
169
|
eventProps: {
|
|
170
170
|
filterType: "Dynamic",
|
|
@@ -202,7 +202,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
202
202
|
}) => {
|
|
203
203
|
if (filterId === "sort") {
|
|
204
204
|
const newSort = filterItemId as ProductSorting;
|
|
205
|
-
trackEvent({
|
|
205
|
+
trackEvent?.({
|
|
206
206
|
eventName: SpiffyMetricsEventName.SearchSortClicked,
|
|
207
207
|
eventProps: {
|
|
208
208
|
sortType: newSort,
|
|
@@ -215,7 +215,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
215
215
|
removeFilter(`${filterId}:${filterItemId}`);
|
|
216
216
|
scrollToTop();
|
|
217
217
|
} else {
|
|
218
|
-
trackEvent({
|
|
218
|
+
trackEvent?.({
|
|
219
219
|
eventName: SpiffyMetricsEventName.SearchFilterClicked,
|
|
220
220
|
eventProps: {
|
|
221
221
|
filterType: "Static",
|
|
@@ -254,7 +254,7 @@ export const useSearch = (): SearchResultsHocProps => {
|
|
|
254
254
|
|
|
255
255
|
useEffect(() => {
|
|
256
256
|
if (productList.length > 0) {
|
|
257
|
-
trackEvent({
|
|
257
|
+
trackEvent?.({
|
|
258
258
|
eventName: SpiffyMetricsEventName.SearchResultsViewed,
|
|
259
259
|
eventProps: {
|
|
260
260
|
queryText: searchText,
|
|
@@ -8,13 +8,14 @@ import {
|
|
|
8
8
|
} from "@envive-ai/types";
|
|
9
9
|
import { useAmplitudeTracking } from "../AmplitudeOperations";
|
|
10
10
|
import { autocompleteStateAtom } from "src/atoms/globalSearch";
|
|
11
|
+
import { amplitudeTrackEventAtom } from "src/atoms/amplitude/amplitudeTrackEventAtom";
|
|
11
12
|
|
|
12
13
|
export const useSearchInput = ({
|
|
13
14
|
initialSearchText = "",
|
|
14
15
|
searchOrigin,
|
|
15
16
|
onSearchSubmit,
|
|
16
17
|
}: UseSearchInputProps): UseSearchInputReturn => {
|
|
17
|
-
const
|
|
18
|
+
const track = useAtomValue(amplitudeTrackEventAtom);
|
|
18
19
|
|
|
19
20
|
// State
|
|
20
21
|
const [searchText, setSearchText] = useState(initialSearchText);
|
|
@@ -92,8 +93,11 @@ export const useSearchInput = ({
|
|
|
92
93
|
}
|
|
93
94
|
|
|
94
95
|
if (newValue.length === 1) {
|
|
95
|
-
track(
|
|
96
|
-
|
|
96
|
+
track?.({
|
|
97
|
+
eventName: SpiffyMetricsEventName.SearchInputStarted,
|
|
98
|
+
eventProps: {
|
|
99
|
+
searchOrigin,
|
|
100
|
+
},
|
|
97
101
|
});
|
|
98
102
|
}
|
|
99
103
|
setSearchText(newValue);
|
|
@@ -121,9 +125,13 @@ export const useSearchInput = ({
|
|
|
121
125
|
const handleSubmitSearch = useCallback(() => {
|
|
122
126
|
setIsFocused(false);
|
|
123
127
|
if (searchText.trim() && onSearchSubmit) {
|
|
124
|
-
track(
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
track?.({
|
|
129
|
+
eventName: SpiffyMetricsEventName.SearchQuerySubmitted,
|
|
130
|
+
eventProps: {
|
|
131
|
+
searchOrigin,
|
|
132
|
+
queryText: searchText.trim(),
|
|
133
|
+
},
|
|
134
|
+
alsoSendToGoogleAnalytics: true,
|
|
127
135
|
});
|
|
128
136
|
onSearchSubmit(searchText.trim());
|
|
129
137
|
}
|
|
@@ -136,9 +144,11 @@ export const useSearchInput = ({
|
|
|
136
144
|
setHasText(suggestion.trim().length > 0);
|
|
137
145
|
setIsFocused(false);
|
|
138
146
|
|
|
139
|
-
track(
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
track?.({
|
|
148
|
+
eventName: SpiffyMetricsEventName.SearchInputStarted,
|
|
149
|
+
eventProps: {
|
|
150
|
+
searchOrigin,
|
|
151
|
+
},
|
|
142
152
|
});
|
|
143
153
|
|
|
144
154
|
if (onSearchSubmit) {
|
|
@@ -1,406 +0,0 @@
|
|
|
1
|
-
var _a;
|
|
2
|
-
import { ContextEnvEnum, Configuration, CustomerServiceApi, DefaultApi, InferenceApi, ResponseError, UserEventCategory, ContextSourceEnum, V1OrgConfigGetSourceEnum, ResponseCategory, FormType, } from "@spiffy-ai/commerce-api-client";
|
|
3
|
-
import { ProductExperiment, } from "@envive-ai/types";
|
|
4
|
-
import { userIdAtom, chatIdAtom } from "src/atoms/app";
|
|
5
|
-
import { getAtomStore } from "src/atoms/atomStore";
|
|
6
|
-
import { baseUrlAtom, orgShortNameAtom, contextSourceAtom, envAtom, reactAppNameAtom, } from "src/atoms/envive/enviveConfig";
|
|
7
|
-
import { orgIdAtom, featureFlagServiceAtom } from "src/atoms/org";
|
|
8
|
-
import { UnsupportedProductException, SessionRestartRequired, } from "src/exceptions";
|
|
9
|
-
import Logger from "./logging/logger";
|
|
10
|
-
import { validateResponse, validateSuggestion, validateUserEvent, validateOrgConfigResults, } from "./models";
|
|
11
|
-
import { messageRequestToCommerceMessageRequest, messageFromResponse, messageFromQueryEvent, messageFromSuggestionEvent, messageFromFormSubmittedEvent, coreSupportedEventRequestToApiRequest, } from "./utils";
|
|
12
|
-
async function errorResponseBody(error) {
|
|
13
|
-
try {
|
|
14
|
-
return await error.response.json();
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
return {};
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
async function throwSessionRestartRequiredIf(errorMsg, error) {
|
|
21
|
-
var _b, _c, _d, _e;
|
|
22
|
-
if (!(error instanceof ResponseError)) {
|
|
23
|
-
Logger.logInfo(errorMsg, error);
|
|
24
|
-
throw error;
|
|
25
|
-
}
|
|
26
|
-
const errorResponse = await errorResponseBody(error);
|
|
27
|
-
if (((_b = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.message) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === "unsupported product" || // for backward compatibility. newer versions of the API return sub_code instead of message
|
|
28
|
-
((_c = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.app_code) === null || _c === void 0 ? void 0 : _c.toUpperCase()) === "PRODUCT_NOT_FOUND") {
|
|
29
|
-
throw new UnsupportedProductException();
|
|
30
|
-
}
|
|
31
|
-
else if (((_d = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.app_code) === null || _d === void 0 ? void 0 : _d.toUpperCase()) === "RESTART_SESSION" ||
|
|
32
|
-
((_e = errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.sub_code) === null || _e === void 0 ? void 0 : _e.toUpperCase()) === "NOT_FOUND" // for backward compatibility. new API responses will contain "app_code"
|
|
33
|
-
) {
|
|
34
|
-
Logger.logInfo("Session does not exist. Re-start session", error, error.response, errorResponse);
|
|
35
|
-
throw new SessionRestartRequired();
|
|
36
|
-
}
|
|
37
|
-
Logger.logInfo(errorMsg, error);
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
class CommerceApiClient {
|
|
41
|
-
constructor(basePath) {
|
|
42
|
-
this.suggestionsAbortController = new AbortController();
|
|
43
|
-
this.responsesAbortController = new AbortController();
|
|
44
|
-
const atomStore = getAtomStore();
|
|
45
|
-
const baseUrl = atomStore.get(baseUrlAtom);
|
|
46
|
-
const path = basePath || baseUrl;
|
|
47
|
-
// API Key is now handled at the EnviveConfigProvider level
|
|
48
|
-
const config = new Configuration({
|
|
49
|
-
basePath: path,
|
|
50
|
-
headers: {
|
|
51
|
-
"Content-Type": "application/json",
|
|
52
|
-
Accept: "application/json",
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
this.defaultApi = new DefaultApi(config);
|
|
56
|
-
this.inferenceApi = new InferenceApi(config);
|
|
57
|
-
this.customerServiceApi = new CustomerServiceApi(config);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
_a = CommerceApiClient;
|
|
61
|
-
CommerceApiClient.getInstance = () => {
|
|
62
|
-
if (!_a.instance) {
|
|
63
|
-
_a.instance = new _a();
|
|
64
|
-
}
|
|
65
|
-
return _a.instance;
|
|
66
|
-
};
|
|
67
|
-
CommerceApiClient.resolveUrl = async (url) => {
|
|
68
|
-
var _b, _c;
|
|
69
|
-
const atomStore = getAtomStore();
|
|
70
|
-
const orgShortName = atomStore.get(orgShortNameAtom);
|
|
71
|
-
const orgId = atomStore.get(orgIdAtom);
|
|
72
|
-
const userId = atomStore.get(userIdAtom);
|
|
73
|
-
const chatId = atomStore.get(chatIdAtom);
|
|
74
|
-
const source = atomStore.get(contextSourceAtom);
|
|
75
|
-
const env = atomStore.get(envAtom);
|
|
76
|
-
const featureFlagService = atomStore.get(featureFlagServiceAtom);
|
|
77
|
-
const context = {
|
|
78
|
-
user_id: userId !== null && userId !== void 0 ? userId : "",
|
|
79
|
-
org_id: orgId !== null && orgId !== void 0 ? orgId : "",
|
|
80
|
-
org_short_name: orgShortName !== null && orgShortName !== void 0 ? orgShortName : "",
|
|
81
|
-
chat_id: chatId !== null && chatId !== void 0 ? chatId : "",
|
|
82
|
-
source: source !== null && source !== void 0 ? source : ContextSourceEnum.App,
|
|
83
|
-
env: (_b = env) !== null && _b !== void 0 ? _b : ContextEnvEnum.Dev, // Cast env to ContextEnvEnum
|
|
84
|
-
};
|
|
85
|
-
const featureGates = ((_c = featureFlagService === null || featureFlagService === void 0 ? void 0 : featureFlagService.featureFlagService) === null || _c === void 0 ? void 0 : _c.getFeatureFlags()) || {};
|
|
86
|
-
const urlResolvingRequest = {
|
|
87
|
-
url,
|
|
88
|
-
context,
|
|
89
|
-
feature_gates: featureGates,
|
|
90
|
-
};
|
|
91
|
-
const rawResponse = await _a.getInstance().inferenceApi.v1UrlResolvingPostRaw({
|
|
92
|
-
UrlResolvingRequest: urlResolvingRequest,
|
|
93
|
-
});
|
|
94
|
-
const responseBody = await rawResponse.raw.json();
|
|
95
|
-
return responseBody;
|
|
96
|
-
};
|
|
97
|
-
CommerceApiClient.reportSession = async (reportRequest) => {
|
|
98
|
-
await _a.getInstance().defaultApi.v1ChatsReportSessionIdPost({
|
|
99
|
-
ReportSessionRequest: reportRequest,
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
CommerceApiClient.getNextResponses = async (payload) => {
|
|
103
|
-
try {
|
|
104
|
-
const response = await _a.getInstance().inferenceApi.v1NextResponsesPost({
|
|
105
|
-
NextMessageRequest: messageRequestToCommerceMessageRequest(payload),
|
|
106
|
-
});
|
|
107
|
-
const messages = response
|
|
108
|
-
.map((resp) => validateResponse(resp))
|
|
109
|
-
.map((resp) => messageFromResponse(resp));
|
|
110
|
-
return messages.filter((m) => m != null);
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
Logger.logInfo("Failed to get next responses", err, {
|
|
114
|
-
payloadContext: payload === null || payload === void 0 ? void 0 : payload.context,
|
|
115
|
-
userEvents: payload === null || payload === void 0 ? void 0 : payload.userEvents,
|
|
116
|
-
});
|
|
117
|
-
await throwSessionRestartRequiredIf("Failed to get next responses", err);
|
|
118
|
-
return [];
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
CommerceApiClient.getNextResponseStreaming = (payload) => {
|
|
122
|
-
async function* generate(inferenceApi, abortController) {
|
|
123
|
-
// make sure streaming is enabled
|
|
124
|
-
try {
|
|
125
|
-
const response = await inferenceApi.v1NextResponsesPostRaw({
|
|
126
|
-
NextMessageRequest: messageRequestToCommerceMessageRequest(payload),
|
|
127
|
-
}, { signal: abortController.signal });
|
|
128
|
-
// Read the response as a stream of data
|
|
129
|
-
if (!response.raw.body) {
|
|
130
|
-
Logger.logError("[spiffy-ai] No body in the streamed response", undefined, {
|
|
131
|
-
response: response.raw,
|
|
132
|
-
});
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const reader = response.raw.body.getReader();
|
|
136
|
-
const decoder = new TextDecoder("utf-8");
|
|
137
|
-
let partial = "";
|
|
138
|
-
// TODO this function is recreated every time new data comes from the stream - define it outside of the generator
|
|
139
|
-
const safeParse = (line) => {
|
|
140
|
-
try {
|
|
141
|
-
return JSON.parse(line); // Parse the JSON string
|
|
142
|
-
}
|
|
143
|
-
catch (err) {
|
|
144
|
-
Logger.logError("[spiffy-ai] Error parsing streamed line", err, {
|
|
145
|
-
line,
|
|
146
|
-
partial,
|
|
147
|
-
});
|
|
148
|
-
// swallow the error and set the partial to our current chunk
|
|
149
|
-
partial = line;
|
|
150
|
-
return partial;
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
// TODO this function is recreated every time new data comes from the stream - define it outside of the generator
|
|
154
|
-
const processChunk = (chunk) => {
|
|
155
|
-
// merge the partial with the incoming chunk
|
|
156
|
-
const lines = `${partial}${chunk}`.split("\n");
|
|
157
|
-
const parsedLines = lines
|
|
158
|
-
.map((line) => line.replace(/^data: /, "").trim()) // Remove the "data: " prefix
|
|
159
|
-
.filter((line) => line !== "" && line !== "[DONE]") // Remove empty lines and "[DONE]"
|
|
160
|
-
.map(safeParse)
|
|
161
|
-
.filter((v) => v); // and filter out the undefined values
|
|
162
|
-
return parsedLines;
|
|
163
|
-
};
|
|
164
|
-
while (true) {
|
|
165
|
-
// eslint-disable-next-line no-await-in-loop
|
|
166
|
-
const { done, value } = await reader.read();
|
|
167
|
-
if (done) {
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
// Massage and parse the chunk of data
|
|
171
|
-
const chunk = decoder.decode(value);
|
|
172
|
-
const parsedLines = processChunk(chunk);
|
|
173
|
-
for (const parsedLine of parsedLines) {
|
|
174
|
-
const validatedResponse = validateResponse(parsedLine);
|
|
175
|
-
if (validatedResponse) {
|
|
176
|
-
yield validatedResponse;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
Logger.logError("[spiffy-ai] Failed to get next streaming responses", error, {
|
|
183
|
-
payloadContext: payload === null || payload === void 0 ? void 0 : payload.context,
|
|
184
|
-
userEvents: payload === null || payload === void 0 ? void 0 : payload.userEvents,
|
|
185
|
-
});
|
|
186
|
-
await throwSessionRestartRequiredIf("Failed to get next streaming responses", error);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
_a.getInstance().responsesAbortController.abort();
|
|
190
|
-
_a.getInstance().responsesAbortController =
|
|
191
|
-
new AbortController();
|
|
192
|
-
return generate(_a.getInstance().inferenceApi, _a.getInstance().responsesAbortController);
|
|
193
|
-
};
|
|
194
|
-
CommerceApiClient.getNextSuggestions = async (payload) => {
|
|
195
|
-
try {
|
|
196
|
-
_a.getInstance().suggestionsAbortController.abort();
|
|
197
|
-
_a.getInstance().suggestionsAbortController =
|
|
198
|
-
new AbortController();
|
|
199
|
-
const response = await _a.getInstance().inferenceApi.v1NextSuggestionsPost({
|
|
200
|
-
NextMessageRequest: messageRequestToCommerceMessageRequest(payload),
|
|
201
|
-
}, {
|
|
202
|
-
signal: _a.getInstance().suggestionsAbortController.signal,
|
|
203
|
-
});
|
|
204
|
-
const suggestions = response
|
|
205
|
-
.map((resp) => validateSuggestion(resp))
|
|
206
|
-
.filter((suggestion) => suggestion != null);
|
|
207
|
-
return suggestions;
|
|
208
|
-
}
|
|
209
|
-
catch (error) {
|
|
210
|
-
Logger.logInfo("Failed to get suggestions", error, {
|
|
211
|
-
payloadContext: payload === null || payload === void 0 ? void 0 : payload.context,
|
|
212
|
-
userEvents: payload === null || payload === void 0 ? void 0 : payload.userEvents,
|
|
213
|
-
});
|
|
214
|
-
await throwSessionRestartRequiredIf("Failed to get suggestions", error);
|
|
215
|
-
return [];
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* Fetches the existing chat data for a given session and transforms them to reconstruct the chat history.
|
|
220
|
-
*
|
|
221
|
-
* @param orgId The organization Id
|
|
222
|
-
* @param chatId The existing chat Id
|
|
223
|
-
* @param userId The user Id
|
|
224
|
-
*
|
|
225
|
-
* @returns A list of messages that were exchanged in the chat, throws an error if the chat session has expired.
|
|
226
|
-
*/
|
|
227
|
-
CommerceApiClient.getResponses = async (orgId, chatId, userId) => {
|
|
228
|
-
var _b;
|
|
229
|
-
let data = {
|
|
230
|
-
responses: [],
|
|
231
|
-
suggestions: [],
|
|
232
|
-
user_events: [],
|
|
233
|
-
};
|
|
234
|
-
const request = {
|
|
235
|
-
org_id: orgId,
|
|
236
|
-
chat_id: chatId,
|
|
237
|
-
user_id: userId,
|
|
238
|
-
};
|
|
239
|
-
try {
|
|
240
|
-
data =
|
|
241
|
-
await _a.getInstance().defaultApi.v1GetSessionMessages(request);
|
|
242
|
-
}
|
|
243
|
-
catch (error) {
|
|
244
|
-
await throwSessionRestartRequiredIf("Failed to get chat responses", error);
|
|
245
|
-
}
|
|
246
|
-
const responses = (_b = data === null || data === void 0 ? void 0 : data.responses) === null || _b === void 0 ? void 0 : _b.map((turn) => turn
|
|
247
|
-
.map((response) => validateResponse(response))
|
|
248
|
-
.filter((response) => response != null));
|
|
249
|
-
const suggestions = data === null || data === void 0 ? void 0 : data.suggestions.map((suggestion) => validateSuggestion(suggestion)).filter((suggestion) => suggestion != null);
|
|
250
|
-
const userEvents = data === null || data === void 0 ? void 0 : data.user_events.map((event) => validateUserEvent(event)).filter((event) => event != null);
|
|
251
|
-
// if a form has already been submitted, don't show it in the chat history
|
|
252
|
-
const formSubmittedUserEventsFormIds = userEvents
|
|
253
|
-
.filter((event) => event.category === UserEventCategory.FormSubmitted)
|
|
254
|
-
.map((event) => event.attributes.formResponseId);
|
|
255
|
-
const assistantMessages = responses
|
|
256
|
-
.map((turn) => turn
|
|
257
|
-
.filter((response) => !(response.category === ResponseCategory.Form &&
|
|
258
|
-
formSubmittedUserEventsFormIds.includes(response.id)))
|
|
259
|
-
.map((response) => messageFromResponse(response))
|
|
260
|
-
.filter((message) => message != null))
|
|
261
|
-
.filter((turn) => turn.length > 0);
|
|
262
|
-
const userMessages = userEvents
|
|
263
|
-
.map((event) => {
|
|
264
|
-
if ([UserEventCategory.QueryTyped, UserEventCategory.Search].includes(event.category)) {
|
|
265
|
-
return [messageFromQueryEvent(event)];
|
|
266
|
-
}
|
|
267
|
-
if (event.category === UserEventCategory.SuggestionClicked) {
|
|
268
|
-
return [messageFromSuggestionEvent(event, suggestions)];
|
|
269
|
-
}
|
|
270
|
-
if (event.category === UserEventCategory.FormSubmitted) {
|
|
271
|
-
const formResponse = responses
|
|
272
|
-
.flat()
|
|
273
|
-
.find((response) => response.id === event.attributes.formResponseId &&
|
|
274
|
-
event.attributes.formType !== FormType.Escalation);
|
|
275
|
-
if (formResponse && formResponse.category === ResponseCategory.Form) {
|
|
276
|
-
return [
|
|
277
|
-
messageFromFormSubmittedEvent(event, formResponse.attributes),
|
|
278
|
-
];
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return [];
|
|
282
|
-
})
|
|
283
|
-
.filter((message) => message.length > 0);
|
|
284
|
-
// Sort the messages chronologically to reconstruct the chat history
|
|
285
|
-
const sortedMessages = [...assistantMessages, ...userMessages].sort((a, b) => new Date(a[0].createdAt).getTime() - new Date(b[0].createdAt).getTime());
|
|
286
|
-
return { responses, userEvents, suggestions, messages: sortedMessages };
|
|
287
|
-
};
|
|
288
|
-
/**
|
|
289
|
-
*
|
|
290
|
-
* @param payload
|
|
291
|
-
* @returns
|
|
292
|
-
*/
|
|
293
|
-
CommerceApiClient.isSupportedEvent = async (payload) => {
|
|
294
|
-
try {
|
|
295
|
-
const rawResponse = await _a.getInstance().inferenceApi.v1SupportedEventPostRaw({
|
|
296
|
-
SupportedEventRequest: coreSupportedEventRequestToApiRequest(payload),
|
|
297
|
-
});
|
|
298
|
-
// Get the actual HTTP response JSON
|
|
299
|
-
const httpResponseText = await rawResponse.raw.text();
|
|
300
|
-
const httpResponseJson = JSON.parse(httpResponseText);
|
|
301
|
-
return {
|
|
302
|
-
...httpResponseJson,
|
|
303
|
-
numberOfReviews: httpResponseJson.num_of_reviews,
|
|
304
|
-
merchant_tags: httpResponseJson.merchant_tags || [],
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
catch (err) {
|
|
308
|
-
Logger.logError("Failed to get response for v1SupportedEventPost", {
|
|
309
|
-
err,
|
|
310
|
-
});
|
|
311
|
-
return {
|
|
312
|
-
supported: false,
|
|
313
|
-
ready: false,
|
|
314
|
-
category: undefined,
|
|
315
|
-
collections: [],
|
|
316
|
-
numberOfReviews: undefined,
|
|
317
|
-
top_category: undefined,
|
|
318
|
-
merchant_tags: [],
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
CommerceApiClient.identifyUser = async (spiffyUserId, merchantUserId, uaDetails) => {
|
|
323
|
-
try {
|
|
324
|
-
await _a.getInstance().defaultApi.v1AnalyticsIdentifyPost({
|
|
325
|
-
AnalyticsIdentifyRequest: {
|
|
326
|
-
user_id: spiffyUserId,
|
|
327
|
-
os_name: uaDetails.os,
|
|
328
|
-
os_version: uaDetails.osVersion,
|
|
329
|
-
platform: uaDetails.os,
|
|
330
|
-
device_id: uaDetails.deviceModel,
|
|
331
|
-
device_brand: uaDetails.deviceBrand,
|
|
332
|
-
device_manufacturer: uaDetails.deviceManufacturer,
|
|
333
|
-
device_model: uaDetails.deviceModel,
|
|
334
|
-
user_properties: {
|
|
335
|
-
cdp_user_id: merchantUserId,
|
|
336
|
-
browser: uaDetails.browser,
|
|
337
|
-
browser_version: uaDetails.browserVersion,
|
|
338
|
-
user_agent: uaDetails.userAgent,
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
catch (err) {
|
|
344
|
-
Logger.logError("Failed to identify user", err);
|
|
345
|
-
}
|
|
346
|
-
};
|
|
347
|
-
CommerceApiClient.mapContextSourceToV1OrgConfigGetSource = (source) => {
|
|
348
|
-
if (source === undefined)
|
|
349
|
-
return undefined;
|
|
350
|
-
switch (source) {
|
|
351
|
-
case ContextSourceEnum.Fork:
|
|
352
|
-
return V1OrgConfigGetSourceEnum.Fork;
|
|
353
|
-
case ContextSourceEnum.Playground:
|
|
354
|
-
return V1OrgConfigGetSourceEnum.Playground;
|
|
355
|
-
case ContextSourceEnum.App:
|
|
356
|
-
return V1OrgConfigGetSourceEnum.App;
|
|
357
|
-
case ContextSourceEnum.Test:
|
|
358
|
-
return V1OrgConfigGetSourceEnum.Test;
|
|
359
|
-
default: {
|
|
360
|
-
// This ensures that if new values are added to ContextSourceEnum, we catch it
|
|
361
|
-
const exhaustiveCheck = source;
|
|
362
|
-
return exhaustiveCheck;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
CommerceApiClient.getOrgConfig = async (user_id) => {
|
|
367
|
-
var _b;
|
|
368
|
-
try {
|
|
369
|
-
const atomStore = getAtomStore();
|
|
370
|
-
const reactAppName = atomStore.get(reactAppNameAtom);
|
|
371
|
-
const contextSource = atomStore.get(contextSourceAtom);
|
|
372
|
-
const featureFlagService = atomStore.get(featureFlagServiceAtom); // Get featureFlagService
|
|
373
|
-
const request = {
|
|
374
|
-
namespace: reactAppName,
|
|
375
|
-
user_id,
|
|
376
|
-
source: _a.mapContextSourceToV1OrgConfigGetSource(contextSource),
|
|
377
|
-
include_experiments: Object.values(ProductExperiment),
|
|
378
|
-
include_feature_gates: Object.entries(((_b = featureFlagService === null || featureFlagService === void 0 ? void 0 : featureFlagService.featureFlagService) === null || _b === void 0 ? void 0 : _b.getFeatureFlags()) || {})
|
|
379
|
-
.filter(([, isEnabled]) => isEnabled)
|
|
380
|
-
.map(([featureGateName]) => featureGateName), // Use featureFlagService
|
|
381
|
-
};
|
|
382
|
-
const response = await _a.getInstance().defaultApi.v1OrgConfigGet(request);
|
|
383
|
-
return validateOrgConfigResults(response);
|
|
384
|
-
}
|
|
385
|
-
catch (err) {
|
|
386
|
-
Logger.logError(`Failed to get org config`, err, { err });
|
|
387
|
-
return undefined;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
CommerceApiClient.addNoteToLatestConversation = async (spiffyUserId, email, customerServiceProvider) => {
|
|
391
|
-
Logger.logInfo(`addNoteToLatestConversation - user_id=${spiffyUserId} email=${email} customer_service_provider=${customerServiceProvider}`);
|
|
392
|
-
try {
|
|
393
|
-
await _a.getInstance().customerServiceApi.v1CustserviceAddNoteToLatestConversationPost({
|
|
394
|
-
AddNoteToLatestConversationRequest: {
|
|
395
|
-
spiffy_user_id: spiffyUserId,
|
|
396
|
-
email,
|
|
397
|
-
customer_service_provider: customerServiceProvider,
|
|
398
|
-
},
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
catch (err) {
|
|
402
|
-
Logger.logError("Failed to add note to latest conversation", { err });
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
CommerceApiClient.getCustomerServiceApi = () => _a.getInstance().customerServiceApi;
|
|
406
|
-
export default CommerceApiClient;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
class Logger {
|
|
3
|
-
static logInfo(message, ...args) {
|
|
4
|
-
console.info(`INFO: ${message}`, ...args);
|
|
5
|
-
}
|
|
6
|
-
static logDebug(message, ...args) {
|
|
7
|
-
console.debug(`DEBUG: ${message}`, ...args);
|
|
8
|
-
}
|
|
9
|
-
static logError(message, error, ...args) {
|
|
10
|
-
console.error(`ERROR: ${message} error=${error}`, args);
|
|
11
|
-
}
|
|
12
|
-
static logWarn(message, error, ...args) {
|
|
13
|
-
console.warn(`WARN: ${message} error=${error}`, args);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export default Logger;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { configVersion } from '../../../../util/configVersion';
|
|
2
|
-
const getMerchantColorsQuery = () => `
|
|
3
|
-
query ($version: "${configVersion()}") {
|
|
4
|
-
me {
|
|
5
|
-
getProductsConfigByVersion(version: $version) {
|
|
6
|
-
colors {
|
|
7
|
-
values
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
`;
|
|
13
|
-
export { getMerchantColorsQuery };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { configVersion } from '../../../../util/configVersion';
|
|
2
|
-
const getMerchantFrontendConfigQuery = () => `
|
|
3
|
-
query ($version: "${configVersion()}") {
|
|
4
|
-
me {
|
|
5
|
-
getProductsConfigByVersion(version: $version) {
|
|
6
|
-
frontend {
|
|
7
|
-
values
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
`;
|
|
13
|
-
export { getMerchantFrontendConfigQuery };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from './isApiPDPEventAttributes';
|
|
2
|
-
export * from './isApiQueryTypedEventAttributes';
|
|
3
|
-
export * from './isApiResponse';
|
|
4
|
-
export * from './isApiProductResponseAttributes';
|
|
5
|
-
export * from './isApiReviewResponseAttributes';
|
|
6
|
-
export * from './isApiReviewRichInformation';
|
|
7
|
-
export * from './isApiSearchEventAttributes';
|
|
8
|
-
export * from './isApiSuggestion';
|
|
9
|
-
export * from './isApiSuggestionClickedEventAttributes';
|
|
10
|
-
export * from './isApiTextResponseAttributes';
|
|
11
|
-
export * from './isApiUserEvent';
|
|
12
|
-
export * from './isApiProductSearchAttributes';
|