@envive-ai/react-hooks 0.2.6 → 0.2.7-arthur-1

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 (361) hide show
  1. package/dist/{NewOrgConfig-BxSuoP9C.cjs → NewOrgConfig-Bo1seKr6.cjs} +2 -2
  2. package/dist/{NewOrgConfig-BfrGpiGk.js → NewOrgConfig-yptI2imS.js} +2 -2
  3. package/dist/{SystemSettingsContext-B8X_Dvw2.js → SystemSettingsContext-BY1BFgAQ.js} +2 -2
  4. package/dist/{SystemSettingsContext-Bkoiobdv.cjs → SystemSettingsContext-EDpRMMt2.cjs} +2 -2
  5. package/dist/{TrackComponentVisibleEvent-DwfGqNTx.js → TrackComponentVisibleEvent-CXhKOwKQ.js} +2 -2
  6. package/dist/{TrackComponentVisibleEvent-DMuX-byo.cjs → TrackComponentVisibleEvent-CgxCqrIt.cjs} +2 -2
  7. package/dist/amplitudeContext-BItT9HmT.js +1 -0
  8. package/dist/{amplitudeContext-ZTQMvVTV.cjs → amplitudeContext-C8tT74Mi.cjs} +9 -9
  9. package/dist/{amplitudeContext-B73xamNe.d.cts → amplitudeContext-CCVyp5RU.d.cts} +1 -1
  10. package/dist/{amplitudeContext-DOqL2Vn8.js → amplitudeContext-DCk6Va-j.js} +9 -9
  11. package/dist/amplitudeContext-DPtyVv3Q.cjs +0 -0
  12. package/dist/{amplitudeContext-CiO9T9c-.d.ts → amplitudeContext-DcRur97Z.d.ts} +1 -1
  13. package/dist/{api-bHEYmSiT.js → api-BWSsazAG.js} +3 -3
  14. package/dist/{api-BvygKEiX.cjs → api-DeW6rHj3.cjs} +3 -3
  15. package/dist/{app-BQw_-JGl.cjs → app-BbPSHefQ.cjs} +2 -2
  16. package/dist/{app-Aqkm_SlS.js → app-CflxT_xI.js} +2 -2
  17. package/dist/application/models/graphql/index.cjs +4 -3
  18. package/dist/application/models/graphql/index.d.cts +2 -2
  19. package/dist/application/models/graphql/index.d.ts +2 -2
  20. package/dist/application/models/graphql/index.js +3 -3
  21. package/dist/application/models/guards/api/index.cjs +3 -3
  22. package/dist/application/models/guards/api/index.d.cts +2 -1
  23. package/dist/application/models/guards/api/index.d.ts +2 -1
  24. package/dist/application/models/guards/api/index.js +3 -3
  25. package/dist/application/models/guards/utils.cjs +1 -1
  26. package/dist/application/models/guards/utils.d.cts +1 -1
  27. package/dist/application/models/guards/utils.d.ts +1 -1
  28. package/dist/application/models/guards/utils.js +1 -1
  29. package/dist/application/models/index.cjs +9 -9
  30. package/dist/application/models/index.d.cts +11 -10
  31. package/dist/application/models/index.d.ts +11 -10
  32. package/dist/application/models/index.js +8 -8
  33. package/dist/application/models/variantInfo/index.d.cts +1 -1
  34. package/dist/application/models/variantInfo/index.d.ts +1 -1
  35. package/dist/application/utils/index.cjs +15 -15
  36. package/dist/application/utils/index.d.cts +14 -13
  37. package/dist/application/utils/index.d.ts +14 -13
  38. package/dist/application/utils/index.js +15 -15
  39. package/dist/atoms/app/index.cjs +11 -11
  40. package/dist/atoms/app/index.d.cts +19 -18
  41. package/dist/atoms/app/index.d.ts +19 -18
  42. package/dist/atoms/app/index.js +11 -11
  43. package/dist/atoms/chat/index.cjs +16 -16
  44. package/dist/atoms/chat/index.d.cts +39 -38
  45. package/dist/atoms/chat/index.d.ts +39 -38
  46. package/dist/atoms/chat/index.js +16 -16
  47. package/dist/atoms/globalSearch/index.d.cts +5 -5
  48. package/dist/atoms/globalSearch/index.d.ts +6 -6
  49. package/dist/atoms/org/index.d.cts +30 -29
  50. package/dist/atoms/org/index.d.ts +30 -29
  51. package/dist/atoms/search/index.cjs +18 -18
  52. package/dist/atoms/search/index.d.cts +13 -12
  53. package/dist/atoms/search/index.d.ts +13 -12
  54. package/dist/atoms/search/index.js +18 -18
  55. package/dist/atoms/search/types.d.cts +4 -2
  56. package/dist/atoms/search/types.d.ts +4 -2
  57. package/dist/atoms/search/utils.d.ts +1 -1
  58. package/dist/{cdnContext-Cd0Kvt6g.cjs → cdnContext-CaDyQ_5p.cjs} +2 -2
  59. package/dist/{cdnContext-D8pHA9gh.js → cdnContext-CtrIlAqX.js} +2 -2
  60. package/dist/{chat-U1IgKNij.js → chat-BjhQCyW_.js} +8 -8
  61. package/dist/{chat-DwNALtox.cjs → chat-BkPax29G.cjs} +13 -7
  62. package/dist/{chat-EJbfGWRr.js → chat-ClvJ9xEj.js} +1 -1
  63. package/dist/{chat-CJ9D8n7g.cjs → chat-DCGriB7h.cjs} +1 -1
  64. package/dist/{chatElementDisplayLocation-DWmfNX_u.d.cts → chatElementDisplayLocation-B7vr33eG.d.cts} +1 -1
  65. package/dist/{chatElementDisplayLocation-DbmdwAff.d.ts → chatElementDisplayLocation-D4XF0UfI.d.ts} +1 -1
  66. package/dist/{chatSearch-Bb2SMr9X.js → chatSearch-BsYlFvpv.js} +4 -4
  67. package/dist/{chatSearch-DtE2cUQw.cjs → chatSearch-C3N3iIxu.cjs} +4 -4
  68. package/dist/{chatState-B3Dyrd9M.cjs → chatState-CJ52Ag_7.cjs} +3 -3
  69. package/dist/{chatState-BXBN-12W.js → chatState-CXA1vF16.js} +3 -3
  70. package/dist/{commerce-api-Dx02FCQ7.cjs → commerce-api-DA1QGGMK.cjs} +8 -7
  71. package/dist/{commerce-api-DXbnMNT8.js → commerce-api-rgj30eEp.js} +8 -7
  72. package/dist/{common-CuwWqIJ1.cjs → common-DQPvV_S_.cjs} +1 -1
  73. package/dist/{common-Df2bwzd2.js → common-c_4eX0qn.js} +1 -1
  74. package/dist/{components-QGCWJ26c.js → components-CDpaMUjK.js} +1 -1
  75. package/dist/{components-BCfFLf9X.cjs → components-DKwVHIjq.cjs} +1 -1
  76. package/dist/config/index.cjs +4 -4
  77. package/dist/config/index.d.cts +4 -4
  78. package/dist/config/index.d.ts +4 -4
  79. package/dist/config/index.js +4 -4
  80. package/dist/config/locators/components/chat/index.cjs +1 -1
  81. package/dist/config/locators/components/chat/index.d.cts +1 -1
  82. package/dist/config/locators/components/chat/index.d.ts +1 -1
  83. package/dist/config/locators/components/chat/index.js +1 -1
  84. package/dist/config/locators/components/common/index.cjs +1 -1
  85. package/dist/config/locators/components/common/index.d.cts +1 -1
  86. package/dist/config/locators/components/common/index.d.ts +1 -1
  87. package/dist/config/locators/components/common/index.js +1 -1
  88. package/dist/config/locators/components/index.cjs +1 -1
  89. package/dist/config/locators/components/index.d.cts +1 -1
  90. package/dist/config/locators/components/index.d.ts +1 -1
  91. package/dist/config/locators/components/index.js +1 -1
  92. package/dist/config/locators/index.cjs +4 -4
  93. package/dist/config/locators/index.d.cts +4 -4
  94. package/dist/config/locators/index.d.ts +4 -4
  95. package/dist/config/locators/index.js +4 -4
  96. package/dist/contexts/amplitudeContext/index.cjs +15 -14
  97. package/dist/contexts/amplitudeContext/index.d.cts +1 -1
  98. package/dist/contexts/amplitudeContext/index.d.ts +1 -1
  99. package/dist/contexts/amplitudeContext/index.js +15 -14
  100. package/dist/contexts/cdnContext/index.cjs +4 -4
  101. package/dist/contexts/cdnContext/index.js +4 -4
  102. package/dist/contexts/chatContext/index.cjs +23 -23
  103. package/dist/contexts/chatContext/index.d.cts +4 -4
  104. package/dist/contexts/chatContext/index.d.ts +4 -4
  105. package/dist/contexts/chatContext/index.js +23 -23
  106. package/dist/contexts/enviveConfigContext/index.cjs +4 -4
  107. package/dist/contexts/enviveConfigContext/index.d.cts +3 -3
  108. package/dist/contexts/enviveConfigContext/index.d.ts +3 -3
  109. package/dist/contexts/enviveConfigContext/index.js +4 -4
  110. package/dist/contexts/enviveCssContext/index.cjs +15 -15
  111. package/dist/contexts/enviveCssContext/index.js +15 -15
  112. package/dist/contexts/featureFlagContext/index.cjs +6 -6
  113. package/dist/contexts/featureFlagContext/index.d.cts +3 -3
  114. package/dist/contexts/featureFlagContext/index.d.ts +3 -3
  115. package/dist/contexts/featureFlagContext/index.js +6 -6
  116. package/dist/contexts/featureFlagServiceContext/index.cjs +3 -3
  117. package/dist/contexts/featureFlagServiceContext/index.d.cts +4 -4
  118. package/dist/contexts/featureFlagServiceContext/index.d.ts +4 -4
  119. package/dist/contexts/featureFlagServiceContext/index.js +3 -3
  120. package/dist/contexts/graphqlContext/index.cjs +11 -11
  121. package/dist/contexts/graphqlContext/index.d.cts +13 -12
  122. package/dist/contexts/graphqlContext/index.d.ts +13 -12
  123. package/dist/contexts/graphqlContext/index.js +11 -11
  124. package/dist/contexts/localStorageContext/index.cjs +2 -2
  125. package/dist/contexts/localStorageContext/index.js +2 -2
  126. package/dist/contexts/newOrgConfigContext/index.cjs +14 -14
  127. package/dist/contexts/newOrgConfigContext/index.d.cts +14 -13
  128. package/dist/contexts/newOrgConfigContext/index.d.ts +14 -13
  129. package/dist/contexts/newOrgConfigContext/index.js +14 -14
  130. package/dist/contexts/searchContext/index.cjs +17 -17
  131. package/dist/contexts/searchContext/index.d.cts +1 -1
  132. package/dist/contexts/searchContext/index.d.ts +1 -1
  133. package/dist/contexts/searchContext/index.js +17 -17
  134. package/dist/contexts/sessionStorageContext/index.cjs +2 -2
  135. package/dist/contexts/sessionStorageContext/index.js +2 -2
  136. package/dist/contexts/shopifyUrlContext/index.cjs +2 -2
  137. package/dist/contexts/shopifyUrlContext/index.d.cts +3 -3
  138. package/dist/contexts/shopifyUrlContext/index.d.ts +3 -3
  139. package/dist/contexts/shopifyUrlContext/index.js +2 -2
  140. package/dist/contexts/systemSettingsContext/index.cjs +4 -4
  141. package/dist/contexts/systemSettingsContext/index.d.cts +16 -15
  142. package/dist/contexts/systemSettingsContext/index.d.ts +16 -15
  143. package/dist/contexts/systemSettingsContext/index.js +4 -4
  144. package/dist/contexts/types.cjs +1 -1
  145. package/dist/contexts/types.d.cts +3 -3
  146. package/dist/contexts/types.d.ts +3 -3
  147. package/dist/contexts/types.js +1 -1
  148. package/dist/contexts/userIdentityContext/index.cjs +18 -18
  149. package/dist/contexts/userIdentityContext/index.d.cts +1 -1
  150. package/dist/contexts/userIdentityContext/index.d.ts +1 -1
  151. package/dist/contexts/userIdentityContext/index.js +18 -18
  152. package/dist/{enviveConfig-BlIkxiAF.js → enviveConfig-DZBohDpc.js} +3 -3
  153. package/dist/{enviveConfig-B42OJ8bK.cjs → enviveConfig-Dv9-esGV.cjs} +3 -3
  154. package/dist/{enviveConfigContext-Y1ahEAMe.cjs → enviveConfigContext-D2OELZDR.cjs} +3 -3
  155. package/dist/{enviveConfigContext-1_EivtCa.js → enviveConfigContext-DrDjCems.js} +3 -3
  156. package/dist/{featureFlagServiceContext-D3Ge8GH5.cjs → featureFlagServiceContext-CJyYItqu.cjs} +3 -3
  157. package/dist/{featureFlagServiceContext-C5U0bshi.d.ts → featureFlagServiceContext-CpxlOkI9.d.ts} +2 -2
  158. package/dist/{featureFlagServiceContext-CAPrb4e_.js → featureFlagServiceContext-FBM6DdMJ.js} +3 -3
  159. package/dist/{featureFlagServiceContext-CiKWV306.d.cts → featureFlagServiceContext-p5UBwPM3.d.cts} +2 -2
  160. package/dist/{featureGates-D4Me_IZH.js → featureGates-KEwAL8p_.js} +1 -1
  161. package/dist/{featureGates-Bt_Y3kZ7.cjs → featureGates-qU_ulhpC.cjs} +1 -1
  162. package/dist/{frontendConfig-BiD1-j48.d.ts → frontendConfig-Cawh5iqv.d.ts} +6 -3
  163. package/dist/{frontendConfig-tVg0hsWZ.d.cts → frontendConfig-iZipB5FG.d.cts} +6 -3
  164. package/dist/graphql-CkxgqsXP.js +48 -0
  165. package/dist/graphql-i3dtpVTl.cjs +71 -0
  166. package/dist/{graphqlContext-Bf3E-V2T.d.cts → graphqlContext-BeyKU1Dr.d.cts} +2 -2
  167. package/dist/{graphqlContext-CDeKzb46.d.ts → graphqlContext-CXQl0hq2.d.ts} +2 -2
  168. package/dist/{graphqlContext-CpwAvnro.cjs → graphqlContext-DP8T3-Kd.cjs} +6 -6
  169. package/dist/{graphqlContext-dyWNSWNv.js → graphqlContext-czH0kIZg.js} +5 -5
  170. package/dist/hooks/AmplitudeOperations/index.cjs +15 -15
  171. package/dist/hooks/AmplitudeOperations/index.d.cts +1 -1
  172. package/dist/hooks/AmplitudeOperations/index.d.ts +1 -1
  173. package/dist/hooks/AmplitudeOperations/index.js +15 -15
  174. package/dist/hooks/AppDetails/index.cjs +14 -14
  175. package/dist/hooks/AppDetails/index.d.cts +12 -11
  176. package/dist/hooks/AppDetails/index.d.ts +12 -11
  177. package/dist/hooks/AppDetails/index.js +14 -14
  178. package/dist/hooks/CdnOperations/index.cjs +4 -4
  179. package/dist/hooks/CdnOperations/index.js +4 -4
  180. package/dist/hooks/ChatToggle/index.cjs +16 -16
  181. package/dist/hooks/ChatToggle/index.d.cts +1 -1
  182. package/dist/hooks/ChatToggle/index.d.ts +1 -1
  183. package/dist/hooks/ChatToggle/index.js +16 -16
  184. package/dist/hooks/ChatToggleAnalytics/index.cjs +16 -16
  185. package/dist/hooks/ChatToggleAnalytics/index.d.cts +1 -1
  186. package/dist/hooks/ChatToggleAnalytics/index.d.ts +1 -1
  187. package/dist/hooks/ChatToggleAnalytics/index.js +16 -16
  188. package/dist/hooks/CustomerSupportHandoff/index.cjs +1 -1
  189. package/dist/hooks/CustomerSupportHandoff/index.js +1 -1
  190. package/dist/hooks/Debounce/index.cjs +20 -2
  191. package/dist/hooks/Debounce/index.js +18 -2
  192. package/dist/hooks/ElementObserver/index.d.cts +1 -1
  193. package/dist/hooks/ElementObserver/index.d.ts +1 -1
  194. package/dist/hooks/GrabAndScroll/index.d.cts +2 -2
  195. package/dist/hooks/GraphQLConfig/index.cjs +12 -12
  196. package/dist/hooks/GraphQLConfig/index.d.cts +13 -12
  197. package/dist/hooks/GraphQLConfig/index.d.ts +13 -12
  198. package/dist/hooks/GraphQLConfig/index.js +12 -12
  199. package/dist/hooks/IdentifyUser/index.cjs +18 -18
  200. package/dist/hooks/IdentifyUser/index.js +18 -18
  201. package/dist/hooks/ImageResolver/index.cjs +10 -10
  202. package/dist/hooks/ImageResolver/index.js +10 -10
  203. package/dist/hooks/LocalStorageOperations/index.cjs +2 -2
  204. package/dist/hooks/LocalStorageOperations/index.js +2 -2
  205. package/dist/hooks/MessageFilter/index.cjs +8 -8
  206. package/dist/hooks/MessageFilter/index.d.cts +12 -11
  207. package/dist/hooks/MessageFilter/index.d.ts +12 -11
  208. package/dist/hooks/MessageFilter/index.js +8 -8
  209. package/dist/hooks/NewOrgConfig/index.cjs +15 -15
  210. package/dist/hooks/NewOrgConfig/index.d.cts +14 -13
  211. package/dist/hooks/NewOrgConfig/index.d.ts +14 -13
  212. package/dist/hooks/NewOrgConfig/index.js +15 -15
  213. package/dist/hooks/Search/index.cjs +1459 -150
  214. package/dist/hooks/Search/index.d.cts +21 -17
  215. package/dist/hooks/Search/index.d.ts +21 -17
  216. package/dist/hooks/Search/index.js +1460 -151
  217. package/dist/hooks/SearchOperations/index.cjs +17 -17
  218. package/dist/hooks/SearchOperations/index.d.cts +1 -1
  219. package/dist/hooks/SearchOperations/index.d.ts +1 -1
  220. package/dist/hooks/SearchOperations/index.js +17 -17
  221. package/dist/hooks/SessionStorageOperations/index.cjs +2 -2
  222. package/dist/hooks/SessionStorageOperations/index.js +2 -2
  223. package/dist/hooks/ShopifyUrlOperations/index.cjs +2 -2
  224. package/dist/hooks/ShopifyUrlOperations/index.d.cts +5 -5
  225. package/dist/hooks/ShopifyUrlOperations/index.d.ts +5 -5
  226. package/dist/hooks/ShopifyUrlOperations/index.js +2 -2
  227. package/dist/hooks/SystemSettingsContext/index.cjs +5 -5
  228. package/dist/hooks/SystemSettingsContext/index.d.cts +14 -13
  229. package/dist/hooks/SystemSettingsContext/index.d.ts +14 -13
  230. package/dist/hooks/SystemSettingsContext/index.js +5 -5
  231. package/dist/hooks/TrackComponentVisibleEvent/index.cjs +15 -15
  232. package/dist/hooks/TrackComponentVisibleEvent/index.d.cts +2 -2
  233. package/dist/hooks/TrackComponentVisibleEvent/index.d.ts +2 -2
  234. package/dist/hooks/TrackComponentVisibleEvent/index.js +15 -15
  235. package/dist/hooks/UpdateAnalyticsProps/index.cjs +14 -14
  236. package/dist/hooks/UpdateAnalyticsProps/index.js +14 -14
  237. package/dist/hooks/utils.d.cts +12 -11
  238. package/dist/hooks/utils.d.ts +12 -11
  239. package/dist/{index-B6xpW8RG.d.ts → index--9_c4tze.d.ts} +1 -1
  240. package/dist/index-BEpDGqnz.d.cts +41 -0
  241. package/dist/{index-D31m6bPU.d.ts → index-BKvFVPUX.d.ts} +1 -1
  242. package/dist/{index-VwfWqyR_.d.ts → index-BNHIIgYk.d.ts} +1 -1
  243. package/dist/{index-Bq39XSmY.d.cts → index-BSd8767K.d.cts} +34 -34
  244. package/dist/index-BUDrAxnl.d.ts +673 -0
  245. package/dist/{index-DzbkQtaK.d.cts → index-CCboEuTO.d.cts} +1 -1
  246. package/dist/{index-FQjyuD3D.d.cts → index-COXkY78t.d.cts} +1 -1
  247. package/dist/{index-wFHfdr6p.d.ts → index-CUO68KG3.d.ts} +34 -34
  248. package/dist/{index--uHjE7L8.d.ts → index-D7htGSQC.d.ts} +1 -1
  249. package/dist/index-DM_5fh8c.d.ts +101 -0
  250. package/dist/index-DU7uw0ba.d.cts +101 -0
  251. package/dist/{index-Da1s8h5C.d.cts → index-DZtnHhlr.d.cts} +1 -1
  252. package/dist/{index-DSRs6N6J.d.ts → index-Dtw-hJdt.d.ts} +1 -1
  253. package/dist/index-Dy3TTIOm.d.cts +673 -0
  254. package/dist/index-ErVcwUnR.d.ts +41 -0
  255. package/dist/{index-Cyq5HiC0.d.cts → index-OkKEOL6H.d.cts} +1 -1
  256. package/dist/{index-9NE86em3.d.cts → index-hAqp0oYb.d.cts} +1 -1
  257. package/dist/interceptors/index.d.cts +13 -12
  258. package/dist/interceptors/index.d.ts +13 -12
  259. package/dist/interceptors/types.d.cts +12 -11
  260. package/dist/interceptors/types.d.ts +12 -11
  261. package/dist/{localStorageContext-DAOJ4be4.js → localStorageContext-BPZ82q-G.js} +2 -2
  262. package/dist/{localStorageContext-C5giszHn.cjs → localStorageContext-NRP-CdmF.cjs} +2 -2
  263. package/dist/{locators-C2fWd-74.js → locators-BMQGmGLq.js} +1 -1
  264. package/dist/{locators-Cx3q6Z_h.cjs → locators-DxYdak1F.cjs} +1 -1
  265. package/dist/{logger-0D_8Ip2L.cjs → logger-TBIl4uIH.cjs} +1 -1
  266. package/dist/{logger-Co0IA3k5.js → logger-W3lqg-4b.js} +1 -1
  267. package/dist/models-CWOgrLCm.js +1284 -0
  268. package/dist/models-DqdLOi2I.cjs +1519 -0
  269. package/dist/{newOrgConfigContext-BMvcqPzD.cjs → newOrgConfigContext-Bet9CgKP.cjs} +4 -4
  270. package/dist/{newOrgConfigContext-6mlrvr1w.js → newOrgConfigContext-Bi_dBNe5.js} +4 -4
  271. package/dist/{newOrgConfigContext-DOdUxlOE.d.cts → newOrgConfigContext-CJI3tsVV.d.cts} +2 -2
  272. package/dist/{newOrgConfigContext-BVyJExeW.d.ts → newOrgConfigContext-I2qceBB4.d.ts} +2 -2
  273. package/dist/{nodeSelector-DYhDUi7v.d.ts → nodeSelector-B5NfnUHv.d.ts} +1 -1
  274. package/dist/{nodeSelector-B3bPtEjX.d.cts → nodeSelector-vKB44CDB.d.cts} +1 -1
  275. package/dist/responseGenerics-D9bS-Dd6.d.ts +148 -0
  276. package/dist/{index-Cx9e-fRi.d.ts → responseGenerics-DWLV09cQ.d.cts} +4 -40
  277. package/dist/{search-y-ioX5Mz.d.cts → search-6RrxBXD6.d.cts} +1 -1
  278. package/dist/{search-D-UfTjB7.cjs → search-Csh2n66W.cjs} +2 -2
  279. package/dist/{search-yawhMv22.js → search-DkiqkogN.js} +2 -2
  280. package/dist/{search-B1OtJe8Z.d.ts → search-DrJiCT7d.d.ts} +1 -1
  281. package/dist/{search-filter-types-BxaNSLs_.d.cts → search-filter-types-BItKtezf.d.cts} +1 -1
  282. package/dist/{search-filter-types-OI9zH3E_.d.ts → search-filter-types-CGFhksO3.d.ts} +1 -1
  283. package/dist/{searchContext-CiqOqTJL.js → searchContext-BmgoAFMF.js} +6 -6
  284. package/dist/{searchContext-CFuwIIW-.cjs → searchContext-DksJfC1s.cjs} +6 -6
  285. package/dist/{sessionStorageContext-BmCW091C.cjs → sessionStorageContext-B6FsNKjj.cjs} +2 -2
  286. package/dist/{sessionStorageContext-CNxkqJi1.js → sessionStorageContext-CLYCm83p.js} +2 -2
  287. package/dist/{shopifyUrlContext-BXbI0PIG.js → shopifyUrlContext-C-PkSgNC.js} +2 -2
  288. package/dist/{shopifyUrlContext-aZMwCfbJ.cjs → shopifyUrlContext-ZOcARiMR.cjs} +2 -2
  289. package/dist/{spiffyWidgets-CvEJIuJx.d.ts → spiffyWidgets-CR6F7FRE.d.ts} +1 -1
  290. package/dist/{spiffyWidgets-BuS00VaQ.d.cts → spiffyWidgets-eNbU1gMc.d.cts} +1 -1
  291. package/dist/{systemSettingsContext-kz6yyiFF.js → systemSettingsContext-DF0jSq9m.js} +2 -2
  292. package/dist/{systemSettingsContext-SozpUezn.cjs → systemSettingsContext-dmE1v6w8.cjs} +2 -2
  293. package/dist/{test-types-DRhqHXw-.d.ts → test-types-BEml_bm3.d.ts} +1 -1
  294. package/dist/{test-types-ThQiO_cc.d.cts → test-types-Dsu8RJZu.d.cts} +1 -1
  295. package/dist/types/index.d.cts +2 -2
  296. package/dist/types/index.d.ts +2 -2
  297. package/dist/{types-r0Z6CwyF.d.ts → types-4LQ7LUCk.d.ts} +2 -2
  298. package/dist/types-BegmH0S1.d.ts +60 -0
  299. package/dist/types-BuvXXGxE.cjs +1 -1
  300. package/dist/types-CtUb63bt.js +76 -0
  301. package/dist/{types-zQGBI-Yo.d.cts → types-DFsSqmWx.d.cts} +2 -2
  302. package/dist/types-DWorwfS-.d.cts +60 -0
  303. package/dist/types-DXnG1tV0.js +1 -1
  304. package/dist/types-UUvB6h05.cjs +106 -0
  305. package/dist/types.d.cts +3 -3
  306. package/dist/types.d.ts +3 -3
  307. package/dist/{unsupportedProductExceptions-B4f9aLjr.cjs → unsupportedProductExceptions-DGENUnEA.cjs} +1 -1
  308. package/dist/{unsupportedProductExceptions-DlmraJm8.js → unsupportedProductExceptions-uQuuelOs.js} +1 -1
  309. package/dist/{urlsParser-DhcEZLc_.cjs → urlsParser-COzMdJaX.cjs} +1 -1
  310. package/dist/{urlsParser-DLCzibqU.js → urlsParser-DxjoLj98.js} +1 -1
  311. package/dist/{useAmplitudeOperations-D0nvIYlt.cjs → useAmplitudeOperations-Bo6YNbTV.cjs} +2 -2
  312. package/dist/{useAmplitudeOperations-Dhks3PgF.js → useAmplitudeOperations-zIRSqmMW.js} +2 -2
  313. package/dist/{useAppDetails-qyaQIbWE.js → useAppDetails-B584gkCs.js} +4 -4
  314. package/dist/{useAppDetails-B9sGmpJ3.cjs → useAppDetails-DczgqeLG.cjs} +4 -4
  315. package/dist/{useGraphQLConfig-BccQUaeW.js → useGraphQLConfig-7UxACM4n.js} +2 -2
  316. package/dist/{useGraphQLConfig-CgKEfVYc.cjs → useGraphQLConfig-D_rF2Sun.cjs} +2 -2
  317. package/dist/{userIdentityContext-Cb6lLv6t.cjs → userIdentityContext-BqbNu7xu.cjs} +5 -5
  318. package/dist/{userIdentityContext-O_DHHPTN.js → userIdentityContext-BxFH9FNQ.js} +5 -5
  319. package/dist/{userIdentityContext-BKLedN4R.d.ts → userIdentityContext-C6kApbuk.d.ts} +1 -1
  320. package/dist/{userIdentityContext-D2oFVFzo.d.cts → userIdentityContext-kU1PIo8K.d.cts} +1 -1
  321. package/dist/{utils-BhyZiDrE.d.ts → utils-BRkGP1eb.d.ts} +1 -1
  322. package/dist/{utils-DFPt3FSw.js → utils-C1ErYSoW.js} +4 -4
  323. package/dist/{utils-B7PAzB_M.d.cts → utils-CBD4g2Nc.d.cts} +4 -4
  324. package/dist/{utils-C6imnLBo.cjs → utils-CDw74BCO.cjs} +1 -1
  325. package/dist/{utils-B3x_9JTY.d.cts → utils-DCrwX6FT.d.cts} +1 -1
  326. package/dist/{utils-C4ci_t0-.js → utils-DIvMgPe8.js} +1 -1
  327. package/dist/{utils-B1v0iXs3.d.ts → utils-QKFAbPT6.d.ts} +4 -4
  328. package/dist/{utils-Cazq8Q3q.cjs → utils-mqfncrhI.cjs} +4 -4
  329. package/package.json +5 -1
  330. package/src/application/commerce-api.ts +2 -0
  331. package/src/application/models/graphql/index.ts +1 -0
  332. package/src/atoms/search/productRetrievalAPI.ts +70 -0
  333. package/src/atoms/search/productRetrievalAdapter.ts +25 -0
  334. package/src/atoms/search/types.ts +13 -0
  335. package/src/contexts/graphqlContext/__tests__/graphqlContext.test.tsx +790 -0
  336. package/src/contexts/localStorageContext/__tests__/localStorageContext.test.tsx +775 -0
  337. package/src/contexts/newOrgConfigContext/__tests__/newOrgConfigContext.test.tsx +495 -0
  338. package/src/contexts/searchContext/__tests__/searchContext.test.tsx +806 -0
  339. package/src/contexts/systemSettingsContext/__tests__/systemSettingsContext.test.tsx +506 -0
  340. package/src/contexts/types.ts +3 -0
  341. package/src/hooks/Search/useRecommendedProducts.ts +48 -0
  342. package/src/hooks/Search/useSearch.tsx +89 -182
  343. package/src/hooks/Search/useSearchInput.ts +263 -0
  344. package/src/types/FilterAttribute.ts +35 -0
  345. package/dist/graphql-OkhsP4ir.js +0 -36
  346. package/dist/graphql-l4dQrsA6.cjs +0 -53
  347. package/dist/index-Bmub8e38.d.cts +0 -98
  348. package/dist/index-CG3P8xE1.d.cts +0 -676
  349. package/dist/index-CiWEYzXl.d.cts +0 -184
  350. package/dist/index-D2VaMPA3.d.ts +0 -98
  351. package/dist/index-fUsw_Mea.d.ts +0 -676
  352. package/dist/models-CkJ-wg9Q.cjs +0 -1537
  353. package/dist/models-UHOY0ak5.js +0 -1296
  354. package/dist/types-BwNrLPSZ.cjs +0 -106
  355. package/dist/types-CKMMb_gX.d.cts +0 -51
  356. package/dist/types-D3uOF0Oy.js +0 -76
  357. package/dist/types-DZPuBnHe.d.ts +0 -51
  358. package/dist/useDebounce-BZDtUAQ8.cjs +0 -26
  359. package/dist/useDebounce-ueblXZI-.js +0 -19
  360. /package/dist/{index-RcVcRKH7.d.cts → index-A0HvA68Y.d.cts} +0 -0
  361. /package/dist/{index-mHc9_XC3.d.ts → index-DNVvRcKu.d.ts} +0 -0
@@ -0,0 +1,806 @@
1
+ import React from "react";
2
+ import { render, screen, waitFor, act } from "@testing-library/react";
3
+ import { Provider } from "jotai";
4
+ import { useAtomValue } from "jotai";
5
+ import {
6
+ SearchProvider,
7
+ useSearchService,
8
+ } from "../searchContext";
9
+ import { EnviveConfigProvider } from "src/contexts/enviveConfigContext/enviveConfigContext";
10
+ import { LocalStorageProvider } from "src/contexts/localStorageContext/localStorageContext";
11
+ import { GraphQLProvider } from "src/contexts/graphqlContext/graphqlContext";
12
+ import { UserIdentityProvider } from "src/contexts/userIdentityContext/userIdentityContext";
13
+ import { FeatureFlagServiceProvider } from "src/contexts/featureFlagServiceContext/featureFlagServiceContext";
14
+ import { baseUrlAtom } from "src/atoms/envive/enviveConfig";
15
+ import { setSearchServiceFunction, clearSearchServiceFunction, getSearchServiceFunction } from "src/atoms/search/searchServiceAdapter";
16
+ import { SearchParams, SearchResult } from "src/application/models/api/search";
17
+ import { SessionRestartRequired } from "src/types/exceptions/sessionExceptions";
18
+ import { UnsupportedProductException } from "src/types/exceptions/unsupportedProductExceptions";
19
+ import { ResponseCategory } from "@spiffy-ai/commerce-api-client";
20
+
21
+ // Mock the commerce-api-client
22
+ const mockV1SearchQueryGet = vi.fn();
23
+ const mockSearchApiConstructor = vi.fn();
24
+ const mockConfigurationConstructor = vi.fn();
25
+
26
+ vi.mock("@spiffy-ai/commerce-api-client", () => {
27
+ const mockV1SearchQueryGet = vi.fn();
28
+ const mockSearchApiConstructor = vi.fn(function SearchApi() {
29
+ return {
30
+ v1SearchQueryGet: mockV1SearchQueryGet,
31
+ };
32
+ });
33
+ const mockConfigurationConstructor = vi.fn(function Configuration() {});
34
+
35
+ return {
36
+ SearchApi: mockSearchApiConstructor,
37
+ Configuration: mockConfigurationConstructor,
38
+ ResponseCategory: {
39
+ Product: "product",
40
+ },
41
+ ResponseError: class ResponseError extends Error {
42
+ response: any;
43
+ constructor(message: string, response?: any) {
44
+ super(message);
45
+ this.response = response;
46
+ }
47
+ },
48
+ __getMocks: () => ({
49
+ mockV1SearchQueryGet,
50
+ mockSearchApiConstructor,
51
+ mockConfigurationConstructor,
52
+ }),
53
+ };
54
+ });
55
+
56
+ // Mock useAppDetails
57
+ vi.mock("src/hooks/AppDetails/useAppDetails", () => ({
58
+ useAppDetails: vi.fn(),
59
+ }));
60
+
61
+ // Mock useEnviveConfig
62
+ vi.mock("src/contexts/enviveConfigContext/enviveConfigContext", async () => {
63
+ const actual = await vi.importActual("src/contexts/enviveConfigContext/enviveConfigContext");
64
+ return {
65
+ ...actual,
66
+ useEnviveConfig: vi.fn(),
67
+ };
68
+ });
69
+
70
+ // Mock Logger
71
+ vi.mock("src/application/logging/logger", () => ({
72
+ default: {
73
+ logInfo: vi.fn(),
74
+ logWarn: vi.fn(),
75
+ logError: vi.fn(),
76
+ logDebug: vi.fn(),
77
+ },
78
+ }));
79
+
80
+ // Mock the search service adapter
81
+ vi.mock("src/atoms/search/searchServiceAdapter", () => ({
82
+ setSearchServiceFunction: vi.fn(),
83
+ clearSearchServiceFunction: vi.fn(),
84
+ getSearchServiceFunction: vi.fn(),
85
+ }));
86
+
87
+ import { useAppDetails } from "src/hooks/AppDetails/useAppDetails";
88
+ import { useEnviveConfig } from "src/contexts/enviveConfigContext/enviveConfigContext";
89
+ import * as commerceApiClient from "@spiffy-ai/commerce-api-client";
90
+
91
+ // Get mocked functions
92
+ const getMocks = () => {
93
+ return (commerceApiClient as any).__getMocks();
94
+ };
95
+
96
+ // Component that uses the useSearchService hook
97
+ const MockSearchComponent: React.FC = () => {
98
+ const { searchProducts, isReady } = useSearchService();
99
+ const [result, setResult] = React.useState<SearchResult | null>(null);
100
+ const [error, setError] = React.useState<string | null>(null);
101
+ const [loading, setLoading] = React.useState(false);
102
+
103
+ const handleSearch = async () => {
104
+ setLoading(true);
105
+ setError(null);
106
+ try {
107
+ const searchResult = await searchProducts({ query: "test query", limit: 10 });
108
+ setResult(searchResult);
109
+ } catch (err: any) {
110
+ setError(err.message);
111
+ } finally {
112
+ setLoading(false);
113
+ }
114
+ };
115
+
116
+ return (
117
+ <div data-testid="search-component">
118
+ <div data-testid="is-ready">{isReady.toString()}</div>
119
+ <div data-testid="loading">{loading.toString()}</div>
120
+ <div data-testid="error">{error || "null"}</div>
121
+ {result && (
122
+ <>
123
+ <div data-testid="result-products-count">{result.products.length}</div>
124
+ <div data-testid="result-total-count">{result.totalProductCount}</div>
125
+ <div data-testid="result-response-id">{result.searchResponseId}</div>
126
+ </>
127
+ )}
128
+ <button data-testid="search-btn" onClick={handleSearch}>
129
+ Search
130
+ </button>
131
+ </div>
132
+ );
133
+ };
134
+
135
+ // Component that reads baseUrlAtom
136
+ const BaseUrlReaderComponent: React.FC = () => {
137
+ const baseUrl = useAtomValue(baseUrlAtom);
138
+ return <div data-testid="base-url">{baseUrl || "not-set"}</div>;
139
+ };
140
+
141
+ // Wrapper component to ensure providers are in correct order
142
+ const TestWrapper: React.FC<{
143
+ children: React.ReactNode;
144
+ orgLevelApiKey?: string;
145
+ publicKey?: string;
146
+ baseUrl?: string;
147
+ appDetails?: {
148
+ orgId?: string;
149
+ userId?: string;
150
+ orgShortName?: string;
151
+ chatId?: string;
152
+ source?: any;
153
+ env?: any;
154
+ variantInfo?: any;
155
+ };
156
+ }> = ({
157
+ children,
158
+ orgLevelApiKey,
159
+ publicKey,
160
+ baseUrl = "https://test-api.example.com",
161
+ appDetails = {
162
+ orgId: "test-org-id",
163
+ userId: "test-user-id",
164
+ orgShortName: "test-org",
165
+ chatId: "test-chat-id",
166
+ source: "app",
167
+ env: "dev",
168
+ variantInfo: {},
169
+ },
170
+ }) => {
171
+ // Mock useEnviveConfig
172
+ (useEnviveConfig as any).mockReturnValue({
173
+ orgLevelApiKey,
174
+ publicKey,
175
+ });
176
+
177
+ // Mock useAppDetails
178
+ (useAppDetails as any).mockReturnValue(appDetails);
179
+
180
+ return (
181
+ <Provider>
182
+ <EnviveConfigProvider
183
+ identifyingPrefix="test"
184
+ orgShortName={appDetails?.orgShortName || "test-org"}
185
+ baseUrl={baseUrl}
186
+ orgLevelApiKey={orgLevelApiKey}
187
+ publicKey={publicKey}
188
+ >
189
+ <LocalStorageProvider>
190
+ <GraphQLProvider>
191
+ <UserIdentityProvider>
192
+ <FeatureFlagServiceProvider featureGates={[]}>
193
+ <SearchProvider>{children}</SearchProvider>
194
+ </FeatureFlagServiceProvider>
195
+ </UserIdentityProvider>
196
+ </GraphQLProvider>
197
+ </LocalStorageProvider>
198
+ </EnviveConfigProvider>
199
+ </Provider>
200
+ );
201
+ };
202
+
203
+ describe("SearchProvider", () => {
204
+ let mocks: ReturnType<typeof getMocks>;
205
+
206
+ beforeEach(() => {
207
+ vi.clearAllMocks();
208
+ mocks = getMocks();
209
+ mocks.mockV1SearchQueryGet.mockReset();
210
+ mocks.mockSearchApiConstructor.mockClear();
211
+ mocks.mockConfigurationConstructor.mockClear();
212
+ (setSearchServiceFunction as any).mockClear();
213
+ (clearSearchServiceFunction as any).mockClear();
214
+ });
215
+
216
+ describe("useSearchService Hook Integration", () => {
217
+ it("should provide context through useSearchService hook", async () => {
218
+ render(
219
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
220
+ <MockSearchComponent />
221
+ </TestWrapper>
222
+ );
223
+
224
+ await waitFor(() => {
225
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
226
+ });
227
+
228
+ expect(screen.getByTestId("search-component")).toBeInTheDocument();
229
+ });
230
+
231
+ it("should throw error when used outside of SearchProvider", () => {
232
+ const consoleSpy = vi
233
+ .spyOn(console, "error")
234
+ .mockImplementation(() => {});
235
+
236
+ const TestComponent: React.FC = () => {
237
+ try {
238
+ useSearchService();
239
+ return <div data-testid="no-error">No Error</div>;
240
+ } catch (error: any) {
241
+ return <div data-testid="error">{error.message}</div>;
242
+ }
243
+ };
244
+
245
+ render(
246
+ <Provider>
247
+ <TestComponent />
248
+ </Provider>
249
+ );
250
+
251
+ expect(screen.getByTestId("error")).toHaveTextContent(
252
+ "useSearchService must be used within a SearchProvider"
253
+ );
254
+
255
+ consoleSpy.mockRestore();
256
+ });
257
+ });
258
+
259
+ describe("isReady State", () => {
260
+ it("should be false when orgLevelApiKey is missing", async () => {
261
+ render(
262
+ <TestWrapper baseUrl="https://test-api.example.com">
263
+ <MockSearchComponent />
264
+ </TestWrapper>
265
+ );
266
+
267
+ await waitFor(() => {
268
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("false");
269
+ });
270
+ });
271
+
272
+ it("should use default baseUrl when baseUrl is not provided", async () => {
273
+ // baseUrlAtom has a default value, so even if baseUrl is empty, it will use the default
274
+ // This test verifies that isReady works with the default baseUrl
275
+ render(
276
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="">
277
+ <MockSearchComponent />
278
+ </TestWrapper>
279
+ );
280
+
281
+ await waitFor(() => {
282
+ // baseUrlAtom has a default, so isReady should be true if apiKey and appDetails are available
283
+ const isReadyElement = screen.getByTestId("is-ready");
284
+ expect(isReadyElement).toBeInTheDocument();
285
+ });
286
+ });
287
+
288
+ it("should be false when appDetails is missing", async () => {
289
+ (useAppDetails as any).mockReturnValue(null);
290
+
291
+ render(
292
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com" appDetails={null as any}>
293
+ <MockSearchComponent />
294
+ </TestWrapper>
295
+ );
296
+
297
+ await waitFor(() => {
298
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("false");
299
+ });
300
+ });
301
+
302
+ it("should be true when all dependencies are available", async () => {
303
+ render(
304
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
305
+ <MockSearchComponent />
306
+ </TestWrapper>
307
+ );
308
+
309
+ await waitFor(() => {
310
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
311
+ });
312
+ });
313
+
314
+ it("should use publicKey when orgLevelApiKey is not available", async () => {
315
+ render(
316
+ <TestWrapper publicKey="public-key" baseUrl="https://test-api.example.com">
317
+ <MockSearchComponent />
318
+ </TestWrapper>
319
+ );
320
+
321
+ await waitFor(() => {
322
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
323
+ });
324
+ });
325
+ });
326
+
327
+ describe("SearchApi Initialization", () => {
328
+ it("should create SearchApi with correct configuration when ready", async () => {
329
+ render(
330
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
331
+ <MockSearchComponent />
332
+ </TestWrapper>
333
+ );
334
+
335
+ await waitFor(() => {
336
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
337
+ });
338
+
339
+ expect(mocks.mockConfigurationConstructor).toHaveBeenCalledWith(
340
+ expect.objectContaining({
341
+ accessToken: "test-key",
342
+ basePath: "https://test-api.example.com",
343
+ headers: {
344
+ "Content-Type": "application/json",
345
+ Accept: "application/json",
346
+ },
347
+ })
348
+ );
349
+ expect(mocks.mockSearchApiConstructor).toHaveBeenCalled();
350
+ });
351
+
352
+ it("should not create SearchApi when not ready", async () => {
353
+ render(
354
+ <TestWrapper baseUrl="https://test-api.example.com">
355
+ <MockSearchComponent />
356
+ </TestWrapper>
357
+ );
358
+
359
+ await waitFor(() => {
360
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("false");
361
+ });
362
+
363
+ // SearchApi should not be created when not ready
364
+ expect(mocks.mockSearchApiConstructor).not.toHaveBeenCalled();
365
+ });
366
+ });
367
+
368
+ describe("searchProducts Function", () => {
369
+ it("should search products successfully", async () => {
370
+ const mockResponse = {
371
+ products: [
372
+ {
373
+ id: "product-1",
374
+ response_id: "resp-1",
375
+ description: "Test product",
376
+ image_url: "https://example.com/image.jpg",
377
+ image_urls: ["https://example.com/image.jpg"],
378
+ title: "Test Product",
379
+ url: "https://example.com/product",
380
+ original_price: 100,
381
+ sale_price: 80,
382
+ average_rating: 4.5,
383
+ number_reviews: 10,
384
+ metadata: {},
385
+ is_for_grid: true,
386
+ colors: [],
387
+ sizes: [],
388
+ filters: [],
389
+ },
390
+ ],
391
+ filters: ["filter1", "filter2"],
392
+ search_response_id: "search-resp-1",
393
+ };
394
+
395
+ mocks.mockV1SearchQueryGet.mockResolvedValueOnce(mockResponse);
396
+
397
+ render(
398
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
399
+ <MockSearchComponent />
400
+ </TestWrapper>
401
+ );
402
+
403
+ await waitFor(() => {
404
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
405
+ });
406
+
407
+ await act(async () => {
408
+ screen.getByTestId("search-btn").click();
409
+ });
410
+
411
+ await waitFor(() => {
412
+ expect(screen.getByTestId("result-products-count")).toHaveTextContent("1");
413
+ });
414
+
415
+ expect(mocks.mockV1SearchQueryGet).toHaveBeenCalledWith({
416
+ query: "test query",
417
+ limit: 10,
418
+ org_id: "test-org-id",
419
+ user_id: "test-user-id",
420
+ });
421
+
422
+ expect(screen.getByTestId("result-total-count")).toHaveTextContent("1");
423
+ expect(screen.getByTestId("result-response-id")).toHaveTextContent("search-resp-1");
424
+ });
425
+
426
+ it("should transform product responses correctly", async () => {
427
+ const mockResponse = {
428
+ products: [
429
+ {
430
+ id: "product-1",
431
+ response_id: "resp-1",
432
+ description: "Test product",
433
+ image_url: "https://example.com/image.jpg",
434
+ image_urls: ["https://example.com/image1.jpg", "https://example.com/image2.jpg"],
435
+ title: "Test Product",
436
+ url: "https://example.com/product",
437
+ original_price: 100,
438
+ sale_price: 80,
439
+ average_rating: 4.5,
440
+ number_reviews: 10,
441
+ metadata: { key: "value" },
442
+ is_for_grid: true,
443
+ colors: ["red", "blue"],
444
+ sizes: ["S", "M", "L"],
445
+ filters: ["filter1"],
446
+ },
447
+ ],
448
+ filters: ["filter1"],
449
+ search_response_id: "search-resp-1",
450
+ };
451
+
452
+ mocks.mockV1SearchQueryGet.mockResolvedValueOnce(mockResponse);
453
+
454
+ render(
455
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
456
+ <MockSearchComponent />
457
+ </TestWrapper>
458
+ );
459
+
460
+ await waitFor(() => {
461
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
462
+ });
463
+
464
+ await act(async () => {
465
+ screen.getByTestId("search-btn").click();
466
+ });
467
+
468
+ await waitFor(() => {
469
+ expect(screen.getByTestId("result-products-count")).toHaveTextContent("1");
470
+ });
471
+
472
+ // Verify the transformed product has correct structure
473
+ const searchResult = await screen.findByTestId("result-products-count");
474
+ expect(searchResult).toBeInTheDocument();
475
+ });
476
+
477
+ it("should handle empty search results", async () => {
478
+ const mockResponse = {
479
+ products: [],
480
+ filters: [],
481
+ search_response_id: "",
482
+ };
483
+
484
+ mocks.mockV1SearchQueryGet.mockResolvedValueOnce(mockResponse);
485
+
486
+ render(
487
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
488
+ <MockSearchComponent />
489
+ </TestWrapper>
490
+ );
491
+
492
+ await waitFor(() => {
493
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
494
+ });
495
+
496
+ await act(async () => {
497
+ screen.getByTestId("search-btn").click();
498
+ });
499
+
500
+ await waitFor(() => {
501
+ expect(screen.getByTestId("result-products-count")).toHaveTextContent("0");
502
+ });
503
+
504
+ expect(screen.getByTestId("result-total-count")).toHaveTextContent("0");
505
+ });
506
+
507
+ it("should throw error when not ready", async () => {
508
+ render(
509
+ <TestWrapper baseUrl="https://test-api.example.com">
510
+ <MockSearchComponent />
511
+ </TestWrapper>
512
+ );
513
+
514
+ await waitFor(() => {
515
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("false");
516
+ });
517
+
518
+ await act(async () => {
519
+ screen.getByTestId("search-btn").click();
520
+ });
521
+
522
+ await waitFor(() => {
523
+ expect(screen.getByTestId("error")).toHaveTextContent(
524
+ "SearchService not ready - missing dependencies"
525
+ );
526
+ });
527
+ });
528
+ });
529
+
530
+ describe("Error Handling", () => {
531
+ it("should throw SessionRestartRequired for RESTART_SESSION error", async () => {
532
+ const { ResponseError } = await import("@spiffy-ai/commerce-api-client");
533
+ const mockError = new (ResponseError as any)("Session error", {
534
+ json: async () => ({
535
+ app_code: "RESTART_SESSION",
536
+ }),
537
+ });
538
+
539
+ mocks.mockV1SearchQueryGet.mockRejectedValueOnce(mockError);
540
+
541
+ render(
542
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
543
+ <MockSearchComponent />
544
+ </TestWrapper>
545
+ );
546
+
547
+ await waitFor(() => {
548
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
549
+ });
550
+
551
+ await act(async () => {
552
+ screen.getByTestId("search-btn").click();
553
+ });
554
+
555
+ await waitFor(() => {
556
+ expect(screen.getByTestId("error")).toHaveTextContent("Session restart required");
557
+ });
558
+ });
559
+
560
+ it("should throw SessionRestartRequired for NOT_FOUND sub_code", async () => {
561
+ const { ResponseError } = await import("@spiffy-ai/commerce-api-client");
562
+ const mockError = new (ResponseError as any)("Not found error", {
563
+ json: async () => ({
564
+ sub_code: "NOT_FOUND",
565
+ }),
566
+ });
567
+
568
+ mocks.mockV1SearchQueryGet.mockRejectedValueOnce(mockError);
569
+
570
+ render(
571
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
572
+ <MockSearchComponent />
573
+ </TestWrapper>
574
+ );
575
+
576
+ await waitFor(() => {
577
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
578
+ });
579
+
580
+ await act(async () => {
581
+ screen.getByTestId("search-btn").click();
582
+ });
583
+
584
+ await waitFor(() => {
585
+ expect(screen.getByTestId("error")).toHaveTextContent("Session restart required");
586
+ });
587
+ });
588
+
589
+ it("should throw UnsupportedProductException for unsupported product message", async () => {
590
+ const { ResponseError } = await import("@spiffy-ai/commerce-api-client");
591
+ const mockError = new (ResponseError as any)("Unsupported product", {
592
+ json: async () => ({
593
+ message: "unsupported product",
594
+ }),
595
+ });
596
+
597
+ mocks.mockV1SearchQueryGet.mockRejectedValueOnce(mockError);
598
+
599
+ render(
600
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
601
+ <MockSearchComponent />
602
+ </TestWrapper>
603
+ );
604
+
605
+ await waitFor(() => {
606
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
607
+ });
608
+
609
+ await act(async () => {
610
+ screen.getByTestId("search-btn").click();
611
+ });
612
+
613
+ await waitFor(() => {
614
+ expect(screen.getByTestId("error")).toHaveTextContent("Unsupported product");
615
+ });
616
+ });
617
+
618
+ it("should throw UnsupportedProductException for PRODUCT_NOT_FOUND app_code", async () => {
619
+ const { ResponseError } = await import("@spiffy-ai/commerce-api-client");
620
+ const mockError = new (ResponseError as any)("Product not found", {
621
+ json: async () => ({
622
+ app_code: "PRODUCT_NOT_FOUND",
623
+ }),
624
+ });
625
+
626
+ mocks.mockV1SearchQueryGet.mockRejectedValueOnce(mockError);
627
+
628
+ render(
629
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
630
+ <MockSearchComponent />
631
+ </TestWrapper>
632
+ );
633
+
634
+ await waitFor(() => {
635
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
636
+ });
637
+
638
+ await act(async () => {
639
+ screen.getByTestId("search-btn").click();
640
+ });
641
+
642
+ await waitFor(() => {
643
+ expect(screen.getByTestId("error")).toHaveTextContent("Unsupported product");
644
+ });
645
+ });
646
+
647
+ it("should rethrow non-ResponseError errors", async () => {
648
+ const genericError = new Error("Generic error");
649
+ mocks.mockV1SearchQueryGet.mockRejectedValueOnce(genericError);
650
+
651
+ render(
652
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
653
+ <MockSearchComponent />
654
+ </TestWrapper>
655
+ );
656
+
657
+ await waitFor(() => {
658
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
659
+ });
660
+
661
+ await act(async () => {
662
+ screen.getByTestId("search-btn").click();
663
+ });
664
+
665
+ await waitFor(() => {
666
+ const errorElement = screen.getByTestId("error");
667
+ expect(errorElement).toBeInTheDocument();
668
+ expect(errorElement.textContent).not.toBe("null");
669
+ });
670
+ });
671
+
672
+ it("should handle ResponseError with invalid JSON response", async () => {
673
+ const { ResponseError } = await import("@spiffy-ai/commerce-api-client");
674
+ const mockError = new (ResponseError as any)("Error", {
675
+ json: async () => {
676
+ throw new Error("Invalid JSON");
677
+ },
678
+ });
679
+
680
+ mocks.mockV1SearchQueryGet.mockRejectedValueOnce(mockError);
681
+
682
+ render(
683
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
684
+ <MockSearchComponent />
685
+ </TestWrapper>
686
+ );
687
+
688
+ await waitFor(() => {
689
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
690
+ });
691
+
692
+ await act(async () => {
693
+ screen.getByTestId("search-btn").click();
694
+ });
695
+
696
+ // Should still throw the original error
697
+ await waitFor(() => {
698
+ const errorElement = screen.getByTestId("error");
699
+ expect(errorElement).toBeInTheDocument();
700
+ expect(errorElement.textContent).not.toBe("null");
701
+ }, { timeout: 2000 });
702
+ });
703
+ });
704
+
705
+ describe("Search Service Adapter Integration", () => {
706
+ it("should register search function when ready", async () => {
707
+ render(
708
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
709
+ <MockSearchComponent />
710
+ </TestWrapper>
711
+ );
712
+
713
+ await waitFor(() => {
714
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
715
+ });
716
+
717
+ await waitFor(() => {
718
+ expect(setSearchServiceFunction).toHaveBeenCalled();
719
+ }, { timeout: 2000 });
720
+ });
721
+
722
+ it("should clear search function when not ready", async () => {
723
+ render(
724
+ <TestWrapper baseUrl="https://test-api.example.com">
725
+ <MockSearchComponent />
726
+ </TestWrapper>
727
+ );
728
+
729
+ await waitFor(() => {
730
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("false");
731
+ });
732
+
733
+ await waitFor(() => {
734
+ expect(clearSearchServiceFunction).toHaveBeenCalled();
735
+ });
736
+ });
737
+
738
+ it("should clear search function on unmount", async () => {
739
+ const { unmount } = render(
740
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
741
+ <MockSearchComponent />
742
+ </TestWrapper>
743
+ );
744
+
745
+ await waitFor(() => {
746
+ expect(screen.getByTestId("is-ready")).toHaveTextContent("true");
747
+ });
748
+
749
+ unmount();
750
+
751
+ await waitFor(() => {
752
+ expect(clearSearchServiceFunction).toHaveBeenCalled();
753
+ });
754
+ });
755
+ });
756
+
757
+ describe("Context Value Memoization", () => {
758
+ it("should maintain stable context value references", async () => {
759
+ let contextValue1: any;
760
+ let contextValue2: any;
761
+
762
+ const Component1: React.FC = () => {
763
+ const context = useSearchService();
764
+ contextValue1 = context;
765
+ return <div>Component1</div>;
766
+ };
767
+
768
+ const Component2: React.FC = () => {
769
+ const context = useSearchService();
770
+ contextValue2 = context;
771
+ return <div>Component2</div>;
772
+ };
773
+
774
+ render(
775
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://test-api.example.com">
776
+ <Component1 />
777
+ <Component2 />
778
+ </TestWrapper>
779
+ );
780
+
781
+ await waitFor(() => {
782
+ expect(contextValue1).toBeDefined();
783
+ expect(contextValue2).toBeDefined();
784
+ // Both components should receive the same context instance
785
+ expect(contextValue1).toBe(contextValue2);
786
+ });
787
+ });
788
+ });
789
+
790
+ describe("BaseUrl Atom Integration", () => {
791
+ it("should read baseUrl from atom", async () => {
792
+ render(
793
+ <TestWrapper orgLevelApiKey="test-key" baseUrl="https://custom-api.example.com">
794
+ <BaseUrlReaderComponent />
795
+ </TestWrapper>
796
+ );
797
+
798
+ await waitFor(() => {
799
+ expect(screen.getByTestId("base-url")).toHaveTextContent(
800
+ "https://custom-api.example.com"
801
+ );
802
+ });
803
+ });
804
+ });
805
+ });
806
+