@envive-ai/react-hooks 0.2.6-alpha-7 → 0.2.6-alpha-8

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.
Files changed (425) hide show
  1. package/dist/{AmplitudeOperations-DbUiR0N_.cjs → AmplitudeOperations-DgBejCXT.cjs} +2 -2
  2. package/dist/{AmplitudeOperations-DjqOM3uE.js → AmplitudeOperations-jbYI0Gt9.js} +2 -2
  3. package/dist/{NewOrgConfig-C_1T1iOt.js → NewOrgConfig-CUQGpmw9.js} +2 -2
  4. package/dist/{NewOrgConfig-D2Kvqa1z.cjs → NewOrgConfig-DD0oloeK.cjs} +2 -2
  5. package/dist/{TrackComponentVisibleEvent-BxOhr9Da.js → TrackComponentVisibleEvent-BTDRmqYu.js} +2 -2
  6. package/dist/{TrackComponentVisibleEvent-CDbecFPM.cjs → TrackComponentVisibleEvent-BmM2CED5.cjs} +2 -2
  7. package/dist/{amplitudeContext-BWmXliMI.cjs → amplitudeContext-BeKYPEAO.cjs} +9 -8
  8. package/dist/{amplitudeContext-BjMlg5RV.js → amplitudeContext-CfMnZGa7.js} +9 -8
  9. package/dist/{amplitudeTrackEventAtom-D66l5oFp.js → amplitudeTrackEventAtom-DXnFiWnV.js} +1 -1
  10. package/dist/{amplitudeTrackEventAtom-f22P2U0u.cjs → amplitudeTrackEventAtom-UVBKhOuI.cjs} +1 -1
  11. package/dist/{app-Bs2KxG_8.js → app-BT3g-mDp.js} +5 -5
  12. package/dist/{app-DSnDDqcW.cjs → app-DxwdFQlv.cjs} +5 -5
  13. package/dist/application/utils/index.cjs +4 -4
  14. package/dist/application/utils/index.d.cts +2 -2
  15. package/dist/application/utils/index.d.ts +2 -2
  16. package/dist/application/utils/index.js +4 -4
  17. package/dist/{atomStore-CfzCqWB9.js → atomStore-BuopbV9k.js} +1 -1
  18. package/dist/{atomStore-BQVO5haU.cjs → atomStore-CZKe3itM.cjs} +1 -1
  19. package/dist/atoms/app/index.cjs +9 -9
  20. package/dist/atoms/app/index.d.cts +6 -6
  21. package/dist/atoms/app/index.d.ts +7 -7
  22. package/dist/atoms/app/index.js +9 -9
  23. package/dist/atoms/atomStore/index.cjs +1 -1
  24. package/dist/atoms/atomStore/index.d.ts +1 -1
  25. package/dist/atoms/atomStore/index.js +1 -1
  26. package/dist/atoms/chat/index.cjs +12 -12
  27. package/dist/atoms/chat/index.d.cts +32 -32
  28. package/dist/atoms/chat/index.d.ts +27 -27
  29. package/dist/atoms/chat/index.js +12 -12
  30. package/dist/atoms/globalSearch/index.cjs +1 -1
  31. package/dist/atoms/globalSearch/index.d.cts +6 -6
  32. package/dist/atoms/globalSearch/index.d.ts +6 -6
  33. package/dist/atoms/globalSearch/index.js +1 -1
  34. package/dist/atoms/org/index.cjs +2 -2
  35. package/dist/atoms/org/index.d.cts +15 -15
  36. package/dist/atoms/org/index.d.ts +16 -16
  37. package/dist/atoms/org/index.js +2 -2
  38. package/dist/atoms/search/index.cjs +5 -5
  39. package/dist/atoms/search/index.d.cts +15 -15
  40. package/dist/atoms/search/index.d.ts +13 -13
  41. package/dist/atoms/search/index.js +5 -5
  42. package/dist/atoms/search/utils.cjs +1 -1
  43. package/dist/atoms/search/utils.d.ts +1 -1
  44. package/dist/atoms/search/utils.js +1 -1
  45. package/dist/{cdnContext-CJ2BNLAD.js → cdnContext-D-qi0lub.js} +2 -2
  46. package/dist/{cdnContext-lkC-AE6A.cjs → cdnContext-DIVgBnsl.cjs} +2 -2
  47. package/dist/{chat-CCjM6fS_.cjs → chat-CgF81Y5r.cjs} +5 -5
  48. package/dist/{chat-EJbfGWRr.js → chat-ClvJ9xEj.js} +1 -1
  49. package/dist/{chat-CJ9D8n7g.cjs → chat-DCGriB7h.cjs} +1 -1
  50. package/dist/{chat-C5afTKUY.js → chat-WdMVMjQh.js} +5 -5
  51. package/dist/{chatState-DlJpHAsW.cjs → chatState-B57-id1_.cjs} +1 -1
  52. package/dist/{chatState-BbI93m6r.js → chatState-DAP9YIWn.js} +1 -1
  53. package/dist/{common-CuwWqIJ1.cjs → common-DQPvV_S_.cjs} +1 -1
  54. package/dist/{common-Df2bwzd2.js → common-c_4eX0qn.js} +1 -1
  55. package/dist/{components-QGCWJ26c.js → components-CDpaMUjK.js} +1 -1
  56. package/dist/{components-BCfFLf9X.cjs → components-DKwVHIjq.cjs} +1 -1
  57. package/dist/config/index.cjs +4 -4
  58. package/dist/config/index.js +4 -4
  59. package/dist/config/locators/components/chat/index.cjs +1 -1
  60. package/dist/config/locators/components/chat/index.js +1 -1
  61. package/dist/config/locators/components/common/index.cjs +1 -1
  62. package/dist/config/locators/components/common/index.js +1 -1
  63. package/dist/config/locators/components/index.cjs +1 -1
  64. package/dist/config/locators/components/index.js +1 -1
  65. package/dist/config/locators/index.cjs +4 -4
  66. package/dist/config/locators/index.js +4 -4
  67. package/dist/contexts/amplitudeContext/index.cjs +13 -13
  68. package/dist/contexts/amplitudeContext/index.d.cts +1 -1
  69. package/dist/contexts/amplitudeContext/index.js +13 -13
  70. package/dist/contexts/cdnContext/index.cjs +2 -2
  71. package/dist/contexts/cdnContext/index.d.cts +1 -1
  72. package/dist/contexts/cdnContext/index.js +2 -2
  73. package/dist/contexts/enviveConfigContext/index.cjs +2 -2
  74. package/dist/contexts/enviveConfigContext/index.d.cts +1 -1
  75. package/dist/contexts/enviveConfigContext/index.js +2 -2
  76. package/dist/contexts/enviveCssContext/index.cjs +7 -7
  77. package/dist/contexts/enviveCssContext/index.d.cts +1 -1
  78. package/dist/contexts/enviveCssContext/index.js +7 -7
  79. package/dist/contexts/featureFlagContext/index.cjs +2 -2
  80. package/dist/contexts/featureFlagContext/index.js +2 -2
  81. package/dist/contexts/featureFlagServiceContext/index.cjs +1 -1
  82. package/dist/contexts/featureFlagServiceContext/index.js +1 -1
  83. package/dist/contexts/graphqlContext/index.cjs +2 -2
  84. package/dist/contexts/graphqlContext/index.js +2 -2
  85. package/dist/contexts/newOrgConfigContext/index.cjs +6 -6
  86. package/dist/contexts/newOrgConfigContext/index.d.cts +1 -1
  87. package/dist/contexts/newOrgConfigContext/index.js +6 -6
  88. package/dist/contexts/searchContext/index.cjs +15 -15
  89. package/dist/contexts/searchContext/index.js +15 -15
  90. package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
  91. package/dist/contexts/shopifyUrlContext/index.d.cts +1 -1
  92. package/dist/contexts/shopifyUrlContext/index.js +2 -2
  93. package/dist/contexts/systemSettingsContext/index.cjs +2 -2
  94. package/dist/contexts/systemSettingsContext/index.d.ts +2 -2
  95. package/dist/contexts/systemSettingsContext/index.js +2 -2
  96. package/dist/contexts/userIdentityContext/index.cjs +9 -9
  97. package/dist/contexts/userIdentityContext/index.js +9 -9
  98. package/dist/{domObserver-DNeeSh1F.js → domObserver-CVhsCSkS.js} +1 -1
  99. package/dist/{domObserver-C2oQO8vi.cjs → domObserver-LCBj1xw4.cjs} +1 -1
  100. package/dist/{enviveConfig-Dp80h9yu.cjs → enviveConfig-CQ_8mT-g.cjs} +1 -1
  101. package/dist/{enviveConfig-Ciq4ASoV.js → enviveConfig-Cwlp7-Qz.js} +1 -1
  102. package/dist/{enviveConfigContext-CCjJUmwp.js → enviveConfigContext-BG1ihSHO.js} +2 -2
  103. package/dist/{enviveConfigContext-DoYP8KSw.cjs → enviveConfigContext-Cn83IoUd.cjs} +2 -2
  104. package/dist/events/index.cjs +1 -1
  105. package/dist/events/index.js +1 -1
  106. package/dist/{events-DBin1Z7o.cjs → events-CgFGtanE.cjs} +1 -1
  107. package/dist/{events-CXiS1aTc.js → events-WOOrnUAx.js} +1 -1
  108. package/dist/exceptions/index.d.cts +1 -1
  109. package/dist/{featureFlagServiceContext-Cvp7NlpC.js → featureFlagServiceContext-Dr8Cw23n.js} +1 -1
  110. package/dist/{featureFlagServiceContext-DHtkQAtq.cjs → featureFlagServiceContext-rxZhpdEj.cjs} +1 -1
  111. package/dist/{globalSearch-Cpc8egsM.cjs → globalSearch-DEKvpWV-.cjs} +1 -1
  112. package/dist/{globalSearch-nmrfGLOn.js → globalSearch-D_nMjrlf.js} +1 -1
  113. package/dist/{graphqlContext-ChXlE8Ul.cjs → graphqlContext-B8wuRZcp.cjs} +2 -2
  114. package/dist/{graphqlContext-0cg9fEUw.js → graphqlContext-CpHMbKoX.js} +2 -2
  115. package/dist/hooks/AmplitudeOperations/index.cjs +14 -14
  116. package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
  117. package/dist/hooks/AmplitudeOperations/index.js +14 -14
  118. package/dist/hooks/AppDetails/index.cjs +12 -12
  119. package/dist/hooks/AppDetails/index.js +12 -12
  120. package/dist/hooks/BlockBackButton/index.d.cts +1 -1
  121. package/dist/hooks/CdnOperations/index.cjs +2 -2
  122. package/dist/hooks/CdnOperations/index.d.cts +1 -1
  123. package/dist/hooks/CdnOperations/index.d.ts +1 -1
  124. package/dist/hooks/CdnOperations/index.js +2 -2
  125. package/dist/hooks/ChatToggle/index.cjs +16 -16
  126. package/dist/hooks/ChatToggle/index.d.cts +1 -1
  127. package/dist/hooks/ChatToggle/index.js +16 -16
  128. package/dist/hooks/ChatToggleAnalytics/index.cjs +15 -15
  129. package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
  130. package/dist/hooks/ChatToggleAnalytics/index.js +15 -15
  131. package/dist/hooks/Debounce/index.d.cts +1 -1
  132. package/dist/hooks/ElementObserver/index.cjs +1 -1
  133. package/dist/hooks/ElementObserver/index.js +1 -1
  134. package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
  135. package/dist/hooks/GraphQLConfig/index.cjs +3 -3
  136. package/dist/hooks/GraphQLConfig/index.d.cts +1 -1
  137. package/dist/hooks/GraphQLConfig/index.js +3 -3
  138. package/dist/hooks/IdentifyUser/index.cjs +9 -9
  139. package/dist/hooks/IdentifyUser/index.d.cts +1 -1
  140. package/dist/hooks/IdentifyUser/index.js +9 -9
  141. package/dist/hooks/ImageResolver/index.cjs +1 -1
  142. package/dist/hooks/ImageResolver/index.d.cts +1 -1
  143. package/dist/hooks/ImageResolver/index.js +1 -1
  144. package/dist/hooks/IsSmallScreen/index.d.cts +1 -1
  145. package/dist/hooks/LocalStorageOperations/index.d.cts +1 -1
  146. package/dist/hooks/MessageFilter/index.d.cts +1 -1
  147. package/dist/hooks/MessageScrollObserver/index.d.cts +1 -1
  148. package/dist/hooks/NewOrgConfig/index.cjs +7 -7
  149. package/dist/hooks/NewOrgConfig/index.d.cts +2 -2
  150. package/dist/hooks/NewOrgConfig/index.js +7 -7
  151. package/dist/hooks/Search/index.cjs +20 -20
  152. package/dist/hooks/Search/index.js +20 -20
  153. package/dist/hooks/SearchOperations/index.cjs +15 -15
  154. package/dist/hooks/SearchOperations/index.js +15 -15
  155. package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
  156. package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
  157. package/dist/hooks/SystemSettingsContext/index.cjs +2 -2
  158. package/dist/hooks/SystemSettingsContext/index.d.cts +4 -4
  159. package/dist/hooks/SystemSettingsContext/index.d.ts +2 -2
  160. package/dist/hooks/SystemSettingsContext/index.js +2 -2
  161. package/dist/hooks/TrackComponentVisibleEvent/index.cjs +14 -14
  162. package/dist/hooks/TrackComponentVisibleEvent/index.js +14 -14
  163. package/dist/hooks/UpdateAnalyticsProps/index.cjs +13 -13
  164. package/dist/hooks/UpdateAnalyticsProps/index.js +13 -13
  165. package/dist/hooks/utils.cjs +1 -1
  166. package/dist/hooks/utils.d.cts +1 -1
  167. package/dist/hooks/utils.js +1 -1
  168. package/dist/index-BVZbvpx_.d.cts +1 -1
  169. package/dist/index-CMZcE7pk.d.cts +1 -1
  170. package/dist/index-ChiZg0yw.d.cts +1 -1
  171. package/dist/index-DtzPIcQp.d.ts +1 -1
  172. package/dist/index-bEjLKG_Q.d.ts +1 -1
  173. package/dist/{locators-C2fWd-74.js → locators-BMQGmGLq.js} +1 -1
  174. package/dist/{locators-Cx3q6Z_h.cjs → locators-DxYdak1F.cjs} +1 -1
  175. package/dist/{newOrgConfigAtom-BuQE_zPK.js → newOrgConfigAtom-C8h3w_Ji.js} +1 -1
  176. package/dist/{newOrgConfigAtom-rrYHmp1b.cjs → newOrgConfigAtom-CDttTiuu.cjs} +1 -1
  177. package/dist/{newOrgConfigContext-D-gU5ppl.js → newOrgConfigContext-BdzDnzUM.js} +5 -5
  178. package/dist/{newOrgConfigContext-d3RHl430.cjs → newOrgConfigContext-cWeJAT6E.cjs} +5 -5
  179. package/dist/{org-CIFgIcO4.cjs → org-BNs_maoW.cjs} +1 -1
  180. package/dist/{org-15F128Ah.js → org-CScQqL4k.js} +1 -1
  181. package/dist/{search-Ch6LKNh4.cjs → search-B8HIKjWF.cjs} +4 -4
  182. package/dist/{search--80x6CfL.js → search-BFXfnniE.js} +4 -4
  183. package/dist/{searchContext-BkPoTq1o.js → searchContext-C3qxKrms.js} +5 -5
  184. package/dist/{searchContext-B0qEUoKb.cjs → searchContext-sVRHEtSD.cjs} +5 -5
  185. package/dist/{searchServiceAdapter-BclWy4fE.cjs → searchServiceAdapter-6Mjz87ZL.cjs} +1 -1
  186. package/dist/{searchServiceAdapter-B0h7psvh.js → searchServiceAdapter-BpmMMb01.js} +1 -1
  187. package/dist/{shopifyUrlContext-Bw1kAZ2P.cjs → shopifyUrlContext-COc1eDR_.cjs} +2 -2
  188. package/dist/{shopifyUrlContext-DnJiUmMA.js → shopifyUrlContext-CToAt_98.js} +2 -2
  189. package/dist/{systemSettingsContext-DPdDfVhj.js → systemSettingsContext-D9iNGz5v.js} +2 -2
  190. package/dist/{systemSettingsContext-068vQuP2.cjs → systemSettingsContext-DdV7Yte8.cjs} +2 -2
  191. package/dist/types/index.cjs +1 -1
  192. package/dist/types/index.js +1 -1
  193. package/dist/{types-B8HZYWV3.cjs → types-1iJ_FnQQ.cjs} +1 -1
  194. package/dist/{types-y3mhxOUA.js → types-D5du68Vp.js} +1 -1
  195. package/dist/{urlsParser-bb8ciRFg.cjs → urlsParser-Dax4iVNC.cjs} +1 -1
  196. package/dist/{urlsParser-v_1DKvyf.js → urlsParser-NAp2LwWP.js} +1 -1
  197. package/dist/{useAppDetails-eP2hBuid.cjs → useAppDetails-D3T6kJY_.cjs} +4 -4
  198. package/dist/{useAppDetails-BPXln8UE.js → useAppDetails-xPVs6fW7.js} +4 -4
  199. package/dist/{useGraphQLConfig-v9veUbvJ.cjs → useGraphQLConfig-B1DaVvFx.cjs} +2 -2
  200. package/dist/{useGraphQLConfig-Btszi6cG.js → useGraphQLConfig-BtPxjtxw.js} +2 -2
  201. package/dist/{utils-D_nGHczN.js → utils-BZT_oZ3n.js} +1 -1
  202. package/dist/{utils-CqVRbvfN.cjs → utils-C8_J5a8M.cjs} +1 -1
  203. package/dist/{utils-DQhbbAnt.js → utils-CkYtC91V.js} +1 -1
  204. package/dist/{utils-SjlIHajO.cjs → utils-D3MjNkd3.cjs} +2 -2
  205. package/dist/{utils-CWzuvlOR.js → utils-DMwh3QbT.js} +2 -2
  206. package/dist/{utils-CJk5iwQI.cjs → utils-qtHPLFby.cjs} +1 -1
  207. package/package.json +1 -1
  208. package/src/contexts/amplitudeContext/amplitudeContext.tsx +11 -3
  209. package/src/contexts/cdnContext/cdnContext.tsx +11 -9
  210. package/dist/src/application/commerce-api.js +0 -408
  211. package/dist/src/application/logging/logger.js +0 -16
  212. package/dist/src/application/models/graphql/index.js +0 -3
  213. package/dist/src/application/models/graphql/queries/getMerchantColorsQuery.js +0 -13
  214. package/dist/src/application/models/graphql/queries/getMerchantFrontendConfigQuery.js +0 -13
  215. package/dist/src/application/models/graphql/queries/getMerchantOrgIdQuery.js +0 -10
  216. package/dist/src/application/models/guards/api/index.js +0 -12
  217. package/dist/src/application/models/guards/api/isApiFormResponse.js +0 -59
  218. package/dist/src/application/models/guards/api/isApiFormSubmittedResponseAttributes.js +0 -22
  219. package/dist/src/application/models/guards/api/isApiOrderResponseAttributes.js +0 -91
  220. package/dist/src/application/models/guards/api/isApiOrgConfigResults.js +0 -188
  221. package/dist/src/application/models/guards/api/isApiOrganizationConfig.js +0 -115
  222. package/dist/src/application/models/guards/api/isApiPDPEventAttributes.js +0 -16
  223. package/dist/src/application/models/guards/api/isApiPLPEventAttributes.js +0 -26
  224. package/dist/src/application/models/guards/api/isApiPageResponseAttributes.js +0 -15
  225. package/dist/src/application/models/guards/api/isApiProductResponseAttributes.js +0 -65
  226. package/dist/src/application/models/guards/api/isApiProductSearchAttributes.js +0 -15
  227. package/dist/src/application/models/guards/api/isApiProductSearchFilterAttributes.js +0 -10
  228. package/dist/src/application/models/guards/api/isApiQueryTypedEventAttributes.js +0 -4
  229. package/dist/src/application/models/guards/api/isApiResponse.js +0 -33
  230. package/dist/src/application/models/guards/api/isApiReviewResponseAttributes.js +0 -22
  231. package/dist/src/application/models/guards/api/isApiReviewRichInformation.js +0 -23
  232. package/dist/src/application/models/guards/api/isApiSearchEventAttributes.js +0 -20
  233. package/dist/src/application/models/guards/api/isApiSuggestion.js +0 -24
  234. package/dist/src/application/models/guards/api/isApiSuggestionClickedEventAttributes.js +0 -4
  235. package/dist/src/application/models/guards/api/isApiTextResponseAttributes.js +0 -4
  236. package/dist/src/application/models/guards/api/isApiUserEvent.js +0 -18
  237. package/dist/src/application/models/guards/graphQL/isGraphQLColorsConfig.js +0 -41
  238. package/dist/src/application/models/guards/isBaseEcommerceEvent.js +0 -14
  239. package/dist/src/application/models/guards/isGA4EcommerceEvent.js +0 -14
  240. package/dist/src/application/models/guards/isLegacyUAEcommerceEvent.js +0 -14
  241. package/dist/src/application/models/guards/isMobilePLPChatPlacementParameter.js +0 -4
  242. package/dist/src/application/models/guards/isSpanxTakeAQuizCtaParameter.js +0 -1
  243. package/dist/src/application/models/guards/isVariantInfo.js +0 -28
  244. package/dist/src/application/models/guards/utils.js +0 -34
  245. package/dist/src/application/models/index.js +0 -34
  246. package/dist/src/application/models/utils/snakeToCamelTransformer.js +0 -71
  247. package/dist/src/application/models/utils/stringToFulfillmentDisplayStatusEnumValue.js +0 -65
  248. package/dist/src/application/models/validators/validateGraphQLColorsConfig.js +0 -9
  249. package/dist/src/application/models/validators/validateGraphQLFrontendConfig.js +0 -420
  250. package/dist/src/application/models/validators/validateGraphQLOrgId.js +0 -6
  251. package/dist/src/application/models/validators/validateMobilePLPChatPlacementParameter.js +0 -9
  252. package/dist/src/application/models/validators/validateOrgConfigResults.js +0 -44
  253. package/dist/src/application/models/validators/validateOrganizationConfig.js +0 -34
  254. package/dist/src/application/models/validators/validateResponse.js +0 -173
  255. package/dist/src/application/models/validators/validateSuggestion.js +0 -13
  256. package/dist/src/application/models/validators/validateUserEvent.js +0 -91
  257. package/dist/src/application/utils/analyticsUtils.js +0 -95
  258. package/dist/src/application/utils/coreContextToApiContext.js +0 -8
  259. package/dist/src/application/utils/coreUserEventToApiUserEvent.js +0 -90
  260. package/dist/src/application/utils/divideArray.js +0 -7
  261. package/dist/src/application/utils/domObserver.js +0 -85
  262. package/dist/src/application/utils/elementObserver.js +0 -186
  263. package/dist/src/application/utils/imageFilter.js +0 -11
  264. package/dist/src/application/utils/index.js +0 -21
  265. package/dist/src/application/utils/merchantUtils.js +0 -15
  266. package/dist/src/application/utils/messageFromFormSubmittedEvent.js +0 -19
  267. package/dist/src/application/utils/messageFromQueryEvent.js +0 -35
  268. package/dist/src/application/utils/messageFromResponse.js +0 -123
  269. package/dist/src/application/utils/messageFromSuggestionEvent.js +0 -27
  270. package/dist/src/application/utils/mouseEventTypes.js +0 -1
  271. package/dist/src/application/utils/mutationHelper.js +0 -33
  272. package/dist/src/application/utils/nextMessageRequestToApiRequest.js +0 -29
  273. package/dist/src/application/utils/nodeSelector.js +0 -101
  274. package/dist/src/application/utils/overrides.js +0 -144
  275. package/dist/src/application/utils/stringUtils.js +0 -47
  276. package/dist/src/application/utils/supportedEventRequestToApiRequest.js +0 -7
  277. package/dist/src/application/utils/urlsParser.js +0 -33
  278. package/dist/src/application/utils/validation.js +0 -5
  279. package/dist/src/atoms/amplitude/amplitudeTrackEventAtom.js +0 -4
  280. package/dist/src/atoms/app/index.js +0 -23
  281. package/dist/src/atoms/app/variant.js +0 -102
  282. package/dist/src/atoms/atomStore/atomStore.js +0 -28
  283. package/dist/src/atoms/atomStore/index.js +0 -1
  284. package/dist/src/atoms/chat/chatState.js +0 -32
  285. package/dist/src/atoms/chat/form.js +0 -16
  286. package/dist/src/atoms/chat/index.js +0 -23
  287. package/dist/src/atoms/chat/lastMessage.js +0 -10
  288. package/dist/src/atoms/chat/messageQueue.js +0 -68
  289. package/dist/src/atoms/chat/performanceMetrics.js +0 -70
  290. package/dist/src/atoms/chat/renderedWidgetRefs.js +0 -24
  291. package/dist/src/atoms/chat/replies.js +0 -42
  292. package/dist/src/atoms/chat/suggestions.js +0 -29
  293. package/dist/src/atoms/envive/enviveConfig.js +0 -67
  294. package/dist/src/atoms/globalSearch/globalSearch.js +0 -8
  295. package/dist/src/atoms/globalSearch/index.js +0 -1
  296. package/dist/src/atoms/org/customerService.js +0 -6
  297. package/dist/src/atoms/org/graphqlConfig.js +0 -8
  298. package/dist/src/atoms/org/index.js +0 -4
  299. package/dist/src/atoms/org/newOrgConfigAtom.js +0 -2
  300. package/dist/src/atoms/org/orgAnalyticsConfig.js +0 -8
  301. package/dist/src/atoms/search/index.js +0 -1
  302. package/dist/src/atoms/search/productFilters.js +0 -163
  303. package/dist/src/atoms/search/productRetrievalAPI.js +0 -50
  304. package/dist/src/atoms/search/productRetrievalAdapter.js +0 -14
  305. package/dist/src/atoms/search/productSorter.js +0 -13
  306. package/dist/src/atoms/search/searchAPI.js +0 -140
  307. package/dist/src/atoms/search/searchServiceAdapter.js +0 -14
  308. package/dist/src/atoms/search/utils.js +0 -15
  309. package/dist/src/config/index.js +0 -1
  310. package/dist/src/config/locators/components/chat/entrypoints.js +0 -10
  311. package/dist/src/config/locators/components/chat/index.js +0 -21
  312. package/dist/src/config/locators/components/chat/preview.js +0 -11
  313. package/dist/src/config/locators/components/chat/variants/index.js +0 -12
  314. package/dist/src/config/locators/components/common/buttons.js +0 -6
  315. package/dist/src/config/locators/components/common/cards.js +0 -17
  316. package/dist/src/config/locators/components/common/index.js +0 -4
  317. package/dist/src/config/locators/components/common/links.js +0 -1
  318. package/dist/src/config/locators/components/common/tables.js +0 -1
  319. package/dist/src/config/locators/components/floating-button.js +0 -2
  320. package/dist/src/config/locators/components/index.js +0 -3
  321. package/dist/src/config/locators/components/report-issue.js +0 -13
  322. package/dist/src/config/locators/components/search/index.js +0 -5
  323. package/dist/src/config/locators/components/shadow-dom.js +0 -1
  324. package/dist/src/config/locators/embedded.js +0 -20
  325. package/dist/src/config/locators/index.js +0 -4
  326. package/dist/src/contexts/amplitudeContext/amplitudeContext.js +0 -271
  327. package/dist/src/contexts/amplitudeContext/index.js +0 -1
  328. package/dist/src/contexts/cdnContext/cdnContext.js +0 -28
  329. package/dist/src/contexts/cdnContext/index.js +0 -1
  330. package/dist/src/contexts/enviveConfigContext/enviveConfigContext.js +0 -37
  331. package/dist/src/contexts/enviveConfigContext/index.js +0 -1
  332. package/dist/src/contexts/enviveCssContext/enviveCssContext.js +0 -31
  333. package/dist/src/contexts/enviveCssContext/index.js +0 -1
  334. package/dist/src/contexts/featureFlagContext/featureFlagContext.js +0 -109
  335. package/dist/src/contexts/featureFlagContext/index.js +0 -1
  336. package/dist/src/contexts/featureFlagServiceContext/featureFlagServiceContext.js +0 -47
  337. package/dist/src/contexts/featureFlagServiceContext/index.js +0 -1
  338. package/dist/src/contexts/graphqlContext/graphqlContext.js +0 -87
  339. package/dist/src/contexts/graphqlContext/index.js +0 -1
  340. package/dist/src/contexts/localStorageContext/index.js +0 -1
  341. package/dist/src/contexts/localStorageContext/localStorageContext.js +0 -95
  342. package/dist/src/contexts/newOrgConfigContext/index.js +0 -1
  343. package/dist/src/contexts/newOrgConfigContext/newOrgConfigContext.js +0 -33
  344. package/dist/src/contexts/searchContext/index.js +0 -1
  345. package/dist/src/contexts/searchContext/searchContext.js +0 -131
  346. package/dist/src/contexts/sessionStorageContext/index.js +0 -1
  347. package/dist/src/contexts/sessionStorageContext/sessionStorageContext.js +0 -43
  348. package/dist/src/contexts/shopifyUrlContext/index.js +0 -1
  349. package/dist/src/contexts/shopifyUrlContext/shopifyUrlContext.js +0 -62
  350. package/dist/src/contexts/systemSettingsContext/index.js +0 -1
  351. package/dist/src/contexts/systemSettingsContext/systemSettingsContext.js +0 -29
  352. package/dist/src/contexts/userIdentityContext/index.js +0 -1
  353. package/dist/src/contexts/userIdentityContext/userIdentityContext.js +0 -118
  354. package/dist/src/events/index.js +0 -51
  355. package/dist/src/events/registerAnalyticsListeners.js +0 -32
  356. package/dist/src/exceptions/index.js +0 -2
  357. package/dist/src/exceptions/sessionExceptions.js +0 -6
  358. package/dist/src/exceptions/unsupportedProductExceptions.js +0 -6
  359. package/dist/src/hooks/AmplitudeOperations/index.js +0 -1
  360. package/dist/src/hooks/AmplitudeOperations/useAmplitudeOperations.js +0 -24
  361. package/dist/src/hooks/AppDetails/index.js +0 -1
  362. package/dist/src/hooks/AppDetails/useAppDetails.js +0 -26
  363. package/dist/src/hooks/BlockBackButton/index.js +0 -1
  364. package/dist/src/hooks/BlockBackButton/useBlockBackButton.js +0 -23
  365. package/dist/src/hooks/CdnOperations/index.js +0 -1
  366. package/dist/src/hooks/CdnOperations/useCdnOperations.js +0 -13
  367. package/dist/src/hooks/ChatToggle/index.js +0 -1
  368. package/dist/src/hooks/ChatToggle/useChatToggle.js +0 -50
  369. package/dist/src/hooks/ChatToggleAnalytics/index.js +0 -1
  370. package/dist/src/hooks/ChatToggleAnalytics/useChatToggleAnalytics.js +0 -11
  371. package/dist/src/hooks/CustomerSupportHandoff/index.js +0 -1
  372. package/dist/src/hooks/CustomerSupportHandoff/useCustomerSupportHandoff.js +0 -32
  373. package/dist/src/hooks/Debounce/index.js +0 -1
  374. package/dist/src/hooks/Debounce/useDebounce.js +0 -13
  375. package/dist/src/hooks/ElementObserver/index.js +0 -1
  376. package/dist/src/hooks/ElementObserver/useElementObserver.js +0 -208
  377. package/dist/src/hooks/GrabAndScroll/index.js +0 -1
  378. package/dist/src/hooks/GrabAndScroll/useGrabAndScroll.js +0 -105
  379. package/dist/src/hooks/GraphQLConfig/index.js +0 -1
  380. package/dist/src/hooks/GraphQLConfig/useGraphQLConfig.js +0 -54
  381. package/dist/src/hooks/IdentifyUser/index.js +0 -1
  382. package/dist/src/hooks/IdentifyUser/useIdentifyUser.js +0 -28
  383. package/dist/src/hooks/ImageResolver/index.js +0 -1
  384. package/dist/src/hooks/ImageResolver/useImageResolver.js +0 -45
  385. package/dist/src/hooks/Intersection/index.js +0 -1
  386. package/dist/src/hooks/Intersection/useIntersection.js +0 -20
  387. package/dist/src/hooks/IsSmallScreen/index.js +0 -1
  388. package/dist/src/hooks/IsSmallScreen/useIsSmallScreen.js +0 -16
  389. package/dist/src/hooks/LocalStorageOperations/index.js +0 -1
  390. package/dist/src/hooks/LocalStorageOperations/useLocalStorageOperations.js +0 -64
  391. package/dist/src/hooks/MessageFilter/index.js +0 -1
  392. package/dist/src/hooks/MessageFilter/useMessageFilter.js +0 -37
  393. package/dist/src/hooks/MessageScrollObserver/index.js +0 -1
  394. package/dist/src/hooks/MessageScrollObserver/useMessageScrollObserver.js +0 -35
  395. package/dist/src/hooks/NewOrgConfig/index.js +0 -1
  396. package/dist/src/hooks/NewOrgConfig/useNewOrgConfig.js +0 -5
  397. package/dist/src/hooks/Search/index.js +0 -1
  398. package/dist/src/hooks/Search/useRecommendedProducts.js +0 -35
  399. package/dist/src/hooks/Search/useSearch.js +0 -224
  400. package/dist/src/hooks/Search/useSearchInput.js +0 -192
  401. package/dist/src/hooks/SearchOperations/index.js +0 -1
  402. package/dist/src/hooks/SearchOperations/useSearchOperations.js +0 -78
  403. package/dist/src/hooks/SessionStorageOperations/index.js +0 -1
  404. package/dist/src/hooks/SessionStorageOperations/useSessionStorageOperations.js +0 -20
  405. package/dist/src/hooks/ShopifyUrlOperations/index.js +0 -1
  406. package/dist/src/hooks/ShopifyUrlOperations/useShopifyUrlOperations.js +0 -34
  407. package/dist/src/hooks/SnapCalculator/index.js +0 -1
  408. package/dist/src/hooks/SnapCalculator/useSnapCalculator.js +0 -22
  409. package/dist/src/hooks/SystemSettingsContext/index.js +0 -1
  410. package/dist/src/hooks/SystemSettingsContext/useSystemSettingsContext.js +0 -9
  411. package/dist/src/hooks/TrackComponentVisibleEvent/index.js +0 -1
  412. package/dist/src/hooks/TrackComponentVisibleEvent/useTrackComponentVisibleEvent.js +0 -45
  413. package/dist/src/hooks/UpdateAnalyticsProps/index.js +0 -1
  414. package/dist/src/hooks/UpdateAnalyticsProps/useUpdateAnalyticsProps.js +0 -43
  415. package/dist/src/hooks/utils.js +0 -116
  416. package/dist/src/interceptors/index.js +0 -1
  417. package/dist/src/interceptors/useMessageInterceptor.js +0 -24
  418. package/dist/src/types/ApiResponse.js +0 -1
  419. package/dist/src/types/FilterAttribute.js +0 -3
  420. package/dist/src/types/Message.js +0 -24
  421. package/dist/src/types/Suggestion.js +0 -3
  422. package/dist/src/types/index.js +0 -4
  423. package/dist/src/util/colorVar.js +0 -3
  424. package/dist/src/util/configVersion.js +0 -4
  425. package/dist/src/util/domInsertion.js +0 -16
@@ -65,6 +65,8 @@ export const AmplitudeProvider: React.FC<{ children: React.ReactNode }> = ({
65
65
  const [amplitudeClient, setAmplitudeClient] = React.useState<
66
66
  BrowserClient | undefined
67
67
  >(undefined);
68
+ const [internalEventTrackingEnrichment, setInternalEventTrackingEnrichment] =
69
+ React.useState<EnrichmentPlugin | undefined>(undefined);
68
70
  const [supplementalDefaultProps, setSupplementalDefaultProps] =
69
71
  React.useState<Record<string, unknown>>({});
70
72
 
@@ -161,7 +163,11 @@ export const AmplitudeProvider: React.FC<{ children: React.ReactNode }> = ({
161
163
  }
162
164
  }, [orgShortName, featureFlagService]);
163
165
 
164
- const eventTrackingEnrichment = useMemo((): EnrichmentPlugin => {
166
+ const getEventTrackingEnrichment = useCallback((): EnrichmentPlugin => {
167
+ if (internalEventTrackingEnrichment !== undefined) {
168
+ return internalEventTrackingEnrichment;
169
+ }
170
+
165
171
  const enrichment: EnrichmentPlugin = {
166
172
  name: "page-view-tracking-enrichment",
167
173
  type: "enrichment",
@@ -232,8 +238,10 @@ export const AmplitudeProvider: React.FC<{ children: React.ReactNode }> = ({
232
238
  return enrichedEvent;
233
239
  },
234
240
  };
241
+ setInternalEventTrackingEnrichment(enrichment);
235
242
  return enrichment;
236
243
  }, [
244
+ internalEventTrackingEnrichment,
237
245
  getDefaultTrackingProps,
238
246
  featureFlagService,
239
247
  publicKey,
@@ -247,7 +255,7 @@ export const AmplitudeProvider: React.FC<{ children: React.ReactNode }> = ({
247
255
  if (isReady && !amplitudeClient) {
248
256
  const currentAmplitudeInstance: BrowserClient = createInstance();
249
257
  const isSessionsEnabled = amplitudeSessionReplayInit();
250
- currentAmplitudeInstance.add(eventTrackingEnrichment);
258
+ currentAmplitudeInstance.add(getEventTrackingEnrichment());
251
259
  currentAmplitudeInstance.init(amplitudeApiKey!, userId!, {
252
260
  serverZone: dataResidency as ServerZoneType,
253
261
  trackingOptions: {
@@ -272,7 +280,7 @@ export const AmplitudeProvider: React.FC<{ children: React.ReactNode }> = ({
272
280
  userId,
273
281
  dataResidency,
274
282
  amplitudeSessionReplayInit,
275
- eventTrackingEnrichment,
283
+ getEventTrackingEnrichment,
276
284
  ]);
277
285
 
278
286
  const trackEvent = useCallback(
@@ -1,13 +1,15 @@
1
- import React, { createContext, useContext, useCallback, useMemo } from 'react';
2
- import { useAtomValue } from 'jotai';
3
- import { cdnUrlAtom } from '../../atoms/envive/enviveConfig';
4
- import { CdnContextType } from '@envive-ai/types';
1
+ import React, { createContext, useContext, useCallback, useMemo } from "react";
2
+ import { useAtomValue } from "jotai";
3
+ import { cdnUrlAtom } from "../../atoms/envive/enviveConfig";
4
+ import { CdnContextType } from "@envive-ai/types";
5
5
 
6
6
  const CdnContext = createContext<CdnContextType | null>(null);
7
7
 
8
- export const CdnProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
8
+ export const CdnProvider: React.FC<{ children: React.ReactNode }> = ({
9
+ children,
10
+ }) => {
9
11
  const cdnUrlAtomValue = useAtomValue(cdnUrlAtom);
10
- const cdnUrl = cdnUrlAtomValue || 'https://cdn.spiffy.ai/other';
12
+ const cdnUrl = cdnUrlAtomValue || "https://cdn.spiffy.ai/other";
11
13
 
12
14
  const getCdnBasePath = useCallback(() => {
13
15
  return cdnUrl;
@@ -17,7 +19,7 @@ export const CdnProvider: React.FC<{ children: React.ReactNode }> = ({ children
17
19
  (assetName: string, orgShortName: string) => {
18
20
  return `${getCdnBasePath()}/assets/${orgShortName}/${assetName}`;
19
21
  },
20
- [getCdnBasePath],
22
+ [getCdnBasePath]
21
23
  );
22
24
 
23
25
  const value = useMemo(
@@ -26,7 +28,7 @@ export const CdnProvider: React.FC<{ children: React.ReactNode }> = ({ children
26
28
  getCdnBasePath,
27
29
  getAssetURL,
28
30
  }),
29
- [cdnUrl, getCdnBasePath, getAssetURL],
31
+ [cdnUrl, getCdnBasePath, getAssetURL]
30
32
  );
31
33
 
32
34
  return <CdnContext.Provider value={value}>{children}</CdnContext.Provider>;
@@ -35,7 +37,7 @@ export const CdnProvider: React.FC<{ children: React.ReactNode }> = ({ children
35
37
  export const useCdn = () => {
36
38
  const context = useContext(CdnContext);
37
39
  if (!context) {
38
- throw new Error('useCdn must be used within a CdnProvider');
40
+ throw new Error("useCdn must be used within a CdnProvider");
39
41
  }
40
42
  return context;
41
43
  };
@@ -1,408 +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
- case ContextSourceEnum.Eval:
360
- return V1OrgConfigGetSourceEnum.Test;
361
- default: {
362
- // This ensures that if new values are added to ContextSourceEnum, we catch it
363
- const exhaustiveCheck = source;
364
- return exhaustiveCheck;
365
- }
366
- }
367
- };
368
- CommerceApiClient.getOrgConfig = async (user_id) => {
369
- var _b;
370
- try {
371
- const atomStore = getAtomStore();
372
- const reactAppName = atomStore.get(reactAppNameAtom);
373
- const contextSource = atomStore.get(contextSourceAtom);
374
- const featureFlagService = atomStore.get(featureFlagServiceAtom); // Get featureFlagService
375
- const request = {
376
- namespace: reactAppName,
377
- user_id,
378
- source: _a.mapContextSourceToV1OrgConfigGetSource(contextSource),
379
- include_experiments: Object.values(ProductExperiment),
380
- include_feature_gates: Object.entries(((_b = featureFlagService === null || featureFlagService === void 0 ? void 0 : featureFlagService.featureFlagService) === null || _b === void 0 ? void 0 : _b.getFeatureFlags()) || {})
381
- .filter(([, isEnabled]) => isEnabled)
382
- .map(([featureGateName]) => featureGateName), // Use featureFlagService
383
- };
384
- const response = await _a.getInstance().defaultApi.v1OrgConfigGet(request);
385
- return validateOrgConfigResults(response);
386
- }
387
- catch (err) {
388
- Logger.logError(`Failed to get org config`, err, { err });
389
- return undefined;
390
- }
391
- };
392
- CommerceApiClient.addNoteToLatestConversation = async (spiffyUserId, email, customerServiceProvider) => {
393
- Logger.logInfo(`addNoteToLatestConversation - user_id=${spiffyUserId} email=${email} customer_service_provider=${customerServiceProvider}`);
394
- try {
395
- await _a.getInstance().customerServiceApi.v1CustserviceAddNoteToLatestConversationPost({
396
- AddNoteToLatestConversationRequest: {
397
- spiffy_user_id: spiffyUserId,
398
- email,
399
- customer_service_provider: customerServiceProvider,
400
- },
401
- });
402
- }
403
- catch (err) {
404
- Logger.logError("Failed to add note to latest conversation", { err });
405
- }
406
- };
407
- CommerceApiClient.getCustomerServiceApi = () => _a.getInstance().customerServiceApi;
408
- 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,3 +0,0 @@
1
- export * from './queries/getMerchantFrontendConfigQuery';
2
- export * from './queries/getMerchantColorsQuery';
3
- export * from './queries/getMerchantOrgIdQuery';
@@ -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,10 +0,0 @@
1
- const getMerchantOrgIdQuery = `
2
- query {
3
- me {
4
- org {
5
- id
6
- }
7
- }
8
- }
9
- `;
10
- export { getMerchantOrgIdQuery };
@@ -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';
@@ -1,59 +0,0 @@
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
- };
@@ -1,22 +0,0 @@
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
- };