@wix/himalaya-cli 0.1870.0 → 0.1872.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 (497) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +3 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/portfolio/src/index.d.ts +19 -0
  3. package/dist/cli.mjs +90 -39
  4. package/fixtures/wix-canned.json +8 -0
  5. package/guides/android-ux.md +3 -2
  6. package/guides/designing-himi-screens.md +10 -4
  7. package/guides/ios-ux.md +3 -2
  8. package/guides/release-notes.md +18 -0
  9. package/guides/sdk-reference.json +8 -1
  10. package/package.json +2 -2
  11. package/template-icons/professional-services.png +0 -0
  12. package/templates/bare-fashion/config.ts +37 -2
  13. package/templates/bare-fashion/dev/index.ts +4006 -48
  14. package/templates/bare-fashion/himalaya.content.json +15 -0
  15. package/templates/bare-fashion/tier5-src/_shared/collection-contract.ts +6 -1
  16. package/templates/bare-fashion/tier5-src/_shared/member-account-routes.ts +56 -0
  17. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  18. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  19. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  20. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  21. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  22. package/templates/bare-fashion/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  23. package/templates/beauty-salon/tier5-src/_shared/collection-contract.ts +6 -1
  24. package/templates/beauty-salon/tier5-src/_shared/himi-events.ts +27 -0
  25. package/templates/beauty-salon-owner/tier5-src/_shared/collection-contract.ts +6 -1
  26. package/templates/beauty-salon-owner/tier5-src/_shared/himi-events.ts +27 -0
  27. package/templates/branded-lite/dev/index.ts +22 -1
  28. package/templates/branded-lite/l10n/ar.json +10 -0
  29. package/templates/branded-lite/l10n/cs.json +10 -0
  30. package/templates/branded-lite/l10n/da.json +10 -0
  31. package/templates/branded-lite/l10n/de.json +10 -0
  32. package/templates/branded-lite/l10n/el.json +10 -0
  33. package/templates/branded-lite/l10n/es.json +10 -0
  34. package/templates/branded-lite/l10n/fi.json +10 -0
  35. package/templates/branded-lite/l10n/fr.json +10 -0
  36. package/templates/branded-lite/l10n/he.json +8 -0
  37. package/templates/branded-lite/l10n/hu.json +10 -0
  38. package/templates/branded-lite/l10n/id.json +10 -0
  39. package/templates/branded-lite/l10n/it.json +10 -0
  40. package/templates/branded-lite/l10n/ja.json +10 -0
  41. package/templates/branded-lite/l10n/ko.json +10 -0
  42. package/templates/branded-lite/l10n/lt.json +10 -0
  43. package/templates/branded-lite/l10n/nl.json +10 -0
  44. package/templates/branded-lite/l10n/no.json +10 -0
  45. package/templates/branded-lite/l10n/pl.json +10 -0
  46. package/templates/branded-lite/l10n/pt.json +10 -0
  47. package/templates/branded-lite/l10n/ru.json +10 -0
  48. package/templates/branded-lite/l10n/sv.json +10 -0
  49. package/templates/branded-lite/l10n/th.json +10 -0
  50. package/templates/branded-lite/l10n/tr.json +10 -0
  51. package/templates/branded-lite/l10n/uk.json +10 -0
  52. package/templates/branded-lite/l10n/vi.json +10 -0
  53. package/templates/branded-lite/l10n/zh.json +10 -0
  54. package/templates/branded-lite/tier5-src/_shared/collection-contract.ts +6 -1
  55. package/templates/branded-lite/tier5-src/_shared/himi-events.ts +27 -0
  56. package/templates/branded-lite/tier5-src/_shared/portfolio-details.ts +70 -0
  57. package/templates/branded-lite/tier5-src/himi-branded-lite-coupons/index.ts +13 -2
  58. package/templates/branded-lite/tier5-src/himi-branded-lite-portfolio/index.ts +90 -9
  59. package/templates/branded-lite/tier5-src/himi-branded-lite-portfolio-project/index.ts +53 -4
  60. package/templates/branded-lite/tier5-src/himi-events-detail/index.ts +3 -1
  61. package/templates/branded-lite/tier5-src/himi-events-list/index.ts +38 -8
  62. package/templates/branded-lite/tier5-src/himi-events-my-events/index.ts +4 -2
  63. package/templates/brandy/tier5-src/_shared/collection-contract.ts +6 -1
  64. package/templates/community-club/dev/index.ts +20 -0
  65. package/templates/community-club/l10n/ar.json +10 -0
  66. package/templates/community-club/l10n/cs.json +10 -0
  67. package/templates/community-club/l10n/da.json +10 -0
  68. package/templates/community-club/l10n/de.json +10 -0
  69. package/templates/community-club/l10n/el.json +10 -0
  70. package/templates/community-club/l10n/es.json +10 -0
  71. package/templates/community-club/l10n/fi.json +10 -0
  72. package/templates/community-club/l10n/fr.json +10 -0
  73. package/templates/community-club/l10n/he.json +8 -0
  74. package/templates/community-club/l10n/hu.json +10 -0
  75. package/templates/community-club/l10n/id.json +10 -0
  76. package/templates/community-club/l10n/it.json +10 -0
  77. package/templates/community-club/l10n/ja.json +10 -0
  78. package/templates/community-club/l10n/ko.json +10 -0
  79. package/templates/community-club/l10n/lt.json +10 -0
  80. package/templates/community-club/l10n/nl.json +10 -0
  81. package/templates/community-club/l10n/no.json +10 -0
  82. package/templates/community-club/l10n/pl.json +10 -0
  83. package/templates/community-club/l10n/pt.json +10 -0
  84. package/templates/community-club/l10n/ru.json +10 -0
  85. package/templates/community-club/l10n/sv.json +10 -0
  86. package/templates/community-club/l10n/th.json +10 -0
  87. package/templates/community-club/l10n/tr.json +10 -0
  88. package/templates/community-club/l10n/uk.json +10 -0
  89. package/templates/community-club/l10n/vi.json +10 -0
  90. package/templates/community-club/l10n/zh.json +10 -0
  91. package/templates/community-club/tier5-src/_shared/collection-contract.ts +6 -1
  92. package/templates/community-club/tier5-src/_shared/himi-events.ts +27 -0
  93. package/templates/community-club/tier5-src/himi-events-detail/index.ts +3 -1
  94. package/templates/community-club/tier5-src/himi-events-list/index.ts +38 -8
  95. package/templates/community-club/tier5-src/himi-events-my-events/index.ts +4 -2
  96. package/templates/community-club-owner/tier5-src/_shared/collection-contract.ts +6 -1
  97. package/templates/community-club-owner/tier5-src/_shared/himi-events.ts +27 -0
  98. package/templates/conference/config.ts +43 -1
  99. package/templates/conference/dev/index.ts +4147 -0
  100. package/templates/conference/himalaya.content.json +18 -0
  101. package/templates/conference/tier5-src/_shared/collection-contract.ts +6 -1
  102. package/templates/conference/tier5-src/_shared/himi-events.ts +27 -0
  103. package/templates/conference/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  104. package/templates/conference/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  105. package/templates/conference/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  106. package/templates/conference/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  107. package/templates/conference/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  108. package/templates/conference/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  109. package/templates/conference/tier5-src/himi-events-detail/index.ts +3 -1
  110. package/templates/conference/tier5-src/himi-events-list/index.ts +38 -8
  111. package/templates/conference/tier5-src/himi-events-my-events/index.ts +4 -2
  112. package/templates/conference/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  113. package/templates/events-meetups/dev/index.ts +20 -0
  114. package/templates/events-meetups/l10n/ar.json +10 -0
  115. package/templates/events-meetups/l10n/cs.json +10 -0
  116. package/templates/events-meetups/l10n/da.json +10 -0
  117. package/templates/events-meetups/l10n/de.json +10 -0
  118. package/templates/events-meetups/l10n/el.json +10 -0
  119. package/templates/events-meetups/l10n/es.json +10 -0
  120. package/templates/events-meetups/l10n/fi.json +10 -0
  121. package/templates/events-meetups/l10n/fr.json +10 -0
  122. package/templates/events-meetups/l10n/he.json +8 -0
  123. package/templates/events-meetups/l10n/hu.json +10 -0
  124. package/templates/events-meetups/l10n/id.json +10 -0
  125. package/templates/events-meetups/l10n/it.json +10 -0
  126. package/templates/events-meetups/l10n/ja.json +10 -0
  127. package/templates/events-meetups/l10n/ko.json +10 -0
  128. package/templates/events-meetups/l10n/lt.json +10 -0
  129. package/templates/events-meetups/l10n/nl.json +10 -0
  130. package/templates/events-meetups/l10n/no.json +10 -0
  131. package/templates/events-meetups/l10n/pl.json +10 -0
  132. package/templates/events-meetups/l10n/pt.json +10 -0
  133. package/templates/events-meetups/l10n/ru.json +10 -0
  134. package/templates/events-meetups/l10n/sv.json +10 -0
  135. package/templates/events-meetups/l10n/th.json +10 -0
  136. package/templates/events-meetups/l10n/tr.json +10 -0
  137. package/templates/events-meetups/l10n/uk.json +10 -0
  138. package/templates/events-meetups/l10n/vi.json +10 -0
  139. package/templates/events-meetups/l10n/zh.json +10 -0
  140. package/templates/events-meetups/tier5-src/_shared/collection-contract.ts +6 -1
  141. package/templates/events-meetups/tier5-src/_shared/himi-events.ts +27 -0
  142. package/templates/events-meetups/tier5-src/himi-events-detail/index.ts +3 -1
  143. package/templates/events-meetups/tier5-src/himi-events-list/index.ts +38 -8
  144. package/templates/events-meetups/tier5-src/himi-events-my-events/index.ts +4 -2
  145. package/templates/events-meetups-owner/tier5-src/_shared/collection-contract.ts +6 -1
  146. package/templates/events-meetups-owner/tier5-src/_shared/himi-events.ts +27 -0
  147. package/templates/fitness-gym/tier5-src/_shared/collection-contract.ts +6 -1
  148. package/templates/gym-fitness/dev/index.ts +20 -0
  149. package/templates/gym-fitness/l10n/ar.json +10 -0
  150. package/templates/gym-fitness/l10n/cs.json +10 -0
  151. package/templates/gym-fitness/l10n/da.json +10 -0
  152. package/templates/gym-fitness/l10n/de.json +10 -0
  153. package/templates/gym-fitness/l10n/el.json +10 -0
  154. package/templates/gym-fitness/l10n/es.json +10 -0
  155. package/templates/gym-fitness/l10n/fi.json +10 -0
  156. package/templates/gym-fitness/l10n/fr.json +10 -0
  157. package/templates/gym-fitness/l10n/he.json +8 -0
  158. package/templates/gym-fitness/l10n/hu.json +10 -0
  159. package/templates/gym-fitness/l10n/id.json +10 -0
  160. package/templates/gym-fitness/l10n/it.json +10 -0
  161. package/templates/gym-fitness/l10n/ja.json +10 -0
  162. package/templates/gym-fitness/l10n/ko.json +10 -0
  163. package/templates/gym-fitness/l10n/lt.json +10 -0
  164. package/templates/gym-fitness/l10n/nl.json +10 -0
  165. package/templates/gym-fitness/l10n/no.json +10 -0
  166. package/templates/gym-fitness/l10n/pl.json +10 -0
  167. package/templates/gym-fitness/l10n/pt.json +10 -0
  168. package/templates/gym-fitness/l10n/ru.json +10 -0
  169. package/templates/gym-fitness/l10n/sv.json +10 -0
  170. package/templates/gym-fitness/l10n/th.json +10 -0
  171. package/templates/gym-fitness/l10n/tr.json +10 -0
  172. package/templates/gym-fitness/l10n/uk.json +10 -0
  173. package/templates/gym-fitness/l10n/vi.json +10 -0
  174. package/templates/gym-fitness/l10n/zh.json +10 -0
  175. package/templates/gym-fitness/tier5-src/_shared/collection-contract.ts +6 -1
  176. package/templates/gym-fitness/tier5-src/_shared/himi-events.ts +27 -0
  177. package/templates/gym-fitness/tier5-src/himi-events-detail/index.ts +3 -1
  178. package/templates/gym-fitness/tier5-src/himi-events-list/index.ts +38 -8
  179. package/templates/gym-fitness/tier5-src/himi-events-my-events/index.ts +4 -2
  180. package/templates/gym-fitness-owner/tier5-src/_shared/collection-contract.ts +6 -1
  181. package/templates/gym-fitness-owner/tier5-src/_shared/himi-events.ts +27 -0
  182. package/templates/medical-services/config.ts +42 -0
  183. package/templates/medical-services/dev/index.ts +4136 -0
  184. package/templates/medical-services/himalaya.content.json +18 -0
  185. package/templates/medical-services/tier5-src/_shared/collection-contract.ts +6 -1
  186. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  187. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  188. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  189. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  190. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  191. package/templates/medical-services/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  192. package/templates/medical-services/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  193. package/templates/nonprofit-cause/dev/index.ts +20 -0
  194. package/templates/nonprofit-cause/l10n/ar.json +10 -0
  195. package/templates/nonprofit-cause/l10n/cs.json +10 -0
  196. package/templates/nonprofit-cause/l10n/da.json +10 -0
  197. package/templates/nonprofit-cause/l10n/de.json +10 -0
  198. package/templates/nonprofit-cause/l10n/el.json +10 -0
  199. package/templates/nonprofit-cause/l10n/es.json +10 -0
  200. package/templates/nonprofit-cause/l10n/fi.json +10 -0
  201. package/templates/nonprofit-cause/l10n/fr.json +10 -0
  202. package/templates/nonprofit-cause/l10n/he.json +8 -0
  203. package/templates/nonprofit-cause/l10n/hu.json +10 -0
  204. package/templates/nonprofit-cause/l10n/id.json +10 -0
  205. package/templates/nonprofit-cause/l10n/it.json +10 -0
  206. package/templates/nonprofit-cause/l10n/ja.json +10 -0
  207. package/templates/nonprofit-cause/l10n/ko.json +10 -0
  208. package/templates/nonprofit-cause/l10n/lt.json +10 -0
  209. package/templates/nonprofit-cause/l10n/nl.json +10 -0
  210. package/templates/nonprofit-cause/l10n/no.json +10 -0
  211. package/templates/nonprofit-cause/l10n/pl.json +10 -0
  212. package/templates/nonprofit-cause/l10n/pt.json +10 -0
  213. package/templates/nonprofit-cause/l10n/ru.json +10 -0
  214. package/templates/nonprofit-cause/l10n/sv.json +10 -0
  215. package/templates/nonprofit-cause/l10n/th.json +10 -0
  216. package/templates/nonprofit-cause/l10n/tr.json +10 -0
  217. package/templates/nonprofit-cause/l10n/uk.json +10 -0
  218. package/templates/nonprofit-cause/l10n/vi.json +10 -0
  219. package/templates/nonprofit-cause/l10n/zh.json +10 -0
  220. package/templates/nonprofit-cause/tier5-src/_shared/collection-contract.ts +6 -1
  221. package/templates/nonprofit-cause/tier5-src/_shared/himi-events.ts +27 -0
  222. package/templates/nonprofit-cause/tier5-src/himi-events-detail/index.ts +3 -1
  223. package/templates/nonprofit-cause/tier5-src/himi-events-list/index.ts +38 -8
  224. package/templates/nonprofit-cause/tier5-src/himi-events-my-events/index.ts +4 -2
  225. package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-contract.ts +6 -1
  226. package/templates/nonprofit-cause-owner/tier5-src/_shared/himi-events.ts +27 -0
  227. package/templates/owner-lite/tier5-src/_shared/collection-contract.ts +6 -1
  228. package/templates/owner-lite/tier5-src/_shared/himi-events.ts +27 -0
  229. package/templates/personal-fitness-trainer/tier5-src/_shared/collection-contract.ts +6 -1
  230. package/templates/podcast-creator/dev/index.ts +20 -0
  231. package/templates/podcast-creator/l10n/ar.json +10 -0
  232. package/templates/podcast-creator/l10n/cs.json +10 -0
  233. package/templates/podcast-creator/l10n/da.json +10 -0
  234. package/templates/podcast-creator/l10n/de.json +10 -0
  235. package/templates/podcast-creator/l10n/el.json +10 -0
  236. package/templates/podcast-creator/l10n/es.json +10 -0
  237. package/templates/podcast-creator/l10n/fi.json +10 -0
  238. package/templates/podcast-creator/l10n/fr.json +10 -0
  239. package/templates/podcast-creator/l10n/he.json +8 -0
  240. package/templates/podcast-creator/l10n/hu.json +10 -0
  241. package/templates/podcast-creator/l10n/id.json +10 -0
  242. package/templates/podcast-creator/l10n/it.json +10 -0
  243. package/templates/podcast-creator/l10n/ja.json +10 -0
  244. package/templates/podcast-creator/l10n/ko.json +10 -0
  245. package/templates/podcast-creator/l10n/lt.json +10 -0
  246. package/templates/podcast-creator/l10n/nl.json +10 -0
  247. package/templates/podcast-creator/l10n/no.json +10 -0
  248. package/templates/podcast-creator/l10n/pl.json +10 -0
  249. package/templates/podcast-creator/l10n/pt.json +10 -0
  250. package/templates/podcast-creator/l10n/ru.json +10 -0
  251. package/templates/podcast-creator/l10n/sv.json +10 -0
  252. package/templates/podcast-creator/l10n/th.json +10 -0
  253. package/templates/podcast-creator/l10n/tr.json +10 -0
  254. package/templates/podcast-creator/l10n/uk.json +10 -0
  255. package/templates/podcast-creator/l10n/vi.json +10 -0
  256. package/templates/podcast-creator/l10n/zh.json +10 -0
  257. package/templates/podcast-creator/tier5-src/_shared/collection-contract.ts +6 -1
  258. package/templates/podcast-creator/tier5-src/_shared/himi-events.ts +27 -0
  259. package/templates/podcast-creator/tier5-src/himi-events-detail/index.ts +3 -1
  260. package/templates/podcast-creator/tier5-src/himi-events-list/index.ts +38 -8
  261. package/templates/podcast-creator/tier5-src/himi-events-my-events/index.ts +4 -2
  262. package/templates/podcast-creator-owner/tier5-src/_shared/collection-contract.ts +6 -1
  263. package/templates/podcast-creator-owner/tier5-src/_shared/himi-events.ts +27 -0
  264. package/templates/portfolio-creative/dev/index.ts +22 -1
  265. package/templates/portfolio-creative/l10n/ar.json +10 -0
  266. package/templates/portfolio-creative/l10n/cs.json +10 -0
  267. package/templates/portfolio-creative/l10n/da.json +10 -0
  268. package/templates/portfolio-creative/l10n/de.json +10 -0
  269. package/templates/portfolio-creative/l10n/el.json +10 -0
  270. package/templates/portfolio-creative/l10n/es.json +10 -0
  271. package/templates/portfolio-creative/l10n/fi.json +10 -0
  272. package/templates/portfolio-creative/l10n/fr.json +10 -0
  273. package/templates/portfolio-creative/l10n/he.json +8 -0
  274. package/templates/portfolio-creative/l10n/hu.json +10 -0
  275. package/templates/portfolio-creative/l10n/id.json +10 -0
  276. package/templates/portfolio-creative/l10n/it.json +10 -0
  277. package/templates/portfolio-creative/l10n/ja.json +10 -0
  278. package/templates/portfolio-creative/l10n/ko.json +10 -0
  279. package/templates/portfolio-creative/l10n/lt.json +10 -0
  280. package/templates/portfolio-creative/l10n/nl.json +10 -0
  281. package/templates/portfolio-creative/l10n/no.json +10 -0
  282. package/templates/portfolio-creative/l10n/pl.json +10 -0
  283. package/templates/portfolio-creative/l10n/pt.json +10 -0
  284. package/templates/portfolio-creative/l10n/ru.json +10 -0
  285. package/templates/portfolio-creative/l10n/sv.json +10 -0
  286. package/templates/portfolio-creative/l10n/th.json +10 -0
  287. package/templates/portfolio-creative/l10n/tr.json +10 -0
  288. package/templates/portfolio-creative/l10n/uk.json +10 -0
  289. package/templates/portfolio-creative/l10n/vi.json +10 -0
  290. package/templates/portfolio-creative/l10n/zh.json +10 -0
  291. package/templates/portfolio-creative/tier5-src/_shared/collection-contract.ts +6 -1
  292. package/templates/portfolio-creative/tier5-src/_shared/himi-events.ts +27 -0
  293. package/templates/portfolio-creative/tier5-src/_shared/portfolio-details.ts +70 -0
  294. package/templates/portfolio-creative/tier5-src/himi-branded-lite-portfolio/index.ts +90 -9
  295. package/templates/portfolio-creative/tier5-src/himi-branded-lite-portfolio-project/index.ts +53 -4
  296. package/templates/portfolio-creative/tier5-src/himi-events-detail/index.ts +3 -1
  297. package/templates/portfolio-creative/tier5-src/himi-events-list/index.ts +38 -8
  298. package/templates/portfolio-creative/tier5-src/himi-events-my-events/index.ts +4 -2
  299. package/templates/portfolio-creative-owner/tier5-src/_shared/collection-contract.ts +6 -1
  300. package/templates/portfolio-creative-owner/tier5-src/_shared/himi-events.ts +27 -0
  301. package/templates/professional-services/README.md +55 -0
  302. package/templates/professional-services/config.ts +436 -0
  303. package/templates/professional-services/dev/index.ts +44772 -0
  304. package/templates/professional-services/himalaya.content.json +100 -0
  305. package/templates/professional-services/himalaya.template.json +16 -0
  306. package/templates/professional-services/icon.png +0 -0
  307. package/templates/professional-services/platforms.json +1 -0
  308. package/templates/professional-services/tier5-src/_shared/app-locale.ts +70 -0
  309. package/templates/professional-services/tier5-src/_shared/booking-location.ts +147 -0
  310. package/templates/professional-services/tier5-src/_shared/booking-session.ts +224 -0
  311. package/templates/professional-services/tier5-src/_shared/branded-lite-hosted.ts +282 -0
  312. package/templates/professional-services/tier5-src/_shared/branded-load-state.ts +109 -0
  313. package/templates/professional-services/tier5-src/_shared/business-chat-copy.ts +40 -0
  314. package/templates/professional-services/tier5-src/_shared/business-chat-history.ts +51 -0
  315. package/templates/professional-services/tier5-src/_shared/business-chat-message-model.ts +177 -0
  316. package/templates/professional-services/tier5-src/_shared/business-chat-model.ts +56 -0
  317. package/templates/professional-services/tier5-src/_shared/business-chat-presenter.ts +587 -0
  318. package/templates/professional-services/tier5-src/_shared/business-chat-transport.ts +164 -0
  319. package/templates/professional-services/tier5-src/_shared/chat-live.ts +242 -0
  320. package/templates/professional-services/tier5-src/_shared/collection-contract.ts +232 -0
  321. package/templates/professional-services/tier5-src/_shared/collection-query.ts +201 -0
  322. package/templates/professional-services/tier5-src/_shared/collection-service.ts +429 -0
  323. package/templates/professional-services/tier5-src/_shared/detail-presence.ts +51 -0
  324. package/templates/professional-services/tier5-src/_shared/engine-intl.ts +538 -0
  325. package/templates/professional-services/tier5-src/_shared/event-registration.ts +86 -0
  326. package/templates/professional-services/tier5-src/_shared/events-inline-options.ts +77 -0
  327. package/templates/professional-services/tier5-src/_shared/faq-list.ts +405 -0
  328. package/templates/professional-services/tier5-src/_shared/featured-event.ts +63 -0
  329. package/templates/professional-services/tier5-src/_shared/group-member-count.ts +15 -0
  330. package/templates/professional-services/tier5-src/_shared/group-privacy.ts +14 -0
  331. package/templates/professional-services/tier5-src/_shared/guest-sign-in.ts +36 -0
  332. package/templates/professional-services/tier5-src/_shared/himi-account.ts +222 -0
  333. package/templates/professional-services/tier5-src/_shared/himi-blog-hidden.ts +66 -0
  334. package/templates/professional-services/tier5-src/_shared/himi-blog-post-row.ts +214 -0
  335. package/templates/professional-services/tier5-src/_shared/himi-blog-saved.ts +64 -0
  336. package/templates/professional-services/tier5-src/_shared/himi-booking-saved.ts +88 -0
  337. package/templates/professional-services/tier5-src/_shared/himi-bookings.ts +318 -0
  338. package/templates/professional-services/tier5-src/_shared/himi-copy.ts +123 -0
  339. package/templates/professional-services/tier5-src/_shared/himi-events.ts +92 -0
  340. package/templates/professional-services/tier5-src/_shared/himi-media.ts +33 -0
  341. package/templates/professional-services/tier5-src/_shared/himi-store.ts +7 -0
  342. package/templates/professional-services/tier5-src/_shared/himi-text.ts +24 -0
  343. package/templates/professional-services/tier5-src/_shared/host-events.ts +66 -0
  344. package/templates/professional-services/tier5-src/_shared/hosted-checkout.ts +70 -0
  345. package/templates/professional-services/tier5-src/_shared/iap-attendance-form.ts +106 -0
  346. package/templates/professional-services/tier5-src/_shared/iap-attendance-purchase.ts +235 -0
  347. package/templates/professional-services/tier5-src/_shared/iap-attendance.ts +38 -0
  348. package/templates/professional-services/tier5-src/_shared/iap-worker.ts +127 -0
  349. package/templates/professional-services/tier5-src/_shared/inbox-rooms.ts +163 -0
  350. package/templates/professional-services/tier5-src/_shared/local-preferences.ts +38 -0
  351. package/templates/professional-services/tier5-src/_shared/member-access.ts +63 -0
  352. package/templates/professional-services/tier5-src/_shared/member-account-routes.ts +56 -0
  353. package/templates/professional-services/tier5-src/_shared/member-avatar.ts +76 -0
  354. package/templates/professional-services/tier5-src/_shared/member-bookings.ts +107 -0
  355. package/templates/professional-services/tier5-src/_shared/member-read.ts +82 -0
  356. package/templates/professional-services/tier5-src/_shared/member-screen.ts +99 -0
  357. package/templates/professional-services/tier5-src/_shared/notification-target.ts +141 -0
  358. package/templates/professional-services/tier5-src/_shared/offset-page.ts +10 -0
  359. package/templates/professional-services/tier5-src/_shared/online-actions.ts +76 -0
  360. package/templates/professional-services/tier5-src/_shared/owner-load-error.ts +348 -0
  361. package/templates/professional-services/tier5-src/_shared/payment-setup.ts +6 -0
  362. package/templates/professional-services/tier5-src/_shared/portfolio-details.ts +70 -0
  363. package/templates/professional-services/tier5-src/_shared/pricing-plan-display.ts +64 -0
  364. package/templates/professional-services/tier5-src/_shared/relative-time.ts +21 -0
  365. package/templates/professional-services/tier5-src/_shared/result-snackbar.ts +26 -0
  366. package/templates/professional-services/tier5-src/_shared/rich-body.ts +78 -0
  367. package/templates/professional-services/tier5-src/_shared/rich-content-link.ts +34 -0
  368. package/templates/professional-services/tier5-src/_shared/sign-in-sheet.ts +18 -0
  369. package/templates/professional-services/tier5-src/_shared/staff-name.ts +18 -0
  370. package/templates/professional-services/tier5-src/_shared/weekly-goal.ts +111 -0
  371. package/templates/professional-services/tier5-src/_shared/wix-bi.ts +85 -0
  372. package/templates/professional-services/tier5-src/_shared/wix-member-links.ts +114 -0
  373. package/templates/professional-services/tier5-src/_shared/wix-service-price.ts +146 -0
  374. package/templates/professional-services/tier5-src/business-chat/index.ts +797 -0
  375. package/templates/professional-services/tier5-src/business-contact/index.ts +6 -0
  376. package/templates/professional-services/tier5-src/himi-blog-feed/index.ts +444 -0
  377. package/templates/professional-services/tier5-src/himi-blog-post/index.ts +1239 -0
  378. package/templates/professional-services/tier5-src/himi-booking-account/index.ts +278 -0
  379. package/templates/professional-services/tier5-src/himi-booking-bookings/index.ts +475 -0
  380. package/templates/professional-services/tier5-src/himi-booking-service/index.ts +1197 -0
  381. package/templates/professional-services/tier5-src/himi-booking-services/index.ts +795 -0
  382. package/templates/professional-services/tier5-src/himi-booking-time/index.ts +1840 -0
  383. package/templates/professional-services/tier5-src/himi-branded-lite-coupons/index.ts +96 -0
  384. package/templates/professional-services/tier5-src/himi-branded-lite-faq/index.ts +6 -0
  385. package/templates/professional-services/tier5-src/himi-branded-lite-file-share/index.ts +12 -0
  386. package/templates/professional-services/tier5-src/himi-branded-lite-group/index.ts +310 -0
  387. package/templates/professional-services/tier5-src/himi-branded-lite-group-about/index.ts +240 -0
  388. package/templates/professional-services/tier5-src/himi-branded-lite-my-groups/index.ts +237 -0
  389. package/templates/professional-services/tier5-src/himi-branded-lite-notifications/index.ts +263 -0
  390. package/templates/professional-services/tier5-src/himi-branded-lite-plans/index.ts +498 -0
  391. package/templates/professional-services/tier5-src/himi-branded-lite-portfolio/index.ts +136 -0
  392. package/templates/professional-services/tier5-src/himi-branded-lite-portfolio-project/index.ts +198 -0
  393. package/templates/professional-services/tier5-src/himi-events-detail/index.ts +1306 -0
  394. package/templates/professional-services/tier5-src/himi-events-list/index.ts +171 -0
  395. package/templates/professional-services/tier5-src/himi-events-my-events/index.ts +227 -0
  396. package/templates/professional-services/tier5-src/himi-events-rsvp/index.ts +230 -0
  397. package/templates/professional-services/tier5-src/himi-professional-services-community/index.ts +318 -0
  398. package/templates/professional-services/tier5-src/himi-professional-services-home/index.ts +772 -0
  399. package/templates/professional-services/tier5-src/himi-store-account/index.ts +1514 -0
  400. package/templates/professional-services/tier5-src/wix-spaces-coupon-detail/index.ts +43 -0
  401. package/templates/professional-services/tier5-src/wix-spaces-my-subscriptions/index.ts +89 -0
  402. package/templates/professional-services/tier5-src/wix-spaces-subscription-detail/index.ts +139 -0
  403. package/templates/professional-services/tokens.json +456 -0
  404. package/templates/restaurant/dev/index.ts +20 -0
  405. package/templates/restaurant/l10n/ar.json +10 -0
  406. package/templates/restaurant/l10n/cs.json +10 -0
  407. package/templates/restaurant/l10n/da.json +10 -0
  408. package/templates/restaurant/l10n/de.json +10 -0
  409. package/templates/restaurant/l10n/el.json +10 -0
  410. package/templates/restaurant/l10n/es.json +10 -0
  411. package/templates/restaurant/l10n/fi.json +10 -0
  412. package/templates/restaurant/l10n/fr.json +10 -0
  413. package/templates/restaurant/l10n/he.json +8 -0
  414. package/templates/restaurant/l10n/hu.json +10 -0
  415. package/templates/restaurant/l10n/id.json +10 -0
  416. package/templates/restaurant/l10n/it.json +10 -0
  417. package/templates/restaurant/l10n/ja.json +10 -0
  418. package/templates/restaurant/l10n/ko.json +10 -0
  419. package/templates/restaurant/l10n/lt.json +10 -0
  420. package/templates/restaurant/l10n/nl.json +10 -0
  421. package/templates/restaurant/l10n/no.json +10 -0
  422. package/templates/restaurant/l10n/pl.json +10 -0
  423. package/templates/restaurant/l10n/pt.json +10 -0
  424. package/templates/restaurant/l10n/ru.json +10 -0
  425. package/templates/restaurant/l10n/sv.json +10 -0
  426. package/templates/restaurant/l10n/th.json +10 -0
  427. package/templates/restaurant/l10n/tr.json +10 -0
  428. package/templates/restaurant/l10n/uk.json +10 -0
  429. package/templates/restaurant/l10n/vi.json +10 -0
  430. package/templates/restaurant/l10n/zh.json +10 -0
  431. package/templates/restaurant/tier5-src/_shared/collection-contract.ts +6 -1
  432. package/templates/restaurant/tier5-src/_shared/himi-events.ts +27 -0
  433. package/templates/restaurant/tier5-src/himi-events-detail/index.ts +3 -1
  434. package/templates/restaurant/tier5-src/himi-events-list/index.ts +38 -8
  435. package/templates/restaurant/tier5-src/himi-events-my-events/index.ts +4 -2
  436. package/templates/restaurant-owner/tier5-src/_shared/collection-contract.ts +6 -1
  437. package/templates/restaurant-owner/tier5-src/_shared/himi-events.ts +27 -0
  438. package/templates/retail-store/tier5-src/_shared/collection-contract.ts +6 -1
  439. package/templates/retail-store/tier5-src/_shared/himi-events.ts +27 -0
  440. package/templates/retail-store-owner/tier5-src/_shared/collection-contract.ts +6 -1
  441. package/templates/retail-store-owner/tier5-src/_shared/himi-events.ts +27 -0
  442. package/templates/salon-spa/config.ts +42 -0
  443. package/templates/salon-spa/dev/index.ts +4136 -0
  444. package/templates/salon-spa/himalaya.content.json +18 -0
  445. package/templates/salon-spa/tier5-src/_shared/collection-contract.ts +6 -1
  446. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  447. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  448. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  449. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  450. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  451. package/templates/salon-spa/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  452. package/templates/salon-spa/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  453. package/templates/wholesale-store/config.ts +43 -1
  454. package/templates/wholesale-store/dev/index.ts +4136 -0
  455. package/templates/wholesale-store/himalaya.content.json +18 -0
  456. package/templates/wholesale-store/tier5-src/_shared/collection-contract.ts +6 -1
  457. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/blocked-members.ts +295 -0
  458. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/index.ts +58 -0
  459. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/login-info.ts +274 -0
  460. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/personal-info.ts +881 -0
  461. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/privacy.ts +139 -0
  462. package/templates/wholesale-store/tier5-src/himi-branded-lite-account-settings/shared.ts +136 -0
  463. package/templates/wholesale-store/tier5-src/wix-spaces-delete-account/index.ts +59 -0
  464. package/templates/yoga-studio/dev/index.ts +20 -0
  465. package/templates/yoga-studio/l10n/ar.json +10 -0
  466. package/templates/yoga-studio/l10n/cs.json +10 -0
  467. package/templates/yoga-studio/l10n/da.json +10 -0
  468. package/templates/yoga-studio/l10n/de.json +10 -0
  469. package/templates/yoga-studio/l10n/el.json +10 -0
  470. package/templates/yoga-studio/l10n/es.json +10 -0
  471. package/templates/yoga-studio/l10n/fi.json +10 -0
  472. package/templates/yoga-studio/l10n/fr.json +10 -0
  473. package/templates/yoga-studio/l10n/he.json +8 -0
  474. package/templates/yoga-studio/l10n/hu.json +10 -0
  475. package/templates/yoga-studio/l10n/id.json +10 -0
  476. package/templates/yoga-studio/l10n/it.json +10 -0
  477. package/templates/yoga-studio/l10n/ja.json +10 -0
  478. package/templates/yoga-studio/l10n/ko.json +10 -0
  479. package/templates/yoga-studio/l10n/lt.json +10 -0
  480. package/templates/yoga-studio/l10n/nl.json +10 -0
  481. package/templates/yoga-studio/l10n/no.json +10 -0
  482. package/templates/yoga-studio/l10n/pl.json +10 -0
  483. package/templates/yoga-studio/l10n/pt.json +10 -0
  484. package/templates/yoga-studio/l10n/ru.json +10 -0
  485. package/templates/yoga-studio/l10n/sv.json +10 -0
  486. package/templates/yoga-studio/l10n/th.json +10 -0
  487. package/templates/yoga-studio/l10n/tr.json +10 -0
  488. package/templates/yoga-studio/l10n/uk.json +10 -0
  489. package/templates/yoga-studio/l10n/vi.json +10 -0
  490. package/templates/yoga-studio/l10n/zh.json +10 -0
  491. package/templates/yoga-studio/tier5-src/_shared/collection-contract.ts +6 -1
  492. package/templates/yoga-studio/tier5-src/_shared/himi-events.ts +27 -0
  493. package/templates/yoga-studio/tier5-src/himi-events-detail/index.ts +3 -1
  494. package/templates/yoga-studio/tier5-src/himi-events-list/index.ts +38 -8
  495. package/templates/yoga-studio/tier5-src/himi-events-my-events/index.ts +4 -2
  496. package/templates/yoga-studio-owner/tier5-src/_shared/collection-contract.ts +6 -1
  497. package/templates/yoga-studio-owner/tier5-src/_shared/himi-events.ts +27 -0
@@ -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,163 @@
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
+ import { calendarDay, formatClock, formatMonthDay, formatWeekdayShort } from "./engine-intl.js";
4
+
5
+ type RecordValue = Record<string, unknown>;
6
+ const object = (value: unknown): RecordValue =>
7
+ value !== null && typeof value === "object" && !Array.isArray(value) ? value as RecordValue : {};
8
+
9
+ /** The two-party room between the member and the business (the Smart Chat room). Another member's
10
+ * room has no `businessContext`, and a contact-less room is not the business's. */
11
+ export function isBusinessRoom(value: unknown): boolean {
12
+ const room = object(value);
13
+ return typeof room.id === "string" && !!room.id &&
14
+ typeof room.participantId === "string" && !!room.participantId &&
15
+ room.participantCount === 2 && room.clientReferenceType === "contactId" &&
16
+ Object.keys(object(room.businessContext)).length > 0;
17
+ }
18
+
19
+ export const BUSINESS_SCREEN = "himi_business_chat";
20
+
21
+ export interface InboxRow {
22
+ id: string;
23
+ title: string;
24
+ subtitle: string;
25
+ /** The screen a tap opens: the business chat for the business room, a thread for any other. */
26
+ screenId: "himi_business_chat" | "himi_chat_thread";
27
+ /** `chatroom` makes the thread use `id` as the room instead of resolving it as a member id. */
28
+ kind: "chatroom" | "";
29
+ photo: string;
30
+ /** The business's own room. Set from the room, never from `screenId`, which a host may route elsewhere. */
31
+ business: boolean;
32
+ /** No photo on a member's room: the screen draws grey initials. Always false for the business, which keeps the solid
33
+ * accent avatar (kept with the photo by completeRow). */
34
+ noPhoto: boolean;
35
+ initial: string;
36
+ /** Has unread messages, or the member marked it unread. */
37
+ unread: boolean;
38
+ /** "●" when unread, else "". Kept for the screens that bind the glyph. */
39
+ unreadDot: string;
40
+ /** The server's unread count; 0 when none, or when the member marked a room unread (the count is then unknown). */
41
+ unreadCount: number;
42
+ /** The count as text: "" for 0 or unknown, "99+" above 99. */
43
+ unreadText: string;
44
+ /** hiddenWhen gates in both polarities: a count badge when the count is known, a plain dot when the room is
45
+ * unread but the count is not. */
46
+ showCount: boolean; hideCount: boolean; showDot: boolean; hideDot: boolean;
47
+ /** Last activity: the time today, "Yesterday", the weekday within the last six calendar days (as chat lists show it,
48
+ * not the calendar week), else the day. "" when unknown. */
49
+ dateLabel: string;
50
+ isArchived: boolean;
51
+ /** Only a private room can be deleted by a member (the Wix app's rule). */
52
+ isPrivate: boolean;
53
+ /** Swipe-action gates (hiddenWhen hides on TRUE). */
54
+ hideArchive: boolean; hideUnarchive: boolean; hideDelete: boolean; hideMarkRead: boolean; hideMarkUnread: boolean;
55
+ /** Sort key only; not bound to the screen. */
56
+ at: number;
57
+ }
58
+
59
+ const text = (value: unknown): string => (typeof value === "string" ? value.trim() : "");
60
+ const MAX_COUNT = 99;
61
+
62
+ /** "" for 0 or an unknown count, "99+" above 99. */
63
+ export const unreadCountText = (count: number): string => (count > MAX_COUNT ? `${MAX_COUNT}+` : count > 0 ? String(count) : "");
64
+
65
+ /** Everything that follows from a row's base fields. The one place a flag is derived, so a row that changes
66
+ * (marked read, archived) can never carry a flag that disagrees with its base fields. */
67
+ export type RowBase = Pick<InboxRow, "id" | "title" | "subtitle" | "screenId" | "kind" | "business" | "photo" | "initial" | "unread" | "unreadCount" | "dateLabel" | "isArchived" | "isPrivate" | "at">;
68
+ export function completeRow(base: RowBase): InboxRow {
69
+ const unreadText = unreadCountText(base.unreadCount);
70
+ const showCount = base.unread && unreadText !== "";
71
+ const showDot = base.unread && !showCount;
72
+ return {
73
+ ...base,
74
+ // Grey initials are for members: the business row keeps the solid accent avatar, photo or not.
75
+ noPhoto: !base.photo && !base.business,
76
+ unreadDot: base.unread ? "●" : "",
77
+ unreadText,
78
+ showCount, hideCount: !showCount, showDot, hideDot: !showDot,
79
+ hideArchive: base.isArchived, hideUnarchive: !base.isArchived,
80
+ hideDelete: !base.isPrivate,
81
+ hideMarkRead: !base.unread, hideMarkUnread: base.unread,
82
+ };
83
+ }
84
+
85
+ /** A row's read state changed: `count` is the server's count (0 = unknown or none). */
86
+ export function withUnread(row: InboxRow, unread: boolean, count: number): InboxRow {
87
+ const { id, title, subtitle, screenId, kind, business, photo, initial, dateLabel, isArchived, isPrivate, at } = row;
88
+ return completeRow({ id, title, subtitle, screenId, kind, business, photo, initial, dateLabel, isArchived, isPrivate, at, unread, unreadCount: unread ? count : 0 });
89
+ }
90
+
91
+ /** Last-activity label in the device's zone: today → the time, yesterday → [yesterday] (the caller passes the localised
92
+ * word), within the last six calendar days → the weekday, otherwise the day. "" for an unknown time. Days are calendar
93
+ * days (local midnight to midnight), never 24-hour spans, so one day never gets two label formats and DST cannot shift them. */
94
+ export function dateLabel(at: number, yesterday: string, now: number = Date.now()): string {
95
+ if (!Number.isFinite(at) || at <= 0) return "";
96
+ const date = new Date(at);
97
+ const day = calendarDay(date);
98
+ if (day === calendarDay(new Date(now))) return formatClock(date);
99
+ const today = new Date(now);
100
+ // Noon of the previous calendar day: a 23- or 25-hour day around DST cannot move it to another day.
101
+ if (day === calendarDay(new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1, 12))) return yesterday;
102
+ const sixDaysBack = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 6).getTime();
103
+ if (at >= sixDaysBack && at <= now) return formatWeekdayShort(date);
104
+ return formatMonthDay(date);
105
+ }
106
+
107
+ function titleOf(room: RecordValue, business: boolean): string {
108
+ const display = text(object(room.displayData).name);
109
+ if (business) return text(object(room.businessContext).name) || display;
110
+ return display;
111
+ }
112
+
113
+ export interface InboxRowsOptions {
114
+ /** `inbox` (default): archived rooms are dropped. `archive`: the list is the archive, every room is kept and marked
115
+ * archived. `all`: search results, kept as they are. */
116
+ scope?: "inbox" | "archive" | "all";
117
+ /** The localised word for yesterday; "Yesterday" when absent. */
118
+ yesterday?: string;
119
+ now?: number;
120
+ /** Rooms the server lists as unread (`unreadChatroomIds`): a room the member marked unread has no count, only this. */
121
+ unreadIds?: ReadonlySet<string>;
122
+ }
123
+
124
+ /** Newest conversation first; rooms without an id are dropped, and so are archived rooms in the inbox. `fallbackTitle`
125
+ * names a room that carries no name (the caller passes the localised word, not a hard-coded English one). */
126
+ export function inboxRows(rooms: unknown[], fallbackTitle: string, options: InboxRowsOptions = {}): InboxRow[] {
127
+ const { scope = "inbox", yesterday = "Yesterday", now, unreadIds } = options;
128
+ const rows: InboxRow[] = [];
129
+ for (const value of rooms) {
130
+ const room = object(value);
131
+ const id = text(room.id);
132
+ if (!id) continue;
133
+ if (scope === "inbox" && room.isArchived === true) continue;
134
+ const business = isBusinessRoom(room);
135
+ const title = titleOf(room, business) || fallbackTitle;
136
+ const last = object(room.lastMessage);
137
+ const count = typeof room.unreadCount === "number" && Number.isFinite(room.unreadCount) && room.unreadCount > 0 ? Math.floor(room.unreadCount) : 0;
138
+ const at = typeof last.createdAt === "number" ? last.createdAt : typeof room.createdAt === "number" ? room.createdAt : 0;
139
+ rows.push(completeRow({
140
+ id,
141
+ title,
142
+ subtitle: text(last.summary),
143
+ screenId: business ? BUSINESS_SCREEN : "himi_chat_thread",
144
+ kind: business ? "" : "chatroom",
145
+ business,
146
+ photo: text(object(object(room.displayData).image).url),
147
+ initial: (title[0] ?? "#").toUpperCase(),
148
+ unread: count > 0 || unreadIds?.has(id) === true,
149
+ unreadCount: count,
150
+ dateLabel: dateLabel(at, yesterday, now),
151
+ isArchived: scope === "archive" || room.isArchived === true,
152
+ isPrivate: room.isPrivate === true,
153
+ at,
154
+ }));
155
+ }
156
+ return rows.sort((a, b) => b.at - a.at);
157
+ }
158
+
159
+ /** The newest message sequence a room's list entry carries, when it carries one (marking a room read needs it). */
160
+ export function lastSequenceOf(value: unknown): number | undefined {
161
+ const sequence = object(object(value).lastMessage).sequence;
162
+ return typeof sequence === "number" && Number.isSafeInteger(sequence) && sequence >= 0 ? sequence : undefined;
163
+ }
@@ -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,56 @@
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
+ /** The web host: a preview of the app, never a member's real device. Account settings say
42
+ * "in preview mode" there, and "here" in every other case it cannot change a password. */
43
+ webPreview: boolean;
44
+ }
45
+
46
+ export async function memberAccountRoutes(): Promise<MemberAccountRoutes> {
47
+ const info = await getAppInfo().catch(() => undefined);
48
+ // A hosted app reaches none of these routes, but a hosted web build is still a preview.
49
+ if (isHostedWorker()) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: info?.platform === "web" };
50
+ if (!info) return { addresses: false, wallet: false, mediaField: false, passwordCredentials: false, webPreview: false };
51
+ const native = info.platform === "ios" || info.platform === "android" || info.platform === "macos";
52
+ const addresses = native && atLeast(info.binaryVersion ?? "", MEMBER_ACCOUNT_ROUTES_MIN_BINARY);
53
+ const mediaField = native && atLeast(info.binaryVersion ?? "", MEMBER_MEDIA_FIELD_MIN_BINARY);
54
+ const passwordCredentials = native && atLeast(info.binaryVersion ?? "", MEMBER_PASSWORD_ACTIONS_MIN_BINARY);
55
+ return { addresses, wallet: addresses && info.memberSiteBound === true, mediaField, passwordCredentials, webPreview: info.platform === "web" };
56
+ }
@@ -0,0 +1,76 @@
1
+ // The signed-in member's photo and initials for a top-bar avatar on a SHARED list screen
2
+ // (`defineBackendCollection({ memberAvatar })`). A screen opts in with the onAppear param
3
+ // `memberAvatar: "1"`; a screen that does not ask pays nothing. A visitor costs one local
4
+ // identity read per load. A member's profile is read again on each visit, while the last photo
5
+ // stays on screen, so a photo or name saved in Personal info reaches this bar on the next visit.
6
+ import { loadMemberProfile, memberIdentity } from "./himi-account.js";
7
+
8
+ /** The state keys the avatar item binds (`$service:<name>.memberImage` / `.memberInitials`). */
9
+ export const MEMBER_AVATAR_KEYS = ["memberImage", "memberInitials"] as const;
10
+ export interface MemberAvatarFields { memberImage: string; memberInitials: string }
11
+ const NONE: MemberAvatarFields = { memberImage: "", memberInitials: "" };
12
+
13
+ export interface MemberAvatarSource {
14
+ /** The state keys this source writes: kept out of a persisted or restored snapshot. */
15
+ readonly keys: readonly string[];
16
+ /** The load action's argument: starts a read when the screen asked for the avatar. */
17
+ onLoad(arg: unknown): void;
18
+ /** The state with the avatar fields, once the screen asked for them. */
19
+ merge<T extends object>(state: T): T;
20
+ /** Call once after registration. A runtime that ignores `notHydrated` restored the last run's
21
+ * photo on a cold boot (maybe another member's): clear it until this run reads its own. */
22
+ resetRestored(svc: { getState(): unknown }): void;
23
+ }
24
+ export type MemberAvatarFactory = (changed: () => void) => MemberAvatarSource;
25
+
26
+ export interface MemberAvatarReads {
27
+ identity(): Promise<{ email: string; signedIn: boolean }>;
28
+ profile(): Promise<{ isMember: boolean; memberImage: string; memberInitials: string } | undefined>;
29
+ }
30
+ const LIVE: MemberAvatarReads = { identity: memberIdentity, profile: () => loadMemberProfile("").catch(() => undefined) };
31
+
32
+ const asked = (arg: unknown): boolean => {
33
+ const value = arg && typeof arg === "object" ? (arg as { memberAvatar?: unknown }).memberAvatar : undefined;
34
+ return value === "1" || value === true;
35
+ };
36
+
37
+ /** `changed` republishes the list's state (the collection's `collectionDataChanged`). */
38
+ export function memberAvatarSource(changed: () => void, reads: MemberAvatarReads = LIVE): MemberAvatarSource {
39
+ let wanted = false;
40
+ let fields = NONE;
41
+ let seq = 0;
42
+ async function read(): Promise<MemberAvatarFields> {
43
+ const who = await reads.identity();
44
+ if (!who.signedIn) return NONE;
45
+ // No per-account cache: no worker is told when Personal info saves a new photo or name, so
46
+ // only a fresh read sees it. The last fields stay on screen until this read answers.
47
+ const profile = await reads.profile();
48
+ if (!profile?.isMember) return NONE;
49
+ return { memberImage: profile.memberImage, memberInitials: profile.memberInitials };
50
+ }
51
+ return {
52
+ keys: MEMBER_AVATAR_KEYS,
53
+ onLoad(arg) {
54
+ if (!asked(arg)) return;
55
+ wanted = true;
56
+ const mine = ++seq;
57
+ void read().then((next) => {
58
+ // A later load (a sign-out, another account) owns the result.
59
+ if (mine !== seq) return;
60
+ if (next.memberImage === fields.memberImage && next.memberInitials === fields.memberInitials) return;
61
+ fields = next;
62
+ changed();
63
+ }, () => undefined);
64
+ },
65
+ merge(state) {
66
+ return wanted ? { ...state, ...fields } : state;
67
+ },
68
+ resetRestored(svc) {
69
+ // The same signal `resetUnhydratedKeysOnOlderRuntime` (iap-worker.ts) reads.
70
+ if ((globalThis as { himalaya?: { hydrationOptOut?: unknown } }).himalaya?.hydrationOptOut === true) return;
71
+ const booted = svc.getState();
72
+ if (!booted || typeof booted !== "object") return;
73
+ for (const key of MEMBER_AVATAR_KEYS) (booted as Record<string, unknown>)[key] = "";
74
+ },
75
+ };
76
+ }
@@ -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
+ }