@wix/himalaya-cli 0.1749.0 → 0.1751.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 (324) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/builder.d.ts +3 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/himi-package.d.ts +478 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/host-compatibility.d.ts +56 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/icon-catalog.generated.d.ts +1 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/schema.d.ts +4 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-shell.d.ts +156 -8
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/validator.d.ts +3 -0
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/index.d.ts +2 -0
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast-service.d.ts +105 -0
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/podcast.d.ts +116 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +326 -13
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +730 -81
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +155 -0
  14. package/dist/browser-plane/assets.json +5 -5
  15. package/dist/browser-plane/preview-deferred/{b40ea5d0d6251898ff5617139fde8be008dd11e99a70b14c1052093685401700.bin → 21f35a12bd94f4ab97a9a75453c4adcadc438daf024a4b1950d5c356c123bd01.bin} +1 -1
  16. package/dist/browser-plane/sw.js +7 -7
  17. package/dist/cli.mjs +44618 -35753
  18. package/dist/preview-assets.generated.bin +0 -0
  19. package/guides/component-reference.json +1 -1
  20. package/guides/component-reference.md +4 -0
  21. package/guides/designing-himi-screens.md +7 -0
  22. package/guides/getting-started.md +5 -1
  23. package/guides/headless-loop.md +1 -1
  24. package/guides/himi-json-output.md +54 -1
  25. package/guides/himi-skill.md +5 -1
  26. package/guides/index.json +6 -0
  27. package/guides/one-app-to-himi-app.md +31 -8
  28. package/guides/qa-builds.md +12 -1
  29. package/guides/recipe-podcast.md +149 -0
  30. package/guides/skill.md +3 -1
  31. package/guides/store-submission.md +149 -34
  32. package/guides/tier-5-add-a-screen.md +16 -2
  33. package/guides/wix-business-context.md +43 -0
  34. package/guides/wix-platform-usage.md +7 -2
  35. package/package.json +10 -10
  36. package/template-icons/fitness-gym.png +0 -0
  37. package/template-icons/personal-fitness-trainer.png +0 -0
  38. package/templates/beauty-salon/config.ts +12 -0
  39. package/templates/beauty-salon/dev/index.ts +1 -1
  40. package/templates/beauty-salon/l10n/en.json +1 -1
  41. package/templates/beauty-salon/tier5-src/_shared/booking-session.ts +3 -1
  42. package/templates/beauty-salon/tier5-src/_shared/business-chat-transport.ts +148 -0
  43. package/templates/beauty-salon/tier5-src/_shared/header-badges.ts +113 -0
  44. package/templates/beauty-salon/tier5-src/_shared/location-pin.ts +97 -0
  45. package/templates/beauty-salon/tier5-src/_shared/member-access.ts +17 -6
  46. package/templates/beauty-salon/tier5-src/_shared/program-fields.ts +16 -0
  47. package/templates/beauty-salon/tier5-src/_shared/programs-section.ts +5 -8
  48. package/templates/beauty-salon/tier5-src/_shared/source-badges.ts +72 -0
  49. package/templates/beauty-salon/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  50. package/templates/beauty-salon/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  51. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +13 -4
  52. package/templates/beauty-salon/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  53. package/templates/branded-lite/config.ts +12 -0
  54. package/templates/branded-lite/dev/index.ts +101 -1
  55. package/templates/branded-lite/l10n/en.json +22 -1
  56. package/templates/branded-lite/l10n/es.json +22 -0
  57. package/templates/branded-lite/l10n/fr.json +23 -0
  58. package/templates/branded-lite/l10n/he.json +19 -0
  59. package/templates/branded-lite/tier5-src/_shared/booking-session.ts +3 -1
  60. package/templates/branded-lite/tier5-src/_shared/location-pin.ts +97 -0
  61. package/templates/branded-lite/tier5-src/_shared/member-access.ts +17 -6
  62. package/templates/branded-lite/tier5-src/_shared/program-fields.ts +16 -0
  63. package/templates/branded-lite/tier5-src/_shared/programs-section.ts +5 -8
  64. package/templates/branded-lite/tier5-src/himi-branded-lite-access-nav/index.ts +10 -5
  65. package/templates/branded-lite/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  66. package/templates/branded-lite/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  67. package/templates/branded-lite/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
  68. package/templates/branded-lite/tier5-src/himi-branded-lite-video/index.ts +12 -1
  69. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +13 -4
  70. package/templates/branded-lite/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  71. package/templates/brandy/README.md +33 -0
  72. package/templates/brandy/config.ts +51 -7
  73. package/templates/brandy/dev/index.ts +23 -9
  74. package/templates/community-club/l10n/en.json +1 -1
  75. package/templates/community-club/tier5-src/_shared/member-access.ts +17 -6
  76. package/templates/community-club/tier5-src/_shared/program-fields.ts +16 -0
  77. package/templates/community-club/tier5-src/_shared/programs-section.ts +5 -8
  78. package/templates/community-club/tier5-src/himi-store-account/index.ts +13 -4
  79. package/templates/community-club/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  80. package/templates/conference/tier5-src/_shared/member-access.ts +17 -6
  81. package/templates/conference/tier5-src/himi-store-account/index.ts +13 -4
  82. package/templates/events-meetups/l10n/en.json +1 -1
  83. package/templates/events-meetups/tier5-src/_shared/member-access.ts +17 -6
  84. package/templates/events-meetups/tier5-src/_shared/program-fields.ts +16 -0
  85. package/templates/events-meetups/tier5-src/_shared/programs-section.ts +5 -8
  86. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +13 -4
  87. package/templates/events-meetups/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  88. package/templates/fitness-gym/README.md +53 -0
  89. package/templates/fitness-gym/config.ts +560 -0
  90. package/templates/fitness-gym/dev/index.ts +25787 -0
  91. package/templates/fitness-gym/himalaya.content.json +64 -0
  92. package/templates/fitness-gym/himalaya.template.json +15 -0
  93. package/templates/fitness-gym/icon.png +0 -0
  94. package/templates/fitness-gym/platforms.json +1 -0
  95. package/templates/fitness-gym/tier5-src/_shared/app-locale.ts +61 -0
  96. package/templates/fitness-gym/tier5-src/_shared/booking-location.ts +147 -0
  97. package/templates/fitness-gym/tier5-src/_shared/booking-session.ts +224 -0
  98. package/templates/fitness-gym/tier5-src/_shared/branded-lite-hosted.ts +280 -0
  99. package/templates/fitness-gym/tier5-src/_shared/branded-load-state.ts +109 -0
  100. package/templates/fitness-gym/tier5-src/_shared/business-chat-copy.ts +40 -0
  101. package/templates/fitness-gym/tier5-src/_shared/business-chat-history.ts +51 -0
  102. package/templates/fitness-gym/tier5-src/_shared/business-chat-message-model.ts +177 -0
  103. package/templates/fitness-gym/tier5-src/_shared/business-chat-model.ts +56 -0
  104. package/templates/fitness-gym/tier5-src/_shared/business-chat-presenter.ts +576 -0
  105. package/templates/fitness-gym/tier5-src/_shared/business-chat-transport.ts +148 -0
  106. package/templates/fitness-gym/tier5-src/_shared/collection-contract.ts +228 -0
  107. package/templates/fitness-gym/tier5-src/_shared/collection-query.ts +193 -0
  108. package/templates/fitness-gym/tier5-src/_shared/collection-service.ts +400 -0
  109. package/templates/fitness-gym/tier5-src/_shared/detail-presence.ts +51 -0
  110. package/templates/fitness-gym/tier5-src/_shared/engine-intl.ts +523 -0
  111. package/templates/fitness-gym/tier5-src/_shared/himi-account.ts +194 -0
  112. package/templates/fitness-gym/tier5-src/_shared/himi-booking-saved.ts +88 -0
  113. package/templates/fitness-gym/tier5-src/_shared/himi-bookings.ts +318 -0
  114. package/templates/fitness-gym/tier5-src/_shared/himi-copy.ts +116 -0
  115. package/templates/fitness-gym/tier5-src/_shared/himi-media.ts +29 -0
  116. package/templates/fitness-gym/tier5-src/_shared/himi-store.ts +7 -0
  117. package/templates/fitness-gym/tier5-src/_shared/himi-text.ts +24 -0
  118. package/templates/fitness-gym/tier5-src/_shared/host-events.ts +66 -0
  119. package/templates/fitness-gym/tier5-src/_shared/hosted-checkout.ts +70 -0
  120. package/templates/fitness-gym/tier5-src/_shared/iap-attendance-form.ts +106 -0
  121. package/templates/fitness-gym/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
  122. package/templates/fitness-gym/tier5-src/_shared/iap-attendance.ts +38 -0
  123. package/templates/fitness-gym/tier5-src/_shared/iap-worker.ts +127 -0
  124. package/templates/fitness-gym/tier5-src/_shared/inbox-rooms.ts +68 -0
  125. package/templates/fitness-gym/tier5-src/_shared/local-preferences.ts +38 -0
  126. package/templates/fitness-gym/tier5-src/_shared/member-access.ts +63 -0
  127. package/templates/fitness-gym/tier5-src/_shared/member-account-routes.ts +52 -0
  128. package/templates/fitness-gym/tier5-src/_shared/member-bookings.ts +107 -0
  129. package/templates/fitness-gym/tier5-src/_shared/member-screen.ts +99 -0
  130. package/templates/fitness-gym/tier5-src/_shared/notification-target.ts +141 -0
  131. package/templates/fitness-gym/tier5-src/_shared/offset-page.ts +10 -0
  132. package/templates/fitness-gym/tier5-src/_shared/online-actions.ts +76 -0
  133. package/templates/fitness-gym/tier5-src/_shared/owner-load-error.ts +348 -0
  134. package/templates/fitness-gym/tier5-src/_shared/payment-setup.ts +6 -0
  135. package/templates/fitness-gym/tier5-src/_shared/pricing-plan-display.ts +64 -0
  136. package/templates/fitness-gym/tier5-src/_shared/program-description.ts +11 -0
  137. package/templates/fitness-gym/tier5-src/_shared/program-fields.ts +16 -0
  138. package/templates/fitness-gym/tier5-src/_shared/program-standing.ts +46 -0
  139. package/templates/fitness-gym/tier5-src/_shared/rich-body.ts +78 -0
  140. package/templates/fitness-gym/tier5-src/_shared/rich-content-link.ts +34 -0
  141. package/templates/fitness-gym/tier5-src/_shared/sign-in-sheet.ts +18 -0
  142. package/templates/fitness-gym/tier5-src/_shared/staff-name.ts +18 -0
  143. package/templates/fitness-gym/tier5-src/_shared/weekly-goal.ts +107 -0
  144. package/templates/fitness-gym/tier5-src/_shared/wix-bi.ts +85 -0
  145. package/templates/fitness-gym/tier5-src/_shared/wix-member-links.ts +114 -0
  146. package/templates/fitness-gym/tier5-src/_shared/wix-service-price.ts +146 -0
  147. package/templates/fitness-gym/tier5-src/business-chat/index.ts +732 -0
  148. package/templates/fitness-gym/tier5-src/business-contact/index.ts +6 -0
  149. package/templates/fitness-gym/tier5-src/himi-booking-account/index.ts +267 -0
  150. package/templates/fitness-gym/tier5-src/himi-booking-bookings/index.ts +468 -0
  151. package/templates/fitness-gym/tier5-src/himi-booking-service/index.ts +1190 -0
  152. package/templates/fitness-gym/tier5-src/himi-booking-services/index.ts +791 -0
  153. package/templates/fitness-gym/tier5-src/himi-booking-time/index.ts +1729 -0
  154. package/templates/fitness-gym/tier5-src/himi-branded-lite-agenda/index.ts +988 -0
  155. package/templates/fitness-gym/tier5-src/himi-branded-lite-member-programs/index.ts +656 -0
  156. package/templates/fitness-gym/tier5-src/himi-branded-lite-notifications/index.ts +256 -0
  157. package/templates/fitness-gym/tier5-src/himi-branded-lite-plans/index.ts +495 -0
  158. package/templates/fitness-gym/tier5-src/himi-branded-lite-program/facts.ts +52 -0
  159. package/templates/fitness-gym/tier5-src/himi-branded-lite-program/index.ts +845 -0
  160. package/templates/fitness-gym/tier5-src/himi-fitcoach-goal/index.ts +191 -0
  161. package/templates/fitness-gym/tier5-src/himi-fitcoach-home/index.ts +619 -0
  162. package/templates/fitness-gym/tier5-src/himi-store-account/index.ts +1007 -0
  163. package/templates/fitness-gym/tier5-src/wix-spaces-my-subscriptions/index.ts +84 -0
  164. package/templates/fitness-gym/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
  165. package/templates/fitness-gym/tokens.json +414 -0
  166. package/templates/gym-fitness/config.ts +12 -0
  167. package/templates/gym-fitness/dev/index.ts +1 -1
  168. package/templates/gym-fitness/l10n/en.json +1 -1
  169. package/templates/gym-fitness/tier5-src/_shared/booking-session.ts +3 -1
  170. package/templates/gym-fitness/tier5-src/_shared/business-chat-transport.ts +148 -0
  171. package/templates/gym-fitness/tier5-src/_shared/header-badges.ts +113 -0
  172. package/templates/gym-fitness/tier5-src/_shared/location-pin.ts +97 -0
  173. package/templates/gym-fitness/tier5-src/_shared/member-access.ts +17 -6
  174. package/templates/gym-fitness/tier5-src/_shared/program-fields.ts +16 -0
  175. package/templates/gym-fitness/tier5-src/_shared/programs-section.ts +5 -8
  176. package/templates/gym-fitness/tier5-src/_shared/source-badges.ts +72 -0
  177. package/templates/gym-fitness/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  178. package/templates/gym-fitness/tier5-src/himi-branded-lite-nav/index.ts +152 -0
  179. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +13 -4
  180. package/templates/gym-fitness/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  181. package/templates/medical-services/dev/index.ts +2 -1
  182. package/templates/medical-services/tier5-src/_shared/booking-session.ts +3 -1
  183. package/templates/medical-services/tier5-src/_shared/member-access.ts +17 -6
  184. package/templates/medical-services/tier5-src/himi-booking-account/index.ts +16 -1
  185. package/templates/medical-services/tier5-src/himi-store-account/index.ts +13 -4
  186. package/templates/nonprofit-cause/l10n/en.json +1 -1
  187. package/templates/nonprofit-cause/tier5-src/_shared/member-access.ts +17 -6
  188. package/templates/nonprofit-cause/tier5-src/_shared/program-fields.ts +16 -0
  189. package/templates/nonprofit-cause/tier5-src/_shared/programs-section.ts +5 -8
  190. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +13 -4
  191. package/templates/nonprofit-cause/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  192. package/templates/personal-fitness-trainer/README.md +51 -0
  193. package/templates/personal-fitness-trainer/config.ts +343 -0
  194. package/templates/personal-fitness-trainer/dev/index.ts +24813 -0
  195. package/templates/personal-fitness-trainer/himalaya.content.json +79 -0
  196. package/templates/personal-fitness-trainer/himalaya.template.json +14 -0
  197. package/templates/personal-fitness-trainer/icon.png +0 -0
  198. package/templates/personal-fitness-trainer/platforms.json +3 -0
  199. package/templates/personal-fitness-trainer/splash.json +3 -0
  200. package/templates/personal-fitness-trainer/tier5-src/_shared/app-locale.ts +61 -0
  201. package/templates/personal-fitness-trainer/tier5-src/_shared/booking-location.ts +147 -0
  202. package/templates/personal-fitness-trainer/tier5-src/_shared/booking-session.ts +224 -0
  203. package/templates/personal-fitness-trainer/tier5-src/_shared/branded-lite-hosted.ts +280 -0
  204. package/templates/personal-fitness-trainer/tier5-src/_shared/branded-load-state.ts +109 -0
  205. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-copy.ts +40 -0
  206. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-history.ts +51 -0
  207. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-message-model.ts +177 -0
  208. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-model.ts +56 -0
  209. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-presenter.ts +576 -0
  210. package/templates/personal-fitness-trainer/tier5-src/_shared/business-chat-transport.ts +148 -0
  211. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-contract.ts +228 -0
  212. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-query.ts +193 -0
  213. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-service.ts +400 -0
  214. package/templates/personal-fitness-trainer/tier5-src/_shared/detail-presence.ts +51 -0
  215. package/templates/personal-fitness-trainer/tier5-src/_shared/empty-flags.ts +33 -0
  216. package/templates/personal-fitness-trainer/tier5-src/_shared/engine-intl.ts +523 -0
  217. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-account.ts +194 -0
  218. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-booking-saved.ts +88 -0
  219. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-bookings.ts +318 -0
  220. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-copy.ts +116 -0
  221. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-layouts.ts +142 -0
  222. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-store.ts +7 -0
  223. package/templates/personal-fitness-trainer/tier5-src/_shared/himi-text.ts +24 -0
  224. package/templates/personal-fitness-trainer/tier5-src/_shared/host-events.ts +66 -0
  225. package/templates/personal-fitness-trainer/tier5-src/_shared/hosted-checkout.ts +70 -0
  226. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-attendance-form.ts +106 -0
  227. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-attendance-purchase.ts +216 -0
  228. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-attendance.ts +38 -0
  229. package/templates/personal-fitness-trainer/tier5-src/_shared/iap-worker.ts +127 -0
  230. package/templates/personal-fitness-trainer/tier5-src/_shared/inbox-rooms.ts +68 -0
  231. package/templates/personal-fitness-trainer/tier5-src/_shared/local-preferences.ts +38 -0
  232. package/templates/personal-fitness-trainer/tier5-src/_shared/member-access.ts +63 -0
  233. package/templates/personal-fitness-trainer/tier5-src/_shared/member-account-routes.ts +52 -0
  234. package/templates/personal-fitness-trainer/tier5-src/_shared/member-bookings.ts +107 -0
  235. package/templates/personal-fitness-trainer/tier5-src/_shared/member-screen.ts +99 -0
  236. package/templates/personal-fitness-trainer/tier5-src/_shared/offset-page.ts +10 -0
  237. package/templates/personal-fitness-trainer/tier5-src/_shared/online-actions.ts +76 -0
  238. package/templates/personal-fitness-trainer/tier5-src/_shared/owner-load-error.ts +348 -0
  239. package/templates/personal-fitness-trainer/tier5-src/_shared/payment-setup.ts +6 -0
  240. package/templates/personal-fitness-trainer/tier5-src/_shared/pricing-plan-display.ts +64 -0
  241. package/templates/personal-fitness-trainer/tier5-src/_shared/rich-body.ts +78 -0
  242. package/templates/personal-fitness-trainer/tier5-src/_shared/rich-content-link.ts +34 -0
  243. package/templates/personal-fitness-trainer/tier5-src/_shared/sign-in-sheet.ts +18 -0
  244. package/templates/personal-fitness-trainer/tier5-src/_shared/staff-name.ts +18 -0
  245. package/templates/personal-fitness-trainer/tier5-src/_shared/video-caption.ts +21 -0
  246. package/templates/personal-fitness-trainer/tier5-src/_shared/weekly-goal.ts +107 -0
  247. package/templates/personal-fitness-trainer/tier5-src/_shared/wix-bi.ts +85 -0
  248. package/templates/personal-fitness-trainer/tier5-src/_shared/wix-service-price.ts +146 -0
  249. package/templates/personal-fitness-trainer/tier5-src/business-chat/index.ts +732 -0
  250. package/templates/personal-fitness-trainer/tier5-src/business-contact/index.ts +6 -0
  251. package/templates/personal-fitness-trainer/tier5-src/himi-booking-bookings/index.ts +468 -0
  252. package/templates/personal-fitness-trainer/tier5-src/himi-booking-service/index.ts +1190 -0
  253. package/templates/personal-fitness-trainer/tier5-src/himi-booking-services/index.ts +791 -0
  254. package/templates/personal-fitness-trainer/tier5-src/himi-booking-time/index.ts +1729 -0
  255. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +242 -0
  256. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-account-settings/index.ts +1094 -0
  257. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-agenda/index.ts +988 -0
  258. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-appearance/index.ts +94 -0
  259. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-notifsettings/index.ts +173 -0
  260. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-plans/index.ts +495 -0
  261. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-splash/index.ts +35 -0
  262. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-video/index.ts +226 -0
  263. package/templates/personal-fitness-trainer/tier5-src/himi-branded-lite-videos/index.ts +145 -0
  264. package/templates/personal-fitness-trainer/tier5-src/himi-fitness-trainer-home/index.ts +70 -0
  265. package/templates/personal-fitness-trainer/tier5-src/himi-fitness-trainer-profile/index.ts +53 -0
  266. package/templates/personal-fitness-trainer/tier5-src/himi-store-account/index.ts +1007 -0
  267. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-app-language/index.ts +73 -0
  268. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  269. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-my-subscriptions/index.ts +84 -0
  270. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
  271. package/templates/personal-fitness-trainer/tier5-src/wix-spaces-view-profile/index.ts +119 -0
  272. package/templates/personal-fitness-trainer/tokens.json +381 -0
  273. package/templates/podcast-creator/dev/index.ts +100 -0
  274. package/templates/podcast-creator/l10n/en.json +22 -1
  275. package/templates/podcast-creator/l10n/es.json +22 -0
  276. package/templates/podcast-creator/l10n/fr.json +18 -0
  277. package/templates/podcast-creator/l10n/he.json +15 -0
  278. package/templates/podcast-creator/tier5-src/_shared/member-access.ts +17 -6
  279. package/templates/podcast-creator/tier5-src/_shared/program-fields.ts +16 -0
  280. package/templates/podcast-creator/tier5-src/_shared/programs-section.ts +5 -8
  281. package/templates/podcast-creator/tier5-src/himi-branded-lite-podcasts/index.ts +14 -234
  282. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +13 -4
  283. package/templates/podcast-creator/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  284. package/templates/portfolio-creative/l10n/en.json +1 -1
  285. package/templates/portfolio-creative/tier5-src/_shared/member-access.ts +17 -6
  286. package/templates/portfolio-creative/tier5-src/_shared/program-fields.ts +16 -0
  287. package/templates/portfolio-creative/tier5-src/_shared/programs-section.ts +5 -8
  288. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +13 -4
  289. package/templates/portfolio-creative/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  290. package/templates/restaurant/l10n/en.json +1 -1
  291. package/templates/restaurant/tier5-src/_shared/member-access.ts +17 -6
  292. package/templates/restaurant/tier5-src/_shared/program-fields.ts +16 -0
  293. package/templates/restaurant/tier5-src/_shared/programs-section.ts +5 -8
  294. package/templates/restaurant/tier5-src/himi-store-account/index.ts +13 -4
  295. package/templates/restaurant/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  296. package/templates/retail-store/l10n/en.json +1 -1
  297. package/templates/retail-store/tier5-src/_shared/member-access.ts +17 -6
  298. package/templates/retail-store/tier5-src/_shared/program-fields.ts +16 -0
  299. package/templates/retail-store/tier5-src/_shared/programs-section.ts +5 -8
  300. package/templates/retail-store/tier5-src/himi-store-account/index.ts +13 -4
  301. package/templates/retail-store/tier5-src/wix-spaces-view-profile/index.ts +68 -55
  302. package/templates/salon-spa/dev/index.ts +1 -1
  303. package/templates/salon-spa/tier5-src/_shared/booking-session.ts +3 -1
  304. package/templates/salon-spa/tier5-src/_shared/member-access.ts +17 -6
  305. package/templates/salon-spa/tier5-src/himi-booking-account/index.ts +16 -1
  306. package/templates/salon-spa/tier5-src/himi-branded-lite-agenda/index.ts +37 -4
  307. package/templates/salon-spa/tier5-src/himi-store-account/index.ts +13 -4
  308. package/templates/wholesale-store/tier5-src/_shared/member-access.ts +17 -6
  309. package/templates/wholesale-store/tier5-src/himi-store-account/index.ts +13 -4
  310. package/templates/yoga-studio/config.ts +12 -0
  311. package/templates/yoga-studio/dev/index.ts +1 -1
  312. package/templates/yoga-studio/l10n/en.json +1 -1
  313. package/templates/yoga-studio/tier5-src/_shared/booking-session.ts +3 -1
  314. package/templates/yoga-studio/tier5-src/_shared/business-chat-transport.ts +148 -0
  315. package/templates/yoga-studio/tier5-src/_shared/header-badges.ts +113 -0
  316. package/templates/yoga-studio/tier5-src/_shared/location-pin.ts +97 -0
  317. package/templates/yoga-studio/tier5-src/_shared/member-access.ts +17 -6
  318. package/templates/yoga-studio/tier5-src/_shared/program-fields.ts +16 -0
  319. package/templates/yoga-studio/tier5-src/_shared/programs-section.ts +5 -8
  320. package/templates/yoga-studio/tier5-src/_shared/source-badges.ts +72 -0
  321. package/templates/yoga-studio/tier5-src/himi-branded-lite-agenda/index.ts +37 -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$source": "en",
3
- "$generated": "2026-11-15T09:24:42.792Z",
3
+ "$generated": "2026-11-17T08:26:59.985Z",
4
4
  "messages": {
5
5
  "h_01e1787a9e5b": {
6
6
  "source": "App language",
@@ -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
+ }
@@ -0,0 +1,97 @@
1
+ // The Services top-bar location pin, for an app-level `brandedLiteNav` worker.
2
+ //
3
+ // A top-bar action hides only through the app worker, never the screen's, so the worker counts the places the
4
+ // visible catalog is offered in, once per launch, and publishes `noLocationMenu` for the pin's `hiddenPath`. One
5
+ // piece, shared by the full nav worker and `himi-branded-lite-access-nav` (the worker `himi one-app access`
6
+ // switches an app to), so the pin follows the business whichever of them an app runs. A worker that does not
7
+ // publish the field leaves the pin unresolved, and an unresolved top-bar `hiddenPath` shows it.
8
+
9
+ import { queryServices } from "@himalaya/wix-bookings";
10
+ import { distinctChoices, serviceLocationChoices } from "./booking-location.js";
11
+
12
+ export interface LocationPinState {
13
+ /** Hides the Services top-bar location pin: true until the catalog shows two or more places. Read once per launch
14
+ * with the same keys as the Services screen: the stored answer first, then the network's. */
15
+ noLocationMenu: boolean;
16
+ }
17
+
18
+ export const LOCATION_PIN_INITIAL: LocationPinState = { noLocationMenu: true };
19
+
20
+ /** The action a service that uses `locationPin` declares in its `defineService` generic. A `type`, as for
21
+ * `HeaderBadgeActionSignatures`: `defineService` constrains its actions to a record only a type alias satisfies. */
22
+ export type LocationPinActionSignatures<S> = {
23
+ /** Commit a count of the places the services are offered in. */
24
+ applyLocationCount: (s: S, places?: unknown) => Promise<S>;
25
+ };
26
+
27
+ /** What `locationPin` hands a worker. Named, so a worker can annotate its `pin` and break the loop with its handle. */
28
+ export interface LocationPin<S> {
29
+ actions: LocationPinActionSignatures<S>;
30
+ /** Call once after `defineService`: the launch read. `skip` is true for an app with no bookings (a hosted site
31
+ * without them), which never shows the pin. */
32
+ start(skip?: boolean): void;
33
+ }
34
+
35
+ type Update<S> = (s: S, change: (current: S) => Promise<S>) => Promise<S>;
36
+ type Self = () => { applyLocationCount(places?: unknown): Promise<unknown> };
37
+
38
+ /** Catalog pages the count may read: a second place can first appear past the first 100 services. */
39
+ const LOCATION_PAGES = 5;
40
+
41
+ /** The site has no Bookings: its API answers 428, or 404 for the route. Read from the LEADING status only, as
42
+ * `_shared/owner-widget-reads.ts` does, so a `HTTP 503` whose body quotes a 404 is still a failed read. */
43
+ function bookingsAbsent(e: unknown): boolean {
44
+ return /^HTTP (?:404|428)\b/.test(String((e as Error)?.message ?? e));
45
+ }
46
+
47
+ /** How many places the visible catalog is offered in, read with `cache`, or undefined when that read
48
+ * has no answer: no stored body, or a failed network read. Pages until a second place shows or the
49
+ * catalog ends; a page that fails after that is no answer, unless two places are already counted. */
50
+ async function locationCount(cache: "only-if-cached" | "reload"): Promise<number | undefined> {
51
+ let places: ReturnType<typeof distinctChoices> = [];
52
+ for (let page = 0; page < LOCATION_PAGES; page++) {
53
+ let services: unknown[];
54
+ try {
55
+ const res = await queryServices({ query: { filter: { hidden: { $ne: true } }, paging: { limit: 100, offset: page * 100 } } }, { cache });
56
+ services = res.services ?? [];
57
+ } catch (e) {
58
+ // No stored body is the normal first launch, and a site without Bookings has no places: neither is worth a
59
+ // line. A worker cannot see which screens its app has, so it reads on a site without Bookings too.
60
+ if (cache === "reload" && !bookingsAbsent(e)) console.warn(`[branded-lite] location count not read: ${String(e)}`);
61
+ return places.length >= 2 ? places.length : undefined;
62
+ }
63
+ places = distinctChoices([...places, ...services.flatMap((service) => serviceLocationChoices((service as { locations?: unknown }).locations))]);
64
+ if (places.length >= 2 || services.length < 100) break;
65
+ }
66
+ return places.length;
67
+ }
68
+
69
+ /**
70
+ * @param update serializes state changes for the worker, so overlapping actions build on the preceding result
71
+ * @param self the worker's own service handle (read lazily: it does not exist yet when this is called)
72
+ */
73
+ export function locationPin<S extends LocationPinState>(update: Update<S>, self: Self): LocationPin<S> {
74
+ const actions: LocationPinActionSignatures<S> = {
75
+ // A param that crosses the native bridge arrives as a string, so the count is read as a number.
76
+ applyLocationCount: async (s, places) =>
77
+ update(s, async (current) => ({ ...current, noLocationMenu: !(Number(places) >= 2) })),
78
+ };
79
+
80
+ /** Two reads, each committed as it lands. The STORED answer (`only-if-cached`) first, so a returning
81
+ * visitor of a business with two places sees the pin at once; then the NETWORK's (`reload`), which
82
+ * is the only one that may override it. A plain read is not enough: the native Wix read cache
83
+ * answers it with the body the PREVIOUS launch stored and refreshes the store only in the
84
+ * background, and nothing reads again, so the pin followed the previous launch's catalog for the
85
+ * whole session. A failed network read keeps the stored count. With neither, the pin keeps what the
86
+ * last run committed (`noLocationMenu` is stored with the worker's state, as the place count is a
87
+ * property of the business, not of the run), and on a first launch it stays hidden. A site without
88
+ * bookings never shows it. */
89
+ async function check(): Promise<void> {
90
+ const stored = await locationCount("only-if-cached");
91
+ if (stored !== undefined) await self().applyLocationCount(stored);
92
+ const fresh = await locationCount("reload");
93
+ if (fresh !== undefined) await self().applyLocationCount(fresh);
94
+ }
95
+
96
+ return { actions, start: (skip) => { if (!skip) void check(); } };
97
+ }
@@ -1,33 +1,44 @@
1
1
  import { dispatch } from "@himalaya/dispatch";
2
2
  import { getMyData } from "@himalaya/wix-users";
3
3
 
4
- export interface MemberAccess { email: string; scope: string; }
4
+ export interface MemberAccess { email: string; scope: string; signedIn?: boolean; }
5
5
  export function memberAccessChanged(): Error {
6
6
  const error = new Error("Member access changed"); error.name = "MemberAccessChanged"; return error;
7
7
  }
8
- export async function memberAccess(): Promise<MemberAccess> {
8
+ export async function memberAccess(options: { throwOnUnavailable?: boolean } = {}): Promise<MemberAccess> {
9
9
  let email = "";
10
+ let signedIn = false;
10
11
  let identityUnavailable = false;
11
12
  try {
12
- const value = await dispatch("himi.wix.memberIdentity") as { email?: unknown; payload?: { email?: unknown } } | null;
13
+ const value = await dispatch("himi.wix.memberIdentity") as { status?: unknown; ok?: unknown; email?: unknown; signedIn?: unknown; payload?: { email?: unknown; signedIn?: unknown } } | null;
14
+ if (value?.status === "error" || value?.ok === false) throw value;
13
15
  const raw = value?.email ?? value?.payload?.email;
14
16
  email = typeof raw === "string" ? raw.trim().toLowerCase() : "";
17
+ signedIn = (value?.signedIn ?? value?.payload?.signedIn) === true;
15
18
  } catch { identityUnavailable = true; }
16
19
  // Older native hosts predate the memberIdentity action but can still expose
17
20
  // the authenticated profile through wix-users. Only a missing action uses
18
- // that rung: an explicit empty current-session response remains a visitor.
21
+ // that rung. A successful host response is authoritative, including a signed-in
22
+ // session whose email has not arrived yet; it must not consult owner records.
19
23
  if (!email && identityUnavailable) {
20
24
  try {
21
25
  const profile = await getMyData();
22
26
  const raw = profile.email ?? profile.contactEmail;
23
27
  email = typeof raw === "string" ? raw.trim().toLowerCase() : "";
24
- } catch { /* A visitor or an unavailable legacy profile remains anonymous. */ }
28
+ } catch (error) {
29
+ const failure = error as { status?: unknown; statusCode?: unknown; code?: unknown } | null;
30
+ const anonymous = failure?.status === 401 || failure?.statusCode === 401 || failure?.code === "UNAUTHENTICATED";
31
+ // Legacy bridges can lose the structured status. An unknown failure is
32
+ // unavailable in strict consumers, never evidence of a signed-out session.
33
+ if (options.throwOnUnavailable && !anonymous) throw error;
34
+ }
25
35
  }
26
36
  const input = (globalThis as { himalaya?: { input?: Record<string, unknown> } }).himalaya?.input;
27
37
  const account = input?.__himiPreferenceAccount, business = input?.__himiPreferenceBusiness;
28
38
  const valid = (v: unknown): v is string => typeof v === "string" && /^[A-Za-z0-9_.:-]{1,128}$/.test(v) && v !== "default";
29
39
  // These fields are overwritten by authenticated hosts. Older binaries stay online-only.
30
- return { email, scope: email && valid(account) && valid(business) ? JSON.stringify([account, business, email]) : "" };
40
+ // A session signal does not grant an email-scoped cache or private query.
41
+ return { email, signedIn: signedIn || Boolean(email), scope: email && valid(account) && valid(business) ? JSON.stringify([account, business, email]) : "" };
31
42
  }
32
43
  export async function assertMemberAccess(member: MemberAccess): Promise<void> {
33
44
  const current = await memberAccess();
@@ -0,0 +1,16 @@
1
+ // How a worker reads an Online Program's lifecycle and name. Wix returns them in more than one
2
+ // shape (v3 `status` or `state`; `description.title`, `settings.title`, a flat `title` or
3
+ // `details.title`), so every screen that lists programs reads them here, the same way.
4
+ import type { WixProgram } from "@himalaya/wix-online-programs";
5
+ import { cleanTitle } from "./himi-text.js";
6
+
7
+ export function programStatus(p: WixProgram): string {
8
+ return (p.status ?? p.state ?? "").toUpperCase();
9
+ }
10
+ export const isProgramEnded = (p: WixProgram): boolean => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
11
+ export const isProgramDraft = (p: WixProgram): boolean => programStatus(p) === "DRAFT";
12
+
13
+ /** The program's own name, cleaned; "" when it has none (the caller picks its own fallback word). */
14
+ export function programName(p: WixProgram): string {
15
+ return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title);
16
+ }
@@ -22,7 +22,8 @@ import { iapPriceFields, onlineProgramItem, type IapPollDirective } from "@himal
22
22
  import { createIapCommerce } from "@himalaya/iap-checkout";
23
23
  import { createCollectionQuery, type CollectionPage, type CollectionQueryState } from "./collection-query.js";
24
24
  import { memberAccess, memberAccessChanged, memberAccessDenied, type MemberAccess } from "./member-access.js";
25
- import { cleanTitle, initials } from "./himi-text.js";
25
+ import { initials } from "./himi-text.js";
26
+ import { isProgramDraft, isProgramEnded, programName } from "./program-fields.js";
26
27
  import { programImage } from "./himi-media.js";
27
28
  import { descriptionBody } from "./rich-body.js";
28
29
  import { programDescription } from "./program-description.js";
@@ -125,19 +126,15 @@ export interface State {
125
126
  const full = (p: WixProgram): WixProgramFull => p as WixProgramFull;
126
127
 
127
128
  function programTitle(p: WixProgram): string {
128
- return cleanTitle(p.description?.title ?? p.settings?.title ?? p.title ?? p.details?.title)
129
- || copyParam("memberPrograms.programFallbackName", "Program");
129
+ return programName(p) || copyParam("memberPrograms.programFallbackName", "Program");
130
130
  }
131
131
  function programDetails(p: WixProgram): string {
132
132
  // The body may be a Ricos document or serialized text: read it the way the catalog and detail do.
133
133
  const raw = descriptionBody(programDescription(p)).bodyText.replace(/\s+/g, " ").trim();
134
134
  return raw.length > 140 ? `${raw.slice(0, 139).trimEnd()}…` : raw;
135
135
  }
136
- function programStatus(p: WixProgram): string {
137
- return (p.status ?? p.state ?? "").toUpperCase();
138
- }
139
- const isEnded = (p: WixProgram) => programStatus(p) === "ENDED" || programStatus(p) === "FINISHED";
140
- const isDraft = (p: WixProgram) => programStatus(p) === "DRAFT";
136
+ const isEnded = isProgramEnded;
137
+ const isDraft = isProgramDraft;
141
138
  function accessType(p: WixProgram): string {
142
139
  return (full(p).restrictions?.accessType ?? "PUBLIC").toUpperCase();
143
140
  }
@@ -0,0 +1,72 @@
1
+ // The live counts behind the header buttons of a migrated One App (notifications, chat, cart), read for the
2
+ // app-level nav worker. `null` is "unavailable" and never a zero: a failed, offline or stale read leaves the
3
+ // badge off instead of claiming an empty inbox or cart. The shell shows no badge for null or 0 alike, so the
4
+ // two differ only in what the worker may later believe about the source.
5
+ import { getCurrentCart } from "@himalaya/wix-ecom";
6
+ import { countUnseenNotifications } from "@himalaya/wix-members-feed-viewer";
7
+ import { connectivity } from "@himalaya/state";
8
+ import { chatIdentity, unreadRoomCount } from "./business-chat-transport.js";
9
+ import { memberAccess } from "./member-access.js";
10
+
11
+ export type SourceBadgeKey = "notifications" | "chat" | "cart";
12
+ export interface SourceBadges {
13
+ notifications: number | null;
14
+ chat: number | null;
15
+ cart: number | null;
16
+ /** The counts a read was attempted for and failed: not the ones unavailable by design (a Visitor's bell and chat,
17
+ * offline), and not one dropped because the identity changed mid-read. */
18
+ failed: SourceBadgeKey[];
19
+ }
20
+ export const NO_SOURCE_BADGES: SourceBadges = { notifications: null, chat: null, cart: null, failed: [] };
21
+
22
+ /** The same item count the Shop and Account badges show: every line's quantity, a missing one counting as 1. */
23
+ async function cartItemCount(): Promise<number> {
24
+ const cart = await getCurrentCart();
25
+ return (cart.lineItems ?? []).reduce((total, line) => total + (line.quantity ?? 1), 0);
26
+ }
27
+
28
+ /** Whether the shopper is still the one the read started for. A cart belongs to a Visitor as much as to a
29
+ * Member, so this compares what `memberAccess` reports rather than requiring a signed-in member. */
30
+ async function sameShopper(started: { email: string; scope: string }): Promise<boolean> {
31
+ const now = await memberAccess();
32
+ return now.email === started.email && now.scope === started.scope;
33
+ }
34
+
35
+ async function unavailable<T>(read: () => Promise<T>): Promise<T | null> {
36
+ try { return await read(); } catch { return null; }
37
+ }
38
+
39
+ /** A read dropped because the shopper changed while it ran: expected, not a failure to report. */
40
+ const SHOPPER_CHANGED = new Error("shopper changed");
41
+
42
+ /** One refresh. Notifications and chat are a Member's: a Visitor has neither inbox, so both read null without
43
+ * a request. Notifications also need `hostMember`, the host's own session clock saying it is a signed-in member
44
+ * (a host with no clock, web and older binaries, stays unavailable). The worker names no site: native sends
45
+ * the bridge's bound site, or none in the multi-tenant Player, where the member credential fixes the business.
46
+ * Cart is the current shopper's.
47
+ * Offline reads nothing. A count that finishes after the signed-in identity changed is dropped, so one
48
+ * member's number never lands on the next member's header. */
49
+ export async function readSourceBadges(hostMember: boolean): Promise<SourceBadges> {
50
+ // Whatever goes wrong, the answer is "unavailable": this runs fire-and-forget at launch.
51
+ const read = unavailable(async (): Promise<SourceBadges> => {
52
+ if (!connectivity().online) return NO_SOURCE_BADGES;
53
+ const identity = await chatIdentity();
54
+ const member = identity.authenticated;
55
+ const stillHere = async <T>(count: Promise<T>): Promise<T> => {
56
+ const value = await count;
57
+ if (!(await sameShopper(identity))) throw SHOPPER_CHANGED;
58
+ return value;
59
+ };
60
+ const failed: SourceBadgeKey[] = [];
61
+ const attempt = async <T>(key: SourceBadgeKey, run: () => Promise<T>): Promise<T | null> => {
62
+ try { return await run(); } catch (error) { if (error !== SHOPPER_CHANGED) failed.push(key); return null; }
63
+ };
64
+ const [notifications, chat, cart] = await Promise.all([
65
+ member && hostMember ? attempt("notifications", () => stillHere(countUnseenNotifications())) : null,
66
+ member ? attempt("chat", () => unreadRoomCount(identity)) : null,
67
+ attempt("cart", () => stillHere(cartItemCount())),
68
+ ]);
69
+ return { notifications, chat, cart, failed };
70
+ });
71
+ return (await read) ?? NO_SOURCE_BADGES;
72
+ }