@envive-ai/react-hooks 0.2.5 → 0.2.6-alpha
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-CDe6oRn4.cjs +41 -0
- package/dist/AmplitudeOperations-zFjk1Mkm.js +34 -0
- package/dist/{NewOrgConfig-B98Y9tMb.js → NewOrgConfig-ChNJ3ZtC.js} +2 -2
- package/dist/{NewOrgConfig-ZbBKiByQ.cjs → NewOrgConfig-KHz61ikr.cjs} +2 -2
- package/dist/TrackComponentVisibleEvent-f8ahqV1g.js +53 -0
- package/dist/TrackComponentVisibleEvent-uEzgBXb9.cjs +60 -0
- package/dist/amplitudeContext-CRFxGj_x.d.ts +52 -0
- package/dist/amplitudeContext-ZkerrMUa.d.cts +52 -0
- package/dist/api-1-73JxnF.js +166 -0
- package/dist/api-ZNG6wObS.cjs +239 -0
- package/dist/application/models/graphql/index.cjs +3 -3
- package/dist/application/models/graphql/index.d.cts +2 -2
- package/dist/application/models/graphql/index.d.ts +2 -2
- package/dist/application/models/graphql/index.js +2 -3
- package/dist/application/models/guards/api/index.cjs +3 -3
- package/dist/application/models/guards/api/index.d.cts +2 -2
- package/dist/application/models/guards/api/index.d.ts +2 -2
- package/dist/application/models/guards/api/index.js +3 -3
- package/dist/application/models/guards/utils.cjs +1 -1
- package/dist/application/models/guards/utils.d.ts +1 -1
- package/dist/application/models/guards/utils.js +1 -1
- package/dist/application/models/index.cjs +7 -23
- package/dist/application/models/index.d.cts +167 -11
- package/dist/application/models/index.d.ts +168 -12
- package/dist/application/models/index.js +7 -11
- package/dist/application/utils/index.cjs +19 -19
- package/dist/application/utils/index.d.cts +14 -63
- package/dist/application/utils/index.d.ts +16 -65
- package/dist/application/utils/index.js +19 -19
- package/dist/{atomStore-DXTVqiKc.js → atomStore-DAQvNPkh.js} +1 -1
- package/dist/{atomStore-DNji91Im.cjs → atomStore-DD9g7Zw2.cjs} +1 -1
- package/dist/atoms/app/index.cjs +19 -19
- package/dist/atoms/app/index.d.cts +9 -20
- package/dist/atoms/app/index.d.ts +8 -19
- package/dist/atoms/app/index.js +19 -19
- package/dist/atoms/atomStore/index.cjs +1 -1
- package/dist/atoms/atomStore/index.js +1 -1
- package/dist/atoms/chat/index.cjs +21 -21
- package/dist/atoms/chat/index.d.cts +37 -45
- package/dist/atoms/chat/index.d.ts +35 -43
- package/dist/atoms/chat/index.js +21 -21
- package/dist/atoms/globalSearch/index.cjs +1 -1
- package/dist/atoms/globalSearch/index.d.cts +1 -1
- package/dist/atoms/globalSearch/index.d.ts +5 -5
- package/dist/atoms/globalSearch/index.js +1 -1
- package/dist/atoms/org/index.cjs +10 -11
- package/dist/atoms/org/index.d.cts +19 -31
- package/dist/atoms/org/index.d.ts +19 -31
- package/dist/atoms/org/index.js +2 -3
- package/dist/atoms/search/index.cjs +7 -47
- package/dist/atoms/search/index.d.cts +76 -14
- package/dist/atoms/search/index.d.ts +76 -14
- package/dist/atoms/search/index.js +7 -29
- package/dist/atoms/search/utils.cjs +1 -1
- package/dist/atoms/search/utils.d.cts +1 -1
- package/dist/atoms/search/utils.d.ts +1 -1
- package/dist/atoms/search/utils.js +1 -1
- package/dist/cdnContext-BLNiW2HT.cjs +53 -0
- package/dist/cdnContext-DT6J5nCw.js +38 -0
- package/dist/chat-C0cgfkL8.js +230 -0
- package/dist/chat-DULmjtx1.cjs +330 -0
- package/dist/chatState-BrSfXIV4.cjs +120 -0
- package/dist/chatState-Cn8JGAlH.js +34 -0
- package/dist/config/index.d.cts +4 -4
- package/dist/config/index.d.ts +4 -4
- package/dist/config/locators/components/chat/index.d.cts +1 -1
- package/dist/config/locators/components/chat/index.d.ts +1 -1
- package/dist/config/locators/components/chat/variants/index.d.cts +1 -1
- package/dist/config/locators/components/chat/variants/index.d.ts +1 -1
- package/dist/config/locators/components/common/index.d.cts +1 -1
- package/dist/config/locators/components/common/index.d.ts +1 -1
- package/dist/config/locators/components/index.d.cts +1 -1
- package/dist/config/locators/components/index.d.ts +1 -1
- package/dist/config/locators/components/search/index.d.cts +1 -1
- package/dist/config/locators/components/search/index.d.ts +1 -1
- package/dist/config/locators/index.d.cts +4 -4
- package/dist/config/locators/index.d.ts +4 -4
- package/dist/contexts/amplitudeContext/index.cjs +19 -19
- package/dist/contexts/amplitudeContext/index.d.cts +1 -1
- package/dist/contexts/amplitudeContext/index.d.ts +1 -1
- package/dist/contexts/amplitudeContext/index.js +19 -19
- package/dist/contexts/cdnContext/index.cjs +4 -4
- package/dist/contexts/cdnContext/index.d.cts +2 -6
- package/dist/contexts/cdnContext/index.d.ts +2 -6
- package/dist/contexts/cdnContext/index.js +4 -4
- package/dist/contexts/enviveConfigContext/index.cjs +4 -4
- package/dist/contexts/enviveConfigContext/index.d.cts +3 -24
- package/dist/contexts/enviveConfigContext/index.d.ts +3 -24
- package/dist/contexts/enviveConfigContext/index.js +4 -4
- package/dist/contexts/enviveCssContext/index.cjs +15 -19
- package/dist/contexts/enviveCssContext/index.d.cts +3 -5
- package/dist/contexts/enviveCssContext/index.d.ts +3 -5
- package/dist/contexts/enviveCssContext/index.js +15 -19
- package/dist/contexts/featureFlagContext/index.cjs +9 -10
- package/dist/contexts/featureFlagContext/index.d.cts +3 -11
- package/dist/contexts/featureFlagContext/index.d.ts +3 -11
- package/dist/contexts/featureFlagContext/index.js +6 -7
- package/dist/contexts/featureFlagServiceContext/index.cjs +4 -3
- package/dist/contexts/featureFlagServiceContext/index.d.cts +1 -4
- package/dist/contexts/featureFlagServiceContext/index.d.ts +1 -4
- package/dist/contexts/featureFlagServiceContext/index.js +4 -3
- package/dist/contexts/graphqlContext/index.cjs +8 -13
- package/dist/contexts/graphqlContext/index.d.cts +11 -14
- package/dist/contexts/graphqlContext/index.d.ts +11 -14
- package/dist/contexts/graphqlContext/index.js +8 -13
- package/dist/contexts/localStorageContext/index.cjs +3 -3
- package/dist/contexts/localStorageContext/index.d.cts +3 -22
- package/dist/contexts/localStorageContext/index.d.ts +3 -22
- package/dist/contexts/localStorageContext/index.js +4 -3
- package/dist/contexts/newOrgConfigContext/index.cjs +13 -17
- package/dist/contexts/newOrgConfigContext/index.d.cts +12 -15
- package/dist/contexts/newOrgConfigContext/index.d.ts +12 -15
- package/dist/contexts/newOrgConfigContext/index.js +13 -17
- package/dist/contexts/searchContext/index.cjs +24 -24
- package/dist/contexts/searchContext/index.d.cts +2 -7
- package/dist/contexts/searchContext/index.d.ts +2 -7
- package/dist/contexts/searchContext/index.js +24 -24
- package/dist/contexts/sessionStorageContext/index.cjs +2 -2
- package/dist/contexts/sessionStorageContext/index.d.cts +2 -6
- package/dist/contexts/sessionStorageContext/index.d.ts +2 -6
- package/dist/contexts/sessionStorageContext/index.js +2 -2
- package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
- package/dist/contexts/shopifyUrlContext/index.d.cts +2 -11
- package/dist/contexts/shopifyUrlContext/index.d.ts +2 -11
- package/dist/contexts/shopifyUrlContext/index.js +2 -2
- package/dist/contexts/systemSettingsContext/index.cjs +4 -4
- package/dist/contexts/systemSettingsContext/index.d.cts +6 -16
- package/dist/contexts/systemSettingsContext/index.d.ts +4 -14
- package/dist/contexts/systemSettingsContext/index.js +4 -4
- package/dist/contexts/userIdentityContext/index.cjs +19 -19
- package/dist/contexts/userIdentityContext/index.d.cts +11 -2
- package/dist/contexts/userIdentityContext/index.d.ts +11 -2
- package/dist/contexts/userIdentityContext/index.js +19 -19
- package/dist/dist-BZX_Mgfn.cjs +6019 -0
- package/dist/dist-CIM4YRqp.js +5923 -0
- package/dist/domObserver-DKcas6tl.js +285 -0
- package/dist/{domObserver-v9ODTyfT.js → domObserver-Do6RAJdf.cjs} +23 -4
- package/dist/enviveConfig-DaotBKMS.cjs +130 -0
- package/dist/enviveConfig-DrvYlCYG.js +62 -0
- package/dist/enviveConfigContext--89ejDs5.cjs +60 -0
- package/dist/enviveConfigContext-BCnzgk4M.js +45 -0
- package/dist/events/index.cjs +2 -3
- package/dist/events/index.d.cts +2 -15
- package/dist/events/index.d.ts +2 -15
- package/dist/events/index.js +2 -2
- package/dist/events-CgFGtanE.cjs +69 -0
- package/dist/events-WOOrnUAx.js +63 -0
- package/dist/exceptions/index.cjs +4 -0
- package/dist/exceptions/index.d.cts +12 -0
- package/dist/exceptions/index.d.ts +12 -0
- package/dist/exceptions/index.js +3 -0
- package/dist/exceptions-BiSWJEl2.cjs +32 -0
- package/dist/exceptions-DSv0ZaH0.js +20 -0
- package/dist/featureFlagServiceContext-B7je7VZV.d.cts +24 -0
- package/dist/featureFlagServiceContext-BztKnBPk.cjs +66 -0
- package/dist/featureFlagServiceContext-DpdlcjNb.js +46 -0
- package/dist/featureFlagServiceContext-ahy3jou0.d.ts +24 -0
- package/dist/{globalSearch-FBk2epe8.cjs → globalSearch-Cpc8egsM.cjs} +1 -1
- package/dist/{globalSearch-Ccxq8hNF.js → globalSearch-nmrfGLOn.js} +1 -1
- package/dist/graphql-CWNkUHFV.js +46 -0
- package/dist/graphql-DT-H-lta.cjs +70 -0
- package/dist/graphqlContext-B181y-sa.cjs +111 -0
- package/dist/graphqlContext-CWulFxxC.js +96 -0
- package/dist/hooks/AmplitudeOperations/index.cjs +21 -22
- package/dist/hooks/AmplitudeOperations/index.d.cts +2 -2
- package/dist/hooks/AmplitudeOperations/index.d.ts +2 -2
- package/dist/hooks/AmplitudeOperations/index.js +20 -21
- package/dist/hooks/AppDetails/index.cjs +22 -22
- package/dist/hooks/AppDetails/index.d.cts +3 -23
- package/dist/hooks/AppDetails/index.d.ts +3 -23
- package/dist/hooks/AppDetails/index.js +22 -22
- package/dist/hooks/CdnOperations/index.cjs +4 -4
- package/dist/hooks/CdnOperations/index.js +4 -4
- package/dist/hooks/ChatToggle/index.cjs +24 -24
- package/dist/hooks/ChatToggle/index.d.cts +2 -2
- package/dist/hooks/ChatToggle/index.d.ts +2 -2
- package/dist/hooks/ChatToggle/index.js +22 -22
- package/dist/hooks/ChatToggleAnalytics/index.cjs +23 -24
- package/dist/hooks/ChatToggleAnalytics/index.d.cts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.d.ts +2 -2
- package/dist/hooks/ChatToggleAnalytics/index.js +22 -23
- package/dist/hooks/CustomerSupportHandoff/index.cjs +2 -2
- package/dist/hooks/CustomerSupportHandoff/index.js +2 -2
- package/dist/hooks/Debounce/index.cjs +20 -2
- package/dist/hooks/Debounce/index.js +18 -2
- package/dist/hooks/ElementObserver/index.cjs +4 -6
- package/dist/hooks/ElementObserver/index.d.cts +4 -25
- package/dist/hooks/ElementObserver/index.d.ts +4 -25
- package/dist/hooks/ElementObserver/index.js +4 -6
- package/dist/hooks/GrabAndScroll/index.cjs +1 -1
- package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
- package/dist/hooks/GrabAndScroll/index.js +1 -1
- package/dist/hooks/GraphQLConfig/index.cjs +9 -14
- package/dist/hooks/GraphQLConfig/index.d.cts +2 -13
- package/dist/hooks/GraphQLConfig/index.d.ts +2 -13
- package/dist/hooks/GraphQLConfig/index.js +9 -14
- package/dist/hooks/IdentifyUser/index.cjs +19 -19
- package/dist/hooks/IdentifyUser/index.js +19 -19
- package/dist/hooks/ImageResolver/index.cjs +20 -29
- package/dist/hooks/ImageResolver/index.js +20 -29
- package/dist/hooks/Intersection/index.cjs +1 -1
- package/dist/hooks/Intersection/index.js +1 -1
- package/dist/hooks/LocalStorageOperations/index.cjs +8 -7
- package/dist/hooks/LocalStorageOperations/index.js +4 -3
- package/dist/hooks/MessageFilter/index.cjs +3 -12
- package/dist/hooks/MessageFilter/index.d.cts +2 -17
- package/dist/hooks/MessageFilter/index.d.ts +2 -17
- package/dist/hooks/MessageFilter/index.js +2 -11
- package/dist/hooks/NewOrgConfig/index.cjs +14 -18
- package/dist/hooks/NewOrgConfig/index.d.cts +3 -16
- package/dist/hooks/NewOrgConfig/index.d.ts +3 -16
- package/dist/hooks/NewOrgConfig/index.js +14 -18
- package/dist/hooks/Search/index.cjs +332 -167
- package/dist/hooks/Search/index.d.cts +3 -57
- package/dist/hooks/Search/index.d.ts +3 -57
- package/dist/hooks/Search/index.js +320 -156
- package/dist/hooks/SearchOperations/index.cjs +25 -25
- package/dist/hooks/SearchOperations/index.d.cts +2 -3
- package/dist/hooks/SearchOperations/index.d.ts +2 -3
- package/dist/hooks/SearchOperations/index.js +25 -25
- package/dist/hooks/SessionStorageOperations/index.cjs +2 -2
- package/dist/hooks/SessionStorageOperations/index.js +2 -2
- package/dist/hooks/ShopifyUrlOperations/index.cjs +3 -3
- package/dist/hooks/ShopifyUrlOperations/index.d.cts +3 -5
- package/dist/hooks/ShopifyUrlOperations/index.d.ts +3 -5
- package/dist/hooks/ShopifyUrlOperations/index.js +3 -3
- package/dist/hooks/SnapCalculator/index.cjs +1 -1
- package/dist/hooks/SnapCalculator/index.d.cts +4 -3
- package/dist/hooks/SnapCalculator/index.d.ts +4 -3
- package/dist/hooks/SnapCalculator/index.js +1 -1
- package/dist/hooks/SystemSettingsContext/index.cjs +17 -6
- package/dist/hooks/SystemSettingsContext/index.d.cts +5 -15
- package/dist/hooks/SystemSettingsContext/index.d.ts +5 -15
- package/dist/hooks/SystemSettingsContext/index.js +15 -6
- package/dist/hooks/TrackComponentVisibleEvent/index.cjs +21 -21
- package/dist/hooks/TrackComponentVisibleEvent/index.d.cts +2 -3
- package/dist/hooks/TrackComponentVisibleEvent/index.d.ts +2 -3
- package/dist/hooks/TrackComponentVisibleEvent/index.js +21 -21
- package/dist/hooks/UpdateAnalyticsProps/index.cjs +21 -21
- package/dist/hooks/UpdateAnalyticsProps/index.js +20 -20
- package/dist/hooks/utils.d.cts +20 -13
- package/dist/hooks/utils.d.ts +20 -13
- package/dist/{index-LTdMHOxj.d.ts → index-B4cSHxVN.d.ts} +1 -1
- package/dist/{index-DzbkQtaK.d.cts → index-BQpWG3Jm.d.cts} +1 -1
- package/dist/index-BVZbvpx_.d.cts +11 -0
- package/dist/index-CEmUfoZa.d.ts +42 -0
- package/dist/index-CMZcE7pk.d.cts +224 -0
- package/dist/{index-DBqgBV9N.d.ts → index-CYGpI6hE.d.ts} +1 -1
- package/dist/{index-9NE86em3.d.cts → index-ClVBVK15.d.cts} +1 -1
- package/dist/{index-nDWHlouq.d.ts → index-Clf4wYaJ.d.ts} +1 -1
- package/dist/index-DeQte6mb.d.ts +11 -0
- package/dist/index-Dzv6WwSZ.d.ts +224 -0
- package/dist/{index-FQjyuD3D.d.cts → index-ca7Qn8o0.d.cts} +1 -1
- package/dist/{index-DHgVW8ey.d.ts → index-dngXrfnT.d.ts} +1 -1
- package/dist/index-qOBU4GEh.d.cts +42 -0
- package/dist/{index-Da1s8h5C.d.cts → index-w64il54a.d.cts} +1 -1
- package/dist/interceptors/index.cjs +28 -3
- package/dist/interceptors/index.d.cts +4 -15
- package/dist/interceptors/index.d.ts +4 -15
- package/dist/interceptors/index.js +25 -3
- package/dist/localStorageContext-DSpmlfyr.js +90 -0
- package/dist/localStorageContext-DbWl7Row.cjs +104 -0
- package/dist/{logger-TBIl4uIH.cjs → logger-BF6iGSVd.cjs} +1 -1
- package/dist/{logger-W3lqg-4b.js → logger-DCs3_11o.js} +1 -1
- package/dist/models-158fyHt9.cjs +1305 -0
- package/dist/models-DEJUuKYQ.js +1118 -0
- package/dist/newOrgConfigAtom-BuQE_zPK.js +8 -0
- package/dist/{newOrgConfigAtom-A4BEeHMf.cjs → newOrgConfigAtom-rrYHmp1b.cjs} +1 -1
- package/dist/newOrgConfigContext-BVrzYatq.cjs +68 -0
- package/dist/newOrgConfigContext-C0LzIRJ7.js +53 -0
- package/dist/nodeSelector-CbWcUbuc.d.ts +28 -0
- package/dist/nodeSelector-Cj-Xl1LP.d.cts +28 -0
- package/dist/org-CVjyv-gv.cjs +111 -0
- package/dist/org-Ct9Vjv1J.js +32 -0
- package/dist/search-C0TAcTeY.cjs +312 -0
- package/dist/search-DLHzcbfP.js +233 -0
- package/dist/searchContext-Dmtue5QO.js +129 -0
- package/dist/searchContext-l_23fiuP.cjs +145 -0
- package/dist/searchServiceAdapter-B0h7psvh.js +16 -0
- package/dist/searchServiceAdapter-BclWy4fE.cjs +34 -0
- package/dist/sessionStorageContext-BOyr7mIM.cjs +66 -0
- package/dist/sessionStorageContext-ClXN9eX4.js +52 -0
- package/dist/shopifyUrlContext-G9eqIcsL.cjs +75 -0
- package/dist/shopifyUrlContext-WAm0pnPh.js +61 -0
- package/dist/src/application/commerce-api.js +406 -0
- package/dist/src/application/logging/logger.js +16 -0
- package/dist/src/application/models/graphql/index.js +3 -0
- package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +13 -0
- package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +13 -0
- package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +10 -0
- package/dist/src/application/models/guards/api/index.js +12 -0
- package/dist/src/application/models/guards/api/isApiFormResponse.js +59 -0
- package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +22 -0
- package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +91 -0
- package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +188 -0
- package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +115 -0
- package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +16 -0
- package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +26 -0
- package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +15 -0
- package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +65 -0
- package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +15 -0
- package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +10 -0
- package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +4 -0
- package/dist/src/application/models/guards/api/isApiResponse.js +33 -0
- package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +22 -0
- package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +23 -0
- package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +20 -0
- package/dist/src/application/models/guards/api/isApiSuggestion.js +24 -0
- package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +4 -0
- package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +4 -0
- package/dist/src/application/models/guards/api/isApiUserEvent.js +18 -0
- package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +41 -0
- package/dist/src/application/models/guards/isBaseEcommerceEvent.js +14 -0
- package/dist/src/application/models/guards/isGA4EcommerceEvent.js +14 -0
- package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +14 -0
- package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +4 -0
- package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +1 -0
- package/dist/src/application/models/guards/isVariantInfo.js +28 -0
- package/dist/src/application/models/guards/utils.js +34 -0
- package/dist/src/application/models/index.js +34 -0
- package/dist/src/application/models/utils/snakeToCamelTransformer.js +71 -0
- package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +65 -0
- package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +9 -0
- package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +420 -0
- package/dist/src/application/models/validators/validateGraphQLOrgId.js +6 -0
- package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +9 -0
- package/dist/src/application/models/validators/validateOrgConfigResults.js +44 -0
- package/dist/src/application/models/validators/validateOrganizationConfig.js +34 -0
- package/dist/src/application/models/validators/validateResponse.js +173 -0
- package/dist/src/application/models/validators/validateSuggestion.js +13 -0
- package/dist/src/application/models/validators/validateUserEvent.js +91 -0
- package/dist/src/application/utils/analyticsUtils.js +94 -0
- package/dist/src/application/utils/coreContextToApiContext.js +8 -0
- package/dist/src/application/utils/coreUserEventToApiUserEvent.js +90 -0
- package/dist/src/application/utils/divideArray.js +7 -0
- package/dist/src/application/utils/domObserver.js +85 -0
- package/dist/src/application/utils/elementObserver.js +186 -0
- package/dist/src/application/utils/imageFilter.js +11 -0
- package/dist/src/application/utils/index.js +21 -0
- package/dist/src/application/utils/merchantUtils.js +15 -0
- package/dist/src/application/utils/messageFromFormSubmittedEvent.js +19 -0
- package/dist/src/application/utils/messageFromQueryEvent.js +35 -0
- package/dist/src/application/utils/messageFromResponse.js +123 -0
- package/dist/src/application/utils/messageFromSuggestionEvent.js +27 -0
- package/dist/src/application/utils/mouseEventTypes.js +1 -0
- package/dist/src/application/utils/mutationHelper.js +33 -0
- package/dist/src/application/utils/nextMessageRequestToApiRequest.js +29 -0
- package/dist/src/application/utils/nodeSelector.js +101 -0
- package/dist/src/application/utils/overrides.js +144 -0
- package/dist/src/application/utils/stringUtils.js +47 -0
- package/dist/src/application/utils/supportedEventRequestToApiRequest.js +7 -0
- package/dist/src/application/utils/urlsParser.js +33 -0
- package/dist/src/application/utils/validation.js +5 -0
- package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +4 -0
- package/dist/src/atoms/app/index.js +23 -0
- package/dist/src/atoms/app/variant.js +102 -0
- package/dist/src/atoms/atomStore/atomStore.js +28 -0
- package/dist/src/atoms/atomStore/index.js +1 -0
- package/dist/src/atoms/chat/chatState.js +33 -0
- package/dist/src/atoms/chat/form.js +16 -0
- package/dist/src/atoms/chat/index.js +23 -0
- package/dist/src/atoms/chat/lastMessage.js +10 -0
- package/dist/src/atoms/chat/messageQueue.js +68 -0
- package/dist/src/atoms/chat/performanceMetrics.js +70 -0
- package/dist/src/atoms/chat/renderedWidgetRefs.js +24 -0
- package/dist/src/atoms/chat/replies.js +43 -0
- package/dist/src/atoms/chat/suggestions.js +29 -0
- package/dist/src/atoms/envive/enviveConfig.js +67 -0
- package/dist/src/atoms/globalSearch/globalSearch.js +8 -0
- package/dist/src/atoms/globalSearch/index.js +1 -0
- package/dist/src/atoms/org/customerService.js +6 -0
- package/dist/src/atoms/org/graphqlConfig.js +8 -0
- package/dist/src/atoms/org/index.js +4 -0
- package/dist/src/atoms/org/newOrgConfigAtom.js +2 -0
- package/dist/src/atoms/org/orgAnalyticsConfig.js +8 -0
- package/dist/src/atoms/search/index.js +1 -0
- package/dist/src/atoms/search/productFilters.js +163 -0
- package/dist/src/atoms/search/productRetrievalAPI.js +50 -0
- package/dist/src/atoms/search/productRetrievalAdapter.js +14 -0
- package/dist/src/atoms/search/productSorter.js +13 -0
- package/dist/src/atoms/search/searchAPI.js +140 -0
- package/dist/src/atoms/search/searchServiceAdapter.js +14 -0
- package/dist/src/atoms/search/utils.js +15 -0
- package/dist/src/config/index.js +1 -0
- package/dist/src/config/locators/components/chat/entrypoints.js +10 -0
- package/dist/src/config/locators/components/chat/index.js +21 -0
- package/dist/src/config/locators/components/chat/preview.js +11 -0
- package/dist/src/config/locators/components/chat/variants/index.js +12 -0
- package/dist/src/config/locators/components/common/buttons.js +6 -0
- package/dist/src/config/locators/components/common/cards.js +17 -0
- package/dist/src/config/locators/components/common/index.js +4 -0
- package/dist/src/config/locators/components/common/links.js +1 -0
- package/dist/src/config/locators/components/common/tables.js +1 -0
- package/dist/src/config/locators/components/floating-button.js +2 -0
- package/dist/src/config/locators/components/index.js +3 -0
- package/dist/src/config/locators/components/report-issue.js +13 -0
- package/dist/src/config/locators/components/search/index.js +5 -0
- package/dist/src/config/locators/components/shadow-dom.js +1 -0
- package/dist/src/config/locators/embedded.js +20 -0
- package/dist/src/config/locators/index.js +4 -0
- package/dist/src/contexts/amplitudeContext/amplitudeContext.js +292 -0
- package/dist/src/contexts/amplitudeContext/index.js +1 -0
- package/dist/src/contexts/cdnContext/cdnContext.js +28 -0
- package/dist/src/contexts/cdnContext/index.js +1 -0
- package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +37 -0
- package/dist/src/contexts/enviveConfigContext/index.js +1 -0
- package/dist/src/contexts/enviveCssContext/enviveCssContext.js +31 -0
- package/dist/src/contexts/enviveCssContext/index.js +1 -0
- package/dist/src/contexts/featureFlagContext/featureFlagContext.js +109 -0
- package/dist/src/contexts/featureFlagContext/index.js +1 -0
- package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +47 -0
- package/dist/src/contexts/featureFlagServiceContext/index.js +1 -0
- package/dist/src/contexts/graphqlContext/graphqlContext.js +87 -0
- package/dist/src/contexts/graphqlContext/index.js +1 -0
- package/dist/src/contexts/localStorageContext/index.js +1 -0
- package/dist/src/contexts/localStorageContext/localStorageContext.js +95 -0
- package/dist/src/contexts/newOrgConfigContext/index.js +1 -0
- package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +33 -0
- package/dist/src/contexts/searchContext/index.js +1 -0
- package/dist/src/contexts/searchContext/searchContext.js +131 -0
- package/dist/src/contexts/sessionStorageContext/index.js +1 -0
- package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +43 -0
- package/dist/src/contexts/shopifyUrlContext/index.js +1 -0
- package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +62 -0
- package/dist/src/contexts/systemSettingsContext/index.js +1 -0
- package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +29 -0
- package/dist/src/contexts/userIdentityContext/index.js +1 -0
- package/dist/src/contexts/userIdentityContext/userIdentityContext.js +118 -0
- package/dist/src/events/index.js +51 -0
- package/dist/src/events/registerAnalyticsListeners.js +32 -0
- package/dist/src/exceptions/index.js +2 -0
- package/dist/src/exceptions/sessionExceptions.js +6 -0
- package/dist/src/exceptions/unsupportedProductExceptions.js +6 -0
- package/dist/src/hooks/AmplitudeOperations/index.js +1 -0
- package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +24 -0
- package/dist/src/hooks/AppDetails/index.js +1 -0
- package/dist/src/hooks/AppDetails/useAppDetails.js +26 -0
- package/dist/src/hooks/BlockBackButton/index.js +1 -0
- package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +23 -0
- package/dist/src/hooks/CdnOperations/index.js +1 -0
- package/dist/src/hooks/CdnOperations/useCdnOperations.js +13 -0
- package/dist/src/hooks/ChatToggle/index.js +1 -0
- package/dist/src/hooks/ChatToggle/useChatToggle.js +50 -0
- package/dist/src/hooks/ChatToggleAnalytics/index.js +1 -0
- package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +11 -0
- package/dist/src/hooks/CustomerSupportHandoff/index.js +1 -0
- package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +32 -0
- package/dist/src/hooks/Debounce/index.js +1 -0
- package/dist/src/hooks/Debounce/useDebounce.js +13 -0
- package/dist/src/hooks/ElementObserver/index.js +1 -0
- package/dist/src/hooks/ElementObserver/useElementObserver.js +208 -0
- package/dist/src/hooks/GrabAndScroll/index.js +1 -0
- package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +105 -0
- package/dist/src/hooks/GraphQLConfig/index.js +1 -0
- package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +54 -0
- package/dist/src/hooks/IdentifyUser/index.js +1 -0
- package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +28 -0
- package/dist/src/hooks/ImageResolver/index.js +1 -0
- package/dist/src/hooks/ImageResolver/useImageResolver.js +45 -0
- package/dist/src/hooks/Intersection/index.js +1 -0
- package/dist/src/hooks/Intersection/useIntersection.js +20 -0
- package/dist/src/hooks/IsSmallScreen/index.js +1 -0
- package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +16 -0
- package/dist/src/hooks/LocalStorageOperations/index.js +1 -0
- package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +64 -0
- package/dist/src/hooks/MessageFilter/index.js +1 -0
- package/dist/src/hooks/MessageFilter/useMessageFilter.js +37 -0
- package/dist/src/hooks/MessageScrollObserver/index.js +1 -0
- package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +35 -0
- package/dist/src/hooks/NewOrgConfig/index.js +1 -0
- package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +5 -0
- package/dist/src/hooks/Search/index.js +1 -0
- package/dist/src/hooks/Search/useRecommendedProducts.js +35 -0
- package/dist/src/hooks/Search/useSearch.js +224 -0
- package/dist/src/hooks/Search/useSearchInput.js +183 -0
- package/dist/src/hooks/SearchOperations/index.js +1 -0
- package/dist/src/hooks/SearchOperations/useSearchOperations.js +78 -0
- package/dist/src/hooks/SessionStorageOperations/index.js +1 -0
- package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +20 -0
- package/dist/src/hooks/ShopifyUrlOperations/index.js +1 -0
- package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +34 -0
- package/dist/src/hooks/SnapCalculator/index.js +1 -0
- package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +22 -0
- package/dist/src/hooks/SystemSettingsContext/index.js +1 -0
- package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +9 -0
- package/dist/src/hooks/TrackComponentVisibleEvent/index.js +1 -0
- package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +45 -0
- package/dist/src/hooks/UpdateAnalyticsProps/index.js +1 -0
- package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +43 -0
- package/dist/src/hooks/utils.js +116 -0
- package/dist/src/interceptors/index.js +1 -0
- package/dist/src/interceptors/useMessageInterceptor.js +24 -0
- package/dist/src/types/ApiResponse.js +1 -0
- package/dist/src/types/FilterAttribute.js +3 -0
- package/dist/src/types/Message.js +24 -0
- package/dist/src/types/Suggestion.js +3 -0
- package/dist/src/types/index.js +4 -0
- package/dist/src/util/colorVar.js +3 -0
- package/dist/src/util/configVersion.js +4 -0
- package/dist/src/util/domInsertion.js +16 -0
- package/dist/systemSettingsContext-Cb5kczBD.cjs +60 -0
- package/dist/systemSettingsContext-CksCdpiU.js +39 -0
- package/dist/types/index.cjs +3 -33
- package/dist/types/index.d.cts +2 -3
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.js +2 -30
- package/dist/types-18QXD2rd.cjs +39 -0
- package/dist/types-DQC1pHqD.js +27 -0
- package/dist/urlsParser-C-Vzs--G.cjs +78 -0
- package/dist/urlsParser-G7Ocwg0M.js +42 -0
- package/dist/useAppDetails-BJFRSYbI.js +30 -0
- package/dist/useAppDetails-Czn-5FzP.cjs +38 -0
- package/dist/useGraphQLConfig-BEtX5pDM.cjs +76 -0
- package/dist/useGraphQLConfig-Dkcrz1YL.js +63 -0
- package/dist/{useIntersection-BJRFGG0f.js → useIntersection-BWiHkpKL.js} +1 -1
- package/dist/{useIntersection-CYRvxtRN.cjs → useIntersection-DZHz44BY.cjs} +1 -1
- package/dist/{utils-DIvMgPe8.js → utils-CEKzBcN2.js} +1 -1
- package/dist/utils-CPvqOk0g.cjs +1546 -0
- package/dist/{utils-Buo4KU5l.cjs → utils-CqVRbvfN.cjs} +1 -1
- package/dist/{utils-CDw74BCO.cjs → utils-CsMbZmRw.cjs} +1 -1
- package/dist/{utils-BRNaQkCK.js → utils-DQhbbAnt.js} +1 -1
- package/dist/utils-D_kATUj6.js +1 -1
- package/dist/utils-N47VsL9W.js +1364 -0
- package/dist/utils-hYTjy7hJ.cjs +1 -1
- package/dist/{utils-DyTiotQz.d.ts → utils-wWki3L1d.d.ts} +1 -1
- package/package.json +7 -25
- package/src/application/commerce-api.ts +38 -37
- package/src/application/models/graphql/index.ts +1 -0
- package/src/application/models/graphql/queries/getMerchantColorsQuery.ts +1 -23
- package/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.ts +1 -89
- package/src/application/models/guards/api/isApiFormResponse.ts +4 -4
- package/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.ts +2 -2
- package/src/application/models/guards/api/isApiOrderResponseAttributes.ts +2 -20
- package/src/application/models/guards/api/isApiOrgConfigResults.ts +3 -9
- package/src/application/models/guards/api/isApiOrganizationConfig.ts +8 -32
- package/src/application/models/guards/api/isApiPDPEventAttributes.ts +8 -5
- package/src/application/models/guards/api/isApiPLPEventAttributes.ts +14 -10
- package/src/application/models/guards/api/isApiPageResponseAttributes.ts +1 -1
- package/src/application/models/guards/api/isApiProductResponseAttributes.ts +2 -4
- package/src/application/models/guards/api/isApiProductSearchAttributes.ts +9 -6
- package/src/application/models/guards/api/isApiProductSearchFilterAttributes.ts +7 -4
- package/src/application/models/guards/api/isApiQueryTypedEventAttributes.ts +8 -3
- package/src/application/models/guards/api/isApiResponse.ts +22 -15
- package/src/application/models/guards/api/isApiReviewResponseAttributes.ts +1 -1
- package/src/application/models/guards/api/isApiReviewRichInformation.ts +1 -1
- package/src/application/models/guards/api/isApiTextResponseAttributes.ts +1 -1
- package/src/application/models/guards/graphQL/isGraphQLColorsConfig.ts +1 -1
- package/src/application/models/guards/isBaseEcommerceEvent.ts +1 -2
- package/src/application/models/guards/isGA4EcommerceEvent.ts +1 -1
- package/src/application/models/guards/isLegacyUAEcommerceEvent.ts +1 -1
- package/src/application/models/guards/isMobilePLPChatPlacementParameter.ts +1 -3
- package/src/application/models/guards/isSpanxTakeAQuizCtaParameter.ts +5 -3
- package/src/application/models/guards/isVariantInfo.ts +6 -1
- package/src/application/models/index.ts +30 -95
- package/src/application/models/utils/snakeToCamelTransformer.ts +8 -8
- package/src/application/models/validators/validateGraphQLColorsConfig.ts +6 -2
- package/src/application/models/validators/validateGraphQLFrontendConfig.ts +6 -6
- package/src/application/models/validators/validateMobilePLPChatPlacementParameter.ts +5 -3
- package/src/application/models/validators/validateOrgConfigResults.ts +6 -5
- package/src/application/models/validators/validateOrganizationConfig.ts +11 -8
- package/src/application/models/validators/validateResponse.ts +66 -44
- package/src/application/models/validators/validateSuggestion.ts +1 -1
- package/src/application/models/validators/validateUserEvent.ts +23 -12
- package/src/application/utils/analyticsUtils.ts +16 -38
- package/src/application/utils/coreContextToApiContext.ts +3 -1
- package/src/application/utils/coreUserEventToApiUserEvent.ts +2 -2
- package/src/application/utils/elementObserver.ts +1 -1
- package/src/application/utils/imageFilter.ts +5 -2
- package/src/application/utils/index.ts +20 -21
- package/src/application/utils/messageFromFormSubmittedEvent.ts +1 -1
- package/src/application/utils/messageFromQueryEvent.ts +1 -1
- package/src/application/utils/messageFromResponse.ts +14 -10
- package/src/application/utils/messageFromSuggestionEvent.ts +6 -4
- package/src/application/utils/mouseEventTypes.ts +1 -1
- package/src/application/utils/nextMessageRequestToApiRequest.ts +1 -1
- package/src/application/utils/overrides.ts +1 -49
- package/src/application/utils/supportedEventRequestToApiRequest.ts +3 -1
- package/src/application/utils/urlsParser.ts +1 -7
- package/src/atoms/app/index.ts +15 -25
- package/src/atoms/app/variant.ts +1 -1
- package/src/atoms/chat/chatState.ts +9 -14
- package/src/atoms/chat/form.ts +1 -1
- package/src/atoms/chat/messageQueue.ts +25 -50
- package/src/atoms/chat/replies.ts +40 -43
- package/src/atoms/chat/suggestions.ts +34 -29
- package/src/atoms/envive/enviveConfig.ts +14 -20
- package/src/atoms/org/customerService.ts +4 -8
- package/src/atoms/org/graphqlConfig.ts +7 -15
- package/src/atoms/org/index.ts +4 -6
- package/src/atoms/org/newOrgConfigAtom.ts +2 -2
- package/src/atoms/org/orgAnalyticsConfig.ts +1 -1
- package/src/atoms/search/index.ts +0 -1
- package/src/atoms/search/productFilters.ts +72 -52
- package/src/atoms/search/productRetrievalAPI.ts +72 -0
- package/src/atoms/search/productRetrievalAdapter.ts +28 -0
- package/src/atoms/search/productSorter.ts +2 -2
- package/src/atoms/search/searchAPI.ts +42 -60
- package/src/atoms/search/searchServiceAdapter.ts +1 -1
- package/src/contexts/amplitudeContext/amplitudeContext.tsx +104 -143
- package/src/contexts/cdnContext/cdnContext.tsx +9 -16
- package/src/contexts/enviveConfigContext/enviveConfigContext.tsx +6 -27
- package/src/contexts/enviveCssContext/enviveCssContext.tsx +5 -12
- package/src/contexts/featureFlagContext/featureFlagContext.tsx +27 -48
- package/src/contexts/featureFlagServiceContext/featureFlagServiceContext.tsx +11 -3
- package/src/contexts/graphqlContext/graphqlContext.tsx +40 -95
- package/src/contexts/localStorageContext/localStorageContext.tsx +26 -60
- package/src/contexts/newOrgConfigContext/newOrgConfigContext.tsx +10 -22
- package/src/contexts/searchContext/searchContext.tsx +29 -49
- package/src/contexts/sessionStorageContext/sessionStorageContext.tsx +12 -33
- package/src/contexts/shopifyUrlContext/shopifyUrlContext.tsx +20 -37
- package/src/contexts/systemSettingsContext/systemSettingsContext.tsx +8 -21
- package/src/contexts/userIdentityContext/userIdentityContext.tsx +33 -77
- package/src/events/index.ts +8 -5
- package/src/events/registerAnalyticsListeners.ts +10 -13
- package/src/exceptions/index.ts +2 -0
- package/src/{types/exceptions → exceptions}/unsupportedProductExceptions.ts +2 -2
- package/src/global.d.ts +8 -0
- package/src/hooks/AmplitudeOperations/useAmplitudeOperations.ts +6 -11
- package/src/hooks/AppDetails/useAppDetails.ts +10 -24
- package/src/hooks/ChatToggle/useChatToggle.ts +7 -19
- package/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.ts +4 -4
- package/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.ts +1 -1
- package/src/hooks/ElementObserver/useElementObserver.ts +14 -32
- package/src/hooks/GrabAndScroll/useGrabAndScroll.ts +125 -124
- package/src/hooks/GraphQLConfig/useGraphQLConfig.ts +5 -7
- package/src/hooks/ImageResolver/useImageResolver.ts +24 -31
- package/src/hooks/LocalStorageOperations/useLocalStorageOperations.ts +12 -19
- package/src/hooks/MessageFilter/useMessageFilter.ts +1 -7
- package/src/hooks/Search/useRecommendedProducts.ts +50 -0
- package/src/hooks/Search/useSearch.tsx +80 -210
- package/src/hooks/Search/useSearchInput.ts +227 -0
- package/src/hooks/SearchOperations/useSearchOperations.ts +8 -12
- package/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.ts +8 -14
- package/src/hooks/SnapCalculator/useSnapCalculator.ts +1 -2
- package/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.ts +8 -11
- package/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.ts +11 -25
- package/src/hooks/utils.ts +19 -29
- package/src/interceptors/index.ts +1 -2
- package/src/interceptors/useMessageInterceptor.ts +10 -6
- package/src/{application/models/api/response.ts → types/ApiResponse.ts} +35 -29
- package/src/types/FilterAttribute.ts +35 -0
- package/src/{application/models/message.ts → types/Message.ts} +38 -34
- package/src/types/Suggestion.ts +6 -0
- package/src/types/index.ts +4 -4
- package/src/util/colorVar.ts +4 -0
- package/src/util/configVersion.ts +4 -0
- package/src/util/domInsertion.ts +17 -0
- package/dist/SystemSettingsContext-CO5c1L62.cjs +0 -20
- package/dist/SystemSettingsContext-CXmUlH8i.js +0 -13
- package/dist/TrackComponentVisibleEvent-B0WO3ArV.js +0 -52
- package/dist/TrackComponentVisibleEvent-LRE9MYzL.cjs +0 -59
- package/dist/amplitudeContext-B73xamNe.d.cts +0 -52
- package/dist/amplitudeContext-DXnJi0V1.d.ts +0 -52
- package/dist/api-BWSsazAG.js +0 -166
- package/dist/api-DeW6rHj3.cjs +0 -239
- package/dist/application/models/utilityTypes/index.cjs +0 -1
- package/dist/application/models/utilityTypes/index.d.cts +0 -2
- package/dist/application/models/utilityTypes/index.d.ts +0 -2
- package/dist/application/models/utilityTypes/index.js +0 -3
- package/dist/application/models/variantInfo/index.cjs +0 -3
- package/dist/application/models/variantInfo/index.d.cts +0 -2
- package/dist/application/models/variantInfo/index.d.ts +0 -2
- package/dist/application/models/variantInfo/index.js +0 -3
- package/dist/atoms/search/types.cjs +0 -5
- package/dist/atoms/search/types.d.cts +0 -2
- package/dist/atoms/search/types.d.ts +0 -2
- package/dist/atoms/search/types.js +0 -3
- package/dist/cdnContext-CH_-ssYa.js +0 -38
- package/dist/cdnContext-D7kHxOzE.cjs +0 -53
- package/dist/chat-CqPuT9_V.cjs +0 -393
- package/dist/chat-DH70QqJp.js +0 -257
- package/dist/chatElementDisplayLocation-BoE6DEdv.d.ts +0 -25
- package/dist/chatElementDisplayLocation-DWmfNX_u.d.cts +0 -25
- package/dist/chatSearch-BQCZI8MJ.cjs +0 -418
- package/dist/chatSearch-D8xCWU8m.js +0 -295
- package/dist/chatState-CcFtSqJT.cjs +0 -120
- package/dist/chatState-DKnNHmwe.js +0 -34
- package/dist/contexts/chatContext/index.cjs +0 -326
- package/dist/contexts/chatContext/index.d.cts +0 -15
- package/dist/contexts/chatContext/index.d.ts +0 -15
- package/dist/contexts/chatContext/index.js +0 -319
- package/dist/contexts/types.cjs +0 -7
- package/dist/contexts/types.d.cts +0 -4
- package/dist/contexts/types.d.ts +0 -4
- package/dist/contexts/types.js +0 -3
- package/dist/domObserver-Bqf3ooj8.cjs +0 -304
- package/dist/enviveConfig-DZBohDpc.js +0 -62
- package/dist/enviveConfig-Dv9-esGV.cjs +0 -130
- package/dist/enviveConfigContext-D2OELZDR.cjs +0 -60
- package/dist/enviveConfigContext-DrDjCems.js +0 -45
- package/dist/events-DYY4l817.cjs +0 -90
- package/dist/events-DyUix-Bn.js +0 -78
- package/dist/featureFlagServiceContext-CJyYItqu.cjs +0 -62
- package/dist/featureFlagServiceContext-C_2m4wPL.d.ts +0 -23
- package/dist/featureFlagServiceContext-CiKWV306.d.cts +0 -23
- package/dist/featureFlagServiceContext-FBM6DdMJ.js +0 -42
- package/dist/featureGates-KEwAL8p_.js +0 -26
- package/dist/featureGates-qU_ulhpC.cjs +0 -32
- package/dist/frontendConfig-CymUbclV.d.ts +0 -856
- package/dist/frontendConfig-tVg0hsWZ.d.cts +0 -856
- package/dist/graphql-3PxNRFOc.js +0 -36
- package/dist/graphql-DGYfelZp.cjs +0 -53
- package/dist/graphqlConfig-GHZ1UgCw.cjs +0 -73
- package/dist/graphqlConfig-mDg6J44N.js +0 -24
- package/dist/graphqlContext-BZPEAFSR.cjs +0 -111
- package/dist/graphqlContext-Bf3E-V2T.d.cts +0 -28
- package/dist/graphqlContext-CQikpV_I.d.ts +0 -28
- package/dist/graphqlContext-eaZPxgRE.js +0 -96
- package/dist/index-BVf069X-.d.ts +0 -184
- package/dist/index-B_KJB5L_.d.cts +0 -186
- package/dist/index-BkLv_fCu.d.ts +0 -186
- package/dist/index-Bmub8e38.d.cts +0 -98
- package/dist/index-C0eAp5f5.d.ts +0 -98
- package/dist/index-CESxqFso.d.cts +0 -228
- package/dist/index-CG3P8xE1.d.cts +0 -676
- package/dist/index-CJc7_j_v.d.ts +0 -44
- package/dist/index-CiWEYzXl.d.cts +0 -184
- package/dist/index-Cyq5HiC0.d.cts +0 -44
- package/dist/index-DL2ODEnw.d.ts +0 -1
- package/dist/index-DgjDuQl4.d.ts +0 -676
- package/dist/index-RcVcRKH7.d.cts +0 -1
- package/dist/index-vP8BKdxl.d.ts +0 -228
- package/dist/interceptors/types.cjs +0 -1
- package/dist/interceptors/types.d.cts +0 -13
- package/dist/interceptors/types.d.ts +0 -13
- package/dist/interceptors/types.js +0 -3
- package/dist/localStorageContext-BPZ82q-G.js +0 -95
- package/dist/localStorageContext-NRP-CdmF.cjs +0 -115
- package/dist/models-D-4db7XW.cjs +0 -1537
- package/dist/models-c86hYW-F.js +0 -1296
- package/dist/newOrgConfigAtom-OzAyrPS8.js +0 -8
- package/dist/newOrgConfigContext-DOdUxlOE.d.cts +0 -16
- package/dist/newOrgConfigContext-DX9iqIIK.cjs +0 -68
- package/dist/newOrgConfigContext-aqN8Tu79.js +0 -53
- package/dist/newOrgConfigContext-jphS5d4K.d.ts +0 -16
- package/dist/nodeSelector-B3bPtEjX.d.cts +0 -31
- package/dist/nodeSelector-Dcn3_NrZ.d.ts +0 -31
- package/dist/org-Bq2KsJSp.cjs +0 -43
- package/dist/org-gtWmGw4K.js +0 -12
- package/dist/search-BQPMtze5.cjs +0 -205
- package/dist/search-CIrqYYMI.d.ts +0 -20
- package/dist/search-PXzaYtZj.js +0 -126
- package/dist/search-filter-types-BhK20ts3.d.ts +0 -102
- package/dist/search-filter-types-BxaNSLs_.d.cts +0 -102
- package/dist/search-y-ioX5Mz.d.cts +0 -20
- package/dist/searchContext-CmsLR6Ka.cjs +0 -145
- package/dist/searchContext-NPfqMf6b.js +0 -129
- package/dist/searchServiceAdapter-BczodJGV.cjs +0 -34
- package/dist/searchServiceAdapter-BuEHFG5t.js +0 -16
- package/dist/sessionStorageContext-C1u04nAK.js +0 -52
- package/dist/sessionStorageContext-Cy8xc9-3.cjs +0 -66
- package/dist/shopifyUrlContext-CUyq3f27.cjs +0 -75
- package/dist/shopifyUrlContext-DTLlqlMj.js +0 -61
- package/dist/spiffyWidgets-BnkP5kXf.d.ts +0 -20
- package/dist/spiffyWidgets-BuS00VaQ.d.cts +0 -20
- package/dist/systemSettingsContext-Ba-wi2NZ.cjs +0 -60
- package/dist/systemSettingsContext-DumUaV0m.js +0 -39
- package/dist/test-types-DbrKQIqB.d.ts +0 -40
- package/dist/test-types-ThQiO_cc.d.cts +0 -40
- package/dist/types-BWzwd0Qc.js +0 -30
- package/dist/types-CEx2uKKS.d.ts +0 -51
- package/dist/types-CKMMb_gX.d.cts +0 -51
- package/dist/types-CKPddlfS.cjs +0 -0
- package/dist/types-CtUb63bt.js +0 -76
- package/dist/types-Cz8CaPUQ.cjs +0 -48
- package/dist/types-Dc6hx6ei.js +0 -1
- package/dist/types-Mwm0bS2l.d.ts +0 -10
- package/dist/types-UUvB6h05.cjs +0 -106
- package/dist/types-zQGBI-Yo.d.cts +0 -10
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +0 -15
- package/dist/types.d.ts +0 -15
- package/dist/types.js +0 -1
- package/dist/urlsParser-COzMdJaX.cjs +0 -78
- package/dist/urlsParser-DxjoLj98.js +0 -42
- package/dist/useAmplitudeOperations-Cv0fi3uj.cjs +0 -41
- package/dist/useAmplitudeOperations-Ti6phPPq.js +0 -34
- package/dist/useAppDetails-BgqbPlfR.cjs +0 -38
- package/dist/useAppDetails-DnKGYtCd.js +0 -30
- package/dist/useDebounce-BV7B-Jz3.js +0 -19
- package/dist/useDebounce-vU5iW5sa.cjs +0 -26
- package/dist/useGraphQLConfig-BizpCw23.cjs +0 -76
- package/dist/useGraphQLConfig-DFWl9Z89.js +0 -63
- package/dist/useMessageInterceptor-BjGP_uXm.js +0 -25
- package/dist/useMessageInterceptor-arAqUq1Q.cjs +0 -33
- package/dist/userIdentityContext-BvsEnQVX.d.ts +0 -20
- package/dist/userIdentityContext-D2oFVFzo.d.cts +0 -20
- package/dist/utilityTypes-B2KuRn37.js +0 -1
- package/dist/utilityTypes-BGbL2WTP.cjs +0 -0
- package/dist/utils-B7PAzB_M.d.cts +0 -22
- package/dist/utils-CLGXsOwE.cjs +0 -1591
- package/dist/utils-CrQ0h9tc.d.ts +0 -22
- package/dist/utils-jYtD3hmA.js +0 -1385
- package/dist/variantInfo-BfKlkaWU.js +0 -11
- package/dist/variantInfo-DpLn4nHz.cjs +0 -17
- package/src/application/models/api/context.ts +0 -4
- package/src/application/models/api/generationParams.ts +0 -4
- package/src/application/models/api/nextMessageRequest.ts +0 -11
- package/src/application/models/api/orgAnalyticsConfig.ts +0 -19
- package/src/application/models/api/orgConfigResults.ts +0 -44
- package/src/application/models/api/organizationConfig.ts +0 -12
- package/src/application/models/api/responseGenerics.ts +0 -67
- package/src/application/models/api/search.ts +0 -26
- package/src/application/models/api/suggestion.ts +0 -4
- package/src/application/models/api/supportedEventRequest.ts +0 -8
- package/src/application/models/api/userEvent.ts +0 -101
- package/src/application/models/cachedValue.ts +0 -8
- package/src/application/models/chatElementDisplayLocation.ts +0 -22
- package/src/application/models/clientDetails.ts +0 -18
- package/src/application/models/colorsConfig.ts +0 -28
- package/src/application/models/conversationalSearchIds.ts +0 -5
- package/src/application/models/dataLayer.ts +0 -45
- package/src/application/models/events.ts +0 -5
- package/src/application/models/featureGates.ts +0 -21
- package/src/application/models/frontendConfig.ts +0 -14
- package/src/application/models/googleAnalyticsEvents.ts +0 -8
- package/src/application/models/localStorageEventListener.ts +0 -4
- package/src/application/models/mobilePLPChatPlacementParameter.ts +0 -3
- package/src/application/models/orgsEnum.ts +0 -36
- package/src/application/models/productExperiment.ts +0 -5
- package/src/application/models/spanxTakeAQuizCtaParameter.ts +0 -4
- package/src/application/models/spiffyWidgets.ts +0 -16
- package/src/application/models/utilityTypes/camelCase.ts +0 -87
- package/src/application/models/utilityTypes/camelCasedPropertiesDeep.ts +0 -80
- package/src/application/models/utilityTypes/delimiterCase.ts +0 -121
- package/src/application/models/utilityTypes/delimiterCasedPropertiesDeep.ts +0 -98
- package/src/application/models/utilityTypes/index.ts +0 -1
- package/src/application/models/utilityTypes/internal.ts +0 -93
- package/src/application/models/utilityTypes/primitive.ts +0 -8
- package/src/application/models/utilityTypes/snakeCasedPropertiesDeep.ts +0 -49
- package/src/application/models/utilityTypes/splitWords.ts +0 -76
- package/src/application/models/utilityTypes/trim.ts +0 -28
- package/src/application/models/utilityTypes/unknownArray.ts +0 -25
- package/src/application/models/variantInfo/index.ts +0 -1
- package/src/application/models/variantInfo/pageVisitInfo.ts +0 -6
- package/src/application/models/variantInfo/plpInfo.ts +0 -3
- package/src/application/models/variantInfo/productInfo.ts +0 -5
- package/src/application/models/variantInfo/variantInfo.ts +0 -29
- package/src/application/utils/__tests__/divideArrays.test.ts +0 -14
- package/src/application/utils/cdnUtils.ts +0 -11
- package/src/atoms/search/chatSearch.ts +0 -317
- package/src/atoms/search/types.ts +0 -55
- package/src/config/divIds.ts +0 -27
- package/src/config/socialProofClasses.ts +0 -17
- package/src/contexts/chatContext/chatContext.tsx +0 -509
- package/src/contexts/chatContext/index.ts +0 -1
- package/src/contexts/types.ts +0 -1066
- package/src/events/event-types.ts +0 -11
- package/src/interceptors/types.ts +0 -6
- package/src/merchants/domInsertion.ts +0 -30
- package/src/merchants/gridInsertion.ts +0 -19
- package/src/types/config-versions.ts +0 -6
- package/src/types/customerService.ts +0 -31
- package/src/types/custservice-types.ts +0 -28
- package/src/types/search-filter-types.ts +0 -111
- package/src/types/suggestionBarV2-types.ts +0 -4
- package/src/types/test-types.ts +0 -3
- package/src/types.ts +0 -11
- /package/dist/{AmplitudeOperations-BEGeYKG5.cjs → featureFlagServiceContext-B4ash4vz.cjs} +0 -0
- /package/dist/{AmplitudeOperations-CWI4yjZ4.js → featureFlagServiceContext-bI7ZLz4r.js} +0 -0
- /package/src/{types/exceptions → exceptions}/sessionExceptions.ts +0 -0
|
@@ -0,0 +1,406 @@
|
|
|
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 };
|
|
@@ -0,0 +1,13 @@
|
|
|
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 };
|
|
@@ -0,0 +1,12 @@
|
|
|
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';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { FormType } from '@spiffy-ai/commerce-api-client';
|
|
2
|
+
import Logger from 'src/application/logging/logger';
|
|
3
|
+
import { hasPropertyOfType } from '../utils';
|
|
4
|
+
/**
|
|
5
|
+
* Type guard to check if the provided data has the all of the properties (with the correct types) of
|
|
6
|
+
* a FormResponseAttribute
|
|
7
|
+
*
|
|
8
|
+
* @param data - The data to check
|
|
9
|
+
*
|
|
10
|
+
* @returns true if the data has the correct properties, false otherwise
|
|
11
|
+
*/
|
|
12
|
+
export const isApiFormResponseAttributes = (data) => {
|
|
13
|
+
if (data == null || typeof data !== 'object') {
|
|
14
|
+
Logger.logError('isApiFormResponseAttributes: data is null or not an object', undefined, {
|
|
15
|
+
data,
|
|
16
|
+
});
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if ('form_category' in data && typeof data.form_category !== 'object') {
|
|
20
|
+
Logger.logError('isApiFormResponseAttributes: form_category is not an object', undefined, {
|
|
21
|
+
data,
|
|
22
|
+
});
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if ('form_category' in data && typeof data.form_category === 'object') {
|
|
26
|
+
if (!hasPropertyOfType(data.form_category, 'form_type', 'string') ||
|
|
27
|
+
!Object.values(FormType).includes(data.form_category.form_type)) {
|
|
28
|
+
Logger.logError('isApiFormResponseAttributes: form_type is missing or not a valid form type', undefined, {
|
|
29
|
+
data,
|
|
30
|
+
});
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!hasPropertyOfType(data, 'schema', 'object')) {
|
|
35
|
+
Logger.logError('isApiFormResponseAttributes: schema is missing or not an object', undefined, {
|
|
36
|
+
data,
|
|
37
|
+
});
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
// TODO: also wanna validate the fields of data.schema.properties but might wanna change the schema
|
|
41
|
+
// to not have the property name as a key in the object
|
|
42
|
+
if (!hasPropertyOfType(data.schema, 'properties', 'object')) {
|
|
43
|
+
Logger.logError('isApiFormResponseAttributes: schema.properties is missing or not an object', undefined, {
|
|
44
|
+
data,
|
|
45
|
+
});
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (!hasPropertyOfType(data.schema, 'required', 'array')) {
|
|
49
|
+
Logger.logError('isApiFormResponseAttributes: schema.required is missing or not an array', undefined, { data });
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
if (!data.schema.required.every((key) => typeof key === 'string' && key in data.schema.properties)) {
|
|
53
|
+
Logger.logError('isApiFormResponseAttributes: schema.required contains invalid property keys', undefined, {
|
|
54
|
+
data,
|
|
55
|
+
});
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FormType } from '@spiffy-ai/commerce-api-client';
|
|
2
|
+
import Logger from 'src/application/logging/logger';
|
|
3
|
+
import { hasPropertyOfType } from '../utils';
|
|
4
|
+
export const isApiFormSubmittedResponseAttributes = (data) => {
|
|
5
|
+
if (data == null || typeof data !== 'object') {
|
|
6
|
+
Logger.logError('isApiFormSubmittedResponseAttributes', 'data is null or not an object', data);
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (!hasPropertyOfType(data, 'filled_schema', 'object')) {
|
|
10
|
+
Logger.logError('isApiFormSubmittedResponseAttributes', 'filled_schema is not an object', data);
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
if (!hasPropertyOfType(data, 'form_response_id', 'string')) {
|
|
14
|
+
Logger.logError('isApiFormSubmittedResponseAttributes', 'form_response_id is not a string', data);
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (!('form_type' in data) || !Object.values(FormType).includes(data.form_type)) {
|
|
18
|
+
Logger.logError('isApiFormSubmittedResponseAttributes', 'form_type is not a valid form type enum', data);
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import Logger from 'src/application/logging/logger';
|
|
2
|
+
import { hasPropertyOfType } from '../utils';
|
|
3
|
+
const isApiOrderItemInfo = (data) => {
|
|
4
|
+
if (data == null || typeof data !== 'object') {
|
|
5
|
+
Logger.logError('OrderItemInfo must be an object', undefined, { data });
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (!hasPropertyOfType(data, 'order_item_id', 'string')) {
|
|
9
|
+
Logger.logError('OrderItemInfo must have an order_item_id property', undefined, { data });
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (!hasPropertyOfType(data, 'item_title', 'string')) {
|
|
13
|
+
Logger.logError('OrderItemInfo must have an item_title property', undefined, { data });
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (!hasPropertyOfType(data, 'item_price', 'number')) {
|
|
17
|
+
Logger.logError('OrderItemInfo must have an item_price property', undefined, { data });
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (!hasPropertyOfType(data, 'item_quantity', 'number')) {
|
|
21
|
+
Logger.logError('OrderItemInfo must have an item_quantity property', undefined, { data });
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (!hasPropertyOfType(data, 'image', 'string', true)) {
|
|
25
|
+
Logger.logError('OrderItemInfo.image must be a string or null', undefined, { data });
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (!hasPropertyOfType(data, 'fulfillment_display_status', 'string', true)) {
|
|
29
|
+
Logger.logError('OrderItemInfo.fulfillment_display_status must be a string or null', undefined, {
|
|
30
|
+
data,
|
|
31
|
+
});
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (!hasPropertyOfType(data, 'tracking_url', 'string', true)) {
|
|
35
|
+
Logger.logError('OrderItemInfo.tracking_url must be a string or null', undefined, { data });
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (!hasPropertyOfType(data, 'delivered_at', 'string', true)) {
|
|
39
|
+
Logger.logError('OrderItemInfo.delivered_at must be a string or null', undefined, { data });
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
if (!hasPropertyOfType(data, 'estimated_delivery_at', 'string', true)) {
|
|
43
|
+
Logger.logError('OrderItemInfo.estimated_delivery_at must be a string or null', undefined, {
|
|
44
|
+
data,
|
|
45
|
+
});
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (!hasPropertyOfType(data, 'in_transit_at', 'string', true)) {
|
|
49
|
+
Logger.logError('OrderItemInfo.in_transit_at must be a string or null', undefined, { data });
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
export const isApiOrderResponseAttributes = (data) => {
|
|
55
|
+
if (data == null || typeof data !== 'object') {
|
|
56
|
+
Logger.logError('Order response attributes must be an object', undefined, { data });
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (!hasPropertyOfType(data, 'created_at', 'string')) {
|
|
60
|
+
Logger.logError('Order response attributes must have a created_at property and have type string', undefined, {
|
|
61
|
+
data,
|
|
62
|
+
});
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
if (!hasPropertyOfType(data, 'latest_event_date', 'string')) {
|
|
66
|
+
Logger.logError('Order response attributes must have a latest_event_date property and have type string', undefined, {
|
|
67
|
+
data,
|
|
68
|
+
});
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
if (!hasPropertyOfType(data, 'line_items', 'array') ||
|
|
72
|
+
!data.line_items.every((item) => isApiOrderItemInfo(item))) {
|
|
73
|
+
Logger.logError('Order response attributes must have a line_items property with at least one order item', undefined, {
|
|
74
|
+
data,
|
|
75
|
+
});
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (!hasPropertyOfType(data, 'order_id', 'string')) {
|
|
79
|
+
Logger.logError('Order response attributes must have an order_id property and have type string', undefined, {
|
|
80
|
+
data,
|
|
81
|
+
});
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
if (!hasPropertyOfType(data, 'order_number', 'string')) {
|
|
85
|
+
Logger.logError('Order response attributes must have an order_number property and have type string', undefined, {
|
|
86
|
+
data,
|
|
87
|
+
});
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
};
|