@wix/himalaya-cli 0.1748.0 → 0.1750.0

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 (327) hide show
  1. package/bin/himi +16 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +9 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +2 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/l10n.mjs +1 -1
  6. package/dist/browser-plane/assets.json +7 -7
  7. package/dist/browser-plane/preview-deferred/{63821bbb8f637899037252154a5587f0596e4b537173c7f50551f9e44f7c22c0.bin → b40ea5d0d6251898ff5617139fde8be008dd11e99a70b14c1052093685401700.bin} +1 -1
  8. package/dist/browser-plane/sw.js +6 -6
  9. package/dist/browser-plane/t5-frame.html +1 -1
  10. package/dist/browser-plane/t5-worker-frame.html +1 -1
  11. package/dist/cli.mjs +13464 -8217
  12. package/dist/preview-assets.generated.bin +0 -0
  13. package/guides/component-reference.json +1 -1
  14. package/guides/component-reference.md +9 -0
  15. package/guides/getting-started.md +3 -1
  16. package/guides/himi-json-output.md +54 -1
  17. package/guides/himi-skill.md +3 -1
  18. package/guides/one-app-to-himi-app.md +31 -8
  19. package/guides/skill.md +3 -1
  20. package/guides/store-submission.md +149 -34
  21. package/guides/wix-business-context.md +14 -0
  22. package/package.json +10 -10
  23. package/template-icons/medical-services.png +0 -0
  24. package/template-icons/personal-fitness-trainer.png +0 -0
  25. package/templates/beauty-salon/config.ts +12 -0
  26. package/templates/beauty-salon/dev/index.ts +1 -0
  27. package/templates/beauty-salon/l10n/en.json +6 -0
  28. package/templates/beauty-salon/l10n/fr.json +11 -0
  29. package/templates/beauty-salon/l10n/he.json +9 -0
  30. package/templates/beauty-salon/tier5-src/_shared/booking-session.ts +3 -1
  31. package/templates/beauty-salon/tier5-src/_shared/business-chat-transport.ts +148 -0
  32. package/templates/beauty-salon/tier5-src/_shared/header-badges.ts +113 -0
  33. package/templates/beauty-salon/tier5-src/_shared/location-pin.ts +97 -0
  34. package/templates/beauty-salon/tier5-src/_shared/member-access.ts +17 -6
  35. package/templates/beauty-salon/tier5-src/_shared/member-bookings.ts +17 -4
  36. package/templates/beauty-salon/tier5-src/_shared/source-badges.ts +72 -0
  37. package/templates/beauty-salon/tier5-src/_shared/staff-name.ts +18 -0
  38. package/templates/beauty-salon/tier5-src/himi-booking-bookings/index.ts +6 -2
  39. package/templates/beauty-salon/tier5-src/himi-booking-service/index.ts +7 -2
  40. package/templates/beauty-salon/tier5-src/himi-booking-time/index.ts +6 -4
  41. package/templates/beauty-salon/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  42. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +13 -4
  43. package/templates/beauty-salon/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  44. package/templates/beauty-salon-owner/dev/index.ts +54 -0
  45. package/templates/beauty-salon-owner/tier5-src/_shared/aria-chat.ts +30 -4
  46. package/templates/beauty-salon-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  47. package/templates/branded-lite/config.ts +12 -0
  48. package/templates/branded-lite/dev/index.ts +1 -0
  49. package/templates/branded-lite/l10n/fr.json +10 -0
  50. package/templates/branded-lite/l10n/he.json +8 -0
  51. package/templates/branded-lite/tier5-src/_shared/booking-session.ts +3 -1
  52. package/templates/branded-lite/tier5-src/_shared/location-pin.ts +97 -0
  53. package/templates/branded-lite/tier5-src/_shared/member-access.ts +17 -6
  54. package/templates/branded-lite/tier5-src/_shared/member-bookings.ts +17 -4
  55. package/templates/branded-lite/tier5-src/_shared/staff-name.ts +18 -0
  56. package/templates/branded-lite/tier5-src/himi-booking-bookings/index.ts +6 -2
  57. package/templates/branded-lite/tier5-src/himi-booking-service/index.ts +7 -2
  58. package/templates/branded-lite/tier5-src/himi-booking-time/index.ts +6 -4
  59. package/templates/branded-lite/tier5-src/himi-branded-lite-access-nav/index.ts +10 -5
  60. package/templates/branded-lite/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  61. package/templates/branded-lite/tier5-src/himi-branded-lite-video/index.ts +12 -1
  62. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +13 -4
  63. package/templates/branded-lite/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  64. package/templates/community-club/dev/index.ts +1 -0
  65. package/templates/community-club/tier5-src/_shared/member-access.ts +17 -6
  66. package/templates/community-club/tier5-src/_shared/member-bookings.ts +17 -4
  67. package/templates/community-club/tier5-src/himi-store-account/index.ts +13 -4
  68. package/templates/community-club/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  69. package/templates/community-club-owner/dev/index.ts +54 -0
  70. package/templates/community-club-owner/tier5-src/_shared/aria-chat.ts +30 -4
  71. package/templates/community-club-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  72. package/templates/conference/dev/index.ts +1 -0
  73. package/templates/conference/tier5-src/_shared/member-access.ts +17 -6
  74. package/templates/conference/tier5-src/himi-store-account/index.ts +13 -4
  75. package/templates/events-meetups/dev/index.ts +1 -0
  76. package/templates/events-meetups/tier5-src/_shared/member-access.ts +17 -6
  77. package/templates/events-meetups/tier5-src/_shared/member-bookings.ts +17 -4
  78. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +13 -4
  79. package/templates/events-meetups/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  80. package/templates/events-meetups-owner/dev/index.ts +54 -0
  81. package/templates/events-meetups-owner/tier5-src/_shared/aria-chat.ts +30 -4
  82. package/templates/events-meetups-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  83. package/templates/gym-fitness/config.ts +12 -0
  84. package/templates/gym-fitness/dev/index.ts +1 -0
  85. package/templates/gym-fitness/l10n/en.json +6 -0
  86. package/templates/gym-fitness/l10n/fr.json +11 -0
  87. package/templates/gym-fitness/l10n/he.json +9 -0
  88. package/templates/gym-fitness/tier5-src/_shared/booking-session.ts +3 -1
  89. package/templates/gym-fitness/tier5-src/_shared/business-chat-transport.ts +148 -0
  90. package/templates/gym-fitness/tier5-src/_shared/header-badges.ts +113 -0
  91. package/templates/gym-fitness/tier5-src/_shared/location-pin.ts +97 -0
  92. package/templates/gym-fitness/tier5-src/_shared/member-access.ts +17 -6
  93. package/templates/gym-fitness/tier5-src/_shared/member-bookings.ts +17 -4
  94. package/templates/gym-fitness/tier5-src/_shared/source-badges.ts +72 -0
  95. package/templates/gym-fitness/tier5-src/_shared/staff-name.ts +18 -0
  96. package/templates/gym-fitness/tier5-src/himi-booking-bookings/index.ts +6 -2
  97. package/templates/gym-fitness/tier5-src/himi-booking-service/index.ts +7 -2
  98. package/templates/gym-fitness/tier5-src/himi-booking-time/index.ts +6 -4
  99. package/templates/gym-fitness/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  100. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +13 -4
  101. package/templates/gym-fitness/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  102. package/templates/gym-fitness-owner/dev/index.ts +54 -0
  103. package/templates/gym-fitness-owner/tier5-src/_shared/aria-chat.ts +30 -4
  104. package/templates/gym-fitness-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  105. package/templates/medical-services/README.md +53 -0
  106. package/templates/medical-services/config.ts +320 -0
  107. package/templates/medical-services/dev/index.ts +17783 -0
  108. package/templates/medical-services/himalaya.content.json +46 -0
  109. package/templates/medical-services/himalaya.template.json +14 -0
  110. package/templates/medical-services/icon.png +0 -0
  111. package/templates/medical-services/platforms.json +1 -0
  112. package/templates/medical-services/tier5-src/_shared/app-locale.ts +61 -0
  113. package/templates/medical-services/tier5-src/_shared/booking-location.ts +147 -0
  114. package/templates/medical-services/tier5-src/_shared/booking-session.ts +224 -0
  115. package/templates/medical-services/tier5-src/_shared/branded-lite-hosted.ts +280 -0
  116. package/templates/medical-services/tier5-src/_shared/branded-load-state.ts +109 -0
  117. package/templates/medical-services/tier5-src/_shared/business-chat-copy.ts +40 -0
  118. package/templates/medical-services/tier5-src/_shared/business-chat-history.ts +51 -0
  119. package/templates/medical-services/tier5-src/_shared/business-chat-message-model.ts +177 -0
  120. package/templates/medical-services/tier5-src/_shared/business-chat-model.ts +56 -0
  121. package/templates/medical-services/tier5-src/_shared/business-chat-presenter.ts +576 -0
  122. package/templates/medical-services/tier5-src/_shared/business-chat-transport.ts +148 -0
  123. package/templates/medical-services/tier5-src/_shared/collection-contract.ts +228 -0
  124. package/templates/medical-services/tier5-src/_shared/collection-query.ts +193 -0
  125. package/templates/medical-services/tier5-src/_shared/collection-service.ts +400 -0
  126. package/templates/medical-services/tier5-src/_shared/engine-intl.ts +523 -0
  127. package/templates/medical-services/tier5-src/_shared/faq-list.ts +405 -0
  128. package/templates/medical-services/tier5-src/_shared/himi-account.ts +194 -0
  129. package/templates/medical-services/tier5-src/_shared/himi-booking-saved.ts +88 -0
  130. package/templates/medical-services/tier5-src/_shared/himi-bookings.ts +318 -0
  131. package/templates/medical-services/tier5-src/_shared/himi-copy.ts +116 -0
  132. package/templates/medical-services/tier5-src/_shared/himi-store.ts +7 -0
  133. package/templates/medical-services/tier5-src/_shared/himi-text.ts +24 -0
  134. package/templates/medical-services/tier5-src/_shared/host-events.ts +66 -0
  135. package/templates/medical-services/tier5-src/_shared/hosted-checkout.ts +70 -0
  136. package/templates/medical-services/tier5-src/_shared/iap-attendance-form.ts +106 -0
  137. package/templates/medical-services/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
  138. package/templates/medical-services/tier5-src/_shared/iap-attendance.ts +38 -0
  139. package/templates/medical-services/tier5-src/_shared/iap-worker.ts +127 -0
  140. package/templates/medical-services/tier5-src/_shared/inbox-rooms.ts +68 -0
  141. package/templates/medical-services/tier5-src/_shared/local-preferences.ts +38 -0
  142. package/templates/medical-services/tier5-src/_shared/member-access.ts +63 -0
  143. package/templates/medical-services/tier5-src/_shared/member-account-routes.ts +52 -0
  144. package/templates/medical-services/tier5-src/_shared/member-bookings.ts +107 -0
  145. package/templates/medical-services/tier5-src/_shared/member-screen.ts +99 -0
  146. package/templates/medical-services/tier5-src/_shared/notification-target.ts +141 -0
  147. package/templates/medical-services/tier5-src/_shared/offset-page.ts +10 -0
  148. package/templates/medical-services/tier5-src/_shared/online-actions.ts +76 -0
  149. package/templates/medical-services/tier5-src/_shared/owner-load-error.ts +348 -0
  150. package/templates/medical-services/tier5-src/_shared/payment-setup.ts +6 -0
  151. package/templates/medical-services/tier5-src/_shared/rich-body.ts +78 -0
  152. package/templates/medical-services/tier5-src/_shared/rich-content-link.ts +34 -0
  153. package/templates/medical-services/tier5-src/_shared/sign-in-sheet.ts +18 -0
  154. package/templates/medical-services/tier5-src/_shared/staff-name.ts +18 -0
  155. package/templates/medical-services/tier5-src/_shared/weekly-goal.ts +107 -0
  156. package/templates/medical-services/tier5-src/_shared/wix-bi.ts +85 -0
  157. package/templates/medical-services/tier5-src/_shared/wix-member-links.ts +114 -0
  158. package/templates/medical-services/tier5-src/_shared/wix-service-price.ts +146 -0
  159. package/templates/medical-services/tier5-src/business-chat/index.ts +732 -0
  160. package/templates/medical-services/tier5-src/himi-booking-account/index.ts +252 -0
  161. package/templates/medical-services/tier5-src/himi-booking-bookings/index.ts +468 -0
  162. package/templates/medical-services/tier5-src/himi-booking-service/index.ts +1190 -0
  163. package/templates/medical-services/tier5-src/himi-booking-services/index.ts +791 -0
  164. package/templates/medical-services/tier5-src/himi-booking-time/index.ts +1729 -0
  165. package/templates/medical-services/tier5-src/himi-branded-lite-faq/index.ts +6 -0
  166. package/templates/medical-services/tier5-src/himi-branded-lite-notifications/index.ts +256 -0
  167. package/templates/medical-services/tier5-src/himi-clinic-home/index.ts +389 -0
  168. package/templates/medical-services/tier5-src/himi-store-account/index.ts +1007 -0
  169. package/templates/medical-services/tokens.json +418 -0
  170. package/templates/nonprofit-cause/dev/index.ts +1 -0
  171. package/templates/nonprofit-cause/tier5-src/_shared/member-access.ts +17 -6
  172. package/templates/nonprofit-cause/tier5-src/_shared/member-bookings.ts +17 -4
  173. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +13 -4
  174. package/templates/nonprofit-cause/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  175. package/templates/nonprofit-cause-owner/dev/index.ts +54 -0
  176. package/templates/nonprofit-cause-owner/tier5-src/_shared/aria-chat.ts +30 -4
  177. package/templates/nonprofit-cause-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  178. package/templates/owner-lite/dev/index.ts +54 -0
  179. package/templates/owner-lite/tier5-src/_shared/aria-chat.ts +30 -4
  180. package/templates/owner-lite/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  181. package/templates/personal-fitness-trainer/README.md +51 -0
  182. package/templates/personal-fitness-trainer/config.ts +343 -0
  183. package/templates/personal-fitness-trainer/dev/index.ts +24813 -0
  184. package/templates/personal-fitness-trainer/himalaya.content.json +79 -0
  185. package/templates/personal-fitness-trainer/himalaya.template.json +14 -0
  186. package/templates/personal-fitness-trainer/icon.png +0 -0
  187. package/templates/personal-fitness-trainer/platforms.json +3 -0
  188. package/templates/personal-fitness-trainer/splash.json +3 -0
  189. package/templates/personal-fitness-trainer/tier5-src/_shared/app-locale.ts +61 -0
  190. package/templates/personal-fitness-trainer/tier5-src/_shared/booking-location.ts +147 -0
  191. package/templates/personal-fitness-trainer/tier5-src/_shared/booking-session.ts +224 -0
  192. package/templates/personal-fitness-trainer/tier5-src/_shared/branded-lite-hosted.ts +280 -0
  193. package/templates/personal-fitness-trainer/tier5-src/_shared/branded-load-state.ts +109 -0
  194. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-copy.ts +40 -0
  195. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-history.ts +51 -0
  196. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-message-model.ts +177 -0
  197. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-model.ts +56 -0
  198. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-presenter.ts +576 -0
  199. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-transport.ts +148 -0
  200. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-contract.ts +228 -0
  201. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-query.ts +193 -0
  202. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-service.ts +400 -0
  203. package/templates/personal-fitness-trainer/tier5-src/_shared/detail-presence.ts +51 -0
  204. package/templates/personal-fitness-trainer/tier5-src/_shared/empty-flags.ts +33 -0
  205. package/templates/personal-fitness-trainer/tier5-src/_shared/engine-intl.ts +523 -0
  206. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-account.ts +194 -0
  207. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-booking-saved.ts +88 -0
  208. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-bookings.ts +318 -0
  209. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-copy.ts +116 -0
  210. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-layouts.ts +142 -0
  211. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-store.ts +7 -0
  212. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-text.ts +24 -0
  213. package/templates/personal-fitness-trainer/tier5-src/_shared/host-events.ts +66 -0
  214. package/templates/personal-fitness-trainer/tier5-src/_shared/hosted-checkout.ts +70 -0
  215. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-attendance-form.ts +106 -0
  216. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
  217. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-attendance.ts +38 -0
  218. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-worker.ts +127 -0
  219. package/templates/personal-fitness-trainer/tier5-src/_shared/inbox-rooms.ts +68 -0
  220. package/templates/personal-fitness-trainer/tier5-src/_shared/local-preferences.ts +38 -0
  221. package/templates/personal-fitness-trainer/tier5-src/_shared/member-access.ts +63 -0
  222. package/templates/personal-fitness-trainer/tier5-src/_shared/member-account-routes.ts +52 -0
  223. package/templates/personal-fitness-trainer/tier5-src/_shared/member-bookings.ts +107 -0
  224. package/templates/personal-fitness-trainer/tier5-src/_shared/member-screen.ts +99 -0
  225. package/templates/personal-fitness-trainer/tier5-src/_shared/offset-page.ts +10 -0
  226. package/templates/personal-fitness-trainer/tier5-src/_shared/online-actions.ts +76 -0
  227. package/templates/personal-fitness-trainer/tier5-src/_shared/owner-load-error.ts +348 -0
  228. package/templates/personal-fitness-trainer/tier5-src/_shared/payment-setup.ts +6 -0
  229. package/templates/personal-fitness-trainer/tier5-src/_shared/pricing-plan-display.ts +64 -0
  230. package/templates/personal-fitness-trainer/tier5-src/_shared/rich-body.ts +78 -0
  231. package/templates/personal-fitness-trainer/tier5-src/_shared/rich-content-link.ts +34 -0
  232. package/templates/personal-fitness-trainer/tier5-src/_shared/sign-in-sheet.ts +18 -0
  233. package/templates/personal-fitness-trainer/tier5-src/_shared/staff-name.ts +18 -0
  234. package/templates/personal-fitness-trainer/tier5-src/_shared/video-caption.ts +21 -0
  235. package/templates/personal-fitness-trainer/tier5-src/_shared/weekly-goal.ts +107 -0
  236. package/templates/personal-fitness-trainer/tier5-src/_shared/wix-bi.ts +85 -0
  237. package/templates/personal-fitness-trainer/tier5-src/_shared/wix-service-price.ts +146 -0
  238. package/templates/personal-fitness-trainer/tier5-src/business-chat/index.ts +732 -0
  239. package/templates/personal-fitness-trainer/tier5-src/business-contact/index.ts +6 -0
  240. package/templates/personal-fitness-trainer/tier5-src/himi-booking-bookings/index.ts +468 -0
  241. package/templates/personal-fitness-trainer/tier5-src/himi-booking-service/index.ts +1190 -0
  242. package/templates/personal-fitness-trainer/tier5-src/himi-booking-services/index.ts +791 -0
  243. package/templates/personal-fitness-trainer/tier5-src/himi-booking-time/index.ts +1729 -0
  244. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
  245. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/index.ts +1094 -0
  246. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-agenda/index.ts +955 -0
  247. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-appearance/index.ts +94 -0
  248. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-notifsettings/index.ts +173 -0
  249. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-plans/index.ts +495 -0
  250. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-splash/index.ts +35 -0
  251. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-video/index.ts +226 -0
  252. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-videos/index.ts +145 -0
  253. package/templates/personal-fitness-trainer/tier5-src/himi-fitness-trainer-home/index.ts +70 -0
  254. package/templates/personal-fitness-trainer/tier5-src/himi-fitness-trainer-profile/index.ts +53 -0
  255. package/templates/personal-fitness-trainer/tier5-src/himi-store-account/index.ts +1007 -0
  256. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-app-language/index.ts +73 -0
  257. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  258. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-my-subscriptions/index.ts +84 -0
  259. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
  260. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-view-profile/index.ts +119 -0
  261. package/templates/personal-fitness-trainer/tokens.json +381 -0
  262. package/templates/podcast-creator/dev/index.ts +1 -0
  263. package/templates/podcast-creator/tier5-src/_shared/member-access.ts +17 -6
  264. package/templates/podcast-creator/tier5-src/_shared/member-bookings.ts +17 -4
  265. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +13 -4
  266. package/templates/podcast-creator/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  267. package/templates/podcast-creator-owner/dev/index.ts +54 -0
  268. package/templates/podcast-creator-owner/tier5-src/_shared/aria-chat.ts +30 -4
  269. package/templates/podcast-creator-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  270. package/templates/portfolio-creative/dev/index.ts +1 -0
  271. package/templates/portfolio-creative/tier5-src/_shared/member-access.ts +17 -6
  272. package/templates/portfolio-creative/tier5-src/_shared/member-bookings.ts +17 -4
  273. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +13 -4
  274. package/templates/portfolio-creative/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  275. package/templates/portfolio-creative-owner/dev/index.ts +54 -0
  276. package/templates/portfolio-creative-owner/tier5-src/_shared/aria-chat.ts +30 -4
  277. package/templates/portfolio-creative-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  278. package/templates/restaurant/dev/index.ts +1 -0
  279. package/templates/restaurant/tier5-src/_shared/member-access.ts +17 -6
  280. package/templates/restaurant/tier5-src/_shared/member-bookings.ts +17 -4
  281. package/templates/restaurant/tier5-src/himi-store-account/index.ts +13 -4
  282. package/templates/restaurant/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  283. package/templates/restaurant-owner/dev/index.ts +54 -0
  284. package/templates/restaurant-owner/tier5-src/_shared/aria-chat.ts +30 -4
  285. package/templates/restaurant-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  286. package/templates/retail-store/dev/index.ts +1 -0
  287. package/templates/retail-store/tier5-src/_shared/member-access.ts +17 -6
  288. package/templates/retail-store/tier5-src/_shared/member-bookings.ts +17 -4
  289. package/templates/retail-store/tier5-src/himi-store-account/index.ts +13 -4
  290. package/templates/retail-store/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  291. package/templates/retail-store-owner/dev/index.ts +54 -0
  292. package/templates/retail-store-owner/tier5-src/_shared/aria-chat.ts +30 -4
  293. package/templates/retail-store-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
  294. package/templates/salon-spa/dev/index.ts +1 -0
  295. package/templates/salon-spa/tier5-src/_shared/booking-session.ts +3 -1
  296. package/templates/salon-spa/tier5-src/_shared/member-access.ts +17 -6
  297. package/templates/salon-spa/tier5-src/_shared/member-bookings.ts +17 -4
  298. package/templates/salon-spa/tier5-src/_shared/staff-name.ts +18 -0
  299. package/templates/salon-spa/tier5-src/himi-booking-bookings/index.ts +6 -2
  300. package/templates/salon-spa/tier5-src/himi-booking-service/index.ts +7 -2
  301. package/templates/salon-spa/tier5-src/himi-booking-time/index.ts +6 -4
  302. package/templates/salon-spa/tier5-src/himi-store-account/index.ts +13 -4
  303. package/templates/wholesale-store/dev/index.ts +1 -0
  304. package/templates/wholesale-store/tier5-src/_shared/member-access.ts +17 -6
  305. package/templates/wholesale-store/tier5-src/himi-store-account/index.ts +13 -4
  306. package/templates/yoga-studio/config.ts +12 -0
  307. package/templates/yoga-studio/dev/index.ts +1 -0
  308. package/templates/yoga-studio/l10n/en.json +6 -0
  309. package/templates/yoga-studio/l10n/fr.json +11 -0
  310. package/templates/yoga-studio/l10n/he.json +9 -0
  311. package/templates/yoga-studio/tier5-src/_shared/booking-session.ts +3 -1
  312. package/templates/yoga-studio/tier5-src/_shared/business-chat-transport.ts +148 -0
  313. package/templates/yoga-studio/tier5-src/_shared/header-badges.ts +113 -0
  314. package/templates/yoga-studio/tier5-src/_shared/location-pin.ts +97 -0
  315. package/templates/yoga-studio/tier5-src/_shared/member-access.ts +17 -6
  316. package/templates/yoga-studio/tier5-src/_shared/member-bookings.ts +17 -4
  317. package/templates/yoga-studio/tier5-src/_shared/source-badges.ts +72 -0
  318. package/templates/yoga-studio/tier5-src/_shared/staff-name.ts +18 -0
  319. package/templates/yoga-studio/tier5-src/himi-booking-bookings/index.ts +6 -2
  320. package/templates/yoga-studio/tier5-src/himi-booking-service/index.ts +7 -2
  321. package/templates/yoga-studio/tier5-src/himi-booking-time/index.ts +6 -4
  322. package/templates/yoga-studio/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  323. package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +13 -4
  324. package/templates/yoga-studio/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  325. package/templates/yoga-studio-owner/dev/index.ts +54 -0
  326. package/templates/yoga-studio-owner/tier5-src/_shared/aria-chat.ts +30 -4
  327. package/templates/yoga-studio-owner/tier5-src/himi-owner-lite-aria/index.ts +29 -0
@@ -62273,6 +62273,60 @@ const SCREENS = runtimeSetting({
62273
62273
  "spacing": 0,
62274
62274
  "alignment": "leading",
62275
62275
  "children": [
62276
+ {
62277
+ "id": "himi_owner_lite_aria.quickReplies.bound",
62278
+ "body": {
62279
+ "package": "himalaya",
62280
+ "type": "LazyList",
62281
+ "props": {
62282
+ "itemsPath": "$service:himiOwnerLiteAria.quickReplies",
62283
+ "horizontal": true,
62284
+ "spacing": 8,
62285
+ "items": [
62286
+ {
62287
+ "id": "himi_owner_lite_aria.quickReply_$item.id",
62288
+ "body": {
62289
+ "package": "himalaya",
62290
+ "type": "Text",
62291
+ "props": {
62292
+ "text": "$item.label",
62293
+ "style": "footnote",
62294
+ "maxLines": 1
62295
+ }
62296
+ },
62297
+ "modifiers": {
62298
+ "padding": {
62299
+ "leading": 12,
62300
+ "trailing": 12,
62301
+ "top": 16,
62302
+ "bottom": 16
62303
+ },
62304
+ "background": {
62305
+ "token": "surfaceSecondary"
62306
+ },
62307
+ "cornerRadius": 16,
62308
+ "accessibilityLabel": "$item.reply",
62309
+ "onTap": {
62310
+ "actionId": "tier5.himiOwnerLiteAria.submitQuickReply",
62311
+ "params": {
62312
+ "id": "$item.id"
62313
+ }
62314
+ }
62315
+ }
62316
+ }
62317
+ ]
62318
+ }
62319
+ },
62320
+ "modifiers": {
62321
+ "hiddenPath": "$service:himiOwnerLiteAria.quickRepliesHidden",
62322
+ "padding": {
62323
+ "leading": 0,
62324
+ "trailing": 0,
62325
+ "top": 8,
62326
+ "bottom": 0
62327
+ }
62328
+ }
62329
+ },
62276
62330
  {
62277
62331
  "id": "",
62278
62332
  "body": {
@@ -1491,6 +1491,7 @@ export interface AriaChatCore {
1491
1491
  load(s: AriaChatState): Promise<AriaChatState>;
1492
1492
  submit(s: AriaChatState, arg?: AriaActionArg): Promise<AriaChatState>;
1493
1493
  submitPrompt(s: AriaChatState, arg?: AriaActionArg): Promise<AriaChatState>;
1494
+ submitQuickReply(s: AriaChatState, arg?: AriaActionArg): Promise<AriaChatState>;
1494
1495
  newChat(s: AriaChatState): Promise<AriaChatState>;
1495
1496
  /** Mirror the composer's text into state. Not cosmetic: the renderers only
1496
1497
  * clear a text field when its BOUND value transitions, so a composer whose
@@ -2799,6 +2800,7 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
2799
2800
  /** The quick replies last painted, so an unchanged list keeps its identity and
2800
2801
  * a reducer that changed nothing still returns the SAME state object. */
2801
2802
  let paintedReplies: AriaQuickReply[] = [];
2803
+ let quickReplyOffer = 0;
2802
2804
 
2803
2805
  /** Ask the host to open the stream for a turn that was just sent, and reset
2804
2806
  * the live model to it. `turnId` may be empty (a service that named no id);
@@ -2867,13 +2869,21 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
2867
2869
  return out;
2868
2870
  };
2869
2871
 
2872
+ const quickReplyLabel = (label: string): string => {
2873
+ const characters = Array.from(label);
2874
+ return characters.length > 30 ? characters.slice(0, 29).join("") + "…" : label;
2875
+ };
2876
+
2870
2877
  /** The current turn's quick replies, as rows. */
2871
2878
  const repliesFor = (s: AriaChatState): AriaQuickReply[] => {
2872
2879
  const offered = !!s._turnId && live.turnId === s._turnId && live.conversationId === s._convId
2873
2880
  ? live.quickReplies() : [];
2874
2881
  const same = offered.length === paintedReplies.length
2875
- && offered.every((r, i) => paintedReplies[i].label === r.label && paintedReplies[i].reply === r.reply);
2876
- if (!same) paintedReplies = offered.map((r, i) => ({ id: `qr${i + 1}`, label: r.label, reply: r.reply }));
2882
+ && offered.every((r, i) => paintedReplies[i].label === quickReplyLabel(r.label) && paintedReplies[i].reply === r.reply);
2883
+ if (!same) {
2884
+ quickReplyOffer += 1;
2885
+ paintedReplies = offered.map((r, i) => ({ id: `${s._convId}:${s._turnId}:${quickReplyOffer}:qr${i + 1}`, label: quickReplyLabel(r.label), reply: r.reply }));
2886
+ }
2877
2887
  return paintedReplies;
2878
2888
  };
2879
2889
 
@@ -3361,8 +3371,9 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
3361
3371
  : { ...actioned, attachments: chips, attachmentsHidden };
3362
3372
  if (out.mention !== mentionViewNow) out = { ...out, mention: mentionViewNow };
3363
3373
  const quickReplies = repliesFor(out);
3364
- if (out.quickReplies !== quickReplies || out.quickRepliesHidden !== (quickReplies.length === 0)) {
3365
- out = { ...out, quickReplies, quickRepliesHidden: quickReplies.length === 0 };
3374
+ const quickRepliesHidden = out.status !== "ready" || quickReplies.length === 0;
3375
+ if (out.quickReplies !== quickReplies || out.quickRepliesHidden !== quickRepliesHidden) {
3376
+ out = { ...out, quickReplies, quickRepliesHidden };
3366
3377
  }
3367
3378
  if (out._realtime !== realtime) out = { ...out, _realtime: realtime };
3368
3379
  // Every state the runtime commits passes through here (an `undefined`
@@ -3651,6 +3662,14 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
3651
3662
  return send(s, content, chips);
3652
3663
  },
3653
3664
 
3665
+ submitQuickReply: async (s, arg) => {
3666
+ if (s.status !== "ready" || s._siteId !== siteOf()) return s;
3667
+ const id = typeof arg === "string" ? arg : firstString(arg?.id);
3668
+ const offered = repliesFor(s).find((reply) => reply.id === id);
3669
+ if (!offered) return s;
3670
+ return impl.submitPrompt(s, { text: offered.reply });
3671
+ },
3672
+
3654
3673
  // A suggested-prompt chip submits its own text through the SAME path a typed
3655
3674
  // message takes — never by dispatching `submit` through the service handle,
3656
3675
  // which exposes actions as direct methods and has no `.actions` member on
@@ -4440,6 +4459,7 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
4440
4459
  // turn running, and a tick resolving around it must go on reporting that
4441
4460
  // turn normally.
4442
4461
  turnSeq += 1;
4462
+ live.reset("", "");
4443
4463
  return slow(withDraft(
4444
4464
  { ...s, status: "ready", statusText: stoppedText(), error: "", _pending: "", _abortId: "" }, typedAt));
4445
4465
  },
@@ -4599,6 +4619,12 @@ export function createAriaChat(o: AriaChatOptions): AriaChatCore {
4599
4619
  return gated(revision !== draftSeq && next.input === s.input && committed
4600
4620
  ? { ...next, input: committed.input } : next);
4601
4621
  },
4622
+ submitQuickReply: async (s, arg) => {
4623
+ const revision = draftSeq;
4624
+ const next = await impl.submitQuickReply(s, arg);
4625
+ return gated(revision !== draftSeq && next.input === s.input && committed
4626
+ ? { ...next, input: committed.input } : next);
4627
+ },
4602
4628
  newChat: (s) => impl.newChat(s).then(gated),
4603
4629
  typing: (s, arg) => gated(impl.typing(s, arg)),
4604
4630
  tick: (s) => impl.tick(s).then((r) => (r ? gated(r) : r)),
@@ -55,6 +55,8 @@ import { copyParam, copyTemplate, stashCopy } from "../_shared/himi-copy.js";
55
55
  import { OWNER_MODULES, ownerModuleIds, ownerModuleScreen } from "../_shared/owner-modules.js";
56
56
 
57
57
  const SERVICE = "himiOwnerLiteAria";
58
+ /** The current turn's quick-reply row — this run's state only, never restored. */
59
+ const QUICK_REPLY_KEYS: Array<"quickReplies" | "quickRepliesHidden"> = ["quickReplies", "quickRepliesHidden"];
58
60
 
59
61
  // Cadence for the reply ladder. `fast` while a reply is outstanding; `idle`
60
62
  // afterwards, because a worker cannot CANCEL a poll — PollDirective has no stop
@@ -477,6 +479,7 @@ const svc = defineService<AriaChatState, {
477
479
  load: (s: AriaChatState, arg?: AriaActionArg) => Promise<AriaChatState>;
478
480
  submit: (s: AriaChatState, arg?: AriaActionArg) => Promise<AriaChatState>;
479
481
  submitPrompt: (s: AriaChatState, arg?: AriaActionArg) => Promise<AriaChatState>;
482
+ submitQuickReply: (s: AriaChatState, arg?: AriaActionArg) => Promise<AriaChatState>;
480
483
  newChat: (s: AriaChatState) => Promise<AriaChatState>;
481
484
  typing: (s: AriaChatState, arg?: AriaActionArg) => AriaChatState;
482
485
  // `undefined` is part of the contract, not sloppiness: a tick whose read was
@@ -527,6 +530,10 @@ const svc = defineService<AriaChatState, {
527
530
  suggestionsSettled: (s: AriaChatState, arg?: AriaActionArg) => AriaChatState | undefined;
528
531
  }>(SERVICE, {
529
532
  state: core.initialState,
533
+ // Quick replies belong to the turn that is live in THIS run's realtime model. A
534
+ // persisted row would paint (and announce) last session's offers before `load`,
535
+ // and every tap on them would be refused, because the live model starts empty.
536
+ notHydrated: QUICK_REPLY_KEYS,
530
537
  actions: {
531
538
  // `load` is the onAppear dispatch, so it is where the copy pack arrives.
532
539
  load: (s, arg) => { mentionDraftRevision += 1; mentionTriggerPrefixes = []; pendingMentionTrigger = null; previousMentionRaw = ""; adoptedMentionDraft = null; stashCopy(arg); stashTargets(arg); stashRealtimeUrl(arg); return core.load(s); },
@@ -552,6 +559,18 @@ const svc = defineService<AriaChatState, {
552
559
  }
553
560
  return next;
554
561
  },
562
+ // A server-offered quick reply sends through submitPrompt in the core, so it
563
+ // settles the mention draft exactly as a suggested-prompt tap does.
564
+ submitQuickReply: async (s, arg) => {
565
+ const previousPrefixes = mentionTriggerPrefixes; const previousTrigger = pendingMentionTrigger;
566
+ const revision = mentionDraftRevision;
567
+ const next = await core.submitQuickReply(s, arg);
568
+ if (revision === mentionDraftRevision) {
569
+ if (next.input && next.input === s.input) { mentionTriggerPrefixes = previousPrefixes; pendingMentionTrigger = previousTrigger; }
570
+ else { mentionTriggerPrefixes = []; pendingMentionTrigger = null; previousMentionRaw = ""; adoptedMentionDraft = null; }
571
+ }
572
+ return next;
573
+ },
555
574
  newChat: (s) => { mentionDraftRevision += 1; mentionTriggerPrefixes = []; pendingMentionTrigger = null; previousMentionRaw = ""; adoptedMentionDraft = null; return core.newChat(s); },
556
575
  // The composer's onChange. Mirrors the draft into state so `submit` can
557
576
  // empty it and the field actually clears.
@@ -648,6 +667,16 @@ const svc = defineService<AriaChatState, {
648
667
  },
649
668
  });
650
669
 
670
+ // A binary older than `notHydrated` restores the persisted row anyway; put those keys
671
+ // back to their declared values before any action runs (as iap-worker's
672
+ // resetUnhydratedKeysOnOlderRuntime does), so no host paints a previous run's offers.
673
+ if ((globalThis as { himalaya?: { hydrationOptOut?: unknown } }).himalaya?.hydrationOptOut !== true) {
674
+ const booted = svc.getState() as unknown as Record<string, unknown> | undefined;
675
+ if (booted && typeof booted === "object") {
676
+ for (const key of QUICK_REPLY_KEYS) booted[key] = (core.initialState as unknown as Record<string, unknown>)[key];
677
+ }
678
+ }
679
+
651
680
  // NO module-scope `svc.load()`, deliberately — the descriptor's `onAppear` is the
652
681
  // only entry point, and on Android the self-kick did not merely duplicate it, it
653
682
  // DISABLED the screen.
@@ -63,6 +63,18 @@ export default defineApp({
63
63
  "maxHoldMs": 5000
64
64
  },
65
65
  navigation: {
66
+ "navLogicBundle": {
67
+ "url": "/v1/bundles/himi-branded-lite-nav",
68
+ "integrity": "",
69
+ "contentType": "application/javascript+ts-bundle",
70
+ "declaredCapabilities": [
71
+ "push",
72
+ "theme",
73
+ "wix_api"
74
+ ],
75
+ "minBinaryVersion": "0.1.0",
76
+ "bundleVersion": "0.0.1"
77
+ },
66
78
  "navKind": "responsive",
67
79
  "scheme": "himalaya-__HIMI_APP_SLUG__",
68
80
  "deepLinkPatterns": [],
@@ -8,6 +8,7 @@ const runtimeSetting = (value: unknown): unknown => {
8
8
  if (value === "__HIMI_PODCAST_FEED_URL__") return process.env.PODCAST_FEED_URL?.trim() || "";
9
9
  if (value === "__HIMI_MEMBER_PHOTO_UPLOAD_FUNCTION__") return process.env.HIMI_BRANDED_LITE_MEMBER_PHOTO_UPLOAD_FUNCTION?.trim() || "";
10
10
  if (value === "__HIMI_MEMBER_SITE_URL__") return String((config as { auth?: { config?: { siteUrl?: unknown } } }).auth?.config?.siteUrl ?? "").trim();
11
+ if (typeof value === "string" && value.startsWith("__HIMI_MEMBER_SITE_URL__/")) return String((config as { auth?: { config?: { siteUrl?: unknown } } }).auth?.config?.siteUrl ?? "").trim().replace(/\/+$/, "") + value.slice(24);
11
12
  if (Array.isArray(value)) return value.map(runtimeSetting);
12
13
  if (!value || typeof value !== "object") return value;
13
14
  return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, runtimeSetting(child)]));
@@ -1736,6 +1736,12 @@
1736
1736
  "key": "account.viewProfileLink",
1737
1737
  "keyOrigin": "string-table"
1738
1738
  },
1739
+ "h_b9e09ae263fb": {
1740
+ "source": "Not confirmed",
1741
+ "kind": "Worker.copy",
1742
+ "translation": "",
1743
+ "key": "businessChat.unconfirmed"
1744
+ },
1739
1745
  "h_ba5a97fbf136": {
1740
1746
  "source": "Update Google Play services",
1741
1747
  "kind": "Button.title",
@@ -14,6 +14,12 @@
14
14
  "translation": "Choisissez la langue utilisée dans cette appli.",
15
15
  "origin": "machine"
16
16
  },
17
+ "h_b9e09ae263fb": {
18
+ "key": "businessChat.unconfirmed",
19
+ "source": "Not confirmed",
20
+ "translation": "Non confirmé",
21
+ "origin": "machine"
22
+ },
17
23
  "h_24345a14377f": {
18
24
  "key": "businessChat.today",
19
25
  "source": "Today",
@@ -4240,6 +4246,11 @@
4240
4246
  "translation": "Vous êtes sur la liste d'attente. Vous recevrez un e-mail si une place se libère.",
4241
4247
  "origin": "machine"
4242
4248
  },
4249
+ "h_146bd1c44b1c": {
4250
+ "source": "This booking is not confirmed. If you did not finish checkout, the business did not get it.",
4251
+ "translation": "Cette réservation n'est pas confirmée. Si vous n'avez pas terminé le paiement, l'établissement ne l'a pas reçue.",
4252
+ "origin": "machine"
4253
+ },
4243
4254
  "h_014a590b30b1": {
4244
4255
  "source": "Get directions to {place}",
4245
4256
  "translation": "Obtenir l'itinéraire vers {place}",
@@ -11,6 +11,11 @@
11
11
  "key": "appLanguage.subtitle",
12
12
  "translation": "בחרו את השפה שבה האפליקציה מוצגת."
13
13
  },
14
+ "h_b9e09ae263fb": {
15
+ "source": "Not confirmed",
16
+ "key": "businessChat.unconfirmed",
17
+ "translation": "לא אושר"
18
+ },
14
19
  "h_24345a14377f": {
15
20
  "source": "Today",
16
21
  "key": "businessChat.today",
@@ -3478,6 +3483,10 @@
3478
3483
  "source": "You are on the waitlist. You get an email if a spot opens.",
3479
3484
  "translation": "אתם ברשימת ההמתנה. תקבלו אימייל אם יתפנה מקום."
3480
3485
  },
3486
+ "h_146bd1c44b1c": {
3487
+ "source": "This booking is not confirmed. If you did not finish checkout, the business did not get it.",
3488
+ "translation": "התור הזה לא אושר. אם לא סיימתם את התשלום, העסק לא קיבל אותו."
3489
+ },
3481
3490
  "h_014a590b30b1": {
3482
3491
  "source": "Get directions to {place}",
3483
3492
  "translation": "הוראות הגעה אל {place}"
@@ -190,7 +190,9 @@ export async function placesIn(start: string, end: string, inWindow: Session[],
190
190
  // Every page, not the first 100: a booking past it would read Book again. Bounded.
191
191
  const bookings: WixBooking[] = [];
192
192
  for (let page = 0; page < 5; page++) {
193
- const res = await queryBookings({ query: { filter: { "contactDetails.email": { $eq: who.email }, startDate: { $gte: from, $lt: to } }, paging: { limit: 100, offset: page * 100 } } } as never);
193
+ // Bookings v2 rejects two comparisons in one field expression (INVALID_FILTER).
194
+ // Keep the half-open window as independent AND clauses, with the same member scope.
195
+ const res = await queryBookings({ query: { filter: { "contactDetails.email": { $eq: who.email }, $and: [{ startDate: { $gte: from } }, { startDate: { $lt: to } }] }, paging: { limit: 100, offset: page * 100 } } } as never);
194
196
  const batch = res.bookings ?? [];
195
197
  bookings.push(...batch);
196
198
  if (batch.length < 100) break;
@@ -0,0 +1,148 @@
1
+ // The business chat's Wix calls: the member-role chat-web SDK for rooms and history, plus the calls the SDKs have
2
+ // no helper for (a typed message sent through Smart Chat, a tapped button, a private attachment's download URL).
3
+ import { getChatToken, getMessagesPage, listChatroomsPage } from "@himalaya/wix-chat-web";
4
+ import { assertMemberAccess, memberAccess } from "./member-access.js";
5
+
6
+ const MANAGE = "https://manage.wix.com";
7
+ const MEMBER = { role: "member" } as const;
8
+ type Raw = Record<string, unknown>;
9
+ type Bridge = { call(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<unknown> };
10
+
11
+ /** Who is signed in. `userId` is empty until the host reports it; the chat then tells the business
12
+ * side apart by the room's participant id instead. */
13
+ export interface ChatIdentity { authenticated: boolean; userId: string; email: string; scope: string }
14
+ export async function chatIdentity(): Promise<ChatIdentity> {
15
+ const member = await memberAccess();
16
+ return { authenticated: !!member.email, userId: "", email: member.email, scope: member.scope };
17
+ }
18
+ export const assertChatIdentity = (identity: ChatIdentity): Promise<void> => assertMemberAccess(identity);
19
+
20
+ /** Every request is fenced: the member is re-checked before it goes out and again before its response is
21
+ * used, so a sign-out or account switch mid-request never leaks one member's data to the next. */
22
+ async function fenced<T>(identity: ChatIdentity, run: () => Promise<T>): Promise<T> {
23
+ await assertChatIdentity(identity);
24
+ const result = await run();
25
+ await assertChatIdentity(identity);
26
+ return result;
27
+ }
28
+
29
+ /** Any other member-scoped call (the AI chat's) goes through the same fence. */
30
+ export const fence = fenced;
31
+
32
+ // Minting a chat token is a network round trip, and every chat call used to mint its own. One token
33
+ // per member is reused until the member changes or a request using it is refused.
34
+ let cachedToken: { key: string; token: string } | null = null;
35
+ const tokenKey = (identity: ChatIdentity): string => `${identity.email}|${identity.scope}`;
36
+ async function chatTokenFor(identity: ChatIdentity): Promise<string> {
37
+ const key = tokenKey(identity);
38
+ if (cachedToken?.key === key) return cachedToken.token;
39
+ const { chatToken } = await getChatToken(MEMBER);
40
+ // The host mints for whoever is signed in NOW: a token minted while the member switched belongs to the
41
+ // new member and must not be cached under the old one.
42
+ await assertChatIdentity(identity);
43
+ cachedToken = { key, token: chatToken };
44
+ return chatToken;
45
+ }
46
+ /** Runs `run` with the member's cached token; a refused request mints a fresh token and tries once more. */
47
+ async function withToken<T>(identity: ChatIdentity, run: (chatToken: string) => Promise<T>): Promise<T> {
48
+ const reused = cachedToken?.key === tokenKey(identity);
49
+ try {
50
+ return await run(await chatTokenFor(identity));
51
+ } catch (error) {
52
+ cachedToken = null;
53
+ if (!reused || !/\b(?:401|403)\b|token/i.test(String((error as Error)?.message ?? error))) throw error;
54
+ return run(await chatTokenFor(identity));
55
+ }
56
+ }
57
+
58
+ const MAX_ROOM_PAGES = 20;
59
+ /** Every chatroom the member can see: the cursor is followed so the business room is found on any page. */
60
+ export const listRooms = (identity: ChatIdentity): Promise<{ items: Raw[]; more: boolean }> => fenced(identity, async () => {
61
+ const items: Raw[] = [];
62
+ let nextPointer: number | string | undefined;
63
+ for (let page = 0; page < MAX_ROOM_PAGES; page++) {
64
+ const result = await withToken(identity, (chatToken) => listChatroomsPage({ ...MEMBER, chatToken, pageSize: 50, ...(nextPointer !== undefined ? { nextPointer } : {}) }));
65
+ items.push(...(result.items as unknown as Raw[]));
66
+ nextPointer = result.nextPointer;
67
+ if (nextPointer === undefined) return { items, more: false };
68
+ }
69
+ return { items, more: true };
70
+ });
71
+ /** How many of the member's BUSINESS chatrooms have unread messages, as the server counts them (capped at 100).
72
+ * Not the rooms themselves: the header badge needs only the total. A response without a valid count is
73
+ * unavailable, never zero. */
74
+ export const unreadRoomCount = (identity: ChatIdentity): Promise<number> => fenced(identity, async () => {
75
+ const page = await withToken(identity, (chatToken) => listChatroomsPage({ ...MEMBER, chatToken, pageSize: 1, onlyUnread: true, participantType: "business" }));
76
+ const count = page.unreadChatroomCount;
77
+ if (typeof count !== "number" || !Number.isSafeInteger(count) || count < 0) throw new Error("unavailable unread chat count");
78
+ return count;
79
+ });
80
+ export const messagesPage = (identity: ChatIdentity, roomId: string): Promise<Raw[]> => fenced(identity, async () =>
81
+ (await withToken(identity, (chatToken) => getMessagesPage(roomId, { ...MEMBER, chatToken, pageSize: 50, ordering: "Desc" }))).items as unknown as Raw[]);
82
+
83
+ function bridge(): Bridge {
84
+ const api = (globalThis as unknown as { himalaya?: { wixApi?: Bridge } }).himalaya?.wixApi;
85
+ if (!api) throw new Error("wix_api_bridge_unavailable");
86
+ return api;
87
+ }
88
+ /** A typed message goes through Smart Chat, exactly as the site's chat widget sends it. The Inbox then files it under
89
+ * Wix Smart Chat and the AI can answer it; a message posted straight into the room has no channel, so the AI never
90
+ * saw it and the owner's reply went out by email. Smart Chat chooses the conversation and stored message id.
91
+ * The bridge resolves once the AI has finished answering, not when the message is stored. */
92
+ export const sendMessage = (identity: ChatIdentity, text: string): Promise<string | undefined> => fenced(identity, async () => {
93
+ const response = await bridge().call("POST", "/wix-assistant-widget/v1/messages/stream", {
94
+ message: { sender: "SITE_VISITOR", messageType: "QUESTION", body: { mainText: text } },
95
+ });
96
+ // The first stream frame names the persisted question. Keep its exact id so a send
97
+ // that moves from an old Members transcript to Smart Chat never relies on a text match.
98
+ let frames: unknown = response;
99
+ if (typeof frames === "string") {
100
+ const raw = frames;
101
+ try { frames = JSON.parse(raw); }
102
+ catch {
103
+ frames = [];
104
+ // The bridge buffers SSE verbatim. Ignore event/comment lines and decode the
105
+ // data of each frame; some hosts instead hand over NDJSON or parsed frames.
106
+ for (const block of raw.split(/\r?\n\r?\n/)) {
107
+ const lines = block.split(/\r?\n/);
108
+ const event = lines.find(line => line.startsWith('event:'))?.slice(6).trim();
109
+ const data = lines.filter(line => line.startsWith('data:')).map(line => line.slice(5).trimStart()).join('\n');
110
+ try {
111
+ const value = JSON.parse(data || block);
112
+ (frames as unknown[]).push(event === 'inputMessage' && !value?.inputMessage ? { inputMessage: value } : value);
113
+ } catch { /* Comments and other non-JSON frames carry no stored question id. */ }
114
+ }
115
+ // A buffered NDJSON response has no SSE separators.
116
+ if (!(frames as unknown[]).length) {
117
+ try { frames = [JSON.parse(raw.split('\n', 1)[0]!)]; } catch { return undefined; }
118
+ }
119
+ }
120
+ }
121
+ for (const frame of Array.isArray(frames) ? frames : [frames]) {
122
+ const input = (frame as { inputMessage?: { id?: unknown; sender?: unknown; messageType?: unknown } } | null)?.inputMessage;
123
+ if (input?.sender === "SITE_VISITOR" && input.messageType === "QUESTION" && typeof input.id === "string" && input.id) return `smart-chat:${input.id}`;
124
+ }
125
+ return undefined;
126
+ });
127
+ /** A tapped button is a silent, ephemeral message carrying the button's chat action. */
128
+ export const sendButton = (identity: ChatIdentity, roomId: string, input: { id: string; text: string; appId: string; interactionId: string }): Promise<void> => fenced(identity, async () => {
129
+ await withToken(identity, (chatToken) => bridge().call("POST", `${MANAGE}/_api/chat-web/v2/chatrooms/${encodeURIComponent(roomId)}/messages`, {
130
+ sendMessageBody: { id: input.id, messageType: "message", messageTypeVersion: 1, summary: input.text, isEphemeral: true, isSilent: true, data: [{ mimeType: "text/plain", data: { text: input.text } }] },
131
+ sendMessageOptions: { chatAction: { actionType: "BUTTON_INTERACTION", appId: input.appId, interactionId: input.interactionId } },
132
+ }, { ChatToken: chatToken }));
133
+ });
134
+
135
+ const https = (value: unknown): string => (typeof value === "string" && /^https:\/\/[^\s\\]+$/.test(value) ? value : "");
136
+ /** A fresh, authorized URL for an attachment. A private file is always fetched by its id. */
137
+ export const attachmentUrl = (identity: ChatIdentity, media: { mediaId?: string; mediaProvider?: string; url?: string; fileName?: string }): Promise<string> => fenced(identity, async () => {
138
+ if (media.mediaProvider === "WixMediaPrivate") {
139
+ if (!media.mediaId) throw new Error("attachment_has_no_media_id");
140
+ const response = await bridge().call("POST", "/communication-channels-media/v1/download-url", {
141
+ fileId: media.mediaId, ...(media.fileName ? { downloadFileName: media.fileName } : {}),
142
+ }) as Raw | null;
143
+ const url = https(response?.downloadUrl);
144
+ if (!url) throw new Error("attachment_download_url_invalid");
145
+ return url;
146
+ }
147
+ return https(media.url);
148
+ });
@@ -0,0 +1,113 @@
1
+ // The header badge counts (bell, chat, cart) as one service piece, shared by the app-level nav workers that
2
+ // bind them: `himi-branded-lite-nav` (the full nav worker of the Branded Lite app) and `himi-branded-lite-header-badges`
3
+ // (the badges-only worker a scaffold ships). Both name their service `brandedLiteNav`, so a top-bar action binds the
4
+ // same `$service:brandedLiteNav.<field>` path in either.
5
+ //
6
+ // `null` is unavailable and never a zero (see source-badges.ts). The counts refresh at launch, whenever the
7
+ // signed-in identity changes (the native host session clock, or the reserved `onIdentityChange` hook a web host
8
+ // delivers), on every foreground (`onForeground`), and whenever the worker is asked to. A read that finishes after
9
+ // the identity changed, or after a newer read began, is dropped.
10
+ import { hostSessionFromGlobal } from "@himalaya/iap";
11
+ import { readSourceBadges } from "./source-badges.js";
12
+
13
+ export interface HeaderBadgeState {
14
+ notificationsBadge: number | null;
15
+ chatBadge: number | null;
16
+ cartBadge: number | null;
17
+ /** Which counts the last refresh tried and failed to read ("" when it read every count it could). A count that is
18
+ * unavailable by design (a Visitor's bell and chat, offline) is not an error. Diagnostic: it says why a badge is
19
+ * missing, so a migration can be checked. */
20
+ errorText: string;
21
+ }
22
+ export const HEADER_BADGES_INITIAL: HeaderBadgeState = { notificationsBadge: null, chatBadge: null, cartBadge: null, errorText: "" };
23
+
24
+ /** The counts describe THIS run: a snapshot from the last one (the web store persists an app worker's state per
25
+ * account) would show another day's numbers until the first read lands. Declare them `notPersisted` and
26
+ * `notHydrated` on the service. */
27
+ export const HEADER_BADGE_KEYS: ("notificationsBadge" | "chatBadge" | "cartBadge" | "errorText")[] = ["notificationsBadge", "chatBadge", "cartBadge", "errorText"];
28
+
29
+ /** The action signatures a service that uses `headerBadges` declares in its `defineService` generic. */
30
+ // A `type`, not an `interface`: `defineService` constrains its actions to `Record<string, fn>`, which only a type
31
+ // alias satisfies (an interface has no implicit index signature).
32
+ export type HeaderBadgeActionSignatures<S> = {
33
+ /** Re-read the header badge counts. Only the newest read lands. */
34
+ refreshBadges: (s: S) => Promise<S>;
35
+ /** Drop every badge count (a new identity), committed at once so no stale number waits on a network read. */
36
+ dropBadges: (s: S) => Promise<S>;
37
+ /** Reserved lifecycle hooks the app-service host delivers to every service that declares them. */
38
+ onForeground: (s: S) => Promise<S>;
39
+ onIdentityChange: (s: S) => Promise<S>;
40
+ };
41
+
42
+ /** What `headerBadges` hands a worker. Named (not inferred) so a worker can annotate its `badges`, which breaks the
43
+ * loop between that value and the service handle it is built from. */
44
+ export interface HeaderBadges<S> {
45
+ actions: HeaderBadgeActionSignatures<S>;
46
+ /** Call once after `defineService`: the launch read, and the session clock's notifications. */
47
+ start(): void;
48
+ /** Re-read after something that may have changed a count (a notification receipt). */
49
+ refresh(): void;
50
+ }
51
+
52
+ type Update<S> = (s: S, change: (current: S) => Promise<S>) => Promise<S>;
53
+ type Self = () => { refreshBadges(): Promise<unknown>; dropBadges(): Promise<unknown> };
54
+
55
+ /**
56
+ * @param update serializes state changes for the worker, so overlapping actions build on the preceding result
57
+ * @param self the worker's own service handle (read lazily: it does not exist yet when this is called)
58
+ */
59
+ export function headerBadges<S extends HeaderBadgeState>(update: Update<S>, self: Self): HeaderBadges<S> {
60
+ /** Which read is the newest: an older one that finishes later must not overwrite a newer answer. */
61
+ let read = 0;
62
+ /** The host session generation the badges on show were read under. */
63
+ let generation = -1;
64
+ /** The clock the native runtime publishes for the signed-in identity: it names the site the bridge is bound to
65
+ * and notifies on every sign-in, sign-out and member switch. A host without one (web, older binaries) reads a
66
+ * signed-out stub that never notifies. */
67
+ const session = hostSessionFromGlobal();
68
+ const cleared = (current: S): S => ({ ...current, ...HEADER_BADGES_INITIAL });
69
+
70
+ const actions: HeaderBadgeActionSignatures<S> = {
71
+ refreshBadges: async (s) => {
72
+ const mine = ++read;
73
+ const badges = await readSourceBadges(session.current().kind === "member");
74
+ return update(s, async (current) => mine === read
75
+ ? { ...current, notificationsBadge: badges.notifications, chatBadge: badges.chat, cartBadge: badges.cart, errorText: badges.failed.length ? `could not read: ${badges.failed.join(", ")}` : "" }
76
+ : current);
77
+ },
78
+ dropBadges: async (s) => {
79
+ ++read; // a read already in flight belongs to the previous identity
80
+ return update(s, async (current) => cleared(current));
81
+ },
82
+ onForeground: async (s) => update(s, async (current) => current).finally(() => { void self().refreshBadges(); }),
83
+ onIdentityChange: async (s) => {
84
+ ++read;
85
+ const dropped = await update(s, async (current) => cleared(current));
86
+ void self().refreshBadges();
87
+ return dropped;
88
+ },
89
+ };
90
+
91
+ /** A session notification: a new generation is a new identity, so the previous one's numbers go first. */
92
+ async function onSession(): Promise<void> {
93
+ const now = session.current().generation;
94
+ if (now !== generation) {
95
+ generation = now;
96
+ await self().dropBadges();
97
+ }
98
+ await self().refreshBadges();
99
+ }
100
+
101
+ return {
102
+ actions,
103
+ /** Call once after `defineService`: the launch read, and the session clock's notifications. */
104
+ start(): void {
105
+ // Subscribing notifies at once, which is the launch read; a host with no clock needs the explicit one.
106
+ let notified = false;
107
+ session.subscribe(() => { notified = true; void onSession(); });
108
+ if (!notified) void self().refreshBadges();
109
+ },
110
+ /** Re-read after something that may have changed a count (a notification receipt). */
111
+ refresh(): void { void self().refreshBadges(); },
112
+ };
113
+ }