@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
@@ -0,0 +1,38 @@
1
+ import { get as appInfo } from "@himalaya/app-info";
2
+ import { attendanceCheckoutRoute, bookingAttendanceOf, ticketAttendanceOf } from "@himalaya/iap";
3
+
4
+ let knownPlatform: string | undefined;
5
+
6
+ export function attendancePlatform(onResolved?: (platform: string) => void): Promise<string> {
7
+ if (knownPlatform) return Promise.resolve(knownPlatform);
8
+ const info = appInfo().then((value) => value.platform, () => "unknown").then((platform) => {
9
+ if (platform !== "unknown") knownPlatform = platform;
10
+ return platform;
11
+ });
12
+ const host = globalThis as { setTimeout?: (fn: () => void, ms: number) => unknown; clearTimeout?: (timer: unknown) => void };
13
+ if (!host.setTimeout) {
14
+ void info.then((platform) => onResolved?.(platform));
15
+ return Promise.resolve("unknown");
16
+ }
17
+ return new Promise((resolve) => {
18
+ let timedOut = false;
19
+ const timer = host.setTimeout!(() => { timedOut = true; resolve("unknown"); }, 1500);
20
+ void info.then((platform) => { host.clearTimeout?.(timer); resolve(platform); if (timedOut) onResolved?.(platform); });
21
+ });
22
+ }
23
+
24
+ export async function mayUseRegularBookingCheckout(service: unknown): Promise<boolean> {
25
+ const metadata = bookingAttendanceOf(service);
26
+ if (metadata.priceType === "NO_FEE" || isZero(metadata.amount)) return true;
27
+ return attendanceCheckoutRoute(metadata, metadata.currency ?? "", await attendancePlatform()) === "regular";
28
+ }
29
+
30
+ export async function mayUseRegularTicketCheckout(event: unknown, ticket: { free?: boolean; price?: { amount?: string; currency?: string }; saleStatus?: string } | undefined): Promise<boolean> {
31
+ if (ticket?.free === true || isZero(ticket?.price?.amount)) return true;
32
+ const metadata = ticketAttendanceOf(event, { hidden: false, saleStatus: ticket?.saleStatus });
33
+ return attendanceCheckoutRoute(metadata, ticket?.price?.currency ?? "", await attendancePlatform()) === "regular";
34
+ }
35
+
36
+ function isZero(value: unknown): boolean {
37
+ return typeof value === "string" && /^0+(?:\.0+)?$/.test(value);
38
+ }
@@ -0,0 +1,127 @@
1
+ // Worker-side glue for the shared IAP layer (`@himalaya/iap` catalog pricing and
2
+ // `@himalaya/iap-checkout` → createIapCommerce), shared by every screen that shows or sells an
3
+ // IAP-backed item. Mapping, Apple prices, payment guards, the host scope and the sale live in the
4
+ // SDK; this only supplies the copy and the hydration reset.
5
+ import { hostSessionFromGlobal, type IapPriceCopy } from "@himalaya/iap";
6
+ import type { IapCommerce, IapPurchaseCopy, IapRestoreResult } from "@himalaya/iap-checkout";
7
+ import { paymentSetupMessage } from "./payment-setup.js";
8
+ import { copyParam, copyTemplate } from "./himi-copy.js";
9
+
10
+ /** Price labels from the screen's copy pack (`<prefix>.priceLoadingText`, …). */
11
+ export function iapPriceCopy(prefix: string): IapPriceCopy {
12
+ return {
13
+ loading: copyParam(`${prefix}.priceLoadingText`, "Loading price…"),
14
+ unavailable: copyParam(`${prefix}.priceUnavailableText`, "Price unavailable"),
15
+ oneTimePurchase: copyParam(`${prefix}.oneTimePurchaseLabel`, "One-time purchase"),
16
+ purchaseUnavailable: copyParam(`${prefix}.purchaseUnavailableText`, "Purchasing is not available yet."),
17
+ };
18
+ }
19
+
20
+ /** App Store purchase labels from the screen's copy pack (`<prefix>.buyCta`, …), for
21
+ * `iapPurchaseFields`. Customer copy only: no backend names, ids or diagnostics. */
22
+ export function iapPurchaseCopy(prefix: string): IapPurchaseCopy {
23
+ return {
24
+ buy: copyParam(`${prefix}.buyCta`, "Buy now"),
25
+ processing: copyParam(`${prefix}.purchaseProcessingText`, "Processing your purchase…"),
26
+ awaitingApproval: copyParam(`${prefix}.purchaseAwaitingApprovalText`, "Waiting for approval"),
27
+ unavailable: copyParam(`${prefix}.purchaseTemporarilyUnavailableText`, "Purchasing is temporarily unavailable."),
28
+ signInRequired: copyParam(`${prefix}.purchaseSignInText`, "Sign in to buy."),
29
+ sitePaymentUnavailable: paymentSetupMessage(prefix),
30
+ memberDetailsRequired: copyParam(`${prefix}.purchaseMemberDetailsText`, "Add your first name, last name and email to your profile, then try again."),
31
+ alreadySubscribed: copyParam(`${prefix}.purchaseAlreadySubscribedText`, "You already have a subscription in this app."),
32
+ retry: copyParam(`${prefix}.purchaseRetryText`, "Something went wrong. Try again."),
33
+ priceChanged: copyParam(`${prefix}.purchasePriceChangedText`, "The price changed. Check it and try again."),
34
+ support: copyParam(`${prefix}.purchaseSupportText`, "We couldn't finish this purchase. Contact support."),
35
+ };
36
+ }
37
+
38
+ /** The Restore purchases control (App Review 3.1.1) a screen binds. */
39
+ export interface IapRestoreFields {
40
+ restoreHidden: boolean;
41
+ restoreLabel: string;
42
+ restoreDisabled: boolean;
43
+ restoreMessage: string;
44
+ }
45
+
46
+ /** Keep these out of hydration: a restore's answer belongs to the run that got it. */
47
+ export const IAP_RESTORE_KEYS = ["restoreHidden", "restoreLabel", "restoreDisabled", "restoreMessage"] as const;
48
+
49
+ /** The control before the screen knows it sells through Apple. */
50
+ export const NO_IAP_RESTORE: IapRestoreFields = { restoreHidden: true, restoreLabel: "", restoreDisabled: false, restoreMessage: "" };
51
+
52
+ export interface IapRestoreControl {
53
+ /** `sellsThroughApple` is the screen's own signal: its item's App Store route, or Account's
54
+ * purchase readiness. */
55
+ fields(sellsThroughApple: boolean): IapRestoreFields;
56
+ /** Runs the shared `commerce.restore()`, repainting as it starts and when it answers. A tap while
57
+ * one runs is ignored. */
58
+ run(): Promise<void>;
59
+ }
60
+
61
+ /** Copy from the screen's pack (`<prefix>.restorePurchasesCta`, …). The restore itself, and the access
62
+ * re-read after it, are the shared commerce's. */
63
+ export function createIapRestore(
64
+ commerce: Pick<IapCommerce, "restore">,
65
+ options: { prefix: string; repaint(): void; /** The session generation; defaults to the host's. */ generation?: () => number },
66
+ ): IapRestoreControl {
67
+ const generation = options.generation ?? (() => hostSessionFromGlobal().current().generation);
68
+ let running = false;
69
+ let message = "";
70
+ let messageGeneration = -1;
71
+
72
+ function say(text: string, forGeneration: number): void {
73
+ message = text;
74
+ messageGeneration = forGeneration;
75
+ }
76
+
77
+ async function run(): Promise<void> {
78
+ if (running) return;
79
+ running = true;
80
+ const startedFor = generation();
81
+ say(copyParam(`${options.prefix}.restoringText`, "Restoring…"), startedFor);
82
+ options.repaint();
83
+ // Stamped with the session the tap was for: an answer landing after a sign-out is never shown.
84
+ say(restoreMessage(await restored(commerce), options.prefix), startedFor);
85
+ running = false;
86
+ options.repaint();
87
+ }
88
+
89
+ return {
90
+ fields: (sellsThroughApple) => ({
91
+ restoreHidden: !sellsThroughApple,
92
+ restoreLabel: copyParam(`${options.prefix}.restorePurchasesCta`, "Restore purchases"),
93
+ restoreDisabled: running,
94
+ // The answer was for the person signed in when it ran; another session never inherits it.
95
+ restoreMessage: sellsThroughApple && messageGeneration === generation() ? message : "",
96
+ }),
97
+ run,
98
+ };
99
+ }
100
+
101
+ function restored(commerce: Pick<IapCommerce, "restore">): Promise<IapRestoreResult> {
102
+ return commerce.restore().catch(() => ({ status: "failed", code: "storeUnavailable" }) as const);
103
+ }
104
+
105
+ function restoreMessage(result: IapRestoreResult, prefix: string): string {
106
+ if (result.status === "needsSignIn") return copyParam(`${prefix}.restoreSignInText`, "Sign in to restore your purchases.");
107
+ if (result.status === "failed") return result.code === "sessionChanged" ? "" : copyParam(`${prefix}.restoreFailedText`, "Couldn't reach the App Store. Try again.");
108
+ // Every part that happened is said: a recovery never hides a refusal or a purchase still pending.
109
+ const parts = [
110
+ result.recovered === 1 ? copyParam(`${prefix}.restoredOneText`, "Restored 1 purchase.") : "",
111
+ result.recovered > 1 ? copyTemplate(`${prefix}.restoredManyText`, "Restored {count} purchases.", { count: result.recovered }) : "",
112
+ // Held unfinished because Wix refused it (another member's purchase, say).
113
+ result.refused > 0 ? copyParam(`${prefix}.restoreRefusedText`, "A purchase on this Apple ID couldn't be added to this account. Contact support.") : "",
114
+ result.pending > 0 ? copyParam(`${prefix}.restorePendingText`, "A purchase is still being confirmed. Try again in a moment.") : "",
115
+ ].filter(Boolean);
116
+ return parts.length ? parts.join(" ") : copyParam(`${prefix}.restoreUpToDateText`, "Your purchases are up to date.");
117
+ }
118
+
119
+ /** What `notHydrated` does, for a runtime that ignores the option (a binary older than it, still
120
+ * served new bundles): put the listed keys back to their declared values before any action runs,
121
+ * so a persisted price or an enabled purchase action never paints as this run's. */
122
+ export function resetUnhydratedKeysOnOlderRuntime<S extends object>(svc: { getState(): S }, declared: S, keys: readonly (keyof S & string)[]): void {
123
+ if ((globalThis as { himalaya?: { hydrationOptOut?: unknown } }).himalaya?.hydrationOptOut === true) return;
124
+ const booted = svc.getState();
125
+ if (!booted || typeof booted !== "object") return;
126
+ for (const key of keys) booted[key] = declared[key];
127
+ }
@@ -0,0 +1,68 @@
1
+ // The member's Inbox rows: every chatroom the member-role chat list returns, business and member alike.
2
+ // Pure, so the worker and its tests share one classification of what a room is.
3
+
4
+ type RecordValue = Record<string, unknown>;
5
+ const object = (value: unknown): RecordValue =>
6
+ value !== null && typeof value === "object" && !Array.isArray(value) ? value as RecordValue : {};
7
+
8
+ /** The two-party room between the member and the business (the Smart Chat room). Another member's
9
+ * room has no `businessContext`, and a contact-less room is not the business's. */
10
+ export function isBusinessRoom(value: unknown): boolean {
11
+ const room = object(value);
12
+ return typeof room.id === "string" && !!room.id &&
13
+ typeof room.participantId === "string" && !!room.participantId &&
14
+ room.participantCount === 2 && room.clientReferenceType === "contactId" &&
15
+ Object.keys(object(room.businessContext)).length > 0;
16
+ }
17
+
18
+ export interface InboxRow {
19
+ id: string;
20
+ title: string;
21
+ subtitle: string;
22
+ /** The screen a tap opens: the business chat for the business room, a thread for any other. */
23
+ screenId: "himi_business_chat" | "himi_chat_thread";
24
+ /** `chatroom` makes the thread use `id` as the room instead of resolving it as a member id. */
25
+ kind: "chatroom" | "";
26
+ photo: string;
27
+ initial: string;
28
+ unread: boolean;
29
+ unreadDot: string;
30
+ /** Sort key only; not bound to the screen. */
31
+ at: number;
32
+ }
33
+
34
+ const text = (value: unknown): string => (typeof value === "string" ? value.trim() : "");
35
+
36
+ function titleOf(room: RecordValue, business: boolean): string {
37
+ const display = text(object(room.displayData).name);
38
+ if (business) return text(object(room.businessContext).name) || display;
39
+ return display;
40
+ }
41
+
42
+ /** Newest conversation first; archived rooms and rooms without an id are dropped. `fallbackTitle` names a
43
+ * room that carries no name (the caller passes the localised word, not a hard-coded English one). */
44
+ export function inboxRows(rooms: unknown[], fallbackTitle: string): InboxRow[] {
45
+ const rows: InboxRow[] = [];
46
+ for (const value of rooms) {
47
+ const room = object(value);
48
+ const id = text(room.id);
49
+ if (!id || room.isArchived === true) continue;
50
+ const business = isBusinessRoom(room);
51
+ const title = titleOf(room, business) || fallbackTitle;
52
+ const last = object(room.lastMessage);
53
+ const unread = typeof room.unreadCount === "number" && room.unreadCount > 0;
54
+ rows.push({
55
+ id,
56
+ title,
57
+ subtitle: text(last.summary),
58
+ screenId: business ? "himi_business_chat" : "himi_chat_thread",
59
+ kind: business ? "" : "chatroom",
60
+ photo: text(object(object(room.displayData).image).url),
61
+ initial: (title[0] ?? "#").toUpperCase(),
62
+ unread,
63
+ unreadDot: unread ? "●" : "",
64
+ at: typeof last.createdAt === "number" ? last.createdAt : typeof room.createdAt === "number" ? room.createdAt : 0,
65
+ });
66
+ }
67
+ return rows.sort((a, b) => b.at - a.at);
68
+ }
@@ -0,0 +1,38 @@
1
+ /** Small local preferences only; never entity records or credentials. The host
2
+ * overwrites these reserved input fields from its authenticated account/site.
3
+ * Older hosts and visitors deliberately stay session-only. */
4
+ export interface PreferenceStore {
5
+ getItem(key: string): string | null;
6
+ setItem(key: string, value: string): void;
7
+ }
8
+ export interface PreferenceRuntime { input?: Record<string, unknown>; storage?: PreferenceStore; }
9
+ export function localPreferences<T>(name: string, normalize: (value: unknown) => T, runtime?: PreferenceRuntime) {
10
+ const host = runtime ?? (globalThis as { himalaya?: PreferenceRuntime }).himalaya;
11
+ const account = host?.input?.__himiPreferenceAccount;
12
+ const business = host?.input?.__himiPreferenceBusiness;
13
+ const valid = (value: unknown): value is string => typeof value === 'string' && /^[A-Za-z0-9_.:-]{1,128}$/.test(value) && value !== 'default';
14
+ const key = valid(account) && valid(business) && host?.storage
15
+ ? `himi.preferences.v1.${account}.${encodeURIComponent(business)}.${name}` : '';
16
+ let available = !!key;
17
+ return {
18
+ get available() { return available; },
19
+ read(): T {
20
+ if (!key) return normalize(undefined);
21
+ try {
22
+ const raw = host!.storage!.getItem(key);
23
+ if (!raw || raw.length > 32768) return normalize(undefined);
24
+ const data = JSON.parse(raw);
25
+ return normalize(data?.version === 1 ? data.value : undefined);
26
+ } catch { available = false; return normalize(undefined); }
27
+ },
28
+ write(value: T): void {
29
+ if (!key) return;
30
+ try {
31
+ const raw = JSON.stringify({ version: 1, value: normalize(value) });
32
+ if (raw.length > 32768) { available = false; return; }
33
+ host!.storage!.setItem(key, raw);
34
+ available = host!.storage!.getItem(key) === raw;
35
+ } catch { available = false; }
36
+ },
37
+ };
38
+ }
@@ -0,0 +1,63 @@
1
+ import { dispatch } from "@himalaya/dispatch";
2
+ import { getMyData } from "@himalaya/wix-users";
3
+
4
+ export interface MemberAccess { email: string; scope: string; signedIn?: boolean; }
5
+ export function memberAccessChanged(): Error {
6
+ const error = new Error("Member access changed"); error.name = "MemberAccessChanged"; return error;
7
+ }
8
+ export async function memberAccess(options: { throwOnUnavailable?: boolean } = {}): Promise<MemberAccess> {
9
+ let email = "";
10
+ let signedIn = false;
11
+ let identityUnavailable = false;
12
+ try {
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;
15
+ const raw = value?.email ?? value?.payload?.email;
16
+ email = typeof raw === "string" ? raw.trim().toLowerCase() : "";
17
+ signedIn = (value?.signedIn ?? value?.payload?.signedIn) === true;
18
+ } catch { identityUnavailable = true; }
19
+ // Older native hosts predate the memberIdentity action but can still expose
20
+ // the authenticated profile through wix-users. Only a missing action uses
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.
23
+ if (!email && identityUnavailable) {
24
+ try {
25
+ const profile = await getMyData();
26
+ const raw = profile.email ?? profile.contactEmail;
27
+ email = typeof raw === "string" ? raw.trim().toLowerCase() : "";
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
+ }
35
+ }
36
+ const input = (globalThis as { himalaya?: { input?: Record<string, unknown> } }).himalaya?.input;
37
+ const account = input?.__himiPreferenceAccount, business = input?.__himiPreferenceBusiness;
38
+ const valid = (v: unknown): v is string => typeof v === "string" && /^[A-Za-z0-9_.:-]{1,128}$/.test(v) && v !== "default";
39
+ // These fields are overwritten by authenticated hosts. Older binaries stay online-only.
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]) : "" };
42
+ }
43
+ export async function assertMemberAccess(member: MemberAccess): Promise<void> {
44
+ const current = await memberAccess();
45
+ if (!member.email || current.email !== member.email || current.scope !== member.scope) throw memberAccessChanged();
46
+ }
47
+ export function memberAccessDenied(error: unknown): boolean {
48
+ return (error as { name?: string } | null)?.name === "MemberAccessChanged" || /(?:HTTP\s*(?:401|403)|READ_ORDER_FORBIDDEN|permission denied|forbidden)/i.test(String(error));
49
+ }
50
+
51
+ /** Did this write fail because the member changed (signed out, or another account)? Then
52
+ * the screen reloads for whoever is signed in now. A 401/403 for the SAME member is only a
53
+ * failed write: the caller keeps what the member typed and says so. */
54
+ export async function memberChanged(member: MemberAccess | undefined, error: unknown): Promise<boolean> {
55
+ if ((error as { name?: string } | null)?.name === "MemberAccessChanged") return true;
56
+ if (!member || !memberAccessDenied(error)) return false;
57
+ try {
58
+ await assertMemberAccess(member);
59
+ return false;
60
+ } catch {
61
+ return true;
62
+ }
63
+ }
@@ -0,0 +1,52 @@
1
+ // Can this host reach the member account routes My Addresses and My Wallet need?
2
+ //
3
+ // Both are served OFF www.wixapis.com (the address book on ecom.wix.com, saved cards on
4
+ // the member's own site), so only a native runtime whose WixApiCapability pins them can
5
+ // call them: HimalayaCore 1.4.0 and later. The web bridges refuse absolute URLs, and a
6
+ // hosted app (Spaces) signs its calls with a capability pinned to www.wixapis.com. Saved
7
+ // cards also need the shell to have bound its own site (app_info `memberSiteBound`): a
8
+ // multi-app host such as Himi Player binds none, so its wallet route has no host. The
9
+ // Account screen hides a link whose route is unreachable, and the screen says so instead
10
+ // of failing a load.
11
+ import { get as getAppInfo } from "@himalaya/app-info";
12
+ import { isHostedWorker } from "./hosted-checkout.js";
13
+
14
+ /** The HimalayaCore version whose WixApiCapability pins these routes. Checked here, at run
15
+ * time: the screens declare no `minBinaryVersion`, because a release takes its highest
16
+ * screen floor as its own and would then refuse every older binary. */
17
+ export const MEMBER_ACCOUNT_ROUTES_MIN_BINARY = "1.4.0";
18
+ export const MEMBER_MEDIA_FIELD_MIN_BINARY = "1.5.0";
19
+ export const MEMBER_PASSWORD_ACTIONS_MIN_BINARY = "1.5.0";
20
+
21
+ /** `version` (a HimalayaCore binary version, pre-release suffix ignored) is `floor` or later. */
22
+ export function atLeast(version: string, floor: string): boolean {
23
+ const parts = (v: string) => v.split("-")[0].split(".").map((p) => Number.parseInt(p, 10) || 0);
24
+ const a = parts(version), b = parts(floor);
25
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
26
+ const x = a[i] ?? 0, y = b[i] ?? 0;
27
+ if (x !== y) return x > y;
28
+ }
29
+ return true;
30
+ }
31
+
32
+ export interface MemberAccountRoutes {
33
+ /** The address book on ecom.wix.com (My Addresses). */
34
+ addresses: boolean;
35
+ /** Saved cards on the member's own site (My Wallet). */
36
+ wallet: boolean;
37
+ /** Native MediaField image picking and presigned PUT support. */
38
+ mediaField: boolean;
39
+ /** Password credential actions introduced in HimalayaCore 1.5.0. */
40
+ passwordCredentials: boolean;
41
+ }
42
+
43
+ export async function memberAccountRoutes(): Promise<MemberAccountRoutes> {
44
+ if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false };
45
+ const info = await getAppInfo().catch(() => undefined);
46
+ if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false };
47
+ const native = info.platform === "ios" || info.platform === "android" || info.platform === "macos";
48
+ const addresses = native && atLeast(info.binaryVersion ?? "", MEMBER_ACCOUNT_ROUTES_MIN_BINARY);
49
+ const mediaField = native && atLeast(info.binaryVersion ?? "", MEMBER_MEDIA_FIELD_MIN_BINARY);
50
+ const passwordCredentials = native && atLeast(info.binaryVersion ?? "", MEMBER_PASSWORD_ACTIONS_MIN_BINARY);
51
+ return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials };
52
+ }
@@ -0,0 +1,107 @@
1
+ import { queryBookings, type WixBooking } from "@himalaya/wix-bookings";
2
+ import { memberAccess, assertMemberAccess, type MemberAccess } from "./member-access.js";
3
+ import { offsetPage } from "./offset-page.js";
4
+ import type { CollectionQuery } from "./collection-query.js";
5
+ import { copyParam } from "./himi-copy.js";
6
+ import { formatWeekdayDateTime } from "./engine-intl.js";
7
+ import { dayKey } from "@himalaya/time";
8
+
9
+ /** The statuses that put a booking in the Canceled tab. Upcoming and Past exclude them, so each
10
+ * booking is in exactly one tab. */
11
+ export const CANCELLED_STATUSES = ["CANCELED", "CANCELLED", "DECLINED"];
12
+
13
+ /** Wix made the booking, but no checkout confirmed it: a paid booking the member did not pay
14
+ * for, or left in the payment page, stays here. It holds no place and the business does not
15
+ * see it in its booking calendar, so it is not an appointment. */
16
+ export const UNCONFIRMED_STATUSES = ["CREATED"];
17
+
18
+ export interface FetchMemberBookingsOptions {
19
+ /** Keep the unconfirmed bookings (`UNCONFIRMED_STATUSES`). Only a list that marks them as
20
+ * not confirmed may ask for them; Home and every count leave them out. */
21
+ includeUnconfirmed?: boolean;
22
+ }
23
+
24
+ export interface MemberBookingRow {
25
+ id: string; title: string; subtitle: string; status: string; revision: string;
26
+ start: string; end: string; day: string; serviceId: string;
27
+ canCancel: boolean; cannotCancel: boolean; cannotRebook: boolean;
28
+ // Added for the My Bookings redesign. Each is "" / 0 / false when the record has nothing for it.
29
+ /** The staff member (the slot's resource), "" when the booking names none. */
30
+ staff: string;
31
+ /** The location's name, else its address. */
32
+ placeName: string;
33
+ /** The location's formatted address. */
34
+ placeAddress: string;
35
+ /** `BUSINESS`, `CUSTOM` or `CUSTOMER` (the client's place), upper case. */
36
+ placeType: string;
37
+ participants: number;
38
+ /** Wix's raw payment status, upper case (`PAID`, `NOT_PAID`, …). */
39
+ paymentStatus: string;
40
+ /** Wix's raw booking status, upper case (`CONFIRMED`, `WAITING_LIST`, …). */
41
+ statusKey: string;
42
+ /** A course booking: it books a schedule, not a slot. */
43
+ isCourse: boolean;
44
+ courseStart: string;
45
+ courseEnd: string;
46
+ }
47
+ export function bookingStart(booking: WixBooking): string {
48
+ // Top-level instants are UTC. Slot dates may be LOCAL to slot.timezone.
49
+ const value = booking.startDate || booking.bookedEntity?.slot?.startDate || "";
50
+ return /(?:Z|[+-]\d{2}:?\d{2})$/i.test(value) && Number.isFinite(Date.parse(value)) ? value : "";
51
+ }
52
+ const instant = (value: unknown): string =>
53
+ typeof value === "string" && /(?:Z|[+-]\d{2}:?\d{2})$/i.test(value) && Number.isFinite(Date.parse(value)) ? value : "";
54
+ const word = (value: unknown): string => typeof value === "string" ? value.trim() : "";
55
+ export function memberBookingRow(booking: WixBooking): MemberBookingRow {
56
+ const start = bookingStart(booking);
57
+ const entity = booking.bookedEntity;
58
+ const slot = entity?.slot, schedule = entity?.schedule;
59
+ const status = (booking.status || "").toUpperCase();
60
+ const revision = String((booking as WixBooking & { revision?: string | number }).revision ?? "");
61
+ // A course booking carries a schedule, not a slot: its service id is on the schedule.
62
+ const serviceId = slot?.serviceId || schedule?.serviceId || "";
63
+ const canCancel = !!booking.id && !!revision && Date.parse(start) > Date.now() && !CANCELLED_STATUSES.includes(status);
64
+ const location = slot?.location ?? schedule?.location;
65
+ const placeAddress = word(location?.formattedAddress);
66
+ const participants = Number(booking.totalParticipants);
67
+ return { id: booking.id, title: entity?.title || copyParam("bookings.booking", "Booking"),
68
+ subtitle: start ? formatWeekdayDateTime(new Date(start)) : copyParam("bookings.timeUnavailable", "Time unavailable"),
69
+ status: status.replace(/_/g, " "), revision, start,
70
+ // Wix may carry the end only on the slot (same instant rule as the start).
71
+ end: booking.endDate || instant(slot?.endDate), day: start ? dayKey(new Date(start)) : "",
72
+ serviceId, canCancel, cannotCancel: !canCancel, cannotRebook: !serviceId,
73
+ staff: word(slot?.resource?.name),
74
+ placeName: word(location?.name) || placeAddress,
75
+ placeAddress,
76
+ placeType: word(location?.locationType).toUpperCase(),
77
+ participants: Number.isFinite(participants) && participants > 0 ? Math.floor(participants) : 0,
78
+ paymentStatus: word(booking.paymentStatus).toUpperCase(),
79
+ statusKey: status,
80
+ isCourse: !slot && !!schedule,
81
+ courseStart: instant(schedule?.firstSessionStart),
82
+ courseEnd: instant(schedule?.lastSessionEnd) };
83
+ }
84
+ export async function fetchMemberBookings(criteria: CollectionQuery, cursor: string, now: string, expected?: MemberAccess, options: FetchMemberBookingsOptions = {}) {
85
+ const member = expected ?? await memberAccess();
86
+ const metadata = { email: member.email, scope: member.scope, needsSignIn: !member.email };
87
+ if (!member.email) return { items: [] as MemberBookingRow[], nextCursor: "", metadata };
88
+ await assertMemberAccess(member);
89
+ if (criteria.filter === "saved" && !criteria.savedIds.length) return { items: [] as MemberBookingRow[], nextCursor: "", metadata };
90
+ const filter: Record<string, unknown> = { "contactDetails.email": { $eq: member.email } };
91
+ if (criteria.query) filter.id = { $eq: criteria.query };
92
+ if (criteria.filter === "saved") filter.id = criteria.query ? { $in: criteria.savedIds.filter(id => id === criteria.query) } : { $in: criteria.savedIds };
93
+ const notListed = options.includeUnconfirmed ? CANCELLED_STATUSES : [...CANCELLED_STATUSES, ...UNCONFIRMED_STATUSES];
94
+ if (criteria.filter === "value:Upcoming") { filter.startDate = { $gte: now }; filter.status = { $nin: notListed }; }
95
+ // Past is what took place: a canceled or declined booking is in the Canceled tab only.
96
+ if (criteria.filter === "value:Past") { filter.startDate = { $lt: now }; filter.status = { $nin: notListed }; }
97
+ if (criteria.filter === "value:Cancelled") filter.status = { $in: CANCELLED_STATUSES };
98
+ const response = await queryBookings({ query: { filter, paging: { limit: 50, offset: Number(cursor || 0) },
99
+ sort: [{ fieldName: "startDate", order: criteria.sort === "za" ? "DESC" : "ASC" }, { fieldName: "id", order: "ASC" }] } });
100
+ await assertMemberAccess(member);
101
+ const raw = response.bookings ?? [];
102
+ // Server authorization remains authoritative. This guard also rejects a
103
+ // malformed/cross-member row before any UI projection. No private disk cache.
104
+ const items = raw.filter(booking => booking.id && booking.contactDetails?.email?.trim().toLowerCase() === member.email).map(memberBookingRow)
105
+ .filter(row => options.includeUnconfirmed || !UNCONFIRMED_STATUSES.includes(row.statusKey));
106
+ return { items, ...offsetPage(cursor, raw.length, 50, response.pagingMetadata), metadata };
107
+ }
@@ -0,0 +1,99 @@
1
+ // "Open a member-only screen" (the business chat): a member goes there; a guest gets the app's
2
+ // sign-in first, never the screen's own guest prompt, and the screen opens once signed in
3
+ // (himi-store-account resumes `returnScreenId`). Salon & Spa offers it from Home and from the
4
+ // shared booking screens (a treatment that cannot be booked online, a Choose a Time with no times),
5
+ // so each of those workers runs the same rule.
6
+ //
7
+ // The tap's params:
8
+ // screenId the member screen
9
+ // signInScreenId the app's sign-in screen; without it the tap opens `screenId` as is
10
+ // signInPresentation "sheet" | "full_screen": the sign-in opens as that modal, and once signed
11
+ // in it closes and opens the screen on `returnTab`. Pushed (no presentation),
12
+ // the sign-in pushes the screen itself.
13
+ // returnTab the tab the screen opens on after a modal sign-in
14
+ //
15
+ // A modal sign-in also carries a host-held continuation (`authContinuation`, begun here for
16
+ // `memberScreenTarget(screenId)`). Where the account change of the sign-in replaces the sign-in
17
+ // worker before it can resume (Android), the replacement consumes it to open the screen, once.
18
+ // A route alone never opens a member screen; old hosts without the contract keep the plain sheet.
19
+ import { dispatch } from "@himalaya/dispatch";
20
+ import type { NavDirective } from "@himalaya/state";
21
+ import { signedInEmail } from "./himi-account.js";
22
+
23
+ /** How long a continuation call may take before the worker goes on without it. Just above the web
24
+ * host's own 4 s identity-read deadline (identityReader.ts), which it runs before answering: a host
25
+ * that answers is never cut off, and one that never answers cannot hold the sheet or the form. */
26
+ export const CONTINUATION_BUDGET_MS = 4_500;
27
+ /** The whole tap (session read, then begin) waits at most this long. On the web host each call runs
28
+ * its own identity read, so a hung host would otherwise cost two full deadlines (~8 s) before the
29
+ * sheet. The session read may use the host's whole deadline; begin then gets what is left, but at
30
+ * least an ordinary read's 1.5 s, so a slow host (2.5 s a read) still hands out the token. */
31
+ const TAP_BUDGET_MS = CONTINUATION_BUDGET_MS + 1_500;
32
+ const MIN_BEGIN_MS = 1_500;
33
+
34
+ /** The continuation target for a member screen, shared with himi-store-account. */
35
+ export const memberScreenTarget = (screenId: string): string => `member_screen:${screenId}`;
36
+
37
+ /** A host-held continuation for `screenId`, or "" (an old host, or a member already). */
38
+ async function beginContinuation(screenId: string): Promise<string> {
39
+ try {
40
+ const value = await dispatch("himi.wix.authContinuation", { operation: "begin", target: memberScreenTarget(screenId) }) as
41
+ { supported?: unknown; token?: unknown; payload?: { supported?: unknown; token?: unknown } } | null;
42
+ const fields = value?.payload ?? value;
43
+ return fields?.supported === true && typeof fields.token === "string" ? fields.token : "";
44
+ } catch {
45
+ return "";
46
+ }
47
+ }
48
+
49
+ const strField = (arg: unknown, key: string): string => {
50
+ const value = (arg as Record<string, unknown> | undefined)?.[key];
51
+ return typeof value === "string" ? value : "";
52
+ };
53
+
54
+ /** `read`, or `fallback` once `ms` pass, where the engine has a timer. A bare JSContext has no
55
+ * timer; there it waits, as every read does. `read` must not reject. */
56
+ export function within<T>(read: Promise<T>, ms: number, fallback: T): Promise<T> {
57
+ const host = globalThis as { setTimeout?: (fn: () => void, ms: number) => unknown; clearTimeout?: (timer: unknown) => void };
58
+ if (typeof host.setTimeout !== "function") return read;
59
+ return new Promise<T>((resolve) => {
60
+ const timer = host.setTimeout!(() => resolve(fallback), ms);
61
+ void read.then((value) => { host.clearTimeout?.(timer); resolve(value); });
62
+ });
63
+ }
64
+
65
+ /** Where a tap goes, given the session's email ("" for a guest). null: no screen named. */
66
+ export function memberScreenNav(arg: unknown, email: string): NavDirective | null {
67
+ const screenId = strField(arg, "screenId"), signInScreenId = strField(arg, "signInScreenId");
68
+ if (!screenId) return null;
69
+ if (!signInScreenId || email) return { screenId };
70
+ const args: Record<string, string> = { mode: "signin", returnScreenId: screenId };
71
+ const presentation = strField(arg, "signInPresentation");
72
+ if (presentation !== "sheet" && presentation !== "full_screen") return { screenId: signInScreenId, args };
73
+ if (strField(arg, "returnTab")) args.returnTab = strField(arg, "returnTab");
74
+ return { screenId: signInScreenId, presentation, args: { ...args, modal: "1" } };
75
+ }
76
+
77
+ /** One worker's opener. The session is asked at the tap, never read from the last load; a read
78
+ * that never answers counts as a guest, so the tap opens the sign-in rather than nothing. Only the
79
+ * newest tap navigates (no second sheet, no sheet over the screen): an older one answers null. */
80
+ // The session read has the continuation calls' budget: on the web host they all wait on the same
81
+ // identity read, so a shorter cutoff here would take a slow member for a guest and flash the sheet.
82
+ export function memberScreenOpener(readEmail: () => Promise<string> = () => within(signedInEmail(), CONTINUATION_BUDGET_MS, "")): (arg: unknown) => Promise<NavDirective | null> {
83
+ let taps = 0;
84
+ return async (arg) => {
85
+ if (!strField(arg, "screenId")) return null;
86
+ const mine = ++taps;
87
+ const tapped = Date.now();
88
+ const email = strField(arg, "signInScreenId") ? await readEmail() : "";
89
+ if (mine !== taps) return null;
90
+ const nav = memberScreenNav(arg, email);
91
+ if (!nav || !("presentation" in nav) || !nav.args?.modal) return nav;
92
+ // Bounded by what the tap has left (TAP_BUDGET_MS): a host that never answers still opens the
93
+ // plain sheet.
94
+ const left = Math.min(CONTINUATION_BUDGET_MS, Math.max(MIN_BEGIN_MS, TAP_BUDGET_MS - (Date.now() - tapped)));
95
+ const token = await within(beginContinuation(strField(arg, "screenId")), left, "");
96
+ if (mine !== taps) return null;
97
+ return token ? { ...nav, args: { ...nav.args, authContinuation: token } } : nav;
98
+ };
99
+ }